[FFmpeg-devel] [PATCH 2/6] lavc: set AVSubtitle.pts if possible.

Philip Langdale philipl at overt.org
Sun Sep 9 23:22:09 CEST 2012


On 09.09.2012 07:50, Nicolas George wrote:
> If the packet has a PTS and the corresponding time base is known,
> set the pts field of the decoded subtitle structure before the
> call to the decoder. The decoder is still allowed to change the
> PTS if necessary.
>
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
>  libavcodec/utils.c |    3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 99e012a..30b0d21 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -1701,6 +1701,9 @@ int avcodec_decode_subtitle2(AVCodecContext
> *avctx, AVSubtitle *sub,
>      avctx->pkt = avpkt;
>      *got_sub_ptr = 0;
>      avcodec_get_subtitle_defaults(sub);
> +    if (avctx->pkt_timebase.den && avpkt->pts != AV_NOPTS_VALUE)
> +        sub->pts = av_rescale_q(avpkt->pts,
> +                                avctx->pkt_timebase, 
> AV_TIME_BASE_Q);
>      ret = avctx->codec->decode(avctx, sub, got_sub_ptr, avpkt);
>      if (*got_sub_ptr)
>          avctx->frame_number++;

LGTM.

--phil


More information about the ffmpeg-devel mailing list