From: Aman Gupta <a...@tmm1.net>

Some streams include both a53 and scte20 data. Before this commit,
the scte20 data would be used instead of the a53 data.

See https://s3.amazonaws.com/tmm1/ccaptions/scte20plusa53.ts,
which produced garbage captions since 3f1a540204a8c187f77b3805d.
---
 libavcodec/mpeg12dec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 9e076e89da..45d0a9d737 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -59,6 +59,7 @@ typedef struct Mpeg1Context {
     int has_stereo3d;
     uint8_t *a53_caption;
     int a53_caption_size;
+    int ignore_scte20;
     uint8_t afd;
     int has_afd;
     int slice_count;
@@ -2241,6 +2242,7 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
         /* extract A53 Part 4 CC data */
         int cc_count = p[5] & 0x1f;
         if (cc_count > 0 && buf_size >= 7 + cc_count * 3) {
+            s1->ignore_scte20 = 1;
             av_freep(&s1->a53_caption);
             s1->a53_caption_size = cc_count * 3;
             s1->a53_caption      = av_malloc(s1->a53_caption_size);
@@ -2253,7 +2255,8 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
         }
         return 1;
     } else if (buf_size >= 2 &&
-               p[0] == 0x03 && (p[1]&0x7f) == 0x01) {
+               p[0] == 0x03 && (p[1]&0x7f) == 0x01 &&
+               !s1->ignore_scte20) {
         /* extract SCTE-20 CC data */
         GetBitContext gb;
         int cc_count = 0;
-- 
2.14.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to