Commit d39f279d authored by James Zern's avatar James Zern
Browse files

vp9_decode_frame: group assignments/setup calls

group error checking at the top followed by allocations, setup then
decode.

Change-Id: I877d21326bb767885520511ecea70e5fd1e28054
Showing with 12 additions and 19 deletions
...@@ -1140,14 +1140,13 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { ...@@ -1140,14 +1140,13 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
MACROBLOCKD *const xd = &pbi->mb; MACROBLOCKD *const xd = &pbi->mb;
const uint8_t *data = pbi->source; const uint8_t *data = pbi->source;
const uint8_t *data_end = pbi->source + pbi->source_sz; const uint8_t *const data_end = pbi->source + pbi->source_sz;
struct vp9_read_bit_buffer rb = { data, data_end, 0, struct vp9_read_bit_buffer rb = { data, data_end, 0, cm, error_handler };
cm, error_handler };
const size_t first_partition_size = read_uncompressed_header(pbi, &rb); const size_t first_partition_size = read_uncompressed_header(pbi, &rb);
const int keyframe = cm->frame_type == KEY_FRAME; const int keyframe = cm->frame_type == KEY_FRAME;
YV12_BUFFER_CONFIG *new_fb = get_frame_new_buffer(cm);
const int tile_cols = 1 << cm->log2_tile_cols; const int tile_cols = 1 << cm->log2_tile_cols;
YV12_BUFFER_CONFIG *const new_fb = get_frame_new_buffer(cm);
if (!first_partition_size) { if (!first_partition_size) {
if (!keyframe) { if (!keyframe) {
...@@ -1160,19 +1159,17 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { ...@@ -1160,19 +1159,17 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
return -1; return -1;
} }
} }
data += vp9_rb_bytes_read(&rb);
xd->corrupted = 0;
new_fb->corrupted = 0;
pbi->do_loopfilter_inline =
(cm->log2_tile_rows | cm->log2_tile_cols) == 0 && cm->lf.filter_level;
if (!pbi->decoded_key_frame && !keyframe) if (!pbi->decoded_key_frame && !keyframe)
return -1; return -1;
data += vp9_rb_bytes_read(&rb);
if (!read_is_valid(data, first_partition_size, data_end)) if (!read_is_valid(data, first_partition_size, data_end))
vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME,
"Truncated packet or corrupt header length"); "Truncated packet or corrupt header length");
pbi->do_loopfilter_inline =
(cm->log2_tile_rows | cm->log2_tile_cols) == 0 && cm->lf.filter_level;
if (pbi->do_loopfilter_inline && pbi->lf_worker.data1 == NULL) { if (pbi->do_loopfilter_inline && pbi->lf_worker.data1 == NULL) {
CHECK_MEM_ERROR(cm, pbi->lf_worker.data1, vpx_malloc(sizeof(LFWorkerData))); CHECK_MEM_ERROR(cm, pbi->lf_worker.data1, vpx_malloc(sizeof(LFWorkerData)));
pbi->lf_worker.hook = (VP9WorkerHook)vp9_loop_filter_worker; pbi->lf_worker.hook = (VP9WorkerHook)vp9_loop_filter_worker;
...@@ -1182,26 +1179,22 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { ...@@ -1182,26 +1179,22 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
} }
} }
setup_plane_dequants(cm, &pbi->mb, cm->base_qindex); alloc_tile_storage(pbi, tile_cols);
xd->mi_8x8 = cm->mi_grid_visible; xd->mi_8x8 = cm->mi_grid_visible;
xd->mode_info_stride = cm->mode_info_stride; xd->mode_info_stride = cm->mode_info_stride;
set_prev_mi(cm);
alloc_tile_storage(pbi, tile_cols); setup_plane_dequants(cm, xd, cm->base_qindex);
setup_block_dptrs(xd, cm->subsampling_x, cm->subsampling_y);
cm->fc = cm->frame_contexts[cm->frame_context_idx]; cm->fc = cm->frame_contexts[cm->frame_context_idx];
vp9_zero(cm->counts); vp9_zero(cm->counts);
new_fb->corrupted |= read_compressed_header(pbi, data, first_partition_size);
setup_block_dptrs(xd, cm->subsampling_x, cm->subsampling_y);
// clear out the coeff buffer
for (i = 0; i < MAX_MB_PLANE; ++i) for (i = 0; i < MAX_MB_PLANE; ++i)
vp9_zero(xd->plane[i].qcoeff); vp9_zero(xd->plane[i].qcoeff);
set_prev_mi(cm); xd->corrupted = 0;
new_fb->corrupted = read_compressed_header(pbi, data, first_partition_size);
*p_data_end = decode_tiles(pbi, data + first_partition_size); *p_data_end = decode_tiles(pbi, data + first_partition_size);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment