diff options
author | Emeric Grange <emeric.grange@gmail.com> | 2012-01-13 15:10:25 +0100 |
---|---|---|
committer | Emeric Grange <emeric.grange@gmail.com> | 2012-06-24 16:57:32 +0200 |
commit | a527f39eb363192aada3381de1372907d38e37a1 (patch) | |
tree | 35716cfc03f43f7d62fb0a2ccbf6536a9810ece8 | |
parent | 2a3aa7ac0fbde5c9a3fe20d0ff29b680107f0660 (diff) |
g3dvl: vp8 software decoder cleanup
Signed-off-by: Emeric Grange <emeric.grange@gmail.com>
-rw-r--r-- | src/gallium/auxiliary/Makefile.sources | 1 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/common/blockd.c | 125 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/common/blockd.h | 38 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/common/entropy.c | 2 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/common/entropymv.h | 2 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/common/filter.c | 61 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/common/mbpitch.c | 120 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/common/onyxc_int.h | 4 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/common/reconintra4x4.c | 6 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/common/subpixel.h | 16 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/common/treecoder.h | 11 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/decoder/dboolhuff.c | 24 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/decoder/dboolhuff.h | 26 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/decoder/decodeframe.c | 42 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/decoder/detokenize.c | 56 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/decoder/onyxd_if.c | 6 |
16 files changed, 242 insertions, 298 deletions
diff --git a/src/gallium/auxiliary/Makefile.sources b/src/gallium/auxiliary/Makefile.sources index d5e0dc7948..a1c7a0a510 100644 --- a/src/gallium/auxiliary/Makefile.sources +++ b/src/gallium/auxiliary/Makefile.sources @@ -164,7 +164,6 @@ C_SOURCES := \ vl/vp8/common/findnearmv.c \ vl/vp8/common/idctllm.c \ vl/vp8/common/invtrans.c \ - vl/vp8/common/mbpitch.c \ vl/vp8/common/modecontext.c \ vl/vp8/common/quant_common.c \ vl/vp8/common/recon.c \ diff --git a/src/gallium/auxiliary/vl/vp8/common/blockd.c b/src/gallium/auxiliary/vl/vp8/common/blockd.c index 218439e2e4..5ff55c8897 100644 --- a/src/gallium/auxiliary/vl/vp8/common/blockd.c +++ b/src/gallium/auxiliary/vl/vp8/common/blockd.c @@ -11,12 +11,125 @@ #include "blockd.h" -const unsigned char vp8_block2left[25] = +typedef enum { - 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 -}; + PRED = 0, + DEST = 1 +} BLOCKSET; -const unsigned char vp8_block2above[25] = +static void setup_block(BLOCKD *b, + int mv_stride, + unsigned char **base, + int stride, + int offset, + BLOCKSET bs) { - 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8 -}; + if (bs == DEST) + { + b->dst_stride = stride; + b->dst = offset; + b->base_dst = base; + } + else + { + b->pre_stride = stride; + b->pre = offset; + b->base_pre = base; + } +} + +static void setup_macroblock(MACROBLOCKD *x, BLOCKSET bs) +{ + int block; + unsigned char **y, **u, **v; + + if (bs == DEST) + { + y = &x->dst.y_buffer; + u = &x->dst.u_buffer; + v = &x->dst.v_buffer; + } + else + { + y = &x->pre.y_buffer; + u = &x->pre.u_buffer; + v = &x->pre.v_buffer; + } + + for (block = 0; block < 16; block++) /* y blocks */ + { + setup_block(&x->block[block], x->dst.y_stride, y, x->dst.y_stride, + (block >> 2) * 4 * x->dst.y_stride + (block & 3) * 4, bs); + } + + for (block = 16; block < 20; block++) /* U and V blocks */ + { + setup_block(&x->block[block], x->dst.uv_stride, u, x->dst.uv_stride, + ((block - 16) >> 1) * 4 * x->dst.uv_stride + (block & 1) * 4, bs); + + setup_block(&x->block[block+4], x->dst.uv_stride, v, x->dst.uv_stride, + ((block - 16) >> 1) * 4 * x->dst.uv_stride + (block & 1) * 4, bs); + } +} + +void vp8_setup_block_dptrs(MACROBLOCKD *x) +{ + int r, c; + + for (r = 0; r < 4; r++) + { + for (c = 0; c < 4; c++) + { + x->block[r*4+c].diff = &x->diff[r * 4 * 16 + c * 4]; + x->block[r*4+c].predictor = x->predictor + r * 4 * 16 + c * 4; + } + } + + for (r = 0; r < 2; r++) + { + for (c = 0; c < 2; c++) + { + x->block[16+r*2+c].diff = &x->diff[256 + r * 4 * 8 + c * 4]; + x->block[16+r*2+c].predictor = x->predictor + 256 + r * 4 * 8 + c * 4; + } + } + + for (r = 0; r < 2; r++) + { + for (c = 0; c < 2; c++) + { + x->block[20+r*2+c].diff = &x->diff[320+ r * 4 * 8 + c * 4]; + x->block[20+r*2+c].predictor = x->predictor + 320 + r * 4 * 8 + c * 4; + } + } + + x->block[24].diff = &x->diff[384]; + + for (r = 0; r < 25; r++) + { + x->block[r].qcoeff = x->qcoeff + r * 16; + x->block[r].dqcoeff = x->dqcoeff + r * 16; + } +} + +void vp8_build_block_doffsets(MACROBLOCKD *x) +{ + /* handle the destination pitch features */ + setup_macroblock(x, DEST); + setup_macroblock(x, PRED); +} + +void update_blockd_bmi(MACROBLOCKD *xd) +{ + int i; + + /* If the block size is 4x4. */ + if (xd->mode_info_context->mbmi.mode == SPLITMV || + xd->mode_info_context->mbmi.mode == B_PRED) + { + for (i = 0; i < 16; i++) + { + xd->block[i].bmi = xd->mode_info_context->bmi[i]; + } + } +} diff --git a/src/gallium/auxiliary/vl/vp8/common/blockd.h b/src/gallium/auxiliary/vl/vp8/common/blockd.h index 18cb36abe0..5312803857 100644 --- a/src/gallium/auxiliary/vl/vp8/common/blockd.h +++ b/src/gallium/auxiliary/vl/vp8/common/blockd.h @@ -29,16 +29,6 @@ #define SEGMENT_DELTADATA 0 #define SEGMENT_ABSDATA 1 -typedef struct -{ - int r, c; -} POS; - -#define PLANE_TYPE_Y_NO_DC 0 -#define PLANE_TYPE_Y2 1 -#define PLANE_TYPE_UV 2 -#define PLANE_TYPE_Y_WITH_DC 3 - typedef char ENTROPY_CONTEXT; typedef struct @@ -49,12 +39,6 @@ typedef struct ENTROPY_CONTEXT y2; } ENTROPY_CONTEXT_PLANES; -extern const unsigned char vp8_block2left[25]; -extern const unsigned char vp8_block2above[25]; - -#define VP8_COMBINEENTROPYCONTEXTS( Dest, A, B) \ - Dest = ((A)!=0) + ((B)!=0); - typedef enum { KEY_FRAME = 0, @@ -181,7 +165,7 @@ typedef struct union b_mode_info bmi; } BLOCKD; -typedef struct MacroBlockD +typedef struct { DECLARE_ALIGNED(16, short, diff[400]); /* from idct diff */ DECLARE_ALIGNED(16, unsigned char, predictor[384]); @@ -256,22 +240,8 @@ typedef struct MacroBlockD } MACROBLOCKD; -extern void vp8_build_block_doffsets(MACROBLOCKD *x); -extern void vp8_setup_block_dptrs(MACROBLOCKD *x); - -static void update_blockd_bmi(MACROBLOCKD *xd) -{ - int i; - - /* If the block size is 4x4. */ - if (xd->mode_info_context->mbmi.mode == SPLITMV || - xd->mode_info_context->mbmi.mode == B_PRED) - { - for (i = 0; i < 16; i++) - { - xd->block[i].bmi = xd->mode_info_context->bmi[i]; - } - } -} +void vp8_build_block_doffsets(MACROBLOCKD *x); +void vp8_setup_block_dptrs(MACROBLOCKD *x); +void update_blockd_bmi(MACROBLOCKD *xd); #endif /* BLOCKD_H */ diff --git a/src/gallium/auxiliary/vl/vp8/common/entropy.c b/src/gallium/auxiliary/vl/vp8/common/entropy.c index 5e0413c11d..83e4cacb33 100644 --- a/src/gallium/auxiliary/vl/vp8/common/entropy.c +++ b/src/gallium/auxiliary/vl/vp8/common/entropy.c @@ -66,7 +66,7 @@ const int vp8_mb_feature_data_bits[MB_LVL_MAX] = {7, 6}; /* Array indices are identical to previously-existing CONTEXT_NODE indices */ -const vp8_tree_index vp8_coef_tree[ 22] = /* corresponding _CONTEXT_NODEs */ +const vp8_tree_index vp8_coef_tree[22] = /* corresponding _CONTEXT_NODEs */ { -DCT_EOB_TOKEN, 2, /* 0 = EOB */ -ZERO_TOKEN, 4, /* 1 = ZERO */ diff --git a/src/gallium/auxiliary/vl/vp8/common/entropymv.h b/src/gallium/auxiliary/vl/vp8/common/entropymv.h index 664a850256..f1e60be7f7 100644 --- a/src/gallium/auxiliary/vl/vp8/common/entropymv.h +++ b/src/gallium/auxiliary/vl/vp8/common/entropymv.h @@ -34,7 +34,7 @@ enum MVPcount = MVPbits + mvlong_width /* (with independent probabilities) */ }; -typedef struct mv_context +typedef struct { vp8_prob prob[MVPcount]; /* often come in row, col pairs */ } MV_CONTEXT; diff --git a/src/gallium/auxiliary/vl/vp8/common/filter.c b/src/gallium/auxiliary/vl/vp8/common/filter.c index ca23ef51d4..68f2a3a306 100644 --- a/src/gallium/auxiliary/vl/vp8/common/filter.c +++ b/src/gallium/auxiliary/vl/vp8/common/filter.c @@ -10,6 +10,7 @@ #include <stdlib.h> + #include "filter.h" #include "../vp8_mem.h" @@ -47,13 +48,13 @@ static void filter_block2d_first_pass(unsigned char *src_ptr, const short *vp8_filter) { unsigned int i, j; - int Temp; + int temp; for (i = 0; i < output_height; i++) { for (j = 0; j < output_width; j++) { - Temp = ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[0]) + + temp = ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[0]) + ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[1]) + ((int)src_ptr[0] * vp8_filter[2]) + ((int)src_ptr[pixel_step] * vp8_filter[3]) + @@ -62,14 +63,14 @@ static void filter_block2d_first_pass(unsigned char *src_ptr, (VP8_FILTER_WEIGHT >> 1); /* Rounding */ /* Normalize back to 0-255 */ - Temp = Temp >> VP8_FILTER_SHIFT; + temp = temp >> VP8_FILTER_SHIFT; - if (Temp < 0) - Temp = 0; - else if (Temp > 255) - Temp = 255; + if (temp < 0) + temp = 0; + else if (temp > 255) + temp = 255; - output_ptr[j] = Temp; + output_ptr[j] = temp; src_ptr++; } @@ -89,14 +90,14 @@ static void filter_block2d_second_pass(int *src_ptr, const short *vp8_filter) { unsigned int i, j; - int Temp; + int temp; for (i = 0; i < output_height; i++) { for (j = 0; j < output_width; j++) { /* Apply filter */ - Temp = ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[0]) + + temp = ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[0]) + ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[1]) + ((int)src_ptr[0] * vp8_filter[2]) + ((int)src_ptr[pixel_step] * vp8_filter[3]) + @@ -105,14 +106,14 @@ static void filter_block2d_second_pass(int *src_ptr, (VP8_FILTER_WEIGHT >> 1); /* Rounding */ /* Normalize back to 0-255 */ - Temp = Temp >> VP8_FILTER_SHIFT; + temp = temp >> VP8_FILTER_SHIFT; - if (Temp < 0) - Temp = 0; - else if (Temp > 255) - Temp = 255; + if (temp < 0) + temp = 0; + else if (temp > 255) + temp = 255; - output_ptr[j] = (unsigned char)Temp; + output_ptr[j] = (unsigned char)temp; src_ptr++; } @@ -300,17 +301,17 @@ static void filter_block2d_bil_second_pass(unsigned short *src_ptr, const short *vp8_filter) { unsigned int i, j; - int Temp; + int temp; for (i = 0; i < height; i++) { for (j = 0; j < width; j++) { /* Apply filter */ - Temp = ((int)src_ptr[0] * vp8_filter[0]) + + temp = ((int)src_ptr[0] * vp8_filter[0]) + ((int)src_ptr[width] * vp8_filter[1]) + (VP8_FILTER_WEIGHT / 2); - dst_ptr[j] = (unsigned int)(Temp >> VP8_FILTER_SHIFT); + dst_ptr[j] = (unsigned int)(temp >> VP8_FILTER_SHIFT); src_ptr++; } @@ -353,7 +354,6 @@ static void filter_block2d_bil(unsigned char *src_ptr, int Width, int Height) { - unsigned short FData[17*16]; /* Temp data buffer used in filtering */ /* First filter 1-D horizontally... */ @@ -363,7 +363,6 @@ static void filter_block2d_bil(unsigned char *src_ptr, filter_block2d_bil_second_pass(FData, dst_ptr, dst_pitch, Height, Width, VFilter); } - void vp8_bilinear_predict4x4_c(unsigned char *src_ptr, int src_pixels_per_line, int xoffset, @@ -377,26 +376,6 @@ void vp8_bilinear_predict4x4_c(unsigned char *src_ptr, HFilter = vp8_bilinear_filters[xoffset]; VFilter = vp8_bilinear_filters[yoffset]; -#if 0 - { - int i; - unsigned char temp1[16]; - unsigned char temp2[16]; - - bilinear_predict4x4_mmx(src_ptr, src_pixels_per_line, xoffset, yoffset, temp1, 4); - filter_block2d_bil(src_ptr, temp2, src_pixels_per_line, 4, HFilter, VFilter, 4, 4); - - for (i = 0; i < 16; i++) - { - if (temp1[i] != temp2[i]) - { - bilinear_predict4x4_mmx(src_ptr, src_pixels_per_line, xoffset, yoffset, temp1, 4); - filter_block2d_bil(src_ptr, temp2, src_pixels_per_line, 4, HFilter, VFilter, 4, 4); - } - } - } -#endif - filter_block2d_bil(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 4, 4); } diff --git a/src/gallium/auxiliary/vl/vp8/common/mbpitch.c b/src/gallium/auxiliary/vl/vp8/common/mbpitch.c deleted file mode 100644 index 237176508b..0000000000 --- a/src/gallium/auxiliary/vl/vp8/common/mbpitch.c +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2010 The WebM project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -#include "blockd.h" - -typedef enum -{ - PRED = 0, - DEST = 1 -} BLOCKSET; - -static void setup_block(BLOCKD *b, - int mv_stride, - unsigned char **base, - int stride, - int offset, - BLOCKSET bs) -{ - if (bs == DEST) - { - b->dst_stride = stride; - b->dst = offset; - b->base_dst = base; - } - else - { - b->pre_stride = stride; - b->pre = offset; - b->base_pre = base; - } -} - -static void setup_macroblock(MACROBLOCKD *x, BLOCKSET bs) -{ - int block; - unsigned char **y, **u, **v; - - if (bs == DEST) - { - y = &x->dst.y_buffer; - u = &x->dst.u_buffer; - v = &x->dst.v_buffer; - } - else - { - y = &x->pre.y_buffer; - u = &x->pre.u_buffer; - v = &x->pre.v_buffer; - } - - for (block = 0; block < 16; block++) /* y blocks */ - { - setup_block(&x->block[block], x->dst.y_stride, y, x->dst.y_stride, - (block >> 2) * 4 * x->dst.y_stride + (block & 3) * 4, bs); - } - - for (block = 16; block < 20; block++) /* U and V blocks */ - { - setup_block(&x->block[block], x->dst.uv_stride, u, x->dst.uv_stride, - ((block - 16) >> 1) * 4 * x->dst.uv_stride + (block & 1) * 4, bs); - - setup_block(&x->block[block+4], x->dst.uv_stride, v, x->dst.uv_stride, - ((block - 16) >> 1) * 4 * x->dst.uv_stride + (block & 1) * 4, bs); - } -} - -void vp8_setup_block_dptrs(MACROBLOCKD *x) -{ - int r, c; - - for (r = 0; r < 4; r++) - { - for (c = 0; c < 4; c++) - { - x->block[r*4+c].diff = &x->diff[r * 4 * 16 + c * 4]; - x->block[r*4+c].predictor = x->predictor + r * 4 * 16 + c * 4; - } - } - - for (r = 0; r < 2; r++) - { - for (c = 0; c < 2; c++) - { - x->block[16+r*2+c].diff = &x->diff[256 + r * 4 * 8 + c * 4]; - x->block[16+r*2+c].predictor = x->predictor + 256 + r * 4 * 8 + c * 4; - } - } - - for (r = 0; r < 2; r++) - { - for (c = 0; c < 2; c++) - { - x->block[20+r*2+c].diff = &x->diff[320+ r * 4 * 8 + c * 4]; - x->block[20+r*2+c].predictor = x->predictor + 320 + r * 4 * 8 + c * 4; - } - } - - x->block[24].diff = &x->diff[384]; - - for (r = 0; r < 25; r++) - { - x->block[r].qcoeff = x->qcoeff + r * 16; - x->block[r].dqcoeff = x->dqcoeff + r * 16; - } -} - -void vp8_build_block_doffsets(MACROBLOCKD *x) -{ - /* handle the destination pitch features */ - setup_macroblock(x, DEST); - setup_macroblock(x, PRED); -} diff --git a/src/gallium/auxiliary/vl/vp8/common/onyxc_int.h b/src/gallium/auxiliary/vl/vp8/common/onyxc_int.h index e905126d69..3d4ba58552 100644 --- a/src/gallium/auxiliary/vl/vp8/common/onyxc_int.h +++ b/src/gallium/auxiliary/vl/vp8/common/onyxc_int.h @@ -70,8 +70,8 @@ typedef struct VP8Common int version; - int Width; - int Height; + int width; + int height; int horiz_scale; int vert_scale; diff --git a/src/gallium/auxiliary/vl/vp8/common/reconintra4x4.c b/src/gallium/auxiliary/vl/vp8/common/reconintra4x4.c index fbdbdaf623..77a191f793 100644 --- a/src/gallium/auxiliary/vl/vp8/common/reconintra4x4.c +++ b/src/gallium/auxiliary/vl/vp8/common/reconintra4x4.c @@ -18,9 +18,9 @@ void vp8_intra4x4_predict(BLOCKD *x, int b_mode, unsigned char *predictor) int i, r, c; unsigned char *Above = *(x->base_dst) + x->dst - x->dst_stride; - unsigned char Left[4]; unsigned char top_left = Above[-1]; + unsigned char Left[4]; Left[0] = (*(x->base_dst))[x->dst - 1]; Left[1] = (*(x->base_dst))[x->dst - 1 + x->dst_stride]; Left[2] = (*(x->base_dst))[x->dst - 1 + 2 * x->dst_stride]; @@ -119,6 +119,7 @@ void vp8_intra4x4_predict(BLOCKD *x, int b_mode, unsigned char *predictor) case B_LD_PRED: { unsigned char *ptr = Above; + predictor[0 * 16 + 0] = (ptr[0] + ptr[1] * 2 + ptr[2] + 2) >> 2; predictor[0 * 16 + 1] = predictor[1 * 16 + 0] = (ptr[1] + ptr[2] * 2 + ptr[3] + 2) >> 2; @@ -141,7 +142,6 @@ void vp8_intra4x4_predict(BLOCKD *x, int b_mode, unsigned char *predictor) case B_RD_PRED: { unsigned char pp[9]; - pp[0] = Left[3]; pp[1] = Left[2]; pp[2] = Left[1]; @@ -174,7 +174,6 @@ void vp8_intra4x4_predict(BLOCKD *x, int b_mode, unsigned char *predictor) case B_VR_PRED: { unsigned char pp[9]; - pp[0] = Left[3]; pp[1] = Left[2]; pp[2] = Left[1]; @@ -230,7 +229,6 @@ void vp8_intra4x4_predict(BLOCKD *x, int b_mode, unsigned char *predictor) case B_HD_PRED: { unsigned char pp[9]; - pp[0] = Left[3]; pp[1] = Left[2]; pp[2] = Left[1]; diff --git a/src/gallium/auxiliary/vl/vp8/common/subpixel.h b/src/gallium/auxiliary/vl/vp8/common/subpixel.h index e2ae8c6e01..9c8ee88165 100644 --- a/src/gallium/auxiliary/vl/vp8/common/subpixel.h +++ b/src/gallium/auxiliary/vl/vp8/common/subpixel.h @@ -59,14 +59,14 @@ extern prototype_subpixel_predict(vp8_subpix_bilinear4x4); typedef prototype_subpixel_predict((*vp8_subpix_fn_t)); typedef struct { - vp8_subpix_fn_t sixtap16x16; - vp8_subpix_fn_t sixtap8x8; - vp8_subpix_fn_t sixtap8x4; - vp8_subpix_fn_t sixtap4x4; - vp8_subpix_fn_t bilinear16x16; - vp8_subpix_fn_t bilinear8x8; - vp8_subpix_fn_t bilinear8x4; - vp8_subpix_fn_t bilinear4x4; + vp8_subpix_fn_t sixtap16x16; + vp8_subpix_fn_t sixtap8x8; + vp8_subpix_fn_t sixtap8x4; + vp8_subpix_fn_t sixtap4x4; + vp8_subpix_fn_t bilinear16x16; + vp8_subpix_fn_t bilinear8x8; + vp8_subpix_fn_t bilinear8x4; + vp8_subpix_fn_t bilinear4x4; } vp8_subpix_rtcd_vtable_t; #define SUBPIX_INVOKE(ctx,fn) vp8_subpix_##fn diff --git a/src/gallium/auxiliary/vl/vp8/common/treecoder.h b/src/gallium/auxiliary/vl/vp8/common/treecoder.h index c16f7b0bce..58cb4f4582 100644 --- a/src/gallium/auxiliary/vl/vp8/common/treecoder.h +++ b/src/gallium/auxiliary/vl/vp8/common/treecoder.h @@ -14,20 +14,9 @@ #define vp8_prob_half ((vp8_prob) 128) -typedef unsigned char vp8bc_index_t; /* probability index */ - typedef unsigned char vp8_prob; typedef signed char vp8_tree_index; -struct bool_coder_spec; - -typedef struct bool_coder_spec bool_coder_spec; -typedef struct bool_writer bool_writer; -typedef struct bool_reader bool_reader; - -typedef const bool_coder_spec c_bool_coder_spec; -typedef const bool_writer c_bool_writer; -typedef const bool_reader c_bool_reader; /* We build coding trees compactly in arrays. Each node of the tree is a pair of vp8_tree_indices. diff --git a/src/gallium/auxiliary/vl/vp8/decoder/dboolhuff.c b/src/gallium/auxiliary/vl/vp8/decoder/dboolhuff.c index c5bf2fd404..f801d9e3f9 100644 --- a/src/gallium/auxiliary/vl/vp8/decoder/dboolhuff.c +++ b/src/gallium/auxiliary/vl/vp8/decoder/dboolhuff.c @@ -47,3 +47,27 @@ void vp8dx_bool_decoder_fill(BOOL_DECODER *bd) bd->value = value; bd->count = count; } + +/** + * Check if we have reached the end of the buffer. + * + * Variable 'count' stores the number of bits in the 'value' buffer, minus + * 8. The top byte is part of the algorithm, and the remainder is buffered + * to be shifted into it. So if count == 8, the top 16 bits of 'value' are + * occupied, 8 for the algorithm and 8 in the buffer. + * + * When reading a byte from the user's buffer, count is filled with 8 and + * one byte is filled into the value buffer. When we reach the end of the + * data, count is additionally filled with VP8_LOTS_OF_BITS. So when + * count == VP8_LOTS_OF_BITS - 1, the user's data has been exhausted. + */ +int vp8dx_bool_error(BOOL_DECODER *bd) +{ + if ((bd->count > VP8_BD_VALUE_SIZE) && (bd->count < VP8_LOTS_OF_BITS)) + { + /* We have tried to decode bits after the end of stream was encountered. */ + return 1; + } + + return 0; +} diff --git a/src/gallium/auxiliary/vl/vp8/decoder/dboolhuff.h b/src/gallium/auxiliary/vl/vp8/decoder/dboolhuff.h index a10a7a44bc..9329e2983d 100644 --- a/src/gallium/auxiliary/vl/vp8/decoder/dboolhuff.h +++ b/src/gallium/auxiliary/vl/vp8/decoder/dboolhuff.h @@ -45,6 +45,8 @@ int vp8dx_start_decode(BOOL_DECODER *bd, void vp8dx_bool_decoder_fill(BOOL_DECODER *bd); +int vp8dx_bool_error(BOOL_DECODER *bd); + /** * The refill loop is used in several places, so define it in a macro to make * sure they're all consistent. @@ -132,28 +134,4 @@ static int vp8_decode_value(BOOL_DECODER *bd, int bits) return z; } -/** - * Check if we have reached the end of the buffer. - * - * Variable 'count' stores the number of bits in the 'value' buffer, minus - * 8. The top byte is part of the algorithm, and the remainder is buffered - * to be shifted into it. So if count == 8, the top 16 bits of 'value' are - * occupied, 8 for the algorithm and 8 in the buffer. - * - * When reading a byte from the user's buffer, count is filled with 8 and - * one byte is filled into the value buffer. When we reach the end of the - * data, count is additionally filled with VP8_LOTS_OF_BITS. So when - * count == VP8_LOTS_OF_BITS - 1, the user's data has been exhausted. - */ -static int vp8dx_bool_error(BOOL_DECODER *bd) -{ - if ((bd->count > VP8_BD_VALUE_SIZE) && (bd->count < VP8_LOTS_OF_BITS)) - { - /* We have tried to decode bits after the end of stream was encountered. */ - return 1; - } - - return 0; -} - #endif /* DBOOLHUFF_H */ diff --git a/src/gallium/auxiliary/vl/vp8/decoder/decodeframe.c b/src/gallium/auxiliary/vl/vp8/decoder/decodeframe.c index f5b8647207..e96f3c4c63 100644 --- a/src/gallium/auxiliary/vl/vp8/decoder/decodeframe.c +++ b/src/gallium/auxiliary/vl/vp8/decoder/decodeframe.c @@ -261,19 +261,19 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, unsigned int mb_i { BLOCKD *b = &xd->block[i]; RECON_INVOKE(RTCD_VTABLE(recon), intra4x4_predict) - (b, b->bmi.as_mode, b->predictor); + (b, b->bmi.as_mode, b->predictor); if (xd->eobs[i] > 1) { DEQUANT_INVOKE(&pbi->dequant, idct_add) - (b->qcoeff, b->dequant, b->predictor, - *(b->base_dst) + b->dst, 16, b->dst_stride); + (b->qcoeff, b->dequant, b->predictor, + *(b->base_dst) + b->dst, 16, b->dst_stride); } else { IDCT_INVOKE(RTCD_VTABLE(idct), idct1_scalar_add) - (b->qcoeff[0] * b->dequant[0], b->predictor, - *(b->base_dst) + b->dst, 16, b->dst_stride); + (b->qcoeff[0] * b->dequant[0], b->predictor, + *(b->base_dst) + b->dst, 16, b->dst_stride); ((int *)b->qcoeff)[0] = 0; } } @@ -281,10 +281,10 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, unsigned int mb_i } else if (mode == SPLITMV) { - DEQUANT_INVOKE (&pbi->dequant, idct_add_y_block) - (xd->qcoeff, xd->block[0].dequant, - xd->predictor, xd->dst.y_buffer, - xd->dst.y_stride, xd->eobs); + DEQUANT_INVOKE(&pbi->dequant, idct_add_y_block) + (xd->qcoeff, xd->block[0].dequant, + xd->predictor, xd->dst.y_buffer, + xd->dst.y_stride, xd->eobs); } else { @@ -312,15 +312,15 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, unsigned int mb_i } DEQUANT_INVOKE (&pbi->dequant, dc_idct_add_y_block) - (xd->qcoeff, xd->block[0].dequant, - xd->predictor, xd->dst.y_buffer, - xd->dst.y_stride, xd->eobs, xd->block[24].diff); + (xd->qcoeff, xd->block[0].dequant, + xd->predictor, xd->dst.y_buffer, + xd->dst.y_stride, xd->eobs, xd->block[24].diff); } DEQUANT_INVOKE (&pbi->dequant, idct_add_uv_block) - (xd->qcoeff+16*16, xd->block[16].dequant, - xd->predictor+16*16, xd->dst.u_buffer, xd->dst.v_buffer, - xd->dst.uv_stride, xd->eobs+16); + (xd->qcoeff+16*16, xd->block[16].dequant, + xd->predictor+16*16, xd->dst.u_buffer, xd->dst.v_buffer, + xd->dst.uv_stride, xd->eobs+16); } static void @@ -453,8 +453,8 @@ static void token_decoder_setup(VP8D_COMP *pbi, partition_size = user_data_end - partition; } - if (partition + partition_size > user_data_end - || partition + partition_size < partition) + if (partition + partition_size > user_data_end || + partition + partition_size < partition) { vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME, "Truncated packet or corrupt partition " @@ -570,8 +570,8 @@ int vp8_frame_decode(VP8D_COMP *pbi, struct pipe_vp8_picture_desc *frame_header) if (pc->frame_type == KEY_FRAME) { - if (pc->Width != frame_header->width || - pc->Height != frame_header->height) + if (pc->width != frame_header->width || + pc->height != frame_header->height) { if (vp8_alloc_frame_buffers(pc, frame_header->width, frame_header->height)) { @@ -580,9 +580,9 @@ int vp8_frame_decode(VP8D_COMP *pbi, struct pipe_vp8_picture_desc *frame_header) } } - pc->Width = frame_header->width; + pc->width = frame_header->width; pc->horiz_scale = frame_header->horizontal_scale; - pc->Height = frame_header->height; + pc->height = frame_header->height; pc->vert_scale = frame_header->vertical_scale; } diff --git a/src/gallium/auxiliary/vl/vp8/decoder/detokenize.c b/src/gallium/auxiliary/vl/vp8/decoder/detokenize.c index 4538d89001..fad43f4ae3 100644 --- a/src/gallium/auxiliary/vl/vp8/decoder/detokenize.c +++ b/src/gallium/auxiliary/vl/vp8/decoder/detokenize.c @@ -18,14 +18,6 @@ #define OCB_X PREV_COEF_CONTEXTS * ENTROPY_NODES -DECLARE_ALIGNED(16, static const unsigned char, coef_bands_x[16]) = -{ - 0 * OCB_X, 1 * OCB_X, 2 * OCB_X, 3 * OCB_X, - 6 * OCB_X, 4 * OCB_X, 5 * OCB_X, 6 * OCB_X, - 6 * OCB_X, 6 * OCB_X, 6 * OCB_X, 6 * OCB_X, - 6 * OCB_X, 6 * OCB_X, 6 * OCB_X, 7 * OCB_X -}; - #define EOB_CONTEXT_NODE 0 #define ZERO_CONTEXT_NODE 1 #define ONE_CONTEXT_NODE 2 @@ -38,22 +30,40 @@ DECLARE_ALIGNED(16, static const unsigned char, coef_bands_x[16]) = #define CAT_THREE_CONTEXT_NODE 9 #define CAT_FIVE_CONTEXT_NODE 10 +DECLARE_ALIGNED(16, static const unsigned char, coef_bands_x[16]) = +{ + 0 * OCB_X, 1 * OCB_X, 2 * OCB_X, 3 * OCB_X, + 6 * OCB_X, 4 * OCB_X, 5 * OCB_X, 6 * OCB_X, + 6 * OCB_X, 6 * OCB_X, 6 * OCB_X, 6 * OCB_X, + 6 * OCB_X, 6 * OCB_X, 6 * OCB_X, 7 * OCB_X +}; + DECLARE_ALIGNED(16, static const TOKENEXTRABITS, vp8d_token_extra_bits2[MAX_ENTROPY_TOKENS]) = { { 0, -1, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, /* ZERO_TOKEN */ - { 1, 0, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, /* ONE_TOKEN */ - { 2, 0, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, /* TWO_TOKEN */ - { 3, 0, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, /* THREE_TOKEN */ - { 4, 0, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, /* FOUR_TOKEN */ - { 5, 0, { 159, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, /* DCT_VAL_CATEGORY1 */ - { 7, 1, { 145, 165, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, /* DCT_VAL_CATEGORY2 */ - { 11, 2, { 140, 148, 173, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, /* DCT_VAL_CATEGORY3 */ - { 19, 3, { 135, 140, 155, 176, 0, 0, 0, 0, 0, 0, 0, 0 } }, /* DCT_VAL_CATEGORY4 */ - { 35, 4, { 130, 134, 141, 157, 180, 0, 0, 0, 0, 0, 0, 0 } }, /* DCT_VAL_CATEGORY5 */ + { 1, 0, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, /* ONE_TOKEN */ + { 2, 0, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, /* TWO_TOKEN */ + { 3, 0, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, /* THREE_TOKEN */ + { 4, 0, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, /* FOUR_TOKEN */ + { 5, 0, { 159, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, /* DCT_VAL_CATEGORY1 */ + { 7, 1, { 145, 165, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, /* DCT_VAL_CATEGORY2 */ + { 11, 2, { 140, 148, 173, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, /* DCT_VAL_CATEGORY3 */ + { 19, 3, { 135, 140, 155, 176, 0, 0, 0, 0, 0, 0, 0, 0 } }, /* DCT_VAL_CATEGORY4 */ + { 35, 4, { 130, 134, 141, 157, 180, 0, 0, 0, 0, 0, 0, 0 } }, /* DCT_VAL_CATEGORY5 */ { 67, 10, { 129, 130, 133, 140, 153, 177, 196, 230, 243, 254, 254, 0 } }, /* DCT_VAL_CATEGORY6 */ { 0, -1, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, /* EOB TOKEN */ }; +const unsigned char vp8_block2left[25] = +{ + 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 +}; + +const unsigned char vp8_block2above[25] = +{ + 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8 +}; + void vp8_reset_mb_tokens_context(MACROBLOCKD *x) { /* Clear entropy contexts for Y2 blocks */ @@ -70,6 +80,7 @@ void vp8_reset_mb_tokens_context(MACROBLOCKD *x) } DECLARE_ALIGNED(16, extern const unsigned char, vp8_norm[256]); + #define FILL \ if(count < 0) \ VP8DX_BOOL_DECODER_FILL(count, value, bufptr, bufend); @@ -104,7 +115,7 @@ DECLARE_ALIGNED(16, extern const unsigned char, vp8_norm[256]); #define DECODE_AND_BRANCH_IF_ZERO(probability,branch) \ { \ - split = 1 + (((probability*(range-1)))>> 8); \ + split = 1 + (((probability*(range-1))) >> 8); \ bigsplit = (VP8_BD_VALUE)split << (VP8_BD_VALUE_SIZE - 8); \ FILL \ if (value < bigsplit) \ @@ -128,7 +139,7 @@ DECLARE_ALIGNED(16, extern const unsigned char, vp8_norm[256]); range = split; \ NORMALIZE \ Prob = coef_probs; \ - if (c < 15) {\ + if (c < 15) { \ ++c; \ Prob += coef_bands_x[c]; \ goto branch; \ @@ -150,7 +161,7 @@ DECLARE_ALIGNED(16, extern const unsigned char, vp8_norm[256]); goto BLOCK_FINISHED; -#define DECODE_EXTRABIT_AND_ADJUST_VAL(t,bits_count) \ +#define DECODE_EXTRABIT_AND_ADJUST_VAL(t, bits_count) \ split = 1 + (((range-1) * vp8d_token_extra_bits2[t].Probs[bits_count]) >> 8); \ bigsplit = (VP8_BD_VALUE)split << (VP8_BD_VALUE_SIZE - 8); \ FILL \ @@ -166,6 +177,10 @@ DECLARE_ALIGNED(16, extern const unsigned char, vp8_norm[256]); } \ NORMALIZE +#define VP8_COMBINEENTROPYCONTEXTS(Dest, A, B) \ + Dest = ((A) != 0) + ((B) != 0); + + int vp8_decode_mb_tokens(VP8D_COMP *dx, MACROBLOCKD *x) { ENTROPY_CONTEXT *A = (ENTROPY_CONTEXT *)x->above_context; @@ -224,7 +239,6 @@ int vp8_decode_mb_tokens(VP8D_COMP *dx, MACROBLOCKD *x) count = bd->count; range = bd->range; - coef_probs = fc->coef_probs [type] [0] [0]; BLOCK_LOOP: diff --git a/src/gallium/auxiliary/vl/vp8/decoder/onyxd_if.c b/src/gallium/auxiliary/vl/vp8/decoder/onyxd_if.c index fba2071aa6..ad2b39401f 100644 --- a/src/gallium/auxiliary/vl/vp8/decoder/onyxd_if.c +++ b/src/gallium/auxiliary/vl/vp8/decoder/onyxd_if.c @@ -239,9 +239,9 @@ int vp8_decoder_getframe(VP8D_PTR ptr, { *sd = *pbi->common.frame_to_show; sd->clrtype = pbi->common.clr_type; - sd->y_width = pbi->common.Width; - sd->y_height = pbi->common.Height; - sd->uv_height = pbi->common.Height / 2; + sd->y_width = pbi->common.width; + sd->y_height = pbi->common.height; + sd->uv_height = pbi->common.height / 2; ret = 0; } |