diff options
Diffstat (limited to 'vp9/decoder')
-rw-r--r-- | vp9/decoder/vp9_dboolhuff.h | 38 | ||||
-rw-r--r-- | vp9/decoder/vp9_onyxd_if.c | 36 |
2 files changed, 33 insertions, 41 deletions
diff --git a/vp9/decoder/vp9_dboolhuff.h b/vp9/decoder/vp9_dboolhuff.h index eeb5c35d4..02ae1d3c8 100644 --- a/vp9/decoder/vp9_dboolhuff.h +++ b/vp9/decoder/vp9_dboolhuff.h @@ -88,34 +88,28 @@ static int decode_value(BOOL_DECODER *br, int bits) { int bit; for (bit = bits - 1; bit >= 0; bit--) { - z |= (decode_bool(br, 0x80) << bit); + z |= decode_bool(br, 0x80) << bit; } return z; } static int bool_error(BOOL_DECODER *br) { - /* 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 VP9_LOTS_OF_BITS. So when - * count == VP9_LOTS_OF_BITS - 1, the user's data has been exhausted. - */ - if ((br->count > VP9_BD_VALUE_SIZE) && (br->count < VP9_LOTS_OF_BITS)) { - /* We have tried to decode bits after the end of - * stream was encountered. - */ - return 1; - } - - /* No error. */ - return 0; + // 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 VP9_LOTS_OF_BITS. So when + // count == VP9_LOTS_OF_BITS - 1, the user's data has been exhausted. + // + // 1 if we have tried to decode bits after the end of stream was encountered. + // 0 No error. + return br->count > VP9_BD_VALUE_SIZE && br->count < VP9_LOTS_OF_BITS; } int vp9_decode_unsigned_max(BOOL_DECODER *br, int max); diff --git a/vp9/decoder/vp9_onyxd_if.c b/vp9/decoder/vp9_onyxd_if.c index bcb5897e6..2b61f0aff 100644 --- a/vp9/decoder/vp9_onyxd_if.c +++ b/vp9/decoder/vp9_onyxd_if.c @@ -154,8 +154,8 @@ void vp9_remove_decompressor(VP9D_PTR ptr) { if (!pbi) return; - // Delete sementation map - if (pbi->common.last_frame_seg_map != 0) + // Delete segmentation map + if (pbi->common.last_frame_seg_map) vpx_free(pbi->common.last_frame_seg_map); vp9_remove_common(&pbi->common); @@ -163,6 +163,10 @@ void vp9_remove_decompressor(VP9D_PTR ptr) { vpx_free(pbi); } +static int equal_dimensions(YV12_BUFFER_CONFIG *a, YV12_BUFFER_CONFIG *b) { + return a->y_height == b->y_height && a->y_width == b->y_width && + a->uv_height == b->uv_height && a->uv_width == b->uv_width; +} vpx_codec_err_t vp9_copy_reference_dec(VP9D_PTR ptr, VP9_REFFRAME ref_frame_flag, @@ -176,22 +180,20 @@ vpx_codec_err_t vp9_copy_reference_dec(VP9D_PTR ptr, * vpxenc --test-decode functionality working, and will be replaced in a * later commit that adds VP9-specific controls for this functionality. */ - if (ref_frame_flag == VP9_LAST_FLAG) + if (ref_frame_flag == VP9_LAST_FLAG) { ref_fb_idx = pbi->common.ref_frame_map[0]; - else { + } else { vpx_internal_error(&pbi->common.error, VPX_CODEC_ERROR, "Invalid reference frame"); return pbi->common.error.error_code; } - if (cm->yv12_fb[ref_fb_idx].y_height != sd->y_height || - cm->yv12_fb[ref_fb_idx].y_width != sd->y_width || - cm->yv12_fb[ref_fb_idx].uv_height != sd->uv_height || - cm->yv12_fb[ref_fb_idx].uv_width != sd->uv_width) { + if (!equal_dimensions(&cm->yv12_fb[ref_fb_idx], sd)) { vpx_internal_error(&pbi->common.error, VPX_CODEC_ERROR, "Incorrect buffer dimensions"); - } else + } else { vp8_yv12_copy_frame(&cm->yv12_fb[ref_fb_idx], sd); + } return pbi->common.error.error_code; } @@ -202,7 +204,6 @@ vpx_codec_err_t vp9_set_reference_dec(VP9D_PTR ptr, VP9_REFFRAME ref_frame_flag, VP9D_COMP *pbi = (VP9D_COMP *) ptr; VP9_COMMON *cm = &pbi->common; int *ref_fb_ptr = NULL; - int free_fb; /* TODO(jkoleszar): The decoder doesn't have any real knowledge of what the * encoder is using the frame buffers for. This is just a stub to keep the @@ -221,20 +222,17 @@ vpx_codec_err_t vp9_set_reference_dec(VP9D_PTR ptr, VP9_REFFRAME ref_frame_flag, return pbi->common.error.error_code; } - if (cm->yv12_fb[*ref_fb_ptr].y_height != sd->y_height || - cm->yv12_fb[*ref_fb_ptr].y_width != sd->y_width || - cm->yv12_fb[*ref_fb_ptr].uv_height != sd->uv_height || - cm->yv12_fb[*ref_fb_ptr].uv_width != sd->uv_width) { + if (!equal_dimensions(&cm->yv12_fb[*ref_fb_ptr], sd)) { vpx_internal_error(&pbi->common.error, VPX_CODEC_ERROR, "Incorrect buffer dimensions"); } else { - /* Find an empty frame buffer. */ - free_fb = get_free_fb(cm); - /* Decrease fb_idx_ref_cnt since it will be increased again in - * ref_cnt_fb() below. */ + // Find an empty frame buffer. + const int free_fb = get_free_fb(cm); + // Decrease fb_idx_ref_cnt since it will be increased again in + // ref_cnt_fb() below. cm->fb_idx_ref_cnt[free_fb]--; - /* Manage the reference counters and copy image. */ + // Manage the reference counters and copy image. ref_cnt_fb(cm->fb_idx_ref_cnt, ref_fb_ptr, free_fb); vp8_yv12_copy_frame(sd, &cm->yv12_fb[*ref_fb_ptr]); } |