[FFmpeg-cvslog] avfilter/ccfifo: remove unnecessary context allocations

James Almer git at videolan.org
Fri May 12 22:24:19 EEST 2023


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Thu May 11 14:34:57 2023 -0300| [7f890b2fbb75fa38e7b197cdd509afc7c391f998] | committer: James Almer

avfilter/ccfifo: remove unnecessary context allocations

This is not public API, no it has no need for an alloc() and free()
functions. The struct can reside on stack.

Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7f890b2fbb75fa38e7b197cdd509afc7c391f998
---

 libavdevice/decklink_common.h |  2 +-
 libavdevice/decklink_enc.cpp  | 14 ++++++-------
 libavfilter/ccfifo.c          | 49 +++++++++++++------------------------------
 libavfilter/ccfifo.h          | 42 ++++++++++++++++++++++---------------
 libavfilter/tinterlace.h      |  2 +-
 libavfilter/vf_bwdif.c        |  8 ++++---
 libavfilter/vf_ccrepack.c     | 13 ++++++------
 libavfilter/vf_fps.c          | 13 ++++++------
 libavfilter/vf_tinterlace.c   | 18 ++++++++--------
 libavfilter/vf_yadif.c        |  8 ++++---
 libavfilter/vf_yadif_cuda.c   |  6 +++---
 libavfilter/yadif.h           |  2 +-
 libavfilter/yadif_common.c    |  6 +++---
 13 files changed, 89 insertions(+), 94 deletions(-)

diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h
index 1cc6d9c2cc..ebb5b94bed 100644
--- a/libavdevice/decklink_common.h
+++ b/libavdevice/decklink_common.h
@@ -113,7 +113,7 @@ struct decklink_ctx {
     /* Capture buffer queue */
     DecklinkPacketQueue queue;
 
-    AVCCFifo *cc_fifo;      ///< closed captions
+    CCFifo cc_fifo;      ///< closed captions
 
     /* Streams present */
     int audio;
diff --git a/libavdevice/decklink_enc.cpp b/libavdevice/decklink_enc.cpp
index 22aa80b8c2..6906cb0882 100644
--- a/libavdevice/decklink_enc.cpp
+++ b/libavdevice/decklink_enc.cpp
@@ -371,7 +371,7 @@ av_cold int ff_decklink_write_trailer(AVFormatContext *avctx)
     klvanc_context_destroy(ctx->vanc_ctx);
 #endif
 
-    ff_ccfifo_freep(&ctx->cc_fifo);
+    ff_ccfifo_uninit(&ctx->cc_fifo);
     av_freep(&cctx->ctx);
 
     return 0;
@@ -527,15 +527,15 @@ out:
    that will later be handled by construct_cc... */
 static void parse_608subs(AVFormatContext *avctx, struct decklink_ctx *ctx, AVPacket *pkt)
 {
-    size_t cc_size = ff_ccfifo_getoutputsize(ctx->cc_fifo);
+    size_t cc_size = ff_ccfifo_getoutputsize(&ctx->cc_fifo);
     uint8_t *cc_data;
 
-    if (!ff_ccfifo_ccdetected(ctx->cc_fifo))
+    if (!ff_ccfifo_ccdetected(&ctx->cc_fifo))
         return;
 
     cc_data = av_packet_new_side_data(pkt, AV_PKT_DATA_A53_CC, cc_size);
     if (cc_data)
-        ff_ccfifo_injectbytes(ctx->cc_fifo, cc_data, cc_size);
+        ff_ccfifo_injectbytes(&ctx->cc_fifo, cc_data, cc_size);
 }
 
 static int decklink_construct_vanc(AVFormatContext *avctx, struct decklink_ctx *ctx,
@@ -745,7 +745,7 @@ static int decklink_write_subtitle_packet(AVFormatContext *avctx, AVPacket *pkt)
     struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data;
     struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
 
-    ff_ccfifo_extractbytes(ctx->cc_fifo, pkt->data, pkt->size);
+    ff_ccfifo_extractbytes(&ctx->cc_fifo, pkt->data, pkt->size);
 
     return 0;
 }
@@ -831,9 +831,9 @@ av_cold int ff_decklink_write_header(AVFormatContext *avctx)
             avpriv_set_pts_info(st, 64, ctx->bmd_tb_num, ctx->bmd_tb_den);
     }
 
