Merge commit 'f4d581cda3897f66c1dda7586b93f86a591dbbef'

* commit 'f4d581cda3897f66c1dda7586b93f86a591dbbef':
  lavc: Deduplicate zigzag_scan table

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
This commit is contained in:
Derek Buitenhuis 2016-04-24 11:47:15 +01:00
commit a5a6621616
10 changed files with 24 additions and 33 deletions

View File

@ -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

View File

@ -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 ));

View File

@ -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,

View File

@ -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"

View File

@ -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,
};

View File

@ -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;

View File

@ -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);
}

View File

@ -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] = {

View File

@ -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);

View File

@ -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,