Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Thomas Mundt <tmundt75@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Cc: Devin Heitmueller <dheitmueller@ltnglobal.com>
Subject: Re: [FFmpeg-devel] [RFC PATCH 4/5] tinterlace: Properly preserve CEA-708 closed captions
Date: Sat, 18 Mar 2023 18:12:09 +0100
Message-ID: <CAC5+Sy4TZ9NWpEtEGBjfBJ0=3UVh936Hz0L_OpFndOg+Fjo25g@mail.gmail.com> (raw)
In-Reply-To: <20230317200941.3936-5-dheitmueller@ltnglobal.com>

Hi Devin,

Am Fr., 17. März 2023 um 21:10 Uhr schrieb Devin Heitmueller <
devin.heitmueller@ltnglobal.com>:

> Because the interlacing filter halves the effective framerate, we
> need to ensure that no CEA-708 data is lost as frames are merged.
>

Not all modes of tinterlace halve the frame rate. mergex2 and pad keep it,
interlacex2 even doubles it.


> Make use of the new ccfifo mechanism to ensure that caption data
> is properly preserved as frames pass through the filter.
>
> Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
> ---
>  libavfilter/tinterlace.h    |  2 ++
>  libavfilter/vf_tinterlace.c | 10 ++++++++++
>  2 files changed, 12 insertions(+)
>
> diff --git a/libavfilter/tinterlace.h b/libavfilter/tinterlace.h
> index 37b6c10c08..30574c2ebf 100644
> --- a/libavfilter/tinterlace.h
> +++ b/libavfilter/tinterlace.h
> @@ -30,6 +30,7 @@
>  #include "libavutil/bswap.h"
>  #include "libavutil/opt.h"
>  #include "libavutil/pixdesc.h"
> +#include "libavutil/ccfifo.h"
>  #include "drawutils.h"
>  #include "avfilter.h"
>
> @@ -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 032629279a..260386a889 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 */
> @@ -390,6 +395,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
> *picref)
>          if (!out)
>              return AVERROR(ENOMEM);
>          av_frame_copy_props(out, cur);
> +        av_ccfifo_inject(tinterlace->cc_fifo, out);
>          out->height = outlink->h;
>          out->interlaced_frame = 1;
>          out->top_field_first = 1;
> @@ -423,6 +429,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
> *picref)
>

Are the drop modes missing?
Would it perhaps be clearer to put av_ccfifo_inject before ff_filter_frame?


>          if (!out)
>              return AVERROR(ENOMEM);
>          av_frame_copy_props(out, cur);
> +        av_ccfifo_inject(tinterlace->cc_fifo, out);
>          out->height = outlink->h;
>          out->sample_aspect_ratio = av_mul_q(cur->sample_aspect_ratio,
> av_make_q(2, 1));
>
> @@ -459,6 +466,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
> *picref)
>          if (!out)
>              return AVERROR(ENOMEM);
>          av_frame_copy_props(out, cur);
> +        av_ccfifo_inject(tinterlace->cc_fifo, out);
>          out->interlaced_frame = 1;
>          out->top_field_first = tff;
>
> @@ -481,6 +489,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
> *picref)
>          out = av_frame_clone(cur);
>          if (!out)
>              return AVERROR(ENOMEM);
> +        av_ccfifo_inject(tinterlace->cc_fifo, out);
>          out->interlaced_frame = 1;
>          if (cur->pts != AV_NOPTS_VALUE)
>              out->pts = cur->pts*2;
> @@ -495,6 +504,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
> *picref)
>          if (!out)
>              return AVERROR(ENOMEM);
>          av_frame_copy_props(out, next);
> +        av_ccfifo_inject(tinterlace->cc_fifo, out);
>          out->interlaced_frame = 1;
>          out->top_field_first = !tff;
>
> --
>

Regards,
Thomas
_______________________________________________
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".

  reply	other threads:[~2023-03-18 17:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-17 20:09 [FFmpeg-devel] [RFC PATCH 0/5] Properly handle CEA-708 caption data when transcoding Devin Heitmueller
2023-03-17 20:09 ` [FFmpeg-devel] [RFC PATCH 1/5] ccfifo: Properly handle CEA-708 captions through framerate conversion Devin Heitmueller
2023-03-17 20:09 ` [FFmpeg-devel] [RFC PATCH 2/5] vf_fps: properly preserve CEA-708 captions Devin Heitmueller
2023-03-17 20:09 ` [FFmpeg-devel] [RFC PATCH 3/5] yadif: Properly preserve CEA-708 closed captions Devin Heitmueller
2023-03-18 15:48   ` Dennis Mungai
2023-03-18 23:20     ` Devin Heitmueller
2023-03-17 20:09 ` [FFmpeg-devel] [RFC PATCH 4/5] tinterlace: " Devin Heitmueller
2023-03-18 17:12   ` Thomas Mundt [this message]
2023-03-18 23:22     ` Devin Heitmueller
2023-03-19 16:50       ` Thomas Mundt
2023-03-19 17:33         ` Devin Heitmueller
2023-03-17 20:09 ` [FFmpeg-devel] [RFC PATCH 5/5] vf_ccrepack: Add new filter to repack CEA-708 side data Devin Heitmueller
2023-03-17 23:23 ` [FFmpeg-devel] [RFC PATCH 0/5] Properly handle CEA-708 caption data when transcoding BUCCIANTINI Francesco - ADECCO
2023-03-18 23:16   ` Devin Heitmueller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAC5+Sy4TZ9NWpEtEGBjfBJ0=3UVh936Hz0L_OpFndOg+Fjo25g@mail.gmail.com' \
    --to=tmundt75@gmail.com \
    --cc=dheitmueller@ltnglobal.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git