@@ -297,6 +297,7 @@ static av_cold void uninit(AVFilterContext *ctx)
av_frame_free(&yadif->prev);
av_frame_free(&yadif->cur );
av_frame_free(&yadif->next);
+ av_ccfifo_freep(&yadif->cc_fifo);
}
static const enum AVPixelFormat pix_fmts[] = {
@@ -332,6 +333,12 @@ static int config_props(AVFilterLink *link)
if(yadif->mode&1)
link->frame_rate = av_mul_q(link->src->inputs[0]->frame_rate, (AVRational){2,1});
+ else
+ link->frame_rate = ctx->inputs[0]->frame_rate;
+
+ if (!(yadif->cc_fifo = av_ccfifo_alloc(&link->frame_rate, ctx)))
+ av_log(ctx, AV_LOG_VERBOSE, "Failure to setup CC FIFO queue. Captions will be passed through\n");
+
if (link->w < 3 || link->h < 4) {
av_log(ctx, AV_LOG_ERROR, "Video of less than 3 columns or 4 lines is not supported\n");
@@ -261,6 +261,7 @@ static av_cold void uninit(AVFilterContext *ctx)
av_frame_free(&yadif->prev);
av_frame_free(&yadif->cur );
av_frame_free(&yadif->next);
+ av_ccfifo_freep(&yadif->cc_fifo);
}
static const enum AVPixelFormat pix_fmts[] = {
@@ -293,6 +294,11 @@ static int config_output(AVFilterLink *outlink)
if(s->mode & 1)
outlink->frame_rate = av_mul_q(ctx->inputs[0]->frame_rate,
(AVRational){2, 1});
+ else
+ outlink->frame_rate = ctx->inputs[0]->frame_rate;
+
+ if (!(s->cc_fifo = av_ccfifo_alloc(&outlink->frame_rate, ctx)))
+ av_log(ctx, AV_LOG_VERBOSE, "Failure to setup CC FIFO queue. Captions will be passed through\n");
if (outlink->w < 3 || outlink->h < 3) {
av_log(ctx, AV_LOG_ERROR, "Video of less than 3 columns or lines is not supported\n");
@@ -206,6 +206,9 @@ static av_cold void deint_cuda_uninit(AVFilterContext *ctx)
av_frame_free(&y->cur);
av_frame_free(&y->next);
+ if (yadif->cc_fifo)
+ av_cc_fifo_free(yadif->cc_fifo);
+
av_buffer_unref(&s->device_ref);
s->hwctx = NULL;
av_buffer_unref(&s->input_frames_ref);
@@ -291,6 +294,11 @@ static int config_output(AVFilterLink *link)
if(y->mode & 1)
link->frame_rate = av_mul_q(ctx->inputs[0]->frame_rate,
(AVRational){2, 1});
+ else
+ outlink->frame_rate = ctx->inputs[0]->frame_rate;
+
+ if (!(s->cc_fifo = av_cc_fifo_alloc(&outlink->frame_rate, ctx)))
+ av_log(ctx, AV_LOG_VERBOSE, "Failure to setup CC FIFO queue. Captions will be passed through\n");
if (link->w < 3 || link->h < 3) {
av_log(ctx, AV_LOG_ERROR, "Video of less than 3 columns or lines is not supported\n");
@@ -21,6 +21,7 @@
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
+#include "libavutil/ccfifo.h"
#include "avfilter.h"
enum YADIFMode {
@@ -76,6 +77,7 @@ typedef struct YADIFContext {
int eof;
uint8_t *temp_line;
int temp_line_size;
+ AVCCFifo *cc_fifo;
/*
* An algorithm that treats first and/or last fields in a sequence
@@ -60,6 +60,8 @@ static int return_frame(AVFilterContext *ctx, int is_second)
yadif->out->pts = AV_NOPTS_VALUE;
}
}
+
+ av_ccfifo_inject(yadif->cc_fifo, yadif->out);
ret = ff_filter_frame(ctx->outputs[0], yadif->out);
yadif->frame_pending = (yadif->mode&1) && !is_second;
@@ -96,6 +98,8 @@ int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame)
av_assert0(frame);
+ av_ccfifo_extract(yadif->cc_fifo, frame);
+
if (yadif->frame_pending)
return_frame(ctx, 1);
@@ -137,6 +141,7 @@ int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame)
if (!yadif->out)
return AVERROR(ENOMEM);
+ av_ccfifo_inject(yadif->cc_fifo, yadif->out);
av_frame_free(&yadif->prev);
if (yadif->out->pts != AV_NOPTS_VALUE)
yadif->out->pts *= 2;
Various deinterlacing modes have the effect of doubling the framerate, and we need to ensure that the caption data isn't duplicated (or else you get double captions on-screen). Use the new ccfifo mechanism for yadif (and yadif_cuda and bwdif since they use the same yadif core) so that CEA-708 data is properly preserved through this filter. Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com> --- libavfilter/vf_bwdif.c | 7 +++++++ libavfilter/vf_yadif.c | 6 ++++++ libavfilter/vf_yadif_cuda.c | 8 ++++++++ libavfilter/yadif.h | 2 ++ libavfilter/yadif_common.c | 5 +++++ 5 files changed, 28 insertions(+)