Re: [FFmpeg-devel] [PATCH 2/2] fftools/ffmpeg: log skipped initial non-keyframes
On Fri, Jun 07, 2019 at 10:35:03PM +0200, Stephan Hilb wrote: > >> -!ost->copy_initial_nonkeyframes) > >> +!ost->copy_initial_nonkeyframes) { > >> +av_log(NULL, AV_LOG_DEBUG, "skipping initial > >> non-keyframe\n"); return; > > > > Incorrect indentation. > > It's actually the same indentation as in other places in the same file, > what would be the correct way then? > > > I suggest this message should be at INFO level, but appear only once. > > I'm fine with INFO level. Repeated messages get supressed anyways, does > that suffice? Repeated messages only get supressed if there is no interspaced message if 2 things generate a message per frame, neither will be supressed [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB "You are 36 times more likely to die in a bathtub than at the hands of a terrorist. Also, you are 2.5 times more likely to become a president and 2 times more likely to become an astronaut, than to die in a terrorist attack." -- Thoughty2 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 v8 2/2] fftools/ffmpeg: add exif orientation support per frame's metadata
On Sat, Jun 8, 2019 at 2:25 AM Nicolas George wrote: > Jun Li (12019-06-07): > > I think a complete validation should be creating a function like > "atodigit" > > , string to digit, instead of using atoi, > > The problem of validation is a common one, and as such it already has a > solution. > > APPLICATION USAGE > > The atoi() function is subsumed by strtol() but is retained because it > is > used extensively in existing code. If the number is not known to be in > range, strtol() should be used because atoi() is not required to > perform > any error checking. Thanks Nicolas and Michael, it is very helpful. After reread the exif orientation doc, I realized that the correct value should be in range [1,8], that is, 0 is considered as invalid. So the new version is still using "atoi", since it return 0 for either input "0" or "This is a test", and 0 considered as invalid in any case. https://patchwork.ffmpeg.org/patch/13471/ I am not against using strtol, which is a superset of atoi. Let me know if there is a code preference in ffmpeg since I see strtol is more widely used. Best Regards, Jun > > Regards, > > -- > Nicolas George > ___ > 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 v9 1/2] lavf/vf_transpose: add exif orientation support
Add exif orientation support and expose an option. --- libavfilter/hflip.h| 2 + libavfilter/transpose.h| 14 libavfilter/vf_hflip.c | 40 ++--- libavfilter/vf_transpose.c | 168 - 4 files changed, 192 insertions(+), 32 deletions(-) diff --git a/libavfilter/hflip.h b/libavfilter/hflip.h index 204090dbb4..4e89bae3fc 100644 --- a/libavfilter/hflip.h +++ b/libavfilter/hflip.h @@ -35,5 +35,7 @@ typedef struct FlipContext { int ff_hflip_init(FlipContext *s, int step[4], int nb_planes); void ff_hflip_init_x86(FlipContext *s, int step[4], int nb_planes); +int ff_hflip_config_props(FlipContext* s, AVFilterLink *inlink); +int ff_hflip_filter_slice(FlipContext *s, AVFrame *in, AVFrame *out, int job, int nb_jobs, int vlifp); #endif /* AVFILTER_HFLIP_H */ diff --git a/libavfilter/transpose.h b/libavfilter/transpose.h index aa262b9487..5da08bddc0 100644 --- a/libavfilter/transpose.h +++ b/libavfilter/transpose.h @@ -34,4 +34,18 @@ enum TransposeDir { TRANSPOSE_VFLIP, }; +enum OrientationType { +ORIENTATION_AUTO_TRANSPOSE = -2, +ORIENTATION_AUTO_FLIP = -1, +ORIENTATION_NONE = 0, +ORIENTATION_NORMAL, +ORIENTATION_HFLIP, +ORIENTATION_ROTATE180, +ORIENTATION_VFLIP, +ORIENTATION_HFLIP_ROTATE270CW, +ORIENTATION_ROTATE90CW, +ORIENTATION_HFLIP_ROTATE90CW, +ORIENTATION_ROTATE270CW +}; + #endif diff --git a/libavfilter/vf_hflip.c b/libavfilter/vf_hflip.c index b77afc77fc..d24ca5c2e7 100644 --- a/libavfilter/vf_hflip.c +++ b/libavfilter/vf_hflip.c @@ -125,9 +125,8 @@ static void hflip_qword_c(const uint8_t *ssrc, uint8_t *ddst, int w) dst[j] = src[-j]; } -static int config_props(AVFilterLink *inlink) +int ff_hflip_config_props(FlipContext* s, AVFilterLink *inlink) { -FlipContext *s = inlink->dst->priv; const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format); const int hsub = pix_desc->log2_chroma_w; const int vsub = pix_desc->log2_chroma_h; @@ -144,6 +143,12 @@ static int config_props(AVFilterLink *inlink) return ff_hflip_init(s, s->max_step, nb_planes); } +static int config_props(AVFilterLink *inlink) +{ +FlipContext *s = inlink->dst->priv; +return ff_hflip_config_props(s, inlink); +} + int ff_hflip_init(FlipContext *s, int step[4], int nb_planes) { int i; @@ -170,14 +175,10 @@ typedef struct ThreadData { AVFrame *in, *out; } ThreadData; -static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs) +int ff_hflip_filter_slice(FlipContext *s, AVFrame *in, AVFrame *out, int job, int nb_jobs, int vflip) { -FlipContext *s = ctx->priv; -ThreadData *td = arg; -AVFrame *in = td->in; -AVFrame *out = td->out; uint8_t *inrow, *outrow; -int i, plane, step; +int i, plane, step, outlinesize; for (plane = 0; plane < 4 && in->data[plane] && in->linesize[plane]; plane++) { const int width = s->planewidth[plane]; @@ -187,19 +188,36 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs) step = s->max_step[plane]; -outrow = out->data[plane] + start * out->linesize[plane]; -inrow = in ->data[plane] + start * in->linesize[plane] + (width - 1) * step; +if (vflip) { +outrow = out->data[plane] + (height - start - 1)* out->linesize[plane]; +outlinesize = -out->linesize[plane]; +} else { +outrow = out->data[plane] + start * out->linesize[plane]; +outlinesize = out->linesize[plane]; +} + +inrow = in->data[plane] + start * in->linesize[plane] + (width - 1) * step; + for (i = start; i < end; i++) { s->flip_line[plane](inrow, outrow, width); inrow += in ->linesize[plane]; -outrow += out->linesize[plane]; +outrow += outlinesize; } } return 0; } +static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs) +{ +FlipContext *s = ctx->priv; +ThreadData *td = arg; +AVFrame *in = td->in; +AVFrame *out = td->out; +return ff_hflip_filter_slice(s, in, out, job, nb_jobs, 0); +} + static int filter_frame(AVFilterLink *inlink, AVFrame *in) { AVFilterContext *ctx = inlink->dst; diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c index dd54947bd9..7a122ba8a9 100644 --- a/libavfilter/vf_transpose.c +++ b/libavfilter/vf_transpose.c @@ -39,6 +39,7 @@ #include "internal.h" #include "video.h" #include "transpose.h" +#include "hflip.h" typedef struct TransVtable { void (*transpose_8x8)(uint8_t *src, ptrdiff_t src_linesize, @@ -48,16 +49,22 @@ typedef struct TransVtable { int w, int h); } TransVtable; -typedef struct TransContext { -const AVClass *class; +typedef struct TransContextData { int hsub, vsub; int planes; int pixsteps[4]; +TransVtable vtables[4]; +}
[FFmpeg-devel] [PATCH v9 2/2] fftools/ffmpeg: add exif orientation support per frame's metadata
Fix #6945 Rotate or/and flip frame according to frame's metadata orientation --- fftools/ffmpeg.c| 5 +++-- fftools/ffmpeg.h| 8 fftools/ffmpeg_filter.c | 40 +++- 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 01f04103cf..bc0cece59d 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2141,8 +2141,9 @@ static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame) ifilter->channel_layout != frame->channel_layout; break; case AVMEDIA_TYPE_VIDEO: -need_reinit |= ifilter->width != frame->width || - ifilter->height != frame->height; +need_reinit |= ifilter->width != frame->width || + ifilter->height != frame->height || + ifilter->orientation != get_frame_orientation(frame); break; } diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 7b6f802082..7324813ce3 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -232,6 +232,12 @@ typedef struct OptionsContext { intnb_enc_time_bases; } OptionsContext; +enum OrientationType { +ORIENTATION_NONE, +ORIENTATION_AUTO_FLIP, +ORIENTATION_AUTO_TRANSPOSE +}; + typedef struct InputFilter { AVFilterContext*filter; struct InputStream *ist; @@ -245,6 +251,7 @@ typedef struct InputFilter { int format; int width, height; +enum OrientationType orientation; AVRational sample_aspect_ratio; int sample_rate; @@ -649,6 +656,7 @@ int init_complex_filtergraph(FilterGraph *fg); void sub2video_update(InputStream *ist, AVSubtitle *sub); int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame); +enum OrientationType get_frame_orientation(const AVFrame* frame); int ffmpeg_parse_options(int argc, char **argv); diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 72838de1e2..8fe17c8013 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -743,6 +743,32 @@ static int sub2video_prepare(InputStream *ist, InputFilter *ifilter) return 0; } +enum OrientationType get_frame_orientation(const AVFrame *frame) +{ +AVDictionaryEntry *entry = NULL; +int orientation = 0; + +// read exif orientation data +entry = av_dict_get(frame->metadata, "Orientation", NULL, 0); +if (entry && entry->value) +orientation = atoi(entry->value); + +//exif defines orientation in range [1, 8] +if (orientation > 8 || orientation < 1) { +if (entry && entry->value) { +av_log(NULL, AV_LOG_WARNING, +"Invalid frame orientation: %s, skip it.\n", entry->value); +} +return ORIENTATION_NONE; +} else if (orientation == 1) { +return ORIENTATION_NONE; +} else if (orientation <= 4) { +return ORIENTATION_AUTO_FLIP; +} else { +return ORIENTATION_AUTO_TRANSPOSE; +} +} + static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, AVFilterInOut *in) { @@ -809,13 +835,16 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, if (ist->autorotate) { double theta = get_rotation(ist->st); -if (fabs(theta - 90) < 1.0) { +if (fabs(theta) < 1.0) { // no rotation info in stream meta +if (ifilter->orientation == ORIENTATION_AUTO_FLIP) { +ret = insert_filter(&last_filter, &pad_idx, "transpose", "orientation=auto_flip"); +} else if (ifilter->orientation == ORIENTATION_AUTO_TRANSPOSE) { +ret = insert_filter(&last_filter, &pad_idx, "transpose", "orientation=auto_transpose"); +} +} else if (fabs(theta - 90) < 1.0) { ret = insert_filter(&last_filter, &pad_idx, "transpose", "clock"); } else if (fabs(theta - 180) < 1.0) { -ret = insert_filter(&last_filter, &pad_idx, "hflip", NULL); -if (ret < 0) -return ret; -ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL); +ret = insert_filter(&last_filter, &pad_idx, "transpose", "orientation=rotate180"); } else if (fabs(theta - 270) < 1.0) { ret = insert_filter(&last_filter, &pad_idx, "transpose", "cclock"); } else if (fabs(theta) > 1.0) { @@ -1191,6 +1220,7 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame) ifilter->width = frame->width; ifilter->height = frame->height; ifilter->sample_aspect_ratio = frame->sample_aspect_ratio; +ifilter->orientation = get_frame_orientation(frame); ifilter->sample_rate = frame->sample_rate; ifilter->channels= frame->channels; -- 2.17.1 ___ ffmpeg-devel mailing list
Re: [FFmpeg-devel] [PATCHv5 2/2] VP4 video decoder
On Sat, Jun 08, 2019 at 08:49:15AM +0200, Reimar Döffinger wrote: > > > On 08.06.2019, at 03:08, Peter Ross wrote: > > > --- > > comments against v4 patch addressed. thanks. > > > > +#if CONFIG_VP4_DECODER > > +static int vp4_get_mb_count(Vp3DecodeContext *s, GetBitContext *gb) > > +{ > > +int v = 1; > > +int bits; > > +while ((bits = show_bits(gb, 9)) == 0x1ff && v < > > s->yuv_macroblock_count) { > > I know some people prefer it, so leave it in that case. > But I think avoiding an assignment in the while makes the code > sufficiently more readable that it's worth the extra line of code. this adds three lines though... while(1) { bits = show_bits(gb, 9); if (bits == 0x1ff) break; if reduced to 'while ((bits = show_bits(gb, 9)) == 0x1ff) {' i think it is readable enough. there are some, but not that many, instances of this throughout ffmpeg % git grep 'while.*[^!<>=]=[^=].*==' > Also why not just check the v < limit inside the loop after the v+= and > immediatedly return? > This would allow choosing the error return value, > printing a warning etc if desired, and wouldn't unintentionally (?) run the > body(7) code. i agree with this restructure. those errors do not ordinarily happen with vp4. so it makes sense to print message in vp4_get_mb_count, and for vp4_unpack_macroblocks to return -1 for each error case. > This looks a bit weird. Is dc /count somehow clearer than dc/2 here? > Can dc actually be negative so that dc / 2 is different from dc >> 1? > If not the compiler probably will generate needless extra code here. my bad, yes it is always / 2. division is essential, because dc is signed. > I hope these are indeed my final comments now :) > It looks really good to me as far as I am qualified to comment. your comments are very much appreciated. it takes time to do these reviews, and the result is worth it imho. cheers, -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B) 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 v3] libavfilter/vf_find_rect: convert the object image to gray8 format instead of failed directly
On Sun, Jun 9, 2019 at 4:38 AM Michael Niedermayer wrote: > On Sat, Jun 08, 2019 at 06:53:58AM +0800, lance.lmw...@gmail.com wrote: > > From: Limin Wang > > > > Signed-off-by: Limin Wang > > --- > > libavfilter/vf_find_rect.c | 40 +++- > > 1 file changed, 27 insertions(+), 13 deletions(-) > > > > diff --git a/libavfilter/vf_find_rect.c b/libavfilter/vf_find_rect.c > > index d7e6579..6fe12fe 100644 > > --- a/libavfilter/vf_find_rect.c > > +++ b/libavfilter/vf_find_rect.c > > @@ -28,6 +28,7 @@ > > #include "internal.h" > > > > #include "lavfutils.h" > > +#include "lswsutils.h" > > > > #define MAX_MIPMAPS 5 > > > > @@ -235,8 +236,6 @@ static av_cold void uninit(AVFilterContext *ctx) > > av_frame_free(&foc->haystack_frame[i]); > > } > > > > -if (foc->obj_frame) > > -av_freep(&foc->obj_frame->data[0]); > > av_frame_free(&foc->obj_frame); > > } > > > > @@ -244,6 +243,9 @@ static av_cold int init(AVFilterContext *ctx) > > { > > FOCContext *foc = ctx->priv; > > int ret, i; > > +uint8_t *tmp_data[4]; > > +int tmp_linesize[4], width, height; > > +enum AVPixelFormat pix_fmt; > > > > if (!foc->obj_filename) { > > av_log(ctx, AV_LOG_ERROR, "object filename not set\n"); > > @@ -254,24 +256,36 @@ static av_cold int init(AVFilterContext *ctx) > > if (!foc->obj_frame) > > return AVERROR(ENOMEM); > > > > -if ((ret = ff_load_image(foc->obj_frame->data, > foc->obj_frame->linesize, > > - &foc->obj_frame->width, > &foc->obj_frame->height, > > - &foc->obj_frame->format, > foc->obj_filename, ctx)) < 0) > > -return ret; > > - > > -if (foc->obj_frame->format != AV_PIX_FMT_GRAY8) { > > -av_log(ctx, AV_LOG_ERROR, "object image is not a grayscale > image\n"); > > -return AVERROR(EINVAL); > > -} > > +if ((ret = ff_load_image(&tmp_data, tmp_linesize, > > + &width, &height, > > + &pix_fmt, foc->obj_filename, ctx)) < 0) > > libavfilter/vf_find_rect.c: In function ‘init’: > libavfilter/vf_find_rect.c:261:30: warning: passing argument 1 of > ‘ff_load_image’ from incompatible pointer type [enabled by default] > > > Should be fixed in the update v4 version patch. Have tested with expected function with below command: ./ffmpeg -i ./input.ts -vf find_rect=./logo.jpg,cover_rect=./cover.jpg:mode=cover output.ts > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > During times of universal deceit, telling the truth becomes a > revolutionary act. -- George Orwell > ___ > 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 v3] libavfilter/vf_find_rect: convert the object image to gray8 format instead of failed directly
On Sun, Jun 9, 2019 at 5:41 AM Michael Niedermayer wrote: > On Sat, Jun 08, 2019 at 06:53:58AM +0800, lance.lmw...@gmail.com wrote: > > From: Limin Wang > > > > Signed-off-by: Limin Wang > > --- > > libavfilter/vf_find_rect.c | 40 +++- > > 1 file changed, 27 insertions(+), 13 deletions(-) > > > > diff --git a/libavfilter/vf_find_rect.c b/libavfilter/vf_find_rect.c > > index d7e6579..6fe12fe 100644 > > --- a/libavfilter/vf_find_rect.c > > +++ b/libavfilter/vf_find_rect.c > > @@ -28,6 +28,7 @@ > > #include "internal.h" > > > > #include "lavfutils.h" > > +#include "lswsutils.h" > > > > #define MAX_MIPMAPS 5 > > > > @@ -235,8 +236,6 @@ static av_cold void uninit(AVFilterContext *ctx) > > av_frame_free(&foc->haystack_frame[i]); > > } > > > > -if (foc->obj_frame) > > -av_freep(&foc->obj_frame->data[0]); > > av_frame_free(&foc->obj_frame); > > } > > this alone will leak > > something like: > foc->obj_frame->buf[0] = > av_buffer_create(foc->obj_frame->data[0], > foc->obj_frame->linesize[0] * > foc->obj_frame->height, > av_buffer_default_free, > NULL, > 0); > > would be needed, but maybe theres a cleaner way to do this > like having a function that does all this in one step and produces a normal > AVFrame. I think more filters could benefit from this if theres nothing > like it yet ... > > I misunderstand by another code review and think the buffer is freed by av_free_frame. I'll revert it back in the update patch. > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > Its not that you shouldnt use gotos but rather that you should write > readable code and code with gotos often but not always is less readable > ___ > 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 v4] libavfilter/vf_find_rect: convert the object image to gray8 format instead of failed directly
From: Limin Wang Signed-off-by: Limin Wang --- libavfilter/vf_find_rect.c | 39 --- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/libavfilter/vf_find_rect.c b/libavfilter/vf_find_rect.c index d7e6579..ee6c3f4 100644 --- a/libavfilter/vf_find_rect.c +++ b/libavfilter/vf_find_rect.c @@ -28,6 +28,7 @@ #include "internal.h" #include "lavfutils.h" +#include "lswsutils.h" #define MAX_MIPMAPS 5 @@ -244,6 +245,9 @@ static av_cold int init(AVFilterContext *ctx) { FOCContext *foc = ctx->priv; int ret, i; +uint8_t *tmp_data[4] = { NULL }; +int tmp_linesize[4], width, height; +enum AVPixelFormat pix_fmt; if (!foc->obj_filename) { av_log(ctx, AV_LOG_ERROR, "object filename not set\n"); @@ -254,24 +258,37 @@ static av_cold int init(AVFilterContext *ctx) if (!foc->obj_frame) return AVERROR(ENOMEM); -if ((ret = ff_load_image(foc->obj_frame->data, foc->obj_frame->linesize, - &foc->obj_frame->width, &foc->obj_frame->height, - &foc->obj_frame->format, foc->obj_filename, ctx)) < 0) -return ret; - -if (foc->obj_frame->format != AV_PIX_FMT_GRAY8) { -av_log(ctx, AV_LOG_ERROR, "object image is not a grayscale image\n"); -return AVERROR(EINVAL); -} +if ((ret = ff_load_image(tmp_data, tmp_linesize, + &width, &height, + &pix_fmt, foc->obj_filename, ctx)) < 0) +goto error; + +/* convert object image to gray8 format with same width and height */ +foc->obj_frame->format = AV_PIX_FMT_GRAY8; +foc->obj_frame->width = width; +foc->obj_frame->height = height; +if ((ret = ff_scale_image(foc->obj_frame->data, foc->obj_frame->linesize, +foc->obj_frame->width, foc->obj_frame->height, foc->obj_frame->format, +tmp_data, tmp_linesize, width, height, pix_fmt, ctx)) < 0) +goto error; +av_freep(&tmp_data[0]); foc->needle_frame[0] = av_frame_clone(foc->obj_frame); for (i = 1; i < foc->mipmaps; i++) { foc->needle_frame[i] = downscale(foc->needle_frame[i-1]); -if (!foc->needle_frame[i]) -return AVERROR(ENOMEM); +if (!foc->needle_frame[i]) { +ret = AVERROR(ENOMEM); +goto error; +} } return 0; +error: +av_freep(&tmp_data[0]); +if (foc->obj_frame) +av_freep(&foc->obj_frame->data[0]); +av_frame_free(&foc->obj_frame); +return ret; } static const AVFilterPad foc_inputs[] = { -- 2.6.4 ___ 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] libavfilter/vf_find_rect: convert the object image to gray8 format instead of failed directly
On Sat, Jun 08, 2019 at 06:53:58AM +0800, lance.lmw...@gmail.com wrote: > From: Limin Wang > > Signed-off-by: Limin Wang > --- > libavfilter/vf_find_rect.c | 40 +++- > 1 file changed, 27 insertions(+), 13 deletions(-) > > diff --git a/libavfilter/vf_find_rect.c b/libavfilter/vf_find_rect.c > index d7e6579..6fe12fe 100644 > --- a/libavfilter/vf_find_rect.c > +++ b/libavfilter/vf_find_rect.c > @@ -28,6 +28,7 @@ > #include "internal.h" > > #include "lavfutils.h" > +#include "lswsutils.h" > > #define MAX_MIPMAPS 5 > > @@ -235,8 +236,6 @@ static av_cold void uninit(AVFilterContext *ctx) > av_frame_free(&foc->haystack_frame[i]); > } > > -if (foc->obj_frame) > -av_freep(&foc->obj_frame->data[0]); > av_frame_free(&foc->obj_frame); > } this alone will leak something like: foc->obj_frame->buf[0] = av_buffer_create(foc->obj_frame->data[0], foc->obj_frame->linesize[0] * foc->obj_frame->height, av_buffer_default_free, NULL, 0); would be needed, but maybe theres a cleaner way to do this like having a function that does all this in one step and produces a normal AVFrame. I think more filters could benefit from this if theres nothing like it yet ... [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Its not that you shouldnt use gotos but rather that you should write readable code and code with gotos often but not always is less readable 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/h264_sei: Add acces to truncated SEI data
On Sat, Jun 08, 2019 at 03:21:45PM +0200, Antonin Gouzer wrote: > --- > Some codecs editors had miss interpreted the H264 standart and > have coded a wrong size in the SEI data. > size = SEI size + 1. > The SEI data is detected as "truncated" This information does not end in the commit message, the result is a commit message thats a bit too terse, information wise. > Ex: > https://drive.google.com/file/d/1cNtLwnfPnyJnYqE7OYhU3SCoLRtuXIUM/view?usp=sharing do you want to submit a fate test ? > Command: > ffprobe -print_format xml -show_frames -read_intervals %+0.04 truncated.h264 > This (simple) patch add the possibility to read this false truncated SEI data > with the default stric_std_compliance or less. > The error remain logged in both cases. > > V2: Modifiy the patch for only the off by one values > > Thanks in advance ! > --- > libavcodec/h264_sei.c | 24 +++- > libavcodec/h264_sei.h | 2 +- > 2 files changed, 16 insertions(+), 10 deletions(-) > > diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c > index d4eb9c0dab..7871cf87ed 100644 > --- a/libavcodec/h264_sei.c > +++ b/libavcodec/h264_sei.c > @@ -402,7 +402,7 @@ static int > decode_alternative_transfer(H264SEIAlternativeTransfer *h, > } > > int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb, > - const H264ParamSets *ps, void *logctx) > + const H264ParamSets *ps, AVCodecContext *avctx) > { you could split this change in a seperate patch, this would make git log slightly more readable > int master_ret = 0; > > @@ -425,27 +425,33 @@ int ff_h264_sei_decode(H264SEIContext *h, GetBitContext > *gb, > } while (get_bits(gb, 8) == 255); > > if (size > get_bits_left(gb) / 8) { > -av_log(logctx, AV_LOG_ERROR, "SEI type %d size %d truncated at > %d\n", > + > +if (size == get_bits_left(gb) / 8 + 1 && > avctx->strict_std_compliance <= FF_COMPLIANCE_NORMAL){ > +av_log(avctx, AV_LOG_WARNING, "SEI type %d size %d truncated > at %d\n", > type, 8*size, get_bits_left(gb)); > + } else { > +av_log(avctx, AV_LOG_ERROR, "SEI type %d size %d truncated > at %d, data will not be read\n", > + type, 8*size, get_bits_left(gb)); > +return AVERROR_INVALIDDATA; > + } something is not right with the indention here thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB "You are 36 times more likely to die in a bathtub than at the hands of a terrorist. Also, you are 2.5 times more likely to become a president and 2 times more likely to become an astronaut, than to die in a terrorist attack." -- Thoughty2 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 v3] libavfilter/vf_find_rect: convert the object image to gray8 format instead of failed directly
On Sat, Jun 08, 2019 at 06:53:58AM +0800, lance.lmw...@gmail.com wrote: > From: Limin Wang > > Signed-off-by: Limin Wang > --- > libavfilter/vf_find_rect.c | 40 +++- > 1 file changed, 27 insertions(+), 13 deletions(-) > > diff --git a/libavfilter/vf_find_rect.c b/libavfilter/vf_find_rect.c > index d7e6579..6fe12fe 100644 > --- a/libavfilter/vf_find_rect.c > +++ b/libavfilter/vf_find_rect.c > @@ -28,6 +28,7 @@ > #include "internal.h" > > #include "lavfutils.h" > +#include "lswsutils.h" > > #define MAX_MIPMAPS 5 > > @@ -235,8 +236,6 @@ static av_cold void uninit(AVFilterContext *ctx) > av_frame_free(&foc->haystack_frame[i]); > } > > -if (foc->obj_frame) > -av_freep(&foc->obj_frame->data[0]); > av_frame_free(&foc->obj_frame); > } > > @@ -244,6 +243,9 @@ static av_cold int init(AVFilterContext *ctx) > { > FOCContext *foc = ctx->priv; > int ret, i; > +uint8_t *tmp_data[4]; > +int tmp_linesize[4], width, height; > +enum AVPixelFormat pix_fmt; > > if (!foc->obj_filename) { > av_log(ctx, AV_LOG_ERROR, "object filename not set\n"); > @@ -254,24 +256,36 @@ static av_cold int init(AVFilterContext *ctx) > if (!foc->obj_frame) > return AVERROR(ENOMEM); > > -if ((ret = ff_load_image(foc->obj_frame->data, foc->obj_frame->linesize, > - &foc->obj_frame->width, &foc->obj_frame->height, > - &foc->obj_frame->format, foc->obj_filename, > ctx)) < 0) > -return ret; > - > -if (foc->obj_frame->format != AV_PIX_FMT_GRAY8) { > -av_log(ctx, AV_LOG_ERROR, "object image is not a grayscale image\n"); > -return AVERROR(EINVAL); > -} > +if ((ret = ff_load_image(&tmp_data, tmp_linesize, > + &width, &height, > + &pix_fmt, foc->obj_filename, ctx)) < 0) libavfilter/vf_find_rect.c: In function ‘init’: libavfilter/vf_find_rect.c:261:30: warning: passing argument 1 of ‘ff_load_image’ from incompatible pointer type [enabled by default] [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB During times of universal deceit, telling the truth becomes a revolutionary act. -- George Orwell 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 2/2] fftools/ffmpeg: log skipped initial non-keyframes
On Fri, Jun 07, 2019 at 22:35:03 +0200, Stephan Hilb wrote: > > Incorrect indentation. > > It's actually the same indentation as in other places in the same file, > what would be the correct way then? Sorry, my mind went flaky, you're corrent. > > I suggest this message should be at INFO level, but appear only once. > > I'm fine with INFO level. Repeated messages get supressed anyways, does > that suffice? If it only appears once, then fine. I couldn't test (see below), so couldn't see whether this comes for every skipped frame. > > I believe ffprobe also suffers from such files and never displays > > anyhing with -show_frames. In fact, does ffprobe perhaps always begin > > from, or at least wait for, the first keyframe? > > Cannot really comment on that. For me it happens when stream copying > from v4l2, since the keyframe flag is not being set there, Probing > works just fine. Okay, I may have a look at ffprobe myself. Thanks for the v4l2 hint, I can use that to produce a sample. Moritz ___ 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] yuv420_bgr24_mmxext conversion taking significant time
On Sat, 8 Jun 2019 at 09:38, Lauri Kasanen wrote: > On Sat, 8 Jun 2019 06:51:51 -0700 > Adrian Tong wrote: > > > Hi Lauri. > > > > Thanks for the reply, any reason why this has not been implemented > before ? > > it seems to me that this would be a pretty important/hot function. > > Just the usual, nobody has had the interest. There are other places too > where the only x86 accel is mmx. > > - Lauri > I see. Thank you. I will see what I can do. -Adrian > ___ > 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] yuv420_bgr24_mmxext conversion taking significant time
On Sat, 8 Jun 2019 06:51:51 -0700 Adrian Tong wrote: > Hi Lauri. > > Thanks for the reply, any reason why this has not been implemented before ? > it seems to me that this would be a pretty important/hot function. Just the usual, nobody has had the interest. There are other places too where the only x86 accel is mmx. - Lauri ___ 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 3/4] avformat/wsddec: Fix undefined shift
On 08.06.2019, at 11:28, Michael Niedermayer wrote: > Fixes: left shift of 1 by 31 places cannot be represented in type 'int' > Fixes: > 15123/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5738039235575808 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavformat/wsddec.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavformat/wsddec.c b/libavformat/wsddec.c > index dfa8014b1c..43660d4cea 100644 > --- a/libavformat/wsddec.c > +++ b/libavformat/wsddec.c > @@ -137,7 +137,7 @@ static int wsd_read_header(AVFormatContext *s) > if (!(channel_assign & 1)) { > int i; > for (i = 1; i < 32; i++) > -if (channel_assign & (1 << i)) > +if (channel_assign & (1U << i)) I'd be in favour of switching these kind of checks to (a>>i)&1 as this is a much less risky idiom and IMO it would be best to spread that style... ___ 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/h264_sei: Add acces to truncated SEI data
looks good to me if maintainer has no objections... On 08.06.2019, at 15:21, Antonin Gouzer wrote: > --- > Some codecs editors had miss interpreted the H264 standart and > have coded a wrong size in the SEI data. > size = SEI size + 1. > The SEI data is detected as "truncated" > Ex: > https://drive.google.com/file/d/1cNtLwnfPnyJnYqE7OYhU3SCoLRtuXIUM/view?usp=sharing > Command: > ffprobe -print_format xml -show_frames -read_intervals %+0.04 truncated.h264 > This (simple) patch add the possibility to read this false truncated SEI data > with the default stric_std_compliance or less. > The error remain logged in both cases. > > V2: Modifiy the patch for only the off by one values > > Thanks in advance ! > --- > libavcodec/h264_sei.c | 24 +++- > libavcodec/h264_sei.h | 2 +- > 2 files changed, 16 insertions(+), 10 deletions(-) > > diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c > index d4eb9c0dab..7871cf87ed 100644 > --- a/libavcodec/h264_sei.c > +++ b/libavcodec/h264_sei.c > @@ -402,7 +402,7 @@ static int > decode_alternative_transfer(H264SEIAlternativeTransfer *h, > } > > int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb, > - const H264ParamSets *ps, void *logctx) > + const H264ParamSets *ps, AVCodecContext *avctx) > { > int master_ret = 0; > > @@ -425,27 +425,33 @@ int ff_h264_sei_decode(H264SEIContext *h, GetBitContext > *gb, > } while (get_bits(gb, 8) == 255); > > if (size > get_bits_left(gb) / 8) { > -av_log(logctx, AV_LOG_ERROR, "SEI type %d size %d truncated at > %d\n", > + > +if (size == get_bits_left(gb) / 8 + 1 && > avctx->strict_std_compliance <= FF_COMPLIANCE_NORMAL){ > +av_log(avctx, AV_LOG_WARNING, "SEI type %d size %d truncated > at %d\n", >type, 8*size, get_bits_left(gb)); > -return AVERROR_INVALIDDATA; > + } else { > +av_log(avctx, AV_LOG_ERROR, "SEI type %d size %d truncated > at %d, data will not be read\n", > + type, 8*size, get_bits_left(gb)); > +return AVERROR_INVALIDDATA; > + } > } > next = get_bits_count(gb) + 8 * size; > > switch (type) { > case H264_SEI_TYPE_PIC_TIMING: // Picture timing SEI > -ret = decode_picture_timing(&h->picture_timing, gb, ps, logctx); > +ret = decode_picture_timing(&h->picture_timing, gb, ps, avctx); > break; > case H264_SEI_TYPE_USER_DATA_REGISTERED: > -ret = decode_registered_user_data(h, gb, logctx, size); > +ret = decode_registered_user_data(h, gb, avctx, size); > break; > case H264_SEI_TYPE_USER_DATA_UNREGISTERED: > -ret = decode_unregistered_user_data(&h->unregistered, gb, > logctx, size); > +ret = decode_unregistered_user_data(&h->unregistered, gb, avctx, > size); > break; > case H264_SEI_TYPE_RECOVERY_POINT: > -ret = decode_recovery_point(&h->recovery_point, gb, logctx); > +ret = decode_recovery_point(&h->recovery_point, gb, avctx); > break; > case H264_SEI_TYPE_BUFFERING_PERIOD: > -ret = decode_buffering_period(&h->buffering_period, gb, ps, > logctx); > +ret = decode_buffering_period(&h->buffering_period, gb, ps, > avctx); > break; > case H264_SEI_TYPE_FRAME_PACKING: > ret = decode_frame_packing_arrangement(&h->frame_packing, gb); > @@ -460,7 +466,7 @@ int ff_h264_sei_decode(H264SEIContext *h, GetBitContext > *gb, > ret = decode_alternative_transfer(&h->alternative_transfer, gb); > break; > default: > -av_log(logctx, AV_LOG_DEBUG, "unknown SEI type %d\n", type); > +av_log(avctx, AV_LOG_DEBUG, "unknown SEI type %d\n", type); > } > if (ret < 0 && ret != AVERROR_PS_NOT_FOUND) > return ret; > diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h > index a75c3aa175..32f3d67096 100644 > --- a/libavcodec/h264_sei.h > +++ b/libavcodec/h264_sei.h > @@ -190,7 +190,7 @@ typedef struct H264SEIContext { > struct H264ParamSets; > > int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb, > - const struct H264ParamSets *ps, void *logctx); > + const struct H264ParamSets *ps, AVCodecContext > *avctx); > > /** > * Reset SEI values at the beginning of the frame. > -- > 2.11.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". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To
[FFmpeg-devel] [PATCH V1 2/2] doc/fftools-common-opts: document ffmpeg -h bsf=bitstream_filter_name
From: Jun Zhao document ffmpeg -h bsf=bitstream_filter_name Signed-off-by: Jun Zhao --- doc/fftools-common-opts.texi |4 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi index 4c821ba..1234de8 100644 --- a/doc/fftools-common-opts.texi +++ b/doc/fftools-common-opts.texi @@ -109,6 +109,10 @@ Print detailed information about the muxer named @var{muxer_name}. Use the @item filter=@var{filter_name} Print detailed information about the filter name @var{filter_name}. Use the @option{-filters} option to get a list of all filters. + +@item bsf=@var{bitstream_filter_name} +Print detailed information about the bitstream filter name @var{bitstream_filter_name}. +Use the @option{-bsfs} option to get a list of all bitstream filters. @end table @item -version -- 1.7.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 V1 1/2] doc/formats: document f_strict/strict for AVFormatContext
From: Jun Zhao document f_strict/strict option for AVFormatContext Signed-off-by: Jun Zhao --- doc/formats.texi | 22 ++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/doc/formats.texi b/doc/formats.texi index a992506..729c77b 100644 --- a/doc/formats.texi +++ b/doc/formats.texi @@ -224,6 +224,28 @@ would require too many resources due to a large number of streams. @item skip_estimate_duration_from_pts @var{bool} (@emph{input}) Skip estimation of input duration when calculated using PTS. At present, applicable for MPEG-PS and MPEG-TS. + +@item strict, f_strict @var{integer} (@emph{input/output}) +Specify how strictly to follow the standards. @code{f_strict} is deprecated and +should be used only via the @command{ffmpeg} tool. + +Possible values: +@table @samp +@item very +strictly conform to an older more strict version of the spec or reference software +@item strict +strictly conform to all the things in the spec no matter what consequences +@item normal + +@item unofficial +allow unofficial extensions +@item experimental +allow non standardized experimental things, experimental +(unfinished/work in progress/not well tested) decoders and encoders. +Note: experimental decoders can pose a security risk, do not use this for +decoding untrusted input. +@end table + @end table @c man end FORMAT OPTIONS -- 1.7.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] yuv420_bgr24_mmxext conversion taking significant time
On Fri, 7 Jun 2019 at 23:20, Lauri Kasanen wrote: > On Fri, 7 Jun 2019 08:38:35 -0700 > Adrian Tong wrote: > > > Hi > > > > I have a workload which spends a significant amount of time (~10%) in > > the yuv420_bgr24_mmxext function in FFMEPG. > > > > I looked at the assembly and profile and see MMX (64 bit) registers are > > used. I wonder whether we can have a SSE2 version which has a register > bit > > width of 128. > > > > I am very interested in implementing such support if it is possible. > > I'm not well versed in x86 vectors, so I can't say if SSE2 is enough or > some other SSE version would be needed, but certainly YUV to RGB > conversion can be done faster than with MMX. Please do send a patch. > > - Lauri > Hi Lauri. Thanks for the reply, any reason why this has not been implemented before ? it seems to me that this would be a pretty important/hot function. -Adrian > ___ > 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 v2] avcodec/h264_sei: Add acces to truncated SEI data
--- Some codecs editors had miss interpreted the H264 standart and have coded a wrong size in the SEI data. size = SEI size + 1. The SEI data is detected as "truncated" Ex: https://drive.google.com/file/d/1cNtLwnfPnyJnYqE7OYhU3SCoLRtuXIUM/view?usp=sharing Command: ffprobe -print_format xml -show_frames -read_intervals %+0.04 truncated.h264 This (simple) patch add the possibility to read this false truncated SEI data with the default stric_std_compliance or less. The error remain logged in both cases. V2: Modifiy the patch for only the off by one values Thanks in advance ! --- libavcodec/h264_sei.c | 24 +++- libavcodec/h264_sei.h | 2 +- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c index d4eb9c0dab..7871cf87ed 100644 --- a/libavcodec/h264_sei.c +++ b/libavcodec/h264_sei.c @@ -402,7 +402,7 @@ static int decode_alternative_transfer(H264SEIAlternativeTransfer *h, } int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb, - const H264ParamSets *ps, void *logctx) + const H264ParamSets *ps, AVCodecContext *avctx) { int master_ret = 0; @@ -425,27 +425,33 @@ int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb, } while (get_bits(gb, 8) == 255); if (size > get_bits_left(gb) / 8) { -av_log(logctx, AV_LOG_ERROR, "SEI type %d size %d truncated at %d\n", + +if (size == get_bits_left(gb) / 8 + 1 && avctx->strict_std_compliance <= FF_COMPLIANCE_NORMAL){ +av_log(avctx, AV_LOG_WARNING, "SEI type %d size %d truncated at %d\n", type, 8*size, get_bits_left(gb)); -return AVERROR_INVALIDDATA; + } else { +av_log(avctx, AV_LOG_ERROR, "SEI type %d size %d truncated at %d, data will not be read\n", + type, 8*size, get_bits_left(gb)); +return AVERROR_INVALIDDATA; + } } next = get_bits_count(gb) + 8 * size; switch (type) { case H264_SEI_TYPE_PIC_TIMING: // Picture timing SEI -ret = decode_picture_timing(&h->picture_timing, gb, ps, logctx); +ret = decode_picture_timing(&h->picture_timing, gb, ps, avctx); break; case H264_SEI_TYPE_USER_DATA_REGISTERED: -ret = decode_registered_user_data(h, gb, logctx, size); +ret = decode_registered_user_data(h, gb, avctx, size); break; case H264_SEI_TYPE_USER_DATA_UNREGISTERED: -ret = decode_unregistered_user_data(&h->unregistered, gb, logctx, size); +ret = decode_unregistered_user_data(&h->unregistered, gb, avctx, size); break; case H264_SEI_TYPE_RECOVERY_POINT: -ret = decode_recovery_point(&h->recovery_point, gb, logctx); +ret = decode_recovery_point(&h->recovery_point, gb, avctx); break; case H264_SEI_TYPE_BUFFERING_PERIOD: -ret = decode_buffering_period(&h->buffering_period, gb, ps, logctx); +ret = decode_buffering_period(&h->buffering_period, gb, ps, avctx); break; case H264_SEI_TYPE_FRAME_PACKING: ret = decode_frame_packing_arrangement(&h->frame_packing, gb); @@ -460,7 +466,7 @@ int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb, ret = decode_alternative_transfer(&h->alternative_transfer, gb); break; default: -av_log(logctx, AV_LOG_DEBUG, "unknown SEI type %d\n", type); +av_log(avctx, AV_LOG_DEBUG, "unknown SEI type %d\n", type); } if (ret < 0 && ret != AVERROR_PS_NOT_FOUND) return ret; diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h index a75c3aa175..32f3d67096 100644 --- a/libavcodec/h264_sei.h +++ b/libavcodec/h264_sei.h @@ -190,7 +190,7 @@ typedef struct H264SEIContext { struct H264ParamSets; int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb, - const struct H264ParamSets *ps, void *logctx); + const struct H264ParamSets *ps, AVCodecContext *avctx); /** * Reset SEI values at the beginning of the frame. -- 2.11.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".
[FFmpeg-devel] [PATCH 4/4] avformat/icodec: Free ico->images on error paths
Fixes: 15116/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5715173567889408 Fixes: memleak Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/icodec.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavformat/icodec.c b/libavformat/icodec.c index f9b0015f34..98684e5e74 100644 --- a/libavformat/icodec.c +++ b/libavformat/icodec.c @@ -96,8 +96,10 @@ static int read_header(AVFormatContext *s) break; st = avformat_new_stream(s, NULL); -if (!st) +if (!st) { +av_freep(&ico->images); return AVERROR(ENOMEM); +} st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; st->codecpar->width = avio_r8(pb); @@ -111,6 +113,7 @@ static int read_header(AVFormatContext *s) ico->images[i].size = avio_rl32(pb); if (ico->images[i].size <= 0) { av_log(s, AV_LOG_ERROR, "Invalid image size %d\n", ico->images[i].size); +av_freep(&ico->images); return AVERROR_INVALIDDATA; } ico->images[i].offset = avio_rl32(pb); @@ -126,8 +129,10 @@ static int read_header(AVFormatContext *s) st->codecpar->height = 0; break; case 40: -if (ico->images[i].size < 40) +if (ico->images[i].size < 40) { +av_freep(&ico->images); return AVERROR_INVALIDDATA; +} st->codecpar->codec_id = AV_CODEC_ID_BMP; tmp = avio_rl32(pb); if (tmp) @@ -138,6 +143,7 @@ static int read_header(AVFormatContext *s) break; default: avpriv_request_sample(s, "codec %d", codec); +av_freep(&ico->images); return AVERROR_INVALIDDATA; } } -- 2.21.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".
[FFmpeg-devel] [PATCH 3/4] avformat/wsddec: Fix undefined shift
Fixes: left shift of 1 by 31 places cannot be represented in type 'int' Fixes: 15123/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5738039235575808 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/wsddec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/wsddec.c b/libavformat/wsddec.c index dfa8014b1c..43660d4cea 100644 --- a/libavformat/wsddec.c +++ b/libavformat/wsddec.c @@ -137,7 +137,7 @@ static int wsd_read_header(AVFormatContext *s) if (!(channel_assign & 1)) { int i; for (i = 1; i < 32; i++) -if (channel_assign & (1 << i)) +if (channel_assign & (1U << i)) st->codecpar->channel_layout |= wsd_to_av_channel_layoyt(s, i); } -- 2.21.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".
[FFmpeg-devel] [PATCH 1/4] avformat/tiertexseq: Move seq_read_close() up so it can be used for cleanup
Signed-off-by: Michael Niedermayer --- libavformat/tiertexseq.c | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/libavformat/tiertexseq.c b/libavformat/tiertexseq.c index e861869ad3..a35e08ef50 100644 --- a/libavformat/tiertexseq.c +++ b/libavformat/tiertexseq.c @@ -182,6 +182,17 @@ static int seq_parse_frame_data(SeqDemuxContext *seq, AVIOContext *pb) return 0; } +static int seq_read_close(AVFormatContext *s) +{ +int i; +SeqDemuxContext *seq = s->priv_data; + +for (i = 0; i < SEQ_NUM_FRAME_BUFFERS; i++) +av_freep(&seq->frame_buffers[i].data); + +return 0; +} + static int seq_read_header(AVFormatContext *s) { int i, rc; @@ -295,17 +306,6 @@ static int seq_read_packet(AVFormatContext *s, AVPacket *pkt) return 0; } -static int seq_read_close(AVFormatContext *s) -{ -int i; -SeqDemuxContext *seq = s->priv_data; - -for (i = 0; i < SEQ_NUM_FRAME_BUFFERS; i++) -av_freep(&seq->frame_buffers[i].data); - -return 0; -} - AVInputFormat ff_tiertexseq_demuxer = { .name = "tiertexseq", .long_name = NULL_IF_CONFIG_SMALL("Tiertex Limited SEQ"), -- 2.21.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".
[FFmpeg-devel] [PATCH 2/4] avformat/tiertexseq: Cleanup on error
Fixes: memleak Fixes: 15122/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-568596463616 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/tiertexseq.c | 16 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/libavformat/tiertexseq.c b/libavformat/tiertexseq.c index a35e08ef50..a89a0a9d61 100644 --- a/libavformat/tiertexseq.c +++ b/libavformat/tiertexseq.c @@ -202,16 +202,20 @@ static int seq_read_header(AVFormatContext *s) /* init internal buffers */ rc = seq_init_frame_buffers(seq, pb); -if (rc) +if (rc) { +seq_read_close(s); return rc; +} seq->current_frame_offs = 0; /* preload (no audio data, just buffer operations related data) */ for (i = 1; i <= 100; i++) { rc = seq_parse_frame_data(seq, pb); -if (rc) +if (rc) { +seq_read_close(s); return rc; +} } seq->current_frame_pts = 0; @@ -220,8 +224,10 @@ static int seq_read_header(AVFormatContext *s) /* initialize the video decoder stream */ st = avformat_new_stream(s, NULL); -if (!st) +if (!st) { +seq_read_close(s); return AVERROR(ENOMEM); +} avpriv_set_pts_info(st, 32, 1, SEQ_FRAME_RATE); seq->video_stream_index = st->index; @@ -233,8 +239,10 @@ static int seq_read_header(AVFormatContext *s) /* initialize the audio decoder stream */ st = avformat_new_stream(s, NULL); -if (!st) +if (!st) { +seq_read_close(s); return AVERROR(ENOMEM); +} st->start_time = 0; avpriv_set_pts_info(st, 32, 1, SEQ_SAMPLE_RATE); -- 2.21.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 v8 2/2] fftools/ffmpeg: add exif orientation support per frame's metadata
Jun Li (12019-06-07): > I think a complete validation should be creating a function like "atodigit" > , string to digit, instead of using atoi, The problem of validation is a common one, and as such it already has a solution. APPLICATION USAGE The atoi() function is subsumed by strtol() but is retained because it is used extensively in existing code. If the number is not known to be in range, strtol() should be used because atoi() is not required to perform any error checking. Regards, -- Nicolas George 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".