[FFmpeg-devel] [PATCH v2 2/2] avcodec/decode: remove DecodeFilterContext

Marton Balint cus at passwd.hu
Sun Apr 26 11:34:45 EEST 2020


The only remaining field was the decode bsf, it is now moved to
AVCodecInternal.

Signed-off-by: Marton Balint <cus at passwd.hu>
---
 libavcodec/cuviddec.c |  2 +-
 libavcodec/decode.c   | 21 +++++++++------------
 libavcodec/internal.h |  6 +-----
 3 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index 13a7db10cd..1d6895fa39 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.bsf->par_out;
+        const AVCodecParameters *par = avctx->internal->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 576efd0e49..631894d8ea 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -204,13 +204,12 @@ static int unrefcount_frame(AVCodecInternal *avci, AVFrame *frame)
 int ff_decode_bsfs_init(AVCodecContext *avctx)
 {
     AVCodecInternal *avci = avctx->internal;
-    DecodeFilterContext *s = &avci->filter;
     int ret;
 
-    if (s->bsf)
+    if (avci->bsf)
         return 0;
 
-    ret = av_bsf_list_parse_str(avctx->codec->bsfs, &s->bsf);
+    ret = av_bsf_list_parse_str(avctx->codec->bsfs, &avci->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))
@@ -221,12 +220,12 @@ int ff_decode_bsfs_init(AVCodecContext *avctx)
     /* 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, 90000 };
-    ret = avcodec_parameters_from_context(s->bsf->par_in, avctx);
+    avci->bsf->time_base_in = (AVRational){ 1, 90000 };
+    ret = avcodec_parameters_from_context(avci->bsf->par_in, avctx);
     if (ret < 0)
         goto fail;
 
-    ret = av_bsf_init(s->bsf);
+    ret = av_bsf_init(avci->bsf);
     if (ret < 0)
         goto fail;
 
@@ -244,7 +243,7 @@ int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
     if (avci->draining)
         return AVERROR_EOF;
 
-    ret = av_bsf_receive_packet(avci->filter.bsf, pkt);
+    ret = av_bsf_receive_packet(avci->bsf, pkt);
     if (ret == AVERROR_EOF)
         avci->draining = 1;
     if (ret < 0)
@@ -605,7 +604,7 @@ int attribute_align_arg avcodec_send_packet(AVCodecContext *avctx, const AVPacke
             return ret;
     }
 
-    ret = av_bsf_send_packet(avci->filter.bsf, avci->buffer_pkt);
+    ret = av_bsf_send_packet(avci->bsf, avci->buffer_pkt);
     if (ret < 0) {
         av_packet_unref(avci->buffer_pkt);
         return ret;
@@ -2001,7 +2000,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
     avctx->pts_correction_last_pts =
     avctx->pts_correction_last_dts = INT64_MIN;
 
-    av_bsf_flush(avci->filter.bsf);
+    av_bsf_flush(avci->bsf);
 
     if (!avctx->refcounted_frames)
         av_frame_unref(avci->to_free);
@@ -2009,7 +2008,5 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
 
 void ff_decode_bsfs_uninit(AVCodecContext *avctx)
 {
-    DecodeFilterContext *s = &avctx->internal->filter;
-
-    av_bsf_free(&s->bsf);
+    av_bsf_free(&avctx->internal->bsf);
 }
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 35a15c9664..df82789cdc 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -113,10 +113,6 @@ typedef struct DecodeSimpleContext {
     AVFrame  *out_frame;
 } DecodeSimpleContext;
 
-typedef struct DecodeFilterContext {
-    AVBSFContext *bsf;
-} DecodeFilterContext;
-
 typedef struct AVCodecInternal {
     /**
      * Whether the parent AVCodecContext is a copy of the context which had
@@ -139,7 +135,7 @@ typedef struct AVCodecInternal {
     void *thread_ctx;
 
     DecodeSimpleContext ds;
-    DecodeFilterContext filter;
+    AVBSFContext *bsf;
 
     /**
      * Properties (timestamps+side data) extracted from the last packet passed
-- 
2.16.4



More information about the ffmpeg-devel mailing list