[vlc-commits] PGS subtitles: use origial frame size (fix #6324)

Arne de Bruijn git at videolan.org
Tue May 20 11:12:42 CEST 2014


vlc/vlc-2.1 | branch: master | Arne de Bruijn <mail at arnedebruijn.nl> | Sun May 18 23:36:37 2014 +0200| [fd2fe5f92dda1b70193980b467701296e4c88b02] | committer: Jean-Baptiste Kempf

PGS subtitles: use origial frame size (fix #6324)

With CODEC_ID_HDMV_PGS_SUBTITLE use codec_{width,height} for
i_original_picture_{width,height} to correctly display
subtitles with a frame size that is different from the
video stream

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit 328a034c115dfa9b4ff7b636b8ab90436af6464b)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/codec/avcodec/subtitle.c |   23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/modules/codec/avcodec/subtitle.c b/modules/codec/avcodec/subtitle.c
index 407bb90..f2ff402 100644
--- a/modules/codec/avcodec/subtitle.c
+++ b/modules/codec/avcodec/subtitle.c
@@ -42,7 +42,8 @@ struct decoder_sys_t {
     AVCODEC_COMMON_MEMBERS
 };
 
-static subpicture_t *ConvertSubtitle(decoder_t *, AVSubtitle *, mtime_t pts);
+static subpicture_t *ConvertSubtitle(decoder_t *, AVSubtitle *, mtime_t pts,
+                                     AVCodecContext *avctx);
 
 /**
  * Initialize subtitle decoder
@@ -174,7 +175,8 @@ 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);
+                              block->i_pts > 0 ? block->i_pts : block->i_dts,
+                              sys->p_context);
 
     /* */
     if (!spu)
@@ -232,7 +234,8 @@ static subpicture_region_t *ConvertRegionRGBA(AVSubtitleRect *ffregion)
 /**
  * Convert a libavcodec subtitle to our format.
  */
-static subpicture_t *ConvertSubtitle(decoder_t *dec, AVSubtitle *ffsub, mtime_t pts)
+static subpicture_t *ConvertSubtitle(decoder_t *dec, AVSubtitle *ffsub, mtime_t pts,
+                                     AVCodecContext *avctx)
 {
     subpicture_t *spu = decoder_NewSubpicture(dec, NULL);
     if (!spu)
@@ -244,10 +247,16 @@ static subpicture_t *ConvertSubtitle(decoder_t *dec, AVSubtitle *ffsub, mtime_t
     spu->i_stop     = pts + ffsub->end_display_time * INT64_C(1000);
     spu->b_absolute = true; /* FIXME How to set it right ? */
     spu->b_ephemer  = true; /* FIXME How to set it right ? */
-    spu->i_original_picture_width =
-        dec->fmt_in.subs.spu.i_original_frame_width;
-    spu->i_original_picture_height =
-        dec->fmt_in.subs.spu.i_original_frame_height;
+
+    if (avctx->codec_id == AV_CODEC_ID_HDMV_PGS_SUBTITLE) {
+        spu->i_original_picture_width = avctx->coded_width;
+        spu->i_original_picture_height = avctx->coded_height;
+    } else {
+        spu->i_original_picture_width =
+            dec->fmt_in.subs.spu.i_original_frame_width;
+        spu->i_original_picture_height =
+            dec->fmt_in.subs.spu.i_original_frame_height;
+    }
 
     subpicture_region_t **region_next = &spu->p_region;
 



More information about the vlc-commits mailing list