Re: [FFmpeg-devel] [PATCH v2 1/2] avcodec/decode: use a single list bsf for codec decode bsfs
On Fri, 1 May 2020, Marton Balint wrote: On Tue, 28 Apr 2020, Marton Balint wrote: On Sun, 26 Apr 2020, James Almer wrote: On 4/26/2020 5:34 AM, Marton Balint wrote: void avcodec_flush_buffers(AVCodecContext *avctx) { AVCodecInternal *avci = avctx->internal; @@ -2117,7 +2001,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx) avctx->pts_correction_last_pts = avctx->pts_correction_last_dts = INT64_MIN; -bsfs_flush(avctx); +av_bsf_flush(avci->filter.bsf); This function can be called with encoders as well, and after this change you'll be calling av_bsf_flush() with NULL as argument. Easiest solution is to add an av_codec_is_decoder(avctx->codec) check before calling it, i guess. Ok, changed locally. Will apply the series soon, I will probably squash the two patch, since nobody was against removing DecodeFilterContext. Applied. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 1/2] avcodec/decode: use a single list bsf for codec decode bsfs
On Tue, 28 Apr 2020, Marton Balint wrote: On Sun, 26 Apr 2020, James Almer wrote: On 4/26/2020 5:34 AM, Marton Balint wrote: void avcodec_flush_buffers(AVCodecContext *avctx) { AVCodecInternal *avci = avctx->internal; @@ -2117,7 +2001,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx) avctx->pts_correction_last_pts = avctx->pts_correction_last_dts = INT64_MIN; -bsfs_flush(avctx); +av_bsf_flush(avci->filter.bsf); This function can be called with encoders as well, and after this change you'll be calling av_bsf_flush() with NULL as argument. Easiest solution is to add an av_codec_is_decoder(avctx->codec) check before calling it, i guess. Ok, changed locally. Will apply the series soon, I will probably squash the two patch, since nobody was against removing DecodeFilterContext. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 1/2] avcodec/decode: use a single list bsf for codec decode bsfs
On Sun, 26 Apr 2020, James Almer wrote: On 4/26/2020 5:34 AM, Marton Balint wrote: void avcodec_flush_buffers(AVCodecContext *avctx) { AVCodecInternal *avci = avctx->internal; @@ -2117,7 +2001,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx) avctx->pts_correction_last_pts = avctx->pts_correction_last_dts = INT64_MIN; -bsfs_flush(avctx); +av_bsf_flush(avci->filter.bsf); This function can be called with encoders as well, and after this change you'll be calling av_bsf_flush() with NULL as argument. Easiest solution is to add an av_codec_is_decoder(avctx->codec) check before calling it, i guess. Ok, changed locally. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 1/2] avcodec/decode: use a single list bsf for codec decode bsfs
On 4/26/2020 5:34 AM, Marton Balint wrote: > void avcodec_flush_buffers(AVCodecContext *avctx) > { > AVCodecInternal *avci = avctx->internal; > @@ -2117,7 +2001,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx) > avctx->pts_correction_last_pts = > avctx->pts_correction_last_dts = INT64_MIN; > > -bsfs_flush(avctx); > +av_bsf_flush(avci->filter.bsf); This function can be called with encoders as well, and after this change you'll be calling av_bsf_flush() with NULL as argument. Easiest solution is to add an av_codec_is_decoder(avctx->codec) check before calling it, i guess. > > if (!avctx->refcounted_frames) > av_frame_unref(avci->to_free); ___ 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 1/2] avcodec/decode: use a single list bsf for codec decode bsfs
Signed-off-by: Marton Balint --- libavcodec/cuviddec.c | 2 +- libavcodec/decode.c | 162 +++--- libavcodec/internal.h | 3 +- 3 files changed, 23 insertions(+), 144 deletions(-) diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c index 50dc8956c3..13a7db10cd 100644 --- a/libavcodec/cuviddec.c +++ b/libavcodec/cuviddec.c @@ -946,7 +946,7 @@ static av_cold int cuvid_decode_init(AVCodecContext *avctx) } if (avctx->codec->bsfs) { -const AVCodecParameters *par = avctx->internal->filter.bsfs[avctx->internal->filter.nb_bsfs - 1]->par_out; +const AVCodecParameters *par = avctx->internal->filter.bsf->par_out; ctx->cuparse_ext.format.seqhdr_data_length = par->extradata_size; memcpy(ctx->cuparse_ext.raw_seqhdr_data, par->extradata, diff --git a/libavcodec/decode.c b/libavcodec/decode.c index d4bdb9b1c0..576efd0e49 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -205,100 +205,30 @@ int ff_decode_bsfs_init(AVCodecContext *avctx) { AVCodecInternal *avci = avctx->internal; DecodeFilterContext *s = >filter; -const char *bsfs_str; int ret; -if (s->nb_bsfs) +if (s->bsf) return 0; -bsfs_str = avctx->codec->bsfs ? avctx->codec->bsfs : "null"; -while (bsfs_str && *bsfs_str) { -AVBSFContext **tmp; -const AVBitStreamFilter *filter; -char *bsf, *bsf_options_str, *bsf_name; - -bsf = av_get_token(_str, ","); -if (!bsf) { -ret = AVERROR(ENOMEM); -goto fail; -} -bsf_name = av_strtok(bsf, "=", _options_str); -if (!bsf_name) { -av_freep(); -ret = AVERROR(ENOMEM); -goto fail; -} - -filter = av_bsf_get_by_name(bsf_name); -if (!filter) { -av_log(avctx, AV_LOG_ERROR, "A non-existing bitstream filter %s " - "requested by a decoder. This is a bug, please report it.\n", - bsf_name); -av_freep(); +ret = av_bsf_list_parse_str(avctx->codec->bsfs, >bsf); +if (ret < 0) { +av_log(avctx, AV_LOG_ERROR, "Error parsing decoder bitstream filters '%s': %s\n", avctx->codec->bsfs, av_err2str(ret)); +if (ret != AVERROR(ENOMEM)) ret = AVERROR_BUG; -goto fail; -} - -tmp = av_realloc_array(s->bsfs, s->nb_bsfs + 1, sizeof(*s->bsfs)); -if (!tmp) { -av_freep(); -ret = AVERROR(ENOMEM); -goto fail; -} -s->bsfs = tmp; - -ret = av_bsf_alloc(filter, >bsfs[s->nb_bsfs]); -if (ret < 0) { -av_freep(); -goto fail; -} -s->nb_bsfs++; - -if (s->nb_bsfs == 1) { -/* We do not currently have an API for passing the input timebase into decoders, - * but no filters used here should actually need it. - * So we make up some plausible-looking number (the MPEG 90kHz timebase) */ -s->bsfs[s->nb_bsfs - 1]->time_base_in = (AVRational){ 1, 9 }; -ret = avcodec_parameters_from_context(s->bsfs[s->nb_bsfs - 1]->par_in, - avctx); -} else { -s->bsfs[s->nb_bsfs - 1]->time_base_in = s->bsfs[s->nb_bsfs - 2]->time_base_out; -ret = avcodec_parameters_copy(s->bsfs[s->nb_bsfs - 1]->par_in, - s->bsfs[s->nb_bsfs - 2]->par_out); -} -if (ret < 0) { -av_freep(); -goto fail; -} - -if (bsf_options_str && filter->priv_class) { -const AVOption *opt = av_opt_next(s->bsfs[s->nb_bsfs - 1]->priv_data, NULL); -const char * shorthand[2] = {NULL}; - -if (opt) -shorthand[0] = opt->name; - -ret = av_opt_set_from_string(s->bsfs[s->nb_bsfs - 1]->priv_data, bsf_options_str, shorthand, "=", ":"); -if (ret < 0) { -if (ret != AVERROR(ENOMEM)) { -av_log(avctx, AV_LOG_ERROR, "Invalid options for bitstream filter %s " - "requested by the decoder. This is a bug, please report it.\n", - bsf_name); -ret = AVERROR_BUG; -} -av_freep(); -goto fail; -} -} -av_freep(); +goto fail; +} -ret = av_bsf_init(s->bsfs[s->nb_bsfs - 1]); -if (ret < 0) -goto fail; +/* We do not currently have an API for passing the input timebase into decoders, + * but no filters used here should actually need it. + * So we make up some plausible-looking number (the MPEG 90kHz timebase) */ +s->bsf->time_base_in = (AVRational){ 1, 9 }; +ret = avcodec_parameters_from_context(s->bsf->par_in, avctx); +if (ret < 0) +