summaryrefslogtreecommitdiff
path: root/vp9/decoder
diff options
context:
space:
mode:
Diffstat (limited to 'vp9/decoder')
-rw-r--r--vp9/decoder/vp9_decodeframe.c655
-rw-r--r--vp9/decoder/vp9_decodeframe.h10
-rw-r--r--vp9/decoder/vp9_decodemv.c291
-rw-r--r--vp9/decoder/vp9_decodemv.h5
-rw-r--r--vp9/decoder/vp9_decoder.c65
-rw-r--r--vp9/decoder/vp9_decoder.h16
-rw-r--r--vp9/decoder/vp9_detokenize.c60
-rw-r--r--vp9/decoder/vp9_detokenize.h7
-rw-r--r--vp9/decoder/vp9_dsubexp.c32
-rw-r--r--vp9/decoder/vp9_dsubexp.h3
-rw-r--r--vp9/decoder/vp9_dthread.c31
-rw-r--r--vp9/decoder/vp9_dthread.h2
12 files changed, 504 insertions, 673 deletions
diff --git a/vp9/decoder/vp9_decodeframe.c b/vp9/decoder/vp9_decodeframe.c
index 3199b98aa..66dbbc62c 100644
--- a/vp9/decoder/vp9_decodeframe.c
+++ b/vp9/decoder/vp9_decodeframe.c
@@ -48,20 +48,19 @@
static int is_compound_reference_allowed(const VP9_COMMON *cm) {
int i;
for (i = 1; i < REFS_PER_FRAME; ++i)
- if (cm->ref_frame_sign_bias[i + 1] != cm->ref_frame_sign_bias[1])
- return 1;
+ if (cm->ref_frame_sign_bias[i + 1] != cm->ref_frame_sign_bias[1]) return 1;
return 0;
}
static void setup_compound_reference_mode(VP9_COMMON *cm) {
if (cm->ref_frame_sign_bias[LAST_FRAME] ==
- cm->ref_frame_sign_bias[GOLDEN_FRAME]) {
+ cm->ref_frame_sign_bias[GOLDEN_FRAME]) {
cm->comp_fixed_ref = ALTREF_FRAME;
cm->comp_var_ref[0] = LAST_FRAME;
cm->comp_var_ref[1] = GOLDEN_FRAME;
} else if (cm->ref_frame_sign_bias[LAST_FRAME] ==
- cm->ref_frame_sign_bias[ALTREF_FRAME]) {
+ cm->ref_frame_sign_bias[ALTREF_FRAME]) {
cm->comp_fixed_ref = GOLDEN_FRAME;
cm->comp_var_ref[0] = LAST_FRAME;
cm->comp_var_ref[1] = ALTREF_FRAME;
@@ -83,8 +82,7 @@ static int decode_unsigned_max(struct vpx_read_bit_buffer *rb, int max) {
static TX_MODE read_tx_mode(vpx_reader *r) {
TX_MODE tx_mode = vpx_read_literal(r, 2);
- if (tx_mode == ALLOW_32X32)
- tx_mode += vpx_read_bit(r);
+ if (tx_mode == ALLOW_32X32) tx_mode += vpx_read_bit(r);
return tx_mode;
}
@@ -121,9 +119,9 @@ static void read_inter_mode_probs(FRAME_CONTEXT *fc, vpx_reader *r) {
static REFERENCE_MODE read_frame_reference_mode(const VP9_COMMON *cm,
vpx_reader *r) {
if (is_compound_reference_allowed(cm)) {
- return vpx_read_bit(r) ? (vpx_read_bit(r) ? REFERENCE_MODE_SELECT
- : COMPOUND_REFERENCE)
- : SINGLE_REFERENCE;
+ return vpx_read_bit(r)
+ ? (vpx_read_bit(r) ? REFERENCE_MODE_SELECT : COMPOUND_REFERENCE)
+ : SINGLE_REFERENCE;
} else {
return SINGLE_REFERENCE;
}
@@ -151,8 +149,7 @@ static void read_frame_reference_mode_probs(VP9_COMMON *cm, vpx_reader *r) {
static void update_mv_probs(vpx_prob *p, int n, vpx_reader *r) {
int i;
for (i = 0; i < n; ++i)
- if (vpx_read(r, MV_UPDATE_PROB))
- p[i] = (vpx_read_literal(r, 7) << 1) | 1;
+ if (vpx_read(r, MV_UPDATE_PROB)) p[i] = (vpx_read_literal(r, 7) << 1) | 1;
}
static void read_mv_probs(nmv_context *ctx, int allow_hp, vpx_reader *r) {
@@ -184,10 +181,9 @@ static void read_mv_probs(nmv_context *ctx, int allow_hp, vpx_reader *r) {
}
}
-static void inverse_transform_block_inter(MACROBLOCKD* xd, int plane,
- const TX_SIZE tx_size,
- uint8_t *dst, int stride,
- int eob) {
+static void inverse_transform_block_inter(MACROBLOCKD *xd, int plane,
+ const TX_SIZE tx_size, uint8_t *dst,
+ int stride, int eob) {
struct macroblockd_plane *const pd = &xd->plane[plane];
tran_low_t *const dqcoeff = pd->dqcoeff;
assert(eob > 0);
@@ -209,8 +205,7 @@ static void inverse_transform_block_inter(MACROBLOCKD* xd, int plane,
case TX_32X32:
vp9_highbd_idct32x32_add(dqcoeff, dst, stride, eob, xd->bd);
break;
- default:
- assert(0 && "Invalid transform size");
+ default: assert(0 && "Invalid transform size");
}
}
} else {
@@ -218,21 +213,11 @@ static void inverse_transform_block_inter(MACROBLOCKD* xd, int plane,
vp9_iwht4x4_add(dqcoeff, dst, stride, eob);
} else {
switch (tx_size) {
- case TX_4X4:
- vp9_idct4x4_add(dqcoeff, dst, stride, eob);
- break;
- case TX_8X8:
- vp9_idct8x8_add(dqcoeff, dst, stride, eob);
- break;
- case TX_16X16:
- vp9_idct16x16_add(dqcoeff, dst, stride, eob);
- break;
- case TX_32X32:
- vp9_idct32x32_add(dqcoeff, dst, stride, eob);
- break;
- default:
- assert(0 && "Invalid transform size");
- return;
+ case TX_4X4: vp9_idct4x4_add(dqcoeff, dst, stride, eob); break;
+ case TX_8X8: vp9_idct8x8_add(dqcoeff, dst, stride, eob); break;
+ case TX_16X16: vp9_idct16x16_add(dqcoeff, dst, stride, eob); break;
+ case TX_32X32: vp9_idct32x32_add(dqcoeff, dst, stride, eob); break;
+ default: assert(0 && "Invalid transform size"); return;
}
}
}
@@ -241,21 +226,11 @@ static void inverse_transform_block_inter(MACROBLOCKD* xd, int plane,
vp9_iwht4x4_add(dqcoeff, dst, stride, eob);
} else {
switch (tx_size) {
- case TX_4X4:
- vp9_idct4x4_add(dqcoeff, dst, stride, eob);
- break;
- case TX_8X8:
- vp9_idct8x8_add(dqcoeff, dst, stride, eob);
- break;
- case TX_16X16:
- vp9_idct16x16_add(dqcoeff, dst, stride, eob);
- break;
- case TX_32X32:
- vp9_idct32x32_add(dqcoeff, dst, stride, eob);
- break;
- default:
- assert(0 && "Invalid transform size");
- return;
+ case TX_4X4: vp9_idct4x4_add(dqcoeff, dst, stride, eob); break;
+ case TX_8X8: vp9_idct8x8_add(dqcoeff, dst, stride, eob); break;
+ case TX_16X16: vp9_idct16x16_add(dqcoeff, dst, stride, eob); break;
+ case TX_32X32: vp9_idct32x32_add(dqcoeff, dst, stride, eob); break;
+ default: assert(0 && "Invalid transform size"); return;
}
}
#endif // CONFIG_VP9_HIGHBITDEPTH
@@ -272,11 +247,10 @@ static void inverse_transform_block_inter(MACROBLOCKD* xd, int plane,
}
}
-static void inverse_transform_block_intra(MACROBLOCKD* xd, int plane,
+static void inverse_transform_block_intra(MACROBLOCKD *xd, int plane,
const TX_TYPE tx_type,
- const TX_SIZE tx_size,
- uint8_t *dst, int stride,
- int eob) {
+ const TX_SIZE tx_size, uint8_t *dst,
+ int stride, int eob) {
struct macroblockd_plane *const pd = &xd->plane[plane];
tran_low_t *const dqcoeff = pd->dqcoeff;
assert(eob > 0);
@@ -298,8 +272,7 @@ static void inverse_transform_block_intra(MACROBLOCKD* xd, int plane,
case TX_32X32:
vp9_highbd_idct32x32_add(dqcoeff, dst, stride, eob, xd->bd);
break;
- default:
- assert(0 && "Invalid transform size");
+ default: assert(0 && "Invalid transform size");
}
}
} else {
@@ -307,21 +280,13 @@ static void inverse_transform_block_intra(MACROBLOCKD* xd, int plane,
vp9_iwht4x4_add(dqcoeff, dst, stride, eob);
} else {
switch (tx_size) {
- case TX_4X4:
- vp9_iht4x4_add(tx_type, dqcoeff, dst, stride, eob);
- break;
- case TX_8X8:
- vp9_iht8x8_add(tx_type, dqcoeff, dst, stride, eob);
- break;
+ case TX_4X4: vp9_iht4x4_add(tx_type, dqcoeff, dst, stride, eob); break;
+ case TX_8X8: vp9_iht8x8_add(tx_type, dqcoeff, dst, stride, eob); break;
case TX_16X16:
vp9_iht16x16_add(tx_type, dqcoeff, dst, stride, eob);
break;
- case TX_32X32:
- vp9_idct32x32_add(dqcoeff, dst, stride, eob);
- break;
- default:
- assert(0 && "Invalid transform size");
- return;
+ case TX_32X32: vp9_idct32x32_add(dqcoeff, dst, stride, eob); break;
+ default: assert(0 && "Invalid transform size"); return;
}
}
}
@@ -330,21 +295,13 @@ static void inverse_transform_block_intra(MACROBLOCKD* xd, int plane,
vp9_iwht4x4_add(dqcoeff, dst, stride, eob);
} else {
switch (tx_size) {
- case TX_4X4:
- vp9_iht4x4_add(tx_type, dqcoeff, dst, stride, eob);
- break;
- case TX_8X8:
- vp9_iht8x8_add(tx_type, dqcoeff, dst, stride, eob);
- break;
+ case TX_4X4: vp9_iht4x4_add(tx_type, dqcoeff, dst, stride, eob); break;
+ case TX_8X8: vp9_iht8x8_add(tx_type, dqcoeff, dst, stride, eob); break;
case TX_16X16:
vp9_iht16x16_add(tx_type, dqcoeff, dst, stride, eob);
break;
- case TX_32X32:
- vp9_idct32x32_add(dqcoeff, dst, stride, eob);
- break;
- default:
- assert(0 && "Invalid transform size");
- return;
+ case TX_32X32: vp9_idct32x32_add(dqcoeff, dst, stride, eob); break;
+ default: assert(0 && "Invalid transform size"); return;
}
}
#endif // CONFIG_VP9_HIGHBITDEPTH
@@ -363,8 +320,7 @@ static void inverse_transform_block_intra(MACROBLOCKD* xd, int plane,
static void predict_and_reconstruct_intra_block(MACROBLOCKD *const xd,
vpx_reader *r,
- MODE_INFO *const mi,
- int plane,
+ MODE_INFO *const mi, int plane,
int row, int col,
TX_SIZE tx_size) {
struct macroblockd_plane *const pd = &xd->plane[plane];
@@ -373,30 +329,29 @@ static void predict_and_reconstruct_intra_block(MACROBLOCKD *const xd,
dst = &pd->dst.buf[4 * row * pd->dst.stride + 4 * col];
if (mi->sb_type < BLOCK_8X8)
- if (plane == 0)
- mode = xd->mi[0]->bmi[(row << 1) + col].as_mode;
+ if (plane == 0) mode = xd->mi[0]->bmi[(row << 1) + col].as_mode;
- vp9_predict_intra_block(xd, pd->n4_wl, tx_size, mode,
- dst, pd->dst.stride, dst, pd->dst.stride,
- col, row, plane);
+ vp9_predict_intra_block(xd, pd->n4_wl, tx_size, mode, dst, pd->dst.stride,
+ dst, pd->dst.stride, col, row, plane);
if (!mi->skip) {
- const TX_TYPE tx_type = (plane || xd->lossless) ?
- DCT_DCT : intra_mode_to_tx_type_lookup[mode];
- const scan_order *sc = (plane || xd->lossless) ?
- &vp9_default_scan_orders[tx_size] : &vp9_scan_orders[tx_size][tx_type];
- const int eob = vp9_decode_block_tokens(xd, plane, sc, col, row, tx_size,
- r, mi->segment_id);
+ const TX_TYPE tx_type =
+ (plane || xd->lossless) ? DCT_DCT : intra_mode_to_tx_type_lookup[mode];
+ const scan_order *sc = (plane || xd->lossless)
+ ? &vp9_default_scan_orders[tx_size]
+ : &vp9_scan_orders[tx_size][tx_type];
+ const int eob = vp9_decode_block_tokens(xd, plane, sc, col, row, tx_size, r,
+ mi->segment_id);
if (eob > 0) {
- inverse_transform_block_intra(xd, plane, tx_type, tx_size,
- dst, pd->dst.stride, eob);
+ inverse_transform_block_intra(xd, plane, tx_type, tx_size, dst,
+ pd->dst.stride, eob);
}
}
}
static int reconstruct_inter_block(MACROBLOCKD *const xd, vpx_reader *r,
- MODE_INFO *const mi, int plane,
- int row, int col, TX_SIZE tx_size) {
+ MODE_INFO *const mi, int plane, int row,
+ int col, TX_SIZE tx_size) {
struct macroblockd_plane *const pd = &xd->plane[plane];
const scan_order *sc = &vp9_default_scan_orders[tx_size];
const int eob = vp9_decode_block_tokens(xd, plane, sc, col, row, tx_size, r,
@@ -410,9 +365,9 @@ static int reconstruct_inter_block(MACROBLOCKD *const xd, vpx_reader *r,
return eob;
}
-static void build_mc_border(const uint8_t *src, int src_stride,
- uint8_t *dst, int dst_stride,
- int x, int y, int b_w, int b_h, int w, int h) {
+static void build_mc_border(const uint8_t *src, int src_stride, uint8_t *dst,
+ int dst_stride, int x, int y, int b_w, int b_h,
+ int w, int h) {
// Get a pointer to the start of the real data for this row.
const uint8_t *ref_row = src - x - y * src_stride;
@@ -425,39 +380,31 @@ static void build_mc_border(const uint8_t *src, int src_stride,
int right = 0, copy;
int left = x < 0 ? -x : 0;
- if (left > b_w)
- left = b_w;
+ if (left > b_w) left = b_w;
- if (x + b_w > w)
- right = x + b_w - w;
+ if (x + b_w > w) right = x + b_w - w;
- if (right > b_w)
- right = b_w;
+ if (right > b_w) right = b_w;
copy = b_w - left - right;
- if (left)
- memset(dst, ref_row[0], left);
+ if (left) memset(dst, ref_row[0], left);
- if (copy)
- memcpy(dst + left, ref_row + x + left, copy);
+ if (copy) memcpy(dst + left, ref_row + x + left, copy);
- if (right)
- memset(dst + left + copy, ref_row[w - 1], right);
+ if (right) memset(dst + left + copy, ref_row[w - 1], right);
dst += dst_stride;
++y;
- if (y > 0 && y < h)
- ref_row += src_stride;
+ if (y > 0 && y < h) ref_row += src_stride;
} while (--b_h);
}
#if CONFIG_VP9_HIGHBITDEPTH
static void high_build_mc_border(const uint8_t *src8, int src_stride,
- uint16_t *dst, int dst_stride,
- int x, int y, int b_w, int b_h,
- int w, int h) {
+ uint16_t *dst, int dst_stride, int x, int y,
+ int b_w, int b_h, int w, int h) {
// Get a pointer to the start of the real data for this row.
const uint16_t *src = CONVERT_TO_SHORTPTR(src8);
const uint16_t *ref_row = src - x - y * src_stride;
@@ -471,31 +418,24 @@ static void high_build_mc_border(const uint8_t *src8, int src_stride,
int right = 0, copy;
int left = x < 0 ? -x : 0;
- if (left > b_w)
- left = b_w;
+ if (left > b_w) left = b_w;
- if (x + b_w > w)
- right = x + b_w - w;
+ if (x + b_w > w) right = x + b_w - w;
- if (right > b_w)
- right = b_w;
+ if (right > b_w) right = b_w;
copy = b_w - left - right;
- if (left)
- vpx_memset16(dst, ref_row[0], left);
+ if (left) vpx_memset16(dst, ref_row[0], left);
- if (copy)
- memcpy(dst + left, ref_row + x + left, copy * sizeof(uint16_t));
+ if (copy) memcpy(dst + left, ref_row + x + left, copy * sizeof(uint16_t));
- if (right)
- vpx_memset16(dst + left + copy, ref_row[w - 1], right);
+ if (right) vpx_memset16(dst + left + copy, ref_row[w - 1], right);
dst += dst_stride;
++y;
- if (y > 0 && y < h)
- ref_row += src_stride;
+ if (y > 0 && y < h) ref_row += src_stride;
} while (--b_h);
}
#endif // CONFIG_VP9_HIGHBITDEPTH
@@ -504,23 +444,21 @@ static void high_build_mc_border(const uint8_t *src8, int src_stride,
static void extend_and_predict(const uint8_t *buf_ptr1, int pre_buf_stride,
int x0, int y0, int b_w, int b_h,
int frame_width, int frame_height,
- int border_offset,
- uint8_t *const dst, int dst_buf_stride,
- int subpel_x, int subpel_y,
+ int border_offset, uint8_t *const dst,
+ int dst_buf_stride, int subpel_x, int subpel_y,
const InterpKernel *kernel,
- const struct scale_factors *sf,
- MACROBLOCKD *xd,
+ const struct scale_factors *sf, MACROBLOCKD *xd,
int w, int h, int ref, int xs, int ys) {
DECLARE_ALIGNED(16, uint16_t, mc_buf_high[80 * 2 * 80 * 2]);
const uint8_t *buf_ptr;
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
- high_build_mc_border(buf_ptr1, pre_buf_stride, mc_buf_high, b_w,
- x0, y0, b_w, b_h, frame_width, frame_height);
+ high_build_mc_border(buf_ptr1, pre_buf_stride, mc_buf_high, b_w, x0, y0,
+ b_w, b_h, frame_width, frame_height);
buf_ptr = CONVERT_TO_BYTEPTR(mc_buf_high) + border_offset;
} else {
- build_mc_border(buf_ptr1, pre_buf_stride, (uint8_t *)mc_buf_high, b_w,
- x0, y0, b_w, b_h, frame_width, frame_height);
+ build_mc_border(buf_ptr1, pre_buf_stride, (uint8_t *)mc_buf_high, b_w, x0,
+ y0, b_w, b_h, frame_width, frame_height);
buf_ptr = ((uint8_t *)mc_buf_high) + border_offset;
}
@@ -528,46 +466,42 @@ static void extend_and_predict(const uint8_t *buf_ptr1, int pre_buf_stride,
highbd_inter_predictor(buf_ptr, b_w, dst, dst_buf_stride, subpel_x,
subpel_y, sf, w, h, ref, kernel, xs, ys, xd->bd);
} else {
- inter_predictor(buf_ptr, b_w, dst, dst_buf_stride, subpel_x,
- subpel_y, sf, w, h, ref, kernel, xs, ys);
+ inter_predictor(buf_ptr, b_w, dst, dst_buf_stride, subpel_x, subpel_y, sf,
+ w, h, ref, kernel, xs, ys);
}
}
#else
static void extend_and_predict(const uint8_t *buf_ptr1, int pre_buf_stride,
int x0, int y0, int b_w, int b_h,
int frame_width, int frame_height,
- int border_offset,
- uint8_t *const dst, int dst_buf_stride,
- int subpel_x, int subpel_y,
+ int border_offset, uint8_t *const dst,
+ int dst_buf_stride, int subpel_x, int subpel_y,
const InterpKernel *kernel,
- const struct scale_factors *sf,
- int w, int h, int ref, int xs, int ys) {
+ const struct scale_factors *sf, int w, int h,
+ int ref, int xs, int ys) {
DECLARE_ALIGNED(16, uint8_t, mc_buf[80 * 2 * 80 * 2]);
const uint8_t *buf_ptr;
- build_mc_border(buf_ptr1, pre_buf_stride, mc_buf, b_w,
- x0, y0, b_w, b_h, frame_width, frame_height);
+ build_mc_border(buf_ptr1, pre_buf_stride, mc_buf, b_w, x0, y0, b_w, b_h,
+ frame_width, frame_height);
buf_ptr = mc_buf + border_offset;
- inter_predictor(buf_ptr, b_w, dst, dst_buf_stride, subpel_x,
- subpel_y, sf, w, h, ref, kernel, xs, ys);
+ inter_predictor(buf_ptr, b_w, dst, dst_buf_stride, subpel_x, subpel_y, sf, w,
+ h, ref, kernel, xs, ys);
}
#endif // CONFIG_VP9_HIGHBITDEPTH
-static void dec_build_inter_predictors(VPxWorker *const worker, MACROBLOCKD *xd,
- int plane, int bw, int bh, int x,
- int y, int w, int h, int mi_x, int mi_y,
- const InterpKernel *kernel,
- const struct scale_factors *sf,
- struct buf_2d *pre_buf,
- struct buf_2d *dst_buf, const MV* mv,
- RefCntBuffer *ref_frame_buf,
- int is_scaled, int ref) {
+static void dec_build_inter_predictors(
+ VPxWorker *const worker, MACROBLOCKD *xd, int plane, int bw, int bh, int x,
+ int y, int w, int h, int mi_x, int mi_y, const InterpKernel *kernel,
+ const struct scale_factors *sf, struct buf_2d *pre_buf,
+ struct buf_2d *dst_buf, const MV *mv, RefCntBuffer *ref_frame_buf,
+ int is_scaled, int ref) {
struct macroblockd_plane *const pd = &xd->plane[plane];
uint8_t *const dst = dst_buf->buf + dst_buf->stride * y + x;
MV32 scaled_mv;
- int xs, ys, x0, y0, x0_16, y0_16, frame_width, frame_height,
- buf_stride, subpel_x, subpel_y;
+ int xs, ys, x0, y0, x0_16, y0_16, frame_width, frame_height, buf_stride,
+ subpel_x, subpel_y;
uint8_t *ref_frame, *buf_ptr;
// Get reference frame pointer, width and height.
@@ -578,14 +512,13 @@ static void dec_build_inter_predictors(VPxWorker *const worker, MACROBLOCKD *xd,
} else {
frame_width = ref_frame_buf->buf.uv_crop_width;
frame_height = ref_frame_buf->buf.uv_crop_height;
- ref_frame = plane == 1 ? ref_frame_buf->buf.u_buffer
- : ref_frame_buf->buf.v_buffer;
+ ref_frame =
+ plane == 1 ? ref_frame_buf->buf.u_buffer : ref_frame_buf->buf.v_buffer;
}
if (is_scaled) {
- const MV mv_q4 = clamp_mv_to_umv_border_sb(xd, mv, bw, bh,
- pd->subsampling_x,
- pd->subsampling_y);
+ const MV mv_q4 = clamp_mv_to_umv_border_sb(
+ xd, mv, bw, bh, pd->subsampling_x, pd->subsampling_y);
// Co-ordinate of containing block to pixel precision.
int x_start = (-xd->mb_to_left_edge >> (3 + pd->subsampling_x));
int y_start = (-xd->mb_to_top_edge >> (3 + pd->subsampling_y));
@@ -642,8 +575,8 @@ static void dec_build_inter_predictors(VPxWorker *const worker, MACROBLOCKD *xd,
// Do border extension if there is motion or the
// width/height is not a multiple of 8 pixels.
- if (is_scaled || scaled_mv.col || scaled_mv.row ||
- (frame_width & 0x7) || (frame_height & 0x7)) {
+ if (is_scaled || scaled_mv.col || scaled_mv.row || (frame_width & 0x7) ||
+ (frame_height & 0x7)) {
int y1 = ((y0_16 + (h - 1) * ys) >> SUBPEL_BITS) + 1;
// Get reference block bottom right horizontal coordinate.
@@ -665,8 +598,8 @@ static void dec_build_inter_predictors(VPxWorker *const worker, MACROBLOCKD *xd,
// Wait until reference block is ready. Pad 7 more pixels as last 7
// pixels of each superblock row can be changed by next superblock row.
if (worker != NULL)
- vp9_frameworker_wait(worker, ref_frame_buf,
- VPXMAX(0, (y1 + 7)) << (plane == 0 ? 0 : 1));
+ vp9_frameworker_wait(worker, ref_frame_buf, VPXMAX(0, (y1 + 7))
+ << (plane == 0 ? 0 : 1));
// Skip border extension if block is inside the frame.
if (x0 < 0 || x0 > frame_width - 1 || x1 < 0 || x1 > frame_width - 1 ||
@@ -677,11 +610,9 @@ static void dec_build_inter_predictors(VPxWorker *const worker, MACROBLOCKD *xd,
const int b_h = y1 - y0 + 1;
const int border_offset = y_pad * 3 * b_w + x_pad * 3;
- extend_and_predict(buf_ptr1, buf_stride, x0, y0, b_w, b_h,
- frame_width, frame_height, border_offset,
- dst, dst_buf->stride,
- subpel_x, subpel_y,
- kernel, sf,
+ extend_and_predict(buf_ptr1, buf_stride, x0, y0, b_w, b_h, frame_width,
+ frame_height, border_offset, dst, dst_buf->stride,
+ subpel_x, subpel_y, kernel, sf,
#if CONFIG_VP9_HIGHBITDEPTH
xd,
#endif
@@ -693,8 +624,8 @@ static void dec_build_inter_predictors(VPxWorker *const worker, MACROBLOCKD *xd,
// pixels of each superblock row can be changed by next superblock row.
if (worker != NULL) {
const int y1 = (y0_16 + (h - 1) * ys) >> SUBPEL_BITS;
- vp9_frameworker_wait(worker, ref_frame_buf,
- VPXMAX(0, (y1 + 7)) << (plane == 0 ? 0 : 1));
+ vp9_frameworker_wait(worker, ref_frame_buf, VPXMAX(0, (y1 + 7))
+ << (plane == 0 ? 0 : 1));
}
}
#if CONFIG_VP9_HIGHBITDEPTH
@@ -706,14 +637,14 @@ static void dec_build_inter_predictors(VPxWorker *const worker, MACROBLOCKD *xd,
subpel_y, sf, w, h, ref, kernel, xs, ys);
}
#else
- inter_predictor(buf_ptr, buf_stride, dst, dst_buf->stride, subpel_x,
- subpel_y, sf, w, h, ref, kernel, xs, ys);
+ inter_predictor(buf_ptr, buf_stride, dst, dst_buf->stride, subpel_x, subpel_y,
+ sf, w, h, ref, kernel, xs, ys);
#endif // CONFIG_VP9_HIGHBITDEPTH
}
static void dec_build_inter_predictors_sb(VP9Decoder *const pbi,
- MACROBLOCKD *xd,
- int mi_row, int mi_col) {
+ MACROBLOCKD *xd, int mi_row,
+ int mi_col) {
int plane;
const int mi_x = mi_col * MI_SIZE;
const int mi_y = mi_row * MI_SIZE;
@@ -723,8 +654,8 @@ static void dec_build_inter_predictors_sb(VP9Decoder *const pbi,
const int is_compound = has_second_ref(mi);
int ref;
int is_scaled;
- VPxWorker *const fwo = pbi->frame_parallel_decode ?
- pbi->frame_worker_owner : NULL;
+ VPxWorker *const fwo =
+ pbi->frame_parallel_decode ? pbi->frame_worker_owner : NULL;
for (ref = 0; ref < 1 + is_compound; ++ref) {
const MV_REFERENCE_FRAME frame = mi->ref_frame[ref];
@@ -756,10 +687,10 @@ static void dec_build_inter_predictors_sb(VP9Decoder *const pbi,
for (y = 0; y < num_4x4_h; ++y) {
for (x = 0; x < num_4x4_w; ++x) {
const MV mv = average_split_mvs(pd, mi, ref, i++);
- dec_build_inter_predictors(fwo, xd, plane, n4w_x4, n4h_x4,
- 4 * x, 4 * y, 4, 4, mi_x, mi_y, kernel,
- sf, pre_buf, dst_buf, &mv,
- ref_frame_buf, is_scaled, ref);
+ dec_build_inter_predictors(fwo, xd, plane, n4w_x4, n4h_x4, 4 * x,
+ 4 * y, 4, 4, mi_x, mi_y, kernel, sf,
+ pre_buf, dst_buf, &mv, ref_frame_buf,
+ is_scaled, ref);
}
}
}
@@ -773,20 +704,19 @@ static void dec_build_inter_predictors_sb(VP9Decoder *const pbi,
const int n4w_x4 = 4 * num_4x4_w;
const int n4h_x4 = 4 * num_4x4_h;
struct buf_2d *const pre_buf = &pd->pre[ref];
- dec_build_inter_predictors(fwo, xd, plane, n4w_x4, n4h_x4,
- 0, 0, n4w_x4, n4h_x4, mi_x, mi_y, kernel,
- sf, pre_buf, dst_buf, &mv,
- ref_frame_buf, is_scaled, ref);
+ dec_build_inter_predictors(fwo, xd, plane, n4w_x4, n4h_x4, 0, 0, n4w_x4,
+ n4h_x4, mi_x, mi_y, kernel, sf, pre_buf,
+ dst_buf, &mv, ref_frame_buf, is_scaled, ref);
}
}
}
}
-static INLINE TX_SIZE dec_get_uv_tx_size(const MODE_INFO *mi,
- int n4_wl, int n4_hl) {
+static INLINE TX_SIZE dec_get_uv_tx_size(const MODE_INFO *mi, int n4_wl,
+ int n4_hl) {
// get minimum log2 num4x4s dimension
const int x = VPXMIN(n4_wl, n4_hl);
- return VPXMIN(mi->tx_size, x);
+ return VPXMIN(mi->tx_size, x);
}
static INLINE void dec_reset_skip_context(MACROBLOCKD *xd) {
@@ -810,9 +740,8 @@ static void set_plane_n4(MACROBLOCKD *const xd, int bw, int bh, int bwl,
}
static MODE_INFO *set_offsets(VP9_COMMON *const cm, MACROBLOCKD *const xd,
- BLOCK_SIZE bsize, int mi_row, int mi_col,
- int bw, int bh, int x_mis, int y_mis,
- int bwl, int bhl) {
+ BLOCK_SIZE bsize, int mi_row, int mi_col, int bw,
+ int bh, int x_mis, int y_mis, int bwl, int bhl) {
const int offset = mi_row * cm->mi_stride + mi_col;
int x, y;
const TileInfo *const tile = &xd->tile;
@@ -840,9 +769,8 @@ static MODE_INFO *set_offsets(VP9_COMMON *const cm, MACROBLOCKD *const xd,
}
static void decode_block(VP9Decoder *const pbi, MACROBLOCKD *const xd,
- int mi_row, int mi_col,
- vpx_reader *r, BLOCK_SIZE bsize,
- int bwl, int bhl) {
+ int mi_row, int mi_col, vpx_reader *r,
+ BLOCK_SIZE bsize, int bwl, int bhl) {
VP9_COMMON *const cm = &pbi->common;
const int less8x8 = bsize < BLOCK_8X8;
const int bw = 1 << (bwl - 1);
@@ -850,15 +778,15 @@ static void decode_block(VP9Decoder *const pbi, MACROBLOCKD *const xd,
const int x_mis = VPXMIN(bw, cm->mi_cols - mi_col);
const int y_mis = VPXMIN(bh, cm->mi_rows - mi_row);
- MODE_INFO *mi = set_offsets(cm, xd, bsize, mi_row, mi_col,
- bw, bh, x_mis, y_mis, bwl, bhl);
+ MODE_INFO *mi = set_offsets(cm, xd, bsize, mi_row, mi_col, bw, bh, x_mis,
+ y_mis, bwl, bhl);
if (bsize >= BLOCK_8X8 && (cm->subsampling_x || cm->subsampling_y)) {
const BLOCK_SIZE uv_subsize =
ss_size_lookup[bsize][cm->subsampling_x][cm->subsampling_y];
if (uv_subsize == BLOCK_INVALID)
- vpx_internal_error(xd->error_info,
- VPX_CODEC_CORRUPT_FRAME, "Invalid block size.");
+ vpx_internal_error(xd->error_info, VPX_CODEC_CORRUPT_FRAME,
+ "Invalid block size.");
}
vp9_read_mode_info(pbi, xd, mi_row, mi_col, r, x_mis, y_mis);
@@ -872,24 +800,27 @@ static void decode_block(VP9Decoder *const pbi, MACROBLOCKD *const xd,
for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
const struct macroblockd_plane *const pd = &xd->plane[plane];
const TX_SIZE tx_size =
- plane ? dec_get_uv_tx_size(mi, pd->n4_wl, pd->n4_hl)
- : mi->tx_size;
+ plane ? dec_get_uv_tx_size(mi, pd->n4_wl, pd->n4_hl) : mi->tx_size;
const int num_4x4_w = pd->n4_w;
const int num_4x4_h = pd->n4_h;
const int step = (1 << tx_size);
int row, col;
- const int max_blocks_wide = num_4x4_w + (xd->mb_to_right_edge >= 0 ?
- 0 : xd->mb_to_right_edge >> (5 + pd->subsampling_x));
- const int max_blocks_high = num_4x4_h + (xd->mb_to_bottom_edge >= 0 ?
- 0 : xd->mb_to_bottom_edge >> (5 + pd->subsampling_y));
+ const int max_blocks_wide =
+ num_4x4_w + (xd->mb_to_right_edge >= 0
+ ? 0
+ : xd->mb_to_right_edge >> (5 + pd->subsampling_x));
+ const int max_blocks_high =
+ num_4x4_h + (xd->mb_to_bottom_edge >= 0
+ ? 0
+ : xd->mb_to_bottom_edge >> (5 + pd->subsampling_y));
xd->max_blocks_wide = xd->mb_to_right_edge >= 0 ? 0 : max_blocks_wide;
xd->max_blocks_high = xd->mb_to_bottom_edge >= 0 ? 0 : max_blocks_high;
for (row = 0; row < max_blocks_high; row += step)
for (col = 0; col < max_blocks_wide; col += step)
- predict_and_reconstruct_intra_block(xd, r, mi, plane,
- row, col, tx_size);
+ predict_and_reconstruct_intra_block(xd, r, mi, plane, row, col,
+ tx_size);
}
} else {
// Prediction
@@ -903,28 +834,30 @@ static void decode_block(VP9Decoder *const pbi, MACROBLOCKD *const xd,
for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
const struct macroblockd_plane *const pd = &xd->plane[plane];
const TX_SIZE tx_size =
- plane ? dec_get_uv_tx_size(mi, pd->n4_wl, pd->n4_hl)
- : mi->tx_size;
+ plane ? dec_get_uv_tx_size(mi, pd->n4_wl, pd->n4_hl) : mi->tx_size;
const int num_4x4_w = pd->n4_w;
const int num_4x4_h = pd->n4_h;
const int step = (1 << tx_size);
int row, col;
- const int max_blocks_wide = num_4x4_w + (xd->mb_to_right_edge >= 0 ?
- 0 : xd->mb_to_right_edge >> (5 + pd->subsampling_x));
- const int max_blocks_high = num_4x4_h + (xd->mb_to_bottom_edge >= 0 ?
- 0 : xd->mb_to_bottom_edge >> (5 + pd->subsampling_y));
+ const int max_blocks_wide =
+ num_4x4_w + (xd->mb_to_right_edge >= 0
+ ? 0
+ : xd->mb_to_right_edge >> (5 + pd->subsampling_x));
+ const int max_blocks_high =
+ num_4x4_h +
+ (xd->mb_to_bottom_edge >= 0 ? 0 : xd->mb_to_bottom_edge >>
+ (5 + pd->subsampling_y));
xd->max_blocks_wide = xd->mb_to_right_edge >= 0 ? 0 : max_blocks_wide;
xd->max_blocks_high = xd->mb_to_bottom_edge >= 0 ? 0 : max_blocks_high;
for (row = 0; row < max_blocks_high; row += step)
for (col = 0; col < max_blocks_wide; col += step)
- eobtotal += reconstruct_inter_block(xd, r, mi, plane, row, col,
- tx_size);
+ eobtotal +=
+ reconstruct_inter_block(xd, r, mi, plane, row, col, tx_size);
}
- if (!less8x8 && eobtotal == 0)
- mi->skip = 1; // skip loopfilter
+ if (!less8x8 && eobtotal == 0) mi->skip = 1; // skip loopfilter
}
}
@@ -935,21 +868,19 @@ static void decode_block(VP9Decoder *const pbi, MACROBLOCKD *const xd,
}
}
-static INLINE int dec_partition_plane_context(const MACROBLOCKD *xd,
- int mi_row, int mi_col,
- int bsl) {
+static INLINE int dec_partition_plane_context(const MACROBLOCKD *xd, int mi_row,
+ int mi_col, int bsl) {
const PARTITION_CONTEXT *above_ctx = xd->above_seg_context + mi_col;
const PARTITION_CONTEXT *left_ctx = xd->left_seg_context + (mi_row & MI_MASK);
- int above = (*above_ctx >> bsl) & 1 , left = (*left_ctx >> bsl) & 1;
+ int above = (*above_ctx >> bsl) & 1, left = (*left_ctx >> bsl) & 1;
-// assert(bsl >= 0);
+ // assert(bsl >= 0);
return (left * 2 + above) + bsl * PARTITION_PLOFFSET;
}
-static INLINE void dec_update_partition_context(MACROBLOCKD *xd,
- int mi_row, int mi_col,
- BLOCK_SIZE subsize,
+static INLINE void dec_update_partition_context(MACROBLOCKD *xd, int mi_row,
+ int mi_col, BLOCK_SIZE subsize,
int bw) {
PARTITION_CONTEXT *const above_ctx = xd->above_seg_context + mi_col;
PARTITION_CONTEXT *const left_ctx = xd->left_seg_context + (mi_row & MI_MASK);
@@ -962,8 +893,8 @@ static INLINE void dec_update_partition_context(MACROBLOCKD *xd,
}
static PARTITION_TYPE read_partition(MACROBLOCKD *xd, int mi_row, int mi_col,
- vpx_reader *r,
- int has_rows, int has_cols, int bsl) {
+ vpx_reader *r, int has_rows, int has_cols,
+ int bsl) {
const int ctx = dec_partition_plane_context(xd, mi_row, mi_col, bsl);
const vpx_prob *const probs = get_partition_probs(xd, ctx);
FRAME_COUNTS *counts = xd->counts;
@@ -978,16 +909,15 @@ static PARTITION_TYPE read_partition(MACROBLOCKD *xd, int mi_row, int mi_col,
else
p = PARTITION_SPLIT;
- if (counts)
- ++counts->partition[ctx][p];
+ if (counts) ++counts->partition[ctx][p];
return p;
}
// TODO(slavarnway): eliminate bsize and subsize in future commits
static void decode_partition(VP9Decoder *const pbi, MACROBLOCKD *const xd,
- int mi_row, int mi_col,
- vpx_reader* r, BLOCK_SIZE bsize, int n4x4_l2) {
+ int mi_row, int mi_col, vpx_reader *r,
+ BLOCK_SIZE bsize, int n4x4_l2) {
VP9_COMMON *const cm = &pbi->common;
const int n8x8_l2 = n4x4_l2 - 1;
const int num_8x8_wh = 1 << n8x8_l2;
@@ -997,11 +927,10 @@ static void decode_partition(VP9Decoder *const pbi, MACROBLOCKD *const xd,
const int has_rows = (mi_row + hbs) < cm->mi_rows;
const int has_cols = (mi_col + hbs) < cm->mi_cols;
- if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols)
- return;
+ if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) return;
- partition = read_partition(xd, mi_row, mi_col, r, has_rows, has_cols,
- n8x8_l2);
+ partition =
+ read_partition(xd, mi_row, mi_col, r, has_rows, has_cols, n8x8_l2);
subsize = subsize_lookup[partition][bsize]; // get_subsize(bsize, partition);
if (!hbs) {
// calculate bmode block dimensions (log 2)
@@ -1032,8 +961,7 @@ static void decode_partition(VP9Decoder *const pbi, MACROBLOCKD *const xd,
decode_partition(pbi, xd, mi_row + hbs, mi_col + hbs, r, subsize,
n8x8_l2);
break;
- default:
- assert(0 && "Invalid partition type");
+ default: assert(0 && "Invalid partition type");
}
}
@@ -1043,12 +971,10 @@ static void decode_partition(VP9Decoder *const pbi, MACROBLOCKD *const xd,
dec_update_partition_context(xd, mi_row, mi_col, subsize, num_8x8_wh);
}
-static void setup_token_decoder(const uint8_t *data,
- const uint8_t *data_end,
+static void setup_token_decoder(const uint8_t *data, const uint8_t *data_end,
size_t read_size,
struct vpx_internal_error_info *error_info,
- vpx_reader *r,
- vpx_decrypt_cb decrypt_cb,
+ vpx_reader *r, vpx_decrypt_cb decrypt_cb,
void *decrypt_state) {
// Validate the calculated partition length. If the buffer
// described by the partition can't be fully read, then restrict
@@ -1075,12 +1001,11 @@ static void read_coef_probs_common(vp9_coeff_probs_model *coef_probs,
vp9_diff_update_prob(r, &coef_probs[i][j][k][l][m]);
}
-static void read_coef_probs(FRAME_CONTEXT *fc, TX_MODE tx_mode,
- vpx_reader *r) {
- const TX_SIZE max_tx_size = tx_mode_to_biggest_tx_size[tx_mode];
- TX_SIZE tx_size;
- for (tx_size = TX_4X4; tx_size <= max_tx_size; ++tx_size)
- read_coef_probs_common(fc->coef_probs[tx_size], r);
+static void read_coef_probs(FRAME_CONTEXT *fc, TX_MODE tx_mode, vpx_reader *r) {
+ const TX_SIZE max_tx_size = tx_mode_to_biggest_tx_size[tx_mode];
+ TX_SIZE tx_size;
+ for (tx_size = TX_4X4; tx_size <= max_tx_size; ++tx_size)
+ read_coef_probs_common(fc->coef_probs[tx_size], r);
}
static void setup_segmentation(struct segmentation *seg,
@@ -1091,24 +1016,22 @@ static void setup_segmentation(struct segmentation *seg,
seg->update_data = 0;
seg->enabled = vpx_rb_read_bit(rb);
- if (!seg->enabled)
- return;
+ if (!seg->enabled) return;
// Segmentation map update
seg->update_map = vpx_rb_read_bit(rb);
if (seg->update_map) {
for (i = 0; i < SEG_TREE_PROBS; i++)
- seg->tree_probs[i] = vpx_rb_read_bit(rb) ? vpx_rb_read_literal(rb, 8)
- : MAX_PROB;
+ seg->tree_probs[i] =
+ vpx_rb_read_bit(rb) ? vpx_rb_read_literal(rb, 8) : MAX_PROB;
seg->temporal_update = vpx_rb_read_bit(rb);
if (seg->temporal_update) {
for (i = 0; i < PREDICTION_PROBS; i++)
- seg->pred_probs[i] = vpx_rb_read_bit(rb) ? vpx_rb_read_literal(rb, 8)
- : MAX_PROB;
+ seg->pred_probs[i] =
+ vpx_rb_read_bit(rb) ? vpx_rb_read_literal(rb, 8) : MAX_PROB;
} else {
- for (i = 0; i < PREDICTION_PROBS; i++)
- seg->pred_probs[i] = MAX_PROB;
+ for (i = 0; i < PREDICTION_PROBS; i++) seg->pred_probs[i] = MAX_PROB;
}
}
@@ -1172,10 +1095,8 @@ static void setup_quantization(VP9_COMMON *const cm, MACROBLOCKD *const xd,
cm->uv_dc_delta_q = read_delta_q(rb);
cm->uv_ac_delta_q = read_delta_q(rb);
cm->dequant_bit_depth = cm->bit_depth;
- xd->lossless = cm->base_qindex == 0 &&
- cm->y_dc_delta_q == 0 &&
- cm->uv_dc_delta_q == 0 &&
- cm->uv_ac_delta_q == 0;
+ xd->lossless = cm->base_qindex == 0 && cm->y_dc_delta_q == 0 &&
+ cm->uv_dc_delta_q == 0 && cm->uv_ac_delta_q == 0;
#if CONFIG_VP9_HIGHBITDEPTH
xd->bd = (int)cm->bit_depth;
@@ -1188,13 +1109,13 @@ static void setup_segmentation_dequant(VP9_COMMON *const cm) {
int i;
for (i = 0; i < MAX_SEGMENTS; ++i) {
const int qindex = vp9_get_qindex(&cm->seg, i, cm->base_qindex);
- cm->y_dequant[i][0] = vp9_dc_quant(qindex, cm->y_dc_delta_q,
- cm->bit_depth);
+ cm->y_dequant[i][0] =
+ vp9_dc_quant(qindex, cm->y_dc_delta_q, cm->bit_depth);
cm->y_dequant[i][1] = vp9_ac_quant(qindex, 0, cm->bit_depth);
- cm->uv_dequant[i][0] = vp9_dc_quant(qindex, cm->uv_dc_delta_q,
- cm->bit_depth);
- cm->uv_dequant[i][1] = vp9_ac_quant(qindex, cm->uv_ac_delta_q,
- cm->bit_depth);
+ cm->uv_dequant[i][0] =
+ vp9_dc_quant(qindex, cm->uv_dc_delta_q, cm->bit_depth);
+ cm->uv_dequant[i][1] =
+ vp9_ac_quant(qindex, cm->uv_ac_delta_q, cm->bit_depth);
}
} else {
const int qindex = cm->base_qindex;
@@ -1202,18 +1123,16 @@ static void setup_segmentation_dequant(VP9_COMMON *const cm) {
// remaining are don't cares.
cm->y_dequant[0][0] = vp9_dc_quant(qindex, cm->y_dc_delta_q, cm->bit_depth);
cm->y_dequant[0][1] = vp9_ac_quant(qindex, 0, cm->bit_depth);
- cm->uv_dequant[0][0] = vp9_dc_quant(qindex, cm->uv_dc_delta_q,
- cm->bit_depth);
- cm->uv_dequant[0][1] = vp9_ac_quant(qindex, cm->uv_ac_delta_q,
- cm->bit_depth);
+ cm->uv_dequant[0][0] =
+ vp9_dc_quant(qindex, cm->uv_dc_delta_q, cm->bit_depth);
+ cm->uv_dequant[0][1] =
+ vp9_ac_quant(qindex, cm->uv_ac_delta_q, cm->bit_depth);
}
}
static INTERP_FILTER read_interp_filter(struct vpx_read_bit_buffer *rb) {
- const INTERP_FILTER literal_to_filter[] = { EIGHTTAP_SMOOTH,
- EIGHTTAP,
- EIGHTTAP_SHARP,
- BILINEAR };
+ const INTERP_FILTER literal_to_filter[] = { EIGHTTAP_SMOOTH, EIGHTTAP,
+ EIGHTTAP_SHARP, BILINEAR };
return vpx_rb_read_bit(rb) ? SWITCHABLE
: literal_to_filter[vpx_rb_read_literal(rb, 2)];
}
@@ -1245,7 +1164,7 @@ static void resize_context_buffers(VP9_COMMON *cm, int width, int height) {
const int new_mi_rows =
ALIGN_POWER_OF_TWO(height, MI_SIZE_LOG2) >> MI_SIZE_LOG2;
const int new_mi_cols =
- ALIGN_POWER_OF_TWO(width, MI_SIZE_LOG2) >> MI_SIZE_LOG2;
+ ALIGN_POWER_OF_TWO(width, MI_SIZE_LOG2) >> MI_SIZE_LOG2;
// Allocations in vp9_alloc_context_buffers() depend on individual
// dimensions as well as the overall size.
@@ -1275,13 +1194,12 @@ static void setup_frame_size(VP9_COMMON *cm, struct vpx_read_bit_buffer *rb) {
lock_buffer_pool(pool);
if (vpx_realloc_frame_buffer(
- get_frame_new_buffer(cm), cm->width, cm->height,
- cm->subsampling_x, cm->subsampling_y,
+ get_frame_new_buffer(cm), cm->width, cm->height, cm->subsampling_x,
+ cm->subsampling_y,
#if CONFIG_VP9_HIGHBITDEPTH
cm->use_highbitdepth,
#endif
- VP9_DEC_BORDER_IN_PIXELS,
- cm->byte_alignment,
+ VP9_DEC_BORDER_IN_PIXELS, cm->byte_alignment,
&pool->frame_bufs[cm->new_fb_idx].raw_frame_buffer, pool->get_fb_cb,
pool->cb_priv)) {
unlock_buffer_pool(pool);
@@ -1295,7 +1213,7 @@ static void setup_frame_size(VP9_COMMON *cm, struct vpx_read_bit_buffer *rb) {
pool->frame_bufs[cm->new_fb_idx].buf.bit_depth = (unsigned int)cm->bit_depth;
pool->frame_bufs[cm->new_fb_idx].buf.color_space = cm->color_space;
pool->frame_bufs[cm->new_fb_idx].buf.color_range = cm->color_range;
- pool->frame_bufs[cm->new_fb_idx].buf.render_width = cm->render_width;
+ pool->frame_bufs[cm->new_fb_idx].buf.render_width = cm->render_width;
pool->frame_bufs[cm->new_fb_idx].buf.render_height = cm->render_height;
}
@@ -1328,8 +1246,7 @@ static void setup_frame_size_with_refs(VP9_COMMON *cm,
}
}
- if (!found)
- vp9_read_frame_size(rb, &width, &height);
+ if (!found) vp9_read_frame_size(rb, &width, &height);
if (width <= 0 || height <= 0)
vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME,
@@ -1339,10 +1256,10 @@ static void setup_frame_size_with_refs(VP9_COMMON *cm,
// has valid dimensions.
for (i = 0; i < REFS_PER_FRAME; ++i) {
RefBuffer *const ref_frame = &cm->frame_refs[i];
- has_valid_ref_frame |= (ref_frame->idx != INVALID_IDX &&
- valid_ref_frame_size(ref_frame->buf->y_crop_width,
- ref_frame->buf->y_crop_height,
- width, height));
+ has_valid_ref_frame |=
+ (ref_frame->idx != INVALID_IDX &&
+ valid_ref_frame_size(ref_frame->buf->y_crop_width,
+ ref_frame->buf->y_crop_height, width, height));
}
if (!has_valid_ref_frame)
vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME,
@@ -1352,10 +1269,8 @@ static void setup_frame_size_with_refs(VP9_COMMON *cm,
if (ref_frame->idx == INVALID_IDX ||
!valid_ref_frame_img_fmt(ref_frame->buf->bit_depth,
ref_frame->buf->subsampling_x,
- ref_frame->buf->subsampling_y,
- cm->bit_depth,
- cm->subsampling_x,
- cm->subsampling_y))
+ ref_frame->buf->subsampling_y, cm->bit_depth,
+ cm->subsampling_x, cm->subsampling_y))
vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME,
"Referenced frame has incompatible color format");
}
@@ -1365,13 +1280,12 @@ static void setup_frame_size_with_refs(VP9_COMMON *cm,
lock_buffer_pool(pool);
if (vpx_realloc_frame_buffer(
- get_frame_new_buffer(cm), cm->width, cm->height,
- cm->subsampling_x, cm->subsampling_y,
+ get_frame_new_buffer(cm), cm->width, cm->height, cm->subsampling_x,
+ cm->subsampling_y,
#if CONFIG_VP9_HIGHBITDEPTH
cm->use_highbitdepth,
#endif
- VP9_DEC_BORDER_IN_PIXELS,
- cm->byte_alignment,
+ VP9_DEC_BORDER_IN_PIXELS, cm->byte_alignment,
&pool->frame_bufs[cm->new_fb_idx].raw_frame_buffer, pool->get_fb_cb,
pool->cb_priv)) {
unlock_buffer_pool(pool);
@@ -1385,7 +1299,7 @@ static void setup_frame_size_with_refs(VP9_COMMON *cm,
pool->frame_bufs[cm->new_fb_idx].buf.bit_depth = (unsigned int)cm->bit_depth;
pool->frame_bufs[cm->new_fb_idx].buf.color_space = cm->color_space;
pool->frame_bufs[cm->new_fb_idx].buf.color_range = cm->color_range;
- pool->frame_bufs[cm->new_fb_idx].buf.render_width = cm->render_width;
+ pool->frame_bufs[cm->new_fb_idx].buf.render_width = cm->render_width;
pool->frame_bufs[cm->new_fb_idx].buf.render_height = cm->render_height;
}
@@ -1396,8 +1310,7 @@ static void setup_tile_info(VP9_COMMON *cm, struct vpx_read_bit_buffer *rb) {
// columns
max_ones = max_log2_tile_cols - min_log2_tile_cols;
cm->log2_tile_cols = min_log2_tile_cols;
- while (max_ones-- && vpx_rb_read_bit(rb))
- cm->log2_tile_cols++;
+ while (max_ones-- && vpx_rb_read_bit(rb)) cm->log2_tile_cols++;
if (cm->log2_tile_cols > 6)
vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME,
@@ -1405,18 +1318,15 @@ static void setup_tile_info(VP9_COMMON *cm, struct vpx_read_bit_buffer *rb) {
// rows
cm->log2_tile_rows = vpx_rb_read_bit(rb);
- if (cm->log2_tile_rows)
- cm->log2_tile_rows += vpx_rb_read_bit(rb);
+ if (cm->log2_tile_rows) cm->log2_tile_rows += vpx_rb_read_bit(rb);
}
// Reads the next tile returning its size and adjusting '*data' accordingly
// based on 'is_last'.
-static void get_tile_buffer(const uint8_t *const data_end,
- int is_last,
+static void get_tile_buffer(const uint8_t *const data_end, int is_last,
struct vpx_internal_error_info *error_info,
- const uint8_t **data,
- vpx_decrypt_cb decrypt_cb, void *decrypt_state,
- TileBuffer *buf) {
+ const uint8_t **data, vpx_decrypt_cb decrypt_cb,
+ void *decrypt_state, TileBuffer *buf) {
size_t size;
if (!is_last) {
@@ -1446,9 +1356,9 @@ static void get_tile_buffer(const uint8_t *const data_end,
*data += size;
}
-static void get_tile_buffers(VP9Decoder *pbi,
- const uint8_t *data, const uint8_t *data_end,
- int tile_cols, int tile_rows,
+static void get_tile_buffers(VP9Decoder *pbi, const uint8_t *data,
+ const uint8_t *data_end, int tile_cols,
+ int tile_rows,
TileBuffer (*tile_buffers)[1 << 6]) {
int r, c;
@@ -1463,8 +1373,7 @@ static void get_tile_buffers(VP9Decoder *pbi,
}
}
-static const uint8_t *decode_tiles(VP9Decoder *pbi,
- const uint8_t *data,
+static const uint8_t *decode_tiles(VP9Decoder *pbi, const uint8_t *data,
const uint8_t *data_end) {
VP9_COMMON *const cm = &pbi->common;
const VPxWorkerInterface *const winterface = vpx_get_worker_interface();
@@ -1488,7 +1397,7 @@ static const uint8_t *decode_tiles(VP9Decoder *pbi,
}
if (cm->lf.filter_level && !cm->skip_loop_filter) {
- LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1;
+ LFWorkerData *const lf_data = (LFWorkerData *)pbi->lf_worker.data1;
// Be sure to sync as we might be resuming after a failed frame decode.
winterface->sync(&pbi->lf_worker);
vp9_loop_filter_data_reset(lf_data, get_frame_new_buffer(cm), cm,
@@ -1534,26 +1443,26 @@ static const uint8_t *decode_tiles(VP9Decoder *pbi,
for (mi_row = tile.mi_row_start; mi_row < tile.mi_row_end;
mi_row += MI_BLOCK_SIZE) {
for (tile_col = 0; tile_col < tile_cols; ++tile_col) {
- const int col = pbi->inv_tile_order ?
- tile_cols - tile_col - 1 : tile_col;
+ const int col =
+ pbi->inv_tile_order ? tile_cols - tile_col - 1 : tile_col;
tile_data = pbi->tile_worker_data + tile_cols * tile_row + col;
vp9_tile_set_col(&tile, cm, col);
vp9_zero(tile_data->xd.left_context);
vp9_zero(tile_data->xd.left_seg_context);
for (mi_col = tile.mi_col_start; mi_col < tile.mi_col_end;
mi_col += MI_BLOCK_SIZE) {
- decode_partition(pbi, &tile_data->xd, mi_row,
- mi_col, &tile_data->bit_reader, BLOCK_64X64, 4);
+ decode_partition(pbi, &tile_data->xd, mi_row, mi_col,
+ &tile_data->bit_reader, BLOCK_64X64, 4);
}
pbi->mb.corrupted |= tile_data->xd.corrupted;
if (pbi->mb.corrupted)
- vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME,
- "Failed to decode tile data");
+ vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME,
+ "Failed to decode tile data");
}
// Loopfilter one row.
if (cm->lf.filter_level && !cm->skip_loop_filter) {
const int lf_start = mi_row - MI_BLOCK_SIZE;
- LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1;
+ LFWorkerData *const lf_data = (LFWorkerData *)pbi->lf_worker.data1;
// delay the loopfilter by 1 macroblock row.
if (lf_start < 0) continue;
@@ -1574,14 +1483,13 @@ static const uint8_t *decode_tiles(VP9Decoder *pbi,
// still be changed by the longest loopfilter of the next superblock
// row.
if (pbi->frame_parallel_decode)
- vp9_frameworker_broadcast(pbi->cur_buf,
- mi_row << MI_BLOCK_SIZE_LOG2);
+ vp9_frameworker_broadcast(pbi->cur_buf, mi_row << MI_BLOCK_SIZE_LOG2);
}
}
// Loopfilter remaining rows in the frame.
if (cm->lf.filter_level && !cm->skip_loop_filter) {
- LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1;
+ LFWorkerData *const lf_data = (LFWorkerData *)pbi->lf_worker.data1;
winterface->sync(&pbi->lf_worker);
lf_data->start = lf_data->stop;
lf_data->stop = cm->mi_rows;
@@ -1649,13 +1557,12 @@ static int tile_worker_hook(TileWorkerData *const tile_data,
// sorts in descending order
static int compare_tile_buffers(const void *a, const void *b) {
- const TileBuffer *const buf1 = (const TileBuffer*)a;
- const TileBuffer *const buf2 = (const TileBuffer*)b;
+ const TileBuffer *const buf1 = (const TileBuffer *)a;
+ const TileBuffer *const buf2 = (const TileBuffer *)b;
return (int)(buf2->size - buf1->size);
}
-static const uint8_t *decode_tiles_mt(VP9Decoder *pbi,
- const uint8_t *data,
+static const uint8_t *decode_tiles_mt(VP9Decoder *pbi, const uint8_t *data,
const uint8_t *data_end) {
VP9_COMMON *const cm = &pbi->common;
const VPxWorkerInterface *const winterface = vpx_get_worker_interface();
@@ -1745,7 +1652,7 @@ static const uint8_t *decode_tiles_mt(VP9Decoder *pbi,
if (!cm->frame_parallel_decoding_mode) {
for (n = 0; n < num_workers; ++n) {
TileWorkerData *const tile_data =
- (TileWorkerData*)pbi->tile_workers[n].data1;
+ (TileWorkerData *)pbi->tile_workers[n].data1;
vp9_zero(tile_data->counts);
}
}
@@ -1758,7 +1665,7 @@ static const uint8_t *decode_tiles_mt(VP9Decoder *pbi,
for (n = 0; n < num_workers; ++n) {
const int count = base + (remain + n) / num_workers;
VPxWorker *const worker = &pbi->tile_workers[n];
- TileWorkerData *const tile_data = (TileWorkerData*)worker->data1;
+ TileWorkerData *const tile_data = (TileWorkerData *)worker->data1;
tile_data->buf_start = buf_start;
tile_data->buf_end = buf_start + count - 1;
@@ -1776,7 +1683,7 @@ static const uint8_t *decode_tiles_mt(VP9Decoder *pbi,
for (; n > 0; --n) {
VPxWorker *const worker = &pbi->tile_workers[n - 1];
- TileWorkerData *const tile_data = (TileWorkerData*)worker->data1;
+ TileWorkerData *const tile_data = (TileWorkerData *)worker->data1;
// TODO(jzern): The tile may have specific error data associated with
// its vpx_internal_error_info which could be propagated to the main info
// in cm. Additionally once the threads have been synced and an error is
@@ -1790,7 +1697,7 @@ static const uint8_t *decode_tiles_mt(VP9Decoder *pbi,
if (!cm->frame_parallel_decoding_mode) {
for (n = 0; n < num_workers; ++n) {
TileWorkerData *const tile_data =
- (TileWorkerData*)pbi->tile_workers[n].data1;
+ (TileWorkerData *)pbi->tile_workers[n].data1;
vp9_accumulate_frame_counts(&cm->counts, &tile_data->counts, 1);
}
}
@@ -1804,8 +1711,8 @@ static void error_handler(void *data) {
vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, "Truncated packet");
}
-static void read_bitdepth_colorspace_sampling(
- VP9_COMMON *cm, struct vpx_read_bit_buffer *rb) {
+static void read_bitdepth_colorspace_sampling(VP9_COMMON *cm,
+ struct vpx_read_bit_buffer *rb) {
if (cm->profile >= PROFILE_2) {
cm->bit_depth = vpx_rb_read_bit(rb) ? VPX_BITS_12 : VPX_BITS_10;
#if CONFIG_VP9_HIGHBITDEPTH
@@ -1860,8 +1767,8 @@ static size_t read_uncompressed_header(VP9Decoder *pbi,
cm->last_intra_only = cm->intra_only;
if (vpx_rb_read_literal(rb, 2) != VP9_FRAME_MARKER)
- vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM,
- "Invalid frame marker");
+ vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM,
+ "Invalid frame marker");
cm->profile = vp9_read_profile(rb);
#if CONFIG_VP9_HIGHBITDEPTH
@@ -1899,7 +1806,7 @@ static size_t read_uncompressed_header(VP9Decoder *pbi,
return 0;
}
- cm->frame_type = (FRAME_TYPE) vpx_rb_read_bit(rb);
+ cm->frame_type = (FRAME_TYPE)vpx_rb_read_bit(rb);
cm->show_frame = vpx_rb_read_bit(rb);
cm->error_resilient_mode = vpx_rb_read_bit(rb);
@@ -1924,8 +1831,8 @@ static size_t read_uncompressed_header(VP9Decoder *pbi,
} else {
cm->intra_only = cm->show_frame ? 0 : vpx_rb_read_bit(rb);
- cm->reset_frame_context = cm->error_resilient_mode ?
- 0 : vpx_rb_read_literal(rb, 2);
+ cm->reset_frame_context =
+ cm->error_resilient_mode ? 0 : vpx_rb_read_literal(rb, 2);
if (cm->intra_only) {
if (!vp9_read_sync_code(rb))
@@ -1953,7 +1860,7 @@ static size_t read_uncompressed_header(VP9Decoder *pbi,
memset(&cm->ref_frame_map, -1, sizeof(cm->ref_frame_map));
pbi->need_resync = 0;
}
- } else if (pbi->need_resync != 1) { /* Skip if need resync */
+ } else if (pbi->need_resync != 1) { /* Skip if need resync */
pbi->refresh_frame_flags = vpx_rb_read_literal(rb, REF_FRAMES);
for (i = 0; i < REFS_PER_FRAME; ++i) {
const int ref = vpx_rb_read_literal(rb, REF_FRAMES_LOG2);
@@ -1972,16 +1879,14 @@ static size_t read_uncompressed_header(VP9Decoder *pbi,
for (i = 0; i < REFS_PER_FRAME; ++i) {
RefBuffer *const ref_buf = &cm->frame_refs[i];
#if CONFIG_VP9_HIGHBITDEPTH
- vp9_setup_scale_factors_for_frame(&ref_buf->sf,
- ref_buf->buf->y_crop_width,
- ref_buf->buf->y_crop_height,
- cm->width, cm->height,
- cm->use_highbitdepth);
+ vp9_setup_scale_factors_for_frame(
+ &ref_buf->sf, ref_buf->buf->y_crop_width,
+ ref_buf->buf->y_crop_height, cm->width, cm->height,
+ cm->use_highbitdepth);
#else
- vp9_setup_scale_factors_for_frame(&ref_buf->sf,
- ref_buf->buf->y_crop_width,
- ref_buf->buf->y_crop_height,
- cm->width, cm->height);
+ vp9_setup_scale_factors_for_frame(
+ &ref_buf->sf, ref_buf->buf->y_crop_width,
+ ref_buf->buf->y_crop_height, cm->width, cm->height);
#endif
}
}
@@ -1991,7 +1896,7 @@ static size_t read_uncompressed_header(VP9Decoder *pbi,
#endif
get_frame_new_buffer(cm)->color_space = cm->color_space;
get_frame_new_buffer(cm)->color_range = cm->color_range;
- get_frame_new_buffer(cm)->render_width = cm->render_width;
+ get_frame_new_buffer(cm)->render_width = cm->render_width;
get_frame_new_buffer(cm)->render_height = cm->render_height;
if (pbi->need_resync) {
@@ -2003,8 +1908,7 @@ static size_t read_uncompressed_header(VP9Decoder *pbi,
if (!cm->error_resilient_mode) {
cm->refresh_frame_context = vpx_rb_read_bit(rb);
cm->frame_parallel_decoding_mode = vpx_rb_read_bit(rb);
- if (!cm->frame_parallel_decoding_mode)
- vp9_zero(cm->counts);
+ if (!cm->frame_parallel_decoding_mode) vp9_zero(cm->counts);
} else {
cm->refresh_frame_context = 0;
cm->frame_parallel_decoding_mode = 1;
@@ -2070,8 +1974,7 @@ static int read_compressed_header(VP9Decoder *pbi, const uint8_t *data,
"Failed to allocate bool decoder 0");
cm->tx_mode = xd->lossless ? ONLY_4X4 : read_tx_mode(&r);
- if (cm->tx_mode == TX_MODE_SELECT)
- read_tx_mode_probs(&fc->tx_probs, &r);
+ if (cm->tx_mode == TX_MODE_SELECT) read_tx_mode_probs(&fc->tx_probs, &r);
read_coef_probs(fc, cm->tx_mode, &r);
for (k = 0; k < SKIP_CONTEXTS; ++k)
@@ -2083,8 +1986,7 @@ static int read_compressed_header(VP9Decoder *pbi, const uint8_t *data,
read_inter_mode_probs(fc, &r);
- if (cm->interp_filter == SWITCHABLE)
- read_switchable_interp_probs(fc, &r);
+ if (cm->interp_filter == SWITCHABLE) read_switchable_interp_probs(fc, &r);
for (i = 0; i < INTRA_INTER_CONTEXTS; i++)
vp9_diff_update_prob(&r, &fc->intra_inter_prob[i]);
@@ -2109,11 +2011,8 @@ static int read_compressed_header(VP9Decoder *pbi, const uint8_t *data,
}
static struct vpx_read_bit_buffer *init_read_bit_buffer(
- VP9Decoder *pbi,
- struct vpx_read_bit_buffer *rb,
- const uint8_t *data,
- const uint8_t *data_end,
- uint8_t clear_data[MAX_VP9_HEADER_SIZE]) {
+ VP9Decoder *pbi, struct vpx_read_bit_buffer *rb, const uint8_t *data,
+ const uint8_t *data_end, uint8_t clear_data[MAX_VP9_HEADER_SIZE]) {
rb->bit_offset = 0;
rb->error_handler = error_handler;
rb->error_handler_data = &pbi->common;
@@ -2137,8 +2036,8 @@ int vp9_read_sync_code(struct vpx_read_bit_buffer *const rb) {
vpx_rb_read_literal(rb, 8) == VP9_SYNC_CODE_2;
}
-void vp9_read_frame_size(struct vpx_read_bit_buffer *rb,
- int *width, int *height) {
+void vp9_read_frame_size(struct vpx_read_bit_buffer *rb, int *width,
+ int *height) {
*width = vpx_rb_read_literal(rb, 16) + 1;
*height = vpx_rb_read_literal(rb, 16) + 1;
}
@@ -2146,21 +2045,19 @@ void vp9_read_frame_size(struct vpx_read_bit_buffer *rb,
BITSTREAM_PROFILE vp9_read_profile(struct vpx_read_bit_buffer *rb) {
int profile = vpx_rb_read_bit(rb);
profile |= vpx_rb_read_bit(rb) << 1;
- if (profile > 2)
- profile += vpx_rb_read_bit(rb);
- return (BITSTREAM_PROFILE) profile;
+ if (profile > 2) profile += vpx_rb_read_bit(rb);
+ return (BITSTREAM_PROFILE)profile;
}
-void vp9_decode_frame(VP9Decoder *pbi,
- const uint8_t *data, const uint8_t *data_end,
- const uint8_t **p_data_end) {
+void vp9_decode_frame(VP9Decoder *pbi, const uint8_t *data,
+ const uint8_t *data_end, const uint8_t **p_data_end) {
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
struct vpx_read_bit_buffer rb;
int context_updated = 0;
uint8_t clear_data[MAX_VP9_HEADER_SIZE];
- const size_t first_partition_size = read_uncompressed_header(pbi,
- init_read_bit_buffer(pbi, &rb, data, data_end, clear_data));
+ const size_t first_partition_size = read_uncompressed_header(
+ pbi, init_read_bit_buffer(pbi, &rb, data, data_end, clear_data));
const int tile_rows = 1 << cm->log2_tile_rows;
const int tile_cols = 1 << cm->log2_tile_cols;
YV12_BUFFER_CONFIG *const new_fb = get_frame_new_buffer(cm);
@@ -2177,12 +2074,10 @@ void vp9_decode_frame(VP9Decoder *pbi,
vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME,
"Truncated packet or corrupt header length");
- cm->use_prev_frame_mvs = !cm->error_resilient_mode &&
- cm->width == cm->last_width &&
- cm->height == cm->last_height &&
- !cm->last_intra_only &&
- cm->last_show_frame &&
- (cm->last_frame_type != KEY_FRAME);
+ cm->use_prev_frame_mvs =
+ !cm->error_resilient_mode && cm->width == cm->last_width &&
+ cm->height == cm->last_height && !cm->last_intra_only &&
+ cm->last_show_frame && (cm->last_frame_type != KEY_FRAME);
vp9_setup_block_planes(xd, cm->subsampling_x, cm->subsampling_y);
@@ -2221,8 +2116,8 @@ void vp9_decode_frame(VP9Decoder *pbi,
if (pbi->tile_worker_data == NULL ||
(tile_cols * tile_rows) != pbi->total_tiles) {
- const int num_tile_workers = tile_cols * tile_rows +
- ((pbi->max_threads > 1) ? pbi->max_threads : 0);
+ const int num_tile_workers =
+ tile_cols * tile_rows + ((pbi->max_threads > 1) ? pbi->max_threads : 0);
const size_t twd_size = num_tile_workers * sizeof(*pbi->tile_worker_data);
// Ensure tile data offsets will be properly aligned. This may fail on
// platforms without DECLARE_ALIGNED().
@@ -2239,9 +2134,9 @@ void vp9_decode_frame(VP9Decoder *pbi,
if (!cm->skip_loop_filter) {
// If multiple threads are used to decode tiles, then we use those
// threads to do parallel loopfiltering.
- vp9_loop_filter_frame_mt(new_fb, cm, pbi->mb.plane,
- cm->lf.filter_level, 0, 0, pbi->tile_workers,
- pbi->num_tile_workers, &pbi->lf_row_sync);
+ vp9_loop_filter_frame_mt(new_fb, cm, pbi->mb.plane, cm->lf.filter_level,
+ 0, 0, pbi->tile_workers, pbi->num_tile_workers,
+ &pbi->lf_row_sync);
}
} else {
vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME,
diff --git a/vp9/decoder/vp9_decodeframe.h b/vp9/decoder/vp9_decodeframe.h
index ce33cbdbd..44717f546 100644
--- a/vp9/decoder/vp9_decodeframe.h
+++ b/vp9/decoder/vp9_decodeframe.h
@@ -8,7 +8,6 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-
#ifndef VP9_DECODER_VP9_DECODEFRAME_H_
#define VP9_DECODER_VP9_DECODEFRAME_H_
@@ -22,13 +21,12 @@ struct VP9Decoder;
struct vpx_read_bit_buffer;
int vp9_read_sync_code(struct vpx_read_bit_buffer *const rb);
-void vp9_read_frame_size(struct vpx_read_bit_buffer *rb,
- int *width, int *height);
+void vp9_read_frame_size(struct vpx_read_bit_buffer *rb, int *width,
+ int *height);
BITSTREAM_PROFILE vp9_read_profile(struct vpx_read_bit_buffer *rb);
-void vp9_decode_frame(struct VP9Decoder *pbi,
- const uint8_t *data, const uint8_t *data_end,
- const uint8_t **p_data_end);
+void vp9_decode_frame(struct VP9Decoder *pbi, const uint8_t *data,
+ const uint8_t *data_end, const uint8_t **p_data_end);
#ifdef __cplusplus
} // extern "C"
diff --git a/vp9/decoder/vp9_decodemv.c b/vp9/decoder/vp9_decodemv.c
index f9bd6deb2..7358c9a39 100644
--- a/vp9/decoder/vp9_decodemv.c
+++ b/vp9/decoder/vp9_decodemv.c
@@ -33,29 +33,26 @@ static PREDICTION_MODE read_intra_mode_y(VP9_COMMON *cm, MACROBLOCKD *xd,
const PREDICTION_MODE y_mode =
read_intra_mode(r, cm->fc->y_mode_prob[size_group]);
FRAME_COUNTS *counts = xd->counts;
- if (counts)
- ++counts->y_mode[size_group][y_mode];
+ if (counts) ++counts->y_mode[size_group][y_mode];
return y_mode;
}
static PREDICTION_MODE read_intra_mode_uv(VP9_COMMON *cm, MACROBLOCKD *xd,
vpx_reader *r,
PREDICTION_MODE y_mode) {
- const PREDICTION_MODE uv_mode = read_intra_mode(r,
- cm->fc->uv_mode_prob[y_mode]);
+ const PREDICTION_MODE uv_mode =
+ read_intra_mode(r, cm->fc->uv_mode_prob[y_mode]);
FRAME_COUNTS *counts = xd->counts;
- if (counts)
- ++counts->uv_mode[y_mode][uv_mode];
+ if (counts) ++counts->uv_mode[y_mode][uv_mode];
return uv_mode;
}
static PREDICTION_MODE read_inter_mode(VP9_COMMON *cm, MACROBLOCKD *xd,
vpx_reader *r, int ctx) {
- const int mode = vpx_read_tree(r, vp9_inter_mode_tree,
- cm->fc->inter_mode_probs[ctx]);
+ const int mode =
+ vpx_read_tree(r, vp9_inter_mode_tree, cm->fc->inter_mode_probs[ctx]);
FRAME_COUNTS *counts = xd->counts;
- if (counts)
- ++counts->inter_mode[ctx][mode];
+ if (counts) ++counts->inter_mode[ctx][mode];
return NEARESTMV + mode;
}
@@ -76,8 +73,7 @@ static TX_SIZE read_selected_tx_size(VP9_COMMON *cm, MACROBLOCKD *xd,
tx_size += vpx_read(r, tx_probs[2]);
}
- if (counts)
- ++get_tx_counts(max_tx_size, ctx, &counts->tx)[tx_size];
+ if (counts) ++get_tx_counts(max_tx_size, ctx, &counts->tx)[tx_size];
return (TX_SIZE)tx_size;
}
@@ -105,8 +101,8 @@ static int dec_get_segment_id(const VP9_COMMON *cm, const uint8_t *segment_ids,
return segment_id;
}
-static void set_segment_id(VP9_COMMON *cm, int mi_offset,
- int x_mis, int y_mis, int segment_id) {
+static void set_segment_id(VP9_COMMON *cm, int mi_offset, int x_mis, int y_mis,
+ int segment_id) {
int x, y;
assert(segment_id >= 0 && segment_id < MAX_SEGMENTS);
@@ -117,25 +113,24 @@ static void set_segment_id(VP9_COMMON *cm, int mi_offset,
}
static void copy_segment_id(const VP9_COMMON *cm,
- const uint8_t *last_segment_ids,
- uint8_t *current_segment_ids,
- int mi_offset, int x_mis, int y_mis) {
+ const uint8_t *last_segment_ids,
+ uint8_t *current_segment_ids, int mi_offset,
+ int x_mis, int y_mis) {
int x, y;
for (y = 0; y < y_mis; y++)
for (x = 0; x < x_mis; x++)
- current_segment_ids[mi_offset + y * cm->mi_cols + x] = last_segment_ids ?
- last_segment_ids[mi_offset + y * cm->mi_cols + x] : 0;
+ current_segment_ids[mi_offset + y * cm->mi_cols + x] =
+ last_segment_ids ? last_segment_ids[mi_offset + y * cm->mi_cols + x]
+ : 0;
}
-static int read_intra_segment_id(VP9_COMMON *const cm, int mi_offset,
- int x_mis, int y_mis,
- vpx_reader *r) {
+static int read_intra_segment_id(VP9_COMMON *const cm, int mi_offset, int x_mis,
+ int y_mis, vpx_reader *r) {
struct segmentation *const seg = &cm->seg;
int segment_id;
- if (!seg->enabled)
- return 0; // Default for disabled segmentation
+ if (!seg->enabled) return 0; // Default for disabled segmentation
if (!seg->update_map) {
copy_segment_id(cm, cm->last_frame_seg_map, cm->current_frame_seg_map,
@@ -156,12 +151,12 @@ static int read_inter_segment_id(VP9_COMMON *const cm, MACROBLOCKD *const xd,
int predicted_segment_id, segment_id;
const int mi_offset = mi_row * cm->mi_cols + mi_col;
- if (!seg->enabled)
- return 0; // Default for disabled segmentation
+ if (!seg->enabled) return 0; // Default for disabled segmentation
- predicted_segment_id = cm->last_frame_seg_map ?
- dec_get_segment_id(cm, cm->last_frame_seg_map, mi_offset, x_mis, y_mis) :
- 0;
+ predicted_segment_id = cm->last_frame_seg_map
+ ? dec_get_segment_id(cm, cm->last_frame_seg_map,
+ mi_offset, x_mis, y_mis)
+ : 0;
if (!seg->update_map) {
copy_segment_id(cm, cm->last_frame_seg_map, cm->current_frame_seg_map,
@@ -172,8 +167,8 @@ static int read_inter_segment_id(VP9_COMMON *const cm, MACROBLOCKD *const xd,
if (seg->temporal_update) {
const vpx_prob pred_prob = vp9_get_pred_prob_seg_id(seg, xd);
mi->seg_id_predicted = vpx_read(r, pred_prob);
- segment_id = mi->seg_id_predicted ? predicted_segment_id
- : read_segment_id(r, seg);
+ segment_id =
+ mi->seg_id_predicted ? predicted_segment_id : read_segment_id(r, seg);
} else {
segment_id = read_segment_id(r, seg);
}
@@ -181,27 +176,26 @@ static int read_inter_segment_id(VP9_COMMON *const cm, MACROBLOCKD *const xd,
return segment_id;
}
-static int read_skip(VP9_COMMON *cm, const MACROBLOCKD *xd,
- int segment_id, vpx_reader *r) {
+static int read_skip(VP9_COMMON *cm, const MACROBLOCKD *xd, int segment_id,
+ vpx_reader *r) {
if (segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP)) {
return 1;
} else {
const int ctx = vp9_get_skip_context(xd);
const int skip = vpx_read(r, cm->fc->skip_probs[ctx]);
FRAME_COUNTS *counts = xd->counts;
- if (counts)
- ++counts->skip[ctx][skip];
+ if (counts) ++counts->skip[ctx][skip];
return skip;
}
}
static void read_intra_frame_mode_info(VP9_COMMON *const cm,
- MACROBLOCKD *const xd,
- int mi_row, int mi_col, vpx_reader *r,
- int x_mis, int y_mis) {
+ MACROBLOCKD *const xd, int mi_row,
+ int mi_col, vpx_reader *r, int x_mis,
+ int y_mis) {
MODE_INFO *const mi = xd->mi[0];
const MODE_INFO *above_mi = xd->above_mi;
- const MODE_INFO *left_mi = xd->left_mi;
+ const MODE_INFO *left_mi = xd->left_mi;
const BLOCK_SIZE bsize = mi->sb_type;
int i;
const int mi_offset = mi_row * cm->mi_cols + mi_col;
@@ -232,15 +226,14 @@ static void read_intra_frame_mode_info(VP9_COMMON *const cm,
read_intra_mode(r, get_y_mode_probs(mi, above_mi, left_mi, 2));
break;
default:
- mi->mode = read_intra_mode(r,
- get_y_mode_probs(mi, above_mi, left_mi, 0));
+ mi->mode = read_intra_mode(r, get_y_mode_probs(mi, above_mi, left_mi, 0));
}
mi->uv_mode = read_intra_mode(r, vp9_kf_uv_mode_prob[mi->mode]);
}
-static int read_mv_component(vpx_reader *r,
- const nmv_component *mvcomp, int usehp) {
+static int read_mv_component(vpx_reader *r, const nmv_component *mvcomp,
+ int usehp) {
int mag, d, fr, hp;
const int sign = vpx_read(r, mvcomp->sign);
const int mv_class = vpx_read_tree(r, vp9_mv_class_tree, mvcomp->classes);
@@ -255,18 +248,16 @@ static int read_mv_component(vpx_reader *r,
const int n = mv_class + CLASS0_BITS - 1; // number of bits
d = 0;
- for (i = 0; i < n; ++i)
- d |= vpx_read(r, mvcomp->bits[i]) << i;
+ for (i = 0; i < n; ++i) d |= vpx_read(r, mvcomp->bits[i]) << i;
mag = CLASS0_SIZE << (mv_class + 2);
}
// Fractional part
- fr = vpx_read_tree(r, vp9_mv_fp_tree, class0 ? mvcomp->class0_fp[d]
- : mvcomp->fp);
+ fr = vpx_read_tree(r, vp9_mv_fp_tree,
+ class0 ? mvcomp->class0_fp[d] : mvcomp->fp);
// High precision part (if hp is not used, the default value of the hp is 1)
- hp = usehp ? vpx_read(r, class0 ? mvcomp->class0_hp : mvcomp->hp)
- : 1;
+ hp = usehp ? vpx_read(r, class0 ? mvcomp->class0_hp : mvcomp->hp) : 1;
// Result
mag += ((d << 3) | (fr << 1) | hp) + 1;
@@ -274,12 +265,12 @@ static int read_mv_component(vpx_reader *r,
}
static INLINE void read_mv(vpx_reader *r, MV *mv, const MV *ref,
- const nmv_context *ctx,
- nmv_context_counts *counts, int allow_hp) {
+ const nmv_context *ctx, nmv_context_counts *counts,
+ int allow_hp) {
const MV_JOINT_TYPE joint_type =
(MV_JOINT_TYPE)vpx_read_tree(r, vp9_mv_joint_tree, ctx->joints);
const int use_hp = allow_hp && use_mv_hp(ref);
- MV diff = {0, 0};
+ MV diff = { 0, 0 };
if (mv_joint_vertical(joint_type))
diff.row = read_mv_component(r, &ctx->comps[0], use_hp);
@@ -301,8 +292,7 @@ static REFERENCE_MODE read_block_reference_mode(VP9_COMMON *cm,
const REFERENCE_MODE mode =
(REFERENCE_MODE)vpx_read(r, cm->fc->comp_inter_prob[ctx]);
FRAME_COUNTS *counts = xd->counts;
- if (counts)
- ++counts->comp_inter[ctx][mode];
+ if (counts) ++counts->comp_inter[ctx][mode];
return mode; // SINGLE_REFERENCE or COMPOUND_REFERENCE
} else {
return cm->reference_mode;
@@ -311,8 +301,8 @@ static REFERENCE_MODE read_block_reference_mode(VP9_COMMON *cm,
// Read the referncence frame
static void read_ref_frames(VP9_COMMON *const cm, MACROBLOCKD *const xd,
- vpx_reader *r,
- int segment_id, MV_REFERENCE_FRAME ref_frame[2]) {
+ vpx_reader *r, int segment_id,
+ MV_REFERENCE_FRAME ref_frame[2]) {
FRAME_CONTEXT *const fc = cm->fc;
FRAME_COUNTS *counts = xd->counts;
@@ -327,20 +317,17 @@ static void read_ref_frames(VP9_COMMON *const cm, MACROBLOCKD *const xd,
const int idx = cm->ref_frame_sign_bias[cm->comp_fixed_ref];
const int ctx = vp9_get_pred_context_comp_ref_p(cm, xd);
const int bit = vpx_read(r, fc->comp_ref_prob[ctx]);
- if (counts)
- ++counts->comp_ref[ctx][bit];
+ if (counts) ++counts->comp_ref[ctx][bit];
ref_frame[idx] = cm->comp_fixed_ref;
ref_frame[!idx] = cm->comp_var_ref[bit];
} else if (mode == SINGLE_REFERENCE) {
const int ctx0 = vp9_get_pred_context_single_ref_p1(xd);
const int bit0 = vpx_read(r, fc->single_ref_prob[ctx0][0]);
- if (counts)
- ++counts->single_ref[ctx0][0][bit0];
+ if (counts) ++counts->single_ref[ctx0][0][bit0];
if (bit0) {
const int ctx1 = vp9_get_pred_context_single_ref_p2(xd);
const int bit1 = vpx_read(r, fc->single_ref_prob[ctx1][1]);
- if (counts)
- ++counts->single_ref[ctx1][1][bit1];
+ if (counts) ++counts->single_ref[ctx1][1][bit1];
ref_frame[0] = bit1 ? ALTREF_FRAME : GOLDEN_FRAME;
} else {
ref_frame[0] = LAST_FRAME;
@@ -353,16 +340,14 @@ static void read_ref_frames(VP9_COMMON *const cm, MACROBLOCKD *const xd,
}
}
-static INLINE INTERP_FILTER read_switchable_interp_filter(
- VP9_COMMON *const cm, MACROBLOCKD *const xd,
- vpx_reader *r) {
+static INLINE INTERP_FILTER read_switchable_interp_filter(VP9_COMMON *const cm,
+ MACROBLOCKD *const xd,
+ vpx_reader *r) {
const int ctx = get_pred_context_switchable_interp(xd);
- const INTERP_FILTER type =
- (INTERP_FILTER)vpx_read_tree(r, vp9_switchable_interp_tree,
- cm->fc->switchable_interp_prob[ctx]);
+ const INTERP_FILTER type = (INTERP_FILTER)vpx_read_tree(
+ r, vp9_switchable_interp_tree, cm->fc->switchable_interp_prob[ctx]);
FRAME_COUNTS *counts = xd->counts;
- if (counts)
- ++counts->switchable_interp[ctx][type];
+ if (counts) ++counts->switchable_interp[ctx][type];
return type;
}
@@ -379,19 +364,16 @@ static void read_intra_block_mode_info(VP9_COMMON *const cm,
mi->mode = mi->bmi[3].as_mode;
break;
case BLOCK_4X8:
- mi->bmi[0].as_mode = mi->bmi[2].as_mode = read_intra_mode_y(cm, xd,
- r, 0);
+ mi->bmi[0].as_mode = mi->bmi[2].as_mode = read_intra_mode_y(cm, xd, r, 0);
mi->bmi[1].as_mode = mi->bmi[3].as_mode = mi->mode =
read_intra_mode_y(cm, xd, r, 0);
break;
case BLOCK_8X4:
- mi->bmi[0].as_mode = mi->bmi[1].as_mode = read_intra_mode_y(cm, xd,
- r, 0);
+ mi->bmi[0].as_mode = mi->bmi[1].as_mode = read_intra_mode_y(cm, xd, r, 0);
mi->bmi[2].as_mode = mi->bmi[3].as_mode = mi->mode =
read_intra_mode_y(cm, xd, r, 0);
break;
- default:
- mi->mode = read_intra_mode_y(cm, xd, r, size_group_lookup[bsize]);
+ default: mi->mode = read_intra_mode_y(cm, xd, r, size_group_lookup[bsize]);
}
mi->uv_mode = read_intra_mode_uv(cm, xd, r, mi->mode);
@@ -405,8 +387,8 @@ static void read_intra_block_mode_info(VP9_COMMON *const cm,
}
static INLINE int is_mv_valid(const MV *mv) {
- return mv->row > MV_LOW && mv->row < MV_UPP &&
- mv->col > MV_LOW && mv->col < MV_UPP;
+ return mv->row > MV_LOW && mv->row < MV_UPP && mv->col > MV_LOW &&
+ mv->col < MV_UPP;
}
static INLINE void copy_mv_pair(int_mv *dst, const int_mv *src) {
@@ -418,9 +400,8 @@ static INLINE void zero_mv_pair(int_mv *dst) {
}
static INLINE int assign_mv(VP9_COMMON *cm, MACROBLOCKD *xd,
- PREDICTION_MODE mode,
- int_mv mv[2], int_mv ref_mv[2],
- int_mv near_nearest_mv[2],
+ PREDICTION_MODE mode, int_mv mv[2],
+ int_mv ref_mv[2], int_mv near_nearest_mv[2],
int is_compound, int allow_hp, vpx_reader *r) {
int i;
int ret = 1;
@@ -445,9 +426,7 @@ static INLINE int assign_mv(VP9_COMMON *cm, MACROBLOCKD *xd,
zero_mv_pair(mv);
break;
}
- default: {
- return 0;
- }
+ default: { return 0; }
}
return ret;
}
@@ -460,8 +439,7 @@ static int read_is_inter_block(VP9_COMMON *const cm, MACROBLOCKD *const xd,
const int ctx = get_intra_inter_context(xd);
const int is_inter = vpx_read(r, cm->fc->intra_inter_prob[ctx]);
FRAME_COUNTS *counts = xd->counts;
- if (counts)
- ++counts->intra_inter[ctx][is_inter];
+ if (counts) ++counts->intra_inter[ctx][is_inter];
return is_inter;
}
}
@@ -487,35 +465,33 @@ static void fpm_sync(void *const data, int mi_row) {
// already in the list. If it's the second motion vector or early_break
// it will also skip all additional processing and jump to Done!
#define ADD_MV_REF_LIST_EB(mv, refmv_count, mv_ref_list, Done) \
- do { \
- if (refmv_count) { \
- if ((mv).as_int != (mv_ref_list)[0].as_int) { \
- (mv_ref_list)[(refmv_count)] = (mv); \
- refmv_count++; \
- goto Done; \
- } \
- } else { \
- (mv_ref_list)[(refmv_count)++] = (mv); \
- if (early_break) \
- goto Done; \
- } \
+ do { \
+ if (refmv_count) { \
+ if ((mv).as_int != (mv_ref_list)[0].as_int) { \
+ (mv_ref_list)[(refmv_count)] = (mv); \
+ refmv_count++; \
+ goto Done; \
+ } \
+ } else { \
+ (mv_ref_list)[(refmv_count)++] = (mv); \
+ if (early_break) goto Done; \
+ } \
} while (0)
// If either reference frame is different, not INTRA, and they
// are different from each other scale and add the mv to our list.
-#define IF_DIFF_REF_FRAME_ADD_MV_EB(mbmi, ref_frame, ref_sign_bias, \
- refmv_count, mv_ref_list, Done) \
- do { \
- if (is_inter_block(mbmi)) { \
- if ((mbmi)->ref_frame[0] != ref_frame) \
+#define IF_DIFF_REF_FRAME_ADD_MV_EB(mbmi, ref_frame, ref_sign_bias, \
+ refmv_count, mv_ref_list, Done) \
+ do { \
+ if (is_inter_block(mbmi)) { \
+ if ((mbmi)->ref_frame[0] != ref_frame) \
ADD_MV_REF_LIST_EB(scale_mv((mbmi), 0, ref_frame, ref_sign_bias), \
- refmv_count, mv_ref_list, Done); \
- if (has_second_ref(mbmi) && \
- (mbmi)->ref_frame[1] != ref_frame && \
- (mbmi)->mv[1].as_int != (mbmi)->mv[0].as_int) \
+ refmv_count, mv_ref_list, Done); \
+ if (has_second_ref(mbmi) && (mbmi)->ref_frame[1] != ref_frame && \
+ (mbmi)->mv[1].as_int != (mbmi)->mv[0].as_int) \
ADD_MV_REF_LIST_EB(scale_mv((mbmi), 1, ref_frame, ref_sign_bias), \
- refmv_count, mv_ref_list, Done); \
- } \
+ refmv_count, mv_ref_list, Done); \
+ } \
} while (0)
// This function searches the neighborhood of a given MB/SB
@@ -523,14 +499,16 @@ static void fpm_sync(void *const data, int mi_row) {
static int dec_find_mv_refs(const VP9_COMMON *cm, const MACROBLOCKD *xd,
PREDICTION_MODE mode, MV_REFERENCE_FRAME ref_frame,
const POSITION *const mv_ref_search,
- int_mv *mv_ref_list,
- int mi_row, int mi_col, int block, int is_sub8x8,
- find_mv_refs_sync sync, void *const data) {
+ int_mv *mv_ref_list, int mi_row, int mi_col,
+ int block, int is_sub8x8, find_mv_refs_sync sync,
+ void *const data) {
const int *ref_sign_bias = cm->ref_frame_sign_bias;
int i, refmv_count = 0;
int different_ref_found = 0;
- const MV_REF *const prev_frame_mvs = cm->use_prev_frame_mvs ?
- cm->prev_frame->mvs + mi_row * cm->mi_cols + mi_col : NULL;
+ const MV_REF *const prev_frame_mvs =
+ cm->use_prev_frame_mvs
+ ? cm->prev_frame->mvs + mi_row * cm->mi_cols + mi_col
+ : NULL;
const TileInfo *const tile = &xd->tile;
// If mode is nearestmv or newmv (uses nearestmv as a reference) then stop
// searching after the first mv is found.
@@ -553,11 +531,11 @@ static int dec_find_mv_refs(const VP9_COMMON *cm, const MACROBLOCKD *xd,
if (candidate_mi->ref_frame[0] == ref_frame)
ADD_MV_REF_LIST_EB(
get_sub_block_mv(candidate_mi, 0, mv_ref->col, block),
- refmv_count, mv_ref_list, Done);
+ refmv_count, mv_ref_list, Done);
else if (candidate_mi->ref_frame[1] == ref_frame)
ADD_MV_REF_LIST_EB(
get_sub_block_mv(candidate_mi, 1, mv_ref->col, block),
- refmv_count, mv_ref_list, Done);
+ refmv_count, mv_ref_list, Done);
}
}
}
@@ -579,14 +557,14 @@ static int dec_find_mv_refs(const VP9_COMMON *cm, const MACROBLOCKD *xd,
}
}
- // TODO(hkuang): Remove this sync after fixing pthread_cond_broadcast
- // on windows platform. The sync here is unnecessary if use_prev_frame_mvs
- // is 0. But after removing it, there will be hang in the unit test on windows
- // due to several threads waiting for a thread's signal.
+// TODO(hkuang): Remove this sync after fixing pthread_cond_broadcast
+// on windows platform. The sync here is unnecessary if use_prev_frame_mvs
+// is 0. But after removing it, there will be hang in the unit test on windows
+// due to several threads waiting for a thread's signal.
#if defined(_WIN32) && !HAVE_PTHREAD_H
- if (cm->frame_parallel_decode && sync != NULL) {
- sync(data, mi_row);
- }
+ if (cm->frame_parallel_decode && sync != NULL) {
+ sync(data, mi_row);
+ }
#endif
// Check the last frame's mode and mv info.
@@ -652,10 +630,9 @@ static int dec_find_mv_refs(const VP9_COMMON *cm, const MACROBLOCKD *xd,
// we only care about the nearestmv for the remaining modes
refmv_count = 1;
- Done:
+Done:
// Clamp vectors
- for (i = 0; i < refmv_count; ++i)
- clamp_mv_ref(&mv_ref_list[i].as_mv, xd);
+ for (i = 0; i < refmv_count; ++i) clamp_mv_ref(&mv_ref_list[i].as_mv, xd);
return refmv_count;
}
@@ -673,14 +650,12 @@ static void append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd,
assert(MAX_MV_REF_CANDIDATES == 2);
- refmv_count = dec_find_mv_refs(cm, xd, b_mode, mi->ref_frame[ref],
- mv_ref_search, mv_list, mi_row, mi_col, block,
- 1, NULL, NULL);
+ refmv_count =
+ dec_find_mv_refs(cm, xd, b_mode, mi->ref_frame[ref], mv_ref_search,
+ mv_list, mi_row, mi_col, block, 1, NULL, NULL);
switch (block) {
- case 0:
- best_sub8x8->as_int = mv_list[refmv_count - 1].as_int;
- break;
+ case 0: best_sub8x8->as_int = mv_list[refmv_count - 1].as_int; break;
case 1:
case 2:
if (b_mode == NEARESTMV) {
@@ -711,14 +686,13 @@ static void append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd,
}
}
break;
- default:
- assert(0 && "Invalid block index.");
+ default: assert(0 && "Invalid block index.");
}
}
static uint8_t get_mode_context(const VP9_COMMON *cm, const MACROBLOCKD *xd,
- const POSITION *const mv_ref_search,
- int mi_row, int mi_col) {
+ const POSITION *const mv_ref_search, int mi_row,
+ int mi_col) {
int i;
int context_counter = 0;
const TileInfo *const tile = &xd->tile;
@@ -739,8 +713,8 @@ static uint8_t get_mode_context(const VP9_COMMON *cm, const MACROBLOCKD *xd,
static void read_inter_block_mode_info(VP9Decoder *const pbi,
MACROBLOCKD *const xd,
- MODE_INFO *const mi,
- int mi_row, int mi_col, vpx_reader *r) {
+ MODE_INFO *const mi, int mi_row,
+ int mi_col, vpx_reader *r) {
VP9_COMMON *const cm = &pbi->common;
const BLOCK_SIZE bsize = mi->sb_type;
const int allow_hp = cm->allow_high_precision_mv;
@@ -756,9 +730,9 @@ static void read_inter_block_mode_info(VP9Decoder *const pbi,
if (segfeature_active(&cm->seg, mi->segment_id, SEG_LVL_SKIP)) {
mi->mode = ZEROMV;
if (bsize < BLOCK_8X8) {
- vpx_internal_error(xd->error_info, VPX_CODEC_UNSUP_BITSTREAM,
- "Invalid usage of segement feature on small blocks");
- return;
+ vpx_internal_error(xd->error_info, VPX_CODEC_UNSUP_BITSTREAM,
+ "Invalid usage of segement feature on small blocks");
+ return;
}
} else {
if (bsize >= BLOCK_8X8)
@@ -776,9 +750,9 @@ static void read_inter_block_mode_info(VP9Decoder *const pbi,
const MV_REFERENCE_FRAME frame = mi->ref_frame[ref];
int refmv_count;
- refmv_count = dec_find_mv_refs(cm, xd, mi->mode, frame, mv_ref_search,
- tmp_mvs, mi_row, mi_col, -1, 0,
- fpm_sync, (void *)pbi);
+ refmv_count =
+ dec_find_mv_refs(cm, xd, mi->mode, frame, mv_ref_search, tmp_mvs,
+ mi_row, mi_col, -1, 0, fpm_sync, (void *)pbi);
dec_find_best_ref_mvs(allow_hp, tmp_mvs, &best_ref_mvs[ref],
refmv_count);
@@ -787,8 +761,8 @@ static void read_inter_block_mode_info(VP9Decoder *const pbi,
}
mi->interp_filter = (cm->interp_filter == SWITCHABLE)
- ? read_switchable_interp_filter(cm, xd, r)
- : cm->interp_filter;
+ ? read_switchable_interp_filter(cm, xd, r)
+ : cm->interp_filter;
if (bsize < BLOCK_8X8) {
const int num_4x4_w = 1 << xd->bmode_blocks_wl;
@@ -813,10 +787,8 @@ static void read_inter_block_mode_info(VP9Decoder *const pbi,
break;
}
- if (num_4x4_h == 2)
- mi->bmi[j + 2] = mi->bmi[j];
- if (num_4x4_w == 2)
- mi->bmi[j + 1] = mi->bmi[j];
+ if (num_4x4_h == 2) mi->bmi[j + 2] = mi->bmi[j];
+ if (num_4x4_w == 2) mi->bmi[j + 1] = mi->bmi[j];
}
}
@@ -830,15 +802,15 @@ static void read_inter_block_mode_info(VP9Decoder *const pbi,
}
static void read_inter_frame_mode_info(VP9Decoder *const pbi,
- MACROBLOCKD *const xd,
- int mi_row, int mi_col, vpx_reader *r,
- int x_mis, int y_mis) {
+ MACROBLOCKD *const xd, int mi_row,
+ int mi_col, vpx_reader *r, int x_mis,
+ int y_mis) {
VP9_COMMON *const cm = &pbi->common;
MODE_INFO *const mi = xd->mi[0];
int inter_block;
- mi->segment_id = read_inter_segment_id(cm, xd, mi_row, mi_col, r, x_mis,
- y_mis);
+ mi->segment_id =
+ read_inter_segment_id(cm, xd, mi_row, mi_col, r, x_mis, y_mis);
mi->skip = read_skip(cm, xd, mi->segment_id, r);
inter_block = read_is_inter_block(cm, xd, mi->segment_id, r);
mi->tx_size = read_tx_size(cm, xd, !mi->skip || !inter_block, r);
@@ -854,12 +826,11 @@ static INLINE void copy_ref_frame_pair(MV_REFERENCE_FRAME *dst,
memcpy(dst, src, sizeof(*dst) * 2);
}
-void vp9_read_mode_info(VP9Decoder *const pbi, MACROBLOCKD *xd,
- int mi_row, int mi_col, vpx_reader *r,
- int x_mis, int y_mis) {
+void vp9_read_mode_info(VP9Decoder *const pbi, MACROBLOCKD *xd, int mi_row,
+ int mi_col, vpx_reader *r, int x_mis, int y_mis) {
VP9_COMMON *const cm = &pbi->common;
MODE_INFO *const mi = xd->mi[0];
- MV_REF* frame_mvs = cm->cur_frame->mvs + mi_row * cm->mi_cols + mi_col;
+ MV_REF *frame_mvs = cm->cur_frame->mvs + mi_row * cm->mi_cols + mi_col;
int w, h;
if (frame_is_intra_only(cm)) {
@@ -876,7 +847,7 @@ void vp9_read_mode_info(VP9Decoder *const pbi, MACROBLOCKD *xd,
frame_mvs += cm->mi_cols;
}
}
-#if 0 // CONFIG_BETTER_HW_COMPATIBILITY && CONFIG_VP9_HIGHBITDEPTH
+#if 0 // CONFIG_BETTER_HW_COMPATIBILITY && CONFIG_VP9_HIGHBITDEPTH
if ((xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) &&
(xd->above_mi == NULL || xd->left_mi == NULL) &&
!is_inter_block(mi) && need_top_left[mi->uv_mode])
diff --git a/vp9/decoder/vp9_decodemv.h b/vp9/decoder/vp9_decodemv.h
index 45569ec81..4e11c2fc0 100644
--- a/vp9/decoder/vp9_decodemv.h
+++ b/vp9/decoder/vp9_decodemv.h
@@ -19,9 +19,8 @@
extern "C" {
#endif
-void vp9_read_mode_info(VP9Decoder *const pbi, MACROBLOCKD *xd,
- int mi_row, int mi_col, vpx_reader *r,
- int x_mis, int y_mis);
+void vp9_read_mode_info(VP9Decoder *const pbi, MACROBLOCKD *xd, int mi_row,
+ int mi_col, vpx_reader *r, int x_mis, int y_mis);
#ifdef __cplusplus
} // extern "C"
diff --git a/vp9/decoder/vp9_decoder.c b/vp9/decoder/vp9_decoder.c
index 9ed980081..37693f094 100644
--- a/vp9/decoder/vp9_decoder.c
+++ b/vp9/decoder/vp9_decoder.c
@@ -57,12 +57,10 @@ static void vp9_dec_setup_mi(VP9_COMMON *cm) {
static int vp9_dec_alloc_mi(VP9_COMMON *cm, int mi_size) {
cm->mip = vpx_calloc(mi_size, sizeof(*cm->mip));
- if (!cm->mip)
- return 1;
+ if (!cm->mip) return 1;
cm->mi_alloc_size = mi_size;
- cm->mi_grid_base = (MODE_INFO **)vpx_calloc(mi_size, sizeof(MODE_INFO*));
- if (!cm->mi_grid_base)
- return 1;
+ cm->mi_grid_base = (MODE_INFO **)vpx_calloc(mi_size, sizeof(MODE_INFO *));
+ if (!cm->mi_grid_base) return 1;
return 0;
}
@@ -77,8 +75,7 @@ VP9Decoder *vp9_decoder_create(BufferPool *const pool) {
VP9Decoder *volatile const pbi = vpx_memalign(32, sizeof(*pbi));
VP9_COMMON *volatile const cm = pbi ? &pbi->common : NULL;
- if (!cm)
- return NULL;
+ if (!cm) return NULL;
vp9_zero(*pbi);
@@ -90,11 +87,10 @@ VP9Decoder *vp9_decoder_create(BufferPool *const pool) {
cm->error.setjmp = 1;
- CHECK_MEM_ERROR(cm, cm->fc,
- (FRAME_CONTEXT *)vpx_calloc(1, sizeof(*cm->fc)));
- CHECK_MEM_ERROR(cm, cm->frame_contexts,
- (FRAME_CONTEXT *)vpx_calloc(FRAME_CONTEXTS,
- sizeof(*cm->frame_contexts)));
+ CHECK_MEM_ERROR(cm, cm->fc, (FRAME_CONTEXT *)vpx_calloc(1, sizeof(*cm->fc)));
+ CHECK_MEM_ERROR(
+ cm, cm->frame_contexts,
+ (FRAME_CONTEXT *)vpx_calloc(FRAME_CONTEXTS, sizeof(*cm->frame_contexts)));
pbi->need_resync = 1;
once(initialize_dec);
@@ -126,8 +122,7 @@ VP9Decoder *vp9_decoder_create(BufferPool *const pool) {
void vp9_decoder_remove(VP9Decoder *pbi) {
int i;
- if (!pbi)
- return;
+ if (!pbi) return;
vpx_get_worker_interface()->end(&pbi->lf_worker);
vpx_free(pbi->lf_worker.data1);
@@ -149,8 +144,8 @@ void vp9_decoder_remove(VP9Decoder *pbi) {
static int equal_dimensions(const YV12_BUFFER_CONFIG *a,
const 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;
+ 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(VP9Decoder *pbi,
@@ -176,14 +171,12 @@ vpx_codec_err_t vp9_copy_reference_dec(VP9Decoder *pbi,
else
vp8_yv12_copy_frame(cfg, sd);
} else {
- vpx_internal_error(&cm->error, VPX_CODEC_ERROR,
- "Invalid reference frame");
+ vpx_internal_error(&cm->error, VPX_CODEC_ERROR, "Invalid reference frame");
}
return cm->error.error_code;
}
-
vpx_codec_err_t vp9_set_reference_dec(VP9_COMMON *cm,
VP9_REFFRAME ref_frame_flag,
YV12_BUFFER_CONFIG *sd) {
@@ -206,8 +199,7 @@ vpx_codec_err_t vp9_set_reference_dec(VP9_COMMON *cm,
} else if (ref_frame_flag == VP9_ALT_FLAG) {
idx = cm->ref_frame_map[2];
} else {
- vpx_internal_error(&cm->error, VPX_CODEC_ERROR,
- "Invalid reference frame");
+ vpx_internal_error(&cm->error, VPX_CODEC_ERROR, "Invalid reference frame");
return cm->error.error_code;
}
@@ -273,8 +265,8 @@ static void swap_frame_buffers(VP9Decoder *pbi) {
cm->frame_refs[ref_index].idx = -1;
}
-int vp9_receive_compressed_data(VP9Decoder *pbi,
- size_t size, const uint8_t **psource) {
+int vp9_receive_compressed_data(VP9Decoder *pbi, size_t size,
+ const uint8_t **psource) {
VP9_COMMON *volatile const cm = &pbi->common;
BufferPool *volatile const pool = cm->buffer_pool;
RefCntBuffer *volatile const frame_bufs = cm->buffer_pool->frame_bufs;
@@ -301,8 +293,8 @@ int vp9_receive_compressed_data(VP9Decoder *pbi,
// Check if the previous frame was a frame without any references to it.
// Release frame buffer if not decoding in frame parallel mode.
- if (!pbi->frame_parallel_decode && cm->new_fb_idx >= 0
- && frame_bufs[cm->new_fb_idx].ref_count == 0)
+ if (!pbi->frame_parallel_decode && cm->new_fb_idx >= 0 &&
+ frame_bufs[cm->new_fb_idx].ref_count == 0)
pool->release_fb_cb(pool->cb_priv,
&frame_bufs[cm->new_fb_idx].raw_frame_buffer);
// Find a free frame buffer. Return error if can not find any.
@@ -330,7 +322,6 @@ int vp9_receive_compressed_data(VP9Decoder *pbi,
pbi->cur_buf = &frame_bufs[cm->new_fb_idx];
}
-
if (setjmp(cm->error.jmp)) {
const VPxWorkerInterface *const winterface = vpx_get_worker_interface();
int i;
@@ -425,14 +416,12 @@ int vp9_get_raw_frame(VP9Decoder *pbi, YV12_BUFFER_CONFIG *sd,
(void)*flags;
#endif
- if (pbi->ready_for_new_data == 1)
- return ret;
+ if (pbi->ready_for_new_data == 1) return ret;
pbi->ready_for_new_data = 1;
/* no raw frame to show!!! */
- if (!cm->show_frame)
- return ret;
+ if (!cm->show_frame) return ret;
pbi->ready_for_new_data = 1;
@@ -451,8 +440,7 @@ int vp9_get_raw_frame(VP9Decoder *pbi, YV12_BUFFER_CONFIG *sd,
return ret;
}
-vpx_codec_err_t vp9_parse_superframe_index(const uint8_t *data,
- size_t data_sz,
+vpx_codec_err_t vp9_parse_superframe_index(const uint8_t *data, size_t data_sz,
uint32_t sizes[8], int *count,
vpx_decrypt_cb decrypt_cb,
void *decrypt_state) {
@@ -475,18 +463,16 @@ vpx_codec_err_t vp9_parse_superframe_index(const uint8_t *data,
// This chunk is marked as having a superframe index but doesn't have
// enough data for it, thus it's an invalid superframe index.
- if (data_sz < index_sz)
- return VPX_CODEC_CORRUPT_FRAME;
+ if (data_sz < index_sz) return VPX_CODEC_CORRUPT_FRAME;
{
- const uint8_t marker2 = read_marker(decrypt_cb, decrypt_state,
- data + data_sz - index_sz);
+ const uint8_t marker2 =
+ read_marker(decrypt_cb, decrypt_state, data + data_sz - index_sz);
// This chunk is marked as having a superframe index but doesn't have
// the matching marker byte at the front of the index therefore it's an
// invalid chunk.
- if (marker != marker2)
- return VPX_CODEC_CORRUPT_FRAME;
+ if (marker != marker2) return VPX_CODEC_CORRUPT_FRAME;
}
{
@@ -505,8 +491,7 @@ vpx_codec_err_t vp9_parse_superframe_index(const uint8_t *data,
for (i = 0; i < frames; ++i) {
uint32_t this_sz = 0;
- for (j = 0; j < mag; ++j)
- this_sz |= ((uint32_t)(*x++)) << (j * 8);
+ for (j = 0; j < mag; ++j) this_sz |= ((uint32_t)(*x++)) << (j * 8);
sizes[i] = this_sz;
}
*count = frames;
diff --git a/vp9/decoder/vp9_decoder.h b/vp9/decoder/vp9_decoder.h
index 7111a36d3..427baf1e0 100644
--- a/vp9/decoder/vp9_decoder.h
+++ b/vp9/decoder/vp9_decoder.h
@@ -57,9 +57,9 @@ typedef struct VP9Decoder {
// TODO(hkuang): Combine this with cur_buf in macroblockd as they are
// the same.
- RefCntBuffer *cur_buf; // Current decoding frame buffer.
+ RefCntBuffer *cur_buf; // Current decoding frame buffer.
- VPxWorker *frame_worker_owner; // frame_worker that owns this pbi.
+ VPxWorker *frame_worker_owner; // frame_worker that owns this pbi.
VPxWorker lf_worker;
VPxWorker *tile_workers;
TileWorkerData *tile_worker_data;
@@ -74,12 +74,12 @@ typedef struct VP9Decoder {
int max_threads;
int inv_tile_order;
- int need_resync; // wait for key/intra-only frame.
+ int need_resync; // wait for key/intra-only frame.
int hold_ref_buf; // hold the reference buffer.
} VP9Decoder;
-int vp9_receive_compressed_data(struct VP9Decoder *pbi,
- size_t size, const uint8_t **dest);
+int vp9_receive_compressed_data(struct VP9Decoder *pbi, size_t size,
+ const uint8_t **dest);
int vp9_get_raw_frame(struct VP9Decoder *pbi, YV12_BUFFER_CONFIG *sd,
vp9_ppflags_t *flags);
@@ -93,8 +93,7 @@ vpx_codec_err_t vp9_set_reference_dec(VP9_COMMON *cm,
YV12_BUFFER_CONFIG *sd);
static INLINE uint8_t read_marker(vpx_decrypt_cb decrypt_cb,
- void *decrypt_state,
- const uint8_t *data) {
+ void *decrypt_state, const uint8_t *data) {
if (decrypt_cb) {
uint8_t marker;
decrypt_cb(decrypt_state, data, &marker, 1);
@@ -105,8 +104,7 @@ static INLINE uint8_t read_marker(vpx_decrypt_cb decrypt_cb,
// This function is exposed for use in tests, as well as the inlined function
// "read_marker".
-vpx_codec_err_t vp9_parse_superframe_index(const uint8_t *data,
- size_t data_sz,
+vpx_codec_err_t vp9_parse_superframe_index(const uint8_t *data, size_t data_sz,
uint32_t sizes[8], int *count,
vpx_decrypt_cb decrypt_cb,
void *decrypt_state);
diff --git a/vp9/decoder/vp9_detokenize.c b/vp9/decoder/vp9_detokenize.c
index 47dc107fe..cc01909ff 100644
--- a/vp9/decoder/vp9_detokenize.c
+++ b/vp9/decoder/vp9_detokenize.c
@@ -20,25 +20,22 @@
#include "vp9/decoder/vp9_detokenize.h"
-#define EOB_CONTEXT_NODE 0
-#define ZERO_CONTEXT_NODE 1
-#define ONE_CONTEXT_NODE 2
-
-#define INCREMENT_COUNT(token) \
- do { \
- if (counts) \
- ++coef_counts[band][ctx][token]; \
+#define EOB_CONTEXT_NODE 0
+#define ZERO_CONTEXT_NODE 1
+#define ONE_CONTEXT_NODE 2
+
+#define INCREMENT_COUNT(token) \
+ do { \
+ if (counts) ++coef_counts[band][ctx][token]; \
} while (0)
static INLINE int read_coeff(const vpx_prob *probs, int n, vpx_reader *r) {
int i, val = 0;
- for (i = 0; i < n; ++i)
- val = (val << 1) | vpx_read(r, probs[i]);
+ for (i = 0; i < n; ++i) val = (val << 1) | vpx_read(r, probs[i]);
return val;
}
-static int decode_coefs(const MACROBLOCKD *xd,
- PLANE_TYPE type,
+static int decode_coefs(const MACROBLOCKD *xd, PLANE_TYPE type,
tran_low_t *dqcoeff, TX_SIZE tx_size, const int16_t *dq,
int ctx, const int16_t *scan, const int16_t *nb,
vpx_reader *r) {
@@ -47,11 +44,11 @@ static int decode_coefs(const MACROBLOCKD *xd,
const FRAME_CONTEXT *const fc = xd->fc;
const int ref = is_inter_block(xd->mi[0]);
int band, c = 0;
- const vpx_prob (*coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] =
+ const vpx_prob(*coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] =
fc->coef_probs[tx_size][type][ref];
const vpx_prob *prob;
- unsigned int (*coef_counts)[COEFF_CONTEXTS][UNCONSTRAINED_NODES + 1];
- unsigned int (*eob_branch_count)[COEFF_CONTEXTS];
+ unsigned int(*coef_counts)[COEFF_CONTEXTS][UNCONSTRAINED_NODES + 1];
+ unsigned int(*eob_branch_count)[COEFF_CONTEXTS];
uint8_t token_cache[32 * 32];
const uint8_t *band_translate = get_band_translate(tx_size);
const int dq_shift = (tx_size == TX_32X32);
@@ -59,16 +56,16 @@ static int decode_coefs(const MACROBLOCKD *xd,
int16_t dqv = dq[0];
const uint8_t *const cat6_prob =
#if CONFIG_VP9_HIGHBITDEPTH
- (xd->bd == VPX_BITS_12) ? vp9_cat6_prob_high12 :
- (xd->bd == VPX_BITS_10) ? vp9_cat6_prob_high12 + 2 :
+ (xd->bd == VPX_BITS_12)
+ ? vp9_cat6_prob_high12
+ : (xd->bd == VPX_BITS_10) ? vp9_cat6_prob_high12 + 2 :
#endif // CONFIG_VP9_HIGHBITDEPTH
- vp9_cat6_prob;
+ vp9_cat6_prob;
const int cat6_bits =
#if CONFIG_VP9_HIGHBITDEPTH
- (xd->bd == VPX_BITS_12) ? 18 :
- (xd->bd == VPX_BITS_10) ? 16 :
+ (xd->bd == VPX_BITS_12) ? 18 : (xd->bd == VPX_BITS_10) ? 16 :
#endif // CONFIG_VP9_HIGHBITDEPTH
- 14;
+ 14;
if (counts) {
coef_counts = counts->coef[tx_size][type][ref];
@@ -79,8 +76,7 @@ static int decode_coefs(const MACROBLOCKD *xd,
int val = -1;
band = *band_translate++;
prob = coef_probs[band][ctx];
- if (counts)
- ++eob_branch_count[band][ctx];
+ if (counts) ++eob_branch_count[band][ctx];
if (!vpx_read(r, prob[EOB_CONTEXT_NODE])) {
INCREMENT_COUNT(EOB_MODEL_TOKEN);
break;
@@ -91,8 +87,7 @@ static int decode_coefs(const MACROBLOCKD *xd,
dqv = dq[1];
token_cache[scan[c]] = 0;
++c;
- if (c >= max_eob)
- return c; // zero tokens at the end (no eob token)
+ if (c >= max_eob) return c; // zero tokens at the end (no eob token)
ctx = get_coef_context(nb, token_cache, c);
band = *band_translate++;
prob = coef_probs[band][ctx];
@@ -109,9 +104,7 @@ static int decode_coefs(const MACROBLOCKD *xd,
switch (token) {
case TWO_TOKEN:
case THREE_TOKEN:
- case FOUR_TOKEN:
- val = token;
- break;
+ case FOUR_TOKEN: val = token; break;
case CATEGORY1_TOKEN:
val = CAT1_MIN_VAL + read_coeff(vp9_cat1_prob, 1, r);
break;
@@ -135,8 +128,7 @@ static int decode_coefs(const MACROBLOCKD *xd,
v = (val * dqv) >> dq_shift;
#if CONFIG_COEFFICIENT_RANGE_CHECKING
#if CONFIG_VP9_HIGHBITDEPTH
- dqcoeff[scan[c]] = highbd_check_range((vpx_read_bit(r) ? -v : v),
- xd->bd);
+ dqcoeff[scan[c]] = highbd_check_range((vpx_read_bit(r) ? -v : v), xd->bd);
#else
dqcoeff[scan[c]] = check_range(vpx_read_bit(r) ? -v : v);
#endif // CONFIG_VP9_HIGHBITDEPTH
@@ -178,7 +170,7 @@ int vp9_decode_block_tokens(MACROBLOCKD *xd, int plane, const scan_order *sc,
switch (tx_size) {
case TX_4X4:
- ctx = a[0] != 0;
+ ctx = a[0] != 0;
ctx += l[0] != 0;
eob = decode_coefs(xd, get_plane_type(plane), pd->dqcoeff, tx_size,
dequant, ctx, sc->scan, sc->neighbors, r);
@@ -186,7 +178,7 @@ int vp9_decode_block_tokens(MACROBLOCKD *xd, int plane, const scan_order *sc,
break;
case TX_8X8:
get_ctx_shift(xd, &ctx_shift_a, &ctx_shift_l, x, y, 1 << TX_8X8);
- ctx = !!*(const uint16_t *)a;
+ ctx = !!*(const uint16_t *)a;
ctx += !!*(const uint16_t *)l;
eob = decode_coefs(xd, get_plane_type(plane), pd->dqcoeff, tx_size,
dequant, ctx, sc->scan, sc->neighbors, r);
@@ -195,7 +187,7 @@ int vp9_decode_block_tokens(MACROBLOCKD *xd, int plane, const scan_order *sc,
break;
case TX_16X16:
get_ctx_shift(xd, &ctx_shift_a, &ctx_shift_l, x, y, 1 << TX_16X16);
- ctx = !!*(const uint32_t *)a;
+ ctx = !!*(const uint32_t *)a;
ctx += !!*(const uint32_t *)l;
eob = decode_coefs(xd, get_plane_type(plane), pd->dqcoeff, tx_size,
dequant, ctx, sc->scan, sc->neighbors, r);
@@ -207,7 +199,7 @@ int vp9_decode_block_tokens(MACROBLOCKD *xd, int plane, const scan_order *sc,
// NOTE: casting to uint64_t here is safe because the default memory
// alignment is at least 8 bytes and the TX_32X32 is aligned on 8 byte
// boundaries.
- ctx = !!*(const uint64_t *)a;
+ ctx = !!*(const uint64_t *)a;
ctx += !!*(const uint64_t *)l;
eob = decode_coefs(xd, get_plane_type(plane), pd->dqcoeff, tx_size,
dequant, ctx, sc->scan, sc->neighbors, r);
diff --git a/vp9/decoder/vp9_detokenize.h b/vp9/decoder/vp9_detokenize.h
index d242d4466..aa2afb16a 100644
--- a/vp9/decoder/vp9_detokenize.h
+++ b/vp9/decoder/vp9_detokenize.h
@@ -8,7 +8,6 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-
#ifndef VP9_DECODER_VP9_DETOKENIZE_H_
#define VP9_DECODER_VP9_DETOKENIZE_H_
@@ -20,10 +19,8 @@
extern "C" {
#endif
-int vp9_decode_block_tokens(MACROBLOCKD *xd,
- int plane, const scan_order *sc,
- int x, int y,
- TX_SIZE tx_size, vpx_reader *r,
+int vp9_decode_block_tokens(MACROBLOCKD *xd, int plane, const scan_order *sc,
+ int x, int y, TX_SIZE tx_size, vpx_reader *r,
int seg_id);
#ifdef __cplusplus
diff --git a/vp9/decoder/vp9_dsubexp.c b/vp9/decoder/vp9_dsubexp.c
index 05b38538a..126ba0b96 100644
--- a/vp9/decoder/vp9_dsubexp.c
+++ b/vp9/decoder/vp9_dsubexp.c
@@ -15,8 +15,7 @@
#include "vp9/decoder/vp9_dsubexp.h"
static int inv_recenter_nonneg(int v, int m) {
- if (v > 2 * m)
- return v;
+ if (v > 2 * m) return v;
return (v & 1) ? m - ((v + 1) >> 1) : m + (v >> 1);
}
@@ -25,19 +24,19 @@ static int decode_uniform(vpx_reader *r) {
const int l = 8;
const int m = (1 << l) - 191;
const int v = vpx_read_literal(r, l - 1);
- return v < m ? v : (v << 1) - m + vpx_read_bit(r);
+ return v < m ? v : (v << 1) - m + vpx_read_bit(r);
}
static int inv_remap_prob(int v, int m) {
static uint8_t inv_map_table[MAX_PROB] = {
- 7, 20, 33, 46, 59, 72, 85, 98, 111, 124, 137, 150, 163, 176, 189,
- 202, 215, 228, 241, 254, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11,
- 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27,
- 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
- 44, 45, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60,
- 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76,
- 77, 78, 79, 80, 81, 82, 83, 84, 86, 87, 88, 89, 90, 91, 92,
- 93, 94, 95, 96, 97, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
+ 7, 20, 33, 46, 59, 72, 85, 98, 111, 124, 137, 150, 163, 176, 189,
+ 202, 215, 228, 241, 254, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27,
+ 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
+ 44, 45, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60,
+ 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76,
+ 77, 78, 79, 80, 81, 82, 83, 84, 86, 87, 88, 89, 90, 91, 92,
+ 93, 94, 95, 96, 97, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
109, 110, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 125,
126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 138, 139, 140, 141,
142, 143, 144, 145, 146, 147, 148, 149, 151, 152, 153, 154, 155, 156, 157,
@@ -59,16 +58,13 @@ static int inv_remap_prob(int v, int m) {
}
static int decode_term_subexp(vpx_reader *r) {
- if (!vpx_read_bit(r))
- return vpx_read_literal(r, 4);
- if (!vpx_read_bit(r))
- return vpx_read_literal(r, 4) + 16;
- if (!vpx_read_bit(r))
- return vpx_read_literal(r, 5) + 32;
+ if (!vpx_read_bit(r)) return vpx_read_literal(r, 4);
+ if (!vpx_read_bit(r)) return vpx_read_literal(r, 4) + 16;
+ if (!vpx_read_bit(r)) return vpx_read_literal(r, 5) + 32;
return decode_uniform(r) + 64;
}
-void vp9_diff_update_prob(vpx_reader *r, vpx_prob* p) {
+void vp9_diff_update_prob(vpx_reader *r, vpx_prob *p) {
if (vpx_read(r, DIFF_UPDATE_PROB)) {
const int delp = decode_term_subexp(r);
*p = (vpx_prob)inv_remap_prob(delp, *p);
diff --git a/vp9/decoder/vp9_dsubexp.h b/vp9/decoder/vp9_dsubexp.h
index a8bcc70be..5a8ec8300 100644
--- a/vp9/decoder/vp9_dsubexp.h
+++ b/vp9/decoder/vp9_dsubexp.h
@@ -8,7 +8,6 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-
#ifndef VP9_DECODER_VP9_DSUBEXP_H_
#define VP9_DECODER_VP9_DSUBEXP_H_
@@ -18,7 +17,7 @@
extern "C" {
#endif
-void vp9_diff_update_prob(vpx_reader *r, vpx_prob* p);
+void vp9_diff_update_prob(vpx_reader *r, vpx_prob *p);
#ifdef __cplusplus
} // extern "C"
diff --git a/vp9/decoder/vp9_dthread.c b/vp9/decoder/vp9_dthread.c
index 14a71448f..52bc2a0f6 100644
--- a/vp9/decoder/vp9_dthread.c
+++ b/vp9/decoder/vp9_dthread.c
@@ -62,8 +62,7 @@ void vp9_frameworker_signal_stats(VPxWorker *const worker) {
void vp9_frameworker_wait(VPxWorker *const worker, RefCntBuffer *const ref_buf,
int row) {
#if CONFIG_MULTITHREAD
- if (!ref_buf)
- return;
+ if (!ref_buf) return;
#ifndef BUILDING_WITH_TSAN
// The following line of code will get harmless tsan error but it is the key
@@ -147,11 +146,12 @@ void vp9_frameworker_copy_context(VPxWorker *const dst_worker,
vp9_frameworker_lock_stats(src_worker);
while (!src_worker_data->frame_context_ready) {
pthread_cond_wait(&src_worker_data->stats_cond,
- &src_worker_data->stats_mutex);
+ &src_worker_data->stats_mutex);
}
- dst_cm->last_frame_seg_map = src_cm->seg.enabled ?
- src_cm->current_frame_seg_map : src_cm->last_frame_seg_map;
+ dst_cm->last_frame_seg_map = src_cm->seg.enabled
+ ? src_cm->current_frame_seg_map
+ : src_cm->last_frame_seg_map;
dst_worker_data->pbi->need_resync = src_worker_data->pbi->need_resync;
vp9_frameworker_unlock_stats(src_worker);
@@ -159,17 +159,18 @@ void vp9_frameworker_copy_context(VPxWorker *const dst_worker,
#if CONFIG_VP9_HIGHBITDEPTH
dst_cm->use_highbitdepth = src_cm->use_highbitdepth;
#endif
- dst_cm->prev_frame = src_cm->show_existing_frame ?
- src_cm->prev_frame : src_cm->cur_frame;
- dst_cm->last_width = !src_cm->show_existing_frame ?
- src_cm->width : src_cm->last_width;
- dst_cm->last_height = !src_cm->show_existing_frame ?
- src_cm->height : src_cm->last_height;
+ dst_cm->prev_frame =
+ src_cm->show_existing_frame ? src_cm->prev_frame : src_cm->cur_frame;
+ dst_cm->last_width =
+ !src_cm->show_existing_frame ? src_cm->width : src_cm->last_width;
+ dst_cm->last_height =
+ !src_cm->show_existing_frame ? src_cm->height : src_cm->last_height;
dst_cm->subsampling_x = src_cm->subsampling_x;
dst_cm->subsampling_y = src_cm->subsampling_y;
dst_cm->frame_type = src_cm->frame_type;
- dst_cm->last_show_frame = !src_cm->show_existing_frame ?
- src_cm->show_frame : src_cm->last_show_frame;
+ dst_cm->last_show_frame = !src_cm->show_existing_frame
+ ? src_cm->show_frame
+ : src_cm->last_show_frame;
for (i = 0; i < REF_FRAMES; ++i)
dst_cm->ref_frame_map[i] = src_cm->next_ref_frame_map[i];
@@ -183,7 +184,7 @@ void vp9_frameworker_copy_context(VPxWorker *const dst_worker,
memcpy(dst_cm->frame_contexts, src_cm->frame_contexts,
FRAME_CONTEXTS * sizeof(dst_cm->frame_contexts[0]));
#else
- (void) dst_worker;
- (void) src_worker;
+ (void)dst_worker;
+ (void)src_worker;
#endif // CONFIG_MULTITHREAD
}
diff --git a/vp9/decoder/vp9_dthread.h b/vp9/decoder/vp9_dthread.h
index ba7c38a51..fce0fe7fe 100644
--- a/vp9/decoder/vp9_dthread.h
+++ b/vp9/decoder/vp9_dthread.h
@@ -68,7 +68,7 @@ void vp9_frameworker_copy_context(VPxWorker *const dst_worker,
VPxWorker *const src_worker);
#ifdef __cplusplus
-} // extern "C"
+} // extern "C"
#endif
#endif // VP9_DECODER_VP9_DTHREAD_H_