[FFmpeg-devel] [PATCH] lavf/matroskadec: add missing linebreaks in error messages
--- libavformat/matroskadec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 5d3d18a146..6d6a60c552 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -2036,7 +2036,7 @@ static int matroska_parse_content_encodings(MatroskaTrackEncoding *encodings, { if (nb_encodings > 1) { av_log(logctx, AV_LOG_ERROR, -"Multiple combined encodings not supported"); +"Multiple combined encodings not supported\n"); return 0; } if (!nb_encodings) @@ -2055,7 +2055,7 @@ static int matroska_parse_content_encodings(MatroskaTrackEncoding *encodings, encodings->encryption.key_id.size); } else { encodings->scope = 0; -av_log(logctx, AV_LOG_ERROR, "Unsupported encoding type"); +av_log(logctx, AV_LOG_ERROR, "Unsupported encoding type\n"); } } else if ( #if CONFIG_ZLIB @@ -2067,7 +2067,7 @@ static int matroska_parse_content_encodings(MatroskaTrackEncoding *encodings, encodings->compression.algo != MATROSKA_TRACK_ENCODING_COMP_LZO && encodings->compression.algo != MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP) { encodings->scope = 0; -av_log(logctx, AV_LOG_ERROR, "Unsupported encoding type"); +av_log(logctx, AV_LOG_ERROR, "Unsupported encoding type\n"); } else if (track->codec_priv.size && encodings[0].scope & 2) { uint8_t *codec_priv = track->codec_priv.data; int ret = matroska_decode_buffer(&track->codec_priv.data, -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/9] avcodec/libxevd: Remove FF_CODEC_CAP_SETS_PKT_DTS cap
> -Original Message- > From: ffmpeg-devel On Behalf Of > Andreas Rheinhardt > Sent: wtorek, 27 lutego 2024 20:48 > To: ffmpeg-devel@ffmpeg.org > Cc: Andreas Rheinhardt > Subject: [FFmpeg-devel] [PATCH 1/9] avcodec/libxevd: Remove > FF_CODEC_CAP_SETS_PKT_DTS cap > > This decoder implements the receive_frame API; such decoders always have to > set the pkt_dts field themselves and the avcodec test checks for this. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/libxevd.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavcodec/libxevd.c b/libavcodec/libxevd.c index > 58ef90d929..eb007e30fe 100644 > --- a/libavcodec/libxevd.c > +++ b/libavcodec/libxevd.c > @@ -534,5 +534,5 @@ const FFCodec ff_libxevd_decoder = { > .p.capabilities = AV_CODEC_CAP_DELAY | > AV_CODEC_CAP_OTHER_THREADS | AV_CODEC_CAP_AVOID_PROBING, > .p.profiles = NULL_IF_CONFIG_SMALL(ff_evc_profiles), > .p.wrapper_name = "libxevd", > -.caps_internal = FF_CODEC_CAP_INIT_CLEANUP | > FF_CODEC_CAP_NOT_INIT_THREADSAFE | FF_CODEC_CAP_SETS_PKT_DTS | > FF_CODEC_CAP_SETS_FRAME_PROPS > +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP | > FF_CODEC_CAP_NOT_INIT_THREADSAFE | > FF_CODEC_CAP_SETS_FRAME_PROPS > }; > -- > 2.40.1 > It has been checked. Looks good. > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://protect2.fireeye.com/v1/url?k=90421711-f13fff56-90439c5e- > 74fe485fff30-8ac153898cae4df3&q=1&e=8fc861d3-bd49-4b68-a822- > 7514fe931b97&u=https%3A%2F%2Fffmpeg.org%2Fmailman%2Flistinfo%2Fffmp > eg-devel > > To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org > with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/9] avcodec/libxevd: Set AV_CODEC_CAP_DR1
> -Original Message- > From: ffmpeg-devel On Behalf Of > Andreas Rheinhardt > Sent: wtorek, 27 lutego 2024 20:59 > To: ffmpeg-devel@ffmpeg.org > Cc: Andreas Rheinhardt > Subject: [FFmpeg-devel] [PATCH 2/9] avcodec/libxevd: Set AV_CODEC_CAP_DR1 > > This decoder uses av_image_copy() to copy decoded images to buffers obtained > via ff_get_buffer(); ergo it can handle user-provided buffers. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/libxevd.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/libxevd.c b/libavcodec/libxevd.c index > eb007e30fe..4bcf2585cc 100644 > --- a/libavcodec/libxevd.c > +++ b/libavcodec/libxevd.c > @@ -531,7 +531,8 @@ const FFCodec ff_libxevd_decoder = { > .close = libxevd_close, > .priv_data_size = sizeof(XevdContext), > .p.priv_class = &libxevd_class, > -.p.capabilities = AV_CODEC_CAP_DELAY | > AV_CODEC_CAP_OTHER_THREADS | AV_CODEC_CAP_AVOID_PROBING, > +.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | > + AV_CODEC_CAP_OTHER_THREADS | > + AV_CODEC_CAP_AVOID_PROBING, > .p.profiles = NULL_IF_CONFIG_SMALL(ff_evc_profiles), > .p.wrapper_name = "libxevd", > .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | > FF_CODEC_CAP_NOT_INIT_THREADSAFE | > FF_CODEC_CAP_SETS_FRAME_PROPS > -- > 2.40.1 > It has been checked. Looks good. > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://protect2.fireeye.com/v1/url?k=1bd9a923-4442903c-1bd8226c- > 000babdfecba-775f8081ce267ea1&q=1&e=6c5480c4-5786-4329-8ea5- > 7b0e913bf303&u=https%3A%2F%2Fffmpeg.org%2Fmailman%2Flistinfo%2Fffmp > eg-devel > > To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org > with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 6/9] avcodec/libxevd: Remove useless AVClass
> -Original Message- > From: ffmpeg-devel On Behalf Of > Andreas Rheinhardt > Sent: wtorek, 27 lutego 2024 20:59 > To: ffmpeg-devel@ffmpeg.org > Cc: Andreas Rheinhardt > Subject: [FFmpeg-devel] [PATCH 6/9] avcodec/libxevd: Remove useless AVClass > > This decoder does not have options. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/libxevd.c | 12 > 1 file changed, 12 deletions(-) > > diff --git a/libavcodec/libxevd.c b/libavcodec/libxevd.c index > de0739a80c..5075936a0e 100644 > --- a/libavcodec/libxevd.c > +++ b/libavcodec/libxevd.c > @@ -50,8 +50,6 @@ > * The structure stores all the states associated with the instance of Xeve MPEG- > 5 EVC decoder > */ > typedef struct XevdContext { > -const AVClass *class; > - > XEVD id;// XEVD instance identifier @see xevd.h > XEVD_CDSC cdsc; // decoding parameters @see xevd.h > > @@ -471,15 +469,6 @@ static av_cold int libxevd_close(AVCodecContext > *avctx) > return 0; > } > > -#define OFFSET(x) offsetof(XevdContext, x) -#define VD > AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM > - > -static const AVClass libxevd_class = { > -.class_name = "libxevd", > -.item_name = av_default_item_name, > -.version= LIBAVUTIL_VERSION_INT, > -}; > - > const FFCodec ff_libxevd_decoder = { > .p.name = "evc", > .p.long_name= NULL_IF_CONFIG_SMALL("EVC / MPEG-5 Essential Video > Coding (EVC)"), > @@ -489,7 +478,6 @@ const FFCodec ff_libxevd_decoder = { > FF_CODEC_RECEIVE_FRAME_CB(libxevd_receive_frame), > .close = libxevd_close, > .priv_data_size = sizeof(XevdContext), > -.p.priv_class = &libxevd_class, > .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | >AV_CODEC_CAP_OTHER_THREADS | > AV_CODEC_CAP_AVOID_PROBING, > .p.profiles = NULL_IF_CONFIG_SMALL(ff_evc_profiles), > -- > 2.40.1 > It has been checked. Looks good. > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://protect2.fireeye.com/v1/url?k=bf2f1a4e-e0b33364-bf2e9101- > 000babe598f7-5400e6cfb92c61da&q=1&e=f85ba7c0-e001-488d-9c87- > 565dfbde8ea3&u=https%3A%2F%2Fffmpeg.org%2Fmailman%2Flistinfo%2Fffmp > eg-devel > > To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org > with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 7/9] avcodec/libxevd: Use CODEC_LONG_NAME()
> -Original Message- > From: ffmpeg-devel On Behalf Of > Andreas Rheinhardt > Sent: wtorek, 27 lutego 2024 20:59 > To: ffmpeg-devel@ffmpeg.org > Cc: Andreas Rheinhardt > Subject: [FFmpeg-devel] [PATCH 7/9] avcodec/libxevd: Use > CODEC_LONG_NAME() > > Brings the length of the line down to less than 80 chars. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/libxevd.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavcodec/libxevd.c b/libavcodec/libxevd.c index > 5075936a0e..92804422a3 100644 > --- a/libavcodec/libxevd.c > +++ b/libavcodec/libxevd.c > @@ -471,7 +471,7 @@ static av_cold int libxevd_close(AVCodecContext > *avctx) > > const FFCodec ff_libxevd_decoder = { > .p.name = "evc", > -.p.long_name= NULL_IF_CONFIG_SMALL("EVC / MPEG-5 Essential Video > Coding (EVC)"), > +CODEC_LONG_NAME("EVC / MPEG-5 Essential Video Coding (EVC)"), > .p.type = AVMEDIA_TYPE_VIDEO, > .p.id = AV_CODEC_ID_EVC, > .init = libxevd_init, > -- > 2.40.1 > It has been checked. Looks good. > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://protect2.fireeye.com/v1/url?k=1d225d22-7ca9480d-1d23d66d- > 74fe485cbfe7-f66098d66f3bbf3d&q=1&e=74f8822a-e9c0-4ed9-be20- > f11f599cf138&u=https%3A%2F%2Fffmpeg.org%2Fmailman%2Flistinfo%2Fffmpe > g-devel > > To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org > with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/9] avcodec/libxevd: Remove FF_CODEC_CAP_SETS_PKT_DTS cap
> -Original Message- > From: ffmpeg-devel On Behalf Of > Andreas Rheinhardt > Sent: czwartek, 29 lutego 2024 10:37 > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH 1/9] avcodec/libxevd: Remove > FF_CODEC_CAP_SETS_PKT_DTS cap > > Andreas Rheinhardt: > > This decoder implements the receive_frame API; such decoders always > > have to set the pkt_dts field themselves and the avcodec test checks > > for this. > > > > Signed-off-by: Andreas Rheinhardt > > --- > > libavcodec/libxevd.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/libavcodec/libxevd.c b/libavcodec/libxevd.c index > > 58ef90d929..eb007e30fe 100644 > > --- a/libavcodec/libxevd.c > > +++ b/libavcodec/libxevd.c > > @@ -534,5 +534,5 @@ const FFCodec ff_libxevd_decoder = { > > .p.capabilities = AV_CODEC_CAP_DELAY | > AV_CODEC_CAP_OTHER_THREADS | AV_CODEC_CAP_AVOID_PROBING, > > .p.profiles = NULL_IF_CONFIG_SMALL(ff_evc_profiles), > > .p.wrapper_name = "libxevd", > > -.caps_internal = FF_CODEC_CAP_INIT_CLEANUP | > FF_CODEC_CAP_NOT_INIT_THREADSAFE | FF_CODEC_CAP_SETS_PKT_DTS | > FF_CODEC_CAP_SETS_FRAME_PROPS > > +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP | > FF_CODEC_CAP_NOT_INIT_THREADSAFE | > FF_CODEC_CAP_SETS_FRAME_PROPS > > }; > > Will apply this patchset tomorrow unless there are objections. > No objections. It has been checked. Looks good. > - Andreas > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://protect2.fireeye.com/v1/url?k=2ba11787-4adabd0f-2ba09cc8- > 74fe4860018a-c9fa419a18ec0235&q=1&e=1f7f95c0-bdda-4754-9900- > 6c849de896ad&u=https%3A%2F%2Fffmpeg.org%2Fmailman%2Flistinfo%2Fffmp > eg-devel > > To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org > with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 04/18] fftools/ffmpeg_dec: move scheduler registration from dec_open() to dec_alloc()
Will be useful in following commits where we will want to create a decoder before having enough information to open it. --- fftools/ffmpeg_dec.c | 51 +++- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c index 8c92b27cc1..98c4a0c83c 100644 --- a/fftools/ffmpeg_dec.c +++ b/fftools/ffmpeg_dec.c @@ -110,9 +110,26 @@ void dec_free(Decoder **pdec) av_freep(pdec); } -static int dec_alloc(DecoderPriv **pdec) +static const char *dec_item_name(void *obj) +{ +const DecoderPriv *dp = obj; + +return dp->log_name; +} + +static const AVClass dec_class = { +.class_name= "Decoder", +.version = LIBAVUTIL_VERSION_INT, +.parent_log_context_offset = offsetof(DecoderPriv, log_parent), +.item_name = dec_item_name, +}; + +static void *decoder_thread(void *arg); + +static int dec_alloc(DecoderPriv **pdec, Scheduler *sch, int send_end_ts) { DecoderPriv *dp; +int ret = 0; *pdec = NULL; @@ -128,17 +145,24 @@ static int dec_alloc(DecoderPriv **pdec) if (!dp->pkt) goto fail; +dp->dec.class= &dec_class; dp->last_filter_in_rescale_delta = AV_NOPTS_VALUE; dp->last_frame_pts = AV_NOPTS_VALUE; dp->last_frame_tb= (AVRational){ 1, 1 }; dp->hwaccel_pix_fmt = AV_PIX_FMT_NONE; +ret = sch_add_dec(sch, decoder_thread, dp, send_end_ts); +if (ret < 0) +goto fail; +dp->sch = sch; +dp->sch_idx = ret; + *pdec = dp; return 0; fail: dec_free((Decoder**)&dp); -return AVERROR(ENOMEM); +return ret >= 0 ? AVERROR(ENOMEM) : ret; } static AVRational audio_samplerate_update(DecoderPriv *dp, @@ -1042,20 +1066,6 @@ static int hw_device_setup_for_decode(DecoderPriv *dp, return 0; } -static const char *dec_item_name(void *obj) -{ -const DecoderPriv *dp = obj; - -return dp->log_name; -} - -static const AVClass dec_class = { -.class_name= "Decoder", -.version = LIBAVUTIL_VERSION_INT, -.parent_log_context_offset = offsetof(DecoderPriv, log_parent), -.item_name = dec_item_name, -}; - int dec_open(Decoder **pdec, Scheduler *sch, AVDictionary **dec_opts, const DecoderOpts *o) { @@ -1065,18 +1075,11 @@ int dec_open(Decoder **pdec, Scheduler *sch, *pdec = NULL; -ret = dec_alloc(&dp); +ret = dec_alloc(&dp, sch, !!(o->flags & DECODER_FLAG_SEND_END_TS)); if (ret < 0) return ret; -ret = sch_add_dec(sch, decoder_thread, dp, o->flags & DECODER_FLAG_SEND_END_TS); -if (ret < 0) -return ret; -dp->sch = sch; -dp->sch_idx = ret; - dp->flags = o->flags; -dp->dec.class = &dec_class; dp->log_parent = o->log_parent; dp->framerate_in= o->framerate; -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 03/18] fftools/ffmpeg_filter: drop unused InputFilterPriv.ist
Outside of ifilter_bind_ist(), there are no longer any assumptions about about filter inputs being fed by an InputStream. --- fftools/ffmpeg_filter.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 9d9762a599..37705297fb 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -109,8 +109,6 @@ typedef struct InputFilterPriv { AVFilterContext*filter; -InputStream*ist; - // used to hold submitted input AVFrame*frame; @@ -125,6 +123,7 @@ typedef struct InputFilterPriv { enum AVMediaTypetype_src; int eof; +int bound; // parameters configured for this input int format; @@ -664,7 +663,8 @@ static int ifilter_bind_ist(InputFilter *ifilter, InputStream *ist) FilterGraphPriv *fgp = fgp_from_fg(ifilter->graph); int ret, dec_idx; -av_assert0(!ifp->ist); +av_assert0(!ifp->bound); +ifp->bound = 1; if (ifp->type != ist->par->codec_type && !(ifp->type == AVMEDIA_TYPE_VIDEO && ist->par->codec_type == AVMEDIA_TYPE_SUBTITLE)) { @@ -673,7 +673,6 @@ static int ifilter_bind_ist(InputFilter *ifilter, InputStream *ist) return AVERROR(EINVAL); } -ifp->ist = ist; ifp->type_src= ist->st->codecpar->codec_type; dec_idx = ist_filter_add(ist, ifilter, filtergraph_is_simple(ifilter->graph), -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 01/18] fftools/cmdutils: fix printing group name in split_commandline()
--- fftools/cmdutils.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 008949a39d..8efec942bd 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -793,7 +793,7 @@ int split_commandline(OptionParseContext *octx, int argc, char *argv[], while (optindex < argc) { const char *opt = argv[optindex++], *arg; const OptionDef *po; -int ret; +int ret, group_idx; av_log(NULL, AV_LOG_DEBUG, "Reading option '%s' ...", opt); @@ -822,14 +822,15 @@ do { \ } while (0) /* named group separators, e.g. -i */ -if ((ret = match_group_separator(groups, nb_groups, opt)) >= 0) { +group_idx = match_group_separator(groups, nb_groups, opt); +if (group_idx >= 0) { GET_ARG(arg); -ret = finish_group(octx, ret, arg); +ret = finish_group(octx, group_idx, arg); if (ret < 0) return ret; av_log(NULL, AV_LOG_DEBUG, " matched as %s with argument '%s'.\n", - groups[ret].name, arg); + groups[group_idx].name, arg); continue; } -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 11/18] fftools/ffmpeg_enc: drop unnecessary parameter from forced_kf_apply()
Encoder timebase is equal to the frame timebase, so does not need to be passed separately. Also, rename in_picture to frame, which is shorter and more accurate - it always contains a frame, never a field. --- fftools/ffmpeg_enc.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 1ddef46d03..f0a17228fe 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -746,16 +746,16 @@ static int do_audio_out(OutputFile *of, OutputStream *ost, } static enum AVPictureType forced_kf_apply(void *logctx, KeyframeForceCtx *kf, - AVRational tb, const AVFrame *in_picture) + const AVFrame *frame) { double pts_time; if (kf->ref_pts == AV_NOPTS_VALUE) -kf->ref_pts = in_picture->pts; +kf->ref_pts = frame->pts; -pts_time = (in_picture->pts - kf->ref_pts) * av_q2d(tb); +pts_time = (frame->pts - kf->ref_pts) * av_q2d(frame->time_base); if (kf->index < kf->nb_pts && -av_compare_ts(in_picture->pts, tb, kf->pts[kf->index], AV_TIME_BASE_Q) >= 0) { +av_compare_ts(frame->pts, frame->time_base, kf->pts[kf->index], AV_TIME_BASE_Q) >= 0) { kf->index++; goto force_keyframe; } else if (kf->pexpr) { @@ -780,7 +780,7 @@ static enum AVPictureType forced_kf_apply(void *logctx, KeyframeForceCtx *kf, kf->expr_const_values[FKF_N_FORCED] += 1; goto force_keyframe; } -} else if (kf->type == KF_FORCE_SOURCE && (in_picture->flags & AV_FRAME_FLAG_KEY)) { +} else if (kf->type == KF_FORCE_SOURCE && (frame->flags & AV_FRAME_FLAG_KEY)) { goto force_keyframe; } @@ -801,7 +801,7 @@ static int do_video_out(OutputFile *of, OutputStream *ost, return AVERROR_EOF; in_picture->quality = enc->global_quality; -in_picture->pict_type = forced_kf_apply(ost, &ost->kf, enc->time_base, in_picture); +in_picture->pict_type = forced_kf_apply(ost, &ost->kf, in_picture); #if FFMPEG_OPT_TOP if (ost->top_field_first >= 0) { -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 09/18] fftools/ffmpeg: simplify propagating fallback parameters from decoders to filters
Current callstack looks like this: * ifilter_bind_ist() (filter) calls ist_filter_add() (demuxer); * ist_filter_add() opens the decoder, and then calls dec_add_filter() (decoder); * dec_add_filter() calls ifilter_parameters_from_dec() (i.e. back into the filtering code) in order to give post-avcodec_open2() parameters to the filter. This is unnecessarily complicated. Pass the parameters as follows instead: * dec_init() (which opens the decoder) returns post-avcodec_open2() parameters to its caller (i.e. the demuxer) in a parameter-only AVFrame * the demuxer passes these parameters to the filter in InputFilterOptions, together with other filter options --- fftools/ffmpeg.h| 9 --- fftools/ffmpeg_dec.c| 36 ++ fftools/ffmpeg_demux.c | 25 ++ fftools/ffmpeg_filter.c | 57 - 4 files changed, 67 insertions(+), 60 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index d3e03543ac..1a60f035b0 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -259,6 +259,8 @@ typedef struct InputFilterOptions { // a combination of IFILTER_FLAG_* unsignedflags; + +AVFrame*fallback; } InputFilterOptions; typedef struct InputFilter { @@ -735,16 +737,17 @@ AVBufferRef *hw_device_for_filter(void); /** * @param dec_opts Dictionary filled with decoder options. Its ownership * is transferred to the decoder. + * @param param_out If non-NULL, media properties after opening the decoder + * are written here. * * @retval ">=0" non-negative scheduler index on success * @retval "<0" an error code on failure */ int dec_init(Decoder **pdec, Scheduler *sch, - AVDictionary **dec_opts, const DecoderOpts *o); + AVDictionary **dec_opts, const DecoderOpts *o, + AVFrame *param_out); void dec_free(Decoder **pdec); -int dec_add_filter(Decoder *dec, InputFilter *ifilter); - int enc_alloc(Encoder **penc, const AVCodec *codec, Scheduler *sch, unsigned sch_idx); void enc_free(Encoder **penc); diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c index af57b2bb9d..7005ada527 100644 --- a/fftools/ffmpeg_dec.c +++ b/fftools/ffmpeg_dec.c @@ -1066,7 +1066,8 @@ static int hw_device_setup_for_decode(DecoderPriv *dp, return 0; } -static int dec_open(DecoderPriv *dp, AVDictionary **dec_opts, const DecoderOpts *o) +static int dec_open(DecoderPriv *dp, AVDictionary **dec_opts, +const DecoderOpts *o, AVFrame *param_out) { const AVCodec *codec = o->codec; int ret; @@ -1140,11 +1141,32 @@ static int dec_open(DecoderPriv *dp, AVDictionary **dec_opts, const DecoderOpts dp->dec.subtitle_header = dp->dec_ctx->subtitle_header; dp->dec.subtitle_header_size = dp->dec_ctx->subtitle_header_size; +if (param_out) { +if (dp->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) { +param_out->format = dp->dec_ctx->sample_fmt; +param_out->sample_rate = dp->dec_ctx->sample_rate; + +ret = av_channel_layout_copy(¶m_out->ch_layout, &dp->dec_ctx->ch_layout); +if (ret < 0) +return ret; +} else if (dp->dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO) { +param_out->format = dp->dec_ctx->pix_fmt; +param_out->width= dp->dec_ctx->width; +param_out->height = dp->dec_ctx->height; +param_out->sample_aspect_ratio = dp->dec_ctx->sample_aspect_ratio; +param_out->colorspace = dp->dec_ctx->colorspace; +param_out->color_range = dp->dec_ctx->color_range; +} + +param_out->time_base = dp->dec_ctx->pkt_timebase; +} + return 0; } int dec_init(Decoder **pdec, Scheduler *sch, - AVDictionary **dec_opts, const DecoderOpts *o) + AVDictionary **dec_opts, const DecoderOpts *o, + AVFrame *param_out) { DecoderPriv *dp; int ret; @@ -1155,7 +1177,7 @@ int dec_init(Decoder **pdec, Scheduler *sch, if (ret < 0) return ret; -ret = dec_open(dp, dec_opts, o); +ret = dec_open(dp, dec_opts, o, param_out); if (ret < 0) goto fail; @@ -1166,11 +1188,3 @@ fail: dec_free((Decoder**)&dp); return ret; } - -int dec_add_filter(Decoder *dec, InputFilter *ifilter) -{ -DecoderPriv *dp = dp_from_dec(dec); - -// initialize fallback parameters for filtering -return ifilter_parameters_from_dec(ifilter, dp->dec_ctx); -} diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index ae0f635d8c..032a96567f 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -81,6 +81,8 @@ typedef struct DemuxStream { AVDictionary*decoder_opts; DecoderOpts dec_opts; char dec_name[16]; +// dec
[FFmpeg-devel] [PATCH 02/18] fftools/ffmpeg_filter: refactor setting input timebase
Treat it analogously to stream parameters like format/dimensions/etc. This is functionally different from previous code in 2 ways: * for non-CFR video, the frame timebase (set by the decoder) is used rather than the demuxer timebase * for sub2video, AV_TIME_BASE_Q is used, which is hardcoded by the subtitle decoding API These changes should avoid unnecessary and potentially lossy timestamp conversions from decoder timebase into the demuxer one. Changes the timebases used in sub2video tests. --- fftools/ffmpeg_filter.c | 17 ++- tests/ref/fate/sub2video_basic| 182 +- tests/ref/fate/sub2video_time_limited | 8 +- 3 files changed, 106 insertions(+), 101 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 13c5065191..9d9762a599 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -148,6 +148,8 @@ typedef struct InputFilterPriv { // fallback parameters to use when no input is ever sent struct { +AVRational time_base; + int format; int width; @@ -696,6 +698,8 @@ static int ifilter_bind_ist(InputFilter *ifilter, InputStream *ist) palettes for all rectangles are identical or compatible */ ifp->format = AV_PIX_FMT_RGB32; +ifp->time_base = AV_TIME_BASE_Q; + av_log(fgp, AV_LOG_VERBOSE, "sub2video: using %dx%d canvas\n", ifp->width, ifp->height); } @@ -1469,7 +1473,6 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph, AVFilterContext *last_filter; const AVFilter *buffer_filt = avfilter_get_by_name("buffer"); const AVPixFmtDescriptor *desc; -InputStream *ist = ifp->ist; AVRational fr = ifp->opts.framerate; AVRational sar; AVBPrint args; @@ -1482,9 +1485,6 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph, if (ifp->type_src == AVMEDIA_TYPE_SUBTITLE) sub2video_prepare(ifp); -ifp->time_base = (ifp->opts.flags & IFILTER_FLAG_CFR) ? - av_inv_q(ifp->opts.framerate) : ist->st->time_base; - sar = ifp->sample_aspect_ratio; if(!sar.den) sar = (AVRational){0,1}; @@ -1575,8 +1575,6 @@ static int configure_input_audio_filter(FilterGraph *fg, AVFilterGraph *graph, char name[255]; int ret, pad_idx = 0; -ifp->time_base = (AVRational){ 1, ifp->sample_rate }; - av_bprint_init(&args, 0, AV_BPRINT_SIZE_AUTOMATIC); av_bprintf(&args, "time_base=%d/%d:sample_rate=%d:sample_fmt=%s", ifp->time_base.num, ifp->time_base.den, @@ -1804,6 +1802,8 @@ int ifilter_parameters_from_dec(InputFilter *ifilter, const AVCodecContext *dec) { InputFilterPriv *ifp = ifp_from_ifilter(ifilter); +ifp->fallback.time_base = dec->pkt_timebase; + if (dec->codec_type == AVMEDIA_TYPE_VIDEO) { ifp->fallback.format = dec->pix_fmt; ifp->fallback.width = dec->width; @@ -1835,6 +1835,10 @@ static int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *fr if (ret < 0) return ret; +ifp->time_base = (ifp->type == AVMEDIA_TYPE_AUDIO)? (AVRational){ 1, frame->sample_rate } : + (ifp->opts.flags & IFILTER_FLAG_CFR) ? av_inv_q(ifp->opts.framerate) : + frame->time_base; + ifp->format = frame->format; ifp->width = frame->width; @@ -2524,6 +2528,7 @@ static int send_eof(FilterGraphThread *fgt, InputFilter *ifilter, ifp->sample_aspect_ratio= ifp->fallback.sample_aspect_ratio; ifp->color_space= ifp->fallback.color_space; ifp->color_range= ifp->fallback.color_range; +ifp->time_base = ifp->fallback.time_base; ret = av_channel_layout_copy(&ifp->ch_layout, &ifp->fallback.ch_layout); diff --git a/tests/ref/fate/sub2video_basic b/tests/ref/fate/sub2video_basic index a6eb1a34ea..2e4dcb625e 100644 --- a/tests/ref/fate/sub2video_basic +++ b/tests/ref/fate/sub2video_basic @@ -1,95 +1,95 @@ -#tb 0: 1/1000 +#tb 0: 1/100 #media_type 0: video #codec_id 0: rawvideo #dimensions 0: 720x480 #sar 0: 0/1 -0, 132499, 132499,0, 1382400, 0x -0, 132499, 132499,0, 1382400, 0x8c93c2ba -0, 137459, 137459,0, 1382400, 0x -0, 147355, 147355,0, 1382400, 0xb02e32ca -0, 152088, 152088,0, 1382400, 0x -0, 180797, 180797,0, 1382400, 0x83b71116 -0, 183357, 183357,0, 1382400, 0x -0, 183433, 183433,0, 1382400, 0x85547fd1 -0, 185799, 185799,0, 1382400, 0x -0, 185909, 185909,0, 1382400, 0x -0, 185910, 185910,0,
[FFmpeg-devel] [PATCH 06/18] fftools/ffmpeg_opt: merge init_complex_filters() and check_filter_outputs()
The first of these binds inputs of complex filtergraphs to demuxer streams (with a misleading comment claiming it *creates* complex filtergraphs). The second ensures that all filtergraph outputs are connected to an encoder. Merge them into a single function, which simplifies the ffmpeg_filter API, is shorter, and will also be useful in following commits. Also, rename misleadingly-named init_input_filter() to fg_complex_bind_input(). --- fftools/ffmpeg.h| 3 +-- fftools/ffmpeg_filter.c | 38 ++ fftools/ffmpeg_opt.c| 32 +--- 3 files changed, 28 insertions(+), 45 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 6b049e329b..d3e03543ac 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -671,12 +671,11 @@ int find_codec(void *logctx, const char *name, enum AVMediaType type, int encoder, const AVCodec **codec); int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global); -int check_filter_outputs(void); int filtergraph_is_simple(const FilterGraph *fg); int init_simple_filtergraph(InputStream *ist, OutputStream *ost, char *graph_desc, Scheduler *sch, unsigned sch_idx_enc); -int init_complex_filtergraph(FilterGraph *fg); +int fg_finalise_bindings(FilterGraph *fg); /** * Get our axiliary frame data attached to the frame, allocating it diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 37705297fb..7425e3d2ed 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1096,7 +1096,7 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost, return 0; } -static int init_input_filter(FilterGraph *fg, InputFilter *ifilter) +static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter) { FilterGraphPriv *fgp = fgp_from_fg(fg); InputFilterPriv *ifp = ifp_from_ifilter(ifilter); @@ -1162,14 +1162,29 @@ static int init_input_filter(FilterGraph *fg, InputFilter *ifilter) return 0; } -int init_complex_filtergraph(FilterGraph *fg) +int fg_finalise_bindings(FilterGraph *fg) { // bind filtergraph inputs to input streams for (int i = 0; i < fg->nb_inputs; i++) { -int ret = init_input_filter(fg, fg->inputs[i]); +InputFilterPriv *ifp = ifp_from_ifilter(fg->inputs[i]); +int ret; + +if (ifp->bound) +continue; + +ret = fg_complex_bind_input(fg, &ifp->ifilter); if (ret < 0) return ret; } + +for (int i = 0; i < fg->nb_outputs; i++) { +OutputFilter *output = fg->outputs[i]; +if (!output->ost) { +av_log(filtergraphs[i], AV_LOG_FATAL, + "Filter %s has an unconnected output\n", output->name); +return AVERROR(EINVAL); +} +} return 0; } @@ -1436,23 +1451,6 @@ static int configure_output_filter(FilterGraph *fg, AVFilterGraph *graph, } } -int check_filter_outputs(void) -{ -for (int i = 0; i < nb_filtergraphs; i++) { -int n; -for (n = 0; n < filtergraphs[i]->nb_outputs; n++) { -OutputFilter *output = filtergraphs[i]->outputs[n]; -if (!output->ost) { -av_log(filtergraphs[i], AV_LOG_FATAL, - "Filter %s has an unconnected output\n", output->name); -return AVERROR(EINVAL); -} -} -} - -return 0; -} - static void sub2video_prepare(InputFilterPriv *ifp) { ifp->sub2video.last_pts = INT64_MIN; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index a9a785a0ac..b550382b4c 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -674,18 +674,6 @@ static int opt_streamid(void *optctx, const char *opt, const char *arg) return av_dict_set(&o->streamid, idx_str, p, 0); } -static int init_complex_filters(void) -{ -int i, ret = 0; - -for (i = 0; i < nb_filtergraphs; i++) { -ret = init_complex_filtergraph(filtergraphs[i]); -if (ret < 0) -return ret; -} -return 0; -} - static int opt_target(void *optctx, const char *opt, const char *arg) { OptionsContext *o = optctx; @@ -1264,13 +1252,6 @@ int ffmpeg_parse_options(int argc, char **argv, Scheduler *sch) goto fail; } -/* create the complex filtergraphs */ -ret = init_complex_filters(); -if (ret < 0) { -errmsg = "initializing complex filters"; -goto fail; -} - /* open output files */ ret = open_files(&octx.groups[GROUP_OUTFILE], "output", sch, of_open); if (ret < 0) { @@ -1278,16 +1259,21 @@ int ffmpeg_parse_options(int argc, char **argv, Scheduler *sch) goto fail; } +// bind unbound filtegraph inputs/outputs and check consistency +for (int i = 0; i < nb_filtergraphs; i++) { +ret = fg_finalise_bindings(filtergraphs[i]); +if (ret < 0)
[FFmpeg-devel] [PATCH 13/18] fftools/ffmpeg_sched: allow encoders to send to multiple destinations
Will become useful in following commits. --- fftools/ffmpeg_sched.c | 117 ++--- 1 file changed, 98 insertions(+), 19 deletions(-) diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c index cf9b0c836e..e5435dd866 100644 --- a/fftools/ffmpeg_sched.c +++ b/fftools/ffmpeg_sched.c @@ -104,7 +104,9 @@ typedef struct SchEnc { const AVClass *class; SchedulerNode src; -SchedulerNode dst; +SchedulerNode *dst; +uint8_t*dst_finished; +unsigned nb_dst; // [0] - index of the sync queue in Scheduler.sq_enc, // [1] - index of this encoder in the sq @@ -134,7 +136,9 @@ typedef struct SchEnc { ThreadQueue*queue; // tq_send() to queue returned EOF int in_finished; -int out_finished; + +// temporary storage used by sch_enc_send() +AVPacket *send_pkt; } SchEnc; typedef struct SchDemuxStream { @@ -569,6 +573,11 @@ void sch_free(Scheduler **psch) SchEnc *enc = &sch->enc[i]; tq_free(&enc->queue); + +av_packet_free(&enc->send_pkt); + +av_freep(&enc->dst); +av_freep(&enc->dst_finished); } av_freep(&sch->enc); @@ -819,6 +828,10 @@ int sch_add_enc(Scheduler *sch, SchThreadFunc func, void *ctx, task_init(sch, &enc->task, SCH_NODE_TYPE_ENC, idx, func, ctx); +enc->send_pkt = av_packet_alloc(); +if (!enc->send_pkt) +return AVERROR(ENOMEM); + ret = queue_alloc(&enc->queue, 1, 0, QUEUE_FRAMES); if (ret < 0) return ret; @@ -1048,9 +1061,14 @@ int sch_connect(Scheduler *sch, SchedulerNode src, SchedulerNode dst) enc = &sch->enc[src.idx]; ms = &sch->mux[dst.idx].streams[dst.idx_stream]; -av_assert0(!enc->dst.type && !ms->src.type); -enc->dst = dst; -ms->src = src; +av_assert0(!ms->src.type); + +ret = GROW_ARRAY(enc->dst, enc->nb_dst); +if (ret < 0) +return ret; + +enc->dst[enc->nb_dst - 1] = dst; +ms->src = src; break; } @@ -1339,12 +1357,16 @@ int sch_start(Scheduler *sch) "Encoder not connected to a source\n"); return AVERROR(EINVAL); } -if (!enc->dst.type) { +if (!enc->nb_dst) { av_log(enc, AV_LOG_ERROR, - "Encoder not connected to a sink\n"); + "Encoder not connected to any sink\n"); return AVERROR(EINVAL); } +enc->dst_finished = av_calloc(enc->nb_dst, sizeof(*enc->dst_finished)); +if (!enc->dst_finished) +return AVERROR(ENOMEM); + ret = task_start(&enc->task); if (ret < 0) return ret; @@ -1518,15 +1540,21 @@ static int send_to_enc_sq(Scheduler *sch, SchEnc *enc, AVFrame *frame) // TODO: consider a cleaner way of passing this information through // the pipeline if (!frame) { -SchMux *mux = &sch->mux[enc->dst.idx]; -SchMuxStream *ms = &mux->streams[enc->dst.idx_stream]; +for (unsigned i = 0; i < enc->nb_dst; i++) { +SchMux *mux; +SchMuxStream *ms; -pthread_mutex_lock(&sch->schedule_lock); -ms->source_finished = 1; -schedule_update_locked(sch); +mux = &sch->mux[enc->dst[i].idx]; +ms = &mux->streams[enc->dst[i].idx_stream]; -pthread_mutex_unlock(&sch->schedule_lock); +pthread_mutex_lock(&sch->schedule_lock); + +ms->source_finished = 1; +schedule_update_locked(sch); + +pthread_mutex_unlock(&sch->schedule_lock); +} } pthread_mutex_lock(&sq->lock); @@ -2080,20 +2108,64 @@ int sch_enc_receive(Scheduler *sch, unsigned enc_idx, AVFrame *frame) return ret; } +static int enc_send_to_dst(Scheduler *sch, const SchedulerNode dst, + uint8_t *dst_finished, AVPacket *pkt) +{ +int ret; + +if (*dst_finished) +return AVERROR_EOF; + +if (!pkt) +goto finish; + +ret = send_to_mux(sch, &sch->mux[dst.idx], dst.idx_stream, pkt); +if (ret == AVERROR_EOF) +goto finish; + +return ret; + +finish: +send_to_mux(sch, &sch->mux[dst.idx], dst.idx_stream, NULL); + +*dst_finished = 1; + +return AVERROR_EOF; +} + int sch_enc_send(Scheduler *sch, unsigned enc_idx, AVPacket *pkt) { SchEnc *enc; int ret; +unsigned nb_done = 0; av_assert0(enc_idx < sch->nb_enc); enc = &sch->enc[enc_idx]; -if (enc->out_finished) -return pkt ? AVERROR_EOF : 0; +for (unsigned i = 0; i < enc->nb_dst; i++) { +uint8_t *finished = &enc->dst_finished[i]; +AVPacket *to_send = pkt; -ret = send_to_mux(sch, &sch->mux[enc->dst.idx], enc->dst.idx_stream, pkt); -if (ret < 0) -enc->out_finished = 1; +
[FFmpeg-devel] [PATCH 08/18] fftools/ffmpeg_filter: add logging for binding inputs to demuxer streams
--- fftools/ffmpeg_filter.c | 8 1 file changed, 8 insertions(+) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index eb8d0aee78..7aa9305c88 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1142,6 +1142,10 @@ static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter) return AVERROR(EINVAL); } ist = input_files[file_idx]->streams[st->index]; + +av_log(fg, AV_LOG_VERBOSE, + "Binding input with label '%s' to input stream %d:%d\n", + ifp->linklabel, ist->file->index, ist->index); } else { ist = ist_find_unused(type); if (!ist) { @@ -1149,6 +1153,10 @@ static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter) "unlabeled input pad %s\n", ifilter->name); return AVERROR(EINVAL); } + +av_log(fg, AV_LOG_VERBOSE, + "Binding unlabeled input %d to input stream %d:%d\n", + ifp->index, ist->file->index, ist->index); } av_assert0(ist); -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 14/18] fftools/ffmpeg_sched: factor initializing nodes into separate function
Will be useful in following commits. --- fftools/ffmpeg_sched.c | 151 + 1 file changed, 91 insertions(+), 60 deletions(-) diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c index e5435dd866..5f8ef04680 100644 --- a/fftools/ffmpeg_sched.c +++ b/fftools/ffmpeg_sched.c @@ -1303,11 +1303,65 @@ static void schedule_update_locked(Scheduler *sch) } -int sch_start(Scheduler *sch) +static int start_prepare(Scheduler *sch) { int ret; -sch->transcode_started = 1; +for (unsigned i = 0; i < sch->nb_demux; i++) { +SchDemux *d = &sch->demux[i]; + +for (unsigned j = 0; j < d->nb_streams; j++) { +SchDemuxStream *ds = &d->streams[j]; + +if (!ds->nb_dst) { +av_log(d, AV_LOG_ERROR, + "Demuxer stream %u not connected to any sink\n", j); +return AVERROR(EINVAL); +} + +ds->dst_finished = av_calloc(ds->nb_dst, sizeof(*ds->dst_finished)); +if (!ds->dst_finished) +return AVERROR(ENOMEM); +} +} + +for (unsigned i = 0; i < sch->nb_dec; i++) { +SchDec *dec = &sch->dec[i]; + +if (!dec->src.type) { +av_log(dec, AV_LOG_ERROR, + "Decoder not connected to a source\n"); +return AVERROR(EINVAL); +} +if (!dec->nb_dst) { +av_log(dec, AV_LOG_ERROR, + "Decoder not connected to any sink\n"); +return AVERROR(EINVAL); +} + +dec->dst_finished = av_calloc(dec->nb_dst, sizeof(*dec->dst_finished)); +if (!dec->dst_finished) +return AVERROR(ENOMEM); +} + +for (unsigned i = 0; i < sch->nb_enc; i++) { +SchEnc *enc = &sch->enc[i]; + +if (!enc->src.type) { +av_log(enc, AV_LOG_ERROR, + "Encoder not connected to a source\n"); +return AVERROR(EINVAL); +} +if (!enc->nb_dst) { +av_log(enc, AV_LOG_ERROR, + "Encoder not connected to any sink\n"); +return AVERROR(EINVAL); +} + +enc->dst_finished = av_calloc(enc->nb_dst, sizeof(*enc->dst_finished)); +if (!enc->dst_finished) +return AVERROR(ENOMEM); +} for (unsigned i = 0; i < sch->nb_mux; i++) { SchMux *mux = &sch->mux[i]; @@ -1341,35 +1395,6 @@ int sch_start(Scheduler *sch) QUEUE_PACKETS); if (ret < 0) return ret; - -if (mux->nb_streams_ready == mux->nb_streams) { -ret = mux_init(sch, mux); -if (ret < 0) -return ret; -} -} - -for (unsigned i = 0; i < sch->nb_enc; i++) { -SchEnc *enc = &sch->enc[i]; - -if (!enc->src.type) { -av_log(enc, AV_LOG_ERROR, - "Encoder not connected to a source\n"); -return AVERROR(EINVAL); -} -if (!enc->nb_dst) { -av_log(enc, AV_LOG_ERROR, - "Encoder not connected to any sink\n"); -return AVERROR(EINVAL); -} - -enc->dst_finished = av_calloc(enc->nb_dst, sizeof(*enc->dst_finished)); -if (!enc->dst_finished) -return AVERROR(ENOMEM); - -ret = task_start(&enc->task); -if (ret < 0) -return ret; } for (unsigned i = 0; i < sch->nb_filters; i++) { @@ -1396,6 +1421,41 @@ int sch_start(Scheduler *sch) return AVERROR(EINVAL); } } +} + +return 0; +} + +int sch_start(Scheduler *sch) +{ +int ret; + +ret = start_prepare(sch); +if (ret < 0) +return ret; + +sch->transcode_started = 1; + +for (unsigned i = 0; i < sch->nb_mux; i++) { +SchMux *mux = &sch->mux[i]; + +if (mux->nb_streams_ready == mux->nb_streams) { +ret = mux_init(sch, mux); +if (ret < 0) +return ret; +} +} + +for (unsigned i = 0; i < sch->nb_enc; i++) { +SchEnc *enc = &sch->enc[i]; + +ret = task_start(&enc->task); +if (ret < 0) +return ret; +} + +for (unsigned i = 0; i < sch->nb_filters; i++) { +SchFilterGraph *fg = &sch->filters[i]; ret = task_start(&fg->task); if (ret < 0) @@ -1405,21 +1465,6 @@ int sch_start(Scheduler *sch) for (unsigned i = 0; i < sch->nb_dec; i++) { SchDec *dec = &sch->dec[i]; -if (!dec->src.type) { -av_log(dec, AV_LOG_ERROR, - "Decoder not connected to a source\n"); -return AVERROR(EINVAL); -} -if (!dec->nb_dst) { -av_log(dec, AV_LOG_ERROR, - "Decoder not connected to any sink\n"); -return AVERROR(EINVAL); -} - -dec->dst_finished = av_calloc(dec->nb_dst, sizeof(*dec->dst_finished)); -if (!dec->dst_finishe
[FFmpeg-devel] [PATCH 10/18] fftools/ffmpeg: remove unncessary casts for *_thread() return values
These functions used to be passed directly to pthread_create(), which required them to return void*. This is no longer the case, so they can return a plain int. --- fftools/ffmpeg.h| 4 ++-- fftools/ffmpeg_dec.c| 6 +++--- fftools/ffmpeg_demux.c | 4 ++-- fftools/ffmpeg_enc.c| 4 ++-- fftools/ffmpeg_filter.c | 6 +++--- fftools/ffmpeg_mux.c| 4 ++-- fftools/ffmpeg_sched.c | 2 +- fftools/ffmpeg_sched.h | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 1a60f035b0..1966817bc3 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -832,7 +832,7 @@ void update_benchmark(const char *fmt, ...); const char *opt_match_per_type_str(const SpecifierOptList *sol, char mediatype); -void *muxer_thread(void *arg); -void *encoder_thread(void *arg); +int muxer_thread(void *arg); +int encoder_thread(void *arg); #endif /* FFTOOLS_FFMPEG_H */ diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c index 7005ada527..3bf7ab4960 100644 --- a/fftools/ffmpeg_dec.c +++ b/fftools/ffmpeg_dec.c @@ -124,7 +124,7 @@ static const AVClass dec_class = { .item_name = dec_item_name, }; -static void *decoder_thread(void *arg); +static int decoder_thread(void *arg); static int dec_alloc(DecoderPriv **pdec, Scheduler *sch, int send_end_ts) { @@ -789,7 +789,7 @@ fail: return AVERROR(ENOMEM); } -static void *decoder_thread(void *arg) +static int decoder_thread(void *arg) { DecoderPriv *dp = arg; DecThreadContext dt; @@ -884,7 +884,7 @@ static void *decoder_thread(void *arg) finish: dec_thread_uninit(&dt); -return (void*)(intptr_t)ret; +return ret; } static enum AVPixelFormat get_format(AVCodecContext *s, const enum AVPixelFormat *pix_fmts) diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 032a96567f..47312c9fe1 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -675,7 +675,7 @@ static int demux_thread_init(DemuxThreadContext *dt) return 0; } -static void *input_thread(void *arg) +static int input_thread(void *arg) { Demuxer *d = arg; InputFile *f = &d->f; @@ -780,7 +780,7 @@ static void *input_thread(void *arg) finish: demux_thread_uninit(&dt); -return (void*)(intptr_t)ret; +return ret; } static void demux_final_stats(Demuxer *d) diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index bdba50df03..1ddef46d03 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -870,7 +870,7 @@ fail: return AVERROR(ENOMEM); } -void *encoder_thread(void *arg) +int encoder_thread(void *arg) { OutputStream *ost = arg; Encoder*e = ost->enc; @@ -948,5 +948,5 @@ void *encoder_thread(void *arg) finish: enc_thread_uninit(&et); -return (void*)(intptr_t)ret; +return ret; } diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 6438cbd73b..a29008387a 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -626,7 +626,7 @@ static int ifilter_has_all_input_formats(FilterGraph *fg) return 1; } -static void *filter_thread(void *arg); +static int filter_thread(void *arg); static char *describe_filter_link(FilterGraph *fg, AVFilterInOut *inout, int in) { @@ -2735,7 +2735,7 @@ fail: return AVERROR(ENOMEM); } -static void *filter_thread(void *arg) +static int filter_thread(void *arg) { FilterGraphPriv *fgp = arg; FilterGraph *fg = &fgp->fg; @@ -2849,7 +2849,7 @@ finish: fg_thread_uninit(&fgt); -return (void*)(intptr_t)ret; +return ret; } void fg_send_command(FilterGraph *fg, double time, const char *target, diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 6ba54b878b..59befefab2 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -404,7 +404,7 @@ fail: return AVERROR(ENOMEM); } -void *muxer_thread(void *arg) +int muxer_thread(void *arg) { Muxer *mux = arg; OutputFile *of = &mux->of; @@ -453,7 +453,7 @@ void *muxer_thread(void *arg) finish: mux_thread_uninit(&mt); -return (void*)(intptr_t)ret; +return ret; } static int of_streamcopy(OutputFile *of, OutputStream *ost, AVPacket *pkt) diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c index 1144fce958..cf9b0c836e 100644 --- a/fftools/ffmpeg_sched.c +++ b/fftools/ffmpeg_sched.c @@ -2226,7 +2226,7 @@ static void *task_wrapper(void *arg) int ret; int err = 0; -ret = (intptr_t)task->func(task->func_arg); +ret = task->func(task->func_arg); if (ret < 0) av_log(task->func_arg, AV_LOG_ERROR, "Task finished with error code: %d (%s)\n", ret, av_err2str(ret)); diff --git a/fftools/ffmpeg_sched.h b/fftools/ffmpeg_sched.h index 95f9c1d4db..fc6711f9c3 100644 --- a/fftools/ffmpeg_sched.h +++ b/fftools/ffmpeg_sched.h @@ -102,7 +102,7 @@ typedef struct SchedulerNode { unsignedidx_stream; }
[FFmpeg-devel] [PATCH 15/18] fftools/ffmpeg_sched: allow connecting encoder output to decoders
--- fftools/ffmpeg_sched.c | 212 ++--- fftools/ffmpeg_sched.h | 8 +- 2 files changed, 181 insertions(+), 39 deletions(-) diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c index 5f8ef04680..d1fb942c34 100644 --- a/fftools/ffmpeg_sched.c +++ b/fftools/ffmpeg_sched.c @@ -1051,24 +1051,43 @@ int sch_connect(Scheduler *sch, SchedulerNode src, SchedulerNode dst) } case SCH_NODE_TYPE_ENC: { SchEnc *enc; -SchMuxStream *ms; av_assert0(src.idx < sch->nb_enc); -// encoding packets go to muxing -av_assert0(dst.type == SCH_NODE_TYPE_MUX && - dst.idx < sch->nb_mux && - dst.idx_stream < sch->mux[dst.idx].nb_streams); enc = &sch->enc[src.idx]; -ms = &sch->mux[dst.idx].streams[dst.idx_stream]; - -av_assert0(!ms->src.type); ret = GROW_ARRAY(enc->dst, enc->nb_dst); if (ret < 0) return ret; enc->dst[enc->nb_dst - 1] = dst; -ms->src = src; + +// encoding packets go to muxing or decoding +switch (dst.type) { +case SCH_NODE_TYPE_MUX: { +SchMuxStream *ms; + +av_assert0(dst.idx< sch->nb_mux && + dst.idx_stream < sch->mux[dst.idx].nb_streams); +ms = &sch->mux[dst.idx].streams[dst.idx_stream]; + +av_assert0(!ms->src.type); +ms->src = src; + +break; +} +case SCH_NODE_TYPE_DEC: { +SchDec *dec; + +av_assert0(dst.idx < sch->nb_dec); +dec = &sch->dec[dst.idx]; + +av_assert0(!dec->src.type); +dec->src = src; + +break; +} +default: av_assert0(0); +} break; } @@ -1217,6 +1236,31 @@ int sch_mux_sub_heartbeat_add(Scheduler *sch, unsigned mux_idx, unsigned stream_ return 0; } +static void unchoke_for_stream(Scheduler *sch, SchedulerNode src) +{ +while (1) { +SchFilterGraph *fg; + +// fed directly by a demuxer (i.e. not through a filtergraph) +if (src.type == SCH_NODE_TYPE_DEMUX) { +sch->demux[src.idx].waiter.choked_next = 0; +return; +} + +av_assert0(src.type == SCH_NODE_TYPE_FILTER_OUT); +fg = &sch->filters[src.idx]; + +// the filtergraph contains internal sources and +// requested to be scheduled directly +if (fg->best_input == fg->nb_inputs) { +fg->waiter.choked_next = 0; +return; +} + +src = fg->inputs[fg->best_input].src_sched; +} +} + static void schedule_update_locked(Scheduler *sch) { int64_t dts; @@ -1245,7 +1289,6 @@ static void schedule_update_locked(Scheduler *sch) for (unsigned j = 0; j < mux->nb_streams; j++) { SchMuxStream *ms = &mux->streams[j]; -SchDemux *d; // unblock sources for output streams that are not finished // and not too far ahead of the trailing stream @@ -1256,28 +1299,9 @@ static void schedule_update_locked(Scheduler *sch) if (dts != AV_NOPTS_VALUE && ms->last_dts - dts >= SCHEDULE_TOLERANCE) continue; -// for outputs fed from filtergraphs, consider that filtergraph's -// best_input information, in other cases there is a well-defined -// source demuxer -if (ms->src_sched.type == SCH_NODE_TYPE_FILTER_OUT) { -SchFilterGraph *fg = &sch->filters[ms->src_sched.idx]; -SchFilterIn *fi; - -// the filtergraph contains internal sources and -// requested to be scheduled directly -if (fg->best_input == fg->nb_inputs) { -fg->waiter.choked_next = 0; -have_unchoked = 1; -continue; -} - -fi = &fg->inputs[fg->best_input]; -d = &sch->demux[fi->src_sched.idx]; -} else -d = &sch->demux[ms->src_sched.idx]; - -d->waiter.choked_next = 0; -have_unchoked = 1; +// resolve the source to unchoke +unchoke_for_stream(sch, ms->src_sched); +have_unchoked = 1; } } @@ -1303,6 +1327,105 @@ static void schedule_update_locked(Scheduler *sch) } +enum { +CYCLE_NODE_NEW = 0, +CYCLE_NODE_STARTED, +CYCLE_NODE_DONE, +}; + +static int +check_acyclic_for_output(const Scheduler *sch, SchedulerNode src, + uint8_t *filters_visited, SchedulerNode *filters_stack) +{ +unsigned nb_filters_stack = 0; + +memset(filters_visited, 0, sch->nb_filters * sizeof(*filters_visited)); + +while (1) { +const SchFilterGraph *fg = &sch->filters[src.idx]; + +filters_visited[src.idx] = CYCLE_NODE_STARTE
[FFmpeg-devel] [PATCH 16/18] fftools/ffmpeg: prepare FrameData for having allocated fields
Will be useful in following commits. --- fftools/ffmpeg.c | 41 +++-- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 2f01a01e2d..ffd25f4c5b 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -402,23 +402,44 @@ InputStream *ist_iter(InputStream *prev) return NULL; } +static void frame_data_free(void *opaque, uint8_t *data) +{ +av_free(data); +} + static int frame_data_ensure(AVBufferRef **dst, int writable) { -if (!*dst) { +AVBufferRef *src = *dst; + +if (!src || (writable && !av_buffer_is_writable(src))) { FrameData *fd; -*dst = av_buffer_allocz(sizeof(*fd)); -if (!*dst) +fd = av_mallocz(sizeof(*fd)); +if (!fd) return AVERROR(ENOMEM); -fd = (FrameData*)((*dst)->data); -fd->dec.frame_num = UINT64_MAX; -fd->dec.pts = AV_NOPTS_VALUE; +*dst = av_buffer_create((uint8_t *)fd, sizeof(*fd), +frame_data_free, NULL, 0); +if (!*dst) { +av_buffer_unref(&src); +av_freep(&fd); +return AVERROR(ENOMEM); +} -for (unsigned i = 0; i < FF_ARRAY_ELEMS(fd->wallclock); i++) -fd->wallclock[i] = INT64_MIN; -} else if (writable) -return av_buffer_make_writable(dst); +if (src) { +const FrameData *fd_src = (const FrameData *)src->data; + +memcpy(fd, fd_src, sizeof(*fd)); + +av_buffer_unref(&src); +} else { +fd->dec.frame_num = UINT64_MAX; +fd->dec.pts = AV_NOPTS_VALUE; + +for (unsigned i = 0; i < FF_ARRAY_ELEMS(fd->wallclock); i++) +fd->wallclock[i] = INT64_MIN; +} +} return 0; } -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 18/18] fftools/ffmpeg_enc: set AV_PKT_FLAG_TRUSTED on encoded packets
This allows using WRAPPED_AVFRAME encoders with loopback decoders in order to connect multiple filtergraphs together. Clear the flag in muxers, since lavf does not need it for anything and it would change the results of framecrc FATE tests. --- fftools/ffmpeg_enc.c | 2 ++ fftools/ffmpeg_mux.c | 1 + 2 files changed, 3 insertions(+) diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index d1dae558e1..c9a12af139 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -706,6 +706,8 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame, return ret; } +pkt->flags |= AV_PKT_FLAG_TRUSTED; + if (enc->codec_type == AVMEDIA_TYPE_VIDEO) { ret = update_video_stats(ost, pkt, !!vstats_filename); if (ret < 0) diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 59befefab2..e8e5c677b8 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -433,6 +433,7 @@ int muxer_thread(void *arg) ost = of->streams[mux->sch_stream_idx[stream_idx]]; mt.pkt->stream_index = ost->index; +mt.pkt->flags &= ~AV_PKT_FLAG_TRUSTED; ret = mux_packet_filter(mux, &mt, ost, ret < 0 ? NULL : mt.pkt, &stream_eof); av_packet_unref(mt.pkt); -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 17/18] fftools/ffmpeg: add loopback decoding
This allows to send an encoder's output back to decoding and feed the result into a complex filtergraph. --- Changelog | 1 + doc/ffmpeg.texi | 49 ++-- fftools/cmdutils.c | 2 +- fftools/cmdutils.h | 7 +- fftools/ffmpeg.c| 26 +++ fftools/ffmpeg.h| 22 ++ fftools/ffmpeg_dec.c| 164 +++- fftools/ffmpeg_enc.c| 19 + fftools/ffmpeg_filter.c | 47 +++- fftools/ffmpeg_opt.c| 13 +++- 10 files changed, 336 insertions(+), 14 deletions(-) diff --git a/Changelog b/Changelog index 0ba3a77c08..22186697fb 100644 --- a/Changelog +++ b/Changelog @@ -31,6 +31,7 @@ version : - removed deprecated ffmpeg CLI options -psnr and -map_channel - DVD-Video demuxer, powered by libdvdnav and libdvdread - ffprobe -show_stream_groups option +- ffmpeg CLI loopback decoders version 6.1: diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index bee3cd4c70..650011e6d2 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -219,6 +219,40 @@ Since there is no decoding or encoding, it is very fast and there is no quality loss. However, it might not work in some cases because of many factors. Applying filters is obviously also impossible, since filters work on uncompressed data. +@section Loopback decoders +While decoders are normally associated with demuxer streams, it is also possible +to create "loopback" decoders that decode the output from some encoder and allow +it to be fed back to complex filtergraphs. This is done with the @code{-dec} +directive, which takes as a parameter the index of the output stream that should +be decoded. Every such directive creates a new loopback decoder, indexed with +successive integers starting at zero. These indices should then be used to refer +to loopback decoders in complex filtergraph link labels, as described in the +documentation for @option{-filter_complex}. + +E.g. the following example: + +@example +ffmpeg -i INPUT \ + -map 0:v:0 -c:v libx264 -crf 45 -f null - \ + -dec 0:0 -filter_complex '[0:v][dec0]hstack[stack]' \ + -map '[stack]' -c:v ffv1 OUTPUT +@end example + +reads an input video and +@itemize +@item +(line 2) encodes it with @code{libx264} at low quality; + +@item +(line 3) decodes this encoded stream and places it side by side with the +original input video; + +@item +(line 4) combined video is then losslessly encoded and written into +@file{OUTPUT}. + +@end itemize + @c man end DETAILED DESCRIPTION @chapter Stream selection @@ -2105,11 +2139,16 @@ type -- see the @option{-filter} options. @var{filtergraph} is a description of the filtergraph, as described in the ``Filtergraph syntax'' section of the ffmpeg-filters manual. -Input link labels must refer to input streams using the -@code{[file_index:stream_specifier]} syntax (i.e. the same as @option{-map} -uses). If @var{stream_specifier} matches multiple streams, the first one will be -used. An unlabeled input will be connected to the first unused input stream of -the matching type. +Input link labels must refer to either input streams or loopback decoders. For +input streams, use the @code{[file_index:stream_specifier]} syntax (i.e. the +same as @option{-map} uses). If @var{stream_specifier} matches multiple streams, +the first one will be used. + +For decoders, the link label must be [dec@var{dec_idx}], where @var{dec_idx} is +the index of the loopback decoder to be connected to given input. + +An unlabeled input will be connected to the first unused input stream of the +matching type. Output link labels are referred to with @option{-map}. Unlabeled outputs are added to the first output file. diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 8efec942bd..f3c258bb99 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -528,7 +528,7 @@ static void check_options(const OptionDef *po) { while (po->name) { if (po->flags & OPT_PERFILE) -av_assert0(po->flags & (OPT_INPUT | OPT_OUTPUT)); +av_assert0(po->flags & (OPT_INPUT | OPT_OUTPUT | OPT_DECODER)); if (po->type == OPT_TYPE_FUNC) av_assert0(!(po->flags & (OPT_FLAG_OFFSET | OPT_FLAG_SPEC))); diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index 86428b3fa4..d0c773663b 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -144,8 +144,8 @@ typedef struct OptionDef { #define OPT_AUDIO (1 << 4) #define OPT_SUBTITLE(1 << 5) #define OPT_DATA(1 << 6) -/* The option is per-file (currently ffmpeg-only). At least one of OPT_INPUT or - * OPT_OUTPUT must be set when this flag is in use. +/* The option is per-file (currently ffmpeg-only). At least one of OPT_INPUT, + * OPT_OUTPUT, OPT_DECODER must be set when this flag is in use. */ #define OPT_PERFILE (1 << 7) @@ -175,6 +175,9 @@ typedef struct OptionDef { * name is stored in u1.name_canon */ #define OPT_HAS_CANON (1
[FFmpeg-devel] [PATCH 12/18] fftools/ffmpeg_enc: merge do_{audio, video}_out into frame_encode()
These functions used to be much longer, but now they are only a couple lines each, some of them duplicated between audio and video. --- fftools/ffmpeg_enc.c | 65 +++- 1 file changed, 22 insertions(+), 43 deletions(-) diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index f0a17228fe..88635629f7 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -727,24 +727,6 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame, av_assert0(0); } -static int do_audio_out(OutputFile *of, OutputStream *ost, -AVFrame *frame, AVPacket *pkt) -{ -AVCodecContext *enc = ost->enc_ctx; - -if (!(enc->codec->capabilities & AV_CODEC_CAP_PARAM_CHANGE) && -enc->ch_layout.nb_channels != frame->ch_layout.nb_channels) { -av_log(ost, AV_LOG_ERROR, - "Audio channel count changed and encoder does not support parameter changes\n"); -return 0; -} - -if (!check_recording_time(ost, frame->pts, frame->time_base)) -return AVERROR_EOF; - -return encode_frame(of, ost, frame, pkt); -} - static enum AVPictureType forced_kf_apply(void *logctx, KeyframeForceCtx *kf, const AVFrame *frame) { @@ -791,28 +773,6 @@ force_keyframe: return AV_PICTURE_TYPE_I; } -/* May modify/reset frame */ -static int do_video_out(OutputFile *of, OutputStream *ost, -AVFrame *in_picture, AVPacket *pkt) -{ -AVCodecContext *enc = ost->enc_ctx; - -if (!check_recording_time(ost, in_picture->pts, ost->enc_ctx->time_base)) -return AVERROR_EOF; - -in_picture->quality = enc->global_quality; -in_picture->pict_type = forced_kf_apply(ost, &ost->kf, in_picture); - -#if FFMPEG_OPT_TOP -if (ost->top_field_first >= 0) { -in_picture->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST; -in_picture->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * (!!ost->top_field_first); -} -#endif - -return encode_frame(of, ost, in_picture, pkt); -} - static int frame_encode(OutputStream *ost, AVFrame *frame, AVPacket *pkt) { OutputFile *of = ost->file; @@ -828,11 +788,30 @@ static int frame_encode(OutputStream *ost, AVFrame *frame, AVPacket *pkt) } if (frame) { -return (type == AVMEDIA_TYPE_VIDEO) ? do_video_out(of, ost, frame, pkt) : - do_audio_out(of, ost, frame, pkt); +if (!check_recording_time(ost, frame->pts, frame->time_base)) +return AVERROR_EOF; + +if (type == AVMEDIA_TYPE_VIDEO) { +frame->quality = ost->enc_ctx->global_quality; +frame->pict_type = forced_kf_apply(ost, &ost->kf, frame); + +#if FFMPEG_OPT_TOP +if (ost->top_field_first >= 0) { +frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST; +frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * (!!ost->top_field_first); +} +#endif +} else { +if (!(ost->enc_ctx->codec->capabilities & AV_CODEC_CAP_PARAM_CHANGE) && +ost->enc_ctx->ch_layout.nb_channels != frame->ch_layout.nb_channels) { +av_log(ost, AV_LOG_ERROR, + "Audio channel count changed and encoder does not support parameter changes\n"); +return 0; +} +} } -return encode_frame(of, ost, NULL, pkt); +return encode_frame(of, ost, frame, pkt); } static void enc_thread_set_name(const OutputStream *ost) -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 07/18] fftools/ffmpeg_filter: move filtergraph input type check to a better place
Perform it right after we figure out what the type is. --- fftools/ffmpeg_filter.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 7425e3d2ed..eb8d0aee78 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1005,6 +1005,14 @@ int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch) ifp->type = avfilter_pad_get_type(cur->filter_ctx->input_pads, cur->pad_idx); + +if (ifp->type != AVMEDIA_TYPE_VIDEO && ifp->type != AVMEDIA_TYPE_AUDIO) { +av_log(fg, AV_LOG_FATAL, "Only video and audio filters supported " + "currently.\n"); +ret = AVERROR(ENOSYS); +goto fail; +} + ifilter->name = describe_filter_link(fg, cur, 1); if (!ifilter->name) { ret = AVERROR(ENOMEM); @@ -1104,13 +1112,6 @@ static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter) enum AVMediaType type = ifp->type; int i, ret; -// TODO: support other filter types -if (type != AVMEDIA_TYPE_VIDEO && type != AVMEDIA_TYPE_AUDIO) { -av_log(fg, AV_LOG_FATAL, "Only video and audio filters supported " - "currently.\n"); -return AVERROR(ENOSYS); -} - if (ifp->linklabel) { AVFormatContext *s; AVStream *st = NULL; -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 05/18] fftools/ffmpeg_dec: factor opening the decoder out of dec_open()
Rename dec_open to dec_init(), as it is more descriptive of its new purpose. Will be useful in following commits, which will add a new path for opening decoders. --- fftools/ffmpeg.h | 2 +- fftools/ffmpeg_dec.c | 61 ++ fftools/ffmpeg_demux.c | 2 +- 3 files changed, 34 insertions(+), 31 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 1c5ebcb43f..6b049e329b 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -740,7 +740,7 @@ AVBufferRef *hw_device_for_filter(void); * @retval ">=0" non-negative scheduler index on success * @retval "<0" an error code on failure */ -int dec_open(Decoder **pdec, Scheduler *sch, +int dec_init(Decoder **pdec, Scheduler *sch, AVDictionary **dec_opts, const DecoderOpts *o); void dec_free(Decoder **pdec); diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c index 98c4a0c83c..af57b2bb9d 100644 --- a/fftools/ffmpeg_dec.c +++ b/fftools/ffmpeg_dec.c @@ -1066,19 +1066,11 @@ static int hw_device_setup_for_decode(DecoderPriv *dp, return 0; } -int dec_open(Decoder **pdec, Scheduler *sch, - AVDictionary **dec_opts, const DecoderOpts *o) +static int dec_open(DecoderPriv *dp, AVDictionary **dec_opts, const DecoderOpts *o) { -DecoderPriv *dp; const AVCodec *codec = o->codec; int ret; -*pdec = NULL; - -ret = dec_alloc(&dp, sch, !!(o->flags & DECODER_FLAG_SEND_END_TS)); -if (ret < 0) -return ret; - dp->flags = o->flags; dp->log_parent = o->log_parent; @@ -1091,39 +1083,31 @@ int dec_open(Decoder **pdec, Scheduler *sch, snprintf(dp->log_name, sizeof(dp->log_name), "dec:%s", codec->name); dp->parent_name = av_strdup(o->name ? o->name : ""); -if (!dp->parent_name) { -ret = AVERROR(ENOMEM); -goto fail; -} +if (!dp->parent_name) +return AVERROR(ENOMEM); if (codec->type == AVMEDIA_TYPE_SUBTITLE && (dp->flags & DECODER_FLAG_FIX_SUB_DURATION)) { for (int i = 0; i < FF_ARRAY_ELEMS(dp->sub_prev); i++) { dp->sub_prev[i] = av_frame_alloc(); -if (!dp->sub_prev[i]) { -ret = AVERROR(ENOMEM); -goto fail; -} +if (!dp->sub_prev[i]) +return AVERROR(ENOMEM); } dp->sub_heartbeat = av_frame_alloc(); -if (!dp->sub_heartbeat) { -ret = AVERROR(ENOMEM); -goto fail; -} +if (!dp->sub_heartbeat) +return AVERROR(ENOMEM); } dp->sar_override = o->par->sample_aspect_ratio; dp->dec_ctx = avcodec_alloc_context3(codec); -if (!dp->dec_ctx) { -ret = AVERROR(ENOMEM); -goto fail; -} +if (!dp->dec_ctx) +return AVERROR(ENOMEM); ret = avcodec_parameters_to_context(dp->dec_ctx, o->par); if (ret < 0) { av_log(dp, AV_LOG_ERROR, "Error initializing the decoder context.\n"); -goto fail; +return ret; } dp->dec_ctx->opaque= dp; @@ -1140,22 +1124,41 @@ int dec_open(Decoder **pdec, Scheduler *sch, av_log(dp, AV_LOG_ERROR, "Hardware device setup failed for decoder: %s\n", av_err2str(ret)); -goto fail; +return ret; } if ((ret = avcodec_open2(dp->dec_ctx, codec, dec_opts)) < 0) { av_log(dp, AV_LOG_ERROR, "Error while opening decoder: %s\n", av_err2str(ret)); -goto fail; +return ret; } ret = check_avoptions(*dec_opts); if (ret < 0) -goto fail; +return ret; dp->dec.subtitle_header = dp->dec_ctx->subtitle_header; dp->dec.subtitle_header_size = dp->dec_ctx->subtitle_header_size; +return 0; +} + +int dec_init(Decoder **pdec, Scheduler *sch, + AVDictionary **dec_opts, const DecoderOpts *o) +{ +DecoderPriv *dp; +int ret; + +*pdec = NULL; + +ret = dec_alloc(&dp, sch, !!(o->flags & DECODER_FLAG_SEND_END_TS)); +if (ret < 0) +return ret; + +ret = dec_open(dp, dec_opts, o); +if (ret < 0) +goto fail; + *pdec = &dp->dec; return dp->sch_idx; diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 29f4a26224..ae0f635d8c 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -935,7 +935,7 @@ static int ist_use(InputStream *ist, int decoding_needed) ds->dec_opts.log_parent = ist; -ret = dec_open(&ist->decoder, d->sch, +ret = dec_init(&ist->decoder, d->sch, &ds->decoder_opts, &ds->dec_opts); if (ret < 0) return ret; -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avcodec/libx264: fix extradata when config annexb=0
From: Zhao Zhili --- configure| 2 +- libavcodec/libx264.c | 148 --- 2 files changed, 125 insertions(+), 25 deletions(-) diff --git a/configure b/configure index bbf1a70731..ef58c3fe97 100755 --- a/configure +++ b/configure @@ -3491,7 +3491,7 @@ libwebp_encoder_deps="libwebp" libwebp_anim_encoder_deps="libwebp" libx262_encoder_deps="libx262" libx264_encoder_deps="libx264" -libx264_encoder_select="atsc_a53" +libx264_encoder_select="atsc_a53 h264parse" libx264rgb_encoder_deps="libx264" libx264rgb_encoder_select="libx264_encoder" libx265_encoder_deps="libx265" diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 10d646bd76..10dfda125d 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -34,9 +34,12 @@ #include "avcodec.h" #include "codec_internal.h" #include "encode.h" +#include "get_bits.h" +#include "h264_ps.h" #include "internal.h" #include "packet_internal.h" #include "atsc_a53.h" +#include "put_bits.h" #include "sei.h" #include @@ -865,6 +868,124 @@ static int convert_pix_fmt(enum AVPixelFormat pix_fmt) return 0; } +static int set_avcc_extradata(AVCodecContext *avctx, x264_nal_t *nal, int nnal) +{ +x264_nal_t *sps_nal = NULL; +x264_nal_t *pps_nal = NULL; +GetBitContext gbc; +PutBitContext pbc; +H264ParamSets ps = { 0 }; +uint8_t *p; +int ret, profile; + +/* We know it's in the order of SPS/PPS/SEI, but it's not documented in x264 API. + * The x264 param i_sps_id implies there is a single pair of SPS/PPS. + */ +for (int i = 0; i < nnal; i++) { +if (nal[i].i_type == NAL_SPS) +sps_nal = &nal[i]; +else if (nal[i].i_type == NAL_PPS) +pps_nal = &nal[i]; +} +av_assert0(sps_nal); +av_assert0(pps_nal); + +// +11 for AVCDecoderConfigurationRecord, will shrink to the real size finally +avctx->extradata_size = sps_nal->i_payload + pps_nal->i_payload + 11; +avctx->extradata = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_MIN_SIZE); +if (!avctx->extradata) +return AVERROR(ENOMEM); + +// Skip size part +p = sps_nal->p_payload + 4; +init_get_bits8(&gbc, p, sps_nal->i_payload - 4); +skip_bits(&gbc, 8); +ret = ff_h264_decode_seq_parameter_set(&gbc, avctx, &ps, 0); +if (ret < 0) +return ret; + +for (int i = 0; i < FF_ARRAY_ELEMS(ps.sps_list); i++) { +if (ps.sps_list[i]) { +ps.sps = ps.sps_list[i]; +break; +} +} + +// Now create AVCDecoderConfigurationRecord +init_put_bits(&pbc, avctx->extradata, avctx->extradata_size); +put_bits(&pbc, 8, 1); // version +put_bits(&pbc, 8, ps.sps->profile_idc); // AVCProfileIndication +put_bits(&pbc, 8, ps.sps->constraint_set_flags); // profile_compatibility +put_bits(&pbc, 8, ps.sps->level_idc); // AVCLevelIndication +put_bits(&pbc, 11, 0x7FF); + +p = sps_nal->p_payload + 4; +put_bits(&pbc, 5, 1); // numOfSequenceParameterSets +put_bits(&pbc, 16, sps_nal->i_payload - 4); // sequenceParameterSetLength +for (int i = 0; i < sps_nal->i_payload - 4; i++) +put_bits(&pbc, 8, p[i]); + +p = pps_nal->p_payload + 4; +put_bits(&pbc, 8, 1); // numOfPictureParameterSets +put_bits(&pbc, 16, pps_nal->i_payload - 4); // pictureParameterSetLength +for (int i = 0; i < pps_nal->i_payload - 4; i++) +put_bits(&pbc, 8, p[i]); + +profile = ps.sps->profile_idc; +if (profile != 66 && profile != 77 && profile != 88) { +put_bits(&pbc, 6, 0x3F); +put_bits(&pbc, 2, ps.sps->chroma_format_idc); +put_bits(&pbc, 5, 0x1F); +put_bits(&pbc, 3, ps.sps->bit_depth_luma - 8); +put_bits(&pbc, 5, 0x1F); +put_bits(&pbc, 3, ps.sps->bit_depth_chroma - 8); +put_bits(&pbc, 8, 0); +} +flush_put_bits(&pbc); +avctx->extradata_size = put_bytes_output(&pbc); + +ff_h264_ps_uninit(&ps); + +return 0; +} + +static int set_extradata(AVCodecContext *avctx) +{ +X264Context *x4 = avctx->priv_data; +x264_nal_t *nal; +uint8_t *p; +int nnal, s; + +s = x264_encoder_headers(x4->enc, &nal, &nnal); +if (s < 0) +return AVERROR_EXTERNAL; + +if (!x4->params.b_annexb) +return set_avcc_extradata(avctx, nal, nnal); + +avctx->extradata = p = av_mallocz(s + AV_INPUT_BUFFER_PADDING_SIZE); +if (!p) +return AVERROR(ENOMEM); + +for (int i = 0; i < nnal; i++) { +/* Don't put the SEI in extradata. */ +if (nal[i].i_type == NAL_SEI) { +av_log(avctx, AV_LOG_INFO, "%s\n", nal[i].p_payload + 25); +x4->sei_size = nal[i].i_payload; +x4->sei = av_malloc(x4->sei_size); +if (!x4->sei) +return AVERROR(ENOMEM); +memcpy(x4->sei, nal[i].p_payload, nal[i].i_payload); +continue; +} +memcpy(p, nal[i].p_payload, nal[i].i_payload); +p +
Re: [FFmpeg-devel] [PATCH 6/9] fftools/ffprobe: export Tile Grid Stream Group parameters
On date Tuesday 2024-03-05 12:50:09 -0300, James Almer wrote: > On 3/5/2024 12:24 PM, Stefano Sabatini wrote: > > On date Tuesday 2024-03-05 12:14:53 -0300, James Almer wrote: > > > On 3/4/2024 9:00 PM, James Almer wrote: > > > > Signed-off-by: James Almer > > > > --- > > > >fftools/ffprobe.c | 41 - > > > >1 file changed, 36 insertions(+), 5 deletions(-) > > [...] > > > > > I think I'll withdraw this patch for now. Some stream group types have > > > several layers of data, so components and pieces would not be enough. This > > > is the case for IAMF Audio Elements and Mix Presentation, for example. > > > A generic way to add N amount of layers would be needed. > > > > I see. > > > > Does it mean that the nesting level is greater than 3 (side_data, > > components, pieces)? > > Yes. Look at AVIAMFMixPresentation, which has an array of AVIAMFSubmix, > which in turn have an array of AVIAMFSubmixLayout plus an array of > AVIAMFSubmixElement per submix, the latter which has a AVIAMFParamDefinition > per element. > If the AVIAMFMixPresentation is the component, the AVIAMFSubmix would be the > piece, and then we ran out of levels. Well, the simplemst approach is to add more levels to the layout (side_data, components, pieces, subpieces?, ...). ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/9] avcodec/bsf/pcm_rechunk: reorder supported codec list
On date Tuesday 2024-03-05 23:51:39 +0100, Marton Balint wrote: > Should be easier to add new codecs by using the same order as in > av_get_exact_bits_per_sample(). > > Signed-off-by: Marton Balint > --- > libavcodec/bsf/pcm_rechunk.c | 21 + > 1 file changed, 13 insertions(+), 8 deletions(-) > > diff --git a/libavcodec/bsf/pcm_rechunk.c b/libavcodec/bsf/pcm_rechunk.c > index 28b5722ac9..9bbc5a74d6 100644 > --- a/libavcodec/bsf/pcm_rechunk.c > +++ b/libavcodec/bsf/pcm_rechunk.c > @@ -193,21 +193,26 @@ static const AVClass pcm_rechunk_class = { > }; > > static const enum AVCodecID codec_ids[] = { > -AV_CODEC_ID_PCM_S16LE, > -AV_CODEC_ID_PCM_S16BE, > +// 8 bit > AV_CODEC_ID_PCM_S8, > -AV_CODEC_ID_PCM_S32LE, > -AV_CODEC_ID_PCM_S32BE, > -AV_CODEC_ID_PCM_S24LE, > +// 16 bit > +AV_CODEC_ID_PCM_S16BE, > +AV_CODEC_ID_PCM_S16LE, > +// 24 bit > AV_CODEC_ID_PCM_S24BE, > +AV_CODEC_ID_PCM_S24LE, > +// 32 bit > +AV_CODEC_ID_PCM_S32BE, > +AV_CODEC_ID_PCM_S32LE, > AV_CODEC_ID_PCM_F32BE, > AV_CODEC_ID_PCM_F32LE, > +AV_CODEC_ID_PCM_F24LE, > +AV_CODEC_ID_PCM_F16LE, > +// 64 bit > AV_CODEC_ID_PCM_F64BE, > AV_CODEC_ID_PCM_F64LE, > -AV_CODEC_ID_PCM_S64LE, > AV_CODEC_ID_PCM_S64BE, > -AV_CODEC_ID_PCM_F16LE, > -AV_CODEC_ID_PCM_F24LE, > +AV_CODEC_ID_PCM_S64LE, > AV_CODEC_ID_NONE, or just use lexical order (given than AV_CODEC_ID_PCM_F24LE/AV_CODEC_ID_PCM_F16LE => 32 might be confusing). ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 07/29] lavc: add a decoder option for configuring side data preference
This and the following commits fix #10857 --- Renamed the option to 'side_data_prefer_packet', as preferred by James and Derek on IRC. --- doc/APIchanges | 3 +++ libavcodec/avcodec.h | 31 +++ libavcodec/decode.c| 36 libavcodec/options_table.h | 12 4 files changed, 82 insertions(+) diff --git a/doc/APIchanges b/doc/APIchanges index a0898dd701..83b24e5b37 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09 API changes, most recent first: +2024-02-xx - xx - lavc 60.xx.100 - avcodec.h + Add AVCodecContext.[nb_]side_data_prefer_packet. + 2024-02-xx - xx - lavu 58.xx.100 - opt.h Add AV_OPT_TYPE_FLAG_ARRAY and AVOptionArrayDef. diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 8aa1356b8c..2e61bef19b 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2120,6 +2120,37 @@ typedef struct AVCodecContext { * an error. */ int64_t frame_num; + +/** + * Decoding only. May be set by the caller before avcodec_open2() to an + * av_malloc()'ed array (or via AVOptions). Owned and freed by the decoder + * afterwards. + * + * Side data attached to decoded frames may come from several sources: + * - coded_side_data, which the decoder will for certain types translate + * from packet-type to frame-type and attach to frames; + * - user-supplied side data attached to an AVPacket sent for decoding (same + * considerations as above); + * - extracted from the coded bytestream. + * The first two cases are supplied by the caller and typically come from a + * container. + * + * This array configures decoder behaviour in case when some side data type + * is present both in the coded bytestream and in the user-supplied side + * data. In all cases, at most one instance of each side data type will be + * attached to output frames. By default it will be the bytestream side + * data. Adding a AVPacketSideDataType value to this array will flip the + * preference for this type, thus making the decoder prefer user-supplied + * side data over bytestream. + * + * The array may also contain a single -1, in which case the preference is + * switched for all side data types. + */ +int*side_data_prefer_packet; +/** + * Number of entries in side_data_prefer_packet. + */ +unsigned nb_side_data_prefer_packet; } AVCodecContext; /** diff --git a/libavcodec/decode.c b/libavcodec/decode.c index cd483528c5..29fe840db7 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -60,6 +60,12 @@ typedef struct DecodeContext { * The caller has submitted a NULL packet on input. */ int draining_started; + +/** + * Bitmask indicating for which side data types we prefer user-supplied + * (global or attached to packets) side data over bytestream. + */ +uint64_t side_data_pref_mask; } DecodeContext; static DecodeContext *decode_ctx(AVCodecInternal *avci) @@ -1744,6 +1750,7 @@ int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) int ff_decode_preinit(AVCodecContext *avctx) { AVCodecInternal *avci = avctx->internal; +DecodeContext *dc = decode_ctx(avci); int ret = 0; /* if the decoder init function was already called previously, @@ -1804,6 +1811,35 @@ int ff_decode_preinit(AVCodecContext *avctx) avctx->export_side_data |= AV_CODEC_EXPORT_DATA_MVS; } +if (avctx->nb_side_data_prefer_packet == 1 && +avctx->side_data_prefer_packet[0] == -1) +dc->side_data_pref_mask = ~0ULL; +else { +for (unsigned i = 0; i < avctx->nb_side_data_prefer_packet; i++) { +int val = avctx->side_data_prefer_packet[i]; + +if (val < 0 || val >= AV_PKT_DATA_NB) { +av_log(avctx, AV_LOG_ERROR, "Invalid side data type: %d\n", val); +return AVERROR(EINVAL); +} + +for (unsigned j = 0; j < FF_ARRAY_ELEMS(sd_global_map); j++) { +if (sd_global_map[j].packet == val) { +val = sd_global_map[j].frame; + +// this code will need to be changed when we have more than +// 64 frame side data types +if (val >= 64) { +av_log(avctx, AV_LOG_ERROR, "Side data type too big\n"); +return AVERROR_BUG; +} + +dc->side_data_pref_mask |= 1ULL << val; +} +} +} +} + avci->in_pkt = av_packet_alloc(); avci->last_pkt_props = av_packet_alloc(); if (!avci->in_pkt || !avci->last_pkt_props) diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index ac32d8928a..55088bd2e4 100644 --- a/
Re: [FFmpeg-devel] [PATCH 2/9] avcodec/bsf/pcm_rechunk: add some more supported PCM formats
On date Tuesday 2024-03-05 23:51:40 +0100, Marton Balint wrote: > Signed-off-by: Marton Balint > --- > libavcodec/bsf/pcm_rechunk.c | 20 +++- > 1 file changed, 19 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/bsf/pcm_rechunk.c b/libavcodec/bsf/pcm_rechunk.c > index 9bbc5a74d6..7198554c17 100644 > --- a/libavcodec/bsf/pcm_rechunk.c > +++ b/libavcodec/bsf/pcm_rechunk.c > @@ -108,6 +108,18 @@ static int get_next_nb_samples(AVBSFContext *ctx) > } > } > > +static void set_silence(AVCodecParameters *par, uint8_t *buf, size_t size) > +{ > +int c = 0; > +switch (par->codec_id) { > +case AV_CODEC_ID_PCM_ALAW: c = 0xd5; break; > +case AV_CODEC_ID_PCM_MULAW: > +case AV_CODEC_ID_PCM_VIDC: c = 0xff; break; > +case AV_CODEC_ID_PCM_U8:c = 0x80; break; > +} > +memset(buf, c, size); > +} Didn't verify these. > + > static int rechunk_filter(AVBSFContext *ctx, AVPacket *pkt) > { > PCMContext *s = ctx->priv_data; > @@ -158,7 +170,7 @@ static int rechunk_filter(AVBSFContext *ctx, AVPacket > *pkt) > ret = ff_bsf_get_packet_ref(ctx, s->in_pkt); > if (ret == AVERROR_EOF && s->out_pkt->size) { > if (s->pad) { > -memset(s->out_pkt->data + s->out_pkt->size, 0, data_size - > s->out_pkt->size); > +set_silence(ctx->par_in, s->out_pkt->data + > s->out_pkt->size, data_size - s->out_pkt->size); > s->out_pkt->size = data_size; > } else { > nb_samples = s->out_pkt->size / s->sample_size; > @@ -194,11 +206,17 @@ static const AVClass pcm_rechunk_class = { > > static const enum AVCodecID codec_ids[] = { > // 8 bit > +AV_CODEC_ID_PCM_ALAW, > +AV_CODEC_ID_PCM_MULAW, > +AV_CODEC_ID_PCM_VIDC, > AV_CODEC_ID_PCM_S8, > +AV_CODEC_ID_PCM_SGA, > +AV_CODEC_ID_PCM_U8, > // 16 bit > AV_CODEC_ID_PCM_S16BE, > AV_CODEC_ID_PCM_S16LE, > // 24 bit > +AV_CODEC_ID_PCM_S24DAUD, > AV_CODEC_ID_PCM_S24BE, > AV_CODEC_ID_PCM_S24LE, > // 32 bit Looks good to me. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 3/9] avformat/daudenc: force 2000 sample packet size with a bsf
On date Tuesday 2024-03-05 23:51:41 +0100, Marton Balint wrote: > The samples I found all have 2000 sample packets, and by forcing the packet > size with a bsf we could automagically make muxing work for packets containing > more than 3640 samples. > > Signed-off-by: Marton Balint > --- > configure | 1 + > libavformat/daudenc.c | 11 +-- > tests/ref/fate/dcinema-encode | 31 +++ > 3 files changed, 17 insertions(+), 26 deletions(-) > > diff --git a/configure b/configure > index bbf1a70731..4ac8758a03 100755 > --- a/configure > +++ b/configure > @@ -3525,6 +3525,7 @@ caf_demuxer_select="iso_media" > caf_muxer_select="iso_media" > dash_muxer_select="mp4_muxer" > dash_demuxer_deps="libxml2" > +daud_muxer_select="pcm_rechunk_bsf" > dirac_demuxer_select="dirac_parser" > dts_demuxer_select="dca_parser" > dtshd_demuxer_select="dca_parser" > diff --git a/libavformat/daudenc.c b/libavformat/daudenc.c > index 37c20618bd..a995838351 100644 > --- a/libavformat/daudenc.c > +++ b/libavformat/daudenc.c > @@ -25,6 +25,7 @@ > static int daud_init(struct AVFormatContext *s) > { > AVCodecParameters *par = s->streams[0]->codecpar; > +int ret; > > if (par->ch_layout.nb_channels != 6) { > av_log(s, AV_LOG_ERROR, > @@ -40,17 +41,15 @@ static int daud_init(struct AVFormatContext *s) > return AVERROR(EINVAL); > } > > +ret = ff_stream_add_bitstream_filter(s->streams[0], "pcm_rechunk", > "n=2000:pad=0"); > +if (ret < 0) > +return ret; > + > return 0; > } Cannot really comment about the implication of adding an automatic bsf a the muxer level, but if this is acceptable probably you can also simplify the doc/muxers/daud documentation (also I think we have a ticket about this issue), since this lift the need to use setnsamples. [...] ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/libx264: fix extradata when config annexb=0
Zhao Zhili: > From: Zhao Zhili > > --- > configure| 2 +- > libavcodec/libx264.c | 148 --- > 2 files changed, 125 insertions(+), 25 deletions(-) > > diff --git a/configure b/configure > index bbf1a70731..ef58c3fe97 100755 > --- a/configure > +++ b/configure > @@ -3491,7 +3491,7 @@ libwebp_encoder_deps="libwebp" > libwebp_anim_encoder_deps="libwebp" > libx262_encoder_deps="libx262" > libx264_encoder_deps="libx264" > -libx264_encoder_select="atsc_a53" > +libx264_encoder_select="atsc_a53 h264parse" > libx264rgb_encoder_deps="libx264" > libx264rgb_encoder_select="libx264_encoder" > libx265_encoder_deps="libx265" > diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c > index 10d646bd76..10dfda125d 100644 > --- a/libavcodec/libx264.c > +++ b/libavcodec/libx264.c > @@ -34,9 +34,12 @@ > #include "avcodec.h" > #include "codec_internal.h" > #include "encode.h" > +#include "get_bits.h" > +#include "h264_ps.h" > #include "internal.h" > #include "packet_internal.h" > #include "atsc_a53.h" > +#include "put_bits.h" > #include "sei.h" > > #include > @@ -865,6 +868,124 @@ static int convert_pix_fmt(enum AVPixelFormat pix_fmt) > return 0; > } > > +static int set_avcc_extradata(AVCodecContext *avctx, x264_nal_t *nal, int > nnal) > +{ > +x264_nal_t *sps_nal = NULL; > +x264_nal_t *pps_nal = NULL; > +GetBitContext gbc; > +PutBitContext pbc; > +H264ParamSets ps = { 0 }; > +uint8_t *p; > +int ret, profile; > + > +/* We know it's in the order of SPS/PPS/SEI, but it's not documented in > x264 API. > + * The x264 param i_sps_id implies there is a single pair of SPS/PPS. > + */ > +for (int i = 0; i < nnal; i++) { > +if (nal[i].i_type == NAL_SPS) > +sps_nal = &nal[i]; > +else if (nal[i].i_type == NAL_PPS) > +pps_nal = &nal[i]; > +} > +av_assert0(sps_nal); > +av_assert0(pps_nal); We should never assert on the output of external libraries. > + > +// +11 for AVCDecoderConfigurationRecord, will shrink to the real size > finally > +avctx->extradata_size = sps_nal->i_payload + pps_nal->i_payload + 11; > +avctx->extradata = av_mallocz(avctx->extradata_size + > AV_INPUT_BUFFER_MIN_SIZE); AV_INPUT_BUFFER_PADDING_SIZE > +if (!avctx->extradata) > +return AVERROR(ENOMEM); > + > +// Skip size part > +p = sps_nal->p_payload + 4; > +init_get_bits8(&gbc, p, sps_nal->i_payload - 4); > +skip_bits(&gbc, 8); > +ret = ff_h264_decode_seq_parameter_set(&gbc, avctx, &ps, 0); This is completely overblown. You only read three fields: profile_idc, the constraint fields and level_idc. All three are at the start of the SPS and occupy a whole byte, so there is no need for a GetBitContext at all. (Yes, I am aware of the hypothetical scenario in which we could have a 0x03 escape byte before level_idc (in case of a hypothetical future profile zero), but even then using ff_h264_decode_seq_parameter_set() is overblown.) > +if (ret < 0) > +return ret; > + > +for (int i = 0; i < FF_ARRAY_ELEMS(ps.sps_list); i++) { > +if (ps.sps_list[i]) { > +ps.sps = ps.sps_list[i]; > +break; > +} > +} > + > +// Now create AVCDecoderConfigurationRecord > +init_put_bits(&pbc, avctx->extradata, avctx->extradata_size); > +put_bits(&pbc, 8, 1); // version > +put_bits(&pbc, 8, ps.sps->profile_idc); // AVCProfileIndication > +put_bits(&pbc, 8, ps.sps->constraint_set_flags); // profile_compatibility > +put_bits(&pbc, 8, ps.sps->level_idc); // AVCLevelIndication > +put_bits(&pbc, 11, 0x7FF); > + > +p = sps_nal->p_payload + 4; > +put_bits(&pbc, 5, 1); // numOfSequenceParameterSets > +put_bits(&pbc, 16, sps_nal->i_payload - 4); // sequenceParameterSetLength I also think that using a PutBitContext is overblown here (most fields don't cross a byte-boundary, the bit-alignment of every field is fixed), in particular if you copy the NALUs eight bits at a time: > +for (int i = 0; i < sps_nal->i_payload - 4; i++) > +put_bits(&pbc, 8, p[i]); > + > +p = pps_nal->p_payload + 4; > +put_bits(&pbc, 8, 1); // numOfPictureParameterSets > +put_bits(&pbc, 16, pps_nal->i_payload - 4); // pictureParameterSetLength > +for (int i = 0; i < pps_nal->i_payload - 4; i++) > +put_bits(&pbc, 8, p[i]); > + > +profile = ps.sps->profile_idc; > +if (profile != 66 && profile != 77 && profile != 88) { > +put_bits(&pbc, 6, 0x3F); > +put_bits(&pbc, 2, ps.sps->chroma_format_idc); > +put_bits(&pbc, 5, 0x1F); > +put_bits(&pbc, 3, ps.sps->bit_depth_luma - 8); > +put_bits(&pbc, 5, 0x1F); > +put_bits(&pbc, 3, ps.sps->bit_depth_chroma - 8); > +put_bits(&pbc, 8, 0); > +} > +flush_put_bits(&pbc); > +avctx->extradata_size = put_bytes_output(&pbc); > + > +ff_h264_ps_uninit(&ps); > + > +return
[FFmpeg-devel] [PATCH] avutil/opt: add a flag to get the default value of an option in av_opt_get
Signed-off-by: James Almer --- libavutil/opt.c | 150 ++ libavutil/opt.h | 8 +++ libavutil/tests/opt.c | 7 +- tests/ref/fate/opt| 48 +++--- 4 files changed, 188 insertions(+), 25 deletions(-) diff --git a/libavutil/opt.c b/libavutil/opt.c index d68184c2cc..226df1da7a 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -844,6 +844,153 @@ static void format_duration(char *buf, size_t size, int64_t d) *(--e) = 0; } +static int get_default(const AVOption *o, int flags, uint8_t **out_val) +{ +uint8_t buf[128]; +int ret = 0; + +av_assert0(o); + +buf[0] = 0; +switch (o->type) { +case AV_OPT_TYPE_BOOL: +ret = snprintf(buf, sizeof(buf), "%s", get_bool_name(o->default_val.i64)); +break; +case AV_OPT_TYPE_FLAGS: +ret = snprintf(buf, sizeof(buf), "0x%08X", (unsigned)o->default_val.i64); +break; +case AV_OPT_TYPE_INT: +case AV_OPT_TYPE_INT64: +case AV_OPT_TYPE_CONST: +ret = snprintf(buf, sizeof(buf), "%"PRId64, o->default_val.i64); +break; +case AV_OPT_TYPE_UINT64: +ret = snprintf(buf, sizeof(buf), "%"PRIu64, (uint64_t)o->default_val.i64); +break; +case AV_OPT_TYPE_FLOAT: +ret = snprintf(buf, sizeof(buf), "%f", (float)o->default_val.dbl); +break; +case AV_OPT_TYPE_DOUBLE: +ret = snprintf(buf, sizeof(buf), "%f", o->default_val.dbl); +break; +case AV_OPT_TYPE_RATIONAL: { +AVRational q = av_d2q(o->default_val.dbl, INT_MAX); +ret = snprintf(buf, sizeof(buf), "%d/%d", q.num, q.den); +break; +} +case AV_OPT_TYPE_VIDEO_RATE: { +AVRational q = (AVRational){0, 0}; +if (o->default_val.str) { +if ((ret = av_parse_video_rate(&q, o->default_val.str)) < 0) +return ret; +ret = snprintf(buf, sizeof(buf), "%d/%d", q.num, q.den); +} else { +*out_val = av_strdup(""); +return *out_val ? 0 : AVERROR(ENOMEM); +} +break; +} +case AV_OPT_TYPE_STRING: +case AV_OPT_TYPE_CHLAYOUT: +if (o->default_val.str) +*out_val = av_strdup(o->default_val.str); +else if (flags & AV_OPT_ALLOW_NULL) { +*out_val = NULL; + return 0; +} else +*out_val = av_strdup(""); +return *out_val ? 0 : AVERROR(ENOMEM); +case AV_OPT_TYPE_DICT: { +AVDictionary *dict = NULL; +if (!o->default_val.str && (flags & AV_OPT_ALLOW_NULL)) { +*out_val = NULL; +return 0; +} +ret = set_string_dict(NULL, NULL, o->default_val.str, (uint8_t **)&dict); +if (ret < 0) +return ret; +ret = av_dict_get_string(dict, (char **)out_val, '=', ':'); +av_dict_free(&dict); +return ret; +} +case AV_OPT_TYPE_BINARY: { +struct { +uint8_t *data; +int size; +} bin = { 0 }; +if (!o->default_val.str && (flags & AV_OPT_ALLOW_NULL)) { +av_free(bin.data); +*out_val = NULL; +return 0; +} +ret = set_string_binary(NULL, NULL, o->default_val.str, &bin.data); +if (ret < 0) { +av_free(bin.data); +return AVERROR(ENOMEM); +} +if ((uint64_t)bin.size * 2 + 1 > INT_MAX) { +av_free(bin.data); +return AVERROR(EINVAL); +} +if (!(*out_val = av_malloc(bin.size * 2 + 1))) { +av_free(bin.data); +return AVERROR(ENOMEM); +} +if (!bin.size) { +*out_val[0] = '\0'; +av_free(bin.data); +return 0; +} +for (int i = 0; i < bin.size; i++) +snprintf(*out_val + i * 2, 3, "%02X", bin.data[i]); +return 0; +} +case AV_OPT_TYPE_IMAGE_SIZE: { +int w = 0, h = 0; +if (o->default_val.str && strcmp(o->default_val.str, "none")) +ret = av_parse_video_size(&w, &h, o->default_val.str); +if (ret < 0) +return ret; +ret = snprintf(buf, sizeof(buf), "%dx%d", w, h); +break; +} +case AV_OPT_TYPE_PIXEL_FMT: +ret = snprintf(buf, sizeof(buf), "%s", (char *)av_x_if_null(av_get_pix_fmt_name((enum AVPixelFormat)o->default_val.i64), "none")); +break; +case AV_OPT_TYPE_SAMPLE_FMT: +ret = snprintf(buf, sizeof(buf), "%s", (char *)av_x_if_null(av_get_sample_fmt_name((enum AVSampleFormat)o->default_val.i64), "none")); +break; +case AV_OPT_TYPE_DURATION: +format_duration(buf, sizeof(buf), o->default_val.i64); +ret = strlen(buf); // no overflow possible, checked by an assert +break; +case AV_OPT_TYPE_COLOR: { +uint8_t color[4] = {0, 0, 0, 0}; +if (o->default_val.str) { +if ((ret = av_parse_color(color, o->default_val.str, -1, NULL))
Re: [FFmpeg-devel] [PATCH 1/3] avformat/dvdvideodec: add CLUT utilities and subtitle palette support
On date Wednesday 2024-03-06 01:19:11 -0600, Marth64 wrote: > Since last iteration: removes unused variable in dvdclut.c > > Signed-off-by: Marth64 > --- > doc/demuxers.texi | 5 +++ > libavformat/Makefile | 2 +- > libavformat/dvdclut.c | 75 +++ > libavformat/dvdclut.h | 37 +++ > libavformat/dvdvideodec.c | 15 > 5 files changed, 133 insertions(+), 1 deletion(-) > create mode 100644 libavformat/dvdclut.c > create mode 100644 libavformat/dvdclut.h > > diff --git a/doc/demuxers.texi b/doc/demuxers.texi > index f4bac8f3b3..1a17c6db16 100644 > --- a/doc/demuxers.texi > +++ b/doc/demuxers.texi > @@ -394,6 +394,11 @@ often with junk data intended for controlling a real DVD > player's > buffering speed and with no other material data value. > Default is 1, true. > > +@item clut_rgb @var{bool} > +Output subtitle palettes (CLUTs) as RGB, required for Matroska. > +Disable to output the palette in its original YUV colorspace. > +Default is 1, true. Can you expand about this? When is matroska used in a DVD? Can we make the setting automatic in case matroska is detected? [...] LGTM otherwise. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 3/3] avformat/dvdvideodec: assign mono channel layout explicitly
On date Wednesday 2024-03-06 01:19:13 -0600, Marth64 wrote: > Signed-off-by: Marth64 > --- > libavformat/dvdvideodec.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/libavformat/dvdvideodec.c b/libavformat/dvdvideodec.c > index 2c7ffdd148..6136060288 100644 > --- a/libavformat/dvdvideodec.c > +++ b/libavformat/dvdvideodec.c > @@ -1142,7 +1142,9 @@ static int > dvdvideo_audio_stream_analyze(AVFormatContext *s, audio_attr_t audio_ > return AVERROR_INVALIDDATA; > } > > -if (nb_channels == 2) > +if (nb_channels == 1) > +ch_layout = (AVChannelLayout) AV_CHANNEL_LAYOUT_MONO; > +else if (nb_channels == 2) > ch_layout = (AVChannelLayout) AV_CHANNEL_LAYOUT_STEREO; > else if (nb_channels == 6) > ch_layout = (AVChannelLayout) AV_CHANNEL_LAYOUT_5POINT1; LGTM, but when this is needed? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/3] avformat/dvdvideodec: add CLUT utilities and subtitle palette support
On 06/03/2024 16:09, Stefano Sabatini wrote: On date Wednesday 2024-03-06 01:19:11 -0600, Marth64 wrote: Since last iteration: removes unused variable in dvdclut.c Signed-off-by: Marth64 --- doc/demuxers.texi | 5 +++ libavformat/Makefile | 2 +- libavformat/dvdclut.c | 75 +++ libavformat/dvdclut.h | 37 +++ libavformat/dvdvideodec.c | 15 5 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 libavformat/dvdclut.c create mode 100644 libavformat/dvdclut.h diff --git a/doc/demuxers.texi b/doc/demuxers.texi index f4bac8f3b3..1a17c6db16 100644 --- a/doc/demuxers.texi +++ b/doc/demuxers.texi @@ -394,6 +394,11 @@ often with junk data intended for controlling a real DVD player's buffering speed and with no other material data value. Default is 1, true. +@item clut_rgb @var{bool} +Output subtitle palettes (CLUTs) as RGB, required for Matroska. +Disable to output the palette in its original YUV colorspace. +Default is 1, true. Can you expand about this? When is matroska used in a DVD? Sounds to me like muxing _to_ matroska needs RGB palettes, but DVDs bring YUV ones. Can we make the setting automatic in case matroska is detected? [...] LGTM otherwise. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/3] avformat/dvdvideodec: add CLUT utilities and subtitle palette support
Good morning, DVD subtitle palettes, which are natively YUV, are currently carried as a hex string in their respective subtitle streams and have no concept of colorspace tagging (even predating dvd demuxer). The convention is to convert them to RGB prior to storage. Common players will only render the palettes properly if they are stored as RGB. Even ffmpeg itself expects this, and already does -in libavformat- the YUV-RGB conversions, specifically in mov.c and movenc.c. The point of this patch is to provide a consolidation of the code that deals with creating the extradata as well as the RGB conversion. That can then (1) enable usable palette support for DVD demuxer if it is merged and (2) start the process of consolidating the related conversions in MOV muxer/demuxer and eventually find a way to properly tag the colorspace. Thank you! On Wed, Mar 6, 2024 at 09:18 Timo Rothenpieler wrote: > On 06/03/2024 16:09, Stefano Sabatini wrote: > > On date Wednesday 2024-03-06 01:19:11 -0600, Marth64 wrote: > >> Since last iteration: removes unused variable in dvdclut.c > >> > >> Signed-off-by: Marth64 > >> --- > >> doc/demuxers.texi | 5 +++ > >> libavformat/Makefile | 2 +- > >> libavformat/dvdclut.c | 75 +++ > >> libavformat/dvdclut.h | 37 +++ > >> libavformat/dvdvideodec.c | 15 > >> 5 files changed, 133 insertions(+), 1 deletion(-) > >> create mode 100644 libavformat/dvdclut.c > >> create mode 100644 libavformat/dvdclut.h > >> > >> diff --git a/doc/demuxers.texi b/doc/demuxers.texi > >> index f4bac8f3b3..1a17c6db16 100644 > >> --- a/doc/demuxers.texi > >> +++ b/doc/demuxers.texi > >> @@ -394,6 +394,11 @@ often with junk data intended for controlling a > real DVD player's > >> buffering speed and with no other material data value. > >> Default is 1, true. > >> > > > >> +@item clut_rgb @var{bool} > >> +Output subtitle palettes (CLUTs) as RGB, required for Matroska. > >> +Disable to output the palette in its original YUV colorspace. > >> +Default is 1, true. > > > > Can you expand about this? When is matroska used in a DVD? > > Sounds to me like muxing _to_ matroska needs RGB palettes, but DVDs > bring YUV ones. > > > Can we make the setting automatic in case matroska is detected? > > > > [...] > > > > LGTM otherwise. > > ___ > > ffmpeg-devel mailing list > > ffmpeg-devel@ffmpeg.org > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > To unsubscribe, visit link above, or email > > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 3/3] avformat/dvdvideodec: assign mono channel layout explicitly
Good morning, There do exist discs with mono tracks. This was to make the channel assignment explicit rather than a guess, although if it is not necessary I am happy to skip it. Thank you! On Wed, Mar 6, 2024 at 09:10 Stefano Sabatini wrote: > On date Wednesday 2024-03-06 01:19:13 -0600, Marth64 wrote: > > Signed-off-by: Marth64 > > --- > > libavformat/dvdvideodec.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/libavformat/dvdvideodec.c b/libavformat/dvdvideodec.c > > index 2c7ffdd148..6136060288 100644 > > --- a/libavformat/dvdvideodec.c > > +++ b/libavformat/dvdvideodec.c > > @@ -1142,7 +1142,9 @@ static int > dvdvideo_audio_stream_analyze(AVFormatContext *s, audio_attr_t audio_ > > return AVERROR_INVALIDDATA; > > } > > > > -if (nb_channels == 2) > > +if (nb_channels == 1) > > +ch_layout = (AVChannelLayout) AV_CHANNEL_LAYOUT_MONO; > > +else if (nb_channels == 2) > > ch_layout = (AVChannelLayout) AV_CHANNEL_LAYOUT_STEREO; > > else if (nb_channels == 6) > > ch_layout = (AVChannelLayout) AV_CHANNEL_LAYOUT_5POINT1; > > LGTM, but when this is needed? > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/3] avformat/dvdvideodec: add menu demuxing support
On date Wednesday 2024-03-06 01:19:12 -0600, Marth64 wrote: > Many DVDs have valuable assets in their menu structures, including background > video or music. Some discs also abuse the menu feature to include actual > feature footage that needs to change aspect ratio (in order to trick the DVD > player). > > This patch allows extraction and archival of these assets, but does not enable > controllable playback (which needs a full-fledged player and nav VM). > Menus are processed directly with dvdread and the existing foundation of the > demuxer. > > Will eventually add option to list their coordinates as well, so users > do not have to rely on other tools to find them. > > Signed-off-by: Marth64 > --- > doc/demuxers.texi | 43 +- > libavformat/dvdvideodec.c | 315 -- > 2 files changed, 339 insertions(+), 19 deletions(-) > > diff --git a/doc/demuxers.texi b/doc/demuxers.texi > index 1a17c6db16..e2ea66c1a5 100644 > --- a/doc/demuxers.texi > +++ b/doc/demuxers.texi > @@ -289,8 +289,10 @@ This demuxer accepts the following option: > > DVD-Video demuxer, powered by libdvdnav and libdvdread. > > -Can directly ingest DVD titles, specifically sequential PGCs, > -into a conversion pipeline. Menus and seeking are not supported at this time. > +Can directly ingest DVD titles, specifically sequential PGCs, into > +a conversion pipeline. Menu assets, such as background video or audio, > +can also be demuxed given the menu's coordinates (at best effort). > +Seeking is not supported at this time. > > Block devices (DVD drives), ISO files, and directory structures are accepted. > Activate with @code{-f dvdvideo} in front of one of these inputs. > @@ -347,37 +349,56 @@ This demuxer accepts the following options: > > @item title @var{int} > The title number to play. Must be set if @option{pgc} and @option{pg} are > not set. > +Not applicable to menus. > Default is 0 (auto), which currently only selects the first available title > (title 1) > and notifies the user about the implications. > > @item chapter_start @var{int} > -The chapter, or PTT (part-of-title), number to start at. Default is 1. > +The chapter, or PTT (part-of-title), number to start at. Not applicable to > menus. > +Default is 1. > > @item chapter_end @var{int} > -The chapter, or PTT (part-of-title), number to end at. Default is 0, > -which is a special value to signal end at the last possible chapter. > +The chapter, or PTT (part-of-title), number to end at. Not applicable to > menus. > +Default is 0, which is a special value to signal end at the last possible > chapter. > > @item angle @var{int} > The video angle number, referring to what is essentially an additional > video stream that is composed from alternate frames interleaved in the VOBs. > +Not applicable to menus. > Default is 1. > > @item region @var{int} > The region code to use for playback. Some discs may use this to default > playback > at a particular angle in different regions. This option will not affect the > region code > -of a real DVD drive, if used as an input. Default is 0, "world". > +of a real DVD drive, if used as an input. Not applicable to menus. > +Default is 0, "world". > + > +@item menu @var{bool} > +Demux menu assets instead of navigating a title. Requires exact coordinates > +of the menu (@option{menu_lu}, @option{menu_vts}, @option{pgc}, @option{pg}). > +Default is false. > + > +@item menu_lu @var{int} > +The menu language to demux. In DVD, menus are grouped by language. > +Default is 0, the first language unit. > + > +@item menu_vts @var{int} > +The VTS where the menu lives, or 0 if it is a VMG menu (root-level). > +Default is 0, VMG menu. > > @item pgc @var{int} > The entry PGC to start playback, in conjunction with @option{pg}. > Alternative to setting @option{title}. > Chapter markers are not supported at this time. > +Must be explicitly set for menus. > Default is 0, automatically resolve from value of @option{title}. > > @item pg @var{int} > The entry PG to start playback, in conjunction with @option{pgc}. > Alternative to setting @option{title}. > Chapter markers are not supported at this time. > -Default is 0, automatically resolve from value of @option{title}. > +Default is 0, automatically resolve from value of @option{title}, or > +start from the beginning (PG 1) of the menu. > > @item preindex @var{bool} > Enable this to have accurate chapter (PTT) markers and duration measurement, > @@ -385,6 +406,7 @@ which requires a slow second pass read in order to index > the chapter marker > timestamps from NAV packets. This is non-ideal extra work for real optical > drives. > It is recommended and faster to use this option with a backup of the DVD > structure > stored on a hard drive. Not compatible with @option{pgc} and @option{pg}. > +Not applicable to menus. > Default is 0, false. > > @item trim @var{bool} > @@ -392,6 +414,7 @@ Skip padding cells (
Re: [FFmpeg-devel] [PATCH 1/3] avformat/dvdvideodec: add CLUT utilities and subtitle palette support
It is true that this is necessary when muxing to Matroska, but it is also the case for MOV - the MOV muxer expects RGB prior to converting to YUV again. So this would be needed for MOV also, despite the awkward conversion circle. I should update the document to reflect this. On Wed, Mar 6, 2024 at 09:36 Marth64 wrote: > Good morning, > > DVD subtitle palettes, which are natively YUV, are currently carried as > a hex string in their respective subtitle streams and have > no concept of colorspace tagging (even predating dvd demuxer). The > convention is to convert > them to RGB prior to storage. Common players will only render > the palettes properly if they are stored as RGB. Even ffmpeg itself > expects this, and already does -in libavformat- the YUV-RGB conversions, > specifically in mov.c and movenc.c. > > The point of this patch is to provide a consolidation of the code > that deals with creating the extradata as well as the RGB conversion. > That can then (1) enable usable palette support for DVD demuxer if it is > merged > and (2) start the process of consolidating the related conversions in > MOV muxer/demuxer and eventually find a way to properly tag > the colorspace. > > Thank you! > > On Wed, Mar 6, 2024 at 09:18 Timo Rothenpieler > wrote: > >> On 06/03/2024 16:09, Stefano Sabatini wrote: >> > On date Wednesday 2024-03-06 01:19:11 -0600, Marth64 wrote: >> >> Since last iteration: removes unused variable in dvdclut.c >> >> >> >> Signed-off-by: Marth64 >> >> --- >> >> doc/demuxers.texi | 5 +++ >> >> libavformat/Makefile | 2 +- >> >> libavformat/dvdclut.c | 75 >> +++ >> >> libavformat/dvdclut.h | 37 +++ >> >> libavformat/dvdvideodec.c | 15 >> >> 5 files changed, 133 insertions(+), 1 deletion(-) >> >> create mode 100644 libavformat/dvdclut.c >> >> create mode 100644 libavformat/dvdclut.h >> >> >> >> diff --git a/doc/demuxers.texi b/doc/demuxers.texi >> >> index f4bac8f3b3..1a17c6db16 100644 >> >> --- a/doc/demuxers.texi >> >> +++ b/doc/demuxers.texi >> >> @@ -394,6 +394,11 @@ often with junk data intended for controlling a >> real DVD player's >> >> buffering speed and with no other material data value. >> >> Default is 1, true. >> >> >> > >> >> +@item clut_rgb @var{bool} >> >> +Output subtitle palettes (CLUTs) as RGB, required for Matroska. >> >> +Disable to output the palette in its original YUV colorspace. >> >> +Default is 1, true. >> > >> > Can you expand about this? When is matroska used in a DVD? >> >> Sounds to me like muxing _to_ matroska needs RGB palettes, but DVDs >> bring YUV ones. >> >> > Can we make the setting automatic in case matroska is detected? >> > >> > [...] >> > >> > LGTM otherwise. >> > ___ >> > ffmpeg-devel mailing list >> > ffmpeg-devel@ffmpeg.org >> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> > >> > To unsubscribe, visit link above, or email >> > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". >> ___ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> >> To unsubscribe, visit link above, or email >> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". >> > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] lavf/matroskadec: add missing linebreaks in error messages
On date Wednesday 2024-03-06 09:02:50 +0100, Anton Khirnov wrote: > --- > libavformat/matroskadec.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c > index 5d3d18a146..6d6a60c552 100644 > --- a/libavformat/matroskadec.c > +++ b/libavformat/matroskadec.c > @@ -2036,7 +2036,7 @@ static int > matroska_parse_content_encodings(MatroskaTrackEncoding *encodings, > { > if (nb_encodings > 1) { > av_log(logctx, AV_LOG_ERROR, > -"Multiple combined encodings not supported"); > +"Multiple combined encodings not supported\n"); > return 0; > } > if (!nb_encodings) > @@ -2055,7 +2055,7 @@ static int > matroska_parse_content_encodings(MatroskaTrackEncoding *encodings, > encodings->encryption.key_id.size); > } else { > encodings->scope = 0; > -av_log(logctx, AV_LOG_ERROR, "Unsupported encoding type"); > +av_log(logctx, AV_LOG_ERROR, "Unsupported encoding type\n"); > } > } else if ( > #if CONFIG_ZLIB > @@ -2067,7 +2067,7 @@ static int > matroska_parse_content_encodings(MatroskaTrackEncoding *encodings, > encodings->compression.algo != MATROSKA_TRACK_ENCODING_COMP_LZO > && > encodings->compression.algo != > MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP) { > encodings->scope = 0; > -av_log(logctx, AV_LOG_ERROR, "Unsupported encoding type"); > +av_log(logctx, AV_LOG_ERROR, "Unsupported encoding type\n"); Seems obviously fine, thanks. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/3] avformat/dvdvideodec: add CLUT utilities and subtitle palette support
On date Wednesday 2024-03-06 09:43:26 -0600, Marth64 wrote: > It is true that this is necessary when muxing to Matroska, but it is also > the case for MOV - the MOV muxer expects RGB prior to converting to YUV > again. So this would be needed for MOV also, despite the awkward conversion > circle. I should update the document to reflect this. So we might drop the reference to Matroska, or change to something as: Output subtitle palettes (CLUTs) as RGB, as required for example when for subtitles rendering in Matroska or MP4 video. ... I assume there is no heuristic to distinguish RGB/YUV (one trick might be to add some custom metadata for the colorspace so that it can then be read by the encoder). Also I wonder if this is should not rather be an option for the Matroska/MP4 renderer, to avoid duplicating the code. > On Wed, Mar 6, 2024 at 09:36 Marth64 wrote: > > > Good morning, > > > > DVD subtitle palettes, which are natively YUV, are currently carried as > > a hex string in their respective subtitle streams and have > > no concept of colorspace tagging (even predating dvd demuxer). The > > convention is to convert > > them to RGB prior to storage. Common players will only render > > the palettes properly if they are stored as RGB. Even ffmpeg itself > > expects this, and already does -in libavformat- the YUV-RGB conversions, > > specifically in mov.c and movenc.c. > > > > The point of this patch is to provide a consolidation of the code > > that deals with creating the extradata as well as the RGB conversion. > > That can then (1) enable usable palette support for DVD demuxer if it is > > merged > > and (2) start the process of consolidating the related conversions in > > MOV muxer/demuxer and eventually find a way to properly tag > > the colorspace. > > > > Thank you! ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/libx264: fix extradata when config annexb=0
> -Original Message- > From: ffmpeg-devel On Behalf Of Andreas > Rheinhardt > Sent: 2024年3月6日 22:19 > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH] avcodec/libx264: fix extradata when > config annexb=0 > > Zhao Zhili: > > From: Zhao Zhili > > > > --- > > configure| 2 +- > > libavcodec/libx264.c | 148 --- > > 2 files changed, 125 insertions(+), 25 deletions(-) > > > > diff --git a/configure b/configure > > index bbf1a70731..ef58c3fe97 100755 > > --- a/configure > > +++ b/configure > > @@ -3491,7 +3491,7 @@ libwebp_encoder_deps="libwebp" > > libwebp_anim_encoder_deps="libwebp" > > libx262_encoder_deps="libx262" > > libx264_encoder_deps="libx264" > > -libx264_encoder_select="atsc_a53" > > +libx264_encoder_select="atsc_a53 h264parse" > > libx264rgb_encoder_deps="libx264" > > libx264rgb_encoder_select="libx264_encoder" > > libx265_encoder_deps="libx265" > > diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c > > index 10d646bd76..10dfda125d 100644 > > --- a/libavcodec/libx264.c > > +++ b/libavcodec/libx264.c > > @@ -34,9 +34,12 @@ > > #include "avcodec.h" > > #include "codec_internal.h" > > #include "encode.h" > > +#include "get_bits.h" > > +#include "h264_ps.h" > > #include "internal.h" > > #include "packet_internal.h" > > #include "atsc_a53.h" > > +#include "put_bits.h" > > #include "sei.h" > > > > #include > > @@ -865,6 +868,124 @@ static int convert_pix_fmt(enum AVPixelFormat pix_fmt) > > return 0; > > } > > > > +static int set_avcc_extradata(AVCodecContext *avctx, x264_nal_t *nal, int > > nnal) > > +{ > > +x264_nal_t *sps_nal = NULL; > > +x264_nal_t *pps_nal = NULL; > > +GetBitContext gbc; > > +PutBitContext pbc; > > +H264ParamSets ps = { 0 }; > > +uint8_t *p; > > +int ret, profile; > > + > > +/* We know it's in the order of SPS/PPS/SEI, but it's not documented > > in x264 API. > > + * The x264 param i_sps_id implies there is a single pair of SPS/PPS. > > + */ > > +for (int i = 0; i < nnal; i++) { > > +if (nal[i].i_type == NAL_SPS) > > +sps_nal = &nal[i]; > > +else if (nal[i].i_type == NAL_PPS) > > +pps_nal = &nal[i]; > > +} > > +av_assert0(sps_nal); > > +av_assert0(pps_nal); > > We should never assert on the output of external libraries. Ok, will just remove the assert. I don't think a check is needed. > > > + > > +// +11 for AVCDecoderConfigurationRecord, will shrink to the real size > > finally > > +avctx->extradata_size = sps_nal->i_payload + pps_nal->i_payload + 11; > > +avctx->extradata = av_mallocz(avctx->extradata_size + > > AV_INPUT_BUFFER_MIN_SIZE); > > AV_INPUT_BUFFER_PADDING_SIZE Oops. > > > +if (!avctx->extradata) > > +return AVERROR(ENOMEM); > > + > > +// Skip size part > > +p = sps_nal->p_payload + 4; > > +init_get_bits8(&gbc, p, sps_nal->i_payload - 4); > > +skip_bits(&gbc, 8); > > +ret = ff_h264_decode_seq_parameter_set(&gbc, avctx, &ps, 0); > > This is completely overblown. You only read three fields: profile_idc, > the constraint fields and level_idc. All three are at the start of the > SPS and occupy a whole byte, so there is no need for a GetBitContext at all. > (Yes, I am aware of the hypothetical scenario in which we could have a > 0x03 escape byte before level_idc (in case of a hypothetical future > profile zero), but even then using ff_h264_decode_seq_parameter_set() is > overblown.) You missed chroma_format_idc, bit_depth_luma/bit_depth_chroma. I can get that from pixel format, but there are a lot of them. > > > +if (ret < 0) > > +return ret; > > + > > +for (int i = 0; i < FF_ARRAY_ELEMS(ps.sps_list); i++) { > > +if (ps.sps_list[i]) { > > +ps.sps = ps.sps_list[i]; > > +break; > > +} > > +} > > + > > +// Now create AVCDecoderConfigurationRecord > > +init_put_bits(&pbc, avctx->extradata, avctx->extradata_size); > > +put_bits(&pbc, 8, 1); // version > > +put_bits(&pbc, 8, ps.sps->profile_idc); // AVCProfileIndication > > +put_bits(&pbc, 8, ps.sps->constraint_set_flags); // > > profile_compatibility > > +put_bits(&pbc, 8, ps.sps->level_idc); // AVCLevelIndication > > +put_bits(&pbc, 11, 0x7FF); > > + > > +p = sps_nal->p_payload + 4; > > +put_bits(&pbc, 5, 1); // numOfSequenceParameterSets > > +put_bits(&pbc, 16, sps_nal->i_payload - 4); // > > sequenceParameterSetLength > > I also think that using a PutBitContext is overblown here (most fields > don't cross a byte-boundary, the bit-alignment of every field is fixed), > in particular if you copy the NALUs eight bits at a time: It's readable, close related to the spec, and it counts how many bytes actually used automatically. I choose it for these convenience over performance. > > > +for (int i = 0; i < sps_nal->i_payload - 4; i++) > > +put_bits(&pbc,
Re: [FFmpeg-devel] [PATCH] avcodec/libx264: fix extradata when config annexb=0
Zhao Zhili: > > >> -Original Message- >> From: ffmpeg-devel On Behalf Of Andreas >> Rheinhardt >> Sent: 2024年3月6日 22:19 >> To: ffmpeg-devel@ffmpeg.org >> Subject: Re: [FFmpeg-devel] [PATCH] avcodec/libx264: fix extradata when >> config annexb=0 >> >> Zhao Zhili: >>> From: Zhao Zhili >>> >>> --- >>> configure| 2 +- >>> libavcodec/libx264.c | 148 --- >>> 2 files changed, 125 insertions(+), 25 deletions(-) >>> >>> diff --git a/configure b/configure >>> index bbf1a70731..ef58c3fe97 100755 >>> --- a/configure >>> +++ b/configure >>> @@ -3491,7 +3491,7 @@ libwebp_encoder_deps="libwebp" >>> libwebp_anim_encoder_deps="libwebp" >>> libx262_encoder_deps="libx262" >>> libx264_encoder_deps="libx264" >>> -libx264_encoder_select="atsc_a53" >>> +libx264_encoder_select="atsc_a53 h264parse" >>> libx264rgb_encoder_deps="libx264" >>> libx264rgb_encoder_select="libx264_encoder" >>> libx265_encoder_deps="libx265" >>> diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c >>> index 10d646bd76..10dfda125d 100644 >>> --- a/libavcodec/libx264.c >>> +++ b/libavcodec/libx264.c >>> @@ -34,9 +34,12 @@ >>> #include "avcodec.h" >>> #include "codec_internal.h" >>> #include "encode.h" >>> +#include "get_bits.h" >>> +#include "h264_ps.h" >>> #include "internal.h" >>> #include "packet_internal.h" >>> #include "atsc_a53.h" >>> +#include "put_bits.h" >>> #include "sei.h" >>> >>> #include >>> @@ -865,6 +868,124 @@ static int convert_pix_fmt(enum AVPixelFormat pix_fmt) >>> return 0; >>> } >>> >>> +static int set_avcc_extradata(AVCodecContext *avctx, x264_nal_t *nal, int >>> nnal) >>> +{ >>> +x264_nal_t *sps_nal = NULL; >>> +x264_nal_t *pps_nal = NULL; >>> +GetBitContext gbc; >>> +PutBitContext pbc; >>> +H264ParamSets ps = { 0 }; >>> +uint8_t *p; >>> +int ret, profile; >>> + >>> +/* We know it's in the order of SPS/PPS/SEI, but it's not documented >>> in x264 API. >>> + * The x264 param i_sps_id implies there is a single pair of SPS/PPS. >>> + */ >>> +for (int i = 0; i < nnal; i++) { >>> +if (nal[i].i_type == NAL_SPS) >>> +sps_nal = &nal[i]; >>> +else if (nal[i].i_type == NAL_PPS) >>> +pps_nal = &nal[i]; >>> +} >>> +av_assert0(sps_nal); >>> +av_assert0(pps_nal); >> >> We should never assert on the output of external libraries. > > Ok, will just remove the assert. I don't think a check is needed. > >> >>> + >>> +// +11 for AVCDecoderConfigurationRecord, will shrink to the real size >>> finally >>> +avctx->extradata_size = sps_nal->i_payload + pps_nal->i_payload + 11; >>> +avctx->extradata = av_mallocz(avctx->extradata_size + >>> AV_INPUT_BUFFER_MIN_SIZE); >> >> AV_INPUT_BUFFER_PADDING_SIZE > > Oops. > >> >>> +if (!avctx->extradata) >>> +return AVERROR(ENOMEM); >>> + >>> +// Skip size part >>> +p = sps_nal->p_payload + 4; >>> +init_get_bits8(&gbc, p, sps_nal->i_payload - 4); >>> +skip_bits(&gbc, 8); >>> +ret = ff_h264_decode_seq_parameter_set(&gbc, avctx, &ps, 0); >> >> This is completely overblown. You only read three fields: profile_idc, >> the constraint fields and level_idc. All three are at the start of the >> SPS and occupy a whole byte, so there is no need for a GetBitContext at all. >> (Yes, I am aware of the hypothetical scenario in which we could have a >> 0x03 escape byte before level_idc (in case of a hypothetical future >> profile zero), but even then using ff_h264_decode_seq_parameter_set() is >> overblown.) > > You missed chroma_format_idc, bit_depth_luma/bit_depth_chroma. > I can get that from pixel format, but there are a lot of them. > Ok, but even then I fail to see a convenience advantage here. After all, using it e.g. forces the following loop onto you. And it forces cleanup code here. Also, there is a gotcha here. See below. >> >>> +if (ret < 0) >>> +return ret; >>> + >>> +for (int i = 0; i < FF_ARRAY_ELEMS(ps.sps_list); i++) { >>> +if (ps.sps_list[i]) { >>> +ps.sps = ps.sps_list[i]; >>> +break; >>> +} >>> +} >>> + >>> +// Now create AVCDecoderConfigurationRecord >>> +init_put_bits(&pbc, avctx->extradata, avctx->extradata_size); >>> +put_bits(&pbc, 8, 1); // version >>> +put_bits(&pbc, 8, ps.sps->profile_idc); // AVCProfileIndication >>> +put_bits(&pbc, 8, ps.sps->constraint_set_flags); // >>> profile_compatibility Sure this is correct at all? It seems to me that h264_ps.c reverses the order of the constraint_set_flags (constraint_set0_flag (which is the 0x80 bit in a file) will be mapped to 0x01 etc.) and it discards reserved_zero_2bits. You should instead simply copy the relevant byte from the SPS. >>> +put_bits(&pbc, 8, ps.sps->level_idc); // AVCLevelIndication >>> +put_bits(&pbc, 11, 0x7FF); >>> + >>> +p = sps_nal->p_payload + 4; >>> +put_bits(&pbc, 5, 1); // numOfSequenceParameterSe
Re: [FFmpeg-devel] [PATCH] lavc/aarch64/fdct: add neon-optimized fdct for aarch64
ping On Sun, Feb 4, 2024 at 3:42 PM Ramiro Polla wrote: > > The code is imported from libjpeg-turbo-3.0.1. The neon registers used > have been changed to avoid modifying v8-v15. > --- > libavcodec/aarch64/Makefile | 2 + > libavcodec/aarch64/fdct.h | 26 ++ > libavcodec/aarch64/fdctdsp_init_aarch64.c | 39 +++ > libavcodec/aarch64/fdctdsp_neon.S | 369 ++ > libavcodec/avcodec.h | 1 + > libavcodec/fdctdsp.c | 4 +- > libavcodec/fdctdsp.h | 2 + > libavcodec/options_table.h| 1 + > libavcodec/tests/aarch64/dct.c| 2 + > 9 files changed, 445 insertions(+), 1 deletion(-) > create mode 100644 libavcodec/aarch64/fdct.h > create mode 100644 libavcodec/aarch64/fdctdsp_init_aarch64.c > create mode 100644 libavcodec/aarch64/fdctdsp_neon.S > > diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile > index beb6a02f5f..eebccbe4a5 100644 > --- a/libavcodec/aarch64/Makefile > +++ b/libavcodec/aarch64/Makefile > @@ -1,4 +1,5 @@ > # subsystems > +OBJS-$(CONFIG_FDCTDSP) += aarch64/fdctdsp_init_aarch64.o > OBJS-$(CONFIG_FMTCONVERT) += aarch64/fmtconvert_init.o > OBJS-$(CONFIG_H264CHROMA) += aarch64/h264chroma_init_aarch64.o > OBJS-$(CONFIG_H264DSP) += aarch64/h264dsp_init_aarch64.o > @@ -35,6 +36,7 @@ ARMV8-OBJS-$(CONFIG_VIDEODSP) += > aarch64/videodsp.o > > # subsystems > NEON-OBJS-$(CONFIG_AAC_DECODER) += aarch64/sbrdsp_neon.o > +NEON-OBJS-$(CONFIG_FDCTDSP) += aarch64/fdctdsp_neon.o > NEON-OBJS-$(CONFIG_FMTCONVERT) += aarch64/fmtconvert_neon.o > NEON-OBJS-$(CONFIG_H264CHROMA) += aarch64/h264cmc_neon.o > NEON-OBJS-$(CONFIG_H264DSP) += aarch64/h264dsp_neon.o > \ > diff --git a/libavcodec/aarch64/fdct.h b/libavcodec/aarch64/fdct.h > new file mode 100644 > index 00..0901b53a83 > --- /dev/null > +++ b/libavcodec/aarch64/fdct.h > @@ -0,0 +1,26 @@ > +/* > + * 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_AARCH64_FDCT_H > +#define AVCODEC_AARCH64_FDCT_H > + > +#include > + > +void ff_fdct_neon(int16_t *block); > + > +#endif /* AVCODEC_AARCH64_FDCT_H */ > diff --git a/libavcodec/aarch64/fdctdsp_init_aarch64.c > b/libavcodec/aarch64/fdctdsp_init_aarch64.c > new file mode 100644 > index 00..59d91bc8fc > --- /dev/null > +++ b/libavcodec/aarch64/fdctdsp_init_aarch64.c > @@ -0,0 +1,39 @@ > +/* > + * 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 "libavutil/attributes.h" > +#include "libavutil/cpu.h" > +#include "libavutil/aarch64/cpu.h" > +#include "libavcodec/avcodec.h" > +#include "libavcodec/fdctdsp.h" > +#include "fdct.h" > + > +av_cold void ff_fdctdsp_init_aarch64(FDCTDSPContext *c, AVCodecContext > *avctx, > + unsigned high_bit_depth) > +{ > +int cpu_flags = av_get_cpu_flags(); > + > +if (have_neon(cpu_flags)) { > +if (!high_bit_depth) { > +if (avctx->dct_algo == FF_DCT_AUTO || > +avctx->dct_algo == FF_DCT_NEON) { > +c->fdct = ff_fdct_neon; > +} > +} > +} > +} > diff --git a/libavcodec/aarch64/fdctdsp_neon.S > b/libavcodec/aarch64/fdctdsp_neon.S > new file mode 100644 > index 00..978c8d3002 > --- /dev/null > +++ b/libavcodec/aarch64/f
Re: [FFmpeg-devel] [PATCH 1/2] avcodec/hq_hqadata: Move data in a header
Andreas Rheinhardt: > It is only used by hq_hqa.c, so said header can simply > be included there. > Also move the code to initialize the VLCs to hq_hqa.c. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/Makefile | 3 +- > libavcodec/hq_hqa.c | 39 +++ > libavcodec/hq_hqa.h | 60 --- > libavcodec/{hq_hqadata.c => hq_hqadata.h} | 34 ++--- > 4 files changed, 48 insertions(+), 88 deletions(-) > delete mode 100644 libavcodec/hq_hqa.h > rename libavcodec/{hq_hqadata.c => hq_hqadata.h} (99%) > > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index eadaab5ec4..cf81a55edb 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -451,8 +451,7 @@ OBJS-$(CONFIG_HEVC_V4L2M2M_DECODER)+= v4l2_m2m_dec.o > OBJS-$(CONFIG_HEVC_V4L2M2M_ENCODER)+= v4l2_m2m_enc.o > OBJS-$(CONFIG_HEVC_VIDEOTOOLBOX_ENCODER) += videotoolboxenc.o > OBJS-$(CONFIG_HNM4_VIDEO_DECODER) += hnm4video.o > -OBJS-$(CONFIG_HQ_HQA_DECODER) += hq_hqa.o hq_hqadata.o hq_hqadsp.o \ > - canopus.o > +OBJS-$(CONFIG_HQ_HQA_DECODER) += hq_hqa.o hq_hqadsp.o canopus.o > OBJS-$(CONFIG_HQX_DECODER) += hqx.o hqxvlc.o hqxdsp.o canopus.o > OBJS-$(CONFIG_HUFFYUV_DECODER) += huffyuv.o huffyuvdec.o > OBJS-$(CONFIG_HUFFYUV_ENCODER) += huffyuv.o huffyuvenc.o > diff --git a/libavcodec/hq_hqa.c b/libavcodec/hq_hqa.c > index 0df7995f84..510a66fd91 100644 > --- a/libavcodec/hq_hqa.c > +++ b/libavcodec/hq_hqa.c > @@ -21,6 +21,7 @@ > #include > > #include "libavutil/attributes.h" > +#include "libavutil/mem_internal.h" > > #include "avcodec.h" > #include "bytestream.h" > @@ -28,9 +29,9 @@ > #include "codec_internal.h" > #include "decode.h" > #include "get_bits.h" > - > -#include "hq_hqa.h" > +#include "hq_hqadata.h" > #include "hq_hqadsp.h" > +#include "vlc.h" > > /* HQ/HQA slices are a set of macroblocks belonging to a frame, and > * they usually form a pseudorandom pattern (probably because it is > @@ -48,6 +49,15 @@ > * while lavc simply aligns coded_width and coded_height. > */ > > +typedef struct HQContext { > +AVCodecContext *avctx; > +HQDSPContext hqhqadsp; > + > +VLC hq_ac_vlc; > +VLC hqa_cbp_vlc; > +DECLARE_ALIGNED(16, int16_t, block)[12][64]; > +} HQContext; > + > static inline void put_blocks(HQContext *c, AVFrame *pic, >int plane, int x, int y, int ilace, >int16_t *block0, int16_t *block1) > @@ -70,9 +80,9 @@ static int hq_decode_block(HQContext *c, GetBitContext *gb, > int16_t block[64], > > if (!is_hqa) { > block[0] = get_sbits(gb, 9) * 64; > -q = ff_hq_quants[qsel][is_chroma][get_bits(gb, 2)]; > +q = hq_quants[qsel][is_chroma][get_bits(gb, 2)]; > } else { > -q = ff_hq_quants[qsel][is_chroma][get_bits(gb, 2)]; > +q = hq_quants[qsel][is_chroma][get_bits(gb, 2)]; > block[0] = get_sbits(gb, 9) * 64; > } > > @@ -81,10 +91,10 @@ static int hq_decode_block(HQContext *c, GetBitContext > *gb, int16_t block[64], > if (val < 0) > return AVERROR_INVALIDDATA; > > -pos += ff_hq_ac_skips[val]; > +pos += hq_ac_skips[val]; > if (pos >= 64) > break; > -block[ff_zigzag_direct[pos]] = (int)(ff_hq_ac_syms[val] * > (unsigned)q[pos]) >> 12; > +block[ff_zigzag_direct[pos]] = (int)(hq_ac_syms[val] * > (unsigned)q[pos]) >> 12; > pos++; > } > > @@ -124,10 +134,10 @@ static int hq_decode_frame(HQContext *ctx, AVFrame > *pic, GetByteContext *gbc, > int slice, start_off, next_off, i, ret; > > if ((unsigned)prof_num >= NUM_HQ_PROFILES) { > -profile = &ff_hq_profile[0]; > +profile = &hq_profile[0]; > avpriv_request_sample(ctx->avctx, "HQ Profile %d", prof_num); > } else { > -profile = &ff_hq_profile[prof_num]; > +profile = &hq_profile[prof_num]; > av_log(ctx->avctx, AV_LOG_VERBOSE, "HQ Profile %d\n", prof_num); > } > > @@ -362,6 +372,17 @@ static int hq_hqa_decode_frame(AVCodecContext *avctx, > AVFrame *pic, > return avpkt->size; > } > > +static av_cold int hq_init_vlcs(HQContext *c) > +{ > +int ret = vlc_init(&c->hqa_cbp_vlc, 5, FF_ARRAY_ELEMS(cbp_vlc_lens), > + cbp_vlc_lens, 1, 1, cbp_vlc_bits, 1, 1, 0); > +if (ret < 0) > +return ret; > + > +return vlc_init(&c->hq_ac_vlc, 9, NUM_HQ_AC_ENTRIES, > +hq_ac_bits, 1, 1, hq_ac_codes, 2, 2, 0); > +} > + > static av_cold int hq_hqa_decode_init(AVCodecContext *avctx) > { > HQContext *ctx = avctx->priv_data; > @@ -369,7 +390,7 @@ static av_cold int hq_hqa_decode_init(AVCodecContext > *avctx) > > ff_hqdsp_init(&ctx->hqhqadsp); > > -return ff_hq_init_vlcs(ctx); > +return hq_init_v
Re: [FFmpeg-devel] [PATCH] lavc/aarch64/fdct: add neon-optimized fdct for aarch64
On Wed, 6 Mar 2024, Ramiro Polla wrote: ping Did you miss my response here? https://ffmpeg.org/pipermail/ffmpeg-devel/2024-February/321448.html // Martin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/3] avformat/dvdvideodec: add menu demuxing support
Thank you Stefano for the review on the whole set. I will take the feedback and come back with a better organized set in the next 2 or so days. On Wed, Mar 6, 2024 at 09:42 Stefano Sabatini wrote: > On date Wednesday 2024-03-06 01:19:12 -0600, Marth64 wrote: > > Many DVDs have valuable assets in their menu structures, including > background > > video or music. Some discs also abuse the menu feature to include actual > > feature footage that needs to change aspect ratio (in order to trick the > DVD player). > > > > This patch allows extraction and archival of these assets, but does not > enable > > controllable playback (which needs a full-fledged player and nav VM). > > Menus are processed directly with dvdread and the existing foundation of > the demuxer. > > > > Will eventually add option to list their coordinates as well, so users > > do not have to rely on other tools to find them. > > > > Signed-off-by: Marth64 > > --- > > doc/demuxers.texi | 43 +- > > libavformat/dvdvideodec.c | 315 -- > > 2 files changed, 339 insertions(+), 19 deletions(-) > > > > diff --git a/doc/demuxers.texi b/doc/demuxers.texi > > index 1a17c6db16..e2ea66c1a5 100644 > > --- a/doc/demuxers.texi > > +++ b/doc/demuxers.texi > > @@ -289,8 +289,10 @@ This demuxer accepts the following option: > > > > DVD-Video demuxer, powered by libdvdnav and libdvdread. > > > > -Can directly ingest DVD titles, specifically sequential PGCs, > > -into a conversion pipeline. Menus and seeking are not supported at this > time. > > +Can directly ingest DVD titles, specifically sequential PGCs, into > > +a conversion pipeline. Menu assets, such as background video or audio, > > +can also be demuxed given the menu's coordinates (at best effort). > > +Seeking is not supported at this time. > > > > Block devices (DVD drives), ISO files, and directory structures are > accepted. > > Activate with @code{-f dvdvideo} in front of one of these inputs. > > @@ -347,37 +349,56 @@ This demuxer accepts the following options: > > > > @item title @var{int} > > The title number to play. Must be set if @option{pgc} and @option{pg} > are not set. > > +Not applicable to menus. > > Default is 0 (auto), which currently only selects the first available > title (title 1) > > and notifies the user about the implications. > > > > @item chapter_start @var{int} > > -The chapter, or PTT (part-of-title), number to start at. Default is 1. > > +The chapter, or PTT (part-of-title), number to start at. Not applicable > to menus. > > +Default is 1. > > > > @item chapter_end @var{int} > > -The chapter, or PTT (part-of-title), number to end at. Default is 0, > > -which is a special value to signal end at the last possible chapter. > > +The chapter, or PTT (part-of-title), number to end at. Not applicable > to menus. > > +Default is 0, which is a special value to signal end at the last > possible chapter. > > > > @item angle @var{int} > > The video angle number, referring to what is essentially an additional > > video stream that is composed from alternate frames interleaved in the > VOBs. > > +Not applicable to menus. > > Default is 1. > > > > @item region @var{int} > > The region code to use for playback. Some discs may use this to default > playback > > at a particular angle in different regions. This option will not affect > the region code > > -of a real DVD drive, if used as an input. Default is 0, "world". > > +of a real DVD drive, if used as an input. Not applicable to menus. > > +Default is 0, "world". > > + > > > +@item menu @var{bool} > > +Demux menu assets instead of navigating a title. Requires exact > coordinates > > +of the menu (@option{menu_lu}, @option{menu_vts}, @option{pgc}, > @option{pg}). > > +Default is false. > > + > > > +@item menu_lu @var{int} > > +The menu language to demux. In DVD, menus are grouped by language. > > +Default is 0, the first language unit. > > + > > +@item menu_vts @var{int} > > +The VTS where the menu lives, or 0 if it is a VMG menu (root-level). > > +Default is 0, VMG menu. > > > > @item pgc @var{int} > > The entry PGC to start playback, in conjunction with @option{pg}. > > Alternative to setting @option{title}. > > Chapter markers are not supported at this time. > > +Must be explicitly set for menus. > > Default is 0, automatically resolve from value of @option{title}. > > > > @item pg @var{int} > > The entry PG to start playback, in conjunction with @option{pgc}. > > Alternative to setting @option{title}. > > Chapter markers are not supported at this time. > > -Default is 0, automatically resolve from value of @option{title}. > > +Default is 0, automatically resolve from value of @option{title}, or > > +start from the beginning (PG 1) of the menu. > > > > @item preindex @var{bool} > > Enable this to have accurate chapter (PTT) markers and duration > measurement, > > @@ -385,6 +406,7 @@ which requires a slow second pass read in order to > index the chapter marker
Re: [FFmpeg-devel] [PATCH] avcodec/libx264: fix extradata when config annexb=0
> -Original Message- > From: ffmpeg-devel On Behalf Of Andreas > Rheinhardt > Sent: 2024年3月7日 0:24 > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH] avcodec/libx264: fix extradata when > config annexb=0 > > Zhao Zhili: > > > > > >> -Original Message- > >> From: ffmpeg-devel On Behalf Of Andreas > >> Rheinhardt > >> Sent: 2024年3月6日 22:19 > >> To: ffmpeg-devel@ffmpeg.org > >> Subject: Re: [FFmpeg-devel] [PATCH] avcodec/libx264: fix extradata when > >> config annexb=0 > >> > >> Zhao Zhili: > >>> From: Zhao Zhili > >>> > >>> --- > >>> configure| 2 +- > >>> libavcodec/libx264.c | 148 --- > >>> 2 files changed, 125 insertions(+), 25 deletions(-) > >>> > >>> diff --git a/configure b/configure > >>> index bbf1a70731..ef58c3fe97 100755 > >>> --- a/configure > >>> +++ b/configure > >>> @@ -3491,7 +3491,7 @@ libwebp_encoder_deps="libwebp" > >>> libwebp_anim_encoder_deps="libwebp" > >>> libx262_encoder_deps="libx262" > >>> libx264_encoder_deps="libx264" > >>> -libx264_encoder_select="atsc_a53" > >>> +libx264_encoder_select="atsc_a53 h264parse" > >>> libx264rgb_encoder_deps="libx264" > >>> libx264rgb_encoder_select="libx264_encoder" > >>> libx265_encoder_deps="libx265" > >>> diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c > >>> index 10d646bd76..10dfda125d 100644 > >>> --- a/libavcodec/libx264.c > >>> +++ b/libavcodec/libx264.c > >>> @@ -34,9 +34,12 @@ > >>> #include "avcodec.h" > >>> #include "codec_internal.h" > >>> #include "encode.h" > >>> +#include "get_bits.h" > >>> +#include "h264_ps.h" > >>> #include "internal.h" > >>> #include "packet_internal.h" > >>> #include "atsc_a53.h" > >>> +#include "put_bits.h" > >>> #include "sei.h" > >>> > >>> #include > >>> @@ -865,6 +868,124 @@ static int convert_pix_fmt(enum AVPixelFormat > >>> pix_fmt) > >>> return 0; > >>> } > >>> > >>> +static int set_avcc_extradata(AVCodecContext *avctx, x264_nal_t *nal, > >>> int nnal) > >>> +{ > >>> +x264_nal_t *sps_nal = NULL; > >>> +x264_nal_t *pps_nal = NULL; > >>> +GetBitContext gbc; > >>> +PutBitContext pbc; > >>> +H264ParamSets ps = { 0 }; > >>> +uint8_t *p; > >>> +int ret, profile; > >>> + > >>> +/* We know it's in the order of SPS/PPS/SEI, but it's not documented > >>> in x264 API. > >>> + * The x264 param i_sps_id implies there is a single pair of SPS/PPS. > >>> + */ > >>> +for (int i = 0; i < nnal; i++) { > >>> +if (nal[i].i_type == NAL_SPS) > >>> +sps_nal = &nal[i]; > >>> +else if (nal[i].i_type == NAL_PPS) > >>> +pps_nal = &nal[i]; > >>> +} > >>> +av_assert0(sps_nal); > >>> +av_assert0(pps_nal); > >> > >> We should never assert on the output of external libraries. > > > > Ok, will just remove the assert. I don't think a check is needed. > > > >> > >>> + > >>> +// +11 for AVCDecoderConfigurationRecord, will shrink to the real > >>> size finally > >>> +avctx->extradata_size = sps_nal->i_payload + pps_nal->i_payload + 11; > >>> +avctx->extradata = av_mallocz(avctx->extradata_size + > >>> AV_INPUT_BUFFER_MIN_SIZE); > >> > >> AV_INPUT_BUFFER_PADDING_SIZE > > > > Oops. > > > >> > >>> +if (!avctx->extradata) > >>> +return AVERROR(ENOMEM); > >>> + > >>> +// Skip size part > >>> +p = sps_nal->p_payload + 4; > >>> +init_get_bits8(&gbc, p, sps_nal->i_payload - 4); > >>> +skip_bits(&gbc, 8); > >>> +ret = ff_h264_decode_seq_parameter_set(&gbc, avctx, &ps, 0); > >> > >> This is completely overblown. You only read three fields: profile_idc, > >> the constraint fields and level_idc. All three are at the start of the > >> SPS and occupy a whole byte, so there is no need for a GetBitContext at > >> all. > >> (Yes, I am aware of the hypothetical scenario in which we could have a > >> 0x03 escape byte before level_idc (in case of a hypothetical future > >> profile zero), but even then using ff_h264_decode_seq_parameter_set() is > >> overblown.) > > > > You missed chroma_format_idc, bit_depth_luma/bit_depth_chroma. > > I can get that from pixel format, but there are a lot of them. > > > > Ok, but even then I fail to see a convenience advantage here. After all, > using it e.g. forces the following loop onto you. And it forces cleanup > code here. Also, there is a gotcha here. See below. I didn't use ff_h264_decode_seq_parameter_set at first, until met chroma_format_idc. Get it from multiple pixel format doesn't like the right way to go. Manually decode golomb is code duplication. The following loop can be removed by using i_sps_id from x264 params. Loop over sps_list is more self-contained. For hevc, it will be more complex and unlikely to avoid ff_hevc_decode_nal_. > > >> > >>> +if (ret < 0) > >>> +return ret; > >>> + > >>> +for (int i = 0; i < FF_ARRAY_ELEMS(ps.sps_list); i++) { > >>> +if (ps.sps_list[i]) { > >>> +ps.sps = ps.sps_list[i
[FFmpeg-devel] Facebook
Hi all Today ive received notifications for password reset requests on my facebook account ive loged in and tried enabling 2FA but facebook refused. It seems my account also had access to the FFmpeg facebook page. Which i believe hasnt been used in the last few years, but maybe iam wrong. Either way, facebook suspended my account, ive started an appeal I have no idea if any of this affects FFmpeg. Maybe it does not But it seems someone at least tried attacking my account. And i couldnt imagine why except to access the ffmpeg page. I dont think i ever used facebook except for FFmpeg. thx -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB it is not once nor twice but times without number that the same ideas make their appearance in the world. -- Aristotle signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avcodec/h264_ps: Fix shadowing
Signed-off-by: Andreas Rheinhardt --- libavcodec/h264_ps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c index dcc51b96db..3c8fc33c7f 100644 --- a/libavcodec/h264_ps.c +++ b/libavcodec/h264_ps.c @@ -522,7 +522,7 @@ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx, sps->vui_parameters_present_flag = get_bits1(gb); if (sps->vui_parameters_present_flag) { -int ret = decode_vui_parameters(gb, avctx, sps); +ret = decode_vui_parameters(gb, avctx, sps); if (ret < 0) goto fail; } -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 7/9] avformat/pcm: use a common default packet size function for both wav and pcm
On Tue, Mar 05, 2024 at 11:51:45PM +0100, Marton Balint wrote: > Signed-off-by: Marton Balint > --- > libavformat/pcm.c| 38 ++ > libavformat/pcm.h| 1 + > libavformat/wavdec.c | 11 ++- > 3 files changed, 29 insertions(+), 21 deletions(-) breaks: ./ffmpeg -i H8Le.xmd -bitexact -f framecrc - [in#0/xmd @ 0x55737c355980] Error during demuxing: Invalid argument [aost#0:0/pcm_s16le @ 0x55737c35a0c0] No filtered frames for output stream, trying to initialize anyway. #tb 0: 1/44100 #media_type 0: audio #codec_id 0: pcm_s16le #sample_rate 0: 44100 #channel_layout_name 0: stereo Output #0, framecrc, to 'pipe:': Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s Metadata: encoder : Lavc pcm_s16le [out#0/framecrc @ 0x55737c357e80] video:0KiB audio:0KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: unknown [out#0/framecrc @ 0x55737c357e80] Output file is empty, nothing was encoded(check -ss / -t / -frames parameters if used) size= 0KiB time=N/A bitrate=N/A speed=N/A file is here: https://0x0.st/H8Le.xmd thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is what and why we do it that matters, not just one of them. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/mxfenc: add h264_mp4toannexb bitstream filter if needed when muxing h264
lör 2024-02-24 klockan 15:13 +0100 skrev Andreas Rheinhardt: > Tomas Härdin: > > > > > +static int mxf_check_bitstream(AVFormatContext *s, AVStream > > > > > *st, > > > > > const AVPacket *pkt) > > > > > +{ > > > > > + if (st->codecpar->codec_id == AV_CODEC_ID_H264) { > > > > > + if (pkt->size >= 5 && AV_RB32(pkt->data) != > > > > > 0x001 && > > > > > + AV_RB24(pkt->data) != > > > > > 0x01) > > > > > + return ff_stream_add_bitstream_filter(st, > > > > > "h264_mp4toannexb", NULL); > > > > Regardless of the comments below, this is wrong. ST 381-3 says > > this: > > > > > The byte stream format can be constructed from the NAL unit > > > stream by > > > prefixing each NAL unit with a start > > > code prefix and zero or more zero-valued bytes to form a stream > > > of > > > bytes. > > > > Note the wording is "zero or more", not "zero or one". > > IMO all the code should only look at extradata to decide whether a > stream is annex B or ISOBMFF (no extradata->annex B, no ISOBMFF > extradata->annex B, else ISOBMFF). But that is a separate issue. > (There is a slight possibility of misdetection here: E.g. a 0x00 00 > 01 > at the start of a packet can actually be the start of the length code > of > an ISOBMFF NALU with length in the range 256-511; on the other hand, > it > is legal for an annex B packet to start with four or more zero bytes, > as > you mentioned.) > > > The correct way to do this is to inspect byte 14 of the EC UL, per > > section 8.1 of ST 381-3. > > This is a patch for the muxer, not the demuxer. D'oh! Then it's an entirely different thing of course. Then the onus falls on lavf internals to behave correctly. > There is no byte 14 of > the EC UL to inspect; or at least: It is what this muxer writes for > it. > This muxer always indicates that the output is an annex B (aka AVC > byte > stream), so it should always convert the input from the user to > actually > be annex B. We could do that, or we could write an appropriate UL. Either is fine I suppose. /Tomas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avutil/avstring: Use proper types
Signed-off-by: Andreas Rheinhardt --- libavutil/avstring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/avstring.c b/libavutil/avstring.c index 8751ce5576..2071dd36a5 100644 --- a/libavutil/avstring.c +++ b/libavutil/avstring.c @@ -345,7 +345,7 @@ int av_escape(char **dst, const char *src, const char *special_chars, int av_match_name(const char *name, const char *names) { const char *p; -int len, namelen; +size_t len, namelen; if (!name || !names) return 0; -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avcodec/xpmdec: Use LUT for hex char->number conversion
Speeds up decoding and also reduces binary size. Signed-off-by: Andreas Rheinhardt --- libavcodec/xpmdec.c | 25 - 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/libavcodec/xpmdec.c b/libavcodec/xpmdec.c index 5bc02378c8..804cf8568d 100644 --- a/libavcodec/xpmdec.c +++ b/libavcodec/xpmdec.c @@ -193,15 +193,22 @@ static const ColorEntry color_table[] = { static unsigned hex_char_to_number(uint8_t x) { -if (x >= 'a' && x <= 'f') -x -= 'a' - 10; -else if (x >= 'A' && x <= 'F') -x -= 'A' - 10; -else if (x >= '0' && x <= '9') -x -= '0'; -else -x = 0; -return x; +#define TIMES256(idx) \ +TIMES64(4 * (idx)) TIMES64(4 * (idx) + 1) TIMES64(4 * (idx) + 2) TIMES64(4 * (idx) + 3) +#define TIMES64(idx) \ +TIMES16(4 * (idx)) TIMES16(4 * (idx) + 1) TIMES16(4 * (idx) + 2) TIMES16(4 * (idx) + 3) +#define TIMES16(idx) \ +TIMES4(4 * (idx)) TIMES4(4 * (idx) + 1) TIMES4(4 * (idx) + 2) TIMES4(4 * (idx) + 3) +#define TIMES4(idx) \ +ENTRY(4 * (idx)) ENTRY(4 * (idx) + 1) ENTRY(4 * (idx) + 2) ENTRY(4 * (idx) + 3) +#define ENTRY(x) [x] = ((x) >= 'a' && (x) <= 'f') ? (x) - ('a' - 10) : \ + ((x) >= 'A' && (x) <= 'F') ? (x) - ('A' - 10) : \ + ((x) >= '0' && (x) <= '9') ? (x) - '0' : 0, + +static const uint8_t lut[] = { +TIMES256(0) +}; +return lut[x]; } /* -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avcodec/xbmdec: Use LUT for hex char->number conversion
Improves performance by about 30%. Signed-off-by: Andreas Rheinhardt --- [1] is a patch that would also move the bitreverse into the LUT; it didn't make a difference in the benchmarks here, but if it is an improvement for someone else, it could still be applied. [1]: https://github.com/mkver/FFmpeg/commit/d4fdac5335d2ccf29f7b55fe3147edf388bb7efa libavcodec/xbmdec.c | 27 --- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/libavcodec/xbmdec.c b/libavcodec/xbmdec.c index ecfc957a3f..2d84327e02 100644 --- a/libavcodec/xbmdec.c +++ b/libavcodec/xbmdec.c @@ -28,17 +28,22 @@ static int get_nibble(uint8_t x) { -int ret = 255; - -if (x <= '9') { -if (x >= '0') -ret = x - '0'; -} else if (x >= 'a') { -if (x <= 'f') -ret = x - ('a' - 10); -} else if (x >= 'A' && x <= 'F') -ret = x - ('A' - 10); -return ret; +#define TIMES256(idx) \ +TIMES64(4 * (idx)) TIMES64(4 * (idx) + 1) TIMES64(4 * (idx) + 2) TIMES64(4 * (idx) + 3) +#define TIMES64(idx) \ +TIMES16(4 * (idx)) TIMES16(4 * (idx) + 1) TIMES16(4 * (idx) + 2) TIMES16(4 * (idx) + 3) +#define TIMES16(idx) \ +TIMES4(4 * (idx)) TIMES4(4 * (idx) + 1) TIMES4(4 * (idx) + 2) TIMES4(4 * (idx) + 3) +#define TIMES4(idx) \ +ENTRY(4 * (idx)) ENTRY(4 * (idx) + 1) ENTRY(4 * (idx) + 2) ENTRY(4 * (idx) + 3) +#define ENTRY(x) [x] = ((x) >= 'a' && (x) <= 'f') ? (x) - ('a' - 10) : \ + ((x) >= 'A' && (x) <= 'F') ? (x) - ('A' - 10) : \ + ((x) >= '0' && (x) <= '9') ? (x) - '0' : 255, + +static const uint8_t lut[] = { +TIMES256(0) +}; +return lut[x]; } static int parse_str_int(const uint8_t *p, const uint8_t *end, const uint8_t *key) -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [RFC] clarifying the TC conflict of interest rule
On Tue, Mar 05, 2024 at 11:27:22AM +0100, Anton Khirnov wrote: > Quoting Michael Niedermayer (2024-03-05 03:50:01) > > The STF opertunity had a deadline. > > Also we can already start discussing what shall be done when the next grant > > opertunity comes. > > How about some actual transparency Theres a wiki: https://trac.ffmpeg.org/wiki/SponsoringPrograms/STF/2024 that contains an application only 2 people filled out the application also Pierre collected the SoWs, only 2 people submitted any SoWs I do remember asking you to submit something and IIRC you said that you are waiting for the vote outcome. But you never submitted anything I also tried to contact everyone else, who at the time had something incomplete on the wiki and their name. This (and other people also not submitting any SoWs) caused us to fall below teh 150k€ minimum so i tried to fill the missing space with added work so we reach the minimum. at night on the 12th/morning 13th february i was CC-ed on the application submission to STF " a draft corresponding to the community-driven proposals found in [wiki]." Tara from STF then reworked this and asked us various additional information: (estimated effort (people hours) per milestone, and the fully loaded hourly rate (the price rate, so the cost divided by total number of hours).) "If you want to invoice after each sub milestone, then you need to break down the total cost per milestone into each sub milestone (and by extension also the estimated effort)." Others, I and niklas then helped fill the missing things in quickly before the deadline Someone along the line added more incomplete proposals to the wiki after the deadline But same as with others, no SoWs where submitted, and none of the details needed in the application where filled out. > instead of backroom deals, for a > change. iam sorry, but these accusations are not acceptable The application was and is on a public wiki the SoWs where collected by pierre and it was publically announced before. I tried to contact all people before the deadline who had incomplete submissions. I think for a change you should say thanks to tara, pierre, SPI, STF and others doing all the work. Instead of accusations. And you should submit a proposal with SoW and all needed information next time. Similarly others should too. The idea of this was never to have just 2 people submit SoWs > > The application has apparently been submitted, with no public > announcement that it even happened, much less what was in it. whats in it, should simlpy be what was on the wiki application plus the fixes and cleanups mentioned above thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Everything should be made as simple as possible, but not simpler. -- Albert Einstein signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avcodec/vulkan_video: Remove unused array
Signed-off-by: Andreas Rheinhardt --- libavcodec/vulkan_video.c | 12 1 file changed, 12 deletions(-) diff --git a/libavcodec/vulkan_video.c b/libavcodec/vulkan_video.c index a87df52871..dc6652709f 100644 --- a/libavcodec/vulkan_video.c +++ b/libavcodec/vulkan_video.c @@ -309,7 +309,6 @@ av_cold int ff_vk_video_common_init(void *log, FFVulkanContext *s, int err; VkResult ret; FFVulkanFunctions *vk = &s->vkfn; -VkMemoryRequirements2 *mem_req = NULL; VkVideoSessionMemoryRequirementsKHR *mem = NULL; VkBindVideoSessionMemoryInfoKHR *bind_mem = NULL; @@ -340,11 +339,6 @@ av_cold int ff_vk_video_common_init(void *log, FFVulkanContext *s, err = AVERROR(ENOMEM); goto fail; } -mem_req = av_mallocz(sizeof(*mem_req)*common->nb_mem); -if (!mem_req) { -err = AVERROR(ENOMEM); -goto fail; -} bind_mem = av_mallocz(sizeof(*bind_mem)*common->nb_mem); if (!bind_mem) { err = AVERROR(ENOMEM); @@ -353,12 +347,8 @@ av_cold int ff_vk_video_common_init(void *log, FFVulkanContext *s, /* Set the needed fields to get the memory requirements */ for (int i = 0; i < common->nb_mem; i++) { -mem_req[i] = (VkMemoryRequirements2) { -.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2, -}; mem[i] = (VkVideoSessionMemoryRequirementsKHR) { .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_MEMORY_REQUIREMENTS_KHR, -.memoryRequirements = mem_req[i].memoryRequirements, }; } @@ -400,14 +390,12 @@ av_cold int ff_vk_video_common_init(void *log, FFVulkanContext *s, } av_freep(&mem); -av_freep(&mem_req); av_freep(&bind_mem); return 0; fail: av_freep(&mem); -av_freep(&mem_req); av_freep(&bind_mem); ff_vk_video_common_uninit(s, common); -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] fate: fix sub2video_{basic, time_limited} on big-endian targets
The reference file uses BGRA pixel format, so request it here. --- tests/fate/ffmpeg.mak | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/fate/ffmpeg.mak b/tests/fate/ffmpeg.mak index 669c878c7f..77e93693b9 100644 --- a/tests/fate/ffmpeg.mak +++ b/tests/fate/ffmpeg.mak @@ -62,6 +62,7 @@ fate-sub2video: CMD = framecrc -auto_conversion_filters \ FATE_SAMPLES_FFMPEG-$(call FRAMECRC, VOBSUB, DVDSUB, SCALE_FILTER) += fate-sub2video_basic fate-sub2video_basic: CMD = framecrc -auto_conversion_filters \ -i $(TARGET_SAMPLES)/sub/vobsub.idx \ + -pix_fmt bgra \ -fps_mode passthrough -copyts \ -filter_complex "sws_flags=+accurate_rnd+bitexact\;[0:s:0]scale" \ -c:v rawvideo -threads 1 @@ -71,6 +72,7 @@ fate-sub2video_basic: CMD = framecrc -auto_conversion_filters \ FATE_SAMPLES_FFMPEG-$(call FRAMECRC, SUP, PGSSUB, SCALE_FILTER RAWVIDEO_ENCODER) += fate-sub2video_time_limited fate-sub2video_time_limited: CMD = framecrc -auto_conversion_filters \ -i $(TARGET_SAMPLES)/sub/pgs_sub.sup \ + -pix_fmt bgra \ -fps_mode passthrough -copyts \ -t 15 \ -filter_complex "sws_flags=+accurate_rnd+bitexact\;[0:s:0]scale" \ -- 2.39.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avcodec/vaapi_encode: add customized surface alignment
This commit fixes issues with AMD HEVC encoding. By default AMD hevc encoder asks for the alignment 64x16, while FFMPEG VAAPI has 16x16. Adding support for customzied surface size from VASurfaceAttribAlignmentSize in VAAPI version 1.21.0. To: primeadv...@gmail.com Signed-off-by: Araz Iusubov --- libavcodec/vaapi_encode.c | 11 +++ libavutil/hwcontext.h | 7 +++ libavutil/hwcontext_vaapi.c | 5 + 3 files changed, 23 insertions(+) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 808b79c0c7..dc1b7465b7 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -2700,6 +2700,17 @@ static av_cold int vaapi_encode_create_recon_frames(AVCodecContext *avctx) av_log(avctx, AV_LOG_DEBUG, "Using %s as format of " "reconstructed frames.\n", av_get_pix_fmt_name(recon_format)); +if (constraints->log2_alignment) { +ctx->surface_width = FFALIGN(avctx->width, + 1 << (constraints->log2_alignment & 0xf)); +ctx->surface_height = FFALIGN(avctx->height, + 1 << ((constraints->log2_alignment & 0xf0) >> 4)); +av_log(avctx, AV_LOG_VERBOSE, "Using customized alignment size " +"[%dx%d].\n", +(1 << (constraints->log2_alignment & 0xf)), +(1 << ((constraints->log2_alignment & 0xf0) >> 4))); +} + if (ctx->surface_width < constraints->min_width || ctx->surface_height < constraints->min_height || ctx->surface_width > constraints->max_width || diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h index df7733fe5e..5725245be4 100644 --- a/libavutil/hwcontext.h +++ b/libavutil/hwcontext.h @@ -481,6 +481,13 @@ typedef struct AVHWFramesConstraints { */ int max_width; int max_height; + +/** + * The frame width/height log2 alignment when available + * the lower 4 bits, width; another 4 bits, height + * (Zero is not applied, use the default value) + */ +int log2_alignment; } AVHWFramesConstraints; /** diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 2c75f5f5b1..161623bc27 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -294,6 +294,11 @@ static int vaapi_frames_get_constraints(AVHWDeviceContext *hwdev, case VASurfaceAttribMaxHeight: constraints->max_height = attr_list[i].value.value.i; break; +#if VA_CHECK_VERSION(1, 21, 0) +case VASurfaceAttribAlignmentSize: +constraints->log2_alignment = attr_list[i].value.value.i; +break; +#endif } } if (pix_fmt_count == 0) { -- 2.43.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/4] avcodec/vulkan_decode: Un-sparse extensions table
Only three of the 226 (== AV_CODEC_ID_AV1) entries have been used. Unsparsing this table is especially important given that this array lives in .data.rel.ro. Signed-off-by: Andreas Rheinhardt --- libavcodec/vulkan_av1.c| 1 + libavcodec/vulkan_decode.c | 13 + libavcodec/vulkan_decode.h | 2 ++ libavcodec/vulkan_h264.c | 1 + libavcodec/vulkan_hevc.c | 1 + 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c index 03ae553ff8..5afd5353cc 100644 --- a/libavcodec/vulkan_av1.c +++ b/libavcodec/vulkan_av1.c @@ -24,6 +24,7 @@ #define MAX_TILES 256 const FFVulkanDecodeDescriptor ff_vk_dec_av1_desc = { +.codec_id = AV_CODEC_ID_AV1, .decode_extension = FF_VK_EXT_VIDEO_DECODE_AV1, .decode_op= 0x0100, /* TODO fix this */ .ext_props = { diff --git a/libavcodec/vulkan_decode.c b/libavcodec/vulkan_decode.c index 6777aa5887..233b5792d8 100644 --- a/libavcodec/vulkan_decode.c +++ b/libavcodec/vulkan_decode.c @@ -20,6 +20,7 @@ #include "vulkan_video.h" #include "vulkan_decode.h" #include "config_components.h" +#include "libavutil/avassert.h" #include "libavutil/vulkan_loader.h" #if CONFIG_H264_VULKAN_HWACCEL @@ -34,19 +35,23 @@ extern const FFVulkanDecodeDescriptor ff_vk_dec_av1_desc; static const FFVulkanDecodeDescriptor *dec_descs[] = { #if CONFIG_H264_VULKAN_HWACCEL -[AV_CODEC_ID_H264] = &ff_vk_dec_h264_desc, +&ff_vk_dec_h264_desc, #endif #if CONFIG_HEVC_VULKAN_HWACCEL -[AV_CODEC_ID_HEVC] = &ff_vk_dec_hevc_desc, +&ff_vk_dec_hevc_desc, #endif #if CONFIG_AV1_VULKAN_HWACCEL -[AV_CODEC_ID_AV1] = &ff_vk_dec_av1_desc, +&ff_vk_dec_av1_desc, #endif }; static const FFVulkanDecodeDescriptor *get_codecdesc(enum AVCodecID codec_id) { -return dec_descs[codec_id]; +for (size_t i = 0; i < FF_ARRAY_ELEMS(dec_descs); i++) +if (dec_descs[i]->codec_id == codec_id) +return dec_descs[i]; +av_assert1(!"no codec descriptor"); +return NULL; } static const VkVideoProfileInfoKHR *get_video_profile(FFVulkanDecodeShared *ctx, enum AVCodecID codec_id) diff --git a/libavcodec/vulkan_decode.h b/libavcodec/vulkan_decode.h index 3e7cd38774..a43e328d73 100644 --- a/libavcodec/vulkan_decode.h +++ b/libavcodec/vulkan_decode.h @@ -19,6 +19,7 @@ #ifndef AVCODEC_VULKAN_DECODE_H #define AVCODEC_VULKAN_DECODE_H +#include "codec_id.h" #include "decode.h" #include "hwaccel_internal.h" #include "internal.h" @@ -26,6 +27,7 @@ #include "vulkan_video.h" typedef struct FFVulkanDecodeDescriptor { +enum AVCodecID codec_id; FFVulkanExtensions decode_extension; VkVideoCodecOperationFlagBitsKHR decode_op; diff --git a/libavcodec/vulkan_h264.c b/libavcodec/vulkan_h264.c index 695b986a7c..0b296b3cc3 100644 --- a/libavcodec/vulkan_h264.c +++ b/libavcodec/vulkan_h264.c @@ -22,6 +22,7 @@ #include "vulkan_decode.h" const FFVulkanDecodeDescriptor ff_vk_dec_h264_desc = { +.codec_id = AV_CODEC_ID_H264, .decode_extension = FF_VK_EXT_VIDEO_DECODE_H264, .decode_op= VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR, .ext_props = { diff --git a/libavcodec/vulkan_hevc.c b/libavcodec/vulkan_hevc.c index e3a1319958..e2acc35612 100644 --- a/libavcodec/vulkan_hevc.c +++ b/libavcodec/vulkan_hevc.c @@ -23,6 +23,7 @@ #include "vulkan_decode.h" const FFVulkanDecodeDescriptor ff_vk_dec_hevc_desc = { +.codec_id = AV_CODEC_ID_HEVC, .decode_extension = FF_VK_EXT_VIDEO_DECODE_H265, .decode_op= VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR, .ext_props = { -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/4] avcodec/vulkan_decode: Remove always-false check
These fields are set for all Vulkan decoding hwaccels; they would be useless if it were different. Signed-off-by: Andreas Rheinhardt --- libavcodec/vulkan_decode.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libavcodec/vulkan_decode.c b/libavcodec/vulkan_decode.c index 233b5792d8..91929d165f 100644 --- a/libavcodec/vulkan_decode.c +++ b/libavcodec/vulkan_decode.c @@ -780,11 +780,7 @@ static int vulkan_decode_get_profile(AVCodecContext *avctx, AVBufferRef *frames_ VkVideoFormatPropertiesKHR *ret_info; uint32_t nb_out_fmts = 0; -if (!vk_desc->decode_op || !vk_desc->decode_extension) { -av_log(avctx, AV_LOG_ERROR, "Unsupported codec for Vulkan decoding: %s!\n", - avcodec_get_name(avctx->codec_id)); -return AVERROR(ENOSYS); -} else if (!(vk_desc->decode_extension & ctx->s.extensions)) { +if (!(vk_desc->decode_extension & ctx->s.extensions)) { av_log(avctx, AV_LOG_ERROR, "Device does not support decoding %s!\n", avcodec_get_name(avctx->codec_id)); return AVERROR(ENOSYS); -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/4] avcodec/vulkan_video: Merge dec part of FFVkCodecMap and extension props
All the fields of FFVkCodecMap are either decoder-only or encoder-only (with the latter being unused and unset for now). Yet there is already a per-decoder struct containing static information about these decoders, namely VkExtensionProperties. This commit merges the decoder-parts of FFVkCodecMap with the VkExtensionProperties into a common structure. Given that FFVkCodecMap is now unused, it is removed. Signed-off-by: Andreas Rheinhardt --- Given that these descriptors are decoding-specific, one could drop the decode_ prefix from decode_(op|extension). libavcodec/vulkan_av1.c| 10 +--- libavcodec/vulkan_decode.c | 49 +- libavcodec/vulkan_decode.h | 7 ++ libavcodec/vulkan_h264.c | 10 +--- libavcodec/vulkan_hevc.c | 10 +--- libavcodec/vulkan_video.c | 26 libavcodec/vulkan_video.h | 11 - 7 files changed, 50 insertions(+), 73 deletions(-) diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c index 9730e4b08d..03ae553ff8 100644 --- a/libavcodec/vulkan_av1.c +++ b/libavcodec/vulkan_av1.c @@ -23,9 +23,13 @@ /* Maximum number of tiles specified by any defined level */ #define MAX_TILES 256 -const VkExtensionProperties ff_vk_dec_av1_ext = { -.extensionName = VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_EXTENSION_NAME, -.specVersion = VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_SPEC_VERSION, +const FFVulkanDecodeDescriptor ff_vk_dec_av1_desc = { +.decode_extension = FF_VK_EXT_VIDEO_DECODE_AV1, +.decode_op= 0x0100, /* TODO fix this */ +.ext_props = { +.extensionName = VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_EXTENSION_NAME, +.specVersion = VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_SPEC_VERSION, +}, }; typedef struct AV1VulkanDecodePicture { diff --git a/libavcodec/vulkan_decode.c b/libavcodec/vulkan_decode.c index 2448ee99ec..6777aa5887 100644 --- a/libavcodec/vulkan_decode.c +++ b/libavcodec/vulkan_decode.c @@ -20,38 +20,33 @@ #include "vulkan_video.h" #include "vulkan_decode.h" #include "config_components.h" -#include "libavutil/avassert.h" #include "libavutil/vulkan_loader.h" #if CONFIG_H264_VULKAN_HWACCEL -extern const VkExtensionProperties ff_vk_dec_h264_ext; +extern const FFVulkanDecodeDescriptor ff_vk_dec_h264_desc; #endif #if CONFIG_HEVC_VULKAN_HWACCEL -extern const VkExtensionProperties ff_vk_dec_hevc_ext; +extern const FFVulkanDecodeDescriptor ff_vk_dec_hevc_desc; #endif #if CONFIG_AV1_VULKAN_HWACCEL -extern const VkExtensionProperties ff_vk_dec_av1_ext; +extern const FFVulkanDecodeDescriptor ff_vk_dec_av1_desc; #endif -static const VkExtensionProperties *dec_ext[] = { +static const FFVulkanDecodeDescriptor *dec_descs[] = { #if CONFIG_H264_VULKAN_HWACCEL -[AV_CODEC_ID_H264] = &ff_vk_dec_h264_ext, +[AV_CODEC_ID_H264] = &ff_vk_dec_h264_desc, #endif #if CONFIG_HEVC_VULKAN_HWACCEL -[AV_CODEC_ID_HEVC] = &ff_vk_dec_hevc_ext, +[AV_CODEC_ID_HEVC] = &ff_vk_dec_hevc_desc, #endif #if CONFIG_AV1_VULKAN_HWACCEL -[AV_CODEC_ID_AV1] = &ff_vk_dec_av1_ext, +[AV_CODEC_ID_AV1] = &ff_vk_dec_av1_desc, #endif }; -static const FFVkCodecMap *get_codecmap(enum AVCodecID codec_id) +static const FFVulkanDecodeDescriptor *get_codecdesc(enum AVCodecID codec_id) { -for (size_t i = 0; i < FF_ARRAY_ELEMS(ff_vk_codec_map); i++) -if (ff_vk_codec_map[i].codec_id == codec_id) -return &ff_vk_codec_map[i]; -av_assert1(!"unreachable"); -return NULL; +return dec_descs[codec_id]; } static const VkVideoProfileInfoKHR *get_video_profile(FFVulkanDecodeShared *ctx, enum AVCodecID codec_id) @@ -671,7 +666,7 @@ static VkResult vulkan_setup_profile(AVCodecContext *avctx, FFVulkanDecodeProfileData *prof, AVVulkanDeviceContext *hwctx, FFVulkanFunctions *vk, - const struct FFVkCodecMap *vk_codec, + const FFVulkanDecodeDescriptor *vk_desc, VkVideoDecodeH264CapabilitiesKHR *h264_caps, VkVideoDecodeH265CapabilitiesKHR *h265_caps, VkVideoDecodeAV1CapabilitiesMESA *av1_caps, @@ -722,7 +717,7 @@ static VkResult vulkan_setup_profile(AVCodecContext *avctx, profile->sType = VK_STRUCTURE_TYPE_VIDEO_PROFILE_INFO_KHR; profile->pNext = usage; -profile->videoCodecOperation = vk_codec->decode_op; +profile->videoCodecOperation = vk_desc->decode_op; profile->chromaSubsampling = ff_vk_subsampling_from_av_desc(desc); profile->lumaBitDepth= ff_vk_depth_from_av_depth(desc->comp[0].depth); profile->chromaBitDepth = profile->lumaBitDepth; @@ -748,7 +743,7 @@ static int vulkan_decode_get_profile(AVCodecContext *avctx, AVBufferRef *frames_ { VkResult ret; i
Re: [FFmpeg-devel] [PATCH] lavf/matroskadec: add missing linebreaks in error messages
Anton Khirnov: > --- > libavformat/matroskadec.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c > index 5d3d18a146..6d6a60c552 100644 > --- a/libavformat/matroskadec.c > +++ b/libavformat/matroskadec.c > @@ -2036,7 +2036,7 @@ static int > matroska_parse_content_encodings(MatroskaTrackEncoding *encodings, > { > if (nb_encodings > 1) { > av_log(logctx, AV_LOG_ERROR, > -"Multiple combined encodings not supported"); > +"Multiple combined encodings not supported\n"); > return 0; > } > if (!nb_encodings) > @@ -2055,7 +2055,7 @@ static int > matroska_parse_content_encodings(MatroskaTrackEncoding *encodings, > encodings->encryption.key_id.size); > } else { > encodings->scope = 0; > -av_log(logctx, AV_LOG_ERROR, "Unsupported encoding type"); > +av_log(logctx, AV_LOG_ERROR, "Unsupported encoding type\n"); > } > } else if ( > #if CONFIG_ZLIB > @@ -2067,7 +2067,7 @@ static int > matroska_parse_content_encodings(MatroskaTrackEncoding *encodings, > encodings->compression.algo != MATROSKA_TRACK_ENCODING_COMP_LZO > && > encodings->compression.algo != > MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP) { > encodings->scope = 0; > -av_log(logctx, AV_LOG_ERROR, "Unsupported encoding type"); > +av_log(logctx, AV_LOG_ERROR, "Unsupported encoding type\n"); > } else if (track->codec_priv.size && encodings[0].scope & 2) { > uint8_t *codec_priv = track->codec_priv.data; > int ret = matroska_decode_buffer(&track->codec_priv.data, LGTM. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/2 v2] fftools/ffprobe: export Tile Grid Stream Group parameters
Signed-off-by: James Almer --- fftools/ffprobe.c | 53 --- tests/fate/mov.mak| 6 +-- .../ref/fate/mov-heic-demux-still-image-grid | 29 ++ .../ref/fate/mov-heic-demux-still-image-iovl | 19 +++ .../fate/mov-heic-demux-still-image-iovl-2| 19 +++ 5 files changed, 115 insertions(+), 11 deletions(-) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 4d4a85b5b0..c2ed8336f9 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -113,6 +113,7 @@ static int do_show_frames = 0; static int do_show_packets = 0; static int do_show_programs = 0; static int do_show_stream_groups = 0; +static int do_show_stream_group_components = 0; static int do_show_streams = 0; static int do_show_stream_disposition = 0; static int do_show_stream_group_disposition = 0; @@ -209,6 +210,10 @@ typedef enum { SECTION_ID_STREAM_GROUP_STREAM_DISPOSITION, SECTION_ID_STREAM_GROUP_STREAM_TAGS, SECTION_ID_STREAM_GROUP, +SECTION_ID_STREAM_GROUP_COMPONENTS, +SECTION_ID_STREAM_GROUP_COMPONENT, +SECTION_ID_STREAM_GROUP_SUB_COMPONENTS, +SECTION_ID_STREAM_GROUP_SUB_COMPONENT, SECTION_ID_STREAM_GROUP_STREAMS, SECTION_ID_STREAM_GROUP_STREAM, SECTION_ID_STREAM_GROUP_DISPOSITION, @@ -309,7 +314,11 @@ static struct section sections[] = { [SECTION_ID_PROGRAMS] = { SECTION_ID_PROGRAMS, "programs", SECTION_FLAG_IS_ARRAY, { SECTION_ID_PROGRAM, -1 } }, [SECTION_ID_STREAM_GROUP_STREAM_DISPOSITION] = { SECTION_ID_STREAM_GROUP_STREAM_DISPOSITION, "disposition", 0, { -1 }, .unique_name = "stream_group_stream_disposition" }, [SECTION_ID_STREAM_GROUP_STREAM_TAGS] ={ SECTION_ID_STREAM_GROUP_STREAM_TAGS, "tags", SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "stream_group_stream_tags" }, -[SECTION_ID_STREAM_GROUP] ={ SECTION_ID_STREAM_GROUP, "stream_group", SECTION_FLAG_HAS_TYPE, { SECTION_ID_STREAM_GROUP_TAGS, SECTION_ID_STREAM_GROUP_DISPOSITION, SECTION_ID_STREAM_GROUP_STREAMS, -1 }, .get_type = get_stream_group_type }, +[SECTION_ID_STREAM_GROUP] ={ SECTION_ID_STREAM_GROUP, "stream_group", 0, { SECTION_ID_STREAM_GROUP_TAGS, SECTION_ID_STREAM_GROUP_DISPOSITION, SECTION_ID_STREAM_GROUP_COMPONENTS, SECTION_ID_STREAM_GROUP_STREAMS, -1 } }, +[SECTION_ID_STREAM_GROUP_COMPONENTS] = { SECTION_ID_STREAM_GROUP_COMPONENTS, "components", SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_GROUP_COMPONENT, -1 }, .element_name = "component", .unique_name = "stream_group_components" }, +[SECTION_ID_STREAM_GROUP_COMPONENT] = { SECTION_ID_STREAM_GROUP_COMPONENT, "component", SECTION_FLAG_HAS_VARIABLE_FIELDS|SECTION_FLAG_HAS_TYPE, { SECTION_ID_STREAM_GROUP_SUB_COMPONENTS, -1 }, .unique_name = "stream_group_component", .element_name = "component_entry", .get_type = get_stream_group_type }, +[SECTION_ID_STREAM_GROUP_SUB_COMPONENTS] = { SECTION_ID_STREAM_GROUP_SUB_COMPONENTS, "subcomponents", SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_GROUP_SUB_COMPONENT, -1 }, .element_name = "component" }, +[SECTION_ID_STREAM_GROUP_SUB_COMPONENT] = { SECTION_ID_STREAM_GROUP_SUB_COMPONENT, "subcomponent", SECTION_FLAG_HAS_VARIABLE_FIELDS|SECTION_FLAG_HAS_TYPE, { -1 }, .element_name = "sub_component_entry", .get_type = get_raw_string_type }, [SECTION_ID_STREAM_GROUP_STREAMS] ={ SECTION_ID_STREAM_GROUP_STREAMS, "streams", SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_GROUP_STREAM, -1 }, .unique_name = "stream_group_streams" }, [SECTION_ID_STREAM_GROUP_STREAM] = { SECTION_ID_STREAM_GROUP_STREAM, "stream", 0, { SECTION_ID_STREAM_GROUP_STREAM_DISPOSITION, SECTION_ID_STREAM_GROUP_STREAM_TAGS, -1 }, .unique_name = "stream_group_stream" }, [SECTION_ID_STREAM_GROUP_DISPOSITION] ={ SECTION_ID_STREAM_GROUP_DISPOSITION, "disposition", 0, { -1 }, .unique_name = "stream_group_disposition" }, @@ -3385,13 +3394,35 @@ static int show_programs(WriterContext *w, InputFile *ifile) return ret; } +static void print_tile_grid_params(WriterContext *w, const AVStreamGroup *stg, + const AVStreamGroupTileGrid *tile_grid) +{ +writer_print_section_header(w, stg, SECTION_ID_STREAM_GROUP_COMPONENT); +print_int("nb_tiles", tile_grid->nb_tiles); +print_int("coded_width", tile_grid->coded_width); +print_int("coded_height", tile_grid->coded_height); +print_int("horizontal_offset", tile_grid->horizontal_offset); +print_int("vertical_offset", tile_grid->vertical_offset); +print_int("width", tile_grid->width); +print_int("height",tile_grid->height); +writer_print_section_header(w, NULL, SECTION_ID_STREAM_GROUP_SUB_COMPONENTS); +for (int i = 0; i < tile_grid->nb_tiles; i++) { +writer_print_section_header(w, "tile_offset",
[FFmpeg-devel] [PATCH 2/2] fftools/ffprobe: export IAMF Stream Group parameters
Signed-off-by: James Almer --- fftools/ffprobe.c | 157 +++- tests/fate/iamf.mak | 8 +- tests/fate/mov.mak | 8 +- tests/ref/fate/iamf-5_1_4 | 92 ++ tests/ref/fate/iamf-7_1_4 | 92 ++ tests/ref/fate/iamf-ambisonic_1 | 39 ++ tests/ref/fate/iamf-stereo | 67 ++ tests/ref/fate/mov-mp4-iamf-5_1_4 | 92 ++ tests/ref/fate/mov-mp4-iamf-7_1_4 | 92 ++ tests/ref/fate/mov-mp4-iamf-ambisonic_1 | 39 ++ tests/ref/fate/mov-mp4-iamf-stereo | 67 ++ 11 files changed, 741 insertions(+), 12 deletions(-) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index c2ed8336f9..393f8d2a99 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -41,6 +41,7 @@ #include "libavutil/display.h" #include "libavutil/hash.h" #include "libavutil/hdr_dynamic_metadata.h" +#include "libavutil/iamf.h" #include "libavutil/mastering_display_metadata.h" #include "libavutil/hdr_dynamic_vivid_metadata.h" #include "libavutil/dovi_meta.h" @@ -214,6 +215,12 @@ typedef enum { SECTION_ID_STREAM_GROUP_COMPONENT, SECTION_ID_STREAM_GROUP_SUB_COMPONENTS, SECTION_ID_STREAM_GROUP_SUB_COMPONENT, +SECTION_ID_STREAM_GROUP_PIECES, +SECTION_ID_STREAM_GROUP_PIECE, +SECTION_ID_STREAM_GROUP_SUB_PIECES, +SECTION_ID_STREAM_GROUP_SUB_PIECE, +SECTION_ID_STREAM_GROUP_BLOCKS, +SECTION_ID_STREAM_GROUP_BLOCK, SECTION_ID_STREAM_GROUP_STREAMS, SECTION_ID_STREAM_GROUP_STREAM, SECTION_ID_STREAM_GROUP_DISPOSITION, @@ -287,8 +294,8 @@ static struct section sections[] = { [SECTION_ID_FRAME_SIDE_DATA_TIMECODE] = { SECTION_ID_FRAME_SIDE_DATA_TIMECODE, "timecode", 0, { -1 } }, [SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST] = { SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST, "components", SECTION_FLAG_IS_ARRAY, { SECTION_ID_FRAME_SIDE_DATA_COMPONENT, -1 }, .element_name = "component", .unique_name = "frame_side_data_components" }, [SECTION_ID_FRAME_SIDE_DATA_COMPONENT] = { SECTION_ID_FRAME_SIDE_DATA_COMPONENT, "component", SECTION_FLAG_HAS_VARIABLE_FIELDS|SECTION_FLAG_HAS_TYPE, { SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST, -1 }, .unique_name = "frame_side_data_component", .element_name = "component_entry", .get_type = get_raw_string_type }, -[SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST] = { SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST, "pieces", SECTION_FLAG_IS_ARRAY, { SECTION_ID_FRAME_SIDE_DATA_PIECE, -1 }, .element_name = "piece" }, -[SECTION_ID_FRAME_SIDE_DATA_PIECE] ={ SECTION_ID_FRAME_SIDE_DATA_PIECE, "piece", SECTION_FLAG_HAS_VARIABLE_FIELDS|SECTION_FLAG_HAS_TYPE, { -1 }, .element_name = "piece_entry", .get_type = get_raw_string_type }, +[SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST] = { SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST, "pieces", SECTION_FLAG_IS_ARRAY, { SECTION_ID_FRAME_SIDE_DATA_PIECE, -1 }, .element_name = "piece", .unique_name = "frame_side_data_pieces" }, +[SECTION_ID_FRAME_SIDE_DATA_PIECE] ={ SECTION_ID_FRAME_SIDE_DATA_PIECE, "piece", SECTION_FLAG_HAS_VARIABLE_FIELDS|SECTION_FLAG_HAS_TYPE, { -1 }, .element_name = "piece_entry", .unique_name = "frame_side_data_piece", .get_type = get_raw_string_type }, [SECTION_ID_FRAME_LOGS] = { SECTION_ID_FRAME_LOGS, "logs", SECTION_FLAG_IS_ARRAY, { SECTION_ID_FRAME_LOG, -1 } }, [SECTION_ID_FRAME_LOG] = { SECTION_ID_FRAME_LOG, "log", 0, { -1 }, }, [SECTION_ID_LIBRARY_VERSIONS] = { SECTION_ID_LIBRARY_VERSIONS, "library_versions", SECTION_FLAG_IS_ARRAY, { SECTION_ID_LIBRARY_VERSION, -1 } }, @@ -318,7 +325,13 @@ static struct section sections[] = { [SECTION_ID_STREAM_GROUP_COMPONENTS] = { SECTION_ID_STREAM_GROUP_COMPONENTS, "components", SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_GROUP_COMPONENT, -1 }, .element_name = "component", .unique_name = "stream_group_components" }, [SECTION_ID_STREAM_GROUP_COMPONENT] = { SECTION_ID_STREAM_GROUP_COMPONENT, "component", SECTION_FLAG_HAS_VARIABLE_FIELDS|SECTION_FLAG_HAS_TYPE, { SECTION_ID_STREAM_GROUP_SUB_COMPONENTS, -1 }, .unique_name = "stream_group_component", .element_name = "component_entry", .get_type = get_stream_group_type }, [SECTION_ID_STREAM_GROUP_SUB_COMPONENTS] = { SECTION_ID_STREAM_GROUP_SUB_COMPONENTS, "subcomponents", SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_GROUP_SUB_COMPONENT, -1 }, .element_name = "component" }, -[SECTION_ID_STREAM_GROUP_SUB_COMPONENT] = { SECTION_ID_STREAM_GROUP_SUB_COMPONENT, "subcomponent", SECTION_FLAG_HAS_VARIABLE_FIELDS|SECTION_FLAG_HAS_TYPE, { -1 }, .element_name = "sub_component_entry", .get_type = get_raw_string_type }, +[SECTION_ID_STREAM_GROUP_SUB_COMPONENT] = { SECTION_ID_STREAM_GROUP_SUB_COMPONENT, "subcomponent", SECTION_FLAG_HAS_VARIABLE_FIELDS|SECTION_FLAG_HAS_TYPE, { SECTION_ID_STREAM_GROUP_P
Re: [FFmpeg-devel] [PATCH 3/3] avcodec/vulkan_decode: Un-sparse extensions table
Lynne: > Mar 3, 2024, 12:35 by andreas.rheinha...@outlook.com: > >> Only three of the 226 (== AV_CODEC_ID_AV1) entries >> have been used. Unsparsing this table is especially >> important given that this array lives in .data.rel.ro. >> >> Signed-off-by: Andreas Rheinhardt >> --- >> Instead of parallel tables, one could also merge VkCodecMap and >> VkExtensionProperties (i.e. putting one of the latter inside >> the former) if preferred. >> >> libavcodec/vulkan_decode.c | 28 ++-- >> 1 file changed, 22 insertions(+), 6 deletions(-) >> > > LGTM on commits 1 and 3. > Would you mind keeping the designated initializers from > commit 2 but still keeping it into vulkan_video.c? > Would save on needing to deduplicate it in the future. I still don't know what you mean by "deduplicating" them in the future. Anyway, I have now implemented the approach outlined in the comment above: https://ffmpeg.org/pipermail/ffmpeg-devel/2024-March/322893.html - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [RFC] clarifying the TC conflict of interest rule
> On Mar 7, 2024, at 07:25, Michael Niedermayer via ffmpeg-devel > wrote: > > On Tue, Mar 05, 2024 at 11:27:22AM +0100, Anton Khirnov wrote: >> Quoting Michael Niedermayer (2024-03-05 03:50:01) >>> The STF opertunity had a deadline. >>> Also we can already start discussing what shall be done when the next grant >>> opertunity comes. >> >> How about some actual transparency > > Theres a wiki: > https://trac.ffmpeg.org/wiki/SponsoringPrograms/STF/2024 > that contains an application > only 2 people filled out the application > > also Pierre collected the SoWs, only 2 people submitted any SoWs > > I do remember asking you to submit something and IIRC you said that you > are waiting for the vote outcome. But you never submitted anything > I also tried to contact everyone else, who at the time had something > incomplete > on the wiki and their name. I confirm that I have got the email from Michael. Unfortunately it’s right during Spring festival (Chinese new year). ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 4/4] avcodec/vulkan_decode: Remove always-false check
Mar 7, 2024, 01:33 by andreas.rheinha...@outlook.com: > These fields are set for all Vulkan decoding hwaccels; > they would be useless if it were different. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/vulkan_decode.c | 6 +- > 1 file changed, 1 insertion(+), 5 deletions(-) > > diff --git a/libavcodec/vulkan_decode.c b/libavcodec/vulkan_decode.c > index 233b5792d8..91929d165f 100644 > --- a/libavcodec/vulkan_decode.c > +++ b/libavcodec/vulkan_decode.c > @@ -780,11 +780,7 @@ static int vulkan_decode_get_profile(AVCodecContext > *avctx, AVBufferRef *frames_ > VkVideoFormatPropertiesKHR *ret_info; > uint32_t nb_out_fmts = 0; > > -if (!vk_desc->decode_op || !vk_desc->decode_extension) { > -av_log(avctx, AV_LOG_ERROR, "Unsupported codec for Vulkan decoding: > %s!\n", > - avcodec_get_name(avctx->codec_id)); > -return AVERROR(ENOSYS); > -} else if (!(vk_desc->decode_extension & ctx->s.extensions)) { > +if (!(vk_desc->decode_extension & ctx->s.extensions)) { > av_log(avctx, AV_LOG_ERROR, "Device does not support decoding %s!\n", > avcodec_get_name(avctx->codec_id)); > return AVERROR(ENOSYS); > Patchset LGTM Thanks for the cleanups ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] lavfi/vulkan_filter: fix input format
Mar 6, 2024, 06:26 by haihao.xiang-at-intel@ffmpeg.org: > From: Haihao Xiang > > Otherwise s->input_format is always yuv420p. > > This fixes invalid output format for hwframe download in the command > below: > ./ffmpeg -init_hw_device vulkan -f lavfi \ > -i testsrc=duration=1,format=nv12 \ > -vf 'hwupload,format=vulkan,scale_vulkan=1024:768,hwdownload,format=nv12' \ > -f null - > > Signed-off-by: Haihao Xiang > --- > libavfilter/vulkan_filter.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/libavfilter/vulkan_filter.c b/libavfilter/vulkan_filter.c > index d3dc2fdacb..cef42eeb4d 100644 > --- a/libavfilter/vulkan_filter.c > +++ b/libavfilter/vulkan_filter.c > @@ -187,6 +187,7 @@ int ff_vk_filter_config_input(AVFilterLink *inlink) > s->input_frames_ref = inlink->hw_frames_ctx; > > /* Defaults */ > +s->input_format = input_frames->sw_format; > s->output_format = input_frames->sw_format; > s->output_width = inlink->w; > s->output_height = inlink->h; > LGTM Thanks ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".