-    if (!(ctx->cc_fifo = ff_ccfifo_alloc(av_make_q(ctx->bmd_tb_den, ctx->bmd_tb_num), avctx))) {
+    ret = ff_ccfifo_init(&ctx->cc_fifo, av_make_q(ctx->bmd_tb_den, ctx->bmd_tb_num), avctx);
+    if (ret < 0) {
         av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n");
-        ret = AVERROR(ENOMEM);
         goto error;
     }
 
diff --git a/libavfilter/ccfifo.c b/libavfilter/ccfifo.c
index 5fb68ce04c..f39dbc1740 100644
--- a/libavfilter/ccfifo.c
+++ b/libavfilter/ccfifo.c
@@ -23,18 +23,6 @@
 
 #include "ccfifo.h"
 
-struct AVCCFifo {
-    AVFifo *cc_608_fifo;
-    AVFifo *cc_708_fifo;
-    AVRational framerate;
-    int expected_cc_count;
-    int expected_608;
-    int cc_detected;
-    int passthrough;
-    int passthrough_warning;
-    void *log_ctx;
-};
-
 #define MAX_CC_ELEMENTS 128
 #define CC_BYTES_PER_ENTRY 3
 
@@ -55,25 +43,18 @@ const static struct cc_lookup cc_lookup_vals[] = {
     { 60000, 1001, 10, 1},
 };
 
-void ff_ccfifo_freep(AVCCFifo **ccf)
+void ff_ccfifo_uninit(CCFifo *ccf)
 {
-    AVCCFifo *tmp = *ccf;
-    if (tmp) {
-        av_fifo_freep2(&tmp->cc_608_fifo);
-        av_fifo_freep2(&tmp->cc_708_fifo);
-    }
-    av_freep(ccf);
+    av_fifo_freep2(&ccf->cc_608_fifo);
+    av_fifo_freep2(&ccf->cc_708_fifo);
+    memset(ccf, 0, sizeof(*ccf));
 }
 
-AVCCFifo *ff_ccfifo_alloc(AVRational framerate, void *log_ctx)
+int ff_ccfifo_init(CCFifo *ccf, AVRational framerate, void *log_ctx)
 {
-    AVCCFifo *ccf;
     int i;
 
-    ccf = av_mallocz(sizeof(*ccf));
-    if (!ccf)
-        return NULL;
-
+    memset(ccf, 0, sizeof(*ccf));
     ccf->log_ctx = log_ctx;
     ccf->framerate = framerate;
 
@@ -101,24 +82,24 @@ AVCCFifo *ff_ccfifo_alloc(AVRational framerate, void *log_ctx)
         ccf->passthrough = 1;
     }
 
-    return ccf;
+    return 0;
 
 error:
-    ff_ccfifo_freep(&ccf);
-    return NULL;
+    ff_ccfifo_uninit(ccf);
+    return AVERROR(ENOMEM);
 }
 
-int ff_ccfifo_getoutputsize(AVCCFifo *ccf)
+int ff_ccfifo_getoutputsize(CCFifo *ccf)
 {
     return ccf->expected_cc_count * CC_BYTES_PER_ENTRY;
 }
 
-int ff_ccfifo_ccdetected(AVCCFifo *ccf)
+int ff_ccfifo_ccdetected(CCFifo *ccf)
 {
     return ccf->cc_detected;
 }
 
-int ff_ccfifo_injectbytes(AVCCFifo *ccf, uint8_t *cc_data, size_t len)
+int ff_ccfifo_injectbytes(CCFifo *ccf, uint8_t *cc_data, size_t len)
 {
     int cc_608_tuples = 0;
     int cc_708_tuples = 0;
@@ -159,7 +140,7 @@ int ff_ccfifo_injectbytes(AVCCFifo *ccf, uint8_t *cc_data, size_t len)
     return 0;
 }
 
-int ff_ccfifo_inject(AVCCFifo *ccf, AVFrame *frame)
+int ff_ccfifo_inject(CCFifo *ccf, AVFrame *frame)
 {
     AVFrameSideData *sd;
     int ret;
@@ -180,7 +161,7 @@ int ff_ccfifo_inject(AVCCFifo *ccf, AVFrame *frame)
     return 0;
 }
 
