summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmeric Grange <emeric.grange@gmail.com>2012-02-23 16:51:02 +0100
committerEmeric Grange <emeric.grange@gmail.com>2012-06-24 16:57:33 +0200
commit1bf1affbced87c5261b45ef9e55f5e1b2b2ae439 (patch)
tree0066e756d0e80ab733ec25c8864f962f8567d9de
parent380c3784dac99d8ef46e60ba3ec8c7104cd0813a (diff)
g3dvl/vp8: Minor cleanups into the software decoder
Signed-off-by: Emeric Grange <emeric.grange@gmail.com>
-rw-r--r--src/gallium/auxiliary/vl/vp8/alloccommon.c29
-rw-r--r--src/gallium/auxiliary/vl/vp8/alloccommon.h4
-rw-r--r--src/gallium/auxiliary/vl/vp8/decodeframe.c29
-rw-r--r--src/gallium/auxiliary/vl/vp8/treereader.h2
-rw-r--r--src/gallium/auxiliary/vl/vp8/treereader_common.c28
-rw-r--r--src/gallium/auxiliary/vl/vp8/vp8_mem.c2
-rw-r--r--src/gallium/auxiliary/vl/vp8/yv12utils.h1
7 files changed, 46 insertions, 49 deletions
diff --git a/src/gallium/auxiliary/vl/vp8/alloccommon.c b/src/gallium/auxiliary/vl/vp8/alloccommon.c
index b97740050a..3e3d50968a 100644
--- a/src/gallium/auxiliary/vl/vp8/alloccommon.c
+++ b/src/gallium/auxiliary/vl/vp8/alloccommon.c
@@ -31,20 +31,6 @@ static void update_mode_info_border(MODE_INFO *mi, int rows, int cols)
}
}
-void vp8_dealloc_frame_buffers(VP8_COMMON *common)
-{
- int i;
-
- for (i = 0; i < NUM_YV12_BUFFERS; i++)
- vp8_yv12_de_alloc_frame_buffer(&common->yv12_fb[i]);
-
- vpx_free(common->above_context);
- vpx_free(common->mip);
-
- common->above_context = 0;
- common->mip = 0;
-}
-
int vp8_alloc_frame_buffers(VP8_COMMON *common, int width, int height)
{
int i;
@@ -61,7 +47,6 @@ int vp8_alloc_frame_buffers(VP8_COMMON *common, int width, int height)
for (i = 0; i < NUM_YV12_BUFFERS; i++)
{
common->fb_idx_ref_cnt[i] = 0;
- common->yv12_fb[i].flags = 0;
if (vp8_yv12_alloc_frame_buffer(&common->yv12_fb[i], width, height, VP8BORDERINPIXELS) < 0)
{
vp8_dealloc_frame_buffers(common);
@@ -106,6 +91,20 @@ int vp8_alloc_frame_buffers(VP8_COMMON *common, int width, int height)
return 0;
}
+void vp8_dealloc_frame_buffers(VP8_COMMON *common)
+{
+ int i;
+
+ for (i = 0; i < NUM_YV12_BUFFERS; i++)
+ vp8_yv12_de_alloc_frame_buffer(&common->yv12_fb[i]);
+
+ vpx_free(common->above_context);
+ vpx_free(common->mip);
+
+ common->above_context = 0;
+ common->mip = 0;
+}
+
/**
* Initialize version specific parameters.
* The VP8 "version" field is the equivalent of the mpeg "profile".
diff --git a/src/gallium/auxiliary/vl/vp8/alloccommon.h b/src/gallium/auxiliary/vl/vp8/alloccommon.h
index 9744415d94..a978421e4a 100644
--- a/src/gallium/auxiliary/vl/vp8/alloccommon.h
+++ b/src/gallium/auxiliary/vl/vp8/alloccommon.h
@@ -14,10 +14,10 @@
#include "vp8_decoder.h"
-void vp8_initialize_common(VP8_COMMON *common);
-
int vp8_alloc_frame_buffers(VP8_COMMON *common, int width, int height);
void vp8_dealloc_frame_buffers(VP8_COMMON *common);
+
+void vp8_initialize_common(VP8_COMMON *common);
void vp8_setup_version(VP8_COMMON *common);
#endif /* ALLOCCOMMON_H */
diff --git a/src/gallium/auxiliary/vl/vp8/decodeframe.c b/src/gallium/auxiliary/vl/vp8/decodeframe.c
index ffead17f9d..6b6a0d9558 100644
--- a/src/gallium/auxiliary/vl/vp8/decodeframe.c
+++ b/src/gallium/auxiliary/vl/vp8/decodeframe.c
@@ -195,7 +195,8 @@ static void vp8_extend_mb_row(YV12_BUFFER_CONFIG *ybf,
}
}
-static void decode_macroblock(VP8_COMMON *common, MACROBLOCKD *mb, unsigned int mb_idx)
+static void decode_macroblock(VP8_COMMON *common,
+ MACROBLOCKD *mb, unsigned int mb_idx)
{
int i;
int eobtotal = 0;
@@ -321,7 +322,7 @@ static void decode_macroblock(VP8_COMMON *common, MACROBLOCKD *mb, unsigned int
}
static void
-decode_macroblock_row(VP8_COMMON *common, int mb_row, MACROBLOCKD *mb)
+decode_macroblock_row(VP8_COMMON *common, MACROBLOCKD *mb, int mb_row)
{
int recon_yoffset, recon_uvoffset;
int mb_col;
@@ -400,13 +401,12 @@ decode_macroblock_row(VP8_COMMON *common, int mb_row, MACROBLOCKD *mb)
++mb->mode_info_context;
}
-static unsigned int token_decoder_readpartitionsize(const unsigned char *cx_size)
+static unsigned int token_decoder_readpartitionsize(const unsigned char *partitions_size)
{
- return (cx_size[0] + (cx_size[1] << 8) + (cx_size[2] << 16));
+ return (partitions_size[0] + (partitions_size[1] << 8) + (partitions_size[2] << 16));
}
-static void token_decoder_setup(VP8_COMMON *common,
- const unsigned char *cx_data)
+static void token_decoder_setup(VP8_COMMON *common, const unsigned char *data)
{
int num_part;
int i;
@@ -414,7 +414,7 @@ static void token_decoder_setup(VP8_COMMON *common,
/* Set up pointers to the first partition */
BOOL_DECODER *bool_decoder = &common->bd2;
- const unsigned char *partition = cx_data;
+ const unsigned char *partition = data;
/* Parse number of token partitions to use */
const TOKEN_PARTITION multi_token_partition = (TOKEN_PARTITION)vp8_read_literal(&common->bd, 2);
@@ -440,7 +440,7 @@ static void token_decoder_setup(VP8_COMMON *common,
for (i = 0; i < num_part; i++)
{
- const unsigned char *partition_size_ptr = cx_data + i * 3;
+ const unsigned char *partition_size_ptr = data + i * 3;
ptrdiff_t partition_size;
/* Calculate the length of this partition. The last partition size is implicit. */
@@ -551,7 +551,6 @@ int vp8_frame_decode(VP8_COMMON *common, struct pipe_vp8_picture_desc *frame_hea
const unsigned char *data_end = data + common->data_size;
ptrdiff_t first_partition_length_in_bytes = (ptrdiff_t)frame_header->first_part_size;
- int mb_row;
int i, j, k, l;
/* Start with no corruption of current frame */
@@ -632,7 +631,7 @@ int vp8_frame_decode(VP8_COMMON *common, struct pipe_vp8_picture_desc *frame_hea
if (mb->update_mb_segmentation_map)
{
- /* Which macro block level features are enabled */
+ /* Which macro block level features are enabled. */
memset(mb->mb_segment_tree_probs, 255, sizeof(mb->mb_segment_tree_probs));
/* Read the probs used to decode the segment id for each macro block. */
@@ -777,6 +776,7 @@ int vp8_frame_decode(VP8_COMMON *common, struct pipe_vp8_picture_desc *frame_hea
{
int ibc = 0;
+ int mb_row = 0;
int num_part = 1 << common->multi_token_partition;
/* Decode the individual macro block */
@@ -791,22 +791,21 @@ int vp8_frame_decode(VP8_COMMON *common, struct pipe_vp8_picture_desc *frame_hea
ibc = 0;
}
- decode_macroblock_row(common, mb_row, mb);
+ decode_macroblock_row(common, mb, mb_row);
}
}
token_decoder_stop(common);
/* Collect information about decoder corruption. */
+
/* 1. Check first boolean decoder for errors. */
common->yv12_fb[common->new_fb_idx].corrupted = vp8dx_bool_error(bd);
- /* 2. Check the macroblock information */
+ /* 2. Check the macroblock information. */
common->yv12_fb[common->new_fb_idx].corrupted |= mb->corrupted;
- /* printf("Decoder: Frame Decoded, Size Roughly:%d bytes \n", bc->pos+pbi->bc2.pos); */
-
- /* If this was a kf or Gf note the Q used */
+ /* If this was a kf or Gf note the Q used. */
if (common->frame_type == KEY_FRAME ||
common->refresh_golden_frame ||
common->refresh_alternate_frame)
diff --git a/src/gallium/auxiliary/vl/vp8/treereader.h b/src/gallium/auxiliary/vl/vp8/treereader.h
index 5c813a1f42..6bc2304db2 100644
--- a/src/gallium/auxiliary/vl/vp8/treereader.h
+++ b/src/gallium/auxiliary/vl/vp8/treereader.h
@@ -65,7 +65,7 @@ int vp8_treed_read(BOOL_DECODER *const bd, vp8_tree t, const vp8_prob *const p);
#define VP8DX_BOOL_DECODER_FILL(_count, _value, _bufptr, _bufend) \
do \
{ \
- size_t bits_left = ((_bufend)-(_bufptr))*CHAR_BIT; \
+ size_t bits_left = ((_bufend) - (_bufptr))*CHAR_BIT; \
int shift = VP8_BD_VALUE_SIZE - 8 - ((_count) + 8); \
int loop_end = 0; \
int x = shift + CHAR_BIT - bits_left; \
diff --git a/src/gallium/auxiliary/vl/vp8/treereader_common.c b/src/gallium/auxiliary/vl/vp8/treereader_common.c
index 21bc59ee77..218fcc9a99 100644
--- a/src/gallium/auxiliary/vl/vp8/treereader_common.c
+++ b/src/gallium/auxiliary/vl/vp8/treereader_common.c
@@ -36,19 +36,6 @@ static void tree2tok(struct vp8_token_struct *const p, vp8_tree t, int i, int v,
while (++v & 1);
}
-/**
- * Construct encoding array from tree.
- */
-void vp8_tokens_from_tree(struct vp8_token_struct *p, vp8_tree t)
-{
- tree2tok(p, t, 0, 0, 0);
-}
-
-void vp8_tokens_from_tree_offset(struct vp8_token_struct *p, vp8_tree t, int offset)
-{
- tree2tok(p - offset, t, 0, 0, 0);
-}
-
static void branch_counts(int n, /* n = size of alphabet */
vp8_token tok[/* n */],
vp8_tree tree,
@@ -83,7 +70,7 @@ static void branch_counts(int n, /* n = size of alphabet */
const int b = (enc >> --L) & 1;
const int j = i >> 1;
#if ENABLE_DEBUG
- assert(j < tree_len && 0 <= L);
+ assert(j < tree_len && 0 <= L);
#endif
branch_ct[j][b] += ct;
i = tree[i + b];
@@ -98,6 +85,19 @@ static void branch_counts(int n, /* n = size of alphabet */
}
/**
+ * Construct encoding array from tree.
+ */
+void vp8_tokens_from_tree(struct vp8_token_struct *p, vp8_tree t)
+{
+ tree2tok(p, t, 0, 0, 0);
+}
+
+void vp8_tokens_from_tree_offset(struct vp8_token_struct *p, vp8_tree t, int offset)
+{
+ tree2tok(p - offset, t, 0, 0, 0);
+}
+
+/**
* Convert array of token occurrence counts into a table of probabilities
* for the associated binary encoding tree. Also writes count of branches
* taken for each node on the tree; this facilitiates decisions as to
diff --git a/src/gallium/auxiliary/vl/vp8/vp8_mem.c b/src/gallium/auxiliary/vl/vp8/vp8_mem.c
index c023bf3544..ff63d4fdf3 100644
--- a/src/gallium/auxiliary/vl/vp8/vp8_mem.c
+++ b/src/gallium/auxiliary/vl/vp8/vp8_mem.c
@@ -15,7 +15,7 @@
#define DEFAULT_ALIGNMENT 32 /**< Must be superior or equal to 1 ! */
/** Returns an addr aligned to the byte boundary specified by align */
-#define align_addr(addr,align) (void*)(((size_t)(addr) + ((align) - 1)) & (size_t)-(align))
+#define align_addr(addr, align) (void*)(((size_t)(addr) + ((align) - 1)) & (size_t) - (align))
void *vpx_memalign(size_t align, size_t size)
{
diff --git a/src/gallium/auxiliary/vl/vp8/yv12utils.h b/src/gallium/auxiliary/vl/vp8/yv12utils.h
index 195a31e7ea..c1732d8be5 100644
--- a/src/gallium/auxiliary/vl/vp8/yv12utils.h
+++ b/src/gallium/auxiliary/vl/vp8/yv12utils.h
@@ -56,7 +56,6 @@ typedef struct
YUV_TYPE clrtype;
int corrupted;
- int flags;
} YV12_BUFFER_CONFIG;
int vp8_yv12_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, int border);