Re: [FFmpeg-devel] [PATCH] libavformat/internal.h - Adjust MAX_URL_SIZE to 8k
Updated patch attached On Sun, May 10, 2020 at 3:19 AM Marton Balint wrote: > > > On Sun, 10 May 2020, Joey Smith wrote: > > > Actually, that seems like a more rational fix all around - I just saw the > > BUFFER_SIZE in > > http.c being limited to MAX_URL_SIZE and jumped straight to expanding > that, > > but in > > looking at your suggestion, I see now there's an HTTP_HEADERS_SIZE that > > appears > > to be defined but then never used. Do you want a new patch for that, or > is > > it easier for > > you guys to just go ahead and do that on your end? > > Please send an updated patch. > > Thanks, > Marton > > > > > On Sun, May 10, 2020 at 2:17 AM Marton Balint wrote: > > > >> > >> > >> On Sun, 10 May 2020, Joey Smith wrote: > >> > >> > Some real-world sites use an authorization header with a bearer token; > >> when > >> > combined with lengthy request parameters to identify the video > segment, > >> > it's rather trivial these days to have a request body of more than 4k > >> bytes. > >> > > >> > Because MAX_URL_SIZE is hard-coded to 4k bytes in > libavformat/internal.h, > >> > this causes ffmpeg to terminate the connection early, even though the > >> HTTP > >> > request is otherwise perfectly valid. > >> > >> If that is the case then BUFFER_SIZE should be increased instead to > >> (MAX_URL_SIZE + HTTP_HEADERS_SIZE) at http.c, no? > >> > >> Thanks, > >> Marton > >> ___ > >> ffmpeg-devel mailing list > >> ffmpeg-devel@ffmpeg.org > >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > >> > >> To unsubscribe, visit link above, or email > >> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > > ___ > > ffmpeg-devel mailing list > > ffmpeg-devel@ffmpeg.org > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > To unsubscribe, visit link above, or email > > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". 0001-libavformat-http.c-BUFFER_SIZE-MAX_URL_SIZE-HTTP_HEA.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] hwcontext_vulkan: let users enable device and instance extensions using options
May 10, 2020, 22:23 by s...@jkqxz.net: >> >> +for (int i = 0; i < dev_info.enabledExtensionCount; i++) >> +av_free((void *)dev_info.ppEnabledExtensionNames[i]); >> av_free((void *)dev_info.ppEnabledExtensionNames); >> >> if (ret != VK_SUCCESS) { >> -- >> 2.26.2 >> > > LGTM with that fixed. > Fixed. Checked whether the entire function to see if it frees everything correctly under failure, it does now. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/2] hwcontext_vulkan: expose enabled device and instance extensions
May 10, 2020, 22:39 by s...@jkqxz.net: > On 10/05/2020 15:23, Lynne wrote: > >> May 10, 2020, 14:33 by s...@jkqxz.net: >> >>> On 10/05/2020 11:54, Lynne wrote: >>> ... >> >> From 6ecc3547bcfcc450c8ffe8d93a3040fd863f6288 Mon Sep 17 00:00:00 2001 >> From: Lynne >> Date: Sun, 10 May 2020 11:47:50 +0100 >> Subject: [PATCH 2/3] hwcontext_vulkan: expose enabled device and instance >> extensions >> >> This solves a huge oversight - it lets users reliably use their own >> AVVulkanDeviceContext. Otherwise, the extensions supplied and enabled >> are not discoverable by anything outside of hwcontext_vulkan. >> --- >> doc/APIchanges | 4 >> libavutil/hwcontext_vulkan.c | 40 >> libavutil/hwcontext_vulkan.h | 21 ++- >> libavutil/version.h | 2 +- >> 4 files changed, 56 insertions(+), 11 deletions(-) >> >> diff --git a/doc/APIchanges b/doc/APIchanges >> index b3e7e89412..75cfdb08b0 100644 >> --- a/doc/APIchanges >> +++ b/doc/APIchanges >> @@ -15,6 +15,10 @@ libavutil: 2017-10-21 >> >> API changes, most recent first: >> >> +2020-05-10 - xx - lavu 56.44.100 - hwcontext_vulkan.h >> + Add enabled_inst_extensions, num_enabled_inst_extensions, >> enabled_dev_extensions >> + and num_enabled_dev_extensions fields to AVVulkanDeviceContext >> + >> 2020-04-22 - 0e1db79e37 - lavc 58.81.100 - packet.h >> - lavu 56.43.100 - dovi_meta.h >> Add AV_PKT_DATA_DOVI_CONF and AVDOVIDecoderConfigurationRecord. >> ... >> diff --git a/libavutil/hwcontext_vulkan.h b/libavutil/hwcontext_vulkan.h >> index ebc28916f3..909f88a7e4 100644 >> --- a/libavutil/hwcontext_vulkan.h >> +++ b/libavutil/hwcontext_vulkan.h >> @@ -39,7 +39,7 @@ typedef struct AVVulkanDeviceContext { >> */ >> const VkAllocationCallbacks *alloc; >> /** >> - * Instance >> + * Vulkan instance. Must be at least version 1.1. >> */ >> VkInstance inst; >> /** >> @@ -65,6 +65,25 @@ typedef struct AVVulkanDeviceContext { >> * Queue family index for compute ops >> */ >> int queue_family_comp_index; >> +/** >> + * Enabled instance extensions. By default, VK_KHR_surface is enabled >> if found. >> + * If supplying your own device context, set this to an array of >> strings, with >> + * each entry containing the specified Vulkan extension string to >> enable. >> + * Duplicates are possible and accepted. >> + * If no extensions are enabled, set these fields to NULL, and 0 >> respectively. >> + */ >> +const char * const *enabled_inst_extensions; >> +int num_enabled_inst_extensions; >> +/** >> + * Enabled device extensions. By default, VK_KHR_external_memory_fd, >> + * VK_EXT_external_memory_dma_buf, VK_EXT_image_drm_format_modifier and >> + * VK_KHR_external_semaphore_fd are enabled if found. >> + * If supplying your own device context, these fields takes the same >> format as >> + * the above fields, with the same conditions that duplicates are >> possible >> + * and accepted, and that NULL and 0 respectively means no extensions >> are enabled. >> + */ >> > > That's much clearer, thank you :) > >> +const char * const *enabled_dev_extensions; >> +int num_enabled_dev_extensions; >> > > A minor stylistic niggle - fields like this are "nb_something" rather than > "num_something" in pretty much all other ffmpeg headers. > Pushed with that change, thanks for reviewing. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] avcodec/mpegvideo: prefer to use variable instead of type for sizeof
On Mon, May 11, 2020 at 01:22:24AM +0200, Marton Balint wrote: > > > On Mon, 11 May 2020, lance.lmw...@gmail.com wrote: > > > On Sun, May 10, 2020 at 06:30:41PM +0200, Marton Balint wrote: > > > > > > > > > On Sun, 10 May 2020, lance.lmw...@gmail.com wrote: > > > > > > > From: Limin Wang > > > > > Signed-off-by: Limin Wang > > > > --- > > > > libavcodec/mpegvideo.c | 48 > > > > > > > > 1 file changed, 24 insertions(+), 24 deletions(-) > > > > > > If you find these cosmetics interesting, then I suggest you introduce a > > > new > > > macro instead: FF_ALLOCZ_ARRAY_OR_GOTO(). > > > > > > E.g.: > > > > > > FF_ALLOCZ_ARRAY_OR_GOTO(s->avctx, s->me.map, ME_MAP_SIZE, fail) > > > > Yeah, I have considered it so I change the type to use use variable first > > and > > submit one typical for review. If the change is OK, then I'll go ahead next. > > No need to do it in two steps, better touch the code once. E.g. patch 2 > might not even be needed if you do this in a single patch. Sorry, now for array alloc, you had to input the one elemeay size and its count always. internal.h have defined it already: FF_ALLOCZ_ARRAY_OR_GOTO(ctx, p, nelem, elsize, label) You don't want to input elsize? isn't general usage? > > Regards, > Marton > > > > > > > > > Regards, > > > Marton > > > > > > > > diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c > > > > index 49fd1c9..561062f 100644 > > > > --- a/libavcodec/mpegvideo.c > > > > +++ b/libavcodec/mpegvideo.c > > > > @@ -373,15 +373,15 @@ static int init_duplicate_context(MpegEncContext > > > > *s) > > > > > if (s->encoding) { > > > > FF_ALLOCZ_OR_GOTO(s->avctx, s->me.map, > > > > - ME_MAP_SIZE * sizeof(uint32_t), fail) > > > > + ME_MAP_SIZE * sizeof(*s->me.map), fail) > > > > FF_ALLOCZ_OR_GOTO(s->avctx, s->me.score_map, > > > > - ME_MAP_SIZE * sizeof(uint32_t), fail) > > > > + ME_MAP_SIZE * sizeof(*s->me.score_map), fail) > > > > if (s->noise_reduction) { > > > > FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_error_sum, > > > > - 2 * 64 * sizeof(int), fail) > > > > + 2 * 64 * sizeof(*s->dct_error_sum), fail) > > > > } > > > > } > > > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->blocks, 64 * 12 * 2 * > > > > sizeof(int16_t), fail) > > > > +FF_ALLOCZ_OR_GOTO(s->avctx, s->blocks, 64 * 12 * 2 * > > > > sizeof(*s->blocks), fail) > > > > s->block = s->blocks[0]; > > > > > for (i = 0; i < 12; i++) { > > > > @@ -400,7 +400,7 @@ static int init_duplicate_context(MpegEncContext *s) > > > > if (s->out_format == FMT_H263) { > > > > /* ac values */ > > > > FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_val_base, > > > > - yc_size * sizeof(int16_t) * 16, fail); > > > > + yc_size * sizeof(*s->ac_val_base) * 16, > > > > fail); > > > > s->ac_val[0] = s->ac_val_base + s->b8_stride + 1; > > > > s->ac_val[1] = s->ac_val_base + y_size + s->mb_stride + 1; > > > > s->ac_val[2] = s->ac_val[1] + c_size; > > > > @@ -715,7 +715,7 @@ static int init_context_frame(MpegEncContext *s) > > > > if (s->mb_height & 1) > > > > yc_size += 2*s->b8_stride + 2*s->mb_stride; > > > > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) > > > * sizeof(int), > > > > +FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * > > > > sizeof(*s->mb_index2xy), > > > > fail); // error resilience code looks cleaner > > > > with this > > > > for (y = 0; y < s->mb_height; y++) > > > > for (x = 0; x < s->mb_width; x++) > > > > @@ -725,12 +725,12 @@ static int init_context_frame(MpegEncContext *s) > > > > > if (s->encoding) { > > > > /* Allocate MV tables */ > > > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base, > > > > mv_table_size * 2 * sizeof(int16_t), fail) > > > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base, > > > > mv_table_size * 2 * sizeof(int16_t), fail) > > > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base, > > > > mv_table_size * 2 * sizeof(int16_t), fail) > > > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base, > > > > mv_table_size * 2 * sizeof(int16_t), fail) > > > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base, > > > > mv_table_size * 2 * sizeof(int16_t), fail) > > > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base, > > > > mv_table_size * 2 * sizeof(int16_t), fail) > > > > +FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base, > > > > mv_table_size * 2 * sizeof(*s->p_mv_table_base), fail) > > > > +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base, > > > > mv_table_size * 2 * s
Re: [FFmpeg-devel] [PATCH 1/2] avcodec/mpegvideo: prefer to use variable instead of type for sizeof
On Mon, May 11, 2020 at 01:22:24AM +0200, Marton Balint wrote: > > > On Mon, 11 May 2020, lance.lmw...@gmail.com wrote: > > > On Sun, May 10, 2020 at 06:30:41PM +0200, Marton Balint wrote: > > > > > > > > > On Sun, 10 May 2020, lance.lmw...@gmail.com wrote: > > > > > > > From: Limin Wang > > > > > Signed-off-by: Limin Wang > > > > --- > > > > libavcodec/mpegvideo.c | 48 > > > > > > > > 1 file changed, 24 insertions(+), 24 deletions(-) > > > > > > If you find these cosmetics interesting, then I suggest you introduce a > > > new > > > macro instead: FF_ALLOCZ_ARRAY_OR_GOTO(). > > > > > > E.g.: > > > > > > FF_ALLOCZ_ARRAY_OR_GOTO(s->avctx, s->me.map, ME_MAP_SIZE, fail) > > > > Yeah, I have considered it so I change the type to use use variable first > > and > > submit one typical for review. If the change is OK, then I'll go ahead next. > > No need to do it in two steps, better touch the code once. E.g. patch 2 > might not even be needed if you do this in a single patch. OK, I'll update the patch later. > > Regards, > Marton > > > > > > > > > Regards, > > > Marton > > > > > > > > diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c > > > > index 49fd1c9..561062f 100644 > > > > --- a/libavcodec/mpegvideo.c > > > > +++ b/libavcodec/mpegvideo.c > > > > @@ -373,15 +373,15 @@ static int init_duplicate_context(MpegEncContext > > > > *s) > > > > > if (s->encoding) { > > > > FF_ALLOCZ_OR_GOTO(s->avctx, s->me.map, > > > > - ME_MAP_SIZE * sizeof(uint32_t), fail) > > > > + ME_MAP_SIZE * sizeof(*s->me.map), fail) > > > > FF_ALLOCZ_OR_GOTO(s->avctx, s->me.score_map, > > > > - ME_MAP_SIZE * sizeof(uint32_t), fail) > > > > + ME_MAP_SIZE * sizeof(*s->me.score_map), fail) > > > > if (s->noise_reduction) { > > > > FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_error_sum, > > > > - 2 * 64 * sizeof(int), fail) > > > > + 2 * 64 * sizeof(*s->dct_error_sum), fail) > > > > } > > > > } > > > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->blocks, 64 * 12 * 2 * > > > > sizeof(int16_t), fail) > > > > +FF_ALLOCZ_OR_GOTO(s->avctx, s->blocks, 64 * 12 * 2 * > > > > sizeof(*s->blocks), fail) > > > > s->block = s->blocks[0]; > > > > > for (i = 0; i < 12; i++) { > > > > @@ -400,7 +400,7 @@ static int init_duplicate_context(MpegEncContext *s) > > > > if (s->out_format == FMT_H263) { > > > > /* ac values */ > > > > FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_val_base, > > > > - yc_size * sizeof(int16_t) * 16, fail); > > > > + yc_size * sizeof(*s->ac_val_base) * 16, > > > > fail); > > > > s->ac_val[0] = s->ac_val_base + s->b8_stride + 1; > > > > s->ac_val[1] = s->ac_val_base + y_size + s->mb_stride + 1; > > > > s->ac_val[2] = s->ac_val[1] + c_size; > > > > @@ -715,7 +715,7 @@ static int init_context_frame(MpegEncContext *s) > > > > if (s->mb_height & 1) > > > > yc_size += 2*s->b8_stride + 2*s->mb_stride; > > > > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) > > > * sizeof(int), > > > > +FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * > > > > sizeof(*s->mb_index2xy), > > > > fail); // error resilience code looks cleaner > > > > with this > > > > for (y = 0; y < s->mb_height; y++) > > > > for (x = 0; x < s->mb_width; x++) > > > > @@ -725,12 +725,12 @@ static int init_context_frame(MpegEncContext *s) > > > > > if (s->encoding) { > > > > /* Allocate MV tables */ > > > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base, > > > > mv_table_size * 2 * sizeof(int16_t), fail) > > > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base, > > > > mv_table_size * 2 * sizeof(int16_t), fail) > > > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base, > > > > mv_table_size * 2 * sizeof(int16_t), fail) > > > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base, > > > > mv_table_size * 2 * sizeof(int16_t), fail) > > > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base, > > > > mv_table_size * 2 * sizeof(int16_t), fail) > > > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base, > > > > mv_table_size * 2 * sizeof(int16_t), fail) > > > > +FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base, > > > > mv_table_size * 2 * sizeof(*s->p_mv_table_base), fail) > > > > +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base, > > > > mv_table_size * 2 * sizeof(*s->b_forw_mv_table_base), fail) > > > > +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base, > > > > mv_table_size * 2 * sizeof(*s->b_back_mv_table_base), fail) > > > > +
Re: [FFmpeg-devel] [PATCH 1/2] avcodec/mpegvideo: prefer to use variable instead of type for sizeof
On Mon, 11 May 2020, lance.lmw...@gmail.com wrote: On Sun, May 10, 2020 at 06:30:41PM +0200, Marton Balint wrote: On Sun, 10 May 2020, lance.lmw...@gmail.com wrote: > From: Limin Wang > > Signed-off-by: Limin Wang > --- > libavcodec/mpegvideo.c | 48 > 1 file changed, 24 insertions(+), 24 deletions(-) If you find these cosmetics interesting, then I suggest you introduce a new macro instead: FF_ALLOCZ_ARRAY_OR_GOTO(). E.g.: FF_ALLOCZ_ARRAY_OR_GOTO(s->avctx, s->me.map, ME_MAP_SIZE, fail) Yeah, I have considered it so I change the type to use use variable first and submit one typical for review. If the change is OK, then I'll go ahead next. No need to do it in two steps, better touch the code once. E.g. patch 2 might not even be needed if you do this in a single patch. Regards, Marton Regards, Marton > > diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c > index 49fd1c9..561062f 100644 > --- a/libavcodec/mpegvideo.c > +++ b/libavcodec/mpegvideo.c > @@ -373,15 +373,15 @@ static int init_duplicate_context(MpegEncContext *s) > > if (s->encoding) { > FF_ALLOCZ_OR_GOTO(s->avctx, s->me.map, > - ME_MAP_SIZE * sizeof(uint32_t), fail) > + ME_MAP_SIZE * sizeof(*s->me.map), fail) > FF_ALLOCZ_OR_GOTO(s->avctx, s->me.score_map, > - ME_MAP_SIZE * sizeof(uint32_t), fail) > + ME_MAP_SIZE * sizeof(*s->me.score_map), fail) > if (s->noise_reduction) { > FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_error_sum, > - 2 * 64 * sizeof(int), fail) > + 2 * 64 * sizeof(*s->dct_error_sum), fail) > } > } > -FF_ALLOCZ_OR_GOTO(s->avctx, s->blocks, 64 * 12 * 2 * sizeof(int16_t), fail) > +FF_ALLOCZ_OR_GOTO(s->avctx, s->blocks, 64 * 12 * 2 * sizeof(*s->blocks), fail) > s->block = s->blocks[0]; > > for (i = 0; i < 12; i++) { > @@ -400,7 +400,7 @@ static int init_duplicate_context(MpegEncContext *s) > if (s->out_format == FMT_H263) { > /* ac values */ > FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_val_base, > - yc_size * sizeof(int16_t) * 16, fail); > + yc_size * sizeof(*s->ac_val_base) * 16, fail); > s->ac_val[0] = s->ac_val_base + s->b8_stride + 1; > s->ac_val[1] = s->ac_val_base + y_size + s->mb_stride + 1; > s->ac_val[2] = s->ac_val[1] + c_size; > @@ -715,7 +715,7 @@ static int init_context_frame(MpegEncContext *s) > if (s->mb_height & 1) > yc_size += 2*s->b8_stride + 2*s->mb_stride; > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int), > +FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(*s->mb_index2xy), > fail); // error resilience code looks cleaner with this > for (y = 0; y < s->mb_height; y++) > for (x = 0; x < s->mb_width; x++) > @@ -725,12 +725,12 @@ static int init_context_frame(MpegEncContext *s) > > if (s->encoding) { > /* Allocate MV tables */ > -FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail) > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail) > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail) > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail) > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail) > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail) > +FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base, mv_table_size * 2 * sizeof(*s->p_mv_table_base), fail) > +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base, mv_table_size * 2 * sizeof(*s->b_forw_mv_table_base), fail) > +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base, mv_table_size * 2 * sizeof(*s->b_back_mv_table_base), fail) > +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base, mv_table_size * 2 * sizeof(*s->b_bidir_forw_mv_table_base), fail) > +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base, mv_table_size * 2 * sizeof(*s->b_bidir_back_mv_table_base), fail) > +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base, mv_table_size * 2 * sizeof(*s->b_direct_mv_table_base), fail) > s->p_mv_table= s->p_mv_table_base + s->mb_stride + 1; > s->b_forw_mv_table = s->b_forw_mv_table_base + s->mb_stride + 1; > s->b_back_mv_table = s->b_back_mv_table_base + s->mb_stride + 1; > @@ -739,14 +739,14 @@ static int init_conte
[FFmpeg-devel] [PATCH] libswscale: fix for floating point formats, require full chroma
From: Mark Reid upon more floating point testing, looks like I missed adding this bit. --- libswscale/utils.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libswscale/utils.c b/libswscale/utils.c index 15c0a19afa..111062e915 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -1405,6 +1405,8 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, srcFormat != AV_PIX_FMT_GBRP14BE && srcFormat != AV_PIX_FMT_GBRP14LE && srcFormat != AV_PIX_FMT_GBRP16BE && srcFormat != AV_PIX_FMT_GBRP16LE && srcFormat != AV_PIX_FMT_GBRAP16BE && srcFormat != AV_PIX_FMT_GBRAP16LE && +srcFormat != AV_PIX_FMT_GBRPF32BE && srcFormat != AV_PIX_FMT_GBRPF32LE && +srcFormat != AV_PIX_FMT_GBRAPF32BE && srcFormat != AV_PIX_FMT_GBRAPF32LE && ((dstW >> c->chrDstHSubSample) <= (srcW >> 1) || (flags & SWS_FAST_BILINEAR))) c->chrSrcHSubSample = 1; -- 2.25.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] avcodec/mpegvideo: prefer to use variable instead of type for sizeof
On Sun, May 10, 2020 at 06:30:41PM +0200, Marton Balint wrote: > > > On Sun, 10 May 2020, lance.lmw...@gmail.com wrote: > > > From: Limin Wang > > > > Signed-off-by: Limin Wang > > --- > > libavcodec/mpegvideo.c | 48 > > 1 file changed, 24 insertions(+), 24 deletions(-) > > If you find these cosmetics interesting, then I suggest you introduce a new > macro instead: FF_ALLOCZ_ARRAY_OR_GOTO(). > > E.g.: > > FF_ALLOCZ_ARRAY_OR_GOTO(s->avctx, s->me.map, ME_MAP_SIZE, fail) Yeah, I have considered it so I change the type to use use variable first and submit one typical for review. If the change is OK, then I'll go ahead next. > > Regards, > Marton > > > > > diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c > > index 49fd1c9..561062f 100644 > > --- a/libavcodec/mpegvideo.c > > +++ b/libavcodec/mpegvideo.c > > @@ -373,15 +373,15 @@ static int init_duplicate_context(MpegEncContext *s) > > > > if (s->encoding) { > > FF_ALLOCZ_OR_GOTO(s->avctx, s->me.map, > > - ME_MAP_SIZE * sizeof(uint32_t), fail) > > + ME_MAP_SIZE * sizeof(*s->me.map), fail) > > FF_ALLOCZ_OR_GOTO(s->avctx, s->me.score_map, > > - ME_MAP_SIZE * sizeof(uint32_t), fail) > > + ME_MAP_SIZE * sizeof(*s->me.score_map), fail) > > if (s->noise_reduction) { > > FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_error_sum, > > - 2 * 64 * sizeof(int), fail) > > + 2 * 64 * sizeof(*s->dct_error_sum), fail) > > } > > } > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->blocks, 64 * 12 * 2 * sizeof(int16_t), > > fail) > > +FF_ALLOCZ_OR_GOTO(s->avctx, s->blocks, 64 * 12 * 2 * > > sizeof(*s->blocks), fail) > > s->block = s->blocks[0]; > > > > for (i = 0; i < 12; i++) { > > @@ -400,7 +400,7 @@ static int init_duplicate_context(MpegEncContext *s) > > if (s->out_format == FMT_H263) { > > /* ac values */ > > FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_val_base, > > - yc_size * sizeof(int16_t) * 16, fail); > > + yc_size * sizeof(*s->ac_val_base) * 16, fail); > > s->ac_val[0] = s->ac_val_base + s->b8_stride + 1; > > s->ac_val[1] = s->ac_val_base + y_size + s->mb_stride + 1; > > s->ac_val[2] = s->ac_val[1] + c_size; > > @@ -715,7 +715,7 @@ static int init_context_frame(MpegEncContext *s) > > if (s->mb_height & 1) > > yc_size += 2*s->b8_stride + 2*s->mb_stride; > > > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * > > sizeof(int), > > +FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * > > sizeof(*s->mb_index2xy), > > fail); // error resilience code looks cleaner with > > this > > for (y = 0; y < s->mb_height; y++) > > for (x = 0; x < s->mb_width; x++) > > @@ -725,12 +725,12 @@ static int init_context_frame(MpegEncContext *s) > > > > if (s->encoding) { > > /* Allocate MV tables */ > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base, > > mv_table_size * 2 * sizeof(int16_t), fail) > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base, > > mv_table_size * 2 * sizeof(int16_t), fail) > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base, > > mv_table_size * 2 * sizeof(int16_t), fail) > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base, > > mv_table_size * 2 * sizeof(int16_t), fail) > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base, > > mv_table_size * 2 * sizeof(int16_t), fail) > > -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base, > > mv_table_size * 2 * sizeof(int16_t), fail) > > +FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base, > > mv_table_size * 2 * sizeof(*s->p_mv_table_base), fail) > > +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base, > > mv_table_size * 2 * sizeof(*s->b_forw_mv_table_base), fail) > > +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base, > > mv_table_size * 2 * sizeof(*s->b_back_mv_table_base), fail) > > +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base, > > mv_table_size * 2 * sizeof(*s->b_bidir_forw_mv_table_base), fail) > > +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base, > > mv_table_size * 2 * sizeof(*s->b_bidir_back_mv_table_base), fail) > > +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base, > > mv_table_size * 2 * sizeof(*s->b_direct_mv_table_base), fail) > > s->p_mv_table= s->p_mv_table_base + s->mb_stride + 1; > > s->b_forw_mv_table = s->b_forw_mv_table_base + s->mb_stride + > > 1; > > s->b_back_mv_table = s->b_back_mv_table_base + s->mb_stride + > > 1; > > @@ -739,14 +7
Re: [FFmpeg-devel] [PATCH 5/7] avcodec/sonic: Fix several integer state overflows
NAK please remove this code fully. On 5/10/20, Michael Niedermayer wrote: > Fixes: signed integer overflow: -234 * -14797801 cannot be represented in > type 'int' > Fixes: > 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-5695924975435776 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavcodec/sonic.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c > index b82c44344c..ea6ef10c9e 100644 > --- a/libavcodec/sonic.c > +++ b/libavcodec/sonic.c > @@ -458,8 +458,8 @@ static void predictor_init_state(int *k, int *state, int > order) > > for (j = 0, p = i+1; p < order; j++,p++) > { > -int tmp = x + shift_down(k[j] * state[p], LATTICE_SHIFT); > -state[p] += shift_down(k[j]*x, LATTICE_SHIFT); > +int tmp = x + shift_down(k[j] * (unsigned)state[p], > LATTICE_SHIFT); > +state[p] += shift_down(k[j]* (unsigned)x, LATTICE_SHIFT); > x = tmp; > } > } > @@ -467,7 +467,7 @@ static void predictor_init_state(int *k, int *state, int > order) > > static int predictor_calc_error(int *k, int *state, int order, int error) > { > -int i, x = error - shift_down(k[order-1] * state[order-1], > LATTICE_SHIFT); > +int i, x = error - shift_down(k[order-1] * (unsigned)state[order-1], > LATTICE_SHIFT); > > #if 1 > int *k_ptr = &(k[order-2]), > -- > 2.17.1 > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/2] avformat/ivfenc: move bsf insertion to the init function
Signed-off-by: James Almer --- libavformat/ivfenc.c | 24 ++-- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/libavformat/ivfenc.c b/libavformat/ivfenc.c index 0ce4a85171..0951f56c92 100644 --- a/libavformat/ivfenc.c +++ b/libavformat/ivfenc.c @@ -43,6 +43,16 @@ static int ivf_init(AVFormatContext *s) return AVERROR(EINVAL); } +if (par->codec_id == AV_CODEC_ID_VP9) { +int ret = ff_stream_add_bitstream_filter(s->streams[0], "vp9_superframe", NULL); +if (ret < 0) +return ret; +} else if (par->codec_id == AV_CODEC_ID_AV1) { +int ret = ff_stream_add_bitstream_filter(s->streams[0], "av1_metadata", "td=insert"); +if (ret < 0) +return ret; +} + return 0; } @@ -100,19 +110,6 @@ static int ivf_write_trailer(AVFormatContext *s) return 0; } -static int ivf_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt) -{ -int ret = 1; -AVStream *st = s->streams[pkt->stream_index]; - -if (st->codecpar->codec_id == AV_CODEC_ID_VP9) -ret = ff_stream_add_bitstream_filter(st, "vp9_superframe", NULL); -else if (st->codecpar->codec_id == AV_CODEC_ID_AV1) -ret = ff_stream_add_bitstream_filter(st, "av1_metadata", "td=insert"); - -return ret; -} - static const AVCodecTag codec_ivf_tags[] = { { AV_CODEC_ID_VP8, MKTAG('V', 'P', '8', '0') }, { AV_CODEC_ID_VP9, MKTAG('V', 'P', '9', '0') }, @@ -131,6 +128,5 @@ AVOutputFormat ff_ivf_muxer = { .write_header = ivf_write_header, .write_packet = ivf_write_packet, .write_trailer = ivf_write_trailer, -.check_bitstream = ivf_check_bitstream, .codec_tag= (const AVCodecTag* const []){ codec_ivf_tags, 0 }, }; -- 2.26.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/2] hwcontext_vulkan: expose enabled device and instance extensions
On 10/05/2020 15:23, Lynne wrote: > May 10, 2020, 14:33 by s...@jkqxz.net: >> On 10/05/2020 11:54, Lynne wrote: >>> ... > > From 6ecc3547bcfcc450c8ffe8d93a3040fd863f6288 Mon Sep 17 00:00:00 2001 > From: Lynne > Date: Sun, 10 May 2020 11:47:50 +0100 > Subject: [PATCH 2/3] hwcontext_vulkan: expose enabled device and instance > extensions > > This solves a huge oversight - it lets users reliably use their own > AVVulkanDeviceContext. Otherwise, the extensions supplied and enabled > are not discoverable by anything outside of hwcontext_vulkan. > --- > doc/APIchanges | 4 > libavutil/hwcontext_vulkan.c | 40 > libavutil/hwcontext_vulkan.h | 21 ++- > libavutil/version.h | 2 +- > 4 files changed, 56 insertions(+), 11 deletions(-) > > diff --git a/doc/APIchanges b/doc/APIchanges > index b3e7e89412..75cfdb08b0 100644 > --- a/doc/APIchanges > +++ b/doc/APIchanges > @@ -15,6 +15,10 @@ libavutil: 2017-10-21 > > API changes, most recent first: > > +2020-05-10 - xx - lavu 56.44.100 - hwcontext_vulkan.h > + Add enabled_inst_extensions, num_enabled_inst_extensions, > enabled_dev_extensions > + and num_enabled_dev_extensions fields to AVVulkanDeviceContext > + > 2020-04-22 - 0e1db79e37 - lavc 58.81.100 - packet.h > - lavu 56.43.100 - dovi_meta.h >Add AV_PKT_DATA_DOVI_CONF and AVDOVIDecoderConfigurationRecord. > ... > diff --git a/libavutil/hwcontext_vulkan.h b/libavutil/hwcontext_vulkan.h > index ebc28916f3..909f88a7e4 100644 > --- a/libavutil/hwcontext_vulkan.h > +++ b/libavutil/hwcontext_vulkan.h > @@ -39,7 +39,7 @@ typedef struct AVVulkanDeviceContext { > */ > const VkAllocationCallbacks *alloc; > /** > - * Instance > + * Vulkan instance. Must be at least version 1.1. > */ > VkInstance inst; > /** > @@ -65,6 +65,25 @@ typedef struct AVVulkanDeviceContext { > * Queue family index for compute ops > */ > int queue_family_comp_index; > +/** > + * Enabled instance extensions. By default, VK_KHR_surface is enabled if > found. > + * If supplying your own device context, set this to an array of > strings, with > + * each entry containing the specified Vulkan extension string to enable. > + * Duplicates are possible and accepted. > + * If no extensions are enabled, set these fields to NULL, and 0 > respectively. > + */ > +const char * const *enabled_inst_extensions; > +int num_enabled_inst_extensions; > +/** > + * Enabled device extensions. By default, VK_KHR_external_memory_fd, > + * VK_EXT_external_memory_dma_buf, VK_EXT_image_drm_format_modifier and > + * VK_KHR_external_semaphore_fd are enabled if found. > + * If supplying your own device context, these fields takes the same > format as > + * the above fields, with the same conditions that duplicates are > possible > + * and accepted, and that NULL and 0 respectively means no extensions > are enabled. > + */ That's much clearer, thank you :) > +const char * const *enabled_dev_extensions; > +int num_enabled_dev_extensions; A minor stylistic niggle - fields like this are "nb_something" rather than "num_something" in pretty much all other ffmpeg headers. > } AVVulkanDeviceContext; > > /** > diff --git a/libavutil/version.h b/libavutil/version.h > index ea9363e8e9..48d8a38c42 100644 > --- a/libavutil/version.h > +++ b/libavutil/version.h > @@ -79,7 +79,7 @@ > */ > > #define LIBAVUTIL_VERSION_MAJOR 56 > -#define LIBAVUTIL_VERSION_MINOR 43 > +#define LIBAVUTIL_VERSION_MINOR 44 > #define LIBAVUTIL_VERSION_MICRO 100 > > #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ > -- > 2.26.2 LGTM with or without that change. Thanks, - Mark ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] avformat/ivfenc: add an AVCodec.init() function
On 5/10/2020 6:29 PM, Andreas Rheinhardt wrote: > James Almer: >> Signed-off-by: James Almer >> --- > AVCodec? What AVCodec? Right, changed locally to AVOutputFormat. Sorry about that. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] avformat/ivfenc: add an AVCodec.init() function
James Almer: > Signed-off-by: James Almer > --- AVCodec? What AVCodec? - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] hwcontext_vulkan: let users enable device and instance extensions using options
On 10/05/2020 15:02, Lynne wrote: > May 10, 2020, 14:14 by s...@jkqxz.net: >> On 10/05/2020 11:51, Lynne wrote: >>> ... > > New version attached. > > > From a4741ed92aecc43e64ca424206c3989008a222fd Mon Sep 17 00:00:00 2001 > From: Lynne > Date: Sun, 10 May 2020 11:26:40 +0100 > Subject: [PATCH 1/2] hwcontext_vulkan: let users enable device and instance > extensions using options > > Also documents all options supported by the hwdevice. > This lets users enable all extensions they need without writing their own > instance initialization code. > --- > doc/ffmpeg.texi | 15 ++ > libavutil/hwcontext_vulkan.c | 39 > 2 files changed, 50 insertions(+), 4 deletions(-) > > diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi > index 29753f06ca..ed437bb16f 100644 > --- a/doc/ffmpeg.texi > +++ b/doc/ffmpeg.texi > @@ -1034,6 +1034,18 @@ If @var{device} is an integer, it selects the device > by its index in a > system-dependent list of devices. If @var{device} is any other string, it > selects the first device with a name containing that string as a substring. > > +The following options are recognized: > +@table @option > +@item debug > +If set to 1, enables the validation layer, if installed. > +@item linear_images > +If set to 1, images allocated by the hwcontext will be linear and locally > mappable. > +@item instance_extensions > +A plus separated list of additional instance extensions to enable. > +@item device_extensions > +A plus separated list of additional device extensions to enable. > +@end table > + > Examples: > @table @emph > @item -init_hw_device vulkan:1 > @@ -1041,6 +1053,9 @@ Choose the second device on the system. > > @item -init_hw_device vulkan:RADV > Choose the first device with a name containing the string @emph{RADV}. > + > +@item -init_hw_device > vulkan:0,instance_extensions=VK_KHR_wayland_surface+VK_KHR_xcb_surface > +Choose the first device and enable the Wayland and XCB instance extensions. > @end table > > @end table > diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c > index 43e7cddbc5..c853e2f502 100644 > --- a/libavutil/hwcontext_vulkan.c > +++ b/libavutil/hwcontext_vulkan.c > @@ -100,7 +100,7 @@ typedef struct AVVkFrameInternal { > err = AVERROR(ENOMEM); > \ > goto end; > \ > } > \ > -list[count - 1] = val; > \ > +list[count - 1] = av_strdup(val); > \ Memory allocation needs a check for failure. > } while(0) > > static const struct { > @@ -261,7 +261,7 @@ static VkBool32 > vk_dbg_callback(VkDebugUtilsMessageSeverityFlagBitsEXT severity, > return 0; > } > > -static int check_extensions(AVHWDeviceContext *ctx, int dev, > +static int check_extensions(AVHWDeviceContext *ctx, int dev, AVDictionary > *opts, > const char * const **dst, uint32_t *num, int > debug) > { > const char *tstr; > @@ -274,12 +274,14 @@ static int check_extensions(AVHWDeviceContext *ctx, int > dev, > int optional_exts_num; > uint32_t sup_ext_count; > VkExtensionProperties *sup_ext; > +AVDictionaryEntry *user_exts = NULL; > const VulkanOptExtension *optional_exts; > > if (!dev) { > mod = "instance"; > optional_exts = optional_instance_exts; > optional_exts_num = FF_ARRAY_ELEMS(optional_instance_exts); > +user_exts = av_dict_get(opts, "instance_extensions", NULL, 0); > vkEnumerateInstanceExtensionProperties(NULL, &sup_ext_count, NULL); > sup_ext = av_malloc_array(sup_ext_count, > sizeof(VkExtensionProperties)); > if (!sup_ext) > @@ -289,6 +291,7 @@ static int check_extensions(AVHWDeviceContext *ctx, int > dev, > mod = "device"; > optional_exts = optional_device_exts; > optional_exts_num = FF_ARRAY_ELEMS(optional_device_exts); > +user_exts = av_dict_get(opts, "device_extensions", NULL, 0); > vkEnumerateDeviceExtensionProperties(hwctx->phys_dev, NULL, > &sup_ext_count, NULL); > sup_ext = av_malloc_array(sup_ext_count, > sizeof(VkExtensionProperties)); > @@ -345,6 +348,30 @@ static int check_extensions(AVHWDeviceContext *ctx, int > dev, > } > } > > +if (user_exts) { > +char *user_exts_str = av_strdup(user_exts->value); Also this one. > +char *save, *token = av_strtok(user_exts_str, "+", &save); > +while (token) { > +found = 0; > +for (int j = 0; j < sup_ext_count; j++) { > +if (!strcmp(token, sup_ext[j].extensionName)) { > +found = 1; > +break
[FFmpeg-devel] [PATCH 1/2] avformat/ivfenc: add an AVCodec.init() function
Signed-off-by: James Almer --- libavformat/ivfenc.c | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libavformat/ivfenc.c b/libavformat/ivfenc.c index 45e5b238dc..0ce4a85171 100644 --- a/libavformat/ivfenc.c +++ b/libavformat/ivfenc.c @@ -26,10 +26,9 @@ typedef struct IVFEncContext { uint64_t last_pts, sum_delta_pts; } IVFEncContext; -static int ivf_write_header(AVFormatContext *s) +static int ivf_init(AVFormatContext *s) { AVCodecParameters *par; -AVIOContext *pb = s->pb; if (s->nb_streams != 1) { av_log(s, AV_LOG_ERROR, "Format supports only exactly one video stream\n"); @@ -43,6 +42,15 @@ static int ivf_write_header(AVFormatContext *s) av_log(s, AV_LOG_ERROR, "Currently only VP8, VP9 and AV1 are supported!\n"); return AVERROR(EINVAL); } + +return 0; +} + +static int ivf_write_header(AVFormatContext *s) +{ +AVCodecParameters *par = s->streams[0]->codecpar; +AVIOContext *pb = s->pb; + avio_write(pb, "DKIF", 4); avio_wl16(pb, 0); // version avio_wl16(pb, 32); // header length @@ -119,6 +127,7 @@ AVOutputFormat ff_ivf_muxer = { .extensions = "ivf", .audio_codec = AV_CODEC_ID_NONE, .video_codec = AV_CODEC_ID_VP8, +.init = ivf_init, .write_header = ivf_write_header, .write_packet = ivf_write_packet, .write_trailer = ivf_write_trailer, -- 2.26.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec: Add MediaFoundation encoder wrapper
On Sun, 10 May 2020, Paul B Mahol wrote: What's next? Decoders? I probably won't put in effort in getting the MediaFoundation decoder support merged myself, but if this is merged, I can at least try to make a WIP patch somewhere that adds the rest of the decoding support from the original patch. // Martin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/mux: Check pkt->stream_index before using it
Anton Khirnov: > Quoting Marton Balint (2020-05-10 19:45:04) >> >> >> On Sun, 10 May 2020, Anton Khirnov wrote: >> >>> Quoting Andreas Rheinhardt (2020-05-08 00:55:00) This commit fixes two recent regressions both of which are about using pkt->stream_index as index in an AVFormatContext's streams array before actually comparing the value with the count of streams in said array. 96e5e6abb9851d7a26ba21703955d5826ac857c0 did this in prepare_input_packet() and 64063512227c4c87a7d16a1076481dc6baf19841 did likewise in write_packets_common(). Signed-off-by: Andreas Rheinhardt --- The same error in the same file applied on the same day by two different people. How unlikely. >>> >>> How is it a regression? Isn't it rather invalid API use? >> >> Fun fact: 7b03b65bf0d02519c86750d2da33f413e11cf0c6 >> >> Yes, it is kind of invalid API use, but since the check is already there, >> we should make it actually worthwile. > > lol > > I agree that checking for it is a good idea, obviously, but I wouldn't > call it a regression. > How about rephrasing the first sentence to: "This commit stops using pkt->stream_index as index in an AVFormatContext's streams array before actually comparing the value with the count of streams in said array." >> >>> >>> Not that I object to having a check. But then why is check_packet() >>> called so deep and not immediately on entry to the muxer? >> >> I guess it is not that deep, but recent factorization efforts hidden it a >> bit. > > You can see in my original commit it is the very first thing done after > entering the muxer. Right now it's several function calls deep. > I could make it the very first thing called in write_packets_common(). - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/7] avcodec/mpc: Fix multiple numerical overflows in ff_mpc_dequantize_and_synth()
On Sun, May 10, 2020 at 09:20:13PM +0200, Michael Niedermayer wrote: > This uses lrintf() which is not ideal as it still can raise an error > but it is not undefined behavior. So a better solution should ideally be found > > Fixes: -2.4187e+09 is outside the range of representable values of type 'int' > Fixes: signed integer overflow: -14512205 + -2147483648 cannot be represented > in type 'int' > Fixes: > 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPC7_fuzzer-5747263166480384 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavcodec/mpc.c | 8 > 1 file changed, 4 insertions(+), 4 deletions(-) Heres a more correct but slower solution: From 74bdf7ac2ff3b72d8f31e43e41555205b9f1e37f Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 10 May 2020 19:04:23 +0200 Subject: [PATCH] avcodec/mpc: Fix multiple numerical overflows in ff_mpc_dequantize_and_synth() Fixes: -2.4187e+09 is outside the range of representable values of type 'int' Fixes: signed integer overflow: -14512205 + -2147483648 cannot be represented in type 'int' Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPC7_fuzzer-5747263166480384 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/mpc.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/mpc.c b/libavcodec/mpc.c index 6cf9b9d520..e56b608d8c 100644 --- a/libavcodec/mpc.c +++ b/libavcodec/mpc.c @@ -75,17 +75,17 @@ void ff_mpc_dequantize_and_synth(MPCContext * c, int maxband, int16_t **out, j = 0; mul = (mpc_CC+1)[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][0] & 0xFF]; for(; j < 12; j++) -c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off]; +c->sb_samples[ch][j][i] = av_clipf(mul * c->Q[ch][j + off], INT32_MIN, INT32_MAX); mul = (mpc_CC+1)[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][1] & 0xFF]; for(; j < 24; j++) -c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off]; +c->sb_samples[ch][j][i] = av_clipf(mul * c->Q[ch][j + off], INT32_MIN, INT32_MAX); mul = (mpc_CC+1)[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][2] & 0xFF]; for(; j < 36; j++) -c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off]; +c->sb_samples[ch][j][i] = av_clipf(mul * c->Q[ch][j + off], INT32_MIN, INT32_MAX); } } if(bands[i].msf){ -int t1, t2; +unsigned t1, t2; for(j = 0; j < SAMPLES_PER_BAND; j++){ t1 = c->sb_samples[0][j][i]; t2 = c->sb_samples[1][j][i]; -- 2.17.1 [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Rewriting code that is poorly written but fully understood is good. Rewriting code that one doesnt understand is a sign that one is less smart then the original author, trying to rewrite it will not make it better. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] fftools/ffmpeg: update text requesting samples
From: Andriy Gelman Signed-off-by: Andriy Gelman --- Same as commit d1e52e396b8aa778bd8d12bf25864beca0937d0a doc/developer.texi | 2 +- fftools/cmdutils.c | 2 +- fftools/ffmpeg.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/developer.texi b/doc/developer.texi index 51e7299b1d..b33cab0fc7 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -625,7 +625,7 @@ If the patch fixes a bug, did you provide a verbose analysis of the bug? If the patch fixes a bug, did you provide enough information, including a sample, so the bug can be reproduced and the fix can be verified? Note please do not attach samples >100k to mails but rather provide a -URL, you can upload to ftp://upload.ffmpeg.org. +URL, you can upload to @url{https://streams.videolan.org/upload/}. @item Did you provide a verbose summary about what the patch does change? diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 7f5a5ca664..072589e358 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -2217,7 +2217,7 @@ double get_rotation(AVStream *st) if (fabs(theta - 90*round(theta/90)) > 2) av_log(NULL, AV_LOG_WARNING, "Odd rotation angle.\n" "If you want to help, upload a sample " - "of this file to ftp://upload.ffmpeg.org/incoming/ " + "of this file to https://streams.videolan.org/upload/ " "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)"); return theta; diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index f697460a30..c86b413f73 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2370,7 +2370,7 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_ av_log(ist->dec_ctx, AV_LOG_WARNING, "video_delay is larger in decoder than demuxer %d > %d.\n" "If you want to help, upload a sample " - "of this file to ftp://upload.ffmpeg.org/incoming/ " + "of this file to https://streams.videolan.org/upload/ " "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)\n", ist->dec_ctx->has_b_frames, ist->st->codecpar->video_delay); -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 6/7] avcodec/ttadsp: Fix several integer overflows in tta_filter_process_c()
Fixes: signed integer overflow: 1931744255 + 252497024 cannot be represented in type 'int' Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TTA_fuzzer-5763348114440192 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/ttadsp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/ttadsp.c b/libavcodec/ttadsp.c index 056a2c7ef1..1d1443aee0 100644 --- a/libavcodec/ttadsp.c +++ b/libavcodec/ttadsp.c @@ -20,9 +20,11 @@ #include "ttadsp.h" #include "config.h" -static void tta_filter_process_c(int32_t *qm, int32_t *dx, int32_t *dl, +static void tta_filter_process_c(int32_t *qmi, int32_t *dx, int32_t *dl, int32_t *error, int32_t *in, int32_t shift, int32_t round) { +uint32_t *qm = qmi; + if (*error < 0) { qm[0] -= dx[0]; qm[1] -= dx[1]; qm[2] -= dx[2]; qm[3] -= dx[3]; qm[4] -= dx[4]; qm[5] -= dx[5]; qm[6] -= dx[6]; qm[7] -= dx[7]; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 7/7] avcodec/utvideodec: Fix integer overflow in decode_plane()
Fixes: signed integer overflow: 2147483594 + 142 cannot be represented in type 'int' Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_UTVIDEO_fuzzer-5658568101724160 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/utvideodec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/utvideodec.c b/libavcodec/utvideodec.c index 4da257fc61..c07636d435 100644 --- a/libavcodec/utvideodec.c +++ b/libavcodec/utvideodec.c @@ -317,7 +317,7 @@ static int decode_plane(UtvideoContext *c, int plane_no, for (i = 0; i < width; i++) { pix = fsym; if (use_pred) { -prev += pix; +prev += (unsigned)pix; pix = prev; } dest[i] = pix; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 5/7] avcodec/sonic: Fix several integer state overflows
Fixes: signed integer overflow: -234 * -14797801 cannot be represented in type 'int' Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-5695924975435776 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/sonic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c index b82c44344c..ea6ef10c9e 100644 --- a/libavcodec/sonic.c +++ b/libavcodec/sonic.c @@ -458,8 +458,8 @@ static void predictor_init_state(int *k, int *state, int order) for (j = 0, p = i+1; p < order; j++,p++) { -int tmp = x + shift_down(k[j] * state[p], LATTICE_SHIFT); -state[p] += shift_down(k[j]*x, LATTICE_SHIFT); +int tmp = x + shift_down(k[j] * (unsigned)state[p], LATTICE_SHIFT); +state[p] += shift_down(k[j]* (unsigned)x, LATTICE_SHIFT); x = tmp; } } @@ -467,7 +467,7 @@ static void predictor_init_state(int *k, int *state, int order) static int predictor_calc_error(int *k, int *state, int order, int error) { -int i, x = error - shift_down(k[order-1] * state[order-1], LATTICE_SHIFT); +int i, x = error - shift_down(k[order-1] * (unsigned)state[order-1], LATTICE_SHIFT); #if 1 int *k_ptr = &(k[order-2]), -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/7] avcodec/nuv: widen buf_size type
Fixes: signed integer overflow: 65312 * 65312 cannot be represented in type 'int' Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_NUV_fuzzer-5740176118906880 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/nuv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c index 7958000ae8..3ceaaac4e9 100644 --- a/libavcodec/nuv.c +++ b/libavcodec/nuv.c @@ -126,7 +126,7 @@ static int codec_reinit(AVCodecContext *avctx, int width, int height, get_quant_quality(c, quality); if (width != c->width || height != c->height) { // also reserve space for a possible additional header -int buf_size = height * width * 3 / 2 +int64_t buf_size = height * (int64_t)width * 3 / 2 + FFMAX(AV_LZO_OUTPUT_PADDING, AV_INPUT_BUFFER_PADDING_SIZE) + RTJPEG_HEADER_SIZE; if (buf_size > INT_MAX/8) -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/7] avcodec/ralf: Fix integer overflow in decode_block()
Fixes: signed integer overflow: 289082077 - -200314 cannot be represented in type 'int' Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RALF_fuzzer-5196077752123392 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/ralf.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/ralf.c b/libavcodec/ralf.c index 831728177e..08e8043e30 100644 --- a/libavcodec/ralf.c +++ b/libavcodec/ralf.c @@ -344,7 +344,8 @@ static int decode_block(AVCodecContext *avctx, GetBitContext *gb, int len, ch, ret; int dmode, mode[2], bits[2]; int *ch0, *ch1; -int i, t, t2; +int i; +unsigned int t, t2; len = 12 - get_unary(gb, 0, 6); @@ -409,8 +410,8 @@ static int decode_block(AVCodecContext *avctx, GetBitContext *gb, for (i = 0; i < len; i++) { t = ch1[i] + ctx->bias[1]; t2 = ((ch0[i] + ctx->bias[0]) * 2) | (t & 1); -dst0[i] = (t2 + t) / 2; -dst1[i] = (t2 - t) / 2; +dst0[i] = (int)(t2 + t) / 2; +dst1[i] = (int)(t2 - t) / 2; } break; } -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/7] avcodec/mpc: Fix multiple numerical overflows in ff_mpc_dequantize_and_synth()
This uses lrintf() which is not ideal as it still can raise an error but it is not undefined behavior. So a better solution should ideally be found Fixes: -2.4187e+09 is outside the range of representable values of type 'int' Fixes: signed integer overflow: -14512205 + -2147483648 cannot be represented in type 'int' Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPC7_fuzzer-5747263166480384 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/mpc.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/mpc.c b/libavcodec/mpc.c index 6cf9b9d520..ebd654ba48 100644 --- a/libavcodec/mpc.c +++ b/libavcodec/mpc.c @@ -75,17 +75,17 @@ void ff_mpc_dequantize_and_synth(MPCContext * c, int maxband, int16_t **out, j = 0; mul = (mpc_CC+1)[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][0] & 0xFF]; for(; j < 12; j++) -c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off]; +c->sb_samples[ch][j][i] = lrintf(mul * c->Q[ch][j + off]); mul = (mpc_CC+1)[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][1] & 0xFF]; for(; j < 24; j++) -c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off]; +c->sb_samples[ch][j][i] = lrintf(mul * c->Q[ch][j + off]); mul = (mpc_CC+1)[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][2] & 0xFF]; for(; j < 36; j++) -c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off]; +c->sb_samples[ch][j][i] = lrintf(mul * c->Q[ch][j + off]); } } if(bands[i].msf){ -int t1, t2; +unsigned t1, t2; for(j = 0; j < SAMPLES_PER_BAND; j++){ t1 = c->sb_samples[0][j][i]; t2 = c->sb_samples[1][j][i]; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/7] avcodec/sonic: Fix several integer overflows
Fixes: signed integer overflow: 2129689466 + 2129689466 cannot be represented in type 'int' Fixes: 20715/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-5155263109922816 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/sonic.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c index c975774b04..b82c44344c 100644 --- a/libavcodec/sonic.c +++ b/libavcodec/sonic.c @@ -140,7 +140,8 @@ static inline av_flatten int get_symbol(RangeCoder *c, uint8_t *state, int is_si if(get_rac(c, state+0)) return 0; else{ -int i, e, a; +int i, e; +unsigned a; e= 0; while(get_rac(c, state+1 + FFMIN(e,9))){ //1..10 e++; @@ -474,7 +475,7 @@ static int predictor_calc_error(int *k, int *state, int order, int error) for (i = order-2; i >= 0; i--, k_ptr--, state_ptr--) { int k_value = *k_ptr, state_value = *state_ptr; -x -= shift_down(k_value * state_value, LATTICE_SHIFT); +x -= shift_down(k_value * (unsigned)state_value, LATTICE_SHIFT); state_ptr[1] = state_value + shift_down(k_value * (unsigned)x, LATTICE_SHIFT); } #else @@ -1044,7 +1045,7 @@ static int sonic_decode_frame(AVCodecContext *avctx, x += s->channels; } -s->int_samples[x] = predictor_calc_error(s->predictor_k, s->predictor_state[ch], s->num_taps, s->coded_samples[ch][i] * quant); +s->int_samples[x] = predictor_calc_error(s->predictor_k, s->predictor_state[ch], s->num_taps, s->coded_samples[ch][i] * (unsigned)quant); x += s->channels; } -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/2] hwcontext_vulkan: expose enabled device and instance extensions
May 10, 2020, 14:33 by s...@jkqxz.net: > On 10/05/2020 11:54, Lynne wrote: > >> */ >> VkInstance inst; >> +/** >> + * Enabled instance extensions. By default, VK_KHR_surface is enabled >> if found. >> + */ >> > > Clarify how this should be set by the user if they are supplying the > instance? (From code, looks like it's not used.) > Done. >> +const char * const *enabled_inst_extensions; >> +int num_enabled_inst_extensions; >> /** >> * Physical device >> */ >> @@ -50,6 +55,13 @@ typedef struct AVVulkanDeviceContext { >> * Active device >> */ >> VkDevice act_dev; >> +/** >> + * Enabled device extensions. By default, VK_KHR_external_memory_fd, >> + * VK_EXT_external_memory_dma_buf, VK_EXT_image_drm_format_modifier and >> + * VK_KHR_external_semaphore_fd are enabled if found. >> + */ >> > > Clarify how this should be set by the user if they are supplying the device? > (From code, looks like it's required.) > Done (it isn't required, and can be NULL). >> +const char * const *enabled_dev_extensions; >> +int num_enabled_dev_extensions; >> /** >> * Queue family index for graphics >> * @note av_hwdevice_create() will set all 3 queue indices if unset >> -- >> 2.26.2 >> > > I think you need to put the new fields at the end to avoid the worst ABI > break (upgrade libavutil and crash trying to use the device fields because > they've moved). > > The API change with the new field being required is ugly given that it's > months after the usual cutoff, but the effect hasn't changed (they wouldn't > have had any extensions) so it's probably ok. Needs a notice in APIchanges, > though. > Done, with a minor lavu bump and an APIchanges notice. Looks tidier with the fields at the bottom anyway. Patch attached. >From 6ecc3547bcfcc450c8ffe8d93a3040fd863f6288 Mon Sep 17 00:00:00 2001 From: Lynne Date: Sun, 10 May 2020 11:47:50 +0100 Subject: [PATCH 2/3] hwcontext_vulkan: expose enabled device and instance extensions This solves a huge oversight - it lets users reliably use their own AVVulkanDeviceContext. Otherwise, the extensions supplied and enabled are not discoverable by anything outside of hwcontext_vulkan. --- doc/APIchanges | 4 libavutil/hwcontext_vulkan.c | 40 libavutil/hwcontext_vulkan.h | 21 ++- libavutil/version.h | 2 +- 4 files changed, 56 insertions(+), 11 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index b3e7e89412..75cfdb08b0 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,10 @@ libavutil: 2017-10-21 API changes, most recent first: +2020-05-10 - xx - lavu 56.44.100 - hwcontext_vulkan.h + Add enabled_inst_extensions, num_enabled_inst_extensions, enabled_dev_extensions + and num_enabled_dev_extensions fields to AVVulkanDeviceContext + 2020-04-22 - 0e1db79e37 - lavc 58.81.100 - packet.h - lavu 56.43.100 - dovi_meta.h Add AV_PKT_DATA_DOVI_CONF and AVDOVIDecoderConfigurationRecord. diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index c853e2f502..fad8c67818 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -417,15 +417,13 @@ static int create_instance(AVHWDeviceContext *ctx, AVDictionary *opts) /* Try to create the instance */ ret = vkCreateInstance(&inst_props, hwctx->alloc, &hwctx->inst); -/* Free used memory */ -for (int i = 0; i < inst_props.enabledExtensionCount; i++) -av_free((void *)inst_props.ppEnabledExtensionNames[i]); -av_free((void *)inst_props.ppEnabledExtensionNames); - /* Check for errors */ if (ret != VK_SUCCESS) { av_log(ctx, AV_LOG_ERROR, "Instance creation failure: %s\n", vk_ret2str(ret)); +for (int i = 0; i < inst_props.enabledExtensionCount; i++) +av_free((void *)inst_props.ppEnabledExtensionNames[i]); +av_free((void *)inst_props.ppEnabledExtensionNames); return AVERROR_EXTERNAL; } @@ -448,6 +446,9 @@ static int create_instance(AVHWDeviceContext *ctx, AVDictionary *opts) hwctx->alloc, &p->debug_ctx); } +hwctx->enabled_inst_extensions = inst_props.ppEnabledExtensionNames; +hwctx->num_enabled_inst_extensions = inst_props.enabledExtensionCount; + return 0; } @@ -753,6 +754,14 @@ static void vulkan_device_free(AVHWDeviceContext *ctx) } vkDestroyInstance(hwctx->inst, hwctx->alloc); + +for (int i = 0; i < hwctx->num_enabled_inst_extensions; i++) +av_free((void *)hwctx->enabled_inst_extensions[i]); +av_free((void *)hwctx->enabled_inst_extensions); + +for (int i = 0; i < hwctx->num_enabled_dev_extensions; i++) +av_free((void *)hwctx->enabled_dev_extensions[i]); +av_free((void *)hwctx->enabled_dev_extensions); } static int vulkan_device_create_internal(AVHWDeviceContext *ctx, @@ -813,13
Re: [FFmpeg-devel] [PATCH] avformat/mux: Check pkt->stream_index before using it
Quoting Marton Balint (2020-05-10 19:45:04) > > > On Sun, 10 May 2020, Anton Khirnov wrote: > > > Quoting Andreas Rheinhardt (2020-05-08 00:55:00) > >> This commit fixes two recent regressions both of which are about using > >> pkt->stream_index as index in an AVFormatContext's streams array before > >> actually comparing the value with the count of streams in said array. > >> 96e5e6abb9851d7a26ba21703955d5826ac857c0 did this in > >> prepare_input_packet() and 64063512227c4c87a7d16a1076481dc6baf19841 did > >> likewise in write_packets_common(). > >> > >> Signed-off-by: Andreas Rheinhardt > >> --- > >> The same error in the same file applied on the same day by two different > >> people. How unlikely. > > > > How is it a regression? Isn't it rather invalid API use? > > Fun fact: 7b03b65bf0d02519c86750d2da33f413e11cf0c6 > > Yes, it is kind of invalid API use, but since the check is already there, > we should make it actually worthwile. lol I agree that checking for it is a good idea, obviously, but I wouldn't call it a regression. > > > > > Not that I object to having a check. But then why is check_packet() > > called so deep and not immediately on entry to the muxer? > > I guess it is not that deep, but recent factorization efforts hidden it a > bit. You can see in my original commit it is the very first thing done after entering the muxer. Right now it's several function calls deep. -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] hwcontext_vulkan: let users enable device and instance extensions using options
May 10, 2020, 14:14 by s...@jkqxz.net: > On 10/05/2020 11:51, Lynne wrote: > >> Also documents all options supported by the hwdevice. >> This lets users enable all extensions they need without writing their own >> instance initialization code. >> >> Patch attached. >> >> >> From cf91acc2a907a5ff7af753bf3b2ab495dbc37db0 Mon Sep 17 00:00:00 2001 >> From: Lynne >> Date: Sun, 10 May 2020 11:26:40 +0100 >> Subject: [PATCH 1/2] hwcontext_vulkan: let users enable device and instance >> extensions using options >> >> Also documents all options supported by the hwdevice. >> This lets users enable all extensions they need without writing their own >> instance initialization code. >> --- >> doc/ffmpeg.texi | 15 +++ >> libavutil/hwcontext_vulkan.c | 31 --- >> 2 files changed, 43 insertions(+), 3 deletions(-) >> >> diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi >> index 29753f06ca..d2a30fc868 100644 >> --- a/doc/ffmpeg.texi >> +++ b/doc/ffmpeg.texi >> @@ -1034,6 +1034,18 @@ If @var{device} is an integer, it selects the device >> by its index in a >> system-dependent list of devices. If @var{device} is any other string, it >> selects the first device with a name containing that string as a substring. >> >> +The following options are recognized: >> +@table @option >> +@item debug >> +If set to 1, enables the validation layer, if installed. >> +@item linear_images >> +If set to 1, images allocated by the hwcontext will be linear and locally >> mappable. >> +@item instance_extensions >> +A vertical bar separated list of additional instance extensions to enable. >> +@item device_extensions >> +A vertical bar separated list of additional device extensions to enable. >> +@end table >> + >> Examples: >> @table @emph >> @item -init_hw_device vulkan:1 >> @@ -1041,6 +1053,9 @@ Choose the second device on the system. >> >> @item -init_hw_device vulkan:RADV >> Choose the first device with a name containing the string @emph{RADV}. >> + >> +@item -init_hw_device >> vulkan:0,instance_extensions=VK_KHR_wayland_surface|VK_KHR_xcb_surface >> +Choose the first device and enable the Wayland and XCB instance extensions. >> @end table >> >> @end table >> diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c >> index 43e7cddbc5..a35c1d3a4f 100644 >> --- a/libavutil/hwcontext_vulkan.c >> +++ b/libavutil/hwcontext_vulkan.c >> @@ -261,7 +261,7 @@ static VkBool32 >> vk_dbg_callback(VkDebugUtilsMessageSeverityFlagBitsEXT severity, >> return 0; >> } >> >> -static int check_extensions(AVHWDeviceContext *ctx, int dev, >> +static int check_extensions(AVHWDeviceContext *ctx, int dev, AVDictionary >> *opts, >> const char * const **dst, uint32_t *num, int debug) >> { >> const char *tstr; >> @@ -274,12 +274,14 @@ static int check_extensions(AVHWDeviceContext *ctx, >> int dev, >> int optional_exts_num; >> uint32_t sup_ext_count; >> VkExtensionProperties *sup_ext; >> +AVDictionaryEntry *user_exts = NULL; >> const VulkanOptExtension *optional_exts; >> >> if (!dev) { >> mod = "instance"; >> optional_exts = optional_instance_exts; >> optional_exts_num = FF_ARRAY_ELEMS(optional_instance_exts); >> +user_exts = av_dict_get(opts, "instance_extensions", NULL, 0);w >> vkEnumerateInstanceExtensionProperties(NULL, &sup_ext_count, NULL); >> sup_ext = av_malloc_array(sup_ext_count, sizeof(VkExtensionProperties)); >> if (!sup_ext) >> @@ -289,6 +291,7 @@ static int check_extensions(AVHWDeviceContext *ctx, int >> dev, >> mod = "device"; >> optional_exts = optional_device_exts; >> optional_exts_num = FF_ARRAY_ELEMS(optional_device_exts); >> +user_exts = av_dict_get(opts, "device_extensions", NULL, 0); >> vkEnumerateDeviceExtensionProperties(hwctx->phys_dev, NULL, >> &sup_ext_count, NULL); >> sup_ext = av_malloc_array(sup_ext_count, sizeof(VkExtensionProperties)); >> @@ -345,6 +348,28 @@ static int check_extensions(AVHWDeviceContext *ctx, int >> dev, >> } >> } >> >> +if (user_exts) { >> +char *save, *token = av_strtok(user_exts->value, "|", &save); >> > > Using strtok modifies the string, but that isn't allowed. Maybe strdup() > first? > Didn't know it did. Changed locally. Had to strdup and then free all values, since previously the array was filled with static strings only. >> +while (token) { >> +found = 0; >> +for (int j = 0; j < sup_ext_count; j++) { >> +if (!strcmp(token, sup_ext[j].extensionName)) { >> +found = 1; >> +break; >> +} >> +} >> +if (found) { >> +ADD_VAL_TO_LIST(extension_names, extensions_found, token); >> +} else { >> +av_log(ctx, AV_LOG_ERROR, "%s extension \"%s\" not >> found!\n", >> + mod, token); >> +err = AVERROR(EINVAL); >> +goto end; >> +} >> +
Re: [FFmpeg-devel] [WIP] XComposite window capture demuxer (Linux)
Hi Marton/all, I've re-uploaded the firefox send link (expired) with some sample capture at 60 FPS: https://send.firefox.com/download/51b45decae720c08/#r5o4J2SgCJZndRdMOxxRBg Please note I have integrated usage of OpenGL's Pixel Buffer Objects - now the memory management of the captured framed can be managed by the drivers and hopefully should be DMA and less memory hops. This new code works on both Nvidia and AMD. CPU usage is still higher than x11grab (similar levels as below). Let me know your thoughts. Thanks, Emanuele Ps. quick link to demuxer: https://github.com/Emanem/replayer/blob/master/src/xcompgrab.c On 08/05/2020 11:43, Emanuele Oriani wrote: Hi Marton, Capturing at 60 FPS 1920x1080, the difference is even more noticeable: x11grab is choppy, xcompgrab is smooth (this time I used H264 ultrafast to encode). https://send.firefox.com/download/17001ef60837a5ec/#FaQTa-dP4MB28YfPNMXxuw CPU performance: real user sys - xcompgrab: 10.32s, 18.2s, 0.38s - x11grab: 10.20s, 11.6s, 0.22s Definitely much more CPU usage, but the output quality can't be compared. Please note no frames were lost/skipped, everything was processed on time for both tests. Thanks, Emanuele On 08/05/2020 11:05, Emanuele Oriani wrote: Hi Marton, TL;DR xcompgrab uses more CPU but produces much better streams than x11grab. I have the following CPU usage performance report (on my i7-8700k, Nvidia 2080 Ti RTX, governor set to 'performance', on Ubuntu 18.04 using Gnome shell). The capture has been a surface area of 1720x1376 for 10 seconds at 30 FPS, only getting the frames, not trying to encode them into a file: real user sys - xcompgrab: 10.13s, 2.06s, 0.085s - x11grab: 10.05s, 0.20s, 0.035s from a first outlook x11grab is much more CPU efficient, almost 90% less CPU usage, but upon starting to record the video, it feels like it's 'choppier' and loses frames. Below videos have been captured at 1920x1080, the encoder is exactly the same with same settings and the total CPU time is greater for xcompgrab (as expected). But if you look at both, the xcompgrab doesn't lose frames/is not choppier, instead x11grab seems to be much worse. I've uploaded both 10 secs segments at: https://send.firefox.com/download/0cbf01f9126519c7/#DPKzIfjemAFm263ZSdMOBw The code used to grab and encode is https://github.com/Emanem/replayer again very simple, one thread gets the packets/frames, the other picks the frames and encodes them. Performance of this run has been: real user sys - xcompgrab: 10.42s, 12.5s, 0.22s - x11grab: 10.21s, 8.90s, 0.31s As expected x11grab yields better CPU usage but the quality of output is somehow lacking. Let me know your thoughts. Thanks, Emanuele On 07/05/2020 19:52, Marton Balint wrote: On Thu, 7 May 2020, Emanuele Oriani wrote: Hi FFMPEG devel, I have been writing a simple XComposite window capture demuxer, heavily inspired from x11grab sources and OBS Window capture logic/code. Have you compared performance to x11grab for various resolutions and frame rates? Do you have some numbers? Thanks, Marton I would like to give back to the community and share the sources; before I would formally submit for a review/patch, I would really appreciate if someone could have a high level pass at the code (it's relatively simple actually) and point out any major issues/problems/... The code is available as part of a simple test application on github, at: https://github.com/Emanem/replayer/blob/master/src/xcompgrab.c Being the author of the code I would be happy to re-license it to be used in ffmpeg/libav* mainline once I get the OK from you. In order to compile/execute this code, one needs the following dev packages: libav*-dev, libx11-dev, libxcomposite-dev, OpenGL headers/libs. Libraries to be linked are: -lavcodec -lavformat -lavdevice -lavutil -lswscale -lX11 -lXcomposite -lGL I've tested it and it's working fine on both AMD and Nvidia hardware. Let me know if this is of interest, otherwise no worries and thanks again for the fantastic library/software. Emanuele ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list
Re: [FFmpeg-devel] [PATCH] avformat/mux: Check pkt->stream_index before using it
On Sun, 10 May 2020, Anton Khirnov wrote: Quoting Andreas Rheinhardt (2020-05-08 00:55:00) This commit fixes two recent regressions both of which are about using pkt->stream_index as index in an AVFormatContext's streams array before actually comparing the value with the count of streams in said array. 96e5e6abb9851d7a26ba21703955d5826ac857c0 did this in prepare_input_packet() and 64063512227c4c87a7d16a1076481dc6baf19841 did likewise in write_packets_common(). Signed-off-by: Andreas Rheinhardt --- The same error in the same file applied on the same day by two different people. How unlikely. How is it a regression? Isn't it rather invalid API use? Fun fact: 7b03b65bf0d02519c86750d2da33f413e11cf0c6 Yes, it is kind of invalid API use, but since the check is already there, we should make it actually worthwile. Not that I object to having a check. But then why is check_packet() called so deep and not immediately on entry to the muxer? I guess it is not that deep, but recent factorization efforts hidden it a bit. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 3/3] avcodec/libx264: return error if unknown picture type encountered
Quoting lance.lmw...@gmail.com (2020-04-18 06:52:49) > From: Limin Wang > > Signed-off-by: Limin Wang > --- > libavcodec/libx264.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c > index edd343e..3fa2311 100644 > --- a/libavcodec/libx264.c > +++ b/libavcodec/libx264.c > @@ -476,7 +476,8 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, > const AVFrame *frame, > pict_type = AV_PICTURE_TYPE_B; > break; > default: > -pict_type = AV_PICTURE_TYPE_NONE; > +av_log(ctx, AV_LOG_ERROR, "Unknown picture type encountered.\n"); > +return AVERROR_EXTERNAL; Why should that cause encoding to fail? And when would this happen? -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/mux: Check pkt->stream_index before using it
Quoting Andreas Rheinhardt (2020-05-08 00:55:00) > This commit fixes two recent regressions both of which are about using > pkt->stream_index as index in an AVFormatContext's streams array before > actually comparing the value with the count of streams in said array. > 96e5e6abb9851d7a26ba21703955d5826ac857c0 did this in > prepare_input_packet() and 64063512227c4c87a7d16a1076481dc6baf19841 did > likewise in write_packets_common(). > > Signed-off-by: Andreas Rheinhardt > --- > The same error in the same file applied on the same day by two different > people. How unlikely. How is it a regression? Isn't it rather invalid API use? Not that I object to having a check. But then why is check_packet() called so deep and not immediately on entry to the muxer? -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec: Add MediaFoundation encoder wrapper
On Sat, May 9, 2020, at 1:41 PM, Martin Storsjö wrote: > + --enable-mf enable decoding via MediaFoundation [auto] encoding/decoding typo I presume. I would prefer --enable-mediafoundation as it is more descriptive. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] avcodec/mpegvideo: prefer to use variable instead of type for sizeof
On Sun, 10 May 2020, lance.lmw...@gmail.com wrote: From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/mpegvideo.c | 48 1 file changed, 24 insertions(+), 24 deletions(-) If you find these cosmetics interesting, then I suggest you introduce a new macro instead: FF_ALLOCZ_ARRAY_OR_GOTO(). E.g.: FF_ALLOCZ_ARRAY_OR_GOTO(s->avctx, s->me.map, ME_MAP_SIZE, fail) Regards, Marton diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 49fd1c9..561062f 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -373,15 +373,15 @@ static int init_duplicate_context(MpegEncContext *s) if (s->encoding) { FF_ALLOCZ_OR_GOTO(s->avctx, s->me.map, - ME_MAP_SIZE * sizeof(uint32_t), fail) + ME_MAP_SIZE * sizeof(*s->me.map), fail) FF_ALLOCZ_OR_GOTO(s->avctx, s->me.score_map, - ME_MAP_SIZE * sizeof(uint32_t), fail) + ME_MAP_SIZE * sizeof(*s->me.score_map), fail) if (s->noise_reduction) { FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_error_sum, - 2 * 64 * sizeof(int), fail) + 2 * 64 * sizeof(*s->dct_error_sum), fail) } } -FF_ALLOCZ_OR_GOTO(s->avctx, s->blocks, 64 * 12 * 2 * sizeof(int16_t), fail) +FF_ALLOCZ_OR_GOTO(s->avctx, s->blocks, 64 * 12 * 2 * sizeof(*s->blocks), fail) s->block = s->blocks[0]; for (i = 0; i < 12; i++) { @@ -400,7 +400,7 @@ static int init_duplicate_context(MpegEncContext *s) if (s->out_format == FMT_H263) { /* ac values */ FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_val_base, - yc_size * sizeof(int16_t) * 16, fail); + yc_size * sizeof(*s->ac_val_base) * 16, fail); s->ac_val[0] = s->ac_val_base + s->b8_stride + 1; s->ac_val[1] = s->ac_val_base + y_size + s->mb_stride + 1; s->ac_val[2] = s->ac_val[1] + c_size; @@ -715,7 +715,7 @@ static int init_context_frame(MpegEncContext *s) if (s->mb_height & 1) yc_size += 2*s->b8_stride + 2*s->mb_stride; -FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int), +FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(*s->mb_index2xy), fail); // error resilience code looks cleaner with this for (y = 0; y < s->mb_height; y++) for (x = 0; x < s->mb_width; x++) @@ -725,12 +725,12 @@ static int init_context_frame(MpegEncContext *s) if (s->encoding) { /* Allocate MV tables */ -FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail) -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail) -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail) -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail) -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail) -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail) +FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base, mv_table_size * 2 * sizeof(*s->p_mv_table_base), fail) +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base, mv_table_size * 2 * sizeof(*s->b_forw_mv_table_base), fail) +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base, mv_table_size * 2 * sizeof(*s->b_back_mv_table_base), fail) +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base, mv_table_size * 2 * sizeof(*s->b_bidir_forw_mv_table_base), fail) +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base, mv_table_size * 2 * sizeof(*s->b_bidir_back_mv_table_base), fail) +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base, mv_table_size * 2 * sizeof(*s->b_direct_mv_table_base), fail) s->p_mv_table= s->p_mv_table_base + s->mb_stride + 1; s->b_forw_mv_table = s->b_forw_mv_table_base + s->mb_stride + 1; s->b_back_mv_table = s->b_back_mv_table_base + s->mb_stride + 1; @@ -739,14 +739,14 @@ static int init_context_frame(MpegEncContext *s) s->b_direct_mv_table = s->b_direct_mv_table_base + s->mb_stride + 1; /* Allocate MB type table */ -FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_type, mb_array_size * sizeof(uint16_t), fail) // needed for encoding +FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_type, mb_array_size * sizeof(*s->mb_type), fail) // needed for encoding -FF_ALLOCZ_OR_GOTO(s->avctx, s->lambda_table, mb_array_size * sizeof(int), fail) +FF_ALLOCZ_OR_GOTO(s->avctx, s->lambda_table, mb_array_size * sizeof(*s->lambda_table), fail)
[FFmpeg-devel] [PATCH] Speedhq: Decode field 2 correctly
This is similar to field 1 (effd2e72) --- libavcodec/speedhq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/speedhq.c b/libavcodec/speedhq.c index 890b8253cd..b834b79f28 100644 --- a/libavcodec/speedhq.c +++ b/libavcodec/speedhq.c @@ -447,7 +447,7 @@ static int speedhq_decode_frame(AVCodecContext *avctx, } frame->key_frame = 1; -if (second_field_offset == 4) { +if (second_field_offset == 4 || second_field_offset == (buf_size-4)) { /* * Overlapping first and second fields is used to signal * encoding only a single field. In this case, "height" -- 2.26.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/2] avcodec/mpegvideo: cosmetics
From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/mpegvideo.c | 27 ++- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 561062f..b993813 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -725,12 +725,18 @@ static int init_context_frame(MpegEncContext *s) if (s->encoding) { /* Allocate MV tables */ -FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base, mv_table_size * 2 * sizeof(*s->p_mv_table_base), fail) -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base, mv_table_size * 2 * sizeof(*s->b_forw_mv_table_base), fail) -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base, mv_table_size * 2 * sizeof(*s->b_back_mv_table_base), fail) -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base, mv_table_size * 2 * sizeof(*s->b_bidir_forw_mv_table_base), fail) -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base, mv_table_size * 2 * sizeof(*s->b_bidir_back_mv_table_base), fail) -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base, mv_table_size * 2 * sizeof(*s->b_direct_mv_table_base), fail) +FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base, + mv_table_size * 2 * sizeof(*s->p_mv_table_base), fail) +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base, + mv_table_size * 2 * sizeof(*s->b_forw_mv_table_base), fail) +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base, + mv_table_size * 2 * sizeof(*s->b_back_mv_table_base), fail) +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base, + mv_table_size * 2 * sizeof(*s->b_bidir_forw_mv_table_base), fail) +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base, + mv_table_size * 2 * sizeof(*s->b_bidir_back_mv_table_base), fail) +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base, + mv_table_size * 2 * sizeof(*s->b_direct_mv_table_base), fail) s->p_mv_table= s->p_mv_table_base + s->mb_stride + 1; s->b_forw_mv_table = s->b_forw_mv_table_base + s->mb_stride + 1; s->b_back_mv_table = s->b_back_mv_table_base + s->mb_stride + 1; @@ -764,11 +770,14 @@ static int init_context_frame(MpegEncContext *s) s->b_field_mv_table[i][j][k] = s->b_field_mv_table_base[i][j][k] + s->mb_stride + 1; } -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_field_select_table [i][j], mb_array_size * 2 * sizeof(*s->b_field_select_table [i][j]), fail) -FF_ALLOCZ_OR_GOTO(s->avctx, s->p_field_mv_table_base[i][j], mv_table_size * 2 * sizeof(*s->p_field_mv_table_base[i][j]), fail) +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_field_select_table [i][j], + mb_array_size * 2 * sizeof(*s->b_field_select_table [i][j]), fail) +FF_ALLOCZ_OR_GOTO(s->avctx, s->p_field_mv_table_base[i][j], + mv_table_size * 2 * sizeof(*s->p_field_mv_table_base[i][j]), fail) s->p_field_mv_table[i][j] = s->p_field_mv_table_base[i][j] + s->mb_stride + 1; } -FF_ALLOCZ_OR_GOTO(s->avctx, s->p_field_select_table[i], mb_array_size * 2 * sizeof(*s->p_field_select_table[i]), fail) +FF_ALLOCZ_OR_GOTO(s->avctx, s->p_field_select_table[i], + mb_array_size * 2 * sizeof(*s->p_field_select_table[i]), fail) } } if (s->out_format == FMT_H263) { -- 1.8.3.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH V3] avformat: Add Dynacolor MVC Demuxer
Please see new version of the patch with the changes addressed. Thanks Tom From f91f5931fcc381cbcddb8abc03dde3f81c33a085 Mon Sep 17 00:00:00 2001 From: Tom Needham <06needh...@gmail.com> Date: Sun, 10 May 2020 16:42:00 +0100 Subject: [PATCH] avformat: Add Dynacolor MVC Demuxer This demuxer adds support for demuxing files in the Dynacolor format such as the sample located at: http://samples.ffmpeg.org/camera-dvr/dynacolor/dynacolor-camera-sample However some decode errors are showing on the resulting MPEG4 stream. I don't know whether this is a bug with the demuxer or the file as there is only one sample but the output results in a 1 second mp4 file that is playable in VLC media player. Signed-off-by: Tom Needham <06needh...@gmail.com> --- Changelog| 1 + doc/general.texi | 1 + libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/dynacolor.c | 411 +++ libavformat/dynacolor.h | 209 libavformat/version.h| 2 +- 7 files changed, 625 insertions(+), 1 deletion(-) create mode 100644 libavformat/dynacolor.c create mode 100644 libavformat/dynacolor.h diff --git a/Changelog b/Changelog index 711861bda9..79d39494c9 100644 --- a/Changelog +++ b/Changelog @@ -54,6 +54,7 @@ version : - DERF demuxer - CRI HCA decoder - CRI HCA demuxer +- Dynacolor MVC Demuxer version 4.2: diff --git a/doc/general.texi b/doc/general.texi index 752618a00b..4eb4716d87 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -452,6 +452,7 @@ library: @item DXA @tab @tab X @tab This format is used in the non-Windows version of the Feeble Files game and different game cutscenes repacked for use with ScummVM. +@item Dynacolor MVC @tab @tab X @item Electronic Arts cdata @tab@tab X @item Electronic Arts Multimedia @tab@tab X @tab Used in various EA games; files have extensions like WVE and UV2. diff --git a/libavformat/Makefile b/libavformat/Makefile index 8fd0d43721..4d1ca8b7ed 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -169,6 +169,7 @@ OBJS-$(CONFIG_DV_MUXER) += dvenc.o OBJS-$(CONFIG_DVBSUB_DEMUXER)+= dvbsub.o rawdec.o OBJS-$(CONFIG_DVBTXT_DEMUXER)+= dvbtxt.o rawdec.o OBJS-$(CONFIG_DXA_DEMUXER) += dxa.o +OBJS-$(CONFIG_DYNACOLOR_DEMUXER) += dynacolor.o OBJS-$(CONFIG_EA_CDATA_DEMUXER) += eacdata.o OBJS-$(CONFIG_EA_DEMUXER)+= electronicarts.o OBJS-$(CONFIG_EAC3_DEMUXER) += ac3dec.o rawdec.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 39d2c352f5..50f3926b05 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -131,6 +131,7 @@ extern AVOutputFormat ff_dv_muxer; extern AVInputFormat ff_dvbsub_demuxer; extern AVInputFormat ff_dvbtxt_demuxer; extern AVInputFormat ff_dxa_demuxer; +extern AVInputFormat ff_dynacolor_demuxer; extern AVInputFormat ff_ea_demuxer; extern AVInputFormat ff_ea_cdata_demuxer; extern AVInputFormat ff_eac3_demuxer; diff --git a/libavformat/dynacolor.c b/libavformat/dynacolor.c new file mode 100644 index 00..05a32b5299 --- /dev/null +++ b/libavformat/dynacolor.c @@ -0,0 +1,411 @@ +/* + * Dynacolor MVC Demuxer + * Copyright (c) 2020 Tom Needham + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include "avformat.h" +#include "internal.h" +#include "dynacolor.h" +#include "libavutil/channel_layout.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/mathematics.h" +#include "libavutil/timecode.h" +#include "libavutil/avassert.h" + +int ff_dyna_read_packet_header(AVFormatContext *ctx, AVIOContext *pb, unsigned char *pes_data, DynacolorPesHeader *pes, + unsigned int *size, time_t *time, DynacolorHeader *header, unsigned int *basicIdx_H, unsigned int *basicIdx_L, + unsigned char first) +{ +int ret = 0; +unsigned int stream_format; + +*(basicIdx_H) = avio_rl32(pb); + +header->Basic.Header1= *(basicIdx_H)&0xFF; +header->Basic.Header2= *(basicIdx_H) >> 8 & 0xFF; +header->Basic.reserved = *(basicIdx_H) >> 16 & 0x0F; +hea
[FFmpeg-devel] [PATCH 1/2] avcodec/mpegvideo: prefer to use variable instead of type for sizeof
From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/mpegvideo.c | 48 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 49fd1c9..561062f 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -373,15 +373,15 @@ static int init_duplicate_context(MpegEncContext *s) if (s->encoding) { FF_ALLOCZ_OR_GOTO(s->avctx, s->me.map, - ME_MAP_SIZE * sizeof(uint32_t), fail) + ME_MAP_SIZE * sizeof(*s->me.map), fail) FF_ALLOCZ_OR_GOTO(s->avctx, s->me.score_map, - ME_MAP_SIZE * sizeof(uint32_t), fail) + ME_MAP_SIZE * sizeof(*s->me.score_map), fail) if (s->noise_reduction) { FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_error_sum, - 2 * 64 * sizeof(int), fail) + 2 * 64 * sizeof(*s->dct_error_sum), fail) } } -FF_ALLOCZ_OR_GOTO(s->avctx, s->blocks, 64 * 12 * 2 * sizeof(int16_t), fail) +FF_ALLOCZ_OR_GOTO(s->avctx, s->blocks, 64 * 12 * 2 * sizeof(*s->blocks), fail) s->block = s->blocks[0]; for (i = 0; i < 12; i++) { @@ -400,7 +400,7 @@ static int init_duplicate_context(MpegEncContext *s) if (s->out_format == FMT_H263) { /* ac values */ FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_val_base, - yc_size * sizeof(int16_t) * 16, fail); + yc_size * sizeof(*s->ac_val_base) * 16, fail); s->ac_val[0] = s->ac_val_base + s->b8_stride + 1; s->ac_val[1] = s->ac_val_base + y_size + s->mb_stride + 1; s->ac_val[2] = s->ac_val[1] + c_size; @@ -715,7 +715,7 @@ static int init_context_frame(MpegEncContext *s) if (s->mb_height & 1) yc_size += 2*s->b8_stride + 2*s->mb_stride; -FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int), +FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(*s->mb_index2xy), fail); // error resilience code looks cleaner with this for (y = 0; y < s->mb_height; y++) for (x = 0; x < s->mb_width; x++) @@ -725,12 +725,12 @@ static int init_context_frame(MpegEncContext *s) if (s->encoding) { /* Allocate MV tables */ -FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail) -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail) -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail) -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail) -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail) -FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail) +FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base, mv_table_size * 2 * sizeof(*s->p_mv_table_base), fail) +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base, mv_table_size * 2 * sizeof(*s->b_forw_mv_table_base), fail) +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base, mv_table_size * 2 * sizeof(*s->b_back_mv_table_base), fail) +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base, mv_table_size * 2 * sizeof(*s->b_bidir_forw_mv_table_base), fail) +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base, mv_table_size * 2 * sizeof(*s->b_bidir_back_mv_table_base), fail) +FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base, mv_table_size * 2 * sizeof(*s->b_direct_mv_table_base), fail) s->p_mv_table= s->p_mv_table_base + s->mb_stride + 1; s->b_forw_mv_table = s->b_forw_mv_table_base + s->mb_stride + 1; s->b_back_mv_table = s->b_back_mv_table_base + s->mb_stride + 1; @@ -739,14 +739,14 @@ static int init_context_frame(MpegEncContext *s) s->b_direct_mv_table = s->b_direct_mv_table_base + s->mb_stride + 1; /* Allocate MB type table */ -FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_type, mb_array_size * sizeof(uint16_t), fail) // needed for encoding +FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_type, mb_array_size * sizeof(*s->mb_type), fail) // needed for encoding -FF_ALLOCZ_OR_GOTO(s->avctx, s->lambda_table, mb_array_size * sizeof(int), fail) +FF_ALLOCZ_OR_GOTO(s->avctx, s->lambda_table, mb_array_size * sizeof(*s->lambda_table), fail) FF_ALLOC_OR_GOTO(s->avctx, s->cplx_tab, - mb_array_size * sizeof(float), fail); + mb_array_size * sizeof(*s->cplx_tab), fail); FF_ALLOC_OR_GOTO(s->avctx, s->bits_tab,
[FFmpeg-devel] [PATCH 2/2] hwcontext_vulkan: expose enabled device and instance extensions
This solves a huge oversight - it lets users reliably use their own AVVulkanDeviceContext. Otherwise, the extensions supplied and enabled are not discoverable by anything outside of hwcontext_vulkan. Patch attached. This, and the previous patch to enable extensions through the options are really needed to make the hwcontext useful and interoperable with other Vulkan API users, so I'm planning to push them later tonight. >From 9a3169afafd1cc668f8f9f78fceef46e322963d6 Mon Sep 17 00:00:00 2001 From: Lynne Date: Sun, 10 May 2020 11:47:50 +0100 Subject: [PATCH 2/2] hwcontext_vulkan: expose enabled device and instance extensions This solves a huge oversight - it lets users reliably use their own AVVulkanDeviceContext. Otherwise, the extensions supplied and enabled are not discoverable by anything outside of hwcontext_vulkan. --- libavutil/hwcontext_vulkan.c | 27 ++- libavutil/hwcontext_vulkan.h | 12 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index a35c1d3a4f..4135cc5209 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -415,13 +415,11 @@ static int create_instance(AVHWDeviceContext *ctx, AVDictionary *opts) /* Try to create the instance */ ret = vkCreateInstance(&inst_props, hwctx->alloc, &hwctx->inst); -/* Free used memory */ -av_free((void *)inst_props.ppEnabledExtensionNames); - /* Check for errors */ if (ret != VK_SUCCESS) { av_log(ctx, AV_LOG_ERROR, "Instance creation failure: %s\n", vk_ret2str(ret)); +av_free((void *)inst_props.ppEnabledExtensionNames); return AVERROR_EXTERNAL; } @@ -444,6 +442,9 @@ static int create_instance(AVHWDeviceContext *ctx, AVDictionary *opts) hwctx->alloc, &p->debug_ctx); } +hwctx->enabled_inst_extensions = inst_props.ppEnabledExtensionNames; +hwctx->num_enabled_inst_extensions = inst_props.enabledExtensionCount; + return 0; } @@ -749,6 +750,9 @@ static void vulkan_device_free(AVHWDeviceContext *ctx) } vkDestroyInstance(hwctx->inst, hwctx->alloc); + +av_free((void *)hwctx->enabled_inst_extensions); +av_free((void *)hwctx->enabled_dev_extensions); } static int vulkan_device_create_internal(AVHWDeviceContext *ctx, @@ -809,11 +813,10 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, ret = vkCreateDevice(hwctx->phys_dev, &dev_info, hwctx->alloc, &hwctx->act_dev); -av_free((void *)dev_info.ppEnabledExtensionNames); - if (ret != VK_SUCCESS) { av_log(ctx, AV_LOG_ERROR, "Device creation failure: %s\n", vk_ret2str(ret)); +av_free((void *)dev_info.ppEnabledExtensionNames); err = AVERROR_EXTERNAL; goto end; } @@ -823,6 +826,9 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, if (opt_d) p->use_linear_images = strtol(opt_d->value, NULL, 10); +hwctx->enabled_dev_extensions = dev_info.ppEnabledExtensionNames; +hwctx->num_enabled_dev_extensions = dev_info.enabledExtensionCount; + end: return err; } @@ -834,6 +840,17 @@ static int vulkan_device_init(AVHWDeviceContext *ctx) AVVulkanDeviceContext *hwctx = ctx->hwctx; VulkanDevicePriv *p = ctx->internal->priv; +/* Set device extension flags */ +for (int i = 0; i < hwctx->num_enabled_dev_extensions; i++) { +for (int j = 0; j < FF_ARRAY_ELEMS(optional_device_exts); j++) { +if (!strcmp(hwctx->enabled_dev_extensions[i], +optional_device_exts[j].name)) { +p->extensions |= optional_device_exts[j].flag; +break; +} +} +} + vkGetPhysicalDeviceQueueFamilyProperties(hwctx->phys_dev, &queue_num, NULL); if (!queue_num) { av_log(ctx, AV_LOG_ERROR, "Failed to get queues!\n"); diff --git a/libavutil/hwcontext_vulkan.h b/libavutil/hwcontext_vulkan.h index ebc28916f3..2f9f92a3a2 100644 --- a/libavutil/hwcontext_vulkan.h +++ b/libavutil/hwcontext_vulkan.h @@ -42,6 +42,11 @@ typedef struct AVVulkanDeviceContext { * Instance */ VkInstance inst; +/** + * Enabled instance extensions. By default, VK_KHR_surface is enabled if found. + */ +const char * const *enabled_inst_extensions; +int num_enabled_inst_extensions; /** * Physical device */ @@ -50,6 +55,13 @@ typedef struct AVVulkanDeviceContext { * Active device */ VkDevice act_dev; +/** + * Enabled device extensions. By default, VK_KHR_external_memory_fd, + * VK_EXT_external_memory_dma_buf, VK_EXT_image_drm_format_modifier and + * VK_KHR_external_semaphore_fd are enabled if found. + */ +const char * const *enabled_dev_extensions; +int num_enabled_dev_extensions; /** * Queue family index for g
[FFmpeg-devel] [PATCH 1/2] hwcontext_vulkan: let users enable device and instance extensions using options
Also documents all options supported by the hwdevice. This lets users enable all extensions they need without writing their own instance initialization code. Patch attached. >From cf91acc2a907a5ff7af753bf3b2ab495dbc37db0 Mon Sep 17 00:00:00 2001 From: Lynne Date: Sun, 10 May 2020 11:26:40 +0100 Subject: [PATCH 1/2] hwcontext_vulkan: let users enable device and instance extensions using options Also documents all options supported by the hwdevice. This lets users enable all extensions they need without writing their own instance initialization code. --- doc/ffmpeg.texi | 15 +++ libavutil/hwcontext_vulkan.c | 31 --- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 29753f06ca..d2a30fc868 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -1034,6 +1034,18 @@ If @var{device} is an integer, it selects the device by its index in a system-dependent list of devices. If @var{device} is any other string, it selects the first device with a name containing that string as a substring. +The following options are recognized: +@table @option +@item debug +If set to 1, enables the validation layer, if installed. +@item linear_images +If set to 1, images allocated by the hwcontext will be linear and locally mappable. +@item instance_extensions +A vertical bar separated list of additional instance extensions to enable. +@item device_extensions +A vertical bar separated list of additional device extensions to enable. +@end table + Examples: @table @emph @item -init_hw_device vulkan:1 @@ -1041,6 +1053,9 @@ Choose the second device on the system. @item -init_hw_device vulkan:RADV Choose the first device with a name containing the string @emph{RADV}. + +@item -init_hw_device vulkan:0,instance_extensions=VK_KHR_wayland_surface|VK_KHR_xcb_surface +Choose the first device and enable the Wayland and XCB instance extensions. @end table @end table diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index 43e7cddbc5..a35c1d3a4f 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -261,7 +261,7 @@ static VkBool32 vk_dbg_callback(VkDebugUtilsMessageSeverityFlagBitsEXT severity, return 0; } -static int check_extensions(AVHWDeviceContext *ctx, int dev, +static int check_extensions(AVHWDeviceContext *ctx, int dev, AVDictionary *opts, const char * const **dst, uint32_t *num, int debug) { const char *tstr; @@ -274,12 +274,14 @@ static int check_extensions(AVHWDeviceContext *ctx, int dev, int optional_exts_num; uint32_t sup_ext_count; VkExtensionProperties *sup_ext; +AVDictionaryEntry *user_exts = NULL; const VulkanOptExtension *optional_exts; if (!dev) { mod = "instance"; optional_exts = optional_instance_exts; optional_exts_num = FF_ARRAY_ELEMS(optional_instance_exts); +user_exts = av_dict_get(opts, "instance_extensions", NULL, 0); vkEnumerateInstanceExtensionProperties(NULL, &sup_ext_count, NULL); sup_ext = av_malloc_array(sup_ext_count, sizeof(VkExtensionProperties)); if (!sup_ext) @@ -289,6 +291,7 @@ static int check_extensions(AVHWDeviceContext *ctx, int dev, mod = "device"; optional_exts = optional_device_exts; optional_exts_num = FF_ARRAY_ELEMS(optional_device_exts); +user_exts = av_dict_get(opts, "device_extensions", NULL, 0); vkEnumerateDeviceExtensionProperties(hwctx->phys_dev, NULL, &sup_ext_count, NULL); sup_ext = av_malloc_array(sup_ext_count, sizeof(VkExtensionProperties)); @@ -345,6 +348,28 @@ static int check_extensions(AVHWDeviceContext *ctx, int dev, } } +if (user_exts) { +char *save, *token = av_strtok(user_exts->value, "|", &save); +while (token) { +found = 0; +for (int j = 0; j < sup_ext_count; j++) { +if (!strcmp(token, sup_ext[j].extensionName)) { +found = 1; +break; +} +} +if (found) { +ADD_VAL_TO_LIST(extension_names, extensions_found, token); +} else { +av_log(ctx, AV_LOG_ERROR, "%s extension \"%s\" not found!\n", + mod, token); +err = AVERROR(EINVAL); +goto end; +} +token = av_strtok(NULL, "|", &save); +} +} + *dst = extension_names; *num = extensions_found; @@ -376,7 +401,7 @@ static int create_instance(AVHWDeviceContext *ctx, AVDictionary *opts) }; /* Check for present/missing extensions */ -err = check_extensions(ctx, 0, &inst_props.ppEnabledExtensionNames, +err = check_extensions(ctx, 0, opts, &inst_props.ppEnabledExtensionNames, &inst_props.enabledExtensionC
Re: [FFmpeg-devel] [PATCH 2/2] hwcontext_vulkan: expose enabled device and instance extensions
On 10/05/2020 11:54, Lynne wrote: > This solves a huge oversight - it lets users reliably use their own > AVVulkanDeviceContext. Otherwise, the extensions supplied and enabled > are not discoverable by anything outside of hwcontext_vulkan. > > Patch attached. > > This, and the previous patch to enable extensions through the options are > really needed > to make the hwcontext useful and interoperable with other Vulkan API users, > so I'm planning > to push them later tonight. > > > From 9a3169afafd1cc668f8f9f78fceef46e322963d6 Mon Sep 17 00:00:00 2001 > From: Lynne > Date: Sun, 10 May 2020 11:47:50 +0100 > Subject: [PATCH 2/2] hwcontext_vulkan: expose enabled device and instance > extensions > > This solves a huge oversight - it lets users reliably use their own > AVVulkanDeviceContext. Otherwise, the extensions supplied and enabled > are not discoverable by anything outside of hwcontext_vulkan. > --- > libavutil/hwcontext_vulkan.c | 27 ++- > libavutil/hwcontext_vulkan.h | 12 > 2 files changed, 34 insertions(+), 5 deletions(-) > > diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c > index a35c1d3a4f..4135cc5209 100644 > --- a/libavutil/hwcontext_vulkan.c > +++ b/libavutil/hwcontext_vulkan.c > @@ -415,13 +415,11 @@ static int create_instance(AVHWDeviceContext *ctx, > AVDictionary *opts) > /* Try to create the instance */ > ret = vkCreateInstance(&inst_props, hwctx->alloc, &hwctx->inst); > > -/* Free used memory */ > -av_free((void *)inst_props.ppEnabledExtensionNames); > - > /* Check for errors */ > if (ret != VK_SUCCESS) { > av_log(ctx, AV_LOG_ERROR, "Instance creation failure: %s\n", > vk_ret2str(ret)); > +av_free((void *)inst_props.ppEnabledExtensionNames); > return AVERROR_EXTERNAL; > } > > @@ -444,6 +442,9 @@ static int create_instance(AVHWDeviceContext *ctx, > AVDictionary *opts) > hwctx->alloc, &p->debug_ctx); > } > > +hwctx->enabled_inst_extensions = inst_props.ppEnabledExtensionNames; > +hwctx->num_enabled_inst_extensions = inst_props.enabledExtensionCount; > + > return 0; > } > > @@ -749,6 +750,9 @@ static void vulkan_device_free(AVHWDeviceContext *ctx) > } > > vkDestroyInstance(hwctx->inst, hwctx->alloc); > + > +av_free((void *)hwctx->enabled_inst_extensions); > +av_free((void *)hwctx->enabled_dev_extensions); > } > > static int vulkan_device_create_internal(AVHWDeviceContext *ctx, > @@ -809,11 +813,10 @@ static int > vulkan_device_create_internal(AVHWDeviceContext *ctx, > ret = vkCreateDevice(hwctx->phys_dev, &dev_info, hwctx->alloc, > &hwctx->act_dev); > > -av_free((void *)dev_info.ppEnabledExtensionNames); > - > if (ret != VK_SUCCESS) { > av_log(ctx, AV_LOG_ERROR, "Device creation failure: %s\n", > vk_ret2str(ret)); > +av_free((void *)dev_info.ppEnabledExtensionNames); > err = AVERROR_EXTERNAL; > goto end; > } > @@ -823,6 +826,9 @@ static int > vulkan_device_create_internal(AVHWDeviceContext *ctx, > if (opt_d) > p->use_linear_images = strtol(opt_d->value, NULL, 10); > > +hwctx->enabled_dev_extensions = dev_info.ppEnabledExtensionNames; > +hwctx->num_enabled_dev_extensions = dev_info.enabledExtensionCount; > + > end: > return err; > } > @@ -834,6 +840,17 @@ static int vulkan_device_init(AVHWDeviceContext *ctx) > AVVulkanDeviceContext *hwctx = ctx->hwctx; > VulkanDevicePriv *p = ctx->internal->priv; > > +/* Set device extension flags */ > +for (int i = 0; i < hwctx->num_enabled_dev_extensions; i++) { > +for (int j = 0; j < FF_ARRAY_ELEMS(optional_device_exts); j++) { > +if (!strcmp(hwctx->enabled_dev_extensions[i], > +optional_device_exts[j].name)) { > +p->extensions |= optional_device_exts[j].flag; > +break; > +} > +} > +} > + > vkGetPhysicalDeviceQueueFamilyProperties(hwctx->phys_dev, &queue_num, > NULL); > if (!queue_num) { > av_log(ctx, AV_LOG_ERROR, "Failed to get queues!\n"); > diff --git a/libavutil/hwcontext_vulkan.h b/libavutil/hwcontext_vulkan.h > index ebc28916f3..2f9f92a3a2 100644 > --- a/libavutil/hwcontext_vulkan.h > +++ b/libavutil/hwcontext_vulkan.h > @@ -42,6 +42,11 @@ typedef struct AVVulkanDeviceContext { > * Instance > */ > VkInstance inst; > +/** > + * Enabled instance extensions. By default, VK_KHR_surface is enabled if > found. > + */ Clarify how this should be set by the user if they are supplying the instance? (From code, looks like it's not used.) > +const char * const *enabled_inst_extensions; > +int num_enabled_inst_extensions; > /** > * Physical device > */ > @@ -50,6 +55,13 @@ typedef struct AVVulkanDev
Re: [FFmpeg-devel] [PATCH 1/2] hwcontext_vulkan: let users enable device and instance extensions using options
On 10/05/2020 11:51, Lynne wrote: > Also documents all options supported by the hwdevice. > This lets users enable all extensions they need without writing their own > instance initialization code. > > Patch attached. > > > From cf91acc2a907a5ff7af753bf3b2ab495dbc37db0 Mon Sep 17 00:00:00 2001 > From: Lynne > Date: Sun, 10 May 2020 11:26:40 +0100 > Subject: [PATCH 1/2] hwcontext_vulkan: let users enable device and instance > extensions using options > > Also documents all options supported by the hwdevice. > This lets users enable all extensions they need without writing their own > instance initialization code. > --- > doc/ffmpeg.texi | 15 +++ > libavutil/hwcontext_vulkan.c | 31 --- > 2 files changed, 43 insertions(+), 3 deletions(-) > > diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi > index 29753f06ca..d2a30fc868 100644 > --- a/doc/ffmpeg.texi > +++ b/doc/ffmpeg.texi > @@ -1034,6 +1034,18 @@ If @var{device} is an integer, it selects the device > by its index in a > system-dependent list of devices. If @var{device} is any other string, it > selects the first device with a name containing that string as a substring. > > +The following options are recognized: > +@table @option > +@item debug > +If set to 1, enables the validation layer, if installed. > +@item linear_images > +If set to 1, images allocated by the hwcontext will be linear and locally > mappable. > +@item instance_extensions > +A vertical bar separated list of additional instance extensions to enable. > +@item device_extensions > +A vertical bar separated list of additional device extensions to enable. > +@end table > + > Examples: > @table @emph > @item -init_hw_device vulkan:1 > @@ -1041,6 +1053,9 @@ Choose the second device on the system. > > @item -init_hw_device vulkan:RADV > Choose the first device with a name containing the string @emph{RADV}. > + > +@item -init_hw_device > vulkan:0,instance_extensions=VK_KHR_wayland_surface|VK_KHR_xcb_surface > +Choose the first device and enable the Wayland and XCB instance extensions. > @end table > > @end table > diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c > index 43e7cddbc5..a35c1d3a4f 100644 > --- a/libavutil/hwcontext_vulkan.c > +++ b/libavutil/hwcontext_vulkan.c > @@ -261,7 +261,7 @@ static VkBool32 > vk_dbg_callback(VkDebugUtilsMessageSeverityFlagBitsEXT severity, > return 0; > } > > -static int check_extensions(AVHWDeviceContext *ctx, int dev, > +static int check_extensions(AVHWDeviceContext *ctx, int dev, AVDictionary > *opts, > const char * const **dst, uint32_t *num, int > debug) > { > const char *tstr; > @@ -274,12 +274,14 @@ static int check_extensions(AVHWDeviceContext *ctx, int > dev, > int optional_exts_num; > uint32_t sup_ext_count; > VkExtensionProperties *sup_ext; > +AVDictionaryEntry *user_exts = NULL; > const VulkanOptExtension *optional_exts; > > if (!dev) { > mod = "instance"; > optional_exts = optional_instance_exts; > optional_exts_num = FF_ARRAY_ELEMS(optional_instance_exts); > +user_exts = av_dict_get(opts, "instance_extensions", NULL, 0);w > vkEnumerateInstanceExtensionProperties(NULL, &sup_ext_count, NULL); > sup_ext = av_malloc_array(sup_ext_count, > sizeof(VkExtensionProperties)); > if (!sup_ext) > @@ -289,6 +291,7 @@ static int check_extensions(AVHWDeviceContext *ctx, int > dev, > mod = "device"; > optional_exts = optional_device_exts; > optional_exts_num = FF_ARRAY_ELEMS(optional_device_exts); > +user_exts = av_dict_get(opts, "device_extensions", NULL, 0); > vkEnumerateDeviceExtensionProperties(hwctx->phys_dev, NULL, > &sup_ext_count, NULL); > sup_ext = av_malloc_array(sup_ext_count, > sizeof(VkExtensionProperties)); > @@ -345,6 +348,28 @@ static int check_extensions(AVHWDeviceContext *ctx, int > dev, > } > } > > +if (user_exts) { > +char *save, *token = av_strtok(user_exts->value, "|", &save); Using strtok modifies the string, but that isn't allowed. Maybe strdup() first? > +while (token) { > +found = 0; > +for (int j = 0; j < sup_ext_count; j++) { > +if (!strcmp(token, sup_ext[j].extensionName)) { > +found = 1; > +break; > +} > +} > +if (found) { > +ADD_VAL_TO_LIST(extension_names, extensions_found, token); > +} else { > +av_log(ctx, AV_LOG_ERROR, "%s extension \"%s\" not found!\n", > + mod, token); > +err = AVERROR(EINVAL); > +goto end; > +} > +token = av_strtok(NULL, "|", &save); > +} > +} > + > *dst = extension_names; >
Re: [FFmpeg-devel] [PATCH] avcodec: Add MediaFoundation encoder wrapper
On 5/9/2020 6:41 PM, Martin Storsjö wrote: > +#define MF_ENCODER(MEDIATYPE, NAME, ID, OPTS, EXTRA) \ > +static const AVClass ff_ ## NAME ## _mf_encoder_class = { > \ > +.class_name = #NAME "_mf", > \ > +.item_name = av_default_item_name, > \ > +.option = OPTS, > \ > +.version= LIBAVUTIL_VERSION_INT, > \ > +}; > \ > +AVCodec ff_ ## NAME ## _mf_encoder = { > \ > +.priv_class = &ff_ ## NAME ## _mf_encoder_class, > \ > +.name = #NAME "_mf", > \ > +.long_name = NULL_IF_CONFIG_SMALL(#ID " via MediaFoundation"), > \ > +.type = AVMEDIA_TYPE_ ## MEDIATYPE, > \ > +.id = AV_CODEC_ID_ ## ID, > \ > +.priv_data_size = sizeof(MFContext), > \ > +.init = mf_init, > \ > +.close = mf_close, > \ > +.send_frame = mf_send_frame, > \ > +.receive_packet = mf_receive_packet, > \ > +EXTRA > \ > +.capabilities = AV_CODEC_CAP_DELAY, > \ Should probably also be AV_CODEC_CAP_HYBRID. > +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | > \ > + FF_CODEC_CAP_INIT_CLEANUP, > \ > +}; > + > +#define AFMTS \ > +.sample_fmts= (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, > \ > + AV_SAMPLE_FMT_NONE > }, > + > +MF_ENCODER(AUDIO, aac, AAC, NULL, AFMTS); > +MF_ENCODER(AUDIO, ac3, AC3, NULL, AFMTS); > +MF_ENCODER(AUDIO, mp3, MP3, NULL, AFMTS); > + > +#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM > +static const AVOption venc_opts[] = { > +{"rate_control", "Select rate control mode", OFFSET(opt_enc_rc), > AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE, "rate_control"}, > +{ "default", "Default mode", 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, > 0, VE, "rate_control"}, > +{ "cbr", "CBR mode", 0, AV_OPT_TYPE_CONST, {.i64 = > ff_eAVEncCommonRateControlMode_CBR}, 0, 0, VE, "rate_control"}, > +{ "pc_vbr", "Peak constrained VBR mode", 0, AV_OPT_TYPE_CONST, > {.i64 = ff_eAVEncCommonRateControlMode_PeakConstrainedVBR}, 0, 0, VE, > "rate_control"}, > +{ "u_vbr","Unconstrained VBR mode", 0, AV_OPT_TYPE_CONST, {.i64 > = ff_eAVEncCommonRateControlMode_UnconstrainedVBR}, 0, 0, VE, "rate_control"}, > +{ "quality", "Quality mode", 0, AV_OPT_TYPE_CONST, {.i64 = > ff_eAVEncCommonRateControlMode_Quality}, 0, 0, VE, "rate_control" }, > +// The following rate_control modes require Windows 8. > +{ "ld_vbr", "Low delay VBR mode", 0, AV_OPT_TYPE_CONST, {.i64 = > ff_eAVEncCommonRateControlMode_LowDelayVBR}, 0, 0, VE, "rate_control"}, > +{ "g_vbr","Global VBR mode", 0, AV_OPT_TYPE_CONST, {.i64 = > ff_eAVEncCommonRateControlMode_GlobalVBR}, 0, 0, VE, "rate_control" }, > +{ "gld_vbr", "Global low delay VBR mode", 0, AV_OPT_TYPE_CONST, > {.i64 = ff_eAVEncCommonRateControlMode_GlobalLowDelayVBR}, 0, 0, VE, > "rate_control"}, > +{"quality", "Quality", OFFSET(opt_enc_quality), AV_OPT_TYPE_INT, > {.i64 = -1}, -1, 100, VE}, > +{"hw_encoding", "Force hardware encoding", OFFSET(opt_enc_hw), > AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, VE, "hw_encoding"}, Can't you attempt to init using hw by default and if that fails gracefully fallback to the sw implementation? This option could instead just attempt to force disable or enable hw (deafault -1/auto), and if hw can't be used when forced it would just abort instead of falling back to sw. > +{NULL} > +}; ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/4] avcodec/g729postfilter: Clip gain before scaling with AGC_FAC1
The fixed point integer reference specifies the multiplication used to have 16bit input and clips so we need to clip the input The floating point implementation does not seem to do that. Fixes: signed integer overflow: 6317568 * 410 cannot be represented in type 'int' Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_G729_fuzzer-5700189272932352 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/g729postfilter.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/g729postfilter.c b/libavcodec/g729postfilter.c index ab668594d2..617744ec8e 100644 --- a/libavcodec/g729postfilter.c +++ b/libavcodec/g729postfilter.c @@ -600,6 +600,7 @@ int16_t ff_g729_adaptive_gain_control(int gain_before, int gain_after, int16_t * gain = ((gain_before - gain_after) << 14) / gain_after + 0x4000; gain = bidir_sal(gain, exp_after - exp_before); } +gain = av_clip_int16(gain); gain = (gain * G729_AGC_FAC1 + 0x4000) >> 15; // gain * (1-0.9875) } else gain = 0; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/4] avcodec/iff: Fix several integer overflows
Fixes: negation of -2147483648 cannot be represented in type 'int32_t' (aka 'int'); cast to an unsigned type to negate this value to itself Fixes: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int32_t' (aka 'int') Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5764066459254784 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/iff.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/iff.c b/libavcodec/iff.c index 75be844a95..b39bb2c312 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -1378,11 +1378,10 @@ static void decode_delta_d(uint8_t *dst, opcode--; } } else { -opcode = -opcode; while (opcode && bytestream2_get_bytes_left(&gb) > 0) { bytestream2_put_be32(&pb, bytestream2_get_be32(&gb)); bytestream2_skip_p(&pb, pitch - 4); -opcode--; +opcode++; } } entries--; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/4] avcodec/alac: Fix integer overflow with 24/20bps samples
Fixes: signed integer overflow: 1020048 * 4096 cannot be represented in type 'int' Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALAC_fuzzer-5753877751660544 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/alac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/alac.c b/libavcodec/alac.c index c8c04223a0..82689da02a 100644 --- a/libavcodec/alac.c +++ b/libavcodec/alac.c @@ -397,13 +397,13 @@ static int decode_element(AVCodecContext *avctx, AVFrame *frame, int ch_index, case 20: { for (ch = 0; ch < channels; ch++) { for (i = 0; i < alac->nb_samples; i++) -alac->output_samples_buffer[ch][i] *= 1 << 12; +alac->output_samples_buffer[ch][i] *= 1U << 12; }} break; case 24: { for (ch = 0; ch < channels; ch++) { for (i = 0; i < alac->nb_samples; i++) -alac->output_samples_buffer[ch][i] *= 1 << 8; +alac->output_samples_buffer[ch][i] *= 1U << 8; }} break; } -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/4] avcodec/adpcm: Clip predictor for IMA_APM
Fixes: signed integer overflow: -2147483647 - 61436 cannot be represented in type 'int' Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_IMA_APM_fuzzer-5092176004644864 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/adpcm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index c6735a49c9..846ec5ef9c 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -163,9 +163,9 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) break; case AV_CODEC_ID_ADPCM_IMA_APM: if (avctx->extradata && avctx->extradata_size >= 16) { -c->status[0].predictor = AV_RL32(avctx->extradata + 0); +c->status[0].predictor = av_clip_intp2(AV_RL32(avctx->extradata + 0), 18); c->status[0].step_index = av_clip(AV_RL32(avctx->extradata + 4), 0, 88); -c->status[1].predictor = AV_RL32(avctx->extradata + 8); +c->status[1].predictor = av_clip_intp2(AV_RL32(avctx->extradata + 8), 18); c->status[1].step_index = av_clip(AV_RL32(avctx->extradata + 12), 0, 88); } break; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libavformat/internal.h - Adjust MAX_URL_SIZE to 8k
On Sun, 10 May 2020, Joey Smith wrote: Actually, that seems like a more rational fix all around - I just saw the BUFFER_SIZE in http.c being limited to MAX_URL_SIZE and jumped straight to expanding that, but in looking at your suggestion, I see now there's an HTTP_HEADERS_SIZE that appears to be defined but then never used. Do you want a new patch for that, or is it easier for you guys to just go ahead and do that on your end? Please send an updated patch. Thanks, Marton On Sun, May 10, 2020 at 2:17 AM Marton Balint wrote: On Sun, 10 May 2020, Joey Smith wrote: > Some real-world sites use an authorization header with a bearer token; when > combined with lengthy request parameters to identify the video segment, > it's rather trivial these days to have a request body of more than 4k bytes. > > Because MAX_URL_SIZE is hard-coded to 4k bytes in libavformat/internal.h, > this causes ffmpeg to terminate the connection early, even though the HTTP > request is otherwise perfectly valid. If that is the case then BUFFER_SIZE should be increased instead to (MAX_URL_SIZE + HTTP_HEADERS_SIZE) at http.c, no? Thanks, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libavformat/internal.h - Adjust MAX_URL_SIZE to 8k
Actually, that seems like a more rational fix all around - I just saw the BUFFER_SIZE in http.c being limited to MAX_URL_SIZE and jumped straight to expanding that, but in looking at your suggestion, I see now there's an HTTP_HEADERS_SIZE that appears to be defined but then never used. Do you want a new patch for that, or is it easier for you guys to just go ahead and do that on your end? On Sun, May 10, 2020 at 2:17 AM Marton Balint wrote: > > > On Sun, 10 May 2020, Joey Smith wrote: > > > Some real-world sites use an authorization header with a bearer token; > when > > combined with lengthy request parameters to identify the video segment, > > it's rather trivial these days to have a request body of more than 4k > bytes. > > > > Because MAX_URL_SIZE is hard-coded to 4k bytes in libavformat/internal.h, > > this causes ffmpeg to terminate the connection early, even though the > HTTP > > request is otherwise perfectly valid. > > If that is the case then BUFFER_SIZE should be increased instead to > (MAX_URL_SIZE + HTTP_HEADERS_SIZE) at http.c, no? > > Thanks, > Marton > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libavformat/internal.h - Adjust MAX_URL_SIZE to 8k
On Sun, 10 May 2020, Joey Smith wrote: Some real-world sites use an authorization header with a bearer token; when combined with lengthy request parameters to identify the video segment, it's rather trivial these days to have a request body of more than 4k bytes. Because MAX_URL_SIZE is hard-coded to 4k bytes in libavformat/internal.h, this causes ffmpeg to terminate the connection early, even though the HTTP request is otherwise perfectly valid. If that is the case then BUFFER_SIZE should be increased instead to (MAX_URL_SIZE + HTTP_HEADERS_SIZE) at http.c, no? Thanks, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2] avcodec/exr: output float pixels in float pixel format
On 5/10/20, Mark Reid wrote: > On Sat., May 9, 2020, 11:59 p.m. Paul B Mahol, wrote: > >> Do we support these float formats in swscale? >> If not, than patch is IMHO pointless. >> > > Yes, my patches for swscale float support was merged a few days ago. I also > plan to try and add floating point support to some vf filters, namely > lut3d. Great! ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] libavformat/internal.h - Adjust MAX_URL_SIZE to 8k
Some real-world sites use an authorization header with a bearer token; when combined with lengthy request parameters to identify the video segment, it's rather trivial these days to have a request body of more than 4k bytes. Because MAX_URL_SIZE is hard-coded to 4k bytes in libavformat/internal.h, this causes ffmpeg to terminate the connection early, even though the HTTP request is otherwise perfectly valid. I am proposing the attached patch, to switch this hard-coded to default from 4k to 8k, as that is the default request body limit in Apache, and most other httpds seem to support at least as much, if not more. 0001-libavformat-internal.h-Adjust-MAX_URL_SIZE-to-8k.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2] avcodec/exr: output float pixels in float pixel format
On Sat., May 9, 2020, 11:59 p.m. Paul B Mahol, wrote: > Do we support these float formats in swscale? > If not, than patch is IMHO pointless. > Yes, my patches for swscale float support was merged a few days ago. I also plan to try and add floating point support to some vf filters, namely lut3d. > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec: Add MediaFoundation encoder wrapper
On Sun, 10 May 2020, Martin Storsjö wrote: From: wm4 This contains encoder wrappers for H264, HEVC, AAC, AC3 and MP3. This is based on top of an original patch by wm4 . The original patch supported both encoding and decoding, but this patch only includes encoding. The patch contains further changes by Paweł Wegner (primarily for splitting out the encoding parts of the original patch) and further cleanup, build compatibility fixes and tweaks for use with Qualcomm encoders by Martin Storsjö. --- This allows access to the HW video encoder on Windows on ARM64 on Qualcomm platforms. However, to actually use that, one has to manually choose nv12 as input pixel format, otherwise the encoder format negotiation fails. I've tried to read up on the feedback this patch got the earlier times it was posted and address those issues. In particular, this is enabled automatically if suitable headers are available. The built binary still runs on Vista (even if the required MF functionality isn't available there). Building succeeds with MSVC, old and new mingw-w64 toolchains, and isn't detected nor enabled on mingw.org toolchains. The configure check looks for one of the API details used; mingw-w64 versions from before that feature was added won't try to build the code, while newer ones should have enough features to build it successfully. --- configure | 11 + libavcodec/Makefile|1 + libavcodec/allcodecs.c |5 + libavcodec/mf_utils.c | 677 +++ libavcodec/mf_utils.h | 138 + libavcodec/mfenc.c | 1181 libavcodec/version.h |2 +- 7 files changed, 2014 insertions(+), 1 deletion(-) create mode 100644 libavcodec/mf_utils.c create mode 100644 libavcodec/mf_utils.h create mode 100644 libavcodec/mfenc.c Missing docs update. Regards, Marton diff --git a/configure b/configure index e7162dbc56..a52d1ebed5 100755 --- a/configure +++ b/configure @@ -304,6 +304,7 @@ External library support: --enable-mbedtls enable mbedTLS, needed for https support if openssl, gnutls or libtls is not used [no] --enable-mediacodec enable Android MediaCodec support [no] + --enable-mf enable decoding via MediaFoundation [auto] --enable-libmysofa enable libmysofa, needed for sofalizer filter [no] --enable-openal enable OpenAL 1.1 capture support [no] --enable-opencl enable OpenCL processing [no] @@ -1704,6 +1705,7 @@ EXTERNAL_AUTODETECT_LIBRARY_LIST=" libxcb_shape libxcb_xfixes lzma +mf schannel sdl2 securetransport @@ -3013,6 +3015,8 @@ wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel" wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel" # hardware-accelerated codecs +mf_deps="mftransform_h MFCreateAlignedMemoryBuffer" +mf_extralibs="-lmfplat -lmfuuid -lole32 -lstrmiids" omx_deps="libdl pthreads" omx_rpi_select="omx" qsv_deps="libmfx" @@ -3037,6 +3041,8 @@ nvenc_deps="ffnvcodec" nvenc_deps_any="libdl LoadLibrary" nvenc_encoder_deps="nvenc" +aac_mf_encoder_deps="mf" +ac3_mf_encoder_deps="mf" h263_v4l2m2m_decoder_deps="v4l2_m2m h263_v4l2_m2m" h263_v4l2m2m_encoder_deps="v4l2_m2m h263_v4l2_m2m" h264_amf_encoder_deps="amf" @@ -3045,6 +3051,7 @@ h264_cuvid_decoder_deps="cuvid" h264_cuvid_decoder_select="h264_mp4toannexb_bsf" h264_mediacodec_decoder_deps="mediacodec" h264_mediacodec_decoder_select="h264_mp4toannexb_bsf h264_parser" +h264_mf_encoder_deps="mf" h264_mmal_decoder_deps="mmal" h264_nvenc_encoder_deps="nvenc" h264_omx_encoder_deps="omx" @@ -3061,6 +3068,7 @@ hevc_cuvid_decoder_deps="cuvid" hevc_cuvid_decoder_select="hevc_mp4toannexb_bsf" hevc_mediacodec_decoder_deps="mediacodec" hevc_mediacodec_decoder_select="hevc_mp4toannexb_bsf hevc_parser" +hevc_mf_encoder_deps="mf" hevc_nvenc_encoder_deps="nvenc" hevc_qsv_decoder_select="hevc_mp4toannexb_bsf qsvdec" hevc_qsv_encoder_select="hevcparse qsvenc" @@ -3077,6 +3085,7 @@ mjpeg_qsv_encoder_deps="libmfx" mjpeg_qsv_encoder_select="qsvenc" mjpeg_vaapi_encoder_deps="VAEncPictureParameterBufferJPEG" mjpeg_vaapi_encoder_select="cbs_jpeg jpegtables vaapi_encode" +mp3_mf_encoder_deps="mf" mpeg1_cuvid_decoder_deps="cuvid" mpeg1_v4l2m2m_decoder_deps="v4l2_m2m mpeg1_v4l2_m2m" mpeg2_crystalhd_decoder_select="crystalhd" @@ -6099,6 +6108,7 @@ check_headers io.h check_headers linux/perf_event.h check_headers libcrystalhd/libcrystalhd_if.h check_headers malloc.h +check_headers mftransform.h check_headers net/udplite.h check_headers poll.h check_headers sys/param.h @@ -6161,6 +6171,7 @@ check_type "windows.h dxva.h" "DXVA_PicParams_VP9" -DWINAPI_FAMILY=WINAPI_FAMILY check_type "windows.h d3d11.h" "ID3D11VideoDecoder" check_type "windows.h d3d11.h" "ID3D11VideoContext" check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0602 +check_func_headers mfapi.h MFCreateAlignedMemoryBuffer -lmfplat check_type "vdpau/vdpau.h" "VdpPictureInfoHEVC" check_type "vdpau/vdpau.h" "VdpPictureInfoVP9"
Re: [FFmpeg-devel] [PATCH 2/2] avcodec/dstdec: Check sample rate
On Fri, Feb 14, 2020 at 04:37:32PM +0100, Paul B Mahol wrote: > Actually I'm pretty sure log message is not needed as not power of 8 > is simply not possible. ok, will apply without the log message thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB He who knows, does not speak. He who speaks, does not know. -- Lao Tsu signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2] avcodec/exr: output float pixels in float pixel format
Do we support these float formats in swscale? If not, than patch is IMHO pointless. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".