--- libavcodec/ccaption_dec.c | 43 +++++++------------------------------------ 1 file changed, 7 insertions(+), 36 deletions(-)
diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c index 9f67caa..1fdf7ed 100644 --- a/libavcodec/ccaption_dec.c +++ b/libavcodec/ccaption_dec.c @@ -101,40 +101,6 @@ static const unsigned char pac2_attribs[32][3] = // Color, font, ident /* total 32 entries */ }; -/* 0-255 needs 256 spaces */ -static const uint8_t parity_table[256] = { 0, 1, 1, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 1, 1, 0, - 0, 1, 1, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 1, 1, 0, - 0, 1, 1, 0, 1, 0, 0, 1, - 0, 1, 1, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 1, 1, 0, - 0, 1, 1, 0, 1, 0, 0, 1, - 0, 1, 1, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 1, 1, 0, - 0, 1, 1, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 1, 1, 0, - 0, 1, 1, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 1, 1, 0, - 0, 1, 1, 0, 1, 0, 0, 1, - 0, 1, 1, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 1, 1, 0, - 0, 1, 1, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 1, 1, 0, - 0, 1, 1, 0, 1, 0, 0, 1, - 0, 1, 1, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 1, 1, 0, - 0, 1, 1, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 1, 1, 0, - 0, 1, 1, 0, 1, 0, 0, 1, - 0, 1, 1, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 1, 1, 0 }; - struct Screen { /* +1 is used to compensate null character of string */ uint8_t characters[SCREEN_ROWS][SCREEN_COLUMNS+1]; @@ -221,6 +187,11 @@ static int write_char (CCaptionSubContext *ctx, char *row,uint8_t col, char ch) } } +static inline int get_parity(uint8_t x) +{ + return (0x6996966996696996ULL >> (x & 63) ^ (x>>7) ^ (x>>6)) & 1; +} + /** * This function after validating parity bit, also remove it from data pair. * The first byte doesn't pass parity, we replace it with a solid blank @@ -238,10 +209,10 @@ static int validate_cc_data_pair (uint8_t *cc_data_pair) // if EIA-608 data then verify parity. if (cc_type==0 || cc_type==1) { - if (!parity_table[cc_data_pair[2]]) { + if (!get_parity(cc_data_pair[2])) { return AVERROR_INVALIDDATA; } - if (!parity_table[cc_data_pair[1]]) { + if (!get_parity(cc_data_pair[1])) { cc_data_pair[1]=0x7F; } } -- 2.6.4 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel