[FFmpeg-devel] [PATCH 2/2] lavc/srtdec: set subtitle timing in the structure.

Clément Bœsch ubitux at gmail.com
Tue Sep 11 19:44:08 CEST 2012


On Sun, Sep 02, 2012 at 10:03:18AM +0200, Nicolas George wrote:
> Also fix the time base used for the packet timestamps.
> 
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
>  libavcodec/srtdec.c |   13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/srtdec.c b/libavcodec/srtdec.c
> index 12b7e0c..87ab6f4 100644
> --- a/libavcodec/srtdec.c
> +++ b/libavcodec/srtdec.c
> @@ -209,7 +209,7 @@ static int srt_decode_frame(AVCodecContext *avctx,
>                              void *data, int *got_sub_ptr, AVPacket *avpkt)
>  {
>      AVSubtitle *sub = data;
> -    int64_t ts_start, ts_end;
> +    int64_t ts_packet, ts_start, ts_end;
>      int x1 = -1, y1 = -1, x2 = -1, y2 = -1;
>      char buffer[2048];
>      const char *ptr = avpkt->data;
> @@ -218,22 +218,25 @@ static int srt_decode_frame(AVCodecContext *avctx,
>      if (avpkt->size <= 0)
>          return avpkt->size;
>  
> +    ts_packet = av_rescale_q(avpkt->pts,
> +                             avctx->pkt_timebase,
> +                             (AVRational){1, 1000});
>      while (ptr < end && *ptr) {
>          if (avctx->codec->id == CODEC_ID_SRT) {
>              ptr = read_ts(ptr, &ts_start, &ts_end, &x1, &y1, &x2, &y2);
>              if (!ptr)
>                  break;
>          } else {
> -            ts_start = av_rescale_q(avpkt->pts,
> -                                    avctx->time_base,
> -                                    (AVRational){1,1000});
> +            ts_start = ts_packet;
>              ts_end   = av_rescale_q(avpkt->pts + avpkt->duration,
> -                                    avctx->time_base,
> +                                    avctx->pkt_timebase,
>                                      (AVRational){1,1000});
>          }

Doesn't make much sense to me, according to my previous mail.

>          ptr = srt_to_ass(avctx, buffer, buffer+sizeof(buffer), ptr,
>                           x1, y1, x2, y2);
>          ff_ass_add_rect(sub, buffer, ts_start / 10, ts_end / 10 - ts_start / 10, 0);
> +        sub->start_display_time = ts_start - ts_packet;
> +        sub->end_display_time   = ts_end   - ts_packet;

Is this really necessary? What does it fix?

[...]

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120911/95080f76/attachment.asc>


More information about the ffmpeg-devel mailing list