ffmpeg | branch: master | Derek Buitenhuis <derek.buitenh...@gmail.com> | Sun Apr 24 11:47:15 2016 +0100| [a5a6621616aac55b8284002af4fef35b66e2b2d1] | committer: Derek Buitenhuis
Merge commit 'f4d581cda3897f66c1dda7586b93f86a591dbbef' * commit 'f4d581cda3897f66c1dda7586b93f86a591dbbef': lavc: Deduplicate zigzag_scan table Merged-by: Derek Buitenhuis <derek.buitenh...@gmail.com> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a5a6621616aac55b8284002af4fef35b66e2b2d1 --- libavcodec/h264_ps.c | 3 ++- libavcodec/h264_slice.c | 4 ++-- libavcodec/h264data.h | 7 ------- libavcodec/mathops.h | 1 + libavcodec/mathtables.c | 7 +++++++ libavcodec/svq3.c | 6 ++++-- libavcodec/tscc2.c | 3 ++- libavcodec/tscc2data.h | 7 ------- libavcodec/vp8.c | 11 ++++++----- libavcodec/vp8data.h | 8 -------- 10 files changed, 24 insertions(+), 33 deletions(-) diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c index 0bca9c1..515eb8a 100644 --- a/libavcodec/h264_ps.c +++ b/libavcodec/h264_ps.c @@ -29,6 +29,7 @@ #include "libavutil/imgutils.h" #include "internal.h" +#include "mathops.h" #include "avcodec.h" #include "h264.h" #include "h264data.h" @@ -272,7 +273,7 @@ static void decode_scaling_list(H264Context *h, uint8_t *factors, int size, const uint8_t *fallback_list) { int i, last = 8, next = 8; - const uint8_t *scan = size == 16 ? zigzag_scan : ff_zigzag_direct; + const uint8_t *scan = size == 16 ? ff_zigzag_scan : ff_zigzag_direct; if (!get_bits1(&h->gb)) /* matrix not written, we use the predicted one */ memcpy(factors, fallback_list, size * sizeof(uint8_t)); else diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index c6d5f37..af52cf6 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -834,7 +834,7 @@ static void init_scan_tables(H264Context *h) int i; for (i = 0; i < 16; i++) { #define TRANSPOSE(x) ((x) >> 2) | (((x) << 2) & 0xF) - h->zigzag_scan[i] = TRANSPOSE(zigzag_scan[i]); + h->zigzag_scan[i] = TRANSPOSE(ff_zigzag_scan[i]); h->field_scan[i] = TRANSPOSE(field_scan[i]); #undef TRANSPOSE } @@ -847,7 +847,7 @@ static void init_scan_tables(H264Context *h) #undef TRANSPOSE } if (h->sps.transform_bypass) { // FIXME same ugly - memcpy(h->zigzag_scan_q0 , zigzag_scan , sizeof(h->zigzag_scan_q0 )); + memcpy(h->zigzag_scan_q0 , ff_zigzag_scan , sizeof(h->zigzag_scan_q0 )); memcpy(h->zigzag_scan8x8_q0 , ff_zigzag_direct , sizeof(h->zigzag_scan8x8_q0 )); memcpy(h->zigzag_scan8x8_cavlc_q0 , zigzag_scan8x8_cavlc , sizeof(h->zigzag_scan8x8_cavlc_q0)); memcpy(h->field_scan_q0 , field_scan , sizeof(h->field_scan_q0 )); diff --git a/libavcodec/h264data.h b/libavcodec/h264data.h index 95ea385..a6c69e5 100644 --- a/libavcodec/h264data.h +++ b/libavcodec/h264data.h @@ -51,13 +51,6 @@ static const uint8_t golomb_to_inter_cbp[48] = { 17, 18, 20, 24, 19, 21, 26, 28, 23, 27, 29, 30, 22, 25, 38, 41 }; -static const uint8_t zigzag_scan[16+1] = { - 0 + 0 * 4, 1 + 0 * 4, 0 + 1 * 4, 0 + 2 * 4, - 1 + 1 * 4, 2 + 0 * 4, 3 + 0 * 4, 2 + 1 * 4, - 1 + 2 * 4, 0 + 3 * 4, 1 + 3 * 4, 2 + 2 * 4, - 3 + 1 * 4, 3 + 2 * 4, 2 + 3 * 4, 3 + 3 * 4, -}; - static const uint8_t chroma_dc_scan[4] = { (0 + 0 * 2) * 16, (1 + 0 * 2) * 16, (0 + 1 * 2) * 16, (1 + 1 * 2) * 16, diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h index 4988f1d..5168dc2 100644 --- a/libavcodec/mathops.h +++ b/libavcodec/mathops.h @@ -33,6 +33,7 @@ extern const uint32_t ff_inverse[257]; extern const uint8_t ff_sqrt_tab[256]; extern const uint8_t ff_crop_tab[256 + 2 * MAX_NEG_CROP]; extern const uint8_t ff_zigzag_direct[64]; +extern const uint8_t ff_zigzag_scan[16+1]; #if ARCH_ARM # include "arm/mathops.h" diff --git a/libavcodec/mathtables.c b/libavcodec/mathtables.c index 7b5efb8..81eabc7 100644 --- a/libavcodec/mathtables.c +++ b/libavcodec/mathtables.c @@ -105,3 +105,10 @@ const uint8_t ff_zigzag_direct[64] = { 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63 }; + +const uint8_t ff_zigzag_scan[16+1] = { + 0 + 0 * 4, 1 + 0 * 4, 0 + 1 * 4, 0 + 2 * 4, + 1 + 1 * 4, 2 + 0 * 4, 3 + 0 * 4, 2 + 1 * 4, + 1 + 2 * 4, 0 + 3 * 4, 1 + 3 * 4, 2 + 2 * 4, + 3 + 1 * 4, 3 + 2 * 4, 2 + 3 * 4, 3 + 3 * 4, +}; diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c index ad3bd5a..5e5bcb3 100644 --- a/libavcodec/svq3.c +++ b/libavcodec/svq3.c @@ -53,6 +53,7 @@ #include "h264_mvpred.h" #include "golomb.h" #include "hpeldsp.h" +#include "mathops.h" #include "rectangle.h" #include "tpeldsp.h" #include "vdpau_internal.h" @@ -244,8 +245,9 @@ void ff_svq3_add_idct_c(uint8_t *dst, int16_t *block, static inline int svq3_decode_block(GetBitContext *gb, int16_t *block, int index, const int type) { - static const uint8_t *const scan_patterns[4] = - { luma_dc_zigzag_scan, zigzag_scan, svq3_scan, chroma_dc_scan }; + static const uint8_t *const scan_patterns[4] = { + luma_dc_zigzag_scan, ff_zigzag_scan, svq3_scan, chroma_dc_scan + }; int run, level, sign, limit; unsigned vlc; diff --git a/libavcodec/tscc2.c b/libavcodec/tscc2.c index 9bb7ab3..69a6fac 100644 --- a/libavcodec/tscc2.c +++ b/libavcodec/tscc2.c @@ -31,6 +31,7 @@ #include "get_bits.h" #include "bytestream.h" #include "internal.h" +#include "mathops.h" #include "tscc2data.h" typedef struct TSCC2Context { @@ -179,7 +180,7 @@ static int tscc2_decode_mb(TSCC2Context *c, int *q, int vlc_set, if (bpos >= 16) return AVERROR_INVALIDDATA; val = sign_extend(ac >> 4, 8); - c->block[tscc2_zigzag[bpos++]] = val; + c->block[ff_zigzag_scan[bpos++]] = val; } tscc2_idct4_put(c->block, q, dst + k * 4, stride); } diff --git a/libavcodec/tscc2data.h b/libavcodec/tscc2data.h index 7806267..7cd6f52 100644 --- a/libavcodec/tscc2data.h +++ b/libavcodec/tscc2data.h @@ -24,13 +24,6 @@ #include <stdint.h> -static const uint8_t tscc2_zigzag[16] = { - 0, 1, 4, 8, - 5, 2, 3, 6, - 9, 12, 13, 10, - 7, 11, 14, 15 -}; - #define NUM_VLC_SETS 13 static const uint16_t tscc2_quants[NUM_VLC_SETS][3] = { diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index 64037fc..e60705a 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -28,6 +28,7 @@ #include "avcodec.h" #include "internal.h" +#include "mathops.h" #include "rectangle.h" #include "thread.h" #include "vp8.h" @@ -541,7 +542,7 @@ static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_si sizeof(vp7_mv_default_prob[i])); memset(&s->segmentation, 0, sizeof(s->segmentation)); memset(&s->lf_delta, 0, sizeof(s->lf_delta)); - memcpy(s->prob[0].scan, zigzag_scan, sizeof(s->prob[0].scan)); + memcpy(s->prob[0].scan, ff_zigzag_scan, sizeof(s->prob[0].scan)); } if (s->keyframe || s->profile > 0) @@ -613,7 +614,7 @@ static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_si /* G. DCT coefficient ordering specification */ if (vp8_rac_get(c)) for (i = 1; i < 16; i++) - s->prob[0].scan[i] = zigzag_scan[vp8_rac_get_uint(c, 4)]; + s->prob[0].scan[i] = ff_zigzag_scan[vp8_rac_get_uint(c, 4)]; /* H. Loop filter levels */ if (s->profile > 0) @@ -1350,7 +1351,7 @@ static int vp8_decode_block_coeffs_internal(VP56RangeCoder *r, int16_t qmul[2]) { return decode_block_coeffs_internal(r, block, probs, i, - token_prob, qmul, zigzag_scan, IS_VP8); + token_prob, qmul, ff_zigzag_scan, IS_VP8); } #endif @@ -1398,7 +1399,7 @@ void decode_mb_coeffs(VP8Context *s, VP8ThreadData *td, VP56RangeCoder *c, // decode DC values and do hadamard nnz = decode_block_coeffs(c, td->block_dc, s->prob->token[1], 0, nnz_pred, s->qmat[segment].luma_dc_qmul, - zigzag_scan, is_vp7); + ff_zigzag_scan, is_vp7); l_nnz[8] = t_nnz[8] = !!nnz; if (is_vp7 && mb->mode > MODE_I4x4) { @@ -2746,7 +2747,7 @@ int vp78_decode_init(AVCodecContext *avctx, int is_vp7) } /* does not change for VP8 */ - memcpy(s->prob[0].scan, zigzag_scan, sizeof(s->prob[0].scan)); + memcpy(s->prob[0].scan, ff_zigzag_scan, sizeof(s->prob[0].scan)); if ((ret = vp8_init_frames(s)) < 0) { ff_vp8_decode_free(avctx); diff --git a/libavcodec/vp8data.h b/libavcodec/vp8data.h index f9dbf56..5e6dea7 100644 --- a/libavcodec/vp8data.h +++ b/libavcodec/vp8data.h @@ -708,14 +708,6 @@ static const uint8_t vp8_token_update_probs[4][8][3][NUM_DCT_TOKENS - 1] = { }, }; -// fixme: copied from h264data.h -static const uint8_t zigzag_scan[16]={ - 0 + 0 * 4, 1 + 0 * 4, 0 + 1 * 4, 0 + 2 * 4, - 1 + 1 * 4, 2 + 0 * 4, 3 + 0 * 4, 2 + 1 * 4, - 1 + 2 * 4, 0 + 3 * 4, 1 + 3 * 4, 2 + 2 * 4, - 3 + 1 * 4, 3 + 2 * 4, 2 + 3 * 4, 3 + 3 * 4, -}; - static const uint8_t vp8_dc_qlookup[VP8_MAX_QUANT + 1] = { 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 17, 18, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 25, 25, 26, 27, 28, ====================================================================== diff --cc libavcodec/h264_ps.c index 0bca9c1,34a2954..515eb8a --- a/libavcodec/h264_ps.c +++ b/libavcodec/h264_ps.c @@@ -29,9 -29,9 +29,10 @@@ #include "libavutil/imgutils.h" #include "internal.h" + #include "mathops.h" #include "avcodec.h" #include "h264.h" +#include "h264data.h" #include "golomb.h" #define MAX_LOG2_MAX_FRAME_NUM (12 + 4) diff --cc libavcodec/h264_slice.c index c6d5f37,b44aa3e..af52cf6 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@@ -833,8 -789,8 +833,8 @@@ static void init_scan_tables(H264Contex { int i; for (i = 0; i < 16; i++) { -#define TRANSPOSE(x) (x >> 2) | ((x << 2) & 0xF) +#define TRANSPOSE(x) ((x) >> 2) | (((x) << 2) & 0xF) - h->zigzag_scan[i] = TRANSPOSE(zigzag_scan[i]); + h->zigzag_scan[i] = TRANSPOSE(ff_zigzag_scan[i]); h->field_scan[i] = TRANSPOSE(field_scan[i]); #undef TRANSPOSE } @@@ -847,19 -803,19 +847,19 @@@ #undef TRANSPOSE } if (h->sps.transform_bypass) { // FIXME same ugly - memcpy(h->zigzag_scan_q0 , zigzag_scan , sizeof(h->zigzag_scan_q0 )); - h->zigzag_scan_q0 = ff_zigzag_scan; - h->zigzag_scan8x8_q0 = ff_zigzag_direct; - h->zigzag_scan8x8_cavlc_q0 = zigzag_scan8x8_cavlc; - h->field_scan_q0 = field_scan; - h->field_scan8x8_q0 = field_scan8x8; - h->field_scan8x8_cavlc_q0 = field_scan8x8_cavlc; ++ memcpy(h->zigzag_scan_q0 , ff_zigzag_scan , sizeof(h->zigzag_scan_q0 )); + memcpy(h->zigzag_scan8x8_q0 , ff_zigzag_direct , sizeof(h->zigzag_scan8x8_q0 )); + memcpy(h->zigzag_scan8x8_cavlc_q0 , zigzag_scan8x8_cavlc , sizeof(h->zigzag_scan8x8_cavlc_q0)); + memcpy(h->field_scan_q0 , field_scan , sizeof(h->field_scan_q0 )); + memcpy(h->field_scan8x8_q0 , field_scan8x8 , sizeof(h->field_scan8x8_q0 )); + memcpy(h->field_scan8x8_cavlc_q0 , field_scan8x8_cavlc , sizeof(h->field_scan8x8_cavlc_q0 )); } else { - h->zigzag_scan_q0 = h->zigzag_scan; - h->zigzag_scan8x8_q0 = h->zigzag_scan8x8; - h->zigzag_scan8x8_cavlc_q0 = h->zigzag_scan8x8_cavlc; - h->field_scan_q0 = h->field_scan; - h->field_scan8x8_q0 = h->field_scan8x8; - h->field_scan8x8_cavlc_q0 = h->field_scan8x8_cavlc; + memcpy(h->zigzag_scan_q0 , h->zigzag_scan , sizeof(h->zigzag_scan_q0 )); + memcpy(h->zigzag_scan8x8_q0 , h->zigzag_scan8x8 , sizeof(h->zigzag_scan8x8_q0 )); + memcpy(h->zigzag_scan8x8_cavlc_q0 , h->zigzag_scan8x8_cavlc , sizeof(h->zigzag_scan8x8_cavlc_q0)); + memcpy(h->field_scan_q0 , h->field_scan , sizeof(h->field_scan_q0 )); + memcpy(h->field_scan8x8_q0 , h->field_scan8x8 , sizeof(h->field_scan8x8_q0 )); + memcpy(h->field_scan8x8_cavlc_q0 , h->field_scan8x8_cavlc , sizeof(h->field_scan8x8_cavlc_q0 )); } } diff --cc libavcodec/mathops.h index 4988f1d,bd85dd7..5168dc2 --- a/libavcodec/mathops.h +++ b/libavcodec/mathops.h @@@ -33,6 -33,8 +33,7 @@@ extern const uint32_t ff_inverse[257] extern const uint8_t ff_sqrt_tab[256]; extern const uint8_t ff_crop_tab[256 + 2 * MAX_NEG_CROP]; extern const uint8_t ff_zigzag_direct[64]; -extern const uint8_t ff_zigzag_scan[16]; ++extern const uint8_t ff_zigzag_scan[16+1]; #if ARCH_ARM # include "arm/mathops.h" diff --cc libavcodec/mathtables.c index 7b5efb8,d198225..81eabc7 --- a/libavcodec/mathtables.c +++ b/libavcodec/mathtables.c @@@ -105,3 -122,10 +105,10 @@@ const uint8_t ff_zigzag_direct[64] = 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63 }; + -const uint8_t ff_zigzag_scan[16] = { ++const uint8_t ff_zigzag_scan[16+1] = { + 0 + 0 * 4, 1 + 0 * 4, 0 + 1 * 4, 0 + 2 * 4, + 1 + 1 * 4, 2 + 0 * 4, 3 + 0 * 4, 2 + 1 * 4, + 1 + 2 * 4, 0 + 3 * 4, 1 + 3 * 4, 2 + 2 * 4, + 3 + 1 * 4, 3 + 2 * 4, 2 + 3 * 4, 3 + 3 * 4, + }; diff --cc libavcodec/svq3.c index ad3bd5a,5208317..5e5bcb3 --- a/libavcodec/svq3.c +++ b/libavcodec/svq3.c @@@ -53,9 -53,9 +53,10 @@@ #include "h264_mvpred.h" #include "golomb.h" #include "hpeldsp.h" + #include "mathops.h" #include "rectangle.h" #include "tpeldsp.h" +#include "vdpau_internal.h" #if CONFIG_ZLIB #include <zlib.h> @@@ -244,10 -240,11 +245,11 @@@ void ff_svq3_add_idct_c(uint8_t *dst, i static inline int svq3_decode_block(GetBitContext *gb, int16_t *block, int index, const int type) { - static const uint8_t *const scan_patterns[4] = - { luma_dc_zigzag_scan, zigzag_scan, svq3_scan, chroma_dc_scan }; + static const uint8_t *const scan_patterns[4] = { + luma_dc_zigzag_scan, ff_zigzag_scan, svq3_scan, chroma_dc_scan + }; - int run, level, limit; + int run, level, sign, limit; unsigned vlc; const int intra = 3 * type >> 2; const uint8_t *const scan = scan_patterns[type]; _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog