Message ID | 1680904709-25951-5-git-send-email-dheitmueller@ltnglobal.com |
---|---|
State | New |
Headers | show |
Series | Add support for Closed Caption FIFO | expand |
Context | Check | Description |
---|---|---|
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | fail | Make fate failed |
On Sat, Apr 8, 2023 at 5:04 AM Devin Heitmueller < devin.heitmueller@ltnglobal.com> wrote: > Because the interlacing filter halves the effective framerate, we > need to ensure that no CEA-708 data is lost as frames are merged. > > Make use of the new ccfifo mechanism to ensure that caption data > is properly preserved as frames pass through the filter. > > Thanks to Thomas Mundt for review and noticing a couple of > missed codepaths for injection on output. > > Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com> > --- > libavfilter/tinterlace.h | 2 ++ > libavfilter/vf_tinterlace.c | 8 ++++++++ > 2 files changed, 10 insertions(+) > > diff --git a/libavfilter/tinterlace.h b/libavfilter/tinterlace.h > index 37b6c10..9f5ce7e 100644 > --- a/libavfilter/tinterlace.h > +++ b/libavfilter/tinterlace.h > @@ -32,6 +32,7 @@ > #include "libavutil/pixdesc.h" > #include "drawutils.h" > #include "avfilter.h" > +#include "ccfifo.h" > > #define TINTERLACE_FLAG_VLPF 01 > #define TINTERLACE_FLAG_CVLPF 2 > @@ -77,6 +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; > } TInterlaceContext; > > void ff_tinterlace_init_x86(TInterlaceContext *interlace); > diff --git a/libavfilter/vf_tinterlace.c b/libavfilter/vf_tinterlace.c > index 0326292..226983c 100644 > --- a/libavfilter/vf_tinterlace.c > +++ b/libavfilter/vf_tinterlace.c > @@ -291,6 +291,9 @@ static int config_out_props(AVFilterLink *outlink) > #endif > } > > + if (!(tinterlace->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"); > + > free cc_fifo? > av_log(ctx, AV_LOG_VERBOSE, "mode:%d filter:%s h:%d -> h:%d\n", > tinterlace->mode, > (tinterlace->flags & TINTERLACE_FLAG_CVLPF) ? "complex" : > (tinterlace->flags & TINTERLACE_FLAG_VLPF) ? "linear" : "off", > @@ -375,6 +378,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame > *picref) > tinterlace->cur = tinterlace->next; > tinterlace->next = picref; > > + av_ccfifo_extract(tinterlace->cc_fifo, picref); > + > cur = tinterlace->cur; > next = tinterlace->next; > /* we need at least two frames */ > @@ -451,6 +456,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame > *picref) > if (!out) > return AVERROR(ENOMEM); > out->pts /= 2; // adjust pts to new framerate > + av_ccfifo_inject(tinterlace->cc_fifo, out); > ret = ff_filter_frame(outlink, out); > return ret; > } > @@ -486,6 +492,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame > *picref) > out->pts = cur->pts*2; > > out->pts = av_rescale_q(out->pts, tinterlace->preout_time_base, > outlink->time_base); > + av_ccfifo_inject(tinterlace->cc_fifo, out); > if ((ret = ff_filter_frame(outlink, out)) < 0) > return ret; > > @@ -521,6 +528,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame > *picref) > > 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); > + av_ccfifo_inject(tinterlace->cc_fifo, out); > ret = ff_filter_frame(outlink, out); > > return ret; > -- > 1.8.3.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-request@ffmpeg.org with subject "unsubscribe". >
Hi Lance, Thanks for taking the time to review. On Sun, Apr 9, 2023 at 9:28 PM Lance Wang <lance.lmwang@gmail.com> wrote: > > free cc_fifo? You're right, I lost the cc_fifo() free call during some refactoring before I submitted the patch series. I will include it in the next version of the series. Devin
diff --git a/libavfilter/tinterlace.h b/libavfilter/tinterlace.h index 37b6c10..9f5ce7e 100644 --- a/libavfilter/tinterlace.h +++ b/libavfilter/tinterlace.h @@ -32,6 +32,7 @@ #include "libavutil/pixdesc.h" #include "drawutils.h" #include "avfilter.h" +#include "ccfifo.h" #define TINTERLACE_FLAG_VLPF 01 #define TINTERLACE_FLAG_CVLPF 2 @@ -77,6 +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; } TInterlaceContext; void ff_tinterlace_init_x86(TInterlaceContext *interlace); diff --git a/libavfilter/vf_tinterlace.c b/libavfilter/vf_tinterlace.c index 0326292..226983c 100644 --- a/libavfilter/vf_tinterlace.c +++ b/libavfilter/vf_tinterlace.c @@ -291,6 +291,9 @@ static int config_out_props(AVFilterLink *outlink) #endif } + if (!(tinterlace->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"); + av_log(ctx, AV_LOG_VERBOSE, "mode:%d filter:%s h:%d -> h:%d\n", tinterlace->mode, (tinterlace->flags & TINTERLACE_FLAG_CVLPF) ? "complex" : (tinterlace->flags & TINTERLACE_FLAG_VLPF) ? "linear" : "off", @@ -375,6 +378,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) tinterlace->cur = tinterlace->next; tinterlace->next = picref; + av_ccfifo_extract(tinterlace->cc_fifo, picref); + cur = tinterlace->cur; next = tinterlace->next; /* we need at least two frames */ @@ -451,6 +456,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) if (!out) return AVERROR(ENOMEM); out->pts /= 2; // adjust pts to new framerate + av_ccfifo_inject(tinterlace->cc_fifo, out); ret = ff_filter_frame(outlink, out); return ret; } @@ -486,6 +492,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) out->pts = cur->pts*2; out->pts = av_rescale_q(out->pts, tinterlace->preout_time_base, outlink->time_base); + av_ccfifo_inject(tinterlace->cc_fifo, out); if ((ret = ff_filter_frame(outlink, out)) < 0) return ret; @@ -521,6 +528,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) 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); + av_ccfifo_inject(tinterlace->cc_fifo, out); ret = ff_filter_frame(outlink, out); return ret;
Because the interlacing filter halves the effective framerate, we need to ensure that no CEA-708 data is lost as frames are merged. Make use of the new ccfifo mechanism to ensure that caption data is properly preserved as frames pass through the filter. Thanks to Thomas Mundt for review and noticing a couple of missed codepaths for injection on output. Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com> --- libavfilter/tinterlace.h | 2 ++ libavfilter/vf_tinterlace.c | 8 ++++++++ 2 files changed, 10 insertions(+)