--- libavcodec/4xm.c | 133 ++++++++++++++++++++++++---------------------- libavdevice/timefilter.c | 2 +- 2 files changed, 71 insertions(+), 64 deletions(-)
diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c index 42d6491..ba28ec4 100644 --- a/libavcodec/4xm.c +++ b/libavcodec/4xm.c @@ -30,8 +30,8 @@ #include "get_bits.h" #include "bytestream.h" -//#undef NDEBUG -//#include <assert.h> +// #undef NDEBUG +// #include <assert.h> #define BLOCK_TYPE_VLC_BITS 5 #define ACDC_VLC_BITS 9 @@ -40,68 +40,68 @@ static const uint8_t block_type_tab[2][4][8][2] = { { - { //{ 8, 4, 2 }x{ 8, 4, 2} + { // { 8, 4, 2 } x { 8, 4, 2} { 0, 1 }, { 2, 2 }, { 6, 3 }, { 14, 4 }, { 30, 5 }, { 31, 5 }, { 0, 0 } - }, { //{ 8, 4 }x1 + }, { // { 8, 4 } x 1 { 0, 1 }, { 0, 0 }, { 2, 2 }, { 6, 3 }, { 14, 4 }, { 15, 4 }, { 0, 0 } - }, { //1x{ 8, 4 } + }, { // 1 x { 8, 4 } { 0, 1 }, { 2, 2 }, { 0, 0 }, { 6, 3 }, { 14, 4 }, { 15, 4 }, { 0, 0 } - }, { //1x2, 2x1 + }, { // 1 x 2, 2 x 1 { 0, 1 }, { 0, 0 }, { 0, 0 }, { 2, 2 }, { 6, 3 }, { 14, 4 }, { 15, 4 } } }, { - { //{ 8, 4, 2 }x{ 8, 4, 2} + { // { 8, 4, 2 } x { 8, 4, 2} { 1, 2 }, { 4, 3 }, { 5, 3 }, { 0, 2 }, { 6, 3 }, { 7, 3 }, { 0, 0 } - }, {//{ 8, 4 }x1 + }, {// { 8, 4 } x 1 { 1, 2 }, { 0, 0 }, { 2, 2 }, { 0, 2 }, { 6, 3 }, { 7, 3 }, { 0, 0 } - }, {//1x{ 8, 4 } + }, {// 1 x { 8, 4 } { 1, 2 }, { 2, 2 }, { 0, 0 }, { 0, 2 }, { 6, 3 }, { 7, 3 }, { 0, 0 } - }, {//1x2, 2x1 + }, {// 1 x 2, 2 x 1 { 1, 2 }, { 0, 0 }, { 0, 0 }, { 0, 2 }, { 2, 2 }, { 6, 3 }, { 7, 3 } } } }; static const uint8_t size2index[4][4] = { - {-1, 3, 1, 1 }, + { -1, 3, 1, 1 }, { 3, 0, 0, 0 }, { 2, 0, 0, 0 }, { 2, 0, 0, 0 }, }; static const int8_t mv[256][2] = { -{ 0, 0 }, { 0,-1 }, {-1, 0 }, { 1, 0 }, { 0, 1 }, {-1,-1 }, { 1,-1 }, {-1, 1 }, -{ 1, 1 }, { 0,-2 }, {-2, 0 }, { 2, 0 }, { 0, 2 }, {-1,-2 }, { 1,-2 }, {-2,-1 }, -{ 2,-1 }, {-2, 1 }, { 2, 1 }, {-1, 2 }, { 1, 2 }, {-2,-2 }, { 2,-2 }, {-2, 2 }, -{ 2, 2 }, { 0,-3 }, {-3, 0 }, { 3, 0 }, { 0, 3 }, {-1,-3 }, { 1,-3 }, {-3,-1 }, -{ 3,-1 }, {-3, 1 }, { 3, 1 }, {-1, 3 }, { 1, 3 }, {-2,-3 }, { 2,-3 }, {-3,-2 }, -{ 3,-2 }, {-3, 2 }, { 3, 2 }, {-2, 3 }, { 2, 3 }, { 0,-4 }, {-4, 0 }, { 4, 0 }, -{ 0, 4 }, {-1,-4 }, { 1,-4 }, {-4,-1 }, { 4,-1 }, { 4, 1 }, {-1, 4 }, { 1, 4 }, -{-3,-3 }, {-3, 3 }, { 3, 3 }, {-2,-4 }, {-4,-2 }, { 4,-2 }, {-4, 2 }, {-2, 4 }, -{ 2, 4 }, {-3,-4 }, { 3,-4 }, { 4,-3 }, {-5, 0 }, {-4, 3 }, {-3, 4 }, { 3, 4 }, -{-1,-5 }, {-5,-1 }, {-5, 1 }, {-1, 5 }, {-2,-5 }, { 2,-5 }, { 5,-2 }, { 5, 2 }, -{-4,-4 }, {-4, 4 }, {-3,-5 }, {-5,-3 }, {-5, 3 }, { 3, 5 }, {-6, 0 }, { 0, 6 }, -{-6,-1 }, {-6, 1 }, { 1, 6 }, { 2,-6 }, {-6, 2 }, { 2, 6 }, {-5,-4 }, { 5, 4 }, -{ 4, 5 }, {-6,-3 }, { 6, 3 }, {-7, 0 }, {-1,-7 }, { 5,-5 }, {-7, 1 }, {-1, 7 }, -{ 4,-6 }, { 6, 4 }, {-2,-7 }, {-7, 2 }, {-3,-7 }, { 7,-3 }, { 3, 7 }, { 6,-5 }, -{ 0,-8 }, {-1,-8 }, {-7,-4 }, {-8, 1 }, { 4, 7 }, { 2,-8 }, {-2, 8 }, { 6, 6 }, -{-8, 3 }, { 5,-7 }, {-5, 7 }, { 8,-4 }, { 0,-9 }, {-9,-1 }, { 1, 9 }, { 7,-6 }, -{-7, 6 }, {-5,-8 }, {-5, 8 }, {-9, 3 }, { 9,-4 }, { 7,-7 }, { 8,-6 }, { 6, 8 }, -{ 10, 1 }, {-10, 2 }, { 9,-5 }, { 10,-3 }, {-8,-7 }, {-10,-4 }, { 6,-9 }, {-11, 0 }, -{ 11, 1 }, {-11,-2 }, {-2, 11 }, { 7,-9 }, {-7, 9 }, { 10, 6 }, {-4, 11 }, { 8,-9 }, -{ 8, 9 }, { 5, 11 }, { 7,-10 }, { 12,-3 }, { 11, 6 }, {-9,-9 }, { 8, 10 }, { 5, 12 }, -{-11, 7 }, { 13, 2 }, { 6,-12 }, { 10, 9 }, {-11, 8 }, {-7, 12 }, { 0, 14 }, { 14,-2 }, -{-9, 11 }, {-6, 13 }, {-14,-4 }, {-5,-14 }, { 5, 14 }, {-15,-1 }, {-14,-6 }, { 3,-15 }, -{ 11,-11 }, {-7, 14 }, {-5, 15 }, { 8,-14 }, { 15, 6 }, { 3, 16 }, { 7,-15 }, {-16, 5 }, -{ 0, 17 }, {-16,-6 }, {-10, 14 }, {-16, 7 }, { 12, 13 }, {-16, 8 }, {-17, 6 }, {-18, 3 }, -{-7, 17 }, { 15, 11 }, { 16, 10 }, { 2,-19 }, { 3,-19 }, {-11,-16 }, {-18, 8 }, {-19,-6 }, -{ 2,-20 }, {-17,-11 }, {-10,-18 }, { 8, 19 }, {-21,-1 }, {-20, 7 }, {-4, 21 }, { 21, 5 }, -{ 15, 16 }, { 2,-22 }, {-10,-20 }, {-22, 5 }, { 20,-11 }, {-7,-22 }, {-12, 20 }, { 23,-5 }, -{ 13,-20 }, { 24,-2 }, {-15, 19 }, {-11, 22 }, { 16, 19 }, { 23,-10 }, {-18,-18 }, {-9,-24 }, -{ 24,-10 }, {-3, 26 }, {-23, 13 }, {-18,-20 }, { 17, 21 }, {-4, 27 }, { 27, 6 }, { 1,-28 }, -{-11, 26 }, {-17,-23 }, { 7, 28 }, { 11,-27 }, { 29, 5 }, {-23,-19 }, {-28,-11 }, {-21, 22 }, -{-30, 7 }, {-17, 26 }, {-27, 16 }, { 13, 29 }, { 19,-26 }, { 10,-31 }, {-14,-30 }, { 20,-27 }, -{-29, 18 }, {-16,-31 }, {-28,-22 }, { 21,-30 }, {-25, 28 }, { 26,-29 }, { 25,-32 }, {-32,-32 } +{ 0, 0 }, { 0, -1 }, { -1, 0 }, { 1, 0 }, { 0, 1 }, { -1, -1 }, { 1, -1 }, { -1, 1 }, +{ 1, 1 }, { 0, -2 }, { -2, 0 }, { 2, 0 }, { 0, 2 }, { -1, -2 }, { 1, -2 }, { -2, -1 }, +{ 2, -1 }, { -2, 1 }, { 2, 1 }, { -1, 2 }, { 1, 2 }, { -2, -2 }, { 2, -2 }, { -2, 2 }, +{ 2, 2 }, { 0, -3 }, { -3, 0 }, { 3, 0 }, { 0, 3 }, { -1, -3 }, { 1, -3 }, { -3, -1 }, +{ 3, -1 }, { -3, 1 }, { 3, 1 }, { -1, 3 }, { 1, 3 }, { -2, -3 }, { 2, -3 }, { -3, -2 }, +{ 3, -2 }, { -3, 2 }, { 3, 2 }, { -2, 3 }, { 2, 3 }, { 0, -4 }, { -4, 0 }, { 4, 0 }, +{ 0, 4 }, { -1, -4 }, { 1, -4 }, { -4, -1 }, { 4, -1 }, { 4, 1 }, { -1, 4 }, { 1, 4 }, +{ -3, -3 }, { -3, 3 }, { 3, 3 }, { -2, -4 }, { -4, -2 }, { 4, -2 }, { -4, 2 }, { -2, 4 }, +{ 2, 4 }, { -3, -4 }, { 3, -4 }, { 4, -3 }, { -5, 0 }, { -4, 3 }, { -3, 4 }, { 3, 4 }, +{ -1, -5 }, { -5, -1 }, { -5, 1 }, { -1, 5 }, { -2, -5 }, { 2, -5 }, { 5, -2 }, { 5, 2 }, +{ -4, -4 }, { -4, 4 }, { -3, -5 }, { -5, -3 }, { -5, 3 }, { 3, 5 }, { -6, 0 }, { 0, 6 }, +{ -6, -1 }, { -6, 1 }, { 1, 6 }, { 2, -6 }, { -6, 2 }, { 2, 6 }, { -5, -4 }, { 5, 4 }, +{ 4, 5 }, { -6, -3 }, { 6, 3 }, { -7, 0 }, { -1, -7 }, { 5, -5 }, { -7, 1 }, { -1, 7 }, +{ 4, -6 }, { 6, 4 }, { -2, -7 }, { -7, 2 }, { -3, -7 }, { 7, -3 }, { 3, 7 }, { 6, -5 }, +{ 0, -8 }, { -1, -8 }, { -7, -4 }, { -8, 1 }, { 4, 7 }, { 2, -8 }, { -2, 8 }, { 6, 6 }, +{ -8, 3 }, { 5, -7 }, { -5, 7 }, { 8, -4 }, { 0, -9 }, { -9, -1 }, { 1, 9 }, { 7, -6 }, +{ -7, 6 }, { -5, -8 }, { -5, 8 }, { -9, 3 }, { 9, -4 }, { 7, -7 }, { 8, -6 }, { 6, 8 }, +{ 10, 1 }, { -10, 2 }, { 9, -5 }, { 10, -3 }, { -8, -7 }, { -10, -4 }, { 6, -9 }, { -11, 0 }, +{ 11, 1 }, { -11, -2 }, { -2, 11 }, { 7, -9 }, { -7, 9 }, { 10, 6 }, { -4, 11 }, { 8, -9 }, +{ 8, 9 }, { 5, 11 }, { 7, -10 }, { 12, -3 }, { 11, 6 }, { -9, -9 }, { 8, 10 }, { 5, 12 }, +{ -11, 7 }, { 13, 2 }, { 6, -12 }, { 10, 9 }, { -11, 8 }, { -7, 12 }, { 0, 14 }, { 14, -2 }, +{ -9, 11 }, { -6, 13 }, { -14, -4 }, { -5, -14 }, { 5, 14 }, { -15, -1 }, { -14, -6 }, { 3, -15 }, +{ 11, -11 }, { -7, 14 }, { -5, 15 }, { 8, -14 }, { 15, 6 }, { 3, 16 }, { 7, -15 }, { -16, 5 }, +{ 0, 17 }, { -16, -6 }, { -10, 14 }, { -16, 7 }, { 12, 13 }, { -16, 8 }, { -17, 6 }, { -18, 3 }, +{ -7, 17 }, { 15, 11 }, { 16, 10 }, { 2, -19 }, { 3, -19 }, { -11, -16 }, { -18, 8 }, { -19, -6 }, +{ 2, -20 }, { -17, -11 }, { -10, -18 }, { 8, 19 }, { -21, -1 }, { -20, 7 }, { -4, 21 }, { 21, 5 }, +{ 15, 16 }, { 2, -22 }, { -10, -20 }, { -22, 5 }, { 20, -11 }, { -7, -22 }, { -12, 20 }, { 23, -5 }, +{ 13, -20 }, { 24, -2 }, { -15, 19 }, { -11, 22 }, { 16, 19 }, { 23, -10 }, { -18, -18 }, { -9, -24 }, +{ 24, -10 }, { -3, 26 }, { -23, 13 }, { -18, -20 }, { 17, 21 }, { -4, 27 }, { 27, 6 }, { 1, -28 }, +{ -11, 26 }, { -17, -23 }, { 7, 28 }, { 11, -27 }, { 29, 5 }, { -23, -19 }, { -28, -11 }, { -21, 22 }, +{ -30, 7 }, { -17, 26 }, { -27, 16 }, { 13, 29 }, { 19, -26 }, { 10, -31 }, { -14, -30 }, { 20, -27 }, +{ -29, 18 }, { -16, -31 }, { -28, -22 }, { 21, -30 }, { -25, 28 }, { 26, -29 }, { 25, -32 }, { -32, -32 } }; // this is simply the scaled down elementwise product of the standard jpeg quantizer table and the AAN premul table @@ -113,7 +113,7 @@ static const uint8_t dequant_table[64] = { 18, 31, 48, 66, 68, 86, 56, 21, 19, 38, 56, 59, 64, 64, 48, 20, 27, 48, 55, 55, 56, 51, 35, 15, - 20, 35, 34, 32, 31, 22, 15, 8, + 20, 35, 34, 32, 31, 22, 15, 8, }; static VLC block_type_vlc[2][4]; @@ -130,7 +130,7 @@ typedef struct FourXContext { AVCodecContext *avctx; DSPContext dsp; AVFrame current_picture, last_picture; - GetBitContext pre_gb; ///< ac/dc prefix + GetBitContext pre_gb; /// < ac/dc prefix GetBitContext gb; GetByteContext g; GetByteContext g2; @@ -145,8 +145,8 @@ typedef struct FourXContext { } FourXContext; -#define FIX_1_082392200 70936 -#define FIX_1_414213562 92682 +#define FIX_1_082392200 70936 +#define FIX_1_414213562 92682 #define FIX_1_847759065 121095 #define FIX_2_613125930 171254 @@ -177,10 +177,10 @@ static void idct(DCTELEM block[64]) z11 = block[8 * 1 + i] + block[8 * 7 + i]; z12 = block[8 * 1 + i] - block[8 * 7 + i]; - tmp7 = z11 + z13; + tmp7 = z11 + z13; tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); - z5 = MULTIPLY(z10 + z12, FIX_1_847759065); + z5 = MULTIPLY(z10 + z12, FIX_1_847759065); tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; @@ -267,9 +267,9 @@ static void init_mv(FourXContext *f) #define LE_CENTRIC_MUL(dst, src, scale, dc) \ { \ unsigned tmpval = AV_RN32(src); \ - tmpval = (tmpval << 16) | (tmpval >> 16); \ + tmpval = (tmpval << 16) | (tmpval >> 16); \ tmpval = tmpval * (scale) + (dc); \ - tmpval = (tmpval << 16) | (tmpval >> 16); \ + tmpval = (tmpval << 16) | (tmpval >> 16); \ AV_WN32A(dst, tmpval); \ } #else @@ -280,12 +280,13 @@ static void init_mv(FourXContext *f) } #endif -static inline void mcdc(uint16_t *dst, uint16_t *src, int log2w, int h, int stride, int scale, unsigned dc) +static inline void mcdc(uint16_t *dst, uint16_t *src, int log2w, + int h, int stride, int scale, unsigned dc) { int i; dc *= 0x10001; - switch(log2w) { + switch (log2w) { case 0: for (i = 0; i < h; i++) { dst[0] = scale * src[0] + dc; @@ -313,7 +314,7 @@ static inline void mcdc(uint16_t *dst, uint16_t *src, int log2w, int h, int stri break; case 3: for (i = 0; i < h; i++) { - LE_CENTRIC_MUL(dst, src, scale, dc); + LE_CENTRIC_MUL(dst, src, scale, dc); LE_CENTRIC_MUL(dst + 2, src + 2, scale, dc); LE_CENTRIC_MUL(dst + 4, src + 4, scale, dc); LE_CENTRIC_MUL(dst + 6, src + 6, scale, dc); @@ -326,7 +327,8 @@ static inline void mcdc(uint16_t *dst, uint16_t *src, int log2w, int h, int stri } } -static void decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src, int log2w, int log2h, int stride) +static void decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src, + int log2w, int log2h, int stride) { const int index = size2index[log2h][log2w]; const int h = 1 << log2h; @@ -346,11 +348,13 @@ static void decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src, int lo } else if (code == 1) { log2h--; decode_p_block(f, dst, src, log2w, log2h, stride); - decode_p_block(f, dst + (stride << log2h), src + (stride << log2h), log2w, log2h, stride); + decode_p_block(f, dst + (stride << log2h), + src + (stride << log2h), log2w, log2h, stride); } else if (code == 2) { log2w--; decode_p_block(f, dst , src, log2w, log2h, stride); - decode_p_block(f, dst + (1 << log2w), src + (1 << log2w), log2w, log2h, stride); + decode_p_block(f, dst + (1 << log2w), + src + (1 << log2w), log2w, log2h, stride); } else if (code == 3 && f->version < 2) { mcdc(dst, src, log2w, h, stride, 1, 0); } else if (code == 4) { @@ -399,7 +403,8 @@ static int decode_p_frame(FourXContext *f, const uint8_t *buf, int length) || bitstream_size > (1 << 26) || bytestream_size > (1 << 26) || wordstream_size > (1 << 26)) { - av_log(f->avctx, AV_LOG_ERROR, "lengths %d %d %d %d\n", bitstream_size, bytestream_size, wordstream_size, + av_log(f->avctx, AV_LOG_ERROR, "lengths %d %d %d %d\n", + bitstream_size, bytestream_size, wordstream_size, bitstream_size + bytestream_size + wordstream_size - length); return -1; } @@ -606,7 +611,7 @@ static const uint8_t *read_huffman_tables(FourXContext *f, const uint8_t * const bits += flag[node] << len; len++; if (len > 31) - av_log(f->avctx, AV_LOG_ERROR, "vlc length overflow\n"); //can this happen at all ? + av_log(f->avctx, AV_LOG_ERROR, "vlc length overflow\n"); // can this happen at all ? } bits_tab[j] = bits; @@ -641,7 +646,7 @@ static int decode_i2_frame(FourXContext *f, const uint8_t *buf, int length) for (x = 0; x < width; x += 16) { unsigned int color[4], bits; memset(color, 0, sizeof(color)); -//warning following is purely guessed ... +// warning following is purely guessed ... color[0] = bytestream_get_le16(&buf); color[1] = bytestream_get_le16(&buf); @@ -690,7 +695,8 @@ static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length) if (prestream_size + bitstream_size + 12 != length || bitstream_size > (1 << 26) || prestream_size > (1 << 26)) { - av_log(f->avctx, AV_LOG_ERROR, "size mismatch %d %d %d\n", prestream_size, bitstream_size, length); + av_log(f->avctx, AV_LOG_ERROR, "size mismatch %d %d %d\n", + prestream_size, bitstream_size, length); return -1; } @@ -765,8 +771,9 @@ static int decode_frame(AVCodecContext *avctx, } cfrm = &f->cfrm[i]; - cfrm->data = av_fast_realloc(cfrm->data, &cfrm->allocated_size, cfrm->size + data_size + FF_INPUT_BUFFER_PADDING_SIZE); - if (!cfrm->data) { //explicit check needed as memcpy below might not catch a NULL + cfrm->data = av_fast_realloc(cfrm->data, &cfrm->allocated_size, + cfrm->size + data_size + FF_INPUT_BUFFER_PADDING_SIZE); + if (!cfrm->data) { // explicit check needed as memcpy below might not catch a NULL av_log(f->avctx, AV_LOG_ERROR, "realloc falure"); return -1; } diff --git a/libavdevice/timefilter.c b/libavdevice/timefilter.c index f23190a..88d7e7b 100644 --- a/libavdevice/timefilter.c +++ b/libavdevice/timefilter.c @@ -140,7 +140,7 @@ int main(void) } ff_timefilter_destroy(tf); #else - printf("[%f %f %9f]", bestpar0, bestpar1, best_error); + printf(" [%f %f %9f]", bestpar0, bestpar1, best_error); #endif } printf("\n"); -- 1.7.1 _______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel