[FFmpeg-cvslog] Exposing forced flag for DVD and PGS subtitles

hakuya git at videolan.org
Mon Apr 30 20:04:32 CEST 2012


ffmpeg | branch: master | hakuya <erikmiranda at gmail.com> | Sun Apr 15 21:58:40 2012 -0400| [79e5902cf163dcb8b6539618936ff0ce28f742e4] | committer: Michael Niedermayer

Exposing forced flag for DVD and PGS subtitles

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=79e5902cf163dcb8b6539618936ff0ce28f742e4
---

 libavcodec/avcodec.h   |    6 ++++++
 libavcodec/dvdsubdec.c |    1 +
 libavcodec/options.c   |    1 +
 libavcodec/pgssubdec.c |    3 +++
 4 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index f8700dd..657e5b7 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3158,6 +3158,12 @@ typedef struct AVSubtitleRect {
      * struct.
      */
     char *ass;
+
+    /**
+     * 1 indicates this subtitle is a forced subtitle.
+     * A forced subtitle should be displayed even when subtitles are hidden.
+     */
+    int forced;
 } AVSubtitleRect;
 
 typedef struct AVSubtitle {
diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c
index 08d1db9..ec86b25 100644
--- a/libavcodec/dvdsubdec.c
+++ b/libavcodec/dvdsubdec.c
@@ -356,6 +356,7 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
                 sub_header->rects[0]->h = h;
                 sub_header->rects[0]->type = SUBTITLE_BITMAP;
                 sub_header->rects[0]->pict.linesize[0] = w;
+                sub_header->rects[0]->forced = is_menu;
             }
         }
         if (next_cmd_pos < cmd_pos) {
diff --git a/libavcodec/options.c b/libavcodec/options.c
index f4daf14..a08b7e5 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -264,6 +264,7 @@ static const AVOption subtitle_rect_options[]={
 {"w", "", SROFFSET(w), AV_OPT_TYPE_INT, {.dbl = 0 }, 0, INT_MAX, 0},
 {"h", "", SROFFSET(h), AV_OPT_TYPE_INT, {.dbl = 0 }, 0, INT_MAX, 0},
 {"type", "", SROFFSET(type), AV_OPT_TYPE_INT, {.dbl = 0 }, 0, INT_MAX, 0},
+{"forced", "", SROFFSET(forced), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 1, 0},
 {NULL},
 };
 
diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c
index be0981d..4fb1e7d 100644
--- a/libavcodec/pgssubdec.c
+++ b/libavcodec/pgssubdec.c
@@ -423,6 +423,9 @@ static int display_end_segment(AVCodecContext *avctx, void *data,
         sub->rects[rect]->nb_colors    = 256;
         sub->rects[rect]->pict.data[1] = av_mallocz(AVPALETTE_SIZE);
 
+        /* Copy the forced flag */
+        sub->rects[rect]->forced = (ctx->presentation.objects[rect].composition & 0x40) != 0;
+
         if (!ctx->forced_subs_only || ctx->presentation.objects[rect].composition & 0x40)
         memcpy(sub->rects[rect]->pict.data[1], ctx->clut, sub->rects[rect]->nb_colors * sizeof(uint32_t));
     }



More information about the ffmpeg-cvslog mailing list