[FFmpeg-cvslog] avfilter/vf_decimate: add support for more formats
ffmpeg | branch: master | Paul B Mahol | Thu Jan 21 11:07:04 2021 +0100| [b43c35c633a4c0c35d914cfc097fe9507a8409e2] | committer: Paul B Mahol avfilter/vf_decimate: add support for more formats > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b43c35c633a4c0c35d914cfc097fe9507a8409e2 --- libavfilter/vf_decimate.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_decimate.c b/libavfilter/vf_decimate.c index 73d9ba8928..a76711f265 100644 --- a/libavfilter/vf_decimate.c +++ b/libavfilter/vf_decimate.c @@ -357,8 +357,12 @@ static int query_formats(AVFilterContext *ctx) #define PF_ALPHA(suf) AV_PIX_FMT_YUVA420##suf, AV_PIX_FMT_YUVA422##suf, AV_PIX_FMT_YUVA444##suf #define PF(suf) PF_NOALPHA(suf), PF_ALPHA(suf) PF(P), PF(P9), PF(P10), PF_NOALPHA(P12), PF_NOALPHA(P14), PF(P16), +AV_PIX_FMT_YUV440P10, AV_PIX_FMT_YUV440P12, AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P, -AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY16, +AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ420P, +AV_PIX_FMT_YUVJ411P, +AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9, AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14, +AV_PIX_FMT_GRAY16, AV_PIX_FMT_NONE }; AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avfilter/vf_deblock: fix >8 depth format case check
ffmpeg | branch: master | Paul B Mahol | Thu Jan 21 12:55:16 2021 +0100| [4225819c70161630f26b7129b63e6f3b3f90f59a] | committer: Paul B Mahol avfilter/vf_deblock: fix >8 depth format case check > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4225819c70161630f26b7129b63e6f3b3f90f59a --- libavfilter/vf_deblock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_deblock.c b/libavfilter/vf_deblock.c index 77c681ecb8..b2be1d6f07 100644 --- a/libavfilter/vf_deblock.c +++ b/libavfilter/vf_deblock.c @@ -285,14 +285,14 @@ static int config_output(AVFilterLink *outlink) if (s->depth <= 8 && s->filter == WEAK) { s->deblockh = deblockh8_weak; s->deblockv = deblockv8_weak; -} else if (s->depth >= 8 && s->filter == WEAK) { +} else if (s->depth > 8 && s->filter == WEAK) { s->deblockh = deblockh16_weak; s->deblockv = deblockv16_weak; } if (s->depth <= 8 && s->filter == STRONG) { s->deblockh = deblockh8_strong; s->deblockv = deblockv8_strong; -} else if (s->depth >= 8 && s->filter == STRONG) { +} else if (s->depth > 8 && s->filter == STRONG) { s->deblockh = deblockh16_strong; s->deblockv = deblockv16_strong; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avfilter/vf_dblur: remove unused line
ffmpeg | branch: master | Paul B Mahol | Thu Jan 21 12:58:58 2021 +0100| [b51eae1abeab6875e619a598b6e8d4e14c1b6cfd] | committer: Paul B Mahol avfilter/vf_dblur: remove unused line > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b51eae1abeab6875e619a598b6e8d4e14c1b6cfd --- libavfilter/vf_dblur.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavfilter/vf_dblur.c b/libavfilter/vf_dblur.c index cc127da73f..c4c37dec52 100644 --- a/libavfilter/vf_dblur.c +++ b/libavfilter/vf_dblur.c @@ -40,7 +40,6 @@ typedef struct DBlurContext { int planeheight[4]; float *buffer; int nb_planes; -void (*horiz_slice)(float *buffer, int width, int height, int steps, float nu, float bscale); } DBlurContext; #define OFFSET(x) offsetof(DBlurContext, x) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avfilter/vf_fieldmatch: use av_malloc_array()
ffmpeg | branch: master | Paul B Mahol | Thu Jan 21 12:28:13 2021 +0100| [27f1ee7f53adf665818d89ce468e7e10bce4c831] | committer: Paul B Mahol avfilter/vf_fieldmatch: use av_malloc_array() > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=27f1ee7f53adf665818d89ce468e7e10bce4c831 --- libavfilter/vf_fieldmatch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_fieldmatch.c b/libavfilter/vf_fieldmatch.c index 57ecf73864..528f943172 100644 --- a/libavfilter/vf_fieldmatch.c +++ b/libavfilter/vf_fieldmatch.c @@ -951,8 +951,8 @@ static int config_input(AVFilterLink *inlink) fm->tpitchuv = FFALIGN(w >> 1, 16); fm->tbuffer = av_calloc((h/2 + 4) * fm->tpitchy, sizeof(*fm->tbuffer)); -fm->c_array = av_mallocw + fm->blockx/2)/fm->blockx)+1) * -(((h + fm->blocky/2)/fm->blocky)+1) * +fm->c_array = av_malloc_arrayw + fm->blockx/2)/fm->blockx)+1) * +(((h + fm->blocky/2)/fm->blocky)+1), 4 * sizeof(*fm->c_array)); if (!fm->tbuffer || !fm->c_array) return AVERROR(ENOMEM); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avfilter/vf_super2xsai: constify src pointer
ffmpeg | branch: master | Paul B Mahol | Thu Jan 21 13:05:57 2021 +0100| [c2ee42e0323943499f5c2ae0dcdc6cccfc09d749] | committer: Paul B Mahol avfilter/vf_super2xsai: constify src pointer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c2ee42e0323943499f5c2ae0dcdc6cccfc09d749 --- libavfilter/vf_super2xsai.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_super2xsai.c b/libavfilter/vf_super2xsai.c index 87eec04da8..4233f02388 100644 --- a/libavfilter/vf_super2xsai.c +++ b/libavfilter/vf_super2xsai.c @@ -54,14 +54,14 @@ typedef struct Super2xSaIContext { + A & q_lo_pixel_mask) + (B & q_lo_pixel_mask) + (C & q_lo_pixel_mask) + (D & q_lo_pixel_mask)) >> 2) & q_lo_pixel_mask) static void super2xsai(AVFilterContext *ctx, - uint8_t *src, int src_linesize, + const uint8_t *src, int src_linesize, uint8_t *dst, int dst_linesize, int width, int height) { Super2xSaIContext *s = ctx->priv; unsigned int x, y; uint32_t color[4][4]; -unsigned char *src_line[4]; +const uint8_t *src_line[4]; const int bpp = s->bpp; const uint32_t hi_pixel_mask = s->hi_pixel_mask; const uint32_t lo_pixel_mask = s->lo_pixel_mask; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avfilter/vf_super2xsai: add slice threading support
ffmpeg | branch: master | Paul B Mahol | Thu Jan 21 13:26:17 2021 +0100| [f07a8b13f38bbd52d55c52d1d6ea1265b13c7a84] | committer: Paul B Mahol avfilter/vf_super2xsai: add slice threading support > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f07a8b13f38bbd52d55c52d1d6ea1265b13c7a84 --- libavfilter/vf_super2xsai.c | 60 - 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/libavfilter/vf_super2xsai.c b/libavfilter/vf_super2xsai.c index 4233f02388..d6c5f44c17 100644 --- a/libavfilter/vf_super2xsai.c +++ b/libavfilter/vf_super2xsai.c @@ -46,6 +46,10 @@ typedef struct Super2xSaIContext { int is_be; } Super2xSaIContext; +typedef struct ThreadData { +AVFrame *in, *out; +} ThreadData; + #define GET_RESULT(A, B, C, D) ((A != C || A != D) - (B != C || B != D)) #define INTERPOLATE(A, B) (((A & hi_pixel_mask) >> 1) + ((B & hi_pixel_mask) >> 1) + (A & B & lo_pixel_mask)) @@ -53,12 +57,18 @@ typedef struct Super2xSaIContext { #define Q_INTERPOLATE(A, B, C, D) ((A & q_hi_pixel_mask) >> 2) + ((B & q_hi_pixel_mask) >> 2) + ((C & q_hi_pixel_mask) >> 2) + ((D & q_hi_pixel_mask) >> 2) \ + A & q_lo_pixel_mask) + (B & q_lo_pixel_mask) + (C & q_lo_pixel_mask) + (D & q_lo_pixel_mask)) >> 2) & q_lo_pixel_mask) -static void super2xsai(AVFilterContext *ctx, - const uint8_t *src, int src_linesize, - uint8_t *dst, int dst_linesize, - int width, int height) +static int super2xsai(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) { Super2xSaIContext *s = ctx->priv; +ThreadData *td = arg; +AVFrame *in = td->in; +AVFrame *out = td->out; +const uint8_t *src = in->data[0]; +uint8_t *dst = out->data[0]; +const int src_linesize = in->linesize[0]; +const int dst_linesize = out->linesize[0]; +const int width = in->width; +const int height = in->height; unsigned int x, y; uint32_t color[4][4]; const uint8_t *src_line[4]; @@ -67,18 +77,20 @@ static void super2xsai(AVFilterContext *ctx, const uint32_t lo_pixel_mask = s->lo_pixel_mask; const uint32_t q_hi_pixel_mask = s->q_hi_pixel_mask; const uint32_t q_lo_pixel_mask = s->q_lo_pixel_mask; +const int slice_start = (height * jobnr) / nb_jobs; +const int slice_end = (height * (jobnr+1)) / nb_jobs; /* Point to the first 4 lines, first line is duplicated */ -src_line[0] = src; -src_line[1] = src; -src_line[2] = src + src_linesize*FFMIN(1, height-1); -src_line[3] = src + src_linesize*FFMIN(2, height-1); +src_line[0] = src + src_linesize*FFMAX(slice_start - 1, 0); +src_line[1] = src + src_linesize*slice_start; +src_line[2] = src + src_linesize*FFMIN(slice_start + 1, height-1); +src_line[3] = src + src_linesize*FFMIN(slice_start + 2, height-1); #define READ_COLOR4(dst, src_line, off) dst = *((const uint32_t *)src_line + off) #define READ_COLOR3(dst, src_line, off) dst = AV_RL24 (src_line + 3*off) #define READ_COLOR2(dst, src_line, off) dst = s->is_be ? AV_RB16(src_line + 2 * off) : AV_RL16(src_line + 2 * off) -for (y = 0; y < height; y++) { +for (y = slice_start; y < slice_end; y++) { uint8_t *dst_line[2]; dst_line[0] = dst + dst_linesize*2*y; @@ -229,6 +241,8 @@ static void super2xsai(AVFilterContext *ctx, if (y < height - 3) src_line[3] += src_linesize; } // y loop + +return 0; } static int query_formats(AVFilterContext *ctx) @@ -305,24 +319,25 @@ static int config_output(AVFilterLink *outlink) return 0; } -static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) +static int filter_frame(AVFilterLink *inlink, AVFrame *in) { -AVFilterLink *outlink = inlink->dst->outputs[0]; -AVFrame *outpicref = ff_get_video_buffer(outlink, outlink->w, outlink->h); -if (!outpicref) { -av_frame_free(&inpicref); +AVFilterContext *ctx = inlink->dst; +AVFilterLink *outlink = ctx->outputs[0]; +ThreadData td; +AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h); +if (!out) { +av_frame_free(&in); return AVERROR(ENOMEM); } -av_frame_copy_props(outpicref, inpicref); -outpicref->width = outlink->w; -outpicref->height = outlink->h; +av_frame_copy_props(out, in); +out->width = outlink->w; +out->height = outlink->h; -super2xsai(inlink->dst, inpicref->data[0], inpicref->linesize[0], - outpicref->data[0], outpicref->linesize[0], - inlink->w, inlink->h); +td.in = in, td.out = out; +ctx->internal->execute(ctx, super2xsai, &td, NULL, FFMIN(in->height, ff_filter_get_nb_threads(ctx))); -av_frame_free(&inpicref); -return ff_filter_frame(outlink, outpicref); +av_frame_free(&in); +return ff_filter_frame(outlink, out); } static const AVFilterPad super2xsai_inputs[] = { @@ -351,4 +366,5 @@ AVFilter
[FFmpeg-cvslog] ffmpeg_opts: remove lowres check
ffmpeg | branch: master | James Almer | Fri Jan 8 17:47:41 2021 -0300| [a423bc9dc294c32e6162b900b58b1cc2d3c3328d] | committer: James Almer ffmpeg_opts: remove lowres check The st->codec values are updated based on the lowres factor by avformat_find_stream_info() when it runs an instance of the decoder internally, and the same thing happens in ffmpeg.c when we open ist->dec_ctx with avcodec_open2(), so these assignments are redundant. Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a423bc9dc294c32e6162b900b58b1cc2d3c3328d --- fftools/ffmpeg_opt.c | 9 - 1 file changed, 9 deletions(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index fd923fce04..bf2eb26246 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -867,15 +867,6 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) case AVMEDIA_TYPE_VIDEO: if(!ist->dec) ist->dec = avcodec_find_decoder(par->codec_id); -#if FF_API_LOWRES -if (st->codec->lowres) { -ist->dec_ctx->lowres = st->codec->lowres; -ist->dec_ctx->width = st->codec->width; -ist->dec_ctx->height = st->codec->height; -ist->dec_ctx->coded_width = st->codec->coded_width; -ist->dec_ctx->coded_height = st->codec->coded_height; -} -#endif // avformat_find_stream_info() doesn't set this for us anymore. ist->dec_ctx->framerate = st->avg_frame_rate; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avfilter/vf_readeia608: add >8 depth support
ffmpeg | branch: master | Paul B Mahol | Thu Jan 21 14:27:44 2021 +0100| [df4e2b923c21ee4565eb1789f96fba0ab55a3c00] | committer: Paul B Mahol avfilter/vf_readeia608: add >8 depth support > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=df4e2b923c21ee4565eb1789f96fba0ab55a3c00 --- libavfilter/vf_readeia608.c | 104 ++-- 1 file changed, 72 insertions(+), 32 deletions(-) diff --git a/libavfilter/vf_readeia608.c b/libavfilter/vf_readeia608.c index bd0a950a26..d4c3ca6e58 100644 --- a/libavfilter/vf_readeia608.c +++ b/libavfilter/vf_readeia608.c @@ -62,7 +62,7 @@ typedef struct ScanItem { int found; int white; int black; -uint64_t histogram[256]; +uint64_t *histogram; uint8_t byte[2]; CodeItem *code; @@ -77,8 +77,13 @@ typedef struct ReadEIA608Context { int chp; int lp; +int depth; +int max; int nb_allocated; ScanItem *scan; + +void (*read_line[2])(AVFrame *in, int nb_line, + LineItem *line, int lp, int w); } ReadEIA608Context; #define OFFSET(x) offsetof(ReadEIA608Context, x) @@ -98,13 +103,26 @@ AVFILTER_DEFINE_CLASS(readeia608); static int query_formats(AVFilterContext *ctx) { static const enum AVPixelFormat pixel_fmts[] = { -AV_PIX_FMT_GRAY8, +AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9, +AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14, +AV_PIX_FMT_GRAY16, AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ411P, +AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9, +AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10, +AV_PIX_FMT_YUV440P10, +AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV420P12, +AV_PIX_FMT_YUV440P12, +AV_PIX_FMT_YUV444P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV420P14, +AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16, +AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P, +AV_PIX_FMT_YUVA444P9, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_YUVA444P16, +AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA422P12, AV_PIX_FMT_YUVA422P16, +AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA420P16, AV_PIX_FMT_NONE }; AVFilterFormats *formats = ff_make_format_list(pixel_fmts); @@ -142,11 +160,13 @@ static int config_filter(AVFilterContext *ctx, int start, int end) for (int i = 0; i < s->nb_allocated; i++) { ScanItem *scan = &s->scan[i]; +if (!scan->histogram) +scan->histogram = av_calloc(s->max + 1, sizeof(*scan->histogram)); if (!scan->line) scan->line = av_calloc(size, sizeof(*scan->line)); if (!scan->code) scan->code = av_calloc(size, sizeof(*scan->code)); -if (!scan->line || !scan->code) +if (!scan->line || !scan->code || !scan->histogram) return AVERROR(ENOMEM); } @@ -156,17 +176,9 @@ static int config_filter(AVFilterContext *ctx, int start, int end) return 0; } -static int config_input(AVFilterLink *inlink) -{ -AVFilterContext *ctx = inlink->dst; -ReadEIA608Context *s = ctx->priv; - -return config_filter(ctx, s->start, s->end); -} - static void build_histogram(ReadEIA608Context *s, ScanItem *scan, const LineItem *line, int len) { -memset(scan->histogram, 0, sizeof(scan->histogram)); +memset(scan->histogram, 0, (s->max + 1) * sizeof(*scan->histogram)); for (int i = LAG; i < len + LAG; i++) scan->histogram[line[i].input]++; @@ -174,18 +186,19 @@ static void build_histogram(ReadEIA608Context *s, ScanItem *scan, const LineItem static void find_black_and_white(ReadEIA608Context *s, ScanItem *scan) { +const int max = s->max; int start = 0, end = 0, middle; int black = 0, white = 0; int cnt; -for (int i = 0; i < 256; i++) { +for (int i = 0; i <= max; i++) { if (scan->histogram[i]) { start = i; break; } } -for (int i = 255; i >= 0; i--) { +for (int i = max; i >= 0; i--) { if (scan->histogram[i]) { end = i; break; @@ -308,12 +321,54 @@ static void dump_code(AVFilterContext *ctx, ScanItem *scan, int len, int item) av_log(ctx, AV_LOG_DEBUG, "\n"); } +#define READ_LINE(type, name) \ +static void read_##name(AVFrame *in, int nb_line, LineItem *line, int lp, int w) \ +{ \ +const type *src = (const type *)(&in->data[0][nb_line * in->linesize[0]]);\ +
[FFmpeg-cvslog] h264_metadata_bsf: Move SEI user data parsing to init time
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:12 2021 +| [75092c5b45d00585f72945243a1509d77a8f6476] | committer: Mark Thompson h264_metadata_bsf: Move SEI user data parsing to init time > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=75092c5b45d00585f72945243a1509d77a8f6476 --- libavcodec/h264_metadata_bsf.c | 91 -- 1 file changed, 43 insertions(+), 48 deletions(-) diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c index d7cf58095b..f39e649ac6 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -78,6 +78,7 @@ typedef struct H264MetadataContext { int crop_bottom; const char *sei_user_data; +H264RawSEIPayload sei_user_data_payload; int delete_filler; @@ -413,54 +414,10 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) // Only insert the SEI in access units containing SPSs, and also // unconditionally in the first access unit we ever see. if (ctx->sei_user_data && (has_sps || !ctx->done_first_au)) { -H264RawSEIPayload payload = { -.payload_type = H264_SEI_TYPE_USER_DATA_UNREGISTERED, -}; -SEIRawUserDataUnregistered *udu = -&payload.payload.user_data_unregistered; - -for (i = j = 0; j < 32 && ctx->sei_user_data[i]; i++) { -int c, v; -c = ctx->sei_user_data[i]; -if (c == '-') { -continue; -} else if (av_isxdigit(c)) { -c = av_tolower(c); -v = (c <= '9' ? c - '0' : c - 'a' + 10); -} else { -goto invalid_user_data; -} -if (j & 1) -udu->uuid_iso_iec_11578[j / 2] |= v; -else -udu->uuid_iso_iec_11578[j / 2] = v << 4; -++j; -} -if (j == 32 && ctx->sei_user_data[i] == '+') { -size_t len = strlen(ctx->sei_user_data + i + 1); - -udu->data_ref = av_buffer_alloc(len + 1); -if (!udu->data_ref) { -err = AVERROR(ENOMEM); -goto fail; -} - -udu->data= udu->data_ref->data; -udu->data_length = len + 1; -memcpy(udu->data, ctx->sei_user_data + i + 1, len + 1); - -err = ff_cbs_h264_add_sei_message(au, &payload); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to add user data SEI " - "message to access unit.\n"); -goto fail; -} - -} else { -invalid_user_data: -av_log(bsf, AV_LOG_ERROR, "Invalid user data: " - "must be \"UUID+string\".\n"); -err = AVERROR(EINVAL); +err = ff_cbs_h264_add_sei_message(au, &ctx->sei_user_data_payload); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to add user data SEI " + "message to access unit.\n"); goto fail; } } @@ -627,6 +584,44 @@ static int h264_metadata_init(AVBSFContext *bsf) CodedBitstreamFragment *au = &ctx->access_unit; int err, i; +if (ctx->sei_user_data) { +SEIRawUserDataUnregistered *udu = +&ctx->sei_user_data_payload.payload.user_data_unregistered; +int j; + +ctx->sei_user_data_payload.payload_type = +H264_SEI_TYPE_USER_DATA_UNREGISTERED; + +// Parse UUID. It must be a hex string of length 32, possibly +// containing '-'s between hex digits (which we ignore). +for (i = j = 0; j < 32 && i < 64 && ctx->sei_user_data[i]; i++) { +int c, v; +c = ctx->sei_user_data[i]; +if (c == '-') { +continue; +} else if (av_isxdigit(c)) { +c = av_tolower(c); +v = (c <= '9' ? c - '0' : c - 'a' + 10); +} else { +break; +} +if (j & 1) +udu->uuid_iso_iec_11578[j / 2] |= v; +else +udu->uuid_iso_iec_11578[j / 2] = v << 4; +++j; +} +if (j == 32 && ctx->sei_user_data[i] == '+') { +udu->data = (uint8_t*)ctx->sei_user_data + i + 1; +udu->data_length = strlen(udu->data) + 1; +} else { +av_log(bsf, AV_LOG_ERROR, "Invalid user data: " + "must be \"UUID+string\".\n"); +err = AVERROR(EINVAL); +goto fail; +} +} + err = ff_cbs_init(&ctx->input, AV_CODEC_ID_H264, bsf); if (err < 0) return err; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] cbs_h2645: Merge SEI messages in common between codecs
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:11 2021 +| [4bf338480035238b3ff595ebd761688fc0db9e11] | committer: Mark Thompson cbs_h2645: Merge SEI messages in common between codecs Make a new template file for common SEI messages - this will also apply to H.266. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4bf338480035238b3ff595ebd761688fc0db9e11 --- libavcodec/cbs_h264.h | 37 ++ libavcodec/cbs_h2645.c| 24 -- libavcodec/cbs_h264_syntax_template.c | 106 +- libavcodec/cbs_h265.h | 45 ++-- libavcodec/cbs_h265_syntax_template.c | 135 +- libavcodec/cbs_sei.h | 60 +++ libavcodec/cbs_sei_syntax_template.c | 132 + libavcodec/h264_metadata_bsf.c| 2 +- libavcodec/vaapi_encode_h264.c| 2 +- libavcodec/vaapi_encode_h265.c| 11 +-- 10 files changed, 250 insertions(+), 304 deletions(-) diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h index a6fe0a6af2..81113f1ad0 100644 --- a/libavcodec/cbs_h264.h +++ b/libavcodec/cbs_h264.h @@ -24,6 +24,7 @@ #include "cbs.h" #include "cbs_h2645.h" +#include "cbs_sei.h" #include "h264.h" @@ -274,21 +275,6 @@ typedef struct H264RawSEIPanScanRect { uint16_t pan_scan_rect_repetition_period; } H264RawSEIPanScanRect; -typedef struct H264RawSEIUserDataRegistered { -uint8_t itu_t_t35_country_code; -uint8_t itu_t_t35_country_code_extension_byte; -uint8_t *data; -AVBufferRef *data_ref; -size_t data_length; -} H264RawSEIUserDataRegistered; - -typedef struct H264RawSEIUserDataUnregistered { -uint8_t uuid_iso_iec_11578[16]; -uint8_t *data; -AVBufferRef *data_ref; -size_t data_length; -} H264RawSEIUserDataUnregistered; - typedef struct H264RawSEIRecoveryPoint { uint16_t recovery_frame_cnt; uint8_t exact_match_flag; @@ -305,19 +291,6 @@ typedef struct H264RawSEIDisplayOrientation { uint8_t display_orientation_extension_flag; } H264RawSEIDisplayOrientation; -typedef struct H264RawSEIMasteringDisplayColourVolume { -uint16_t display_primaries_x[3]; -uint16_t display_primaries_y[3]; -uint16_t white_point_x; -uint16_t white_point_y; -uint32_t max_display_mastering_luminance; -uint32_t min_display_mastering_luminance; -} H264RawSEIMasteringDisplayColourVolume; - -typedef struct H264RawSEIAlternativeTransferCharacteristics { -uint8_t preferred_transfer_characteristics; -} H264RawSEIAlternativeTransferCharacteristics; - typedef struct H264RawSEIPayload { uint32_t payload_type; uint32_t payload_size; @@ -326,12 +299,12 @@ typedef struct H264RawSEIPayload { H264RawSEIPicTiming pic_timing; H264RawSEIPanScanRect pan_scan_rect; // H264RawSEIFiller filler -> no fields. -H264RawSEIUserDataRegistered user_data_registered; -H264RawSEIUserDataUnregistered user_data_unregistered; +SEIRawUserDataRegistered user_data_registered; +SEIRawUserDataUnregistered user_data_unregistered; H264RawSEIRecoveryPoint recovery_point; H264RawSEIDisplayOrientation display_orientation; -H264RawSEIMasteringDisplayColourVolume mastering_display_colour_volume; -H264RawSEIAlternativeTransferCharacteristics +SEIRawMasteringDisplayColourVolume mastering_display_colour_volume; +SEIRawAlternativeTransferCharacteristics alternative_transfer_characteristics; struct { uint8_t *data; diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 550c059ef3..9e210abba4 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -253,9 +253,11 @@ static int cbs_h265_payload_extension_present(GetBitContext *gbc, uint32_t paylo return err; \ } while (0) -#define FUNC_NAME(rw, codec, name) cbs_ ## codec ## _ ## rw ## _ ## name -#define FUNC_H264(rw, name) FUNC_NAME(rw, h264, name) -#define FUNC_H265(rw, name) FUNC_NAME(rw, h265, name) +#define FUNC_NAME2(rw, codec, name) cbs_ ## codec ## _ ## rw ## _ ## name +#define FUNC_NAME1(rw, codec, name) FUNC_NAME2(rw, codec, name) +#define FUNC_H264(name) FUNC_NAME1(READWRITE, h264, name) +#define FUNC_H265(name) FUNC_NAME1(READWRITE, h265, name) +#define FUNC_SEI(name) FUNC_NAME1(READWRITE, sei, name) #define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL) @@ -356,11 +358,15 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc) name = name ## _ref->data; \ } while (0) -#define FUNC(name) FUNC_H264(READWRITE, name) +#define FUNC(name) FUNC_SEI(name) +#include "cbs_sei_syntax_template.c" +#undef FUNC + +#define FUNC(name) FUNC_H264(name) #include "cbs_h264_syntax_template.c" #undef FUNC -#define FUNC(name) FUNC_H265(READWRITE, name) +#define FUNC(name) FUNC_H265(nam
[FFmpeg-cvslog] h264: Use common SEI types
ffmpeg | branch: master | Mark Thompson | Thu Jan 21 14:37:49 2021 +| [64b3aac8d07a8744656737619b70977359d9a6a5] | committer: Mark Thompson h264: Use common SEI types > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=64b3aac8d07a8744656737619b70977359d9a6a5 --- libavcodec/cbs_h2645.c| 18 +- libavcodec/cbs_h264_syntax_template.c | 20 ++-- libavcodec/h264_metadata_bsf.c| 8 libavcodec/h264_sei.c | 18 +- libavcodec/h264_sei.h | 18 +- libavcodec/vaapi_encode_h264.c| 8 libavcodec/videotoolboxenc.c | 6 +++--- 7 files changed, 40 insertions(+), 56 deletions(-) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 9e210abba4..d26d85bcd3 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -1384,18 +1384,18 @@ static void cbs_h265_close(CodedBitstreamContext *ctx) static void cbs_h264_free_sei_payload(H264RawSEIPayload *payload) { switch (payload->payload_type) { -case H264_SEI_TYPE_BUFFERING_PERIOD: -case H264_SEI_TYPE_PIC_TIMING: -case H264_SEI_TYPE_PAN_SCAN_RECT: -case H264_SEI_TYPE_RECOVERY_POINT: -case H264_SEI_TYPE_DISPLAY_ORIENTATION: -case H264_SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME: -case H264_SEI_TYPE_ALTERNATIVE_TRANSFER: +case SEI_TYPE_BUFFERING_PERIOD: +case SEI_TYPE_PIC_TIMING: +case SEI_TYPE_PAN_SCAN_RECT: +case SEI_TYPE_RECOVERY_POINT: +case SEI_TYPE_DISPLAY_ORIENTATION: +case SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME: +case SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS: break; -case H264_SEI_TYPE_USER_DATA_REGISTERED: +case SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35: av_buffer_unref(&payload->payload.user_data_registered.data_ref); break; -case H264_SEI_TYPE_USER_DATA_UNREGISTERED: +case SEI_TYPE_USER_DATA_UNREGISTERED: av_buffer_unref(&payload->payload.user_data_unregistered.data_ref); break; default: diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c index 76ed51cc7b..37047dc30b 100644 --- a/libavcodec/cbs_h264_syntax_template.c +++ b/libavcodec/cbs_h264_syntax_template.c @@ -747,45 +747,45 @@ static int FUNC(sei_payload)(CodedBitstreamContext *ctx, RWContext *rw, #endif switch (current->payload_type) { -case H264_SEI_TYPE_BUFFERING_PERIOD: +case SEI_TYPE_BUFFERING_PERIOD: CHECK(FUNC(sei_buffering_period) (ctx, rw, ¤t->payload.buffering_period)); break; -case H264_SEI_TYPE_PIC_TIMING: +case SEI_TYPE_PIC_TIMING: CHECK(FUNC(sei_pic_timing) (ctx, rw, ¤t->payload.pic_timing)); break; -case H264_SEI_TYPE_PAN_SCAN_RECT: +case SEI_TYPE_PAN_SCAN_RECT: CHECK(FUNC(sei_pan_scan_rect) (ctx, rw, ¤t->payload.pan_scan_rect)); break; -case H264_SEI_TYPE_FILLER_PAYLOAD: +case SEI_TYPE_FILLER_PAYLOAD: { for (i = 0; i < current->payload_size; i++) fixed(8, ff_byte, 0xff); } break; -case H264_SEI_TYPE_USER_DATA_REGISTERED: +case SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35: CHECK(FUNC_SEI(sei_user_data_registered) (ctx, rw, ¤t->payload.user_data_registered, ¤t->payload_size)); break; -case H264_SEI_TYPE_USER_DATA_UNREGISTERED: +case SEI_TYPE_USER_DATA_UNREGISTERED: CHECK(FUNC_SEI(sei_user_data_unregistered) (ctx, rw, ¤t->payload.user_data_unregistered, ¤t->payload_size)); break; -case H264_SEI_TYPE_RECOVERY_POINT: +case SEI_TYPE_RECOVERY_POINT: CHECK(FUNC(sei_recovery_point) (ctx, rw, ¤t->payload.recovery_point)); break; -case H264_SEI_TYPE_DISPLAY_ORIENTATION: +case SEI_TYPE_DISPLAY_ORIENTATION: CHECK(FUNC(sei_display_orientation) (ctx, rw, ¤t->payload.display_orientation)); break; -case H264_SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME: +case SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME: CHECK(FUNC_SEI(sei_mastering_display_colour_volume) (ctx, rw, ¤t->payload.mastering_display_colour_volume)); break; -case H264_SEI_TYPE_ALTERNATIVE_TRANSFER: +case SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS: CHECK(FUNC_SEI(sei_alternative_transfer_characteristics) (ctx, rw, ¤t->payload.alternative_transfer_characteristics)); break; diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c index f39e649ac6..2228761113 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -435,7 +435,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) for (j = sei->payload_count - 1; j >= 0; j--) { if (sei->payload[j].payload_type == -
[FFmpeg-cvslog] lavc: Add new header for SEI payload types
ffmpeg | branch: master | Mark Thompson | Thu Jan 21 14:31:56 2021 +| [9ef32649d02109c364387edcbb55932491f1dcf1] | committer: Mark Thompson lavc: Add new header for SEI payload types These form a common namespace between the H.264, H.265 and H.266 standards, so we can use the same definitions in all three places. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9ef32649d02109c364387edcbb55932491f1dcf1 --- libavcodec/sei.h | 139 +++ 1 file changed, 139 insertions(+) diff --git a/libavcodec/sei.h b/libavcodec/sei.h new file mode 100644 index 00..f07c72ae7b --- /dev/null +++ b/libavcodec/sei.h @@ -0,0 +1,139 @@ +/* + * 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 + */ + +#ifndef AVCODEC_SEI_H +#define AVCODEC_SEI_H + +// SEI payload types form a common namespace between the H.264, H.265 +// and H.266 standards. A given payload type always has the same +// meaning, but some names have different payload types in different +// standards (e.g. scalable-nesting is 30 in H.264 but 133 in H.265). +// The content of the payload data depends on the standard, though +// many generic parts have the same interpretation everywhere (such as +// mastering-display-colour-volume and user-data-unregistered). +enum { +SEI_TYPE_BUFFERING_PERIOD= 0, +SEI_TYPE_PIC_TIMING = 1, +SEI_TYPE_PAN_SCAN_RECT = 2, +SEI_TYPE_FILLER_PAYLOAD = 3, +SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35 = 4, +SEI_TYPE_USER_DATA_UNREGISTERED = 5, +SEI_TYPE_RECOVERY_POINT = 6, +SEI_TYPE_DEC_REF_PIC_MARKING_REPETITION = 7, +SEI_TYPE_SPARE_PIC = 8, +SEI_TYPE_SCENE_INFO = 9, +SEI_TYPE_SUB_SEQ_INFO= 10, +SEI_TYPE_SUB_SEQ_LAYER_CHARACTERISTICS = 11, +SEI_TYPE_SUB_SEQ_CHARACTERISTICS = 12, +SEI_TYPE_FULL_FRAME_FREEZE = 13, +SEI_TYPE_FULL_FRAME_FREEZE_RELEASE = 14, +SEI_TYPE_FULL_FRAME_SNAPSHOT = 15, +SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_START= 16, +SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_END = 17, +SEI_TYPE_MOTION_CONSTRAINED_SLICE_GROUP_SET = 18, +SEI_TYPE_FILM_GRAIN_CHARACTERISTICS = 19, +SEI_TYPE_DEBLOCKING_FILTER_DISPLAY_PREFERENCE= 20, +SEI_TYPE_STEREO_VIDEO_INFO = 21, +SEI_TYPE_POST_FILTER_HINT= 22, +SEI_TYPE_TONE_MAPPING_INFO = 23, +SEI_TYPE_SCALABILITY_INFO= 24, +SEI_TYPE_SUB_PIC_SCALABLE_LAYER = 25, +SEI_TYPE_NON_REQUIRED_LAYER_REP = 26, +SEI_TYPE_PRIORITY_LAYER_INFO = 27, +SEI_TYPE_LAYERS_NOT_PRESENT_4= 28, +SEI_TYPE_LAYER_DEPENDENCY_CHANGE = 29, +SEI_TYPE_SCALABLE_NESTING_4 = 30, +SEI_TYPE_BASE_LAYER_TEMPORAL_HRD = 31, +SEI_TYPE_QUALITY_LAYER_INTEGRITY_CHECK = 32, +SEI_TYPE_REDUNDANT_PIC_PROPERTY = 33, +SEI_TYPE_TL0_DEP_REP_INDEX = 34, +SEI_TYPE_TL_SWITCHING_POINT = 35, +SEI_TYPE_PARALLEL_DECODING_INFO = 36, +SEI_TYPE_MVC_SCALABLE_NESTING= 37, +SEI_TYPE_VIEW_SCALABILITY_INFO = 38, +SEI_TYPE_MULTIVIEW_SCENE_INFO_4 = 39, +SEI_TYPE_MULTIVIEW_ACQUISITION_INFO_4= 40, +SEI_TYPE_NON_REQUIRED_VIEW_COMPONENT = 41, +SEI_TYPE_VIEW_DEPENDENCY_CHANGE = 42, +SEI_TYPE_OPERATION_POINTS_NOT_PRESENT= 43, +SEI_TYPE_BASE_VIEW_TEMPORAL_HRD = 44, +SEI_TYPE_FRAME_PACKING_ARRANGEMENT = 45, +SEI_TYPE_MULTIVIEW_VIEW_POSITION_4
[FFmpeg-cvslog] hevc: Use common SEI types
ffmpeg | branch: master | Mark Thompson | Thu Jan 21 14:38:58 2021 +| [773857df592d8f3095a548b3085c6b7fe6b30dfe] | committer: Mark Thompson hevc: Use common SEI types > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=773857df592d8f3095a548b3085c6b7fe6b30dfe --- libavcodec/cbs_h2645.c| 28 ++-- libavcodec/cbs_h265_syntax_template.c | 15 --- libavcodec/hevc_sei.c | 22 +++--- libavcodec/hevc_sei.h | 34 +- libavcodec/nvenc.c| 2 +- libavcodec/vaapi_encode_h265.c| 4 ++-- 6 files changed, 37 insertions(+), 68 deletions(-) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index d26d85bcd3..4478a6f810 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -1445,23 +1445,23 @@ static const CodedBitstreamUnitTypeDescriptor cbs_h264_unit_types[] = { static void cbs_h265_free_sei_payload(H265RawSEIPayload *payload) { switch (payload->payload_type) { -case HEVC_SEI_TYPE_BUFFERING_PERIOD: -case HEVC_SEI_TYPE_PICTURE_TIMING: -case HEVC_SEI_TYPE_PAN_SCAN_RECT: -case HEVC_SEI_TYPE_RECOVERY_POINT: -case HEVC_SEI_TYPE_DISPLAY_ORIENTATION: -case HEVC_SEI_TYPE_ACTIVE_PARAMETER_SETS: -case HEVC_SEI_TYPE_DECODED_PICTURE_HASH: -case HEVC_SEI_TYPE_TIME_CODE: -case HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO: -case HEVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO: -case HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS: -case HEVC_SEI_TYPE_ALPHA_CHANNEL_INFO: +case SEI_TYPE_BUFFERING_PERIOD: +case SEI_TYPE_PIC_TIMING: +case SEI_TYPE_PAN_SCAN_RECT: +case SEI_TYPE_RECOVERY_POINT: +case SEI_TYPE_DISPLAY_ORIENTATION: +case SEI_TYPE_ACTIVE_PARAMETER_SETS: +case SEI_TYPE_DECODED_PICTURE_HASH: +case SEI_TYPE_TIME_CODE: +case SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME: +case SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO: +case SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS: +case SEI_TYPE_ALPHA_CHANNEL_INFO: break; -case HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35: +case SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35: av_buffer_unref(&payload->payload.user_data_registered.data_ref); break; -case HEVC_SEI_TYPE_USER_DATA_UNREGISTERED: +case SEI_TYPE_USER_DATA_UNREGISTERED: av_buffer_unref(&payload->payload.user_data_unregistered.data_ref); break; default: diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c index b792ec688a..64afc3f01d 100644 --- a/libavcodec/cbs_h265_syntax_template.c +++ b/libavcodec/cbs_h265_syntax_template.c @@ -2049,18 +2049,18 @@ static int FUNC(sei_payload)(CodedBitstreamContext *ctx, RWContext *rw, } \ } while (0) #define SEI_TYPE_N(type, prefix_valid, suffix_valid, name) \ -case HEVC_SEI_TYPE_ ## type: \ +case SEI_TYPE_ ## type: \ SEI_TYPE_CHECK_VALID(name, prefix_valid, suffix_valid); \ CHECK(FUNC(sei_ ## name)(ctx, rw, ¤t->payload.name)); \ break #define SEI_TYPE_S(type, prefix_valid, suffix_valid, name) \ -case HEVC_SEI_TYPE_ ## type: \ +case SEI_TYPE_ ## type: \ SEI_TYPE_CHECK_VALID(name, prefix_valid, suffix_valid); \ CHECK(FUNC(sei_ ## name)(ctx, rw, ¤t->payload.name, \ ¤t->payload_size)); \ break #define SEI_TYPE_E(type, prefix_valid, suffix_valid, name) \ -case HEVC_SEI_TYPE_ ## type: \ +case SEI_TYPE_ ## type: \ SEI_TYPE_CHECK_VALID(name, prefix_valid, suffix_valid); \ CHECK(FUNC(sei_ ## name)(ctx, rw, ¤t->payload.name, \ ¤t->payload_size, \ @@ -2068,19 +2068,19 @@ static int FUNC(sei_payload)(CodedBitstreamContext *ctx, RWContext *rw, break #define SEI_TYPE_N2(type, prefix_valid, suffix_valid, name) \ -case HEVC_SEI_TYPE_ ## type: \ +case SEI_TYPE_ ## type: \ SEI_TYPE_CHECK_VALID(name, prefix_valid, suffix_valid); \ CHECK(FUNC_SEI(sei_ ## name)(ctx, rw, ¤t->payload.name)); \ break #define SEI_TYPE_S2(type, prefix_valid, suffix_valid, name) \ -case HEVC_SEI_TYPE_ ## type: \ +case SEI_TYPE_ ## type: \ SEI_TYPE_CHECK_VALID(name, prefix_valid, suffix_valid); \ CHECK(FUNC_SEI(sei_ ## name)(ctx, rw, ¤t->payload.name, \ ¤t->payload_size)); \ break SEI_TYPE_E(BUFFERING_PERIOD, 1, 0, buffering_period); -SEI_TYPE_N(PICTURE_TIMING, 1, 0, pic_timing); +SEI_TYPE_N(PIC_TIMING, 1, 0, pic_timing); SEI_TYPE_N(PAN_SCAN_RECT,1, 0, pan_scan_rect); SEI_TYPE_S2(USER_DATA_REGISTERED_ITU_T_T35, 1, 1, user_data_registered); @@ -2090,7 +2090,8 @@ static int FUNC(sei_payload)(CodedBitstreamContext *ctx, RWContext *rw
[FFmpeg-cvslog] cbs_h2645: Merge SEI message handling in common between codecs
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:13 2021 +| [8843607f495c95c1e67a3ce3d6f15dca6e252439] | committer: Mark Thompson cbs_h2645: Merge SEI message handling in common between codecs > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8843607f495c95c1e67a3ce3d6f15dca6e252439 --- libavcodec/Makefile | 4 +- libavcodec/cbs_h264.h | 50 + libavcodec/cbs_h2645.c| 300 ++- libavcodec/cbs_h264_syntax_template.c | 173 ++-- libavcodec/cbs_h265.h | 33 +-- libavcodec/cbs_h265_syntax_template.c | 272 +++-- libavcodec/cbs_sei.c | 369 ++ libavcodec/cbs_sei.h | 139 + libavcodec/cbs_sei_syntax_template.c | 215 ++-- libavcodec/h264_metadata_bsf.c| 113 +-- libavcodec/vaapi_encode_h264.c| 51 ++--- libavcodec/vaapi_encode_h265.c| 38 +--- 12 files changed, 991 insertions(+), 766 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 446e6e6b3b..1fcb94fa48 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -71,8 +71,8 @@ OBJS-$(CONFIG_BSWAPDSP)+= bswapdsp.o OBJS-$(CONFIG_CABAC) += cabac.o OBJS-$(CONFIG_CBS) += cbs.o OBJS-$(CONFIG_CBS_AV1) += cbs_av1.o -OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o h2645_parse.o -OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o h2645_parse.o +OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o cbs_sei.o h2645_parse.o +OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o cbs_sei.o h2645_parse.o OBJS-$(CONFIG_CBS_JPEG)+= cbs_jpeg.o OBJS-$(CONFIG_CBS_MPEG2) += cbs_mpeg2.o OBJS-$(CONFIG_CBS_VP9) += cbs_vp9.o diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h index 81113f1ad0..9eb97eae24 100644 --- a/libavcodec/cbs_h264.h +++ b/libavcodec/cbs_h264.h @@ -291,34 +291,9 @@ typedef struct H264RawSEIDisplayOrientation { uint8_t display_orientation_extension_flag; } H264RawSEIDisplayOrientation; -typedef struct H264RawSEIPayload { -uint32_t payload_type; -uint32_t payload_size; -union { -H264RawSEIBufferingPeriod buffering_period; -H264RawSEIPicTiming pic_timing; -H264RawSEIPanScanRect pan_scan_rect; -// H264RawSEIFiller filler -> no fields. -SEIRawUserDataRegistered user_data_registered; -SEIRawUserDataUnregistered user_data_unregistered; -H264RawSEIRecoveryPoint recovery_point; -H264RawSEIDisplayOrientation display_orientation; -SEIRawMasteringDisplayColourVolume mastering_display_colour_volume; -SEIRawAlternativeTransferCharacteristics -alternative_transfer_characteristics; -struct { -uint8_t *data; -AVBufferRef *data_ref; -size_t data_length; -} other; -} payload; -} H264RawSEIPayload; - typedef struct H264RawSEI { H264RawNALUnitHeader nal_unit_header; - -H264RawSEIPayload payload[H264_MAX_SEI_PAYLOADS]; -uint8_t payload_count; +SEIRawMessageListmessage_list; } H264RawSEI; typedef struct H264RawSliceHeader { @@ -438,27 +413,4 @@ typedef struct CodedBitstreamH264Context { uint8_t last_slice_nal_unit_type; } CodedBitstreamH264Context; - -/** - * Add an SEI message to an access unit. - * - * On success, the payload will be owned by a unit in access_unit; - * on failure, the content of the payload will be freed. - */ -int ff_cbs_h264_add_sei_message(CodedBitstreamFragment *access_unit, -H264RawSEIPayload *payload); - -/** - * Delete an SEI message from an access unit. - * - * Deletes from nal_unit, which must be an SEI NAL unit. If this is the - * last message in nal_unit, also deletes it from access_unit. - * - * Requires nal_unit to be a unit in access_unit and position to be >= 0 - * and < the payload count of the SEI nal_unit. - */ -void ff_cbs_h264_delete_sei_message(CodedBitstreamFragment *access_unit, -CodedBitstreamUnit *nal_unit, -int position); - #endif /* AVCODEC_CBS_H264_H */ diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 4478a6f810..6005d46e0d 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -348,6 +348,7 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc) #define more_rbsp_data(var) ((var) = cbs_h2645_read_more_rbsp_data(rw)) +#define bit_position(rw) (get_bits_count(rw)) #define byte_alignment(rw) (get_bits_count(rw) % 8) #define allocate(name, size) do { \ @@ -379,6 +380,7 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc) #undef xse #undef infer #undef more_rbsp_data +#undef bit_position #undef byte_alignment #undef allocat
[FFmpeg-cvslog] h264_metadata_bsf: Improve interpretation of input display matrices
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:16 2021 +| [c9c5b1977fe2406df495665fa3254657f0170ff5] | committer: Mark Thompson h264_metadata_bsf: Improve interpretation of input display matrices The previous code here only worked in more limited cases. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c9c5b1977fe2406df495665fa3254657f0170ff5 --- libavcodec/h264_metadata_bsf.c | 44 -- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c index 34f032624e..d0089b0eb4 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -431,23 +431,39 @@ static int h264_metadata_handle_display_orientation(AVBSFContext *bsf, data = av_packet_get_side_data(pkt, AV_PKT_DATA_DISPLAYMATRIX, &size); if (data && size >= 9 * sizeof(int32_t)) { int32_t matrix[9]; -int hflip, vflip; -double angle; +double dmatrix[9]; +int hflip, vflip, i; +double scale_x, scale_y, angle; memcpy(matrix, data, sizeof(matrix)); -hflip = vflip = 0; -if (matrix[0] < 0 && matrix[4] > 0) -hflip = 1; -else if (matrix[0] > 0 && matrix[4] < 0) -vflip = 1; -av_display_matrix_flip(matrix, hflip, vflip); +for (i = 0; i < 9; i++) +dmatrix[i] = matrix[i] / 65536.0; + +// Extract scale factors. +scale_x = hypot(dmatrix[0], dmatrix[3]); +scale_y = hypot(dmatrix[1], dmatrix[4]); + +// Select flips to make the main diagonal positive. +hflip = dmatrix[0] < 0.0; +vflip = dmatrix[4] < 0.0; +if (hflip) +scale_x = -scale_x; +if (vflip) +scale_y = -scale_y; + +// Rescale. +for (i = 0; i < 9; i += 3) { +dmatrix[i] /= scale_x; +dmatrix[i + 1] /= scale_y; +} -angle = av_display_rotation_get(matrix); +// Extract rotation. +angle = atan2(dmatrix[3], dmatrix[0]); -if (!(angle >= -180.0 && angle <= 180.0 /* also excludes NaN */) || -matrix[2] != 0 || matrix[5] != 0 || -matrix[6] != 0 || matrix[7] != 0) { +if (!(angle >= -M_PI && angle <= M_PI) || +matrix[2] != 0.0 || matrix[5] != 0.0 || +matrix[6] != 0.0 || matrix[7] != 0.0) { av_log(bsf, AV_LOG_WARNING, "Input display matrix is not " "representable in H.264 parameters.\n"); } else { @@ -455,8 +471,8 @@ static int h264_metadata_handle_display_orientation(AVBSFContext *bsf, disp->ver_flip = vflip; disp->anticlockwise_rotation = (uint16_t)rint((angle >= 0.0 ? angle - : angle + 360.0) * - 65536.0 / 360.0); + : angle + 2 * M_PI) * + 32768.0 / M_PI); write = 1; } } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] cbs_sei: Remove restrictions on MDCV values
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:14 2021 +| [88b65bed9ca033818f5618885c8a3d26d61a7c8a] | committer: Mark Thompson cbs_sei: Remove restrictions on MDCV values Since this was originally written the standards have changed to allow arbitrary values here, but leaves their meaning unspecified. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=88b65bed9ca033818f5618885c8a3d26d61a7c8a --- libavcodec/cbs_sei_syntax_template.c | 14 ++ 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/libavcodec/cbs_sei_syntax_template.c b/libavcodec/cbs_sei_syntax_template.c index 5f84246663..9114e61ff6 100644 --- a/libavcodec/cbs_sei_syntax_template.c +++ b/libavcodec/cbs_sei_syntax_template.c @@ -103,17 +103,15 @@ static int FUNC(mastering_display_colour_volume) HEADER("Mastering Display Colour Volume"); for (c = 0; c < 3; c++) { -us(16, display_primaries_x[c], 0, 5, 1, c); -us(16, display_primaries_y[c], 0, 5, 1, c); +ubs(16, display_primaries_x[c], 1, c); +ubs(16, display_primaries_y[c], 1, c); } -u(16, white_point_x, 0, 5); -u(16, white_point_y, 0, 5); +ub(16, white_point_x); +ub(16, white_point_y); -u(32, max_display_mastering_luminance, - 1, MAX_UINT_BITS(32)); -u(32, min_display_mastering_luminance, - 0, current->max_display_mastering_luminance - 1); +ub(32, max_display_mastering_luminance); +ub(32, min_display_mastering_luminance); return 0; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] cbs: Implement common parts of cbs-based bitstream filters separately
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:17 2021 +| [01a68c12a7cdf9031c19d1f00885a84d58e2c2a6] | committer: Mark Thompson cbs: Implement common parts of cbs-based bitstream filters separately This allows removal of a lot of duplicated code between BSFs. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=01a68c12a7cdf9031c19d1f00885a84d58e2c2a6 --- libavcodec/Makefile | 2 +- libavcodec/cbs_bsf.c | 159 +++ libavcodec/cbs_bsf.h | 131 ++ 3 files changed, 291 insertions(+), 1 deletion(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 1fcb94fa48..6c1e7a1c7a 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -69,7 +69,7 @@ OBJS-$(CONFIG_AUDIODSP)+= audiodsp.o OBJS-$(CONFIG_BLOCKDSP)+= blockdsp.o OBJS-$(CONFIG_BSWAPDSP)+= bswapdsp.o OBJS-$(CONFIG_CABAC) += cabac.o -OBJS-$(CONFIG_CBS) += cbs.o +OBJS-$(CONFIG_CBS) += cbs.o cbs_bsf.o OBJS-$(CONFIG_CBS_AV1) += cbs_av1.o OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o cbs_sei.o h2645_parse.o OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o cbs_sei.o h2645_parse.o diff --git a/libavcodec/cbs_bsf.c b/libavcodec/cbs_bsf.c new file mode 100644 index 00..9b521cf111 --- /dev/null +++ b/libavcodec/cbs_bsf.c @@ -0,0 +1,159 @@ +/* + * 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 "bsf_internal.h" +#include "cbs_bsf.h" + +static int cbs_bsf_update_side_data(AVBSFContext *bsf, AVPacket *pkt) +{ +CBSBSFContext *ctx = bsf->priv_data; +CodedBitstreamFragment *frag = &ctx->fragment; +uint8_t *side_data; +int side_data_size; +int err; + +side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, +&side_data_size); +if (!side_data_size) +return 0; + +err = ff_cbs_read(ctx->input, frag, side_data, side_data_size); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, + "Failed to read extradata from packet side data.\n"); +return err; +} + +err = ctx->type->update_fragment(bsf, NULL, frag); +if (err < 0) +return err; + +err = ff_cbs_write_fragment_data(ctx->output, frag); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, + "Failed to write extradata into packet side data.\n"); +return err; +} + +side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, +frag->data_size); +if (!side_data) +return AVERROR(ENOMEM); +memcpy(side_data, frag->data, frag->data_size); + +ff_cbs_fragment_reset(frag); +return 0; +} + +int ff_cbs_bsf_generic_filter(AVBSFContext *bsf, AVPacket *pkt) +{ +CBSBSFContext *ctx = bsf->priv_data; +CodedBitstreamFragment *frag = &ctx->fragment; +int err; + +err = ff_bsf_get_packet_ref(bsf, pkt); +if (err < 0) +return err; + +err = cbs_bsf_update_side_data(bsf, pkt); +if (err < 0) +goto fail; + +err = ff_cbs_read_packet(ctx->input, frag, pkt); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to read %s from packet.\n", + ctx->type->fragment_name); +goto fail; +} + +if (frag->nb_units == 0) { +av_log(bsf, AV_LOG_ERROR, "No %s found in packet.\n", + ctx->type->unit_name); +err = AVERROR_INVALIDDATA; +goto fail; +} + +err = ctx->type->update_fragment(bsf, pkt, frag); +if (err < 0) +goto fail; + +err = ff_cbs_write_packet(ctx->output, pkt, frag); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to write %s into packet.\n", + ctx->type->fragment_name); +goto fail; +} + +err = 0; +fail: +ff_cbs_fragment_reset(frag); + +if (err < 0) +av_packet_unref(pkt); + +return err; +} + +int ff_cbs_bsf_generic_init(AVBSFContext *bsf, const CBSBSFType *type) +{ +CBSBSFContext *ctx = bsf->priv_data; +CodedBitstreamFragment *frag = &ctx->fragment; +int err; + +ctx->type =
[FFmpeg-cvslog] h264_metadata_bsf: Refactor the filter function into smaller parts
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:15 2021 +| [8a14d51b8bab63d23fac2ac05aead590b4178408] | committer: Mark Thompson h264_metadata_bsf: Refactor the filter function into smaller parts > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8a14d51b8bab63d23fac2ac05aead590b4178408 --- libavcodec/h264_metadata_bsf.c | 326 +++-- 1 file changed, 180 insertions(+), 146 deletions(-) diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c index 6badb97b9e..34f032624e 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -56,6 +56,7 @@ typedef struct H264MetadataContext { int done_first_au; int aud; +H264RawAUD aud_nal; AVRational sample_aspect_ratio; @@ -91,6 +92,59 @@ typedef struct H264MetadataContext { } H264MetadataContext; +static int h264_metadata_insert_aud(AVBSFContext *bsf, +CodedBitstreamFragment *au) +{ +H264MetadataContext *ctx = bsf->priv_data; +int primary_pic_type_mask = 0xff; +int err, i, j; + +static const int primary_pic_type_table[] = { +0x084, // 2, 7 +0x0a5, // 0, 2, 5, 7 +0x0e7, // 0, 1, 2, 5, 6, 7 +0x210, // 4, 9 +0x318, // 3, 4, 8, 9 +0x294, // 2, 4, 7, 9 +0x3bd, // 0, 2, 3, 4, 5, 7, 8, 9 +0x3ff, // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 +}; + +for (i = 0; i < au->nb_units; i++) { +if (au->units[i].type == H264_NAL_SLICE || +au->units[i].type == H264_NAL_IDR_SLICE) { +H264RawSlice *slice = au->units[i].content; +for (j = 0; j < FF_ARRAY_ELEMS(primary_pic_type_table); j++) { +if (!(primary_pic_type_table[j] & + (1 << slice->header.slice_type))) +primary_pic_type_mask &= ~(1 << j); +} +} +} +for (j = 0; j < FF_ARRAY_ELEMS(primary_pic_type_table); j++) +if (primary_pic_type_mask & (1 << j)) +break; +if (j >= FF_ARRAY_ELEMS(primary_pic_type_table)) { +av_log(bsf, AV_LOG_ERROR, "No usable primary_pic_type: " + "invalid slice types?\n"); +return AVERROR_INVALIDDATA; +} + +ctx->aud_nal = (H264RawAUD) { +.nal_unit_header.nal_unit_type = H264_NAL_AUD, +.primary_pic_type = j, +}; + +err = ff_cbs_insert_unit_content(au, 0, H264_NAL_AUD, + &ctx->aud_nal, NULL); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to insert AUD.\n"); +return err; +} + +return 0; +} + static int h264_metadata_update_sps(AVBSFContext *bsf, H264RawSPS *sps) { @@ -322,160 +376,51 @@ static int h264_metadata_update_side_data(AVBSFContext *bsf, AVPacket *pkt) return 0; } -static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) +static int h264_metadata_handle_display_orientation(AVBSFContext *bsf, +AVPacket *pkt, +CodedBitstreamFragment *au, +int seek_point) { H264MetadataContext *ctx = bsf->priv_data; -CodedBitstreamFragment *au = &ctx->access_unit; -int err, i, j, has_sps; -H264RawAUD aud; - -err = ff_bsf_get_packet_ref(bsf, pkt); -if (err < 0) -return err; - -err = h264_metadata_update_side_data(bsf, pkt); -if (err < 0) -goto fail; - -err = ff_cbs_read_packet(ctx->input, au, pkt); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n"); -goto fail; -} - -if (au->nb_units == 0) { -av_log(bsf, AV_LOG_ERROR, "No NAL units in packet.\n"); -err = AVERROR_INVALIDDATA; -goto fail; -} - -// If an AUD is present, it must be the first NAL unit. -if (au->units[0].type == H264_NAL_AUD) { -if (ctx->aud == REMOVE) -ff_cbs_delete_unit(au, 0); -} else { -if (ctx->aud == INSERT) { -static const int primary_pic_type_table[] = { -0x084, // 2, 7 -0x0a5, // 0, 2, 5, 7 -0x0e7, // 0, 1, 2, 5, 6, 7 -0x210, // 4, 9 -0x318, // 3, 4, 8, 9 -0x294, // 2, 4, 7, 9 -0x3bd, // 0, 2, 3, 4, 5, 7, 8, 9 -0x3ff, // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 -}; -int primary_pic_type_mask = 0xff; - -for (i = 0; i < au->nb_units; i++) { -if (au->units[i].type == H264_NAL_SLICE || -au->units[i].type == H264_NAL_IDR_SLICE) { -H264RawSlice *slice = au->units[i].content; -for (j = 0; j < FF_ARRAY_ELEMS(primary_pic_type_table); j++) { - if (!(primary_pic_type_table[j] & -
[FFmpeg-cvslog] h264_metadata_bsf: Use common cbs bsf implementation
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:18 2021 +| [c837d9481a0035f3b547a5b417e5341e6e0d6128] | committer: Mark Thompson h264_metadata_bsf: Use common cbs bsf implementation > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c837d9481a0035f3b547a5b417e5341e6e0d6128 --- libavcodec/h264_metadata_bsf.c | 232 + 1 file changed, 49 insertions(+), 183 deletions(-) diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c index d0089b0eb4..30c0aa80d9 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -22,20 +22,13 @@ #include "libavutil/opt.h" #include "bsf.h" -#include "bsf_internal.h" #include "cbs.h" +#include "cbs_bsf.h" #include "cbs_h264.h" #include "h264.h" #include "h264_levels.h" #include "h264_sei.h" -enum { -PASS, -INSERT, -REMOVE, -EXTRACT, -}; - enum { FLIP_HORIZONTAL = 1, FLIP_VERTICAL = 2, @@ -47,11 +40,7 @@ enum { }; typedef struct H264MetadataContext { -const AVClass *class; - -CodedBitstreamContext *input; -CodedBitstreamContext *output; -CodedBitstreamFragment access_unit; +CBSBSFContext common; int done_first_au; @@ -333,49 +322,6 @@ static int h264_metadata_update_sps(AVBSFContext *bsf, return 0; } -static int h264_metadata_update_side_data(AVBSFContext *bsf, AVPacket *pkt) -{ -H264MetadataContext *ctx = bsf->priv_data; -CodedBitstreamFragment *au = &ctx->access_unit; -uint8_t *side_data; -int side_data_size; -int err, i; - -side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, -&side_data_size); -if (!side_data_size) -return 0; - -err = ff_cbs_read(ctx->input, au, side_data, side_data_size); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to read extradata from packet side data.\n"); -return err; -} - -for (i = 0; i < au->nb_units; i++) { -if (au->units[i].type == H264_NAL_SPS) { -err = h264_metadata_update_sps(bsf, au->units[i].content); -if (err < 0) -return err; -} -} - -err = ff_cbs_write_fragment_data(ctx->output, au); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to write extradata into packet side data.\n"); -return err; -} - -side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, au->data_size); -if (!side_data) -return AVERROR(ENOMEM); -memcpy(side_data, au->data, au->data_size); - -ff_cbs_fragment_reset(au); - -return 0; -} - static int h264_metadata_handle_display_orientation(AVBSFContext *bsf, AVPacket *pkt, CodedBitstreamFragment *au, @@ -386,7 +332,7 @@ static int h264_metadata_handle_display_orientation(AVBSFContext *bsf, int err; message = NULL; -while (ff_cbs_sei_find_message(ctx->output, au, +while (ff_cbs_sei_find_message(ctx->common.output, au, SEI_TYPE_DISPLAY_ORIENTATION, &message) == 0) { H264RawSEIDisplayOrientation *disp = message->payload; @@ -415,13 +361,13 @@ static int h264_metadata_handle_display_orientation(AVBSFContext *bsf, } } -if (ctx->display_orientation == REMOVE || -ctx->display_orientation == INSERT) { -ff_cbs_sei_delete_message_type(ctx->output, au, +if (ctx->display_orientation == BSF_ELEMENT_REMOVE || +ctx->display_orientation == BSF_ELEMENT_INSERT) { +ff_cbs_sei_delete_message_type(ctx->common.output, au, SEI_TYPE_DISPLAY_ORIENTATION); } -if (ctx->display_orientation == INSERT) { +if (ctx->display_orientation == BSF_ELEMENT_INSERT) { H264RawSEIDisplayOrientation *disp = &ctx->display_orientation_payload; uint8_t *data; @@ -495,7 +441,7 @@ static int h264_metadata_handle_display_orientation(AVBSFContext *bsf, if (write) { disp->display_orientation_repetition_period = 1; -err = ff_cbs_sei_add_message(ctx->output, au, 1, +err = ff_cbs_sei_add_message(ctx->common.output, au, 1, SEI_TYPE_DISPLAY_ORIENTATION, disp, NULL); if (err < 0) { @@ -509,41 +455,21 @@ static int h264_metadata_handle_display_orientation(AVBSFContext *bsf, return 0; } -static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) +static int h264_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt, + CodedBitstreamFragment *au) { H264MetadataContext *ctx = bsf->priv_data; -CodedBitstreamFragment *au = &ctx->access_unit; int err, i, has_sps, seek_point; -
[FFmpeg-cvslog] h265_metadata_bsf: Use common cbs bsf implementation
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:19 2021 +| [b95f901c7ff5758a31df4d897cc82613b3caf99d] | committer: Mark Thompson h265_metadata_bsf: Use common cbs bsf implementation > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b95f901c7ff5758a31df4d897cc82613b3caf99d --- libavcodec/h265_metadata_bsf.c | 191 + 1 file changed, 22 insertions(+), 169 deletions(-) diff --git a/libavcodec/h265_metadata_bsf.c b/libavcodec/h265_metadata_bsf.c index 504a75dac2..59325c0471 100644 --- a/libavcodec/h265_metadata_bsf.c +++ b/libavcodec/h265_metadata_bsf.c @@ -20,29 +20,19 @@ #include "libavutil/opt.h" #include "bsf.h" -#include "bsf_internal.h" #include "cbs.h" +#include "cbs_bsf.h" #include "cbs_h265.h" #include "hevc.h" #include "h265_profile_level.h" -enum { -PASS, -INSERT, -REMOVE, -}; - enum { LEVEL_UNSET = -2, LEVEL_AUTO = -1, }; typedef struct H265MetadataContext { -const AVClass *class; - -CodedBitstreamContext *input; -CodedBitstreamContext *output; -CodedBitstreamFragment access_unit; +CBSBSFContext common; H265RawAUD aud_nal; @@ -338,89 +328,18 @@ static int h265_metadata_update_sps(AVBSFContext *bsf, return 0; } -static int h265_metadata_update_side_data(AVBSFContext *bsf, AVPacket *pkt) -{ -H265MetadataContext *ctx = bsf->priv_data; -CodedBitstreamFragment *au = &ctx->access_unit; -uint8_t *side_data; -int side_data_size; -int err, i; - -side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, -&side_data_size); -if (!side_data_size) -return 0; - -err = ff_cbs_read(ctx->input, au, side_data, side_data_size); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to read extradata from packet side data.\n"); -return err; -} - -if (ctx->level == LEVEL_AUTO && !ctx->level_guess) -h265_metadata_guess_level(bsf, au); - -for (i = 0; i < au->nb_units; i++) { -if (au->units[i].type == HEVC_NAL_VPS) { -err = h265_metadata_update_vps(bsf, au->units[i].content); -if (err < 0) -return err; -} -if (au->units[i].type == HEVC_NAL_SPS) { -err = h265_metadata_update_sps(bsf, au->units[i].content); -if (err < 0) -return err; -} -} - -err = ff_cbs_write_fragment_data(ctx->output, au); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to write extradata into packet side data.\n"); -return err; -} - -side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, au->data_size); -if (!side_data) -return AVERROR(ENOMEM); -memcpy(side_data, au->data, au->data_size); - -ff_cbs_fragment_reset(au); - -return 0; -} - -static int h265_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) +static int h265_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt, + CodedBitstreamFragment *au) { H265MetadataContext *ctx = bsf->priv_data; -CodedBitstreamFragment *au = &ctx->access_unit; int err, i; -err = ff_bsf_get_packet_ref(bsf, pkt); -if (err < 0) -return err; - -err = h265_metadata_update_side_data(bsf, pkt); -if (err < 0) -goto fail; - -err = ff_cbs_read_packet(ctx->input, au, pkt); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n"); -goto fail; -} - -if (au->nb_units == 0) { -av_log(bsf, AV_LOG_ERROR, "No NAL units in packet.\n"); -err = AVERROR_INVALIDDATA; -goto fail; -} - // If an AUD is present, it must be the first NAL unit. if (au->units[0].type == HEVC_NAL_AUD) { -if (ctx->aud == REMOVE) +if (ctx->aud == BSF_ELEMENT_REMOVE) ff_cbs_delete_unit(au, 0); } else { -if (ctx->aud == INSERT) { +if (pkt && ctx->aud == BSF_ELEMENT_INSERT) { H265RawAUD *aud = &ctx->aud_nal; int pic_type = 0, temporal_id = 8, layer_id = 0; @@ -453,7 +372,7 @@ static int h265_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) err = ff_cbs_insert_unit_content(au, 0, HEVC_NAL_AUD, aud, NULL); if (err < 0) { av_log(bsf, AV_LOG_ERROR, "Failed to insert AUD.\n"); -goto fail; +return err; } } } @@ -465,101 +384,35 @@ static int h265_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) if (au->units[i].type == HEVC_NAL_VPS) { err = h265_metadata_update_vps(bsf, au->units[i].content); if (err < 0) -goto fail; +return err; } if (au->units[i].type == HEVC_NAL_SPS) { err = h265_metadata_update_sps(bsf, au->units[i].content); if (err < 0) -g
[FFmpeg-cvslog] vp9_metadata_bsf: Use common cbs bsf implementation
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:21 2021 +| [e46aa5a894f8b3dcf44a4028af726a5882ed27df] | committer: Mark Thompson vp9_metadata_bsf: Use common cbs bsf implementation > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e46aa5a894f8b3dcf44a4028af726a5882ed27df --- libavcodec/vp9_metadata_bsf.c | 61 --- 1 file changed, 16 insertions(+), 45 deletions(-) diff --git a/libavcodec/vp9_metadata_bsf.c b/libavcodec/vp9_metadata_bsf.c index 00a5580c4d..d904a0088d 100644 --- a/libavcodec/vp9_metadata_bsf.c +++ b/libavcodec/vp9_metadata_bsf.c @@ -21,15 +21,12 @@ #include "libavutil/opt.h" #include "bsf.h" -#include "bsf_internal.h" #include "cbs.h" +#include "cbs_bsf.h" #include "cbs_vp9.h" typedef struct VP9MetadataContext { -const AVClass *class; - -CodedBitstreamContext *cbc; -CodedBitstreamFragment fragment; +CBSBSFContext common; int color_space; int color_range; @@ -38,21 +35,11 @@ typedef struct VP9MetadataContext { } VP9MetadataContext; -static int vp9_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) +static int vp9_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt, +CodedBitstreamFragment *frag) { VP9MetadataContext *ctx = bsf->priv_data; -CodedBitstreamFragment *frag = &ctx->fragment; -int err, i; - -err = ff_bsf_get_packet_ref(bsf, pkt); -if (err < 0) -return err; - -err = ff_cbs_read_packet(ctx->cbc, frag, pkt); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n"); -goto fail; -} +int i; for (i = 0; i < frag->nb_units; i++) { VP9RawFrame *frame = frag->units[i].content; @@ -90,35 +77,19 @@ static int vp9_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) } } -err = ff_cbs_write_packet(ctx->cbc, pkt, frag); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n"); -goto fail; -} - -err = 0; -fail: -ff_cbs_fragment_reset(frag); - -if (err < 0) -av_packet_unref(pkt); - -return err; +return 0; } -static int vp9_metadata_init(AVBSFContext *bsf) -{ -VP9MetadataContext *ctx = bsf->priv_data; - -return ff_cbs_init(&ctx->cbc, AV_CODEC_ID_VP9, bsf); -} +static const CBSBSFType vp9_metadata_type = { +.codec_id= AV_CODEC_ID_VP9, +.fragment_name = "superframe", +.unit_name = "frame", +.update_fragment = &vp9_metadata_update_fragment, +}; -static void vp9_metadata_close(AVBSFContext *bsf) +static int vp9_metadata_init(AVBSFContext *bsf) { -VP9MetadataContext *ctx = bsf->priv_data; - -ff_cbs_fragment_free(&ctx->fragment); -ff_cbs_close(&ctx->cbc); +return ff_cbs_bsf_generic_init(bsf, &vp9_metadata_type); } #define OFFSET(x) offsetof(VP9MetadataContext, x) @@ -169,7 +140,7 @@ const AVBitStreamFilter ff_vp9_metadata_bsf = { .priv_data_size = sizeof(VP9MetadataContext), .priv_class = &vp9_metadata_class, .init = &vp9_metadata_init, -.close = &vp9_metadata_close, -.filter = &vp9_metadata_filter, +.close = &ff_cbs_bsf_generic_close, +.filter = &ff_cbs_bsf_generic_filter, .codec_ids = vp9_metadata_codec_ids, }; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] av1_metadata_bsf: Use common cbs bsf implementation
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:22 2021 +| [375176a540121959a2dd37e910934e77c71eb78a] | committer: Mark Thompson av1_metadata_bsf: Use common cbs bsf implementation > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=375176a540121959a2dd37e910934e77c71eb78a --- libavcodec/av1_metadata_bsf.c | 176 +- 1 file changed, 21 insertions(+), 155 deletions(-) diff --git a/libavcodec/av1_metadata_bsf.c b/libavcodec/av1_metadata_bsf.c index 3158ba995b..8cafe461d1 100644 --- a/libavcodec/av1_metadata_bsf.c +++ b/libavcodec/av1_metadata_bsf.c @@ -20,22 +20,12 @@ #include "libavutil/opt.h" #include "bsf.h" -#include "bsf_internal.h" #include "cbs.h" +#include "cbs_bsf.h" #include "cbs_av1.h" -enum { -PASS, -INSERT, -REMOVE, -}; - typedef struct AV1MetadataContext { -const AVClass *class; - -CodedBitstreamContext *input; -CodedBitstreamContext *output; -CodedBitstreamFragment access_unit; +CBSBSFContext common; int td; @@ -113,91 +103,27 @@ static int av1_metadata_update_sequence_header(AVBSFContext *bsf, return 0; } -static int av1_metadata_update_side_data(AVBSFContext *bsf, AVPacket *pkt) +static int av1_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt, +CodedBitstreamFragment *frag) { AV1MetadataContext *ctx = bsf->priv_data; -CodedBitstreamFragment *frag = &ctx->access_unit; -uint8_t *side_data; -int side_data_size; -int err, i; - -side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, -&side_data_size); -if (!side_data_size) -return 0; - -err = ff_cbs_read(ctx->input, frag, side_data, side_data_size); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to read extradata from packet side data.\n"); -return err; -} - -for (i = 0; i < frag->nb_units; i++) { -if (frag->units[i].type == AV1_OBU_SEQUENCE_HEADER) { -AV1RawOBU *obu = frag->units[i].content; -err = av1_metadata_update_sequence_header(bsf, &obu->obu.sequence_header); -if (err < 0) -return err; -} -} - -err = ff_cbs_write_fragment_data(ctx->output, frag); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to write extradata into packet side data.\n"); -return err; -} - -side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, frag->data_size); -if (!side_data) -return AVERROR(ENOMEM); -memcpy(side_data, frag->data, frag->data_size); - -ff_cbs_fragment_reset(frag); - -return 0; -} - -static int av1_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) -{ -AV1MetadataContext *ctx = bsf->priv_data; -CodedBitstreamFragment *frag = &ctx->access_unit; AV1RawOBU td, *obu; int err, i; -err = ff_bsf_get_packet_ref(bsf, pkt); -if (err < 0) -return err; - -err = av1_metadata_update_side_data(bsf, pkt); -if (err < 0) -goto fail; - -err = ff_cbs_read_packet(ctx->input, frag, pkt); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n"); -goto fail; -} - -if (frag->nb_units == 0) { -av_log(bsf, AV_LOG_ERROR, "No OBU in packet.\n"); -err = AVERROR_INVALIDDATA; -goto fail; -} - for (i = 0; i < frag->nb_units; i++) { if (frag->units[i].type == AV1_OBU_SEQUENCE_HEADER) { obu = frag->units[i].content; err = av1_metadata_update_sequence_header(bsf, &obu->obu.sequence_header); if (err < 0) -goto fail; +return err; } } // If a Temporal Delimiter is present, it must be the first OBU. if (frag->units[0].type == AV1_OBU_TEMPORAL_DELIMITER) { -if (ctx->td == REMOVE) +if (ctx->td == BSF_ELEMENT_REMOVE) ff_cbs_delete_unit(frag, 0); -} else if (ctx->td == INSERT) { +} else if (pkt && ctx->td == BSF_ELEMENT_INSERT) { td = (AV1RawOBU) { .header.obu_type = AV1_OBU_TEMPORAL_DELIMITER, }; @@ -206,7 +132,7 @@ static int av1_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) &td, NULL); if (err < 0) { av_log(bsf, AV_LOG_ERROR, "Failed to insert Temporal Delimiter.\n"); -goto fail; +return err; } } @@ -217,86 +143,26 @@ static int av1_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) } } -err = ff_cbs_write_packet(ctx->output, pkt, frag); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n"); -goto fail; -} - -err = 0; -fail: -ff_cbs_fragment_reset(frag); - -if (err < 0) -av_packet_unref(pkt); - -return err; +return 0; } -static int av1_metadata_init(A
[FFmpeg-cvslog] h264_redundant_pps_bsf: Use common cbs bsf implementation
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:23 2021 +| [fa75e438756f159a667080dcba58ea2e3b190001] | committer: Mark Thompson h264_redundant_pps_bsf: Use common cbs bsf implementation > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fa75e438756f159a667080dcba58ea2e3b190001 --- libavcodec/h264_redundant_pps_bsf.c | 99 - 1 file changed, 21 insertions(+), 78 deletions(-) diff --git a/libavcodec/h264_redundant_pps_bsf.c b/libavcodec/h264_redundant_pps_bsf.c index cf41abe96c..6ba40291d5 100644 --- a/libavcodec/h264_redundant_pps_bsf.c +++ b/libavcodec/h264_redundant_pps_bsf.c @@ -24,15 +24,13 @@ #include "bsf.h" #include "bsf_internal.h" #include "cbs.h" +#include "cbs_bsf.h" #include "cbs_h264.h" #include "h264.h" typedef struct H264RedundantPPSContext { -CodedBitstreamContext *input; -CodedBitstreamContext *output; - -CodedBitstreamFragment access_unit; +CBSBSFContext common; int global_pic_init_qp; int current_pic_init_qp; @@ -49,7 +47,7 @@ static int h264_redundant_pps_fixup_pps(H264RedundantPPSContext *ctx, // The changes we are about to perform affect the parsing process, // so we must make sure that the PPS is writable, otherwise the // parsing of future slices will be incorrect and even raise errors. -err = ff_cbs_make_unit_writable(ctx->input, unit); +err = ff_cbs_make_unit_writable(ctx->common.input, unit); if (err < 0) return err; pps = unit->content; @@ -78,21 +76,14 @@ static int h264_redundant_pps_fixup_slice(H264RedundantPPSContext *ctx, return 0; } -static int h264_redundant_pps_filter(AVBSFContext *bsf, AVPacket *pkt) +static int h264_redundant_pps_update_fragment(AVBSFContext *bsf, + AVPacket *pkt, + CodedBitstreamFragment *au) { H264RedundantPPSContext *ctx = bsf->priv_data; -CodedBitstreamFragment *au = &ctx->access_unit; int au_has_sps; int err, i; -err = ff_bsf_get_packet_ref(bsf, pkt); -if (err < 0) -return err; - -err = ff_cbs_read_packet(ctx->input, au, pkt); -if (err < 0) -goto fail; - au_has_sps = 0; for (i = 0; i < au->nb_units; i++) { CodedBitstreamUnit *nal = &au->units[i]; @@ -102,7 +93,7 @@ static int h264_redundant_pps_filter(AVBSFContext *bsf, AVPacket *pkt) if (nal->type == H264_NAL_PPS) { err = h264_redundant_pps_fixup_pps(ctx, nal); if (err < 0) -goto fail; +return err; if (!au_has_sps) { av_log(bsf, AV_LOG_VERBOSE, "Deleting redundant PPS " "at %"PRId64".\n", pkt->pts); @@ -118,62 +109,7 @@ static int h264_redundant_pps_filter(AVBSFContext *bsf, AVPacket *pkt) } } -err = ff_cbs_write_packet(ctx->output, pkt, au); -if (err < 0) -goto fail; - -err = 0; -fail: -ff_cbs_fragment_reset(au); -if (err < 0) -av_packet_unref(pkt); - -return err; -} - -static int h264_redundant_pps_init(AVBSFContext *bsf) -{ -H264RedundantPPSContext *ctx = bsf->priv_data; -CodedBitstreamFragment *au = &ctx->access_unit; -int err, i; - -err = ff_cbs_init(&ctx->input, AV_CODEC_ID_H264, bsf); -if (err < 0) -return err; - -err = ff_cbs_init(&ctx->output, AV_CODEC_ID_H264, bsf); -if (err < 0) -return err; - -ctx->global_pic_init_qp = 26; - -if (bsf->par_in->extradata) { -err = ff_cbs_read_extradata(ctx->input, au, bsf->par_in); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to read extradata.\n"); -goto fail; -} - -for (i = 0; i < au->nb_units; i++) { -if (au->units[i].type == H264_NAL_PPS) { -err = h264_redundant_pps_fixup_pps(ctx, &au->units[i]); -if (err < 0) -goto fail; -} -} - -ctx->extradata_pic_init_qp = ctx->current_pic_init_qp; -err = ff_cbs_write_extradata(ctx->output, bsf->par_out, au); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to write extradata.\n"); -goto fail; -} -} - -err = 0; -fail: -ff_cbs_fragment_reset(au); -return err; +return 0; } static void h264_redundant_pps_flush(AVBSFContext *bsf) @@ -182,13 +118,20 @@ static void h264_redundant_pps_flush(AVBSFContext *bsf) ctx->current_pic_init_qp = ctx->extradata_pic_init_qp; } -static void h264_redundant_pps_close(AVBSFContext *bsf) +static const CBSBSFType h264_redundant_pps_type = { +.codec_id= AV_CODEC_ID_H264, +.fragment_name = "access unit", +.unit_name = "NAL unit", +.update_fragment = &h264_redundant_pps_update_fragment, +}; + +static int h264_redundant_pps_init(AVBSFContext *bsf) { H264RedundantPPSContext *ctx = b
[FFmpeg-cvslog] mpeg2_metadata_bsf: Use common cbs bsf implementation
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:20 2021 +| [f35b2683275aeea8c4967877267d7376d3741a42] | committer: Mark Thompson mpeg2_metadata_bsf: Use common cbs bsf implementation This also adds support for updating new extradata. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f35b2683275aeea8c4967877267d7376d3741a42 --- libavcodec/mpeg2_metadata_bsf.c | 94 ++--- 1 file changed, 12 insertions(+), 82 deletions(-) diff --git a/libavcodec/mpeg2_metadata_bsf.c b/libavcodec/mpeg2_metadata_bsf.c index d0048c0e25..11b46c0ae3 100644 --- a/libavcodec/mpeg2_metadata_bsf.c +++ b/libavcodec/mpeg2_metadata_bsf.c @@ -21,16 +21,13 @@ #include "libavutil/opt.h" #include "bsf.h" -#include "bsf_internal.h" #include "cbs.h" +#include "cbs_bsf.h" #include "cbs_mpeg2.h" #include "mpeg12.h" typedef struct MPEG2MetadataContext { -const AVClass *class; - -CodedBitstreamContext *cbc; -CodedBitstreamFragment fragment; +CBSBSFContext common; MPEG2RawExtensionData sequence_display_extension; @@ -48,6 +45,7 @@ typedef struct MPEG2MetadataContext { static int mpeg2_metadata_update_fragment(AVBSFContext *bsf, + AVPacket *pkt, CodedBitstreamFragment *frag) { MPEG2MetadataContext *ctx = bsf->priv_data; @@ -170,49 +168,16 @@ static int mpeg2_metadata_update_fragment(AVBSFContext *bsf, return 0; } -static int mpeg2_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) -{ -MPEG2MetadataContext *ctx = bsf->priv_data; -CodedBitstreamFragment *frag = &ctx->fragment; -int err; - -err = ff_bsf_get_packet_ref(bsf, pkt); -if (err < 0) -return err; - -err = ff_cbs_read_packet(ctx->cbc, frag, pkt); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n"); -goto fail; -} - -err = mpeg2_metadata_update_fragment(bsf, frag); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to update frame fragment.\n"); -goto fail; -} - -err = ff_cbs_write_packet(ctx->cbc, pkt, frag); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n"); -goto fail; -} - -err = 0; -fail: -ff_cbs_fragment_reset(frag); - -if (err < 0) -av_packet_unref(pkt); - -return err; -} +static const CBSBSFType mpeg2_metadata_type = { +.codec_id= AV_CODEC_ID_MPEG2VIDEO, +.fragment_name = "frame", +.unit_name = "start code", +.update_fragment = &mpeg2_metadata_update_fragment, +}; static int mpeg2_metadata_init(AVBSFContext *bsf) { MPEG2MetadataContext *ctx = bsf->priv_data; -CodedBitstreamFragment *frag = &ctx->fragment; -int err; #define VALIDITY_CHECK(name) do { \ if (!ctx->name) { \ @@ -226,42 +191,7 @@ static int mpeg2_metadata_init(AVBSFContext *bsf) VALIDITY_CHECK(matrix_coefficients); #undef VALIDITY_CHECK -err = ff_cbs_init(&ctx->cbc, AV_CODEC_ID_MPEG2VIDEO, bsf); -if (err < 0) -return err; - -if (bsf->par_in->extradata) { -err = ff_cbs_read_extradata(ctx->cbc, frag, bsf->par_in); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to read extradata.\n"); -goto fail; -} - -err = mpeg2_metadata_update_fragment(bsf, frag); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to update metadata fragment.\n"); -goto fail; -} - -err = ff_cbs_write_extradata(ctx->cbc, bsf->par_out, frag); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to write extradata.\n"); -goto fail; -} -} - -err = 0; -fail: -ff_cbs_fragment_reset(frag); -return err; -} - -static void mpeg2_metadata_close(AVBSFContext *bsf) -{ -MPEG2MetadataContext *ctx = bsf->priv_data; - -ff_cbs_fragment_free(&ctx->fragment); -ff_cbs_close(&ctx->cbc); +return ff_cbs_bsf_generic_init(bsf, &mpeg2_metadata_type); } #define OFFSET(x) offsetof(MPEG2MetadataContext, x) @@ -307,7 +237,7 @@ const AVBitStreamFilter ff_mpeg2_metadata_bsf = { .priv_data_size = sizeof(MPEG2MetadataContext), .priv_class = &mpeg2_metadata_class, .init = &mpeg2_metadata_init, -.close = &mpeg2_metadata_close, -.filter = &mpeg2_metadata_filter, +.close = &ff_cbs_bsf_generic_close, +.filter = &ff_cbs_bsf_generic_filter, .codec_ids = mpeg2_metadata_codec_ids, }; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/Makefile: Remove unnecessary cbrt_data dependency
ffmpeg | branch: master | Andreas Rheinhardt | Thu Jan 7 00:34:13 2021 +0100| [9e74f324d8096c317419b42081b8288a6bc9ae60] | committer: Andreas Rheinhardt avcodec/Makefile: Remove unnecessary cbrt_data dependency Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9e74f324d8096c317419b42081b8288a6bc9ae60 --- libavcodec/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 6c1e7a1c7a..9ef6d98286 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -173,7 +173,7 @@ OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o aacenctab.o\ aacenc_tns.o \ aacenc_ltp.o \ aacenc_pred.o \ - psymodel.o mpeg4audio.o kbdwin.o cbrt_data.o + psymodel.o mpeg4audio.o kbdwin.o OBJS-$(CONFIG_AAC_MF_ENCODER) += mfenc.o mf_utils.o OBJS-$(CONFIG_AASC_DECODER)+= aasc.o msrledec.o OBJS-$(CONFIG_AC3_DECODER) += ac3dec_float.o ac3dec_data.o ac3.o kbdwin.o ac3tab.o ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/Makefile: Remove FLAC dependencies on vorbis_data
ffmpeg | branch: master | Andreas Rheinhardt | Thu Jan 7 02:00:26 2021 +0100| [d64828c8afe496c0fdb42499309b59ac175b7971] | committer: Andreas Rheinhardt avcodec/Makefile: Remove FLAC dependencies on vorbis_data 2ef2496cd19eb833f4ad22a5051c11be80d09598 used ff_vorbis_channel_layouts in flac.c, but added a dependency to the FLAC decoder only; lateron aba0278e9fe8e66c078588efe66f6af4db432770 added the dependency of the FLAC parser and encoder on vorbis_data.o. Yet when the original commit was reverted in aba0278e9fe8e66c078588efe66f6af4db432770, the two other dependencies were not removed. This commit fixes this. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d64828c8afe496c0fdb42499309b59ac175b7971 --- libavcodec/Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index d94a87003f..c7de95fd18 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -329,7 +329,7 @@ OBJS-$(CONFIG_FIC_DECODER) += fic.o OBJS-$(CONFIG_FITS_DECODER)+= fitsdec.o fits.o OBJS-$(CONFIG_FITS_ENCODER)+= fitsenc.o OBJS-$(CONFIG_FLAC_DECODER)+= flacdec.o flacdata.o flac.o -OBJS-$(CONFIG_FLAC_ENCODER)+= flacenc.o flacdata.o flac.o vorbis_data.o +OBJS-$(CONFIG_FLAC_ENCODER)+= flacenc.o flacdata.o flac.o OBJS-$(CONFIG_FLASHSV_DECODER) += flashsv.o OBJS-$(CONFIG_FLASHSV_ENCODER) += flashsvenc.o OBJS-$(CONFIG_FLASHSV2_ENCODER)+= flashsv2enc.o @@ -1089,8 +1089,7 @@ OBJS-$(CONFIG_DVAUDIO_PARSER) += dvaudio_parser.o OBJS-$(CONFIG_DVBSUB_PARSER) += dvbsub_parser.o OBJS-$(CONFIG_DVD_NAV_PARSER) += dvd_nav_parser.o OBJS-$(CONFIG_DVDSUB_PARSER) += dvdsub_parser.o -OBJS-$(CONFIG_FLAC_PARSER) += flac_parser.o flacdata.o flac.o \ - vorbis_data.o +OBJS-$(CONFIG_FLAC_PARSER) += flac_parser.o flacdata.o flac.o OBJS-$(CONFIG_G723_1_PARSER) += g723_1_parser.o OBJS-$(CONFIG_G729_PARSER) += g729_parser.o OBJS-$(CONFIG_GIF_PARSER) += gif_parser.o ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/Makefile: Remove dependency of H.263 on FLV codecs
ffmpeg | branch: master | Andreas Rheinhardt | Thu Jan 7 01:34:25 2021 +0100| [21b4b90475f61e4204d20c4f228c0c633d1b040a] | committer: Andreas Rheinhardt avcodec/Makefile: Remove dependency of H.263 on FLV codecs Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=21b4b90475f61e4204d20c4f228c0c633d1b040a --- libavcodec/Makefile | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 9ef6d98286..d94a87003f 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -335,6 +335,8 @@ OBJS-$(CONFIG_FLASHSV_ENCODER) += flashsvenc.o OBJS-$(CONFIG_FLASHSV2_ENCODER)+= flashsv2enc.o OBJS-$(CONFIG_FLASHSV2_DECODER)+= flashsv.o OBJS-$(CONFIG_FLIC_DECODER)+= flicvideo.o +OBJS-$(CONFIG_FLV_DECODER) += flvdec.o +OBJS-$(CONFIG_FLV_ENCODER) += flvenc.o OBJS-$(CONFIG_FMVC_DECODER)+= fmvc.o OBJS-$(CONFIG_FOURXM_DECODER) += 4xm.o OBJS-$(CONFIG_FRAPS_DECODER) += fraps.o @@ -354,10 +356,10 @@ OBJS-$(CONFIG_GSM_MS_DECODER) += gsmdec.o gsmdec_data.o msgsmdec.o OBJS-$(CONFIG_H261_DECODER)+= h261dec.o h261data.o h261.o OBJS-$(CONFIG_H261_ENCODER)+= h261enc.o h261data.o h261.o OBJS-$(CONFIG_H263_DECODER)+= h263dec.o h263.o ituh263dec.o \ - mpeg4video.o mpeg4videodec.o flvdec.o\ + mpeg4video.o mpeg4videodec.o \ intelh263dec.o h263data.o OBJS-$(CONFIG_H263_ENCODER)+= mpeg4videoenc.o mpeg4video.o \ - h263.o ituh263enc.o flvenc.o h263data.o + h263.o ituh263enc.o h263data.o OBJS-$(CONFIG_H263_V4L2M2M_DECODER)+= v4l2_m2m_dec.o OBJS-$(CONFIG_H263_V4L2M2M_ENCODER)+= v4l2_m2m_enc.o OBJS-$(CONFIG_H264_DECODER)+= h264dec.o h264_cabac.o h264_cavlc.o \ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/Makefile: Make H.263 decoder compilable without H.263I
ffmpeg | branch: master | Andreas Rheinhardt | Thu Jan 7 02:51:13 2021 +0100| [ab905f1dbc736630538ce61907e6ba691f759d04] | committer: Andreas Rheinhardt avcodec/Makefile: Make H.263 decoder compilable without H.263I The only call to ff_intel_h263_decode_picture_header() is already behind "if (CONFIG_H263I_DECODER)". Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ab905f1dbc736630538ce61907e6ba691f759d04 --- libavcodec/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index c7de95fd18..f5cb63cb85 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -357,7 +357,8 @@ OBJS-$(CONFIG_H261_DECODER)+= h261dec.o h261data.o h261.o OBJS-$(CONFIG_H261_ENCODER)+= h261enc.o h261data.o h261.o OBJS-$(CONFIG_H263_DECODER)+= h263dec.o h263.o ituh263dec.o \ mpeg4video.o mpeg4videodec.o \ - intelh263dec.o h263data.o + h263data.o +OBJS-$(CONFIG_H263I_DECODER) += intelh263dec.o OBJS-$(CONFIG_H263_ENCODER)+= mpeg4videoenc.o mpeg4video.o \ h263.o ituh263enc.o h263data.o OBJS-$(CONFIG_H263_V4L2M2M_DECODER)+= v4l2_m2m_dec.o ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/Makefile: Make H.263 encoder compilable without MPEG4 encoder
ffmpeg | branch: master | Andreas Rheinhardt | Fri Jan 8 04:07:19 2021 +0100| [aff923c0b52d5e38ea3201c34451b918dd92285d] | committer: Andreas Rheinhardt avcodec/Makefile: Make H.263 encoder compilable without MPEG4 encoder Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aff923c0b52d5e38ea3201c34451b918dd92285d --- libavcodec/Makefile| 3 ++- libavcodec/mpeg4videoenc.c | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index f5cb63cb85..5ce3ee0ec9 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -359,7 +359,7 @@ OBJS-$(CONFIG_H263_DECODER)+= h263dec.o h263.o ituh263dec.o\ mpeg4video.o mpeg4videodec.o \ h263data.o OBJS-$(CONFIG_H263I_DECODER) += intelh263dec.o -OBJS-$(CONFIG_H263_ENCODER)+= mpeg4videoenc.o mpeg4video.o \ +OBJS-$(CONFIG_H263_ENCODER)+= mpeg4video.o \ h263.o ituh263enc.o h263data.o OBJS-$(CONFIG_H263_V4L2M2M_DECODER)+= v4l2_m2m_dec.o OBJS-$(CONFIG_H263_V4L2M2M_ENCODER)+= v4l2_m2m_enc.o @@ -497,6 +497,7 @@ OBJS-$(CONFIG_MPEG2_MEDIACODEC_DECODER) += mediacodecdec.o OBJS-$(CONFIG_MPEG2_VAAPI_ENCODER) += vaapi_encode_mpeg2.o OBJS-$(CONFIG_MPEG2_V4L2M2M_DECODER) += v4l2_m2m_dec.o OBJS-$(CONFIG_MPEG4_DECODER) += xvididct.o +OBJS-$(CONFIG_MPEG4_ENCODER) += mpeg4videoenc.o OBJS-$(CONFIG_MPEG4_CUVID_DECODER) += cuviddec.o OBJS-$(CONFIG_MPEG4_MEDIACODEC_DECODER) += mediacodecdec.o OBJS-$(CONFIG_MPEG4_OMX_ENCODER) += omx.o diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index b3fa910c64..a092ab01d0 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -961,9 +961,6 @@ static void mpeg4_encode_vol_header(MpegEncContext *s, { int vo_ver_id; -if (!CONFIG_MPEG4_ENCODER) -return; - if (s->max_b_frames || s->quarter_sample) { vo_ver_id = 5; s->vo_type = ADV_SIMPLE_VO_TYPE; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mpeg12dec: Remove redundant writes
ffmpeg | branch: master | Andreas Rheinhardt | Wed Dec 9 03:30:00 2020 +0100| [1f9ef2f3cf0812c9ad3e3055946673375c982cac] | committer: Andreas Rheinhardt avcodec/mpeg12dec: Remove redundant writes ff_mpv_decode_init() already sets MpegEncContext.avctx. Reviewed-by: Anton Khirnov Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1f9ef2f3cf0812c9ad3e3055946673375c982cac --- libavcodec/mpeg12dec.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 3330967f64..92dd6a0b24 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -1057,8 +1057,6 @@ static av_cold int mpeg_decode_init(AVCodecContext *avctx) avctx->coded_width = avctx->coded_height = 0; // do not trust dimensions from input ff_mpv_decode_init(s2, avctx); -s->mpeg_enc_ctx.avctx = avctx; - /* we need some permutation to store matrices, * until the decoder sets the real permutation. */ ff_mpv_idct_init(s2); @@ -3100,7 +3098,6 @@ static av_cold int ipu_decode_init(AVCodecContext *avctx) avctx->pix_fmt = AV_PIX_FMT_YUV420P; ff_mpv_decode_init(m, avctx); -s->m.avctx = avctx; ff_mpv_idct_init(m); ff_mpeg12_common_init(m); ff_mpeg12_init_vlcs(); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/me_cmp: Remove ff_check_alignment()
ffmpeg | branch: master | Andreas Rheinhardt | Wed Dec 2 00:20:04 2020 +0100| [b3473841731eebf5c32077f931334820316f16c6] | committer: Andreas Rheinhardt avcodec/me_cmp: Remove ff_check_alignment() The usage of a static variable presents a potential for data races and means that this function can't be used in init functions of codecs with FF_CODEC_CAP_INIT_THREADSAFE (unless of course one presumes that everything is alright in which case the error is not triggered; but then the whole function is pointless...). This makes the Snow decoder init-threadsafe as it already claims. Notice that this function has been removed in 2014 by Libav in commit 9103185bd116930f90b847090e66a64fa9971ce2, because only some codepaths are checked this way and because it only affects legacy compilers. The latter is of course even more true today. Reviewed-by: Anton Khirnov Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b3473841731eebf5c32077f931334820316f16c6 --- libavcodec/me_cmp.c| 23 --- libavcodec/me_cmp.h| 2 -- libavcodec/mpegvideo_enc.c | 6 -- 3 files changed, 31 deletions(-) diff --git a/libavcodec/me_cmp.c b/libavcodec/me_cmp.c index ba72468240..60545248b3 100644 --- a/libavcodec/me_cmp.c +++ b/libavcodec/me_cmp.c @@ -1012,31 +1012,8 @@ WRAPPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c) WRAPPER8_16_SQ(rd8x8_c, rd16_c) WRAPPER8_16_SQ(bit8x8_c, bit16_c) -int ff_check_alignment(void) -{ -static int did_fail = 0; -LOCAL_ALIGNED_16(int, aligned, [4]); - -if ((intptr_t)aligned & 15) { -if (!did_fail) { -#if HAVE_MMX || HAVE_ALTIVEC -av_log(NULL, AV_LOG_ERROR, -"Compiler did not align stack variables. Libavcodec has been miscompiled\n" -"and may be very slow or crash. This is not a bug in libavcodec,\n" -"but in the compiler. You may try recompiling using gcc >= 4.2.\n" -"Do not report crashes to FFmpeg developers.\n"); -#endif -did_fail=1; -} -return -1; -} -return 0; -} - av_cold void ff_me_cmp_init(MECmpContext *c, AVCodecContext *avctx) { -ff_check_alignment(); - c->sum_abs_dctelem = sum_abs_dctelem_c; /* TODO [0] 16 [1] 8 */ diff --git a/libavcodec/me_cmp.h b/libavcodec/me_cmp.h index 0a589e3c3d..e9b5161c9a 100644 --- a/libavcodec/me_cmp.h +++ b/libavcodec/me_cmp.h @@ -79,8 +79,6 @@ typedef struct MECmpContext { me_cmp_func median_sad[6]; } MECmpContext; -int ff_check_alignment(void); - void ff_me_cmp_init(MECmpContext *c, AVCodecContext *avctx); void ff_me_cmp_init_alpha(MECmpContext *c, AVCodecContext *avctx); void ff_me_cmp_init_arm(MECmpContext *c, AVCodecContext *avctx); diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 25d9004199..7db042e5fe 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -2786,8 +2786,6 @@ static int pre_estimate_motion_thread(AVCodecContext *c, void *arg){ static int estimate_motion_thread(AVCodecContext *c, void *arg){ MpegEncContext *s= *(void**)arg; -ff_check_alignment(); - s->me.dia_size= s->avctx->dia_size; s->first_slice_line=1; for(s->mb_y= s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) { @@ -2814,8 +2812,6 @@ static int mb_var_thread(AVCodecContext *c, void *arg){ MpegEncContext *s= *(void**)arg; int mb_x, mb_y; -ff_check_alignment(); - for(mb_y=s->start_mb_y; mb_y < s->end_mb_y; mb_y++) { for(mb_x=0; mb_x < s->mb_width; mb_x++) { int xx = mb_x * 16; @@ -2944,8 +2940,6 @@ static int encode_thread(AVCodecContext *c, void *arg){ uint8_t bit_buf_tex[2][MAX_MB_BYTES]; PutBitContext pb[2], pb2[2], tex_pb[2]; -ff_check_alignment(); - for(i=0; i<2; i++){ init_put_bits(&pb[i], bit_buf[i], MAX_MB_BYTES); init_put_bits(&pb2 [i], bit_buf2 [i], MAX_MB_BYTES); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/paf: Do not zero allocated tables which are immedeately filled
ffmpeg | branch: master | Michael Niedermayer | Wed Jan 20 00:32:22 2021 +0100| [631ee3f8e43f95abb4af9d4c83f844ce23f25f26] | committer: Michael Niedermayer avformat/paf: Do not zero allocated tables which are immedeately filled Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=631ee3f8e43f95abb4af9d4c83f844ce23f25f26 --- libavformat/paf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/paf.c b/libavformat/paf.c index 9587111643..6183dc1115 100644 --- a/libavformat/paf.c +++ b/libavformat/paf.c @@ -149,11 +149,11 @@ static int read_header(AVFormatContext *s) p->frame_blks > INT_MAX / sizeof(uint32_t)) return AVERROR_INVALIDDATA; -p->blocks_count_table = av_mallocz(p->nb_frames * +p->blocks_count_table = av_malloc_array(p->nb_frames, sizeof(*p->blocks_count_table)); -p->frames_offset_table = av_mallocz(p->nb_frames * +p->frames_offset_table = av_malloc_array(p->nb_frames, sizeof(*p->frames_offset_table)); -p->blocks_offset_table = av_mallocz(p->frame_blks * +p->blocks_offset_table = av_malloc_array(p->frame_blks, sizeof(*p->blocks_offset_table)); p->video_size = p->max_video_blks * p->buffer_size; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/nistspheredec: Check bits_per_coded_sample and channels
ffmpeg | branch: master | Michael Niedermayer | Sun Jan 17 00:07:26 2021 +0100| [60770a50fba0d47203d417b048b37d314918085d] | committer: Michael Niedermayer avformat/nistspheredec: Check bits_per_coded_sample and channels Fixes: signed integer overflow: 80 * 92233009 cannot be represented in type 'int' Fixes: 26910/clusterfuzz-testcase-minimized-ffmpeg_dem_NISTSPHERE_fuzzer-6669100654919680 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=60770a50fba0d47203d417b048b37d314918085d --- libavformat/nistspheredec.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavformat/nistspheredec.c b/libavformat/nistspheredec.c index 079369929f..78e938da10 100644 --- a/libavformat/nistspheredec.c +++ b/libavformat/nistspheredec.c @@ -90,6 +90,8 @@ static int nist_read_header(AVFormatContext *s) return 0; } else if (!memcmp(buffer, "channel_count", 13)) { sscanf(buffer, "%*s %*s %u", &st->codecpar->channels); +if (st->codecpar->channels <= 0 || st->codecpar->channels > INT16_MAX) +return AVERROR_INVALIDDATA; } else if (!memcmp(buffer, "sample_byte_format", 18)) { sscanf(buffer, "%*s %*s %31s", format); @@ -109,12 +111,14 @@ static int nist_read_header(AVFormatContext *s) sscanf(buffer, "%*s %*s %"SCNd64, &st->duration); } else if (!memcmp(buffer, "sample_n_bytes", 14)) { sscanf(buffer, "%*s %*s %d", &bps); -if (bps > INT_MAX/8U) +if (bps > INT16_MAX/8U) return AVERROR_INVALIDDATA; } else if (!memcmp(buffer, "sample_rate", 11)) { sscanf(buffer, "%*s %*s %d", &st->codecpar->sample_rate); } else if (!memcmp(buffer, "sample_sig_bits", 15)) { sscanf(buffer, "%*s %*s %d", &st->codecpar->bits_per_coded_sample); +if (st->codecpar->bits_per_coded_sample <= 0 || st->codecpar->bits_per_coded_sample > INT16_MAX) +return AVERROR_INVALIDDATA; } else { char key[32], value[32]; if (sscanf(buffer, "%31s %*s %31s", key, value) == 2) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/dhav: Break out of infinite dhav search loop
ffmpeg | branch: master | Michael Niedermayer | Mon Nov 9 20:42:56 2020 +0100| [7540d60bf687ae1f18927c5e6c3dbd317df9f35e] | committer: Michael Niedermayer avformat/dhav: Break out of infinite dhav search loop Fixes: Infinite loop Fixes: 26922/clusterfuzz-testcase-minimized-ffmpeg_dem_DHAV_fuzzer-5794549613723648 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7540d60bf687ae1f18927c5e6c3dbd317df9f35e --- libavformat/dhav.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/dhav.c b/libavformat/dhav.c index 6a6c235e65..526331ae4c 100644 --- a/libavformat/dhav.c +++ b/libavformat/dhav.c @@ -281,6 +281,8 @@ static int dhav_read_header(AVFormatContext *s) int seek_back; seek_back = avio_rl32(s->pb) + 8; +if (seek_back < 9) +break; dhav->last_good_pos = avio_tell(s->pb); avio_seek(s->pb, -seek_back, SEEK_CUR); } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] libavformat/utils: consider avio_size() failure in ffio_limit()
ffmpeg | branch: master | Michael Niedermayer | Mon Nov 9 19:58:20 2020 +0100| [1b1dac2716d713dfd6949b7eb4a3c18c16f1faf6] | committer: Michael Niedermayer libavformat/utils: consider avio_size() failure in ffio_limit() Fixes: Timeout (>20sec -> 3ms) Fixes: 26918/clusterfuzz-testcase-minimized-ffmpeg_dem_THP_fuzzer-5750425191710720 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1b1dac2716d713dfd6949b7eb4a3c18c16f1faf6 --- libavformat/utils.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 8ac6bc04b8..f534b6e5b5 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -244,13 +244,16 @@ int av_format_get_probe_score(const AVFormatContext *s) int ffio_limit(AVIOContext *s, int size) { if (s->maxsize>= 0) { -int64_t remaining= s->maxsize - avio_tell(s); +int64_t pos = avio_tell(s); +int64_t remaining= s->maxsize - pos; if (remaining < size) { int64_t newsize = avio_size(s); if (!s->maxsize || s->maxsizemaxsize = newsize - !newsize; -remaining= s->maxsize - avio_tell(s); -remaining= FFMAX(remaining, 0); +if (pos > s->maxsize && s->maxsize >= 0) +s->maxsize = AVERROR(EIO); +if (s->maxsize >= 0) +remaining = s->maxsize - pos; } if (s->maxsize >= 0 && remaining < size && size > 1) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/avidec: dv does not support palettes
ffmpeg | branch: master | Michael Niedermayer | Mon Nov 9 21:48:31 2020 +0100| [1b373b41d940e3058cdfb3d17703e23ed665353c] | committer: Michael Niedermayer avformat/avidec: dv does not support palettes Fixes: memleak Fixes: 26937/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-5763003338981376 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1b373b41d940e3058cdfb3d17703e23ed665353c --- libavformat/avidec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 57dc54452b..e92a449969 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -1446,6 +1446,7 @@ resync: if (avi->stream_index >= 0) { AVStream *st = s->streams[avi->stream_index]; AVIStream *ast = st->priv_data; +int dv_demux = CONFIG_DV_DEMUXER && avi->dv_demux; int size, err; if (get_subtitle_pkt(s, st, pkt)) @@ -1468,7 +1469,7 @@ resync: return err; size = err; -if (ast->has_pal && pkt->size < (unsigned)INT_MAX / 2) { +if (ast->has_pal && pkt->size < (unsigned)INT_MAX / 2 && !dv_demux) { uint8_t *pal; pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, @@ -1482,7 +1483,7 @@ resync: } } -if (CONFIG_DV_DEMUXER && avi->dv_demux) { +if (dv_demux) { AVBufferRef *avbuf = pkt->buf; size = avpriv_dv_produce_packet(avi->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/cri: check for available input in unpack_10bit()
ffmpeg | branch: master | Michael Niedermayer | Mon Nov 9 23:31:30 2020 +0100| [43c8d3097b8254d08f5413a1934c001327859f47] | committer: Michael Niedermayer avcodec/cri: check for available input in unpack_10bit() Fixes: Timeout (>20sec -> 56ms) Fixes: 26995/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CRI_fuzzer-5107217080254464 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=43c8d3097b8254d08f5413a1934c001327859f47 --- libavcodec/cri.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libavcodec/cri.c b/libavcodec/cri.c index 5234f49965..41be29eabb 100644 --- a/libavcodec/cri.c +++ b/libavcodec/cri.c @@ -80,10 +80,13 @@ static void unpack_10bit(GetByteContext *gb, uint16_t *dst, int shift, int pos = 0; while (count > 0) { -uint32_t a0 = bytestream2_get_le32(gb); -uint32_t a1 = bytestream2_get_le32(gb); -uint32_t a2 = bytestream2_get_le32(gb); -uint32_t a3 = bytestream2_get_le32(gb); +uint32_t a0, a1,a2,a3; +if (bytestream2_get_bytes_left(gb) < 4) +break; +a0 = bytestream2_get_le32(gb); +a1 = bytestream2_get_le32(gb); +a2 = bytestream2_get_le32(gb); +a3 = bytestream2_get_le32(gb); dst[pos] = (((a0 >> 1) & 0xE00) | (a0 & 0x1FF)) << shift; pos++; if (pos >= w) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavd/dshow: Add namespace prefix to global functions
ffmpeg | branch: master | Mark Thompson | Mon Jun 25 19:47:03 2018 +0100| [c154aada45588a01cfa2adb5e56ed197eb3e4bfd] | committer: James Almer lavd/dshow: Add namespace prefix to global functions > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c154aada45588a01cfa2adb5e56ed197eb3e4bfd --- libavdevice/dshow.c | 6 +++--- libavdevice/dshow_capture.h | 4 ++-- libavdevice/dshow_crossbar.c | 8 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index d7f5bd7069..1b9e5be399 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -510,7 +510,7 @@ end: * Pops up a user dialog allowing them to adjust properties for the given filter, if possible. */ void -dshow_show_filter_properties(IBaseFilter *device_filter, AVFormatContext *avctx) { +ff_dshow_show_filter_properties(IBaseFilter *device_filter, AVFormatContext *avctx) { ISpecifyPropertyPages *property_pages = NULL; IUnknown *device_filter_iunknown = NULL; HRESULT hr; @@ -582,7 +582,7 @@ dshow_cycle_pins(AVFormatContext *avctx, enum dshowDeviceType devtype, int should_show_properties = (devtype == VideoDevice) ? ctx->show_video_device_dialog : ctx->show_audio_device_dialog; if (should_show_properties) -dshow_show_filter_properties(device_filter, avctx); +ff_dshow_show_filter_properties(device_filter, avctx); r = IBaseFilter_EnumPins(device_filter, &pins); if (r != S_OK) { @@ -887,7 +887,7 @@ dshow_open_device(AVFormatContext *avctx, ICreateDevEnum *devenum, goto error; } -r = dshow_try_setup_crossbar_options(graph_builder2, device_filter, devtype, avctx); +r = ff_dshow_try_setup_crossbar_options(graph_builder2, device_filter, devtype, avctx); if (r != S_OK) { av_log(avctx, AV_LOG_ERROR, "Could not setup CrossBar\n"); diff --git a/libavdevice/dshow_capture.h b/libavdevice/dshow_capture.h index 475d62ba99..79c004a87f 100644 --- a/libavdevice/dshow_capture.h +++ b/libavdevice/dshow_capture.h @@ -346,9 +346,9 @@ struct dshow_ctx { /* * CrossBar / -HRESULT dshow_try_setup_crossbar_options(ICaptureGraphBuilder2 *graph_builder2, +HRESULT ff_dshow_try_setup_crossbar_options(ICaptureGraphBuilder2 *graph_builder2, IBaseFilter *device_filter, enum dshowDeviceType devtype, AVFormatContext *avctx); -void dshow_show_filter_properties(IBaseFilter *pFilter, AVFormatContext *avctx); +void ff_dshow_show_filter_properties(IBaseFilter *pFilter, AVFormatContext *avctx); #endif /* AVDEVICE_DSHOW_CAPTURE_H */ diff --git a/libavdevice/dshow_crossbar.c b/libavdevice/dshow_crossbar.c index 95fb466f4e..2438683cde 100644 --- a/libavdevice/dshow_crossbar.c +++ b/libavdevice/dshow_crossbar.c @@ -137,7 +137,7 @@ setup_crossbar_options(IAMCrossbar *cross_bar, enum dshowDeviceType devtype, AVF * Given a fully constructed graph, check if there is a cross bar filter, and configure its pins if so. */ HRESULT -dshow_try_setup_crossbar_options(ICaptureGraphBuilder2 *graph_builder2, +ff_dshow_try_setup_crossbar_options(ICaptureGraphBuilder2 *graph_builder2, IBaseFilter *device_filter, enum dshowDeviceType devtype, AVFormatContext *avctx) { struct dshow_ctx *ctx = avctx->priv_data; @@ -163,7 +163,7 @@ dshow_try_setup_crossbar_options(ICaptureGraphBuilder2 *graph_builder2, hr = IAMCrossbar_QueryInterface(cross_bar, &IID_IBaseFilter, (void **) &cross_bar_base_filter); if (hr != S_OK) goto end; -dshow_show_filter_properties(cross_bar_base_filter, avctx); +ff_dshow_show_filter_properties(cross_bar_base_filter, avctx); } if (devtype == VideoDevice && ctx->show_analog_tv_tuner_dialog) { @@ -173,7 +173,7 @@ dshow_try_setup_crossbar_options(ICaptureGraphBuilder2 *graph_builder2, hr = IAMCrossbar_QueryInterface(tv_tuner_filter, &IID_IBaseFilter, (void **) &tv_tuner_base_filter); if (hr != S_OK) goto end; -dshow_show_filter_properties(tv_tuner_base_filter, avctx); +ff_dshow_show_filter_properties(tv_tuner_base_filter, avctx); } else { av_log(avctx, AV_LOG_WARNING, "unable to find a tv tuner to display dialog for!"); } @@ -185,7 +185,7 @@ dshow_try_setup_crossbar_options(ICaptureGraphBuilder2 *graph_builder2, hr = IAMCrossbar_QueryInterface(tv_audio_filter, &IID_IBaseFilter, (void **) &tv_audio_base_filter); if (hr != S_OK) goto end; -dshow_show_filter_properties(tv_audio_base_filter, avctx); +ff_dshow_show_filter_properties(tv_audio_base_filter, avctx); } else { av_log(avctx, AV_LOG_WARNING, "unable to find a tv audio tuner to display dialog for!"); } _
[FFmpeg-cvslog] avformat/async: Use AVERROR macro
ffmpeg | branch: master | Limin Wang | Sat Jan 16 09:32:13 2021 +0800| [6dad42854690f5754a1cf1ed138ebd9813e1af37] | committer: Limin Wang avformat/async: Use AVERROR macro Signed-off-by: Limin Wang > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6dad42854690f5754a1cf1ed138ebd9813e1af37 --- libavformat/async.c | 4 1 file changed, 4 insertions(+) diff --git a/libavformat/async.c b/libavformat/async.c index a0bdfa2ee3..cc11ec47a0 100644 --- a/libavformat/async.c +++ b/libavformat/async.c @@ -262,24 +262,28 @@ static int async_open(URLContext *h, const char *arg, int flags, AVDictionary ** ret = pthread_mutex_init(&c->mutex, NULL); if (ret != 0) { +ret = AVERROR(ret); av_log(h, AV_LOG_ERROR, "pthread_mutex_init failed : %s\n", av_err2str(ret)); goto mutex_fail; } ret = pthread_cond_init(&c->cond_wakeup_main, NULL); if (ret != 0) { +ret = AVERROR(ret); av_log(h, AV_LOG_ERROR, "pthread_cond_init failed : %s\n", av_err2str(ret)); goto cond_wakeup_main_fail; } ret = pthread_cond_init(&c->cond_wakeup_background, NULL); if (ret != 0) { +ret = AVERROR(ret); av_log(h, AV_LOG_ERROR, "pthread_cond_init failed : %s\n", av_err2str(ret)); goto cond_wakeup_background_fail; } ret = pthread_create(&c->async_buffer_thread, NULL, async_buffer_task, h); if (ret) { +ret = AVERROR(ret); av_log(h, AV_LOG_ERROR, "pthread_create failed : %s\n", av_err2str(ret)); goto thread_fail; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] dnn_backend_openvino.c: add version mismatch reminder
ffmpeg | branch: master | Guo, Yejun | Mon Jan 18 15:27:23 2021 +0800| [0d5fd4999a2291d82fe5cc8a4c8157165536ba04] | committer: Guo, Yejun dnn_backend_openvino.c: add version mismatch reminder The OpenVINO model file format changes when OpenVINO goes to a new release, it does not work if the versions between model file and runtime are mismatched. Signed-off-by: Guo, Yejun > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0d5fd4999a2291d82fe5cc8a4c8157165536ba04 --- libavfilter/dnn/dnn_backend_openvino.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c index 8a7abb33f0..bb4ef3958f 100644 --- a/libavfilter/dnn/dnn_backend_openvino.c +++ b/libavfilter/dnn/dnn_backend_openvino.c @@ -544,8 +544,15 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, const char *options, goto err; status = ie_core_read_network(ov_model->core, model_filename, NULL, &ov_model->network); -if (status != OK) +if (status != OK) { +ie_version_t ver; +ver = ie_c_api_version(); +av_log(ctx, AV_LOG_ERROR, "Failed to read the network from model file %s,\n" + "Please check if the model version matches the runtime OpenVINO %s\n", + model_filename, ver.api_version); +ie_version_free(&ver); goto err; +} model->get_input = &get_input_ov; model->get_output = &get_output_ov; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] libavfilter/dnn: use avpriv_report_missing_feature for unsupported features
ffmpeg | branch: master | Guo, Yejun | Mon Jan 18 15:56:34 2021 +0800| [2d6af4a501d0563268580740c5a51073382ad045] | committer: Guo, Yejun libavfilter/dnn: use avpriv_report_missing_feature for unsupported features Signed-off-by: Guo, Yejun > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2d6af4a501d0563268580740c5a51073382ad045 --- libavfilter/dnn/dnn_backend_native.c | 2 +- libavfilter/dnn/dnn_backend_openvino.c | 4 ++-- libavfilter/dnn/dnn_backend_tf.c | 4 ++-- libavfilter/dnn/dnn_io_proc.c | 10 -- libavfilter/vf_dnn_processing.c| 4 ++-- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_native.c b/libavfilter/dnn/dnn_backend_native.c index 5e7fc0f10c..2700251ee6 100644 --- a/libavfilter/dnn/dnn_backend_native.c +++ b/libavfilter/dnn/dnn_backend_native.c @@ -327,7 +327,7 @@ static DNNReturnType execute_model_native(const DNNModel *model, const char *inp if (nb_output != 1) { // currently, the filter does not need multiple outputs, // so we just pending the support until we really need it. -av_log(ctx, AV_LOG_ERROR, "do not support multiple outputs\n"); +avpriv_report_missing_feature(ctx, "multiple outputs"); return DNN_ERROR; } diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c index bb4ef3958f..5820afbcfd 100644 --- a/libavfilter/dnn/dnn_backend_openvino.c +++ b/libavfilter/dnn/dnn_backend_openvino.c @@ -588,12 +588,12 @@ DNNReturnType ff_dnn_execute_model_ov(const DNNModel *model, const char *input_n if (nb_output != 1) { // currently, the filter does not need multiple outputs, // so we just pending the support until we really need it. -av_log(ctx, AV_LOG_ERROR, "do not support multiple outputs\n"); +avpriv_report_missing_feature(ctx, "multiple outputs"); return DNN_ERROR; } if (ctx->options.batch_size > 1) { -av_log(ctx, AV_LOG_ERROR, "do not support batch mode for sync execution.\n"); +avpriv_report_missing_feature(ctx, "batch mode for sync execution"); return DNN_ERROR; } diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c index b9fe01693b..cbe83741f6 100644 --- a/libavfilter/dnn/dnn_backend_tf.c +++ b/libavfilter/dnn/dnn_backend_tf.c @@ -424,7 +424,7 @@ static DNNReturnType add_conv_layer(TFModel *tf_model, TF_Operation *transpose_o op_desc = TF_NewOperation(tf_model->graph, "Sigmoid", name_buffer); break; default: -av_log(ctx, AV_LOG_ERROR, "Unsupported convolutional activation function\n"); +avpriv_report_missing_feature(ctx, "convolutional activation function %d", params->activation); return DNN_ERROR; } input.oper = *cur_op; @@ -750,7 +750,7 @@ static DNNReturnType execute_model_tf(const DNNModel *model, const char *input_n if (nb_output != 1) { // currently, the filter does not need multiple outputs, // so we just pending the support until we really need it. -av_log(ctx, AV_LOG_ERROR, "do not support multiple outputs\n"); +avpriv_report_missing_feature(ctx, "multiple outputs"); return DNN_ERROR; } diff --git a/libavfilter/dnn/dnn_io_proc.c b/libavfilter/dnn/dnn_io_proc.c index 2744cb6502..193e5bd9cc 100644 --- a/libavfilter/dnn/dnn_io_proc.c +++ b/libavfilter/dnn/dnn_io_proc.c @@ -27,7 +27,7 @@ DNNReturnType proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *log_ struct SwsContext *sws_ctx; int bytewidth = av_image_get_linesize(frame->format, frame->width, 0); if (output->dt != DNN_FLOAT) { -av_log(log_ctx, AV_LOG_ERROR, "do not support data type rather than DNN_FLOAT\n"); +avpriv_report_missing_feature(log_ctx, "data type rather than DNN_FLOAT"); return DNN_ERROR; } @@ -85,8 +85,7 @@ DNNReturnType proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *log_ sws_freeContext(sws_ctx); return DNN_SUCCESS; default: -av_log(log_ctx, AV_LOG_ERROR, "do not support frame format %s\n", - av_get_pix_fmt_name(frame->format)); +avpriv_report_missing_feature(log_ctx, "%s", av_get_pix_fmt_name(frame->format)); return DNN_ERROR; } @@ -98,7 +97,7 @@ DNNReturnType proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void *log_c struct SwsContext *sws_ctx; int bytewidth = av_image_get_linesize(frame->format, frame->width, 0); if (input->dt != DNN_FLOAT) { -av_log(log_ctx, AV_LOG_ERROR, "do not support data type rather than DNN_FLOAT\n"); +avpriv_report_missing_feature(log_ctx, "data type rather than DNN_FLOAT"); return DNN_ERROR; } @@ -158,8 +157,7 @@ DNNReturnType proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void *log_c sws_freeContext(sws_ctx); break; d
[FFmpeg-cvslog] libavfilter/dnn: add prefix ff_ for internal functions
ffmpeg | branch: master | Guo, Yejun | Mon Jan 18 16:00:58 2021 +0800| [c5e30d588d7794ac9c93dfb3b9e2464777af0475] | committer: Guo, Yejun libavfilter/dnn: add prefix ff_ for internal functions from proc_from_frame_to_dnn to ff_proc_from_frame_to_dnn, and from proc_from_dnn_to_frame to ff_proc_from_dnn_to_frame. Signed-off-by: Guo, Yejun > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c5e30d588d7794ac9c93dfb3b9e2464777af0475 --- libavfilter/dnn/dnn_backend_native.c | 4 ++-- libavfilter/dnn/dnn_backend_openvino.c | 4 ++-- libavfilter/dnn/dnn_backend_tf.c | 4 ++-- libavfilter/dnn/dnn_io_proc.c | 4 ++-- libavfilter/dnn/dnn_io_proc.h | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_native.c b/libavfilter/dnn/dnn_backend_native.c index 2700251ee6..2c0b938839 100644 --- a/libavfilter/dnn/dnn_backend_native.c +++ b/libavfilter/dnn/dnn_backend_native.c @@ -320,7 +320,7 @@ static DNNReturnType execute_model_native(const DNNModel *model, const char *inp if (native_model->model->pre_proc != NULL) { native_model->model->pre_proc(in_frame, &input, native_model->model->filter_ctx); } else { -proc_from_frame_to_dnn(in_frame, &input, ctx); +ff_proc_from_frame_to_dnn(in_frame, &input, ctx); } } @@ -368,7 +368,7 @@ static DNNReturnType execute_model_native(const DNNModel *model, const char *inp if (native_model->model->post_proc != NULL) { native_model->model->post_proc(out_frame, &output, native_model->model->filter_ctx); } else { -proc_from_dnn_to_frame(out_frame, &output, ctx); +ff_proc_from_dnn_to_frame(out_frame, &output, ctx); } } else { out_frame->width = output.width; diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c index 5820afbcfd..9c803c8188 100644 --- a/libavfilter/dnn/dnn_backend_openvino.c +++ b/libavfilter/dnn/dnn_backend_openvino.c @@ -160,7 +160,7 @@ static DNNReturnType fill_model_input_ov(OVModel *ov_model, RequestItem *request if (ov_model->model->pre_proc != NULL) { ov_model->model->pre_proc(task->in_frame, &input, ov_model->model->filter_ctx); } else { -proc_from_frame_to_dnn(task->in_frame, &input, ctx); +ff_proc_from_frame_to_dnn(task->in_frame, &input, ctx); } } input.data = (uint8_t *)input.data @@ -228,7 +228,7 @@ static void infer_completion_callback(void *args) if (task->ov_model->model->post_proc != NULL) { task->ov_model->model->post_proc(task->out_frame, &output, task->ov_model->model->filter_ctx); } else { -proc_from_dnn_to_frame(task->out_frame, &output, ctx); +ff_proc_from_dnn_to_frame(task->out_frame, &output, ctx); } } else { task->out_frame->width = output.width; diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c index cbe83741f6..f77f3dd817 100644 --- a/libavfilter/dnn/dnn_backend_tf.c +++ b/libavfilter/dnn/dnn_backend_tf.c @@ -743,7 +743,7 @@ static DNNReturnType execute_model_tf(const DNNModel *model, const char *input_n if (tf_model->model->pre_proc != NULL) { tf_model->model->pre_proc(in_frame, &input, tf_model->model->filter_ctx); } else { -proc_from_frame_to_dnn(in_frame, &input, ctx); +ff_proc_from_frame_to_dnn(in_frame, &input, ctx); } } @@ -800,7 +800,7 @@ static DNNReturnType execute_model_tf(const DNNModel *model, const char *input_n if (tf_model->model->post_proc != NULL) { tf_model->model->post_proc(out_frame, &output, tf_model->model->filter_ctx); } else { -proc_from_dnn_to_frame(out_frame, &output, ctx); +ff_proc_from_dnn_to_frame(out_frame, &output, ctx); } } else { out_frame->width = output.width; diff --git a/libavfilter/dnn/dnn_io_proc.c b/libavfilter/dnn/dnn_io_proc.c index 193e5bd9cc..bee1423342 100644 --- a/libavfilter/dnn/dnn_io_proc.c +++ b/libavfilter/dnn/dnn_io_proc.c @@ -22,7 +22,7 @@ #include "libavutil/imgutils.h" #include "libswscale/swscale.h" -DNNReturnType proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *log_ctx) +DNNReturnType ff_proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *log_ctx) { struct SwsContext *sws_ctx; int bytewidth = av_image_get_linesize(frame->format, frame->width, 0); @@ -92,7 +92,7 @@ DNNReturnType proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *log_ return DNN_SUCCESS; } -DNNReturnType proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void *log_ctx) +DNNReturnType ff_proc_from_frame_to_dnn(AVFrame *frame, D
[FFmpeg-cvslog] dnn/queue: remove prefix FF for Queue and SafeQueue
ffmpeg | branch: master | Guo, Yejun | Mon Jan 18 16:09:56 2021 +0800| [d4f40c1b608dbf619976f9fa3b48d16c6dcae946] | committer: Guo, Yejun dnn/queue: remove prefix FF for Queue and SafeQueue we don't need FF prefix for internal data struct Signed-off-by: Guo, Yejun > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d4f40c1b608dbf619976f9fa3b48d16c6dcae946 --- libavfilter/dnn/dnn_backend_openvino.c | 4 +-- libavfilter/dnn/queue.c| 58 +- libavfilter/dnn/queue.h| 20 ++-- libavfilter/dnn/safe_queue.c | 18 +-- libavfilter/dnn/safe_queue.h | 14 5 files changed, 57 insertions(+), 57 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c index 9c803c8188..573344e628 100644 --- a/libavfilter/dnn/dnn_backend_openvino.c +++ b/libavfilter/dnn/dnn_backend_openvino.c @@ -55,8 +55,8 @@ typedef struct OVModel{ ie_infer_request_t *infer_request; /* for async execution */ -FFSafeQueue *request_queue; // holds RequestItem -FFQueue *task_queue; // holds TaskItem +SafeQueue *request_queue; // holds RequestItem +Queue *task_queue; // holds TaskItem } OVModel; typedef struct TaskItem { diff --git a/libavfilter/dnn/queue.c b/libavfilter/dnn/queue.c index e64f567906..954437a8b4 100644 --- a/libavfilter/dnn/queue.c +++ b/libavfilter/dnn/queue.c @@ -23,31 +23,31 @@ #include "libavutil/mem.h" #include "libavutil/avassert.h" -typedef struct FFQueueEntry FFQueueEntry; +typedef struct QueueEntry QueueEntry; -struct FFQueueEntry { +struct QueueEntry { void *value; -FFQueueEntry *prev; -FFQueueEntry *next; +QueueEntry *prev; +QueueEntry *next; }; -struct FFQueue { -FFQueueEntry *head; -FFQueueEntry *tail; +struct Queue { +QueueEntry *head; +QueueEntry *tail; size_t length; }; -static inline FFQueueEntry *create_entry(void *val) +static inline QueueEntry *create_entry(void *val) { -FFQueueEntry *entry = av_malloc(sizeof(*entry)); +QueueEntry *entry = av_malloc(sizeof(*entry)); if (entry) entry->value = val; return entry; } -FFQueue* ff_queue_create(void) +Queue* ff_queue_create(void) { -FFQueue *q = av_malloc(sizeof(*q)); +Queue *q = av_malloc(sizeof(*q)); if (!q) return NULL; @@ -70,15 +70,15 @@ FFQueue* ff_queue_create(void) return q; } -void ff_queue_destroy(FFQueue *q) +void ff_queue_destroy(Queue *q) { -FFQueueEntry *entry; +QueueEntry *entry; if (!q) return; entry = q->head; while (entry != NULL) { -FFQueueEntry *temp = entry; +QueueEntry *temp = entry; entry = entry->next; av_freep(&temp); } @@ -86,12 +86,12 @@ void ff_queue_destroy(FFQueue *q) av_freep(&q); } -size_t ff_queue_size(FFQueue *q) +size_t ff_queue_size(Queue *q) { return q ? q->length : 0; } -void *ff_queue_peek_front(FFQueue *q) +void *ff_queue_peek_front(Queue *q) { if (!q || q->length == 0) return NULL; @@ -99,7 +99,7 @@ void *ff_queue_peek_front(FFQueue *q) return q->head->next->value; } -void *ff_queue_peek_back(FFQueue *q) +void *ff_queue_peek_back(Queue *q) { if (!q || q->length == 0) return NULL; @@ -107,10 +107,10 @@ void *ff_queue_peek_back(FFQueue *q) return q->tail->prev->value; } -int ff_queue_push_front(FFQueue *q, void *v) +int ff_queue_push_front(Queue *q, void *v) { -FFQueueEntry *new_entry; -FFQueueEntry *original_next; +QueueEntry *new_entry; +QueueEntry *original_next; if (!q) return 0; @@ -128,10 +128,10 @@ int ff_queue_push_front(FFQueue *q, void *v) return q->length; } -int ff_queue_push_back(FFQueue *q, void *v) +int ff_queue_push_back(Queue *q, void *v) { -FFQueueEntry *new_entry; -FFQueueEntry *original_prev; +QueueEntry *new_entry; +QueueEntry *original_prev; if (!q) return 0; @@ -149,10 +149,10 @@ int ff_queue_push_back(FFQueue *q, void *v) return q->length; } -void *ff_queue_pop_front(FFQueue *q) +void *ff_queue_pop_front(Queue *q) { -FFQueueEntry *front; -FFQueueEntry *new_head_next; +QueueEntry *front; +QueueEntry *new_head_next; void *ret; if (!q || q->length == 0) @@ -170,10 +170,10 @@ void *ff_queue_pop_front(FFQueue *q) return ret; } -void *ff_queue_pop_back(FFQueue *q) +void *ff_queue_pop_back(Queue *q) { -FFQueueEntry *back; -FFQueueEntry *new_tail_prev; +QueueEntry *back; +QueueEntry *new_tail_prev; void *ret; if (!q || q->length == 0) diff --git a/libavfilter/dnn/queue.h b/libavfilter/dnn/queue.h index df913d91ac..4d7121366a 100644 --- a/libavfilter/dnn/queue.h +++ b/libavfilter/dnn/queue.h @@ -22,20 +22,20 @@ #ifndef AVFILTER_DNN_QUEUE_H #define AVFILTER_DNN_QUEUE_H -typedef struct FFQueue FFQue
[FFmpeg-cvslog] dnn_backend_native_layer_conv2d.c: correct struct name with CamelCase
ffmpeg | branch: master | Guo, Yejun | Mon Jan 18 16:15:34 2021 +0800| [a76fa0caa0cf0109f94eee691ebae3c20432163e] | committer: Guo, Yejun dnn_backend_native_layer_conv2d.c: correct struct name with CamelCase Signed-off-by: Guo, Yejun > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a76fa0caa0cf0109f94eee691ebae3c20432163e --- libavfilter/dnn/dnn_backend_native_layer_conv2d.c | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c index 0fb968a1fc..7c6d96e916 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c +++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c @@ -26,19 +26,19 @@ #define CLAMP_TO_EDGE(x, w) ((x) < 0 ? 0 : ((x) >= (w) ? (w - 1) : (x))) //struct to pass parameters -typedef struct thread_common_param{ +typedef struct ThreadCommonParam{ DnnOperand *operands; const int32_t *input_operand_indexes; int32_t output_operand_index; const void *parameters; NativeContext *ctx; float *output_data; -} thread_common_param; +} ThreadCommonParam; -typedef struct thread_param{ -thread_common_param *thread_common_param; +typedef struct ThreadParam{ +ThreadCommonParam *thread_common_param; int thread_start, thread_end; -} thread_param; +} ThreadParam; int dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num) { @@ -108,8 +108,8 @@ int dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int fil static void * dnn_execute_layer_conv2d_thread(void *threadarg) { //pass parameters -thread_param *thread_param = (struct thread_param *)threadarg; -thread_common_param *thread_common_param = thread_param->thread_common_param; +ThreadParam *thread_param = threadarg; +ThreadCommonParam *thread_common_param = thread_param->thread_common_param; DnnOperand *operands = thread_common_param->operands; int32_t input_operand_index = thread_common_param->input_operand_indexes[0]; int height = operands[input_operand_index].dims[1]; @@ -190,8 +190,8 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_operand_ pthread_t *thread_id = av_malloc(thread_num * sizeof(pthread_t)); int thread_stride; #endif -thread_param **thread_param = av_malloc(thread_num * sizeof(*thread_param)); -thread_common_param thread_common_param; +ThreadParam **thread_param = av_malloc(thread_num * sizeof(*thread_param)); +ThreadCommonParam thread_common_param; const ConvolutionalParams *conv_params = (const ConvolutionalParams *)(parameters); int height = operands[input_operand_indexes[0]].dims[1]; int width = operands[input_operand_indexes[0]].dims[2]; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] dnn_backend_native_layer_conv2d.c: refine code with av_malloc_array and av_freep
ffmpeg | branch: master | Guo, Yejun | Mon Jan 18 16:28:11 2021 +0800| [a11a3f358dcbabf885a57f93956e81cbd968a797] | committer: Guo, Yejun dnn_backend_native_layer_conv2d.c: refine code with av_malloc_array and av_freep Signed-off-by: Guo, Yejun > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a11a3f358dcbabf885a57f93956e81cbd968a797 --- libavfilter/dnn/dnn_backend_native_layer_conv2d.c | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c index 7c6d96e916..9dc50b7cbe 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c +++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c @@ -70,7 +70,7 @@ int dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int fil return 0; } -conv_params->kernel = av_malloc(kernel_size * sizeof(float)); +conv_params->kernel = av_malloc_array(kernel_size, sizeof(*conv_params->kernel)); if (!conv_params->kernel) { av_freep(&conv_params); return 0; @@ -81,7 +81,7 @@ int dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int fil conv_params->biases = NULL; if (conv_params->has_bias) { -conv_params->biases = av_malloc(conv_params->output_num * sizeof(float)); +conv_params->biases = av_malloc_array(conv_params->output_num, sizeof(*conv_params->biases)); if (!conv_params->biases){ av_freep(&conv_params->kernel); av_freep(&conv_params); @@ -187,10 +187,10 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_operand_ int thread_num = (ctx->options.conv2d_threads <= 0 || ctx->options.conv2d_threads > av_cpu_count()) ? (av_cpu_count() + 1) : (ctx->options.conv2d_threads); #if HAVE_PTHREAD_CANCEL -pthread_t *thread_id = av_malloc(thread_num * sizeof(pthread_t)); +pthread_t *thread_id = av_malloc_array(thread_num, sizeof(*thread_id)); int thread_stride; #endif -ThreadParam **thread_param = av_malloc(thread_num * sizeof(*thread_param)); +ThreadParam **thread_param = av_malloc_array(thread_num, sizeof(*thread_param)); ThreadCommonParam thread_common_param; const ConvolutionalParams *conv_params = (const ConvolutionalParams *)(parameters); int height = operands[input_operand_indexes[0]].dims[1]; @@ -224,7 +224,7 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_operand_ thread_stride = (height - pad_size * 2) / thread_num; //create threads for (int i = 0; i < thread_num; i++){ -thread_param[i] = av_malloc(sizeof(**thread_param)); +thread_param[i] = av_malloc(sizeof(*thread_param[0])); thread_param[i]->thread_common_param = &thread_common_param; thread_param[i]->thread_start = thread_stride * i + pad_size; thread_param[i]->thread_end = (i == thread_num - 1) ? (height - pad_size) : (thread_param[i]->thread_start + thread_stride); @@ -237,20 +237,20 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_operand_ } //release memory -av_free(thread_id); +av_freep(&thread_id); for (int i = 0; i < thread_num; i++){ -av_free(thread_param[i]); +av_freep(&thread_param[i]); } #else -thread_param[0] = av_malloc(sizeof(**thread_param)); +thread_param[0] = av_malloc(sizeof(*thread_param[0])); thread_param[0]->thread_common_param = &thread_common_param; thread_param[0]->thread_start = pad_size; thread_param[0]->thread_end = height - pad_size; dnn_execute_layer_conv2d_thread((void *)thread_param[0]); -av_free(thread_param[0]); +av_freep(&thread_param[0]); #endif -av_free(thread_param); +av_freep(&thread_param); return DNN_SUCCESS; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] dnn_backend_native_layer_mathbinary.c: Delete unused global variable
ffmpeg | branch: master | Mark Thompson | Thu Jan 21 21:39:52 2021 +| [c6a3ca2db491a66af9b1f5b12cbe3058713caf0b] | committer: Guo, Yejun dnn_backend_native_layer_mathbinary.c: Delete unused global variable > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c6a3ca2db491a66af9b1f5b12cbe3058713caf0b --- libavfilter/dnn/dnn_backend_native_layer_mathbinary.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c index 998a75245c..fc48242093 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c +++ b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c @@ -28,7 +28,6 @@ #include "dnn_backend_native_layer_mathbinary.h" typedef float (*FunType)(float src0, float src1); -FunType pfun; static float sub(float src0, float src1) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avutils/vulkan: hwmap, respect src frame resolution
ffmpeg | branch: master | Xu Guangxin | Thu Jan 21 12:35:13 2021 +0800| [ae97f69ce1032f96e361c0622355ac15cf7f9029] | committer: Lynne avutils/vulkan: hwmap, respect src frame resolution fixes http://trac.ffmpeg.org/ticket/9055 The hw decoder may allocate a large frame from AVHWFramesContext, and adjust width and height based on bitstream. We need to use resolution from src frame instead of AVHWFramesContext. test command: ffmpeg -loglevel debug -hide_banner -hwaccel vaapi -init_hw_device vaapi=va:/dev/dri/renderD128 -hwaccel_device va -hwaccel_output_format vaapi -init_hw_device vulkan=vulk -filter_hw_device vulk -i 1920x1080.264 -c:v libx264 -r:v 30 -profile:v high -preset veryfast -vf "hwmap,chromaber_vulkan=0:0,hwdownload,format=nv12" -map 0 -y vaapiouts.mkv expected: No green bar at bottom. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ae97f69ce1032f96e361c0622355ac15cf7f9029 --- libavutil/hwcontext_vulkan.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index d4ff4ae307..e835ffe90e 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -2009,7 +2009,7 @@ static inline VkFormat drm_to_vulkan_fmt(uint32_t drm_fourcc) } static int vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **frame, - AVDRMFrameDescriptor *desc) + const AVFrame *src) { int err = 0; VkResult ret; @@ -2020,6 +2020,7 @@ static int vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f VulkanDevicePriv *p = ctx->internal->priv; VulkanFramesPriv *fp = hwfc->internal->priv; AVVulkanFramesContext *frames_hwctx = hwfc->hwctx; +const AVDRMFrameDescriptor *desc = (AVDRMFrameDescriptor *)src->data[0]; const int has_modifiers = !!(p->extensions & EXT_DRM_MODIFIER_FLAGS); VkSubresourceLayout plane_data[AV_NUM_DATA_POINTERS] = { 0 }; VkBindImageMemoryInfo bind_info[AV_NUM_DATA_POINTERS] = { 0 }; @@ -2085,7 +2086,7 @@ static int vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f }; get_plane_wh(&create_info.extent.width, &create_info.extent.height, - hwfc->sw_format, hwfc->width, hwfc->height, i); + hwfc->sw_format, src->width, src->height, i); for (int j = 0; j < planes; j++) { plane_data[j].offset = desc->layers[i].planes[j].offset; @@ -2246,9 +2247,7 @@ static int vulkan_map_from_drm(AVHWFramesContext *hwfc, AVFrame *dst, AVVkFrame *f; VulkanMapping *map = NULL; -err = vulkan_map_from_drm_frame_desc(hwfc, &f, - (AVDRMFrameDescriptor *)src->data[0]); -if (err) +if ((err = vulkan_map_from_drm_frame_desc(hwfc, &f, src))) return err; /* The unmapping function will free this */ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] dnn-layer-conv2d-test.c: remove dependency of dnn_native_class
ffmpeg | branch: master | Guo, Yejun | Fri Jan 22 10:39:19 2021 +0800| [5235634b615110dc5cf6a23141a4bd72730f4ac6] | committer: Guo, Yejun dnn-layer-conv2d-test.c: remove dependency of dnn_native_class > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5235634b615110dc5cf6a23141a4bd72730f4ac6 --- tests/dnn/dnn-layer-conv2d-test.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/dnn/dnn-layer-conv2d-test.c b/tests/dnn/dnn-layer-conv2d-test.c index 378a05eafc..b623ddac0d 100644 --- a/tests/dnn/dnn-layer-conv2d-test.c +++ b/tests/dnn/dnn-layer-conv2d-test.c @@ -25,8 +25,6 @@ #define EPSON 0.1 -extern const AVClass dnn_native_class; - static int test_with_same_dilate(void) { // the input data and expected data are generated with below python code. @@ -99,7 +97,7 @@ static int test_with_same_dilate(void) float bias[2] = { -1.6574852, -0.72915393 }; NativeContext ctx; -ctx.class = &dnn_native_class; +ctx.class = NULL; ctx.options.conv2d_threads = 1; params.activation = TANH; @@ -203,7 +201,7 @@ static int test_with_valid(void) float bias[2] = { -0.4773722, -0.19620377 }; NativeContext ctx; -ctx.class = &dnn_native_class; +ctx.class = NULL; ctx.options.conv2d_threads = 1; params.activation = TANH; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] dnn_backend_native.c: Add missing static to local variable
ffmpeg | branch: master | Mark Thompson | Thu Jan 21 21:39:53 2021 +| [2c424d963039a7d50b5b93f0db5efd70101d8e44] | committer: Guo, Yejun dnn_backend_native.c: Add missing static to local variable > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2c424d963039a7d50b5b93f0db5efd70101d8e44 --- libavfilter/dnn/dnn_backend_native.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/dnn/dnn_backend_native.c b/libavfilter/dnn/dnn_backend_native.c index 2c0b938839..be43081170 100644 --- a/libavfilter/dnn/dnn_backend_native.c +++ b/libavfilter/dnn/dnn_backend_native.c @@ -36,7 +36,7 @@ static const AVOption dnn_native_options[] = { { NULL }, }; -const AVClass dnn_native_class = { +static const AVClass dnn_native_class = { .class_name = "dnn_native", .item_name = av_default_item_name, .option = dnn_native_options, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".