Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Devin Heitmueller <devin.heitmueller@ltnglobal.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Devin Heitmueller <dheitmueller@ltnglobal.com>
Subject: [FFmpeg-devel] [PATCH v2 2/5] vf_fps: properly preserve CEA-708 captions
Date: Fri,  7 Apr 2023 17:58:26 -0400
Message-ID: <1680904709-25951-3-git-send-email-dheitmueller@ltnglobal.com> (raw)
In-Reply-To: <1680904709-25951-1-git-send-email-dheitmueller@ltnglobal.com>

The existing implementation made an attempt to remove duplicate
captions if increasing the framerate, but made no attempt to
handle reducing the framerate, nor did it rewrite the caption
payloads to have the appropriate cc_count (e.g. the cc_count needs
to change from 20 to 10 when going from 1080i59 to 720p59 and
vice-versa).

Make use of the new ccfifo mechanism to ensure that caption data
is properly preserved.

Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
---
 libavfilter/vf_fps.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_fps.c b/libavfilter/vf_fps.c
index 051d278..3f18bfc 100644
--- a/libavfilter/vf_fps.c
+++ b/libavfilter/vf_fps.c
@@ -34,6 +34,7 @@
 #include "libavutil/mathematics.h"
 #include "libavutil/opt.h"
 #include "avfilter.h"
+#include "ccfifo.h"
 #include "filters.h"
 #include "internal.h"
 
@@ -85,6 +86,7 @@ typedef struct FPSContext {
 
     AVFrame *frames[2];     ///< buffered frames
     int      frames_count;  ///< number of buffered frames
+    AVCCFifo *cc_fifo;      ///< closed captions
 
     int64_t  next_pts;      ///< pts of the next frame to output
 
@@ -165,6 +167,7 @@ static av_cold void uninit(AVFilterContext *ctx)
         frame = shift_frame(ctx, s);
         av_frame_free(&frame);
     }
+    av_ccfifo_freep(&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);
@@ -210,6 +213,9 @@ static int config_props(AVFilterLink* outlink)
                s->in_pts_off, s->out_pts_off, s->start_time);
     }
 
+    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");
+
     av_log(ctx, AV_LOG_VERBOSE, "fps=%d/%d\n", outlink->frame_rate.num, outlink->frame_rate.den);
 
     return 0;
@@ -242,6 +248,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);
 
+    av_ccfifo_extract(s->cc_fifo, frame);
     s->frames[s->frames_count++] = frame;
     s->frames_in++;
 
@@ -289,7 +296,7 @@ static int write_frame(AVFilterContext *ctx, FPSContext *s, AVFilterLink *outlin
         if (!frame)
             return AVERROR(ENOMEM);
         // Make sure Closed Captions will not be duplicated
-        av_frame_remove_side_data(s->frames[0], AV_FRAME_DATA_A53_CC);
+        av_ccfifo_inject(s->cc_fifo, frame);
         frame->pts = s->next_pts++;
         frame->duration = 1;
 
-- 
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".

  parent reply	other threads:[~2023-04-07 21:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-07 21:58 [FFmpeg-devel] [PATCH v2 0/5] Add support for Closed Caption FIFO Devin Heitmueller
2023-04-07 21:58 ` [FFmpeg-devel] [PATCH v2 1/5] ccfifo: Properly handle CEA-708 captions through framerate conversion Devin Heitmueller
2023-04-14 13:22   ` James Almer
2023-04-14 15:19     ` Devin Heitmueller
2023-04-16  9:37       ` Thilo Borgmann
2023-04-17  0:29         ` Devin Heitmueller
2023-04-07 21:58 ` Devin Heitmueller [this message]
2023-04-07 21:58 ` [FFmpeg-devel] [PATCH v2 3/5] yadif: Properly preserve CEA-708 closed captions Devin Heitmueller
2023-04-07 21:58 ` [FFmpeg-devel] [PATCH v2 4/5] tinterlace: " Devin Heitmueller
2023-04-10  1:28   ` Lance Wang
2023-04-10 12:45     ` Devin Heitmueller
2023-04-07 21:58 ` [FFmpeg-devel] [PATCH v2 5/5] vf_ccrepack: Add new filter to repack CEA-708 side data Devin Heitmueller
2023-04-14 13:19 ` [FFmpeg-devel] [PATCH v2 0/5] Add support for Closed Caption FIFO 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=1680904709-25951-3-git-send-email-dheitmueller@ltnglobal.com \
    --to=devin.heitmueller@ltnglobal.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