[FFmpeg-devel] [PATCH 3/6] lavf: probe PGS subtitles definition.
Nicolas George
nicolas.george at normalesup.org
Tue Aug 7 21:13:31 CEST 2012
The resolution is in the packets, so decoding must happen.
Since most other formats do not set the dimension, make it
a special case for PGS. If other codecs were to have the
same requirement, using a CODEC_CAP would be preferred.
Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
libavformat/utils.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 23b72b5..75a640c 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2320,6 +2320,10 @@ static int has_codec_parameters(AVStream *st, const char **errmsg_ptr)
if (st->info->found_decoder >= 0 && avctx->pix_fmt == PIX_FMT_NONE)
FAIL("unspecified pixel format");
break;
+ case AVMEDIA_TYPE_SUBTITLE:
+ if (avctx->codec_id == CODEC_ID_HDMV_PGS_SUBTITLE && !avctx->width)
+ FAIL("unspecified size");
+ break;
case AVMEDIA_TYPE_DATA:
if(avctx->codec_id == CODEC_ID_NONE) return 1;
}
@@ -2335,6 +2339,7 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **option
AVCodec *codec;
int got_picture = 1, ret = 0;
AVFrame picture;
+ AVSubtitle subtitle;
AVPacket pkt = *avpkt;
if (!avcodec_is_open(st->codec) && !st->info->found_decoder) {
@@ -2380,6 +2385,11 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **option
case AVMEDIA_TYPE_AUDIO:
ret = avcodec_decode_audio4(st->codec, &picture, &got_picture, &pkt);
break;
+ case AVMEDIA_TYPE_SUBTITLE:
+ ret = avcodec_decode_subtitle2(st->codec, &subtitle,
+ &got_picture, &pkt);
+ ret = pkt.size;
+ break;
default:
break;
}
--
1.7.10.4
More information about the ffmpeg-devel
mailing list