diff options
author | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2016-04-24 11:47:15 +0100 |
---|---|---|
committer | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2016-04-24 11:47:39 +0100 |
commit | a5a6621616aac55b8284002af4fef35b66e2b2d1 (patch) | |
tree | e162517aeeef766d788a645d362e089221681234 | |
parent | 2e67a99fbc6b99315925de40fc6fa7161576be10 (diff) | |
parent | f4d581cda3897f66c1dda7586b93f86a591dbbef (diff) | |
download | ffmpeg-a5a6621616aac55b8284002af4fef35b66e2b2d1.tar.gz |
Merge commit 'f4d581cda3897f66c1dda7586b93f86a591dbbef'
* commit 'f4d581cda3897f66c1dda7586b93f86a591dbbef':
lavc: Deduplicate zigzag_scan table
Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
-rw-r--r-- | libavcodec/h264_ps.c | 3 | ||||
-rw-r--r-- | libavcodec/h264_slice.c | 4 | ||||
-rw-r--r-- | libavcodec/h264data.h | 7 | ||||
-rw-r--r-- | libavcodec/mathops.h | 1 | ||||
-rw-r--r-- | libavcodec/mathtables.c | 7 | ||||
-rw-r--r-- | libavcodec/svq3.c | 6 | ||||
-rw-r--r-- | libavcodec/tscc2.c | 3 | ||||
-rw-r--r-- | libavcodec/tscc2data.h | 7 | ||||
-rw-r--r-- | libavcodec/vp8.c | 11 | ||||
-rw-r--r-- | libavcodec/vp8data.h | 8 |
10 files changed, 24 insertions, 33 deletions
diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c index 0bca9c1a80..515eb8a760 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 c6d5f37899..af52cf6892 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 95ea385deb..a6c69e55d3 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 4988f1d3df..5168dc2ce0 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 7b5efb88a6..81eabc7a65 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 ad3bd5a8fe..5e5bcb3e86 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 9bb7ab3ba3..69a6facaf2 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 7806267545..7cd6f5216e 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 64037fc089..e60705a187 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 f9dbf56feb..5e6dea7617 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, |