[FFmpeg-devel] [PATCH]Tell users about Closed Captions in video streams
Carl Eugen Hoyos
cehoyos at ag.or.at
Mon Jul 6 17:53:29 CEST 2015
Hi!
Attached patch adds "Closed Captions" to the codec dump if
the video stream contains them.
Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index e367399..c39a241 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3171,6 +3171,14 @@ typedef struct AVCodecContext {
* - decoding: set by user through AVOPtions (NO direct access)
*/
char *codec_whitelist;
+
+ /**
+ * Set if the (video) stream contains internal Closed Captions
+ * Not to be accessed outside of libavcodec
+ * - encoding: unused
+ * - decoding: set by libavcodec
+ */
+ int closed_captions;
} AVCodecContext;
AVRational av_codec_get_pkt_timebase (const AVCodecContext *avctx);
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index f62ad6a..824abd6 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -886,6 +886,7 @@ static void decode_postinit(H264Context *h, int setup_finished)
memcpy(sd->data, h->a53_caption, h->a53_caption_size);
av_freep(&h->a53_caption);
h->a53_caption_size = 0;
+ h->avctx->closed_captions = 1;
}
cur->mmco_reset = h->mmco_reset;
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index b0e5ae9..c250d55 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1685,6 +1685,7 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
if (sd)
memcpy(sd->data, s1->a53_caption, s1->a53_caption_size);
av_freep(&s1->a53_caption);
+ avctx->closed_captions = 1;
}
if (s1->has_stereo3d) {
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index b80b4e7..26b1662 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -3136,6 +3136,10 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
if (encode) {
snprintf(buf + strlen(buf), buf_size - strlen(buf),
", q=%d-%d", enc->qmin, enc->qmax);
+ } else {
+ if (enc->closed_captions)
+ snprintf(buf + strlen(buf), buf_size - strlen(buf),
+ ", Closed Captions");
}
break;
case AVMEDIA_TYPE_AUDIO:
More information about the ffmpeg-devel
mailing list