-int ff_ccfifo_extractbytes(AVCCFifo *ccf, uint8_t *cc_bytes, size_t len)
+int ff_ccfifo_extractbytes(CCFifo *ccf, uint8_t *cc_bytes, size_t len)
 {
     int cc_count = len / CC_BYTES_PER_ENTRY;
 
@@ -209,7 +190,7 @@ int ff_ccfifo_extractbytes(AVCCFifo *ccf, uint8_t *cc_bytes, size_t len)
 /* Read the A53 side data, discard padding, and put 608/708 into
    queues so we can ensure they get into the output frames at
    the correct rate... */
-int ff_ccfifo_extract(AVCCFifo *ccf, AVFrame *frame)
+int ff_ccfifo_extract(CCFifo *ccf, AVFrame *frame)
 {
     AVFrameSideData *side_data = av_frame_get_side_data(frame, AV_FRAME_DATA_A53_CC);
     if (side_data) {
diff --git a/libavfilter/ccfifo.h b/libavfilter/ccfifo.h
index 44c924593c..a380f67b52 100644
--- a/libavfilter/ccfifo.h
+++ b/libavfilter/ccfifo.h
@@ -33,25 +33,33 @@
 #include "libavutil/frame.h"
 #include "libavutil/fifo.h"
 
-typedef struct AVCCFifo AVCCFifo;
+typedef struct CCFifo {
+    AVFifo *cc_608_fifo;
+    AVFifo *cc_708_fifo;
+    AVRational framerate;
+    int expected_cc_count;
+    int expected_608;
+    int cc_detected;
+    int passthrough;
+    int passthrough_warning;
+    void *log_ctx;
+} CCFifo;
 
 /**
- * Allocate an AVCCFifo.
+ * Initialize a CCFifo.
  *
  * @param framerate   output framerate
  * @param log_ctx     used for any av_log() calls
- * @return            newly allocated AVCCFifo, or NULL on error
+ * @return            Zero on success, or negative AVERROR code on failure.
  */
-AVCCFifo *ff_ccfifo_alloc(AVRational framerate, void *log_ctx);
+int ff_ccfifo_init(CCFifo *ccf, AVRational framerate, void *log_ctx);
 
 /**
- * Free an AVCCFifo
+ * Free all memory allocated in a CCFifo and clear the context.
  *
- * @param ccf Pointer to the pointer to the AVCCFifo which should be freed
- * @note `*ptr = NULL` is safe and leads to no action.
+ * @param ccf Pointer to the CCFifo which should be uninitialized
  */
-void ff_ccfifo_freep(AVCCFifo **ccf);
-
+void ff_ccfifo_uninit(CCFifo *ccf);
 
 /**
  * Extract CC data from an AVFrame
@@ -61,17 +69,17 @@ void ff_ccfifo_freep(AVCCFifo **ccf);
  * as it will be re-inserted at the appropriate rate later in the
  * filter.
  *
- * @param af          AVCCFifo to write to
+ * @param af          CCFifo to write to
  * @param frame       AVFrame with the video frame to operate on
  * @return            Zero on success, or negative AVERROR
  *                    code on failure.
  */
-int ff_ccfifo_extract(AVCCFifo *ccf, AVFrame *frame);
+int ff_ccfifo_extract(CCFifo *ccf, AVFrame *frame);
 
 /**
  *Just like ff_ccfifo_extract(), but takes the raw bytes instead of an AVFrame
  */
-int ff_ccfifo_extractbytes(AVCCFifo *ccf, uint8_t *data, size_t len);
+int ff_ccfifo_extractbytes(CCFifo *ccf, uint8_t *data, size_t len);
 
 /**
  * Provide the size in bytes of an output buffer to allocate
@@ -80,7 +88,7 @@ int ff_ccfifo_extractbytes(AVCCFifo *ccf, uint8_t *data, size_t len);
  * an appropriately sized buffer and pass it to ff_ccfifo_injectbytes()
  *
  */
-int ff_ccfifo_getoutputsize(AVCCFifo *ccf);
+int ff_ccfifo_getoutputsize(CCFifo *ccf);
 
 /**
  * Insert CC data from the FIFO into an AVFrame (as side data)
@@ -88,23 +96,23 @@ int ff_ccfifo_getoutputsize(AVCCFifo *ccf);
  * Dequeue the appropriate number of CC tuples based on the
  * frame rate, and insert them into the AVFrame
  *
- * @param af          AVCCFifo to read from
+ * @param af          CCFifo to read from
  * @param frame       AVFrame with the video frame to operate on
  * @return            Zero on success, or negative AVERROR
  *                    code on failure.
  */
-int ff_ccfifo_inject(AVCCFifo *ccf, AVFrame *frame);
+int ff_ccfifo_inject(CCFifo *ccf, AVFrame *frame);
 
 /**
  * Just like ff_ccfifo_inject(), but takes the raw bytes to insert the CC data
  * int rather than an AVFrame
  */
-int ff_ccfifo_injectbytes(AVCCFifo *ccf, uint8_t *data, size_t len);
+int ff_ccfifo_injectbytes(CCFifo *ccf, uint8_t *data, size_t len);
 
 /**
  * Returns 1 if captions have been found as a prior call
  * to ff_ccfifo_extract() or ff_ccfifo_extractbytes()
  */
-int ff_ccfifo_ccdetected(AVCCFifo *ccf);
+int ff_ccfifo_ccdetected(CCFifo *ccf);
 
 #endif /* AVFILTER_CCFIFO_H */
diff --git a/libavfilter/tinterlace.h b/libavfilter/tinterlace.h
index 9f5ce7e65b..f9b3e630b8 100644
--- a/libavfilter/tinterlace.h
+++ b/libavfilter/tinterlace.h
@@ -78,7 +78,7 @@ typedef struct TInterlaceContext {
     const AVPixFmtDescriptor *csp;
     void (*lowpass_line)(uint8_t *dstp, ptrdiff_t width, const uint8_t *srcp,
                          ptrdiff_t mref, ptrdiff_t pref, int clip_max);
-    AVCCFifo *cc_fifo;
+    CCFifo cc_fifo;
 } TInterlaceContext;
 
 void ff_tinterlace_init_x86(TInterlaceContext *interlace);
diff --git a/libavfilter/vf_bwdif.c b/libavfilter/vf_bwdif.c
index 51e1e02503..e278cf1217 100644
--- a/libavfilter/vf_bwdif.c
+++ b/libavfilter/vf_bwdif.c
@@ -297,7 +297,7 @@ static av_cold void uninit(AVFilterContext *ctx)
     av_frame_free(&yadif->prev);
     av_frame_free(&yadif->cur );
     av_frame_free(&yadif->next);
-    ff_ccfifo_freep(&yadif->cc_fifo);
+    ff_ccfifo_uninit(&yadif->cc_fifo);
 }
 
 static const enum AVPixelFormat pix_fmts[] = {
@@ -326,6 +326,7 @@ static int config_props(AVFilterLink *link)
     AVFilterContext *ctx = link->src;
     BWDIFContext *s = link->src->priv;
     YADIFContext *yadif = &s->yadif;
+    int ret;
 
     link->time_base = av_mul_q(ctx->inputs[0]->time_base, (AVRational){1, 2});
     link->w         = link->src->inputs[0]->w;
@@ -336,9 +337,10 @@ static int config_props(AVFilterLink *link)
     else
         link->frame_rate = ctx->inputs[0]->frame_rate;
 
-    if (!(yadif->cc_fifo = ff_ccfifo_alloc(link->frame_rate, ctx))) {
+    ret = ff_ccfifo_init(&yadif->cc_fifo, link->frame_rate, ctx);
+    if (ret < 0 ) {
         av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n");
-        return AVERROR(ENOMEM);
+        return ret;
     }
 
     if (link->w < 3 || link->h < 4) {
diff --git a/libavfilter/vf_ccrepack.c b/libavfilter/vf_ccrepack.c
index e3fd67f1b5..61eb2128ae 100644
--- a/libavfilter/vf_ccrepack.c
+++ b/libavfilter/vf_ccrepack.c
@@ -37,7 +37,7 @@
 typedef struct CCRepackContext
 {
     const AVClass *class;
-    AVCCFifo *cc_fifo;
+    CCFifo cc_fifo;
 } CCRepackContext;
 
 static const AVOption ccrepack_options[] = {
@@ -50,9 +50,10 @@ static int config_input(AVFilterLink *link)
 {
     CCRepackContext *ctx = link->dst->priv;
 
-    if (!(ctx->cc_fifo = ff_ccfifo_alloc(link->frame_rate, ctx))) {
+    int ret = ff_ccfifo_init(&ctx->cc_fifo, link->frame_rate, ctx);
+    if (ret < 0) {
         av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n");
-        return AVERROR(ENOMEM);
+        return ret;
     }
 
     return 0;
@@ -63,8 +64,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
     CCRepackContext *ctx = inlink->dst->priv;
     AVFilterLink *outlink = inlink->dst->outputs[0];
 
-    ff_ccfifo_extract(ctx->cc_fifo, frame);
-    ff_ccfifo_inject(ctx->cc_fifo, frame);
+    ff_ccfifo_extract(&ctx->cc_fifo, frame);
+    ff_ccfifo_inject(&ctx->cc_fifo, frame);
 
     return ff_filter_frame(outlink, frame);
 }
@@ -72,7 +73,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
 static av_cold void uninit(AVFilterContext *ctx)
 {
     CCRepackContext *s = ctx->priv;
-    ff_ccfifo_freep(&s->cc_fifo);
+    ff_ccfifo_uninit(&s->cc_fifo);
 }
 
 static const AVFilterPad avfilter_vf_ccrepack_inputs[] = {
diff --git a/libavfilter/vf_fps.c b/libavfilter/vf_fps.c
index 824e7a128d..2bfb6d29e7 100644
--- a/libavfilter/vf_fps.c
+++ b/libavfilter/vf_fps.c
@@ -86,7 +86,7 @@ typedef struct FPSContext {
 
     AVFrame *frames[2];     ///< buffered frames
     int      frames_count;  ///< number of buffered frames
-    AVCCFifo *cc_fifo;      ///< closed captions
+    CCFifo cc_fifo;       ///< closed captions
 
     int64_t  next_pts;      ///< pts of the next frame to output
 
@@ -167,7 +167,7 @@ static av_cold void uninit(AVFilterContext *ctx)
         frame = shift_frame(ctx, s);
         av_frame_free(&frame);
     }
-    ff_ccfifo_freep(&s->cc_fifo);
+    ff_ccfifo_uninit(&s->cc_fifo);
 
     av_log(ctx, AV_LOG_VERBOSE, "%d frames in, %d frames out; %d frames dropped, "
            "%d frames duplicated.\n", s->frames_in, s->frames_out, s->drop, s->dup);
@@ -213,9 +213,10 @@ static int config_props(AVFilterLink* outlink)
                s->in_pts_off, s->out_pts_off, s->start_time);
     }
 
-    if (!(s->cc_fifo = ff_ccfifo_alloc(outlink->frame_rate, ctx))) {
+    ret = ff_ccfifo_init(&s->cc_fifo, outlink->frame_rate, ctx);
+    if (ret < 0) {
         av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n");
-        return AVERROR(ENOMEM);
+        return ret;
     }
 
     av_log(ctx, AV_LOG_VERBOSE, "fps=%d/%d\n", outlink->frame_rate.num, outlink->frame_rate.den);
@@ -250,7 +251,7 @@ static int read_frame(AVFilterContext *ctx, FPSContext *s, AVFilterLink *inlink,
     av_log(ctx, AV_LOG_DEBUG, "Read frame with in pts %"PRId64", out pts %"PRId64"\n",
            in_pts, frame->pts);
 
-    ff_ccfifo_extract(s->cc_fifo, frame);
+    ff_ccfifo_extract(&s->cc_fifo, frame);
     s->frames[s->frames_count++] = frame;
     s->frames_in++;
 
@@ -298,7 +299,7 @@ static int write_frame(AVFilterContext *ctx, FPSContext *s, AVFilterLink *outlin
         if (!frame)
             return AVERROR(ENOMEM);
         // Make sure Closed Captions will not be duplicated
-        ff_ccfifo_inject(s->cc_fifo, frame);
+        ff_ccfifo_inject(&s->cc_fifo, frame);
         frame->pts = s->next_pts++;
         frame->duration = 1;
 
diff --git a/libavfilter/vf_tinterlace.c b/libavfilter/vf_tinterlace.c
index e1057ffc8e..63f1fc72f2 100644
--- a/libavfilter/vf_tinterlace.c
+++ b/libavfilter/vf_tinterlace.c
@@ -203,7 +203,7 @@ static av_cold void uninit(AVFilterContext *ctx)
     av_frame_free(&tinterlace->next);
     av_freep(&tinterlace->black_data[0][0]);
     av_freep(&tinterlace->black_data[1][0]);
-    ff_ccfifo_freep(&tinterlace->cc_fifo);
+    ff_ccfifo_uninit(&tinterlace->cc_fifo);
 }
 
 static int config_out_props(AVFilterLink *outlink)
@@ -212,7 +212,7 @@ static int config_out_props(AVFilterLink *outlink)
     AVFilterLink *inlink = outlink->src->inputs[0];
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(outlink->format);
     TInterlaceContext *tinterlace = ctx->priv;
-    int i;
+    int ret, i;
 
     tinterlace->vsub = desc->log2_chroma_h;
     outlink->w = inlink->w;
@@ -224,7 +224,6 @@ static int config_out_props(AVFilterLink *outlink)
 
     if (tinterlace->mode == MODE_PAD) {
         uint8_t black[4] = { 0, 0, 0, 16 };
-        int ret;
         ff_draw_init(&tinterlace->draw, outlink->format, 0);
         ff_draw_color(&tinterlace->draw, &tinterlace->color, black);
         /* limited range */
@@ -292,9 +291,10 @@ static int config_out_props(AVFilterLink *outlink)
 #endif
     }
 
-    if (!(tinterlace->cc_fifo = ff_ccfifo_alloc(outlink->frame_rate, ctx))) {
+    ret = ff_ccfifo_init(&tinterlace->cc_fifo, outlink->frame_rate, ctx);
+    if (ret < 0) {
         av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n");
-        return AVERROR(ENOMEM);
+        return ret;
     }
 
     av_log(ctx, AV_LOG_VERBOSE, "mode:%d filter:%s h:%d -> h:%d\n", tinterlace->mode,
@@ -381,7 +381,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
     tinterlace->cur  = tinterlace->next;
     tinterlace->next = picref;
 
-    ff_ccfifo_extract(tinterlace->cc_fifo, picref);
+    ff_ccfifo_extract(&tinterlace->cc_fifo, picref);
 
     cur = tinterlace->cur;
     next = tinterlace->next;
@@ -464,7 +464,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
             if (!out)
                 return AVERROR(ENOMEM);
             out->pts /= 2;  // adjust pts to new framerate
-            ff_ccfifo_inject(tinterlace->cc_fifo, out);
+            ff_ccfifo_inject(&tinterlace->cc_fifo, out);
             ret = ff_filter_frame(outlink, out);
             return ret;
         }
@@ -514,7 +514,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
             out->pts = cur->pts*2;
 
         out->pts = av_rescale_q(out->pts, tinterlace->preout_time_base, outlink->time_base);
-        ff_ccfifo_inject(tinterlace->cc_fifo, out);
+        ff_ccfifo_inject(&tinterlace->cc_fifo, out);
         if ((ret = ff_filter_frame(outlink, out)) < 0)
             return ret;
 
@@ -559,7 +559,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
     out->pts = av_rescale_q(out->pts, tinterlace->preout_time_base, outlink->time_base);
     out->duration = av_rescale_q(1, av_inv_q(outlink->frame_rate), outlink->time_base);
-    ff_ccfifo_inject(tinterlace->cc_fifo, out);
+    ff_ccfifo_inject(&tinterlace->cc_fifo, out);
     ret = ff_filter_frame(outlink, out);
 
     return ret;
diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c
index f77f8113ca..d6fe24a386 100644
--- a/libavfilter/vf_yadif.c
+++ b/libavfilter/vf_yadif.c
@@ -261,7 +261,7 @@ static av_cold void uninit(AVFilterContext *ctx)
     av_frame_free(&yadif->prev);
     av_frame_free(&yadif->cur );
     av_frame_free(&yadif->next);
-    ff_ccfifo_freep(&yadif->cc_fifo);
+    ff_ccfifo_uninit(&yadif->cc_fifo);
 }
 
 static const enum AVPixelFormat pix_fmts[] = {
@@ -286,6 +286,7 @@ static int config_output(AVFilterLink *outlink)
 {
     AVFilterContext *ctx = outlink->src;
     YADIFContext *s = ctx->priv;
+    int ret;
 
     outlink->time_base = av_mul_q(ctx->inputs[0]->time_base, (AVRational){1, 2});
     outlink->w             = ctx->inputs[0]->w;
@@ -297,9 +298,10 @@ static int config_output(AVFilterLink *outlink)
     else
         outlink->frame_rate = ctx->inputs[0]->frame_rate;
 
-    if (!(s->cc_fifo = ff_ccfifo_alloc(outlink->frame_rate, ctx))) {
+    ret = ff_ccfifo_init(&s->cc_fifo, outlink->frame_rate, ctx);
+    if (ret < 0) {
         av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n");
-        return AVERROR(ENOMEM);
+        return ret;
     }
 
     if (outlink->w < 3 || outlink->h < 3) {
diff --git a/libavfilter/vf_yadif_cuda.c b/libavfilter/vf_yadif_cuda.c
index 73f04126c5..b5ff84e11a 100644
--- a/libavfilter/vf_yadif_cuda.c
+++ b/libavfilter/vf_yadif_cuda.c
@@ -205,7 +205,7 @@ static av_cold void deint_cuda_uninit(AVFilterContext *ctx)
     av_frame_free(&y->prev);
     av_frame_free(&y->cur);
     av_frame_free(&y->next);
-    ff_ccfifo_freep(&y->cc_fifo);
+    ff_ccfifo_uninit(&y->cc_fifo);
 
     av_buffer_unref(&s->device_ref);
     s->hwctx = NULL;
@@ -295,9 +295,9 @@ static int config_output(AVFilterLink *link)
     else
         link->frame_rate = ctx->inputs[0]->frame_rate;
 
-    if (!(y->cc_fifo = ff_ccfifo_alloc(link->frame_rate, ctx))) {
+    ret = ff_ccfifo_init(&y->cc_fifo, link->frame_rate, ctx);
+    if (ret < 0) {
         av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n");
-        ret = AVERROR(ENOMEM);
         goto exit;
     }
 
diff --git a/libavfilter/yadif.h b/libavfilter/yadif.h
index 10775767e9..fbb99fd46e 100644
--- a/libavfilter/yadif.h
+++ b/libavfilter/yadif.h
@@ -77,7 +77,7 @@ typedef struct YADIFContext {
     int eof;
     uint8_t *temp_line;
     int temp_line_size;
-    AVCCFifo *cc_fifo;
+    CCFifo cc_fifo;
 
     /*
      * An algorithm that treats first and/or last fields in a sequence
diff --git a/libavfilter/yadif_common.c b/libavfilter/yadif_common.c
index 49ea7cfce4..05474a5ba9 100644
--- a/libavfilter/yadif_common.c
+++ b/libavfilter/yadif_common.c
@@ -66,7 +66,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
         }
     }
 
-    ff_ccfifo_inject(yadif->cc_fifo, yadif->out);
+    ff_ccfifo_inject(&yadif->cc_fifo, yadif->out);
     ret = ff_filter_frame(ctx->outputs[0], yadif->out);
 
     yadif->frame_pending = (yadif->mode&1) && !is_second;
@@ -103,7 +103,7 @@ int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame)
 
     av_assert0(frame);
 
-    ff_ccfifo_extract(yadif->cc_fifo, frame);
+    ff_ccfifo_extract(&yadif->cc_fifo, frame);
 
     if (yadif->frame_pending)
         return_frame(ctx, 1);
@@ -146,7 +146,7 @@ int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame)
         if (!yadif->out)
             return AVERROR(ENOMEM);
 
-        ff_ccfifo_inject(yadif->cc_fifo, yadif->out);
+        ff_ccfifo_inject(&yadif->cc_fifo, yadif->out);
         av_frame_free(&yadif->prev);
         if (yadif->out->pts != AV_NOPTS_VALUE)
             yadif->out->pts *= 2;



More information about the ffmpeg-cvslog mailing list