]> git.sesse.net Git - ffmpeg/commitdiff
PGS subtitles: Expose forced flag
authorJohn Stebbins <jstebbins.hb@gmail.com>
Sat, 20 Oct 2012 16:56:11 +0000 (09:56 -0700)
committerDiego Biurrun <diego@biurrun.de>
Fri, 2 Nov 2012 15:13:35 +0000 (16:13 +0100)
Useful for detection of subtitles displayed during foreign language
scenes.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
libavcodec/avcodec.h
libavcodec/pgssubdec.c
libavcodec/version.h

index 73321b20409856478273a63791c6f8b41bf16997..43f7c87b23a55998f41828c6bbc5b3c779f61564 100644 (file)
@@ -3166,6 +3166,8 @@ enum AVSubtitleType {
     SUBTITLE_ASS,
 };
 
+#define AV_SUBTITLE_FLAG_FORCED 0x00000001
+
 typedef struct AVSubtitleRect {
     int x;         ///< top left corner  of pict, undefined when pict is not set
     int y;         ///< top left corner  of pict, undefined when pict is not set
@@ -3188,6 +3190,7 @@ typedef struct AVSubtitleRect {
      * struct.
      */
     char *ass;
+    int flags;
 } AVSubtitleRect;
 
 typedef struct AVSubtitle {
index 9fd26d80aa915dd3d7be0629fee3ee55e314ab97..0326ea8f1b38a028dd6a773edd66d98677048a8c 100644 (file)
@@ -45,6 +45,7 @@ typedef struct PGSSubPresentation {
     int y;
     int id_number;
     int object_number;
+    uint8_t composition_flag;
 } PGSSubPresentation;
 
 typedef struct PGSSubPicture {
@@ -299,16 +300,17 @@ static void parse_presentation_segment(AVCodecContext *avctx,
     buf += 3;
 
     ctx->presentation.object_number = bytestream_get_byte(&buf);
+    ctx->presentation.composition_flag = 0;
     if (!ctx->presentation.object_number)
         return;
 
     /*
-     * Skip 4 bytes of unknown:
+     * Skip 3 bytes of unknown:
      *     object_id_ref (2 bytes),
      *     window_id_ref,
-     *     composition_flag (0x80 - object cropped, 0x40 - object forced)
      */
-    buf += 4;
+    buf += 3;
+    ctx->presentation.composition_flag = bytestream_get_byte(&buf);
 
     x = bytestream_get_be16(&buf);
     y = bytestream_get_be16(&buf);
@@ -368,6 +370,9 @@ static int display_end_segment(AVCodecContext *avctx, void *data,
     sub->rects[0]  = av_mallocz(sizeof(*sub->rects[0]));
     sub->num_rects = 1;
 
+    if (ctx->presentation.composition_flag & 0x40)
+        sub->rects[0]->flags |= AV_SUBTITLE_FLAG_FORCED;
+
     sub->rects[0]->x    = ctx->presentation.x;
     sub->rects[0]->y    = ctx->presentation.y;
     sub->rects[0]->w    = ctx->picture.w;
index 5ee7c7c55d0fe67a2fdde6509a99831b0413a3d9..45ff5077ba443bb0fb83acf23d7ea5d03a791a84 100644 (file)
@@ -27,7 +27,7 @@
  */
 
 #define LIBAVCODEC_VERSION_MAJOR 54
-#define LIBAVCODEC_VERSION_MINOR 32
+#define LIBAVCODEC_VERSION_MINOR 33
 #define LIBAVCODEC_VERSION_MICRO  0
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \