[FFmpeg-devel] [PATCH]Display DVB subtitles if display segment is missing

Carl Eugen Hoyos cehoyos at ag.or.at
Mon Jan 23 12:22:48 CET 2012


Hi!

Attached patch by Mark Kendall fixes ticket #937.

Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
index e2a804a..71b6dc6 100644
--- a/libavcodec/dvbsubdec.c
+++ b/libavcodec/dvbsubdec.c
@@ -1452,6 +1452,7 @@ static int dvbsub_decode(AVCodecContext *avctx,
     int page_id;
     int segment_length;
     int i;
+    int gotpage = 0, gotregion = 0, gotclut = 0, gotobject = 0, gotdisplay = 0;
 
     av_dlog(avctx, "DVB sub packet:\n");
 
@@ -1490,21 +1491,26 @@ static int dvbsub_decode(AVCodecContext *avctx,
             switch (segment_type) {
             case DVBSUB_PAGE_SEGMENT:
                 dvbsub_parse_page_segment(avctx, p, segment_length);
+                gotpage = 1;
                 break;
             case DVBSUB_REGION_SEGMENT:
                 dvbsub_parse_region_segment(avctx, p, segment_length);
+                gotregion = 1;
                 break;
             case DVBSUB_CLUT_SEGMENT:
                 dvbsub_parse_clut_segment(avctx, p, segment_length);
+                gotclut = 1;
                 break;
             case DVBSUB_OBJECT_SEGMENT:
                 dvbsub_parse_object_segment(avctx, p, segment_length);
+                gotobject = 1;
                 break;
             case DVBSUB_DISPLAYDEFINITION_SEGMENT:
                 dvbsub_parse_display_definition_segment(avctx, p, segment_length);
                 break;
             case DVBSUB_DISPLAY_SEGMENT:
                 *data_size = dvbsub_display_end_segment(avctx, p, segment_length, sub);
+                gotdisplay = 1;
                 break;
             default:
                 av_dlog(avctx, "Subtitling segment type 0x%x, page id %d, length %d\n",
@@ -1515,6 +1521,10 @@ static int dvbsub_decode(AVCodecContext *avctx,
 
         p += segment_length;
     }
+    // Some streams do not send a display segment but if we have all the other
+    // segments then we need no further data.
+    if (gotpage && gotregion && gotclut && gotobject && !gotdisplay && sub)
+        *data_size = dvbsub_display_end_segment(avctx, p, 0, sub);
 
     return p - buf;
 }


More information about the ffmpeg-devel mailing list