On Monday 06 July 2015 06:18:14 pm Carl Eugen Hoyos wrote: > Hendrik Leppkes <h.leppkes <at> gmail.com> writes: > > > Attached patch adds "Closed Captions" to the codec > > > dump if the video stream contains them. > > > > Adding fields to a public context which should never > > be accessed by the public is a big no-no. > > What is the alternative?
As in attached? Carl Eugen
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index e367399..cc71f10 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 + * To be accessed through av_codec_get_closed_captions() (NO direct access) + * - encoding: unused + * - decoding: set by libavcodec + */ + int closed_captions; } AVCodecContext; AVRational av_codec_get_pkt_timebase (const AVCodecContext *avctx); @@ -3185,6 +3193,12 @@ void av_codec_set_lowres(AVCodecContext *avctx, int val); int av_codec_get_seek_preroll(const AVCodecContext *avctx); void av_codec_set_seek_preroll(AVCodecContext *avctx, int val); +/** + * Returns >0 if Closed Captions were found in the (video) stream + * Returns 0 if no Closed Captions were found in the (video) stream + */ +int av_codec_get_closed_captions(const AVCodecContext *avctx); + uint16_t *av_codec_get_chroma_intra_matrix(const AVCodecContext *avctx); void av_codec_set_chroma_intra_matrix(AVCodecContext *avctx, uint16_t *val); 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..a875f7c 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1299,6 +1299,11 @@ MAKE_ACCESSORS(AVCodecContext, codec, int, lowres) MAKE_ACCESSORS(AVCodecContext, codec, int, seek_preroll) MAKE_ACCESSORS(AVCodecContext, codec, uint16_t*, chroma_intra_matrix) +int av_codec_get_closed_captions(const AVCodecContext *codec) +{ + return codec->closed_captions; +} + int av_codec_get_max_lowres(const AVCodec *codec) { return codec->max_lowres; @@ -3136,6 +3141,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:
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel