Browse Source

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>
tags/n4.1
Marton Balint 7 years ago
parent
commit
b1e0e21646
1 changed files with 15 additions and 0 deletions
  1. +15
    -0
      libavcodec/libzvbi-teletextdec.c

+ 15
- 0
libavcodec/libzvbi-teletextdec.c View File

@@ -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;


Loading…
Cancel
Save