avcodec/dvbsubdec: Implement display definition segment fallback from ETSI EN 300...
authorMichael Niedermayer <michael@niedermayer.cc>
Wed, 29 Jul 2015 15:59:51 +0000 (17:59 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Wed, 29 Jul 2015 16:02:07 +0000 (18:02 +0200)
Fixes: subtitles.ts
Fixes: Ticket679

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/dvbsubdec.c

index e3b72ab..ce03e12 100644 (file)
@@ -1606,6 +1606,7 @@ static int dvbsub_decode(AVCodecContext *avctx,
     int i;
     int ret = 0;
     int got_segment = 0;
+    int got_dds = 0;
 
     ff_dlog(avctx, "DVB sub packet:\n");
 
@@ -1668,9 +1669,15 @@ static int dvbsub_decode(AVCodecContext *avctx,
             case DVBSUB_DISPLAYDEFINITION_SEGMENT:
                 ret = dvbsub_parse_display_definition_segment(avctx, p,
                                                               segment_length);
+                got_dds = 1;
                 break;
             case DVBSUB_DISPLAY_SEGMENT:
                 ret = dvbsub_display_end_segment(avctx, p, segment_length, sub, data_size);
+                if (got_segment == 15 && !got_dds && !avctx->width && !avctx->height) {
+                    // Default from ETSI EN 300 743 V1.3.1 (7.2.1)
+                    avctx->width  = 720;
+                    avctx->height = 576;
+                }
                 got_segment |= 16;
                 break;
             default: