diff options
author | Aman Gupta <aman@tmm1.net> | 2016-02-14 18:11:53 -0800 |
---|---|---|
committer | Clément Bœsch <u@pkh.me> | 2016-02-17 21:32:18 +0100 |
commit | 2f26b67d557f56e01f8a3efa199a832ad8ce70b0 (patch) | |
tree | 214af4ea65b2c9393b78281f80aeab6265e5aefb /libavcodec | |
parent | f09449daa4f232a932d538f38029cab8d0e7a13f (diff) | |
download | ffmpeg-2f26b67d557f56e01f8a3efa199a832ad8ce70b0.tar.gz |
lavc/ccaption_dec: do not ignore repeated character commands
control codes in a cc stream can be repeated, and must be ignored.
however, repeated characters must not be ignored. the code attempted to
wipe prev_cmd in handle_char to allow repeated characters to be
processed, but prev_cmd would previously get reset _after_ handle_char()
i also moved the prev_cmd reset out from handle_char() so it can be
re-used for special character sets, which _must_ be ignored when
repeated.
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/ccaption_dec.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c index 790f0718fd..5fb2ec6293 100644 --- a/libavcodec/ccaption_dec.c +++ b/libavcodec/ccaption_dec.c @@ -484,9 +484,6 @@ static void handle_char(CCaptionSubContext *ctx, char hi, char lo, int64_t pts) if (ctx->mode != CCMODE_POPON) ctx->screen_touched = 1; - /* reset prev command since character can repeat */ - ctx->prev_cmd[0] = 0; - ctx->prev_cmd[1] = 0; if (lo) ff_dlog(ctx, "(%c,%c)\n", hi, lo); else @@ -497,8 +494,15 @@ static void process_cc608(CCaptionSubContext *ctx, int64_t pts, uint8_t hi, uint { if (hi == ctx->prev_cmd[0] && lo == ctx->prev_cmd[1]) { /* ignore redundant command */ - } else if ( (hi == 0x10 && (lo >= 0x40 && lo <= 0x5f)) || - ( (hi >= 0x11 && hi <= 0x17) && (lo >= 0x40 && lo <= 0x7f) ) ) { + return; + } + + /* set prev command */ + ctx->prev_cmd[0] = hi; + ctx->prev_cmd[1] = lo; + + if ( (hi == 0x10 && (lo >= 0x40 && lo <= 0x5f)) || + ( (hi >= 0x11 && hi <= 0x17) && (lo >= 0x40 && lo <= 0x7f) ) ) { handle_pac(ctx, hi, lo); } else if ( ( hi == 0x11 && lo >= 0x20 && lo <= 0x2f ) || ( hi == 0x17 && lo >= 0x2e && lo <= 0x2f) ) { @@ -559,14 +563,11 @@ static void process_cc608(CCaptionSubContext *ctx, int64_t pts, uint8_t hi, uint } else if (hi >= 0x20) { /* Standard characters (always in pairs) */ handle_char(ctx, hi, lo, pts); + ctx->prev_cmd[0] = ctx->prev_cmd[1] = 0; } else { /* Ignoring all other non data code */ ff_dlog(ctx, "Unknown command 0x%hhx 0x%hhx\n", hi, lo); } - - /* set prev command */ - ctx->prev_cmd[0] = hi; - ctx->prev_cmd[1] = lo; } static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt) |