summaryrefslogtreecommitdiff
path: root/libavcodec/libzvbi-teletextdec.c
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2018-06-11 00:53:13 +0200
committerMarton Balint <cus@passwd.hu>2018-06-20 22:26:41 +0200
commitb1e0e216462a989a39e7b413aef6d32f8cedc154 (patch)
treec62f195c8265a4dcffb33a6578f7ba095f2f232d /libavcodec/libzvbi-teletextdec.c
parenta9901840079b156c88c6d9ad4a61bc6e7e9c6235 (diff)
avcodec/libzvbi-teletextdec: propagate ERASE_PAGE flag for repeated subtitle page headers
This works around a libzvbi bug (a corner case in the teletext spec): https://sourceforge.net/p/zapping/bugs/203/ https://sourceforge.net/p/zapping/patches/20/ Fixes samples/ffmpeg-bugs/trac/ticket2086/RBT_20100801_1835.ts. Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavcodec/libzvbi-teletextdec.c')
-rw-r--r--libavcodec/libzvbi-teletextdec.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/libavcodec/libzvbi-teletextdec.c b/libavcodec/libzvbi-teletextdec.c
index ccded23e7c..809547545b 100644
--- a/libavcodec/libzvbi-teletextdec.c
+++ b/libavcodec/libzvbi-teletextdec.c
@@ -74,6 +74,8 @@ typedef struct TeletextContext
int readorder;
uint8_t subtitle_map[2048];
+ int last_pgno;
+ int last_p5;
} TeletextContext;
static int chop_spaces_utf8(const unsigned char* t, int len)
@@ -372,6 +374,17 @@ static int slice_to_vbi_lines(TeletextContext *ctx, uint8_t* buf, int size)
int pgno = ((pmag & 7) << 8) + page;
// Check for disabled NEWSFLASH flag and enabled SUBTITLE and SUPRESS_HEADER flags
ctx->subtitle_map[pgno] = (!(flags1 & 0x40) && flags1 & 0x80 && flags2 & 0x01);
+ // Propagate ERASE_PAGE flag for repeated page headers to work around a libzvbi bug
+ if (ctx->subtitle_map[pgno] && pgno == ctx->last_pgno) {
+ int last_byte9 = vbi_unham8(ctx->last_p5);
+ if (last_byte9 >= 0 && last_byte9 & 0x8) {
+ int byte9 = vbi_unham8(p[5]);
+ if (byte9 >= 0)
+ p[5] = vbi_ham8(byte9 | 0x8);
+ }
+ }
+ ctx->last_pgno = pgno;
+ ctx->last_p5 = p[5];
}
}
lines++;
@@ -494,6 +507,7 @@ static int teletext_init_decoder(AVCodecContext *avctx)
ctx->vbi = NULL;
ctx->pts = AV_NOPTS_VALUE;
+ ctx->last_pgno = -1;
if (ctx->opacity == -1)
ctx->opacity = ctx->transparent_bg ? 0 : 255;
@@ -514,6 +528,7 @@ static int teletext_close_decoder(AVCodecContext *avctx)
vbi_decoder_delete(ctx->vbi);
ctx->vbi = NULL;
ctx->pts = AV_NOPTS_VALUE;
+ ctx->last_pgno = -1;
memset(ctx->subtitle_map, 0, sizeof(ctx->subtitle_map));
if (!(avctx->flags2 & AV_CODEC_FLAG2_RO_FLUSH_NOOP))
ctx->readorder = 0;