[vlc-commits] avcodec: fix PGS timestamps

Petri Hintukainen git at videolan.org
Wed Nov 25 23:16:48 CET 2015


vlc | branch: master | Petri Hintukainen <phintuka at gmail.com> | Wed Nov 25 14:47:37 2015 +0200| [9fc361dea16db17f3220974d9b68f1af955b236a] | committer: Jean-Baptiste Kempf

avcodec: fix PGS timestamps

Display time is not pts of the last block.
avcodec returns decoded subtitle with the correct timestamp.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9fc361dea16db17f3220974d9b68f1af955b236a
---

 modules/codec/avcodec/subtitle.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/modules/codec/avcodec/subtitle.c b/modules/codec/avcodec/subtitle.c
index 0bdbb5d..9e3b2b4 100644
--- a/modules/codec/avcodec/subtitle.c
+++ b/modules/codec/avcodec/subtitle.c
@@ -80,6 +80,10 @@ int InitSubtitleDec(decoder_t *dec, AVCodecContext *context,
     context->extradata_size = 0;
     context->extradata = NULL;
 
+#if LIBAVFORMAT_VERSION_MICRO >= 100
+    av_codec_set_pkt_timebase(context, AV_TIME_BASE_Q);
+#endif
+
     /* */
     int ret;
     char *psz_opts = var_InheritString(dec, "avcodec-options");
@@ -154,6 +158,7 @@ static subpicture_t *DecodeSubtitle(decoder_t *dec, block_t **block_ptr)
     av_init_packet(&pkt);
     pkt.data = block->p_buffer;
     pkt.size = block->i_buffer;
+    pkt.pts  = block->i_pts;
 
     int has_subtitle = 0;
     int used = avcodec_decode_subtitle2(sys->p_context,
@@ -176,7 +181,7 @@ static subpicture_t *DecodeSubtitle(decoder_t *dec, block_t **block_ptr)
     subpicture_t *spu = NULL;
     if (has_subtitle)
         spu = ConvertSubtitle(dec, &subtitle,
-                              block->i_pts > 0 ? block->i_pts : block->i_dts,
+                              subtitle.pts,
                               sys->p_context);
 
     /* */



More information about the vlc-commits mailing list