lavc: Deduplicate zigzag_scan table
This commit is contained in:
		
							parent
							
								
									02cd8bb9cb
								
							
						
					
					
						commit
						f4d581cda3
					
				@ -29,9 +29,9 @@
 | 
			
		||||
 | 
			
		||||
#include "libavutil/imgutils.h"
 | 
			
		||||
#include "internal.h"
 | 
			
		||||
#include "mathops.h"
 | 
			
		||||
#include "avcodec.h"
 | 
			
		||||
#include "h264.h"
 | 
			
		||||
#include "h264data.h" //FIXME FIXME FIXME (just for zigzag_scan)
 | 
			
		||||
#include "golomb.h"
 | 
			
		||||
 | 
			
		||||
#define MAX_LOG2_MAX_FRAME_NUM    (12 + 4)
 | 
			
		||||
@ -266,7 +266,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
 | 
			
		||||
 | 
			
		||||
@ -790,7 +790,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
 | 
			
		||||
    }
 | 
			
		||||
@ -803,7 +803,7 @@ static void init_scan_tables(H264Context *h)
 | 
			
		||||
#undef TRANSPOSE
 | 
			
		||||
    }
 | 
			
		||||
    if (h->sps.transform_bypass) { // FIXME same ugly
 | 
			
		||||
        h->zigzag_scan_q0          = zigzag_scan;
 | 
			
		||||
        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;
 | 
			
		||||
 | 
			
		||||
@ -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] = {
 | 
			
		||||
    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,
 | 
			
		||||
 | 
			
		||||
@ -34,6 +34,7 @@ extern const uint8_t  ff_reverse[256];
 | 
			
		||||
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];
 | 
			
		||||
 | 
			
		||||
#if   ARCH_ARM
 | 
			
		||||
#   include "arm/mathops.h"
 | 
			
		||||
 | 
			
		||||
@ -122,3 +122,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] = {
 | 
			
		||||
    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,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -53,6 +53,7 @@
 | 
			
		||||
#include "h264_mvpred.h"
 | 
			
		||||
#include "golomb.h"
 | 
			
		||||
#include "hpeldsp.h"
 | 
			
		||||
#include "mathops.h"
 | 
			
		||||
#include "rectangle.h"
 | 
			
		||||
#include "tpeldsp.h"
 | 
			
		||||
 | 
			
		||||
@ -239,8 +240,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, limit;
 | 
			
		||||
    unsigned vlc;
 | 
			
		||||
 | 
			
		||||
@ -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);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -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] = {
 | 
			
		||||
 | 
			
		||||
@ -28,6 +28,7 @@
 | 
			
		||||
 | 
			
		||||
#include "avcodec.h"
 | 
			
		||||
#include "internal.h"
 | 
			
		||||
#include "mathops.h"
 | 
			
		||||
#include "rectangle.h"
 | 
			
		||||
#include "thread.h"
 | 
			
		||||
#include "vp8.h"
 | 
			
		||||
@ -527,7 +528,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)
 | 
			
		||||
@ -599,7 +600,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)
 | 
			
		||||
@ -1317,7 +1318,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
 | 
			
		||||
 | 
			
		||||
@ -1364,7 +1365,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) {
 | 
			
		||||
@ -2679,7 +2680,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);
 | 
			
		||||
 | 
			
		||||
@ -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,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user