decodemv.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. /*
  2. * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #include "decodemv.h"
  11. #include "treereader.h"
  12. #include "vp8/common/entropymv.h"
  13. #include "vp8/common/entropymode.h"
  14. #include "onyxd_int.h"
  15. #include "vp8/common/findnearmv.h"
  16. static B_PREDICTION_MODE read_bmode(vp8_reader *bc, const vp8_prob *p) {
  17. const int i = vp8_treed_read(bc, vp8_bmode_tree, p);
  18. return (B_PREDICTION_MODE)i;
  19. }
  20. static MB_PREDICTION_MODE read_ymode(vp8_reader *bc, const vp8_prob *p) {
  21. const int i = vp8_treed_read(bc, vp8_ymode_tree, p);
  22. return (MB_PREDICTION_MODE)i;
  23. }
  24. static MB_PREDICTION_MODE read_kf_ymode(vp8_reader *bc, const vp8_prob *p) {
  25. const int i = vp8_treed_read(bc, vp8_kf_ymode_tree, p);
  26. return (MB_PREDICTION_MODE)i;
  27. }
  28. static MB_PREDICTION_MODE read_uv_mode(vp8_reader *bc, const vp8_prob *p) {
  29. const int i = vp8_treed_read(bc, vp8_uv_mode_tree, p);
  30. return (MB_PREDICTION_MODE)i;
  31. }
  32. static void read_kf_modes(VP8D_COMP *pbi, MODE_INFO *mi) {
  33. vp8_reader *const bc = &pbi->mbc[8];
  34. const int mis = pbi->common.mode_info_stride;
  35. mi->mbmi.ref_frame = INTRA_FRAME;
  36. mi->mbmi.mode = read_kf_ymode(bc, vp8_kf_ymode_prob);
  37. if (mi->mbmi.mode == B_PRED) {
  38. int i = 0;
  39. mi->mbmi.is_4x4 = 1;
  40. do {
  41. const B_PREDICTION_MODE A = above_block_mode(mi, i, mis);
  42. const B_PREDICTION_MODE L = left_block_mode(mi, i);
  43. mi->bmi[i].as_mode = read_bmode(bc, vp8_kf_bmode_prob[A][L]);
  44. } while (++i < 16);
  45. }
  46. mi->mbmi.uv_mode = read_uv_mode(bc, vp8_kf_uv_mode_prob);
  47. }
  48. static int read_mvcomponent(vp8_reader *r, const MV_CONTEXT *mvc) {
  49. const vp8_prob *const p = (const vp8_prob *)mvc;
  50. int x = 0;
  51. if (vp8_read(r, p[mvpis_short])) { /* Large */
  52. int i = 0;
  53. do {
  54. x += vp8_read(r, p[MVPbits + i]) << i;
  55. } while (++i < 3);
  56. i = mvlong_width - 1; /* Skip bit 3, which is sometimes implicit */
  57. do {
  58. x += vp8_read(r, p[MVPbits + i]) << i;
  59. } while (--i > 3);
  60. if (!(x & 0xFFF0) || vp8_read(r, p[MVPbits + 3])) x += 8;
  61. } else { /* small */
  62. x = vp8_treed_read(r, vp8_small_mvtree, p + MVPshort);
  63. }
  64. if (x && vp8_read(r, p[MVPsign])) x = -x;
  65. return x;
  66. }
  67. static void read_mv(vp8_reader *r, MV *mv, const MV_CONTEXT *mvc) {
  68. mv->row = (short)(read_mvcomponent(r, mvc) * 2);
  69. mv->col = (short)(read_mvcomponent(r, ++mvc) * 2);
  70. }
  71. static void read_mvcontexts(vp8_reader *bc, MV_CONTEXT *mvc) {
  72. int i = 0;
  73. do {
  74. const vp8_prob *up = vp8_mv_update_probs[i].prob;
  75. vp8_prob *p = (vp8_prob *)(mvc + i);
  76. vp8_prob *const pstop = p + MVPcount;
  77. do {
  78. if (vp8_read(bc, *up++)) {
  79. const vp8_prob x = (vp8_prob)vp8_read_literal(bc, 7);
  80. *p = x ? x << 1 : 1;
  81. }
  82. } while (++p < pstop);
  83. } while (++i < 2);
  84. }
  85. static const unsigned char mbsplit_fill_count[4] = { 8, 8, 4, 1 };
  86. static const unsigned char mbsplit_fill_offset[4][16] = {
  87. { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
  88. { 0, 1, 4, 5, 8, 9, 12, 13, 2, 3, 6, 7, 10, 11, 14, 15 },
  89. { 0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15 },
  90. { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }
  91. };
  92. static void mb_mode_mv_init(VP8D_COMP *pbi) {
  93. vp8_reader *const bc = &pbi->mbc[8];
  94. MV_CONTEXT *const mvc = pbi->common.fc.mvc;
  95. #if CONFIG_ERROR_CONCEALMENT
  96. /* Default is that no macroblock is corrupt, therefore we initialize
  97. * mvs_corrupt_from_mb to something very big, which we can be sure is
  98. * outside the frame. */
  99. pbi->mvs_corrupt_from_mb = UINT_MAX;
  100. #endif
  101. /* Read the mb_no_coeff_skip flag */
  102. pbi->common.mb_no_coeff_skip = (int)vp8_read_bit(bc);
  103. pbi->prob_skip_false = 0;
  104. if (pbi->common.mb_no_coeff_skip) {
  105. pbi->prob_skip_false = (vp8_prob)vp8_read_literal(bc, 8);
  106. }
  107. if (pbi->common.frame_type != KEY_FRAME) {
  108. pbi->prob_intra = (vp8_prob)vp8_read_literal(bc, 8);
  109. pbi->prob_last = (vp8_prob)vp8_read_literal(bc, 8);
  110. pbi->prob_gf = (vp8_prob)vp8_read_literal(bc, 8);
  111. if (vp8_read_bit(bc)) {
  112. int i = 0;
  113. do {
  114. pbi->common.fc.ymode_prob[i] = (vp8_prob)vp8_read_literal(bc, 8);
  115. } while (++i < 4);
  116. }
  117. if (vp8_read_bit(bc)) {
  118. int i = 0;
  119. do {
  120. pbi->common.fc.uv_mode_prob[i] = (vp8_prob)vp8_read_literal(bc, 8);
  121. } while (++i < 3);
  122. }
  123. read_mvcontexts(bc, mvc);
  124. }
  125. }
  126. const vp8_prob vp8_sub_mv_ref_prob3[8][VP8_SUBMVREFS - 1] = {
  127. { 147, 136, 18 }, /* SUBMVREF_NORMAL */
  128. { 223, 1, 34 }, /* SUBMVREF_LEFT_ABOVE_SAME */
  129. { 106, 145, 1 }, /* SUBMVREF_LEFT_ZED */
  130. { 208, 1, 1 }, /* SUBMVREF_LEFT_ABOVE_ZED */
  131. { 179, 121, 1 }, /* SUBMVREF_ABOVE_ZED */
  132. { 223, 1, 34 }, /* SUBMVREF_LEFT_ABOVE_SAME */
  133. { 179, 121, 1 }, /* SUBMVREF_ABOVE_ZED */
  134. { 208, 1, 1 } /* SUBMVREF_LEFT_ABOVE_ZED */
  135. };
  136. static const vp8_prob *get_sub_mv_ref_prob(const int left, const int above) {
  137. int lez = (left == 0);
  138. int aez = (above == 0);
  139. int lea = (left == above);
  140. const vp8_prob *prob;
  141. prob = vp8_sub_mv_ref_prob3[(aez << 2) | (lez << 1) | (lea)];
  142. return prob;
  143. }
  144. static void decode_split_mv(vp8_reader *const bc, MODE_INFO *mi,
  145. const MODE_INFO *left_mb, const MODE_INFO *above_mb,
  146. MB_MODE_INFO *mbmi, int_mv best_mv,
  147. MV_CONTEXT *const mvc, int mb_to_left_edge,
  148. int mb_to_right_edge, int mb_to_top_edge,
  149. int mb_to_bottom_edge) {
  150. int s; /* split configuration (16x8, 8x16, 8x8, 4x4) */
  151. /* number of partitions in the split configuration (see vp8_mbsplit_count) */
  152. int num_p;
  153. int j = 0;
  154. s = 3;
  155. num_p = 16;
  156. if (vp8_read(bc, 110)) {
  157. s = 2;
  158. num_p = 4;
  159. if (vp8_read(bc, 111)) {
  160. s = vp8_read(bc, 150);
  161. num_p = 2;
  162. }
  163. }
  164. do /* for each subset j */
  165. {
  166. int_mv leftmv, abovemv;
  167. int_mv blockmv;
  168. int k; /* first block in subset j */
  169. const vp8_prob *prob;
  170. k = vp8_mbsplit_offset[s][j];
  171. if (!(k & 3)) {
  172. /* On L edge, get from MB to left of us */
  173. if (left_mb->mbmi.mode != SPLITMV) {
  174. leftmv.as_int = left_mb->mbmi.mv.as_int;
  175. } else {
  176. leftmv.as_int = (left_mb->bmi + k + 4 - 1)->mv.as_int;
  177. }
  178. } else {
  179. leftmv.as_int = (mi->bmi + k - 1)->mv.as_int;
  180. }
  181. if (!(k >> 2)) {
  182. /* On top edge, get from MB above us */
  183. if (above_mb->mbmi.mode != SPLITMV) {
  184. abovemv.as_int = above_mb->mbmi.mv.as_int;
  185. } else {
  186. abovemv.as_int = (above_mb->bmi + k + 16 - 4)->mv.as_int;
  187. }
  188. } else {
  189. abovemv.as_int = (mi->bmi + k - 4)->mv.as_int;
  190. }
  191. prob = get_sub_mv_ref_prob(leftmv.as_int, abovemv.as_int);
  192. if (vp8_read(bc, prob[0])) {
  193. if (vp8_read(bc, prob[1])) {
  194. blockmv.as_int = 0;
  195. if (vp8_read(bc, prob[2])) {
  196. blockmv.as_mv.row = read_mvcomponent(bc, &mvc[0]) * 2;
  197. blockmv.as_mv.row += best_mv.as_mv.row;
  198. blockmv.as_mv.col = read_mvcomponent(bc, &mvc[1]) * 2;
  199. blockmv.as_mv.col += best_mv.as_mv.col;
  200. }
  201. } else {
  202. blockmv.as_int = abovemv.as_int;
  203. }
  204. } else {
  205. blockmv.as_int = leftmv.as_int;
  206. }
  207. mbmi->need_to_clamp_mvs |=
  208. vp8_check_mv_bounds(&blockmv, mb_to_left_edge, mb_to_right_edge,
  209. mb_to_top_edge, mb_to_bottom_edge);
  210. {
  211. /* Fill (uniform) modes, mvs of jth subset.
  212. Must do it here because ensuing subsets can
  213. refer back to us via "left" or "above". */
  214. const unsigned char *fill_offset;
  215. unsigned int fill_count = mbsplit_fill_count[s];
  216. fill_offset =
  217. &mbsplit_fill_offset[s][(unsigned char)j * mbsplit_fill_count[s]];
  218. do {
  219. mi->bmi[*fill_offset].mv.as_int = blockmv.as_int;
  220. fill_offset++;
  221. } while (--fill_count);
  222. }
  223. } while (++j < num_p);
  224. mbmi->partitioning = s;
  225. }
  226. static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi,
  227. MB_MODE_INFO *mbmi) {
  228. vp8_reader *const bc = &pbi->mbc[8];
  229. mbmi->ref_frame = (MV_REFERENCE_FRAME)vp8_read(bc, pbi->prob_intra);
  230. if (mbmi->ref_frame) { /* inter MB */
  231. enum { CNT_INTRA, CNT_NEAREST, CNT_NEAR, CNT_SPLITMV };
  232. int cnt[4];
  233. int *cntx = cnt;
  234. int_mv near_mvs[4];
  235. int_mv *nmv = near_mvs;
  236. const int mis = pbi->mb.mode_info_stride;
  237. const MODE_INFO *above = mi - mis;
  238. const MODE_INFO *left = mi - 1;
  239. const MODE_INFO *aboveleft = above - 1;
  240. int *ref_frame_sign_bias = pbi->common.ref_frame_sign_bias;
  241. mbmi->need_to_clamp_mvs = 0;
  242. if (vp8_read(bc, pbi->prob_last)) {
  243. mbmi->ref_frame =
  244. (MV_REFERENCE_FRAME)((int)(2 + vp8_read(bc, pbi->prob_gf)));
  245. }
  246. /* Zero accumulators */
  247. nmv[0].as_int = nmv[1].as_int = nmv[2].as_int = 0;
  248. cnt[0] = cnt[1] = cnt[2] = cnt[3] = 0;
  249. /* Process above */
  250. if (above->mbmi.ref_frame != INTRA_FRAME) {
  251. if (above->mbmi.mv.as_int) {
  252. (++nmv)->as_int = above->mbmi.mv.as_int;
  253. mv_bias(ref_frame_sign_bias[above->mbmi.ref_frame], mbmi->ref_frame,
  254. nmv, ref_frame_sign_bias);
  255. ++cntx;
  256. }
  257. *cntx += 2;
  258. }
  259. /* Process left */
  260. if (left->mbmi.ref_frame != INTRA_FRAME) {
  261. if (left->mbmi.mv.as_int) {
  262. int_mv this_mv;
  263. this_mv.as_int = left->mbmi.mv.as_int;
  264. mv_bias(ref_frame_sign_bias[left->mbmi.ref_frame], mbmi->ref_frame,
  265. &this_mv, ref_frame_sign_bias);
  266. if (this_mv.as_int != nmv->as_int) {
  267. (++nmv)->as_int = this_mv.as_int;
  268. ++cntx;
  269. }
  270. *cntx += 2;
  271. } else {
  272. cnt[CNT_INTRA] += 2;
  273. }
  274. }
  275. /* Process above left */
  276. if (aboveleft->mbmi.ref_frame != INTRA_FRAME) {
  277. if (aboveleft->mbmi.mv.as_int) {
  278. int_mv this_mv;
  279. this_mv.as_int = aboveleft->mbmi.mv.as_int;
  280. mv_bias(ref_frame_sign_bias[aboveleft->mbmi.ref_frame], mbmi->ref_frame,
  281. &this_mv, ref_frame_sign_bias);
  282. if (this_mv.as_int != nmv->as_int) {
  283. (++nmv)->as_int = this_mv.as_int;
  284. ++cntx;
  285. }
  286. *cntx += 1;
  287. } else {
  288. cnt[CNT_INTRA] += 1;
  289. }
  290. }
  291. if (vp8_read(bc, vp8_mode_contexts[cnt[CNT_INTRA]][0])) {
  292. /* If we have three distinct MV's ... */
  293. /* See if above-left MV can be merged with NEAREST */
  294. cnt[CNT_NEAREST] += ((cnt[CNT_SPLITMV] > 0) &
  295. (nmv->as_int == near_mvs[CNT_NEAREST].as_int));
  296. /* Swap near and nearest if necessary */
  297. if (cnt[CNT_NEAR] > cnt[CNT_NEAREST]) {
  298. int tmp;
  299. tmp = cnt[CNT_NEAREST];
  300. cnt[CNT_NEAREST] = cnt[CNT_NEAR];
  301. cnt[CNT_NEAR] = tmp;
  302. tmp = near_mvs[CNT_NEAREST].as_int;
  303. near_mvs[CNT_NEAREST].as_int = near_mvs[CNT_NEAR].as_int;
  304. near_mvs[CNT_NEAR].as_int = tmp;
  305. }
  306. if (vp8_read(bc, vp8_mode_contexts[cnt[CNT_NEAREST]][1])) {
  307. if (vp8_read(bc, vp8_mode_contexts[cnt[CNT_NEAR]][2])) {
  308. int mb_to_top_edge;
  309. int mb_to_bottom_edge;
  310. int mb_to_left_edge;
  311. int mb_to_right_edge;
  312. MV_CONTEXT *const mvc = pbi->common.fc.mvc;
  313. int near_index;
  314. mb_to_top_edge = pbi->mb.mb_to_top_edge;
  315. mb_to_bottom_edge = pbi->mb.mb_to_bottom_edge;
  316. mb_to_top_edge -= LEFT_TOP_MARGIN;
  317. mb_to_bottom_edge += RIGHT_BOTTOM_MARGIN;
  318. mb_to_right_edge = pbi->mb.mb_to_right_edge;
  319. mb_to_right_edge += RIGHT_BOTTOM_MARGIN;
  320. mb_to_left_edge = pbi->mb.mb_to_left_edge;
  321. mb_to_left_edge -= LEFT_TOP_MARGIN;
  322. /* Use near_mvs[0] to store the "best" MV */
  323. near_index = CNT_INTRA + (cnt[CNT_NEAREST] >= cnt[CNT_INTRA]);
  324. vp8_clamp_mv2(&near_mvs[near_index], &pbi->mb);
  325. cnt[CNT_SPLITMV] =
  326. ((above->mbmi.mode == SPLITMV) + (left->mbmi.mode == SPLITMV)) *
  327. 2 +
  328. (aboveleft->mbmi.mode == SPLITMV);
  329. if (vp8_read(bc, vp8_mode_contexts[cnt[CNT_SPLITMV]][3])) {
  330. decode_split_mv(bc, mi, left, above, mbmi, near_mvs[near_index],
  331. mvc, mb_to_left_edge, mb_to_right_edge,
  332. mb_to_top_edge, mb_to_bottom_edge);
  333. mbmi->mv.as_int = mi->bmi[15].mv.as_int;
  334. mbmi->mode = SPLITMV;
  335. mbmi->is_4x4 = 1;
  336. } else {
  337. int_mv *const mbmi_mv = &mbmi->mv;
  338. read_mv(bc, &mbmi_mv->as_mv, (const MV_CONTEXT *)mvc);
  339. mbmi_mv->as_mv.row += near_mvs[near_index].as_mv.row;
  340. mbmi_mv->as_mv.col += near_mvs[near_index].as_mv.col;
  341. /* Don't need to check this on NEARMV and NEARESTMV
  342. * modes since those modes clamp the MV. The NEWMV mode
  343. * does not, so signal to the prediction stage whether
  344. * special handling may be required.
  345. */
  346. mbmi->need_to_clamp_mvs =
  347. vp8_check_mv_bounds(mbmi_mv, mb_to_left_edge, mb_to_right_edge,
  348. mb_to_top_edge, mb_to_bottom_edge);
  349. mbmi->mode = NEWMV;
  350. }
  351. } else {
  352. mbmi->mode = NEARMV;
  353. mbmi->mv.as_int = near_mvs[CNT_NEAR].as_int;
  354. vp8_clamp_mv2(&mbmi->mv, &pbi->mb);
  355. }
  356. } else {
  357. mbmi->mode = NEARESTMV;
  358. mbmi->mv.as_int = near_mvs[CNT_NEAREST].as_int;
  359. vp8_clamp_mv2(&mbmi->mv, &pbi->mb);
  360. }
  361. } else {
  362. mbmi->mode = ZEROMV;
  363. mbmi->mv.as_int = 0;
  364. }
  365. #if CONFIG_ERROR_CONCEALMENT
  366. if (pbi->ec_enabled && (mbmi->mode != SPLITMV)) {
  367. mi->bmi[0].mv.as_int = mi->bmi[1].mv.as_int = mi->bmi[2].mv.as_int =
  368. mi->bmi[3].mv.as_int = mi->bmi[4].mv.as_int = mi->bmi[5].mv.as_int =
  369. mi->bmi[6].mv.as_int = mi->bmi[7].mv.as_int =
  370. mi->bmi[8].mv.as_int = mi->bmi[9].mv.as_int =
  371. mi->bmi[10].mv.as_int = mi->bmi[11].mv.as_int =
  372. mi->bmi[12].mv.as_int = mi->bmi[13].mv.as_int =
  373. mi->bmi[14].mv.as_int = mi->bmi[15].mv.as_int =
  374. mbmi->mv.as_int;
  375. }
  376. #endif
  377. } else {
  378. /* required for left and above block mv */
  379. mbmi->mv.as_int = 0;
  380. /* MB is intra coded */
  381. if ((mbmi->mode = read_ymode(bc, pbi->common.fc.ymode_prob)) == B_PRED) {
  382. int j = 0;
  383. mbmi->is_4x4 = 1;
  384. do {
  385. mi->bmi[j].as_mode = read_bmode(bc, pbi->common.fc.bmode_prob);
  386. } while (++j < 16);
  387. }
  388. mbmi->uv_mode = read_uv_mode(bc, pbi->common.fc.uv_mode_prob);
  389. }
  390. }
  391. static void read_mb_features(vp8_reader *r, MB_MODE_INFO *mi, MACROBLOCKD *x) {
  392. /* Is segmentation enabled */
  393. if (x->segmentation_enabled && x->update_mb_segmentation_map) {
  394. /* If so then read the segment id. */
  395. if (vp8_read(r, x->mb_segment_tree_probs[0])) {
  396. mi->segment_id =
  397. (unsigned char)(2 + vp8_read(r, x->mb_segment_tree_probs[2]));
  398. } else {
  399. mi->segment_id =
  400. (unsigned char)(vp8_read(r, x->mb_segment_tree_probs[1]));
  401. }
  402. }
  403. }
  404. static void decode_mb_mode_mvs(VP8D_COMP *pbi, MODE_INFO *mi,
  405. MB_MODE_INFO *mbmi) {
  406. (void)mbmi;
  407. /* Read the Macroblock segmentation map if it is being updated explicitly
  408. * this frame (reset to 0 above by default)
  409. * By default on a key frame reset all MBs to segment 0
  410. */
  411. if (pbi->mb.update_mb_segmentation_map) {
  412. read_mb_features(&pbi->mbc[8], &mi->mbmi, &pbi->mb);
  413. } else if (pbi->common.frame_type == KEY_FRAME) {
  414. mi->mbmi.segment_id = 0;
  415. }
  416. /* Read the macroblock coeff skip flag if this feature is in use,
  417. * else default to 0 */
  418. if (pbi->common.mb_no_coeff_skip) {
  419. mi->mbmi.mb_skip_coeff = vp8_read(&pbi->mbc[8], pbi->prob_skip_false);
  420. } else {
  421. mi->mbmi.mb_skip_coeff = 0;
  422. }
  423. mi->mbmi.is_4x4 = 0;
  424. if (pbi->common.frame_type == KEY_FRAME) {
  425. read_kf_modes(pbi, mi);
  426. } else {
  427. read_mb_modes_mv(pbi, mi, &mi->mbmi);
  428. }
  429. }
  430. void vp8_decode_mode_mvs(VP8D_COMP *pbi) {
  431. MODE_INFO *mi = pbi->common.mi;
  432. int mb_row = -1;
  433. int mb_to_right_edge_start;
  434. mb_mode_mv_init(pbi);
  435. pbi->mb.mb_to_top_edge = 0;
  436. pbi->mb.mb_to_bottom_edge = ((pbi->common.mb_rows - 1) * 16) << 3;
  437. mb_to_right_edge_start = ((pbi->common.mb_cols - 1) * 16) << 3;
  438. while (++mb_row < pbi->common.mb_rows) {
  439. int mb_col = -1;
  440. pbi->mb.mb_to_left_edge = 0;
  441. pbi->mb.mb_to_right_edge = mb_to_right_edge_start;
  442. while (++mb_col < pbi->common.mb_cols) {
  443. #if CONFIG_ERROR_CONCEALMENT
  444. int mb_num = mb_row * pbi->common.mb_cols + mb_col;
  445. #endif
  446. decode_mb_mode_mvs(pbi, mi, &mi->mbmi);
  447. #if CONFIG_ERROR_CONCEALMENT
  448. /* look for corruption. set mvs_corrupt_from_mb to the current
  449. * mb_num if the frame is corrupt from this macroblock. */
  450. if (vp8dx_bool_error(&pbi->mbc[8]) &&
  451. mb_num < (int)pbi->mvs_corrupt_from_mb) {
  452. pbi->mvs_corrupt_from_mb = mb_num;
  453. /* no need to continue since the partition is corrupt from
  454. * here on.
  455. */
  456. return;
  457. }
  458. #endif
  459. pbi->mb.mb_to_left_edge -= (16 << 3);
  460. pbi->mb.mb_to_right_edge -= (16 << 3);
  461. mi++; /* next macroblock */
  462. }
  463. pbi->mb.mb_to_top_edge -= (16 << 3);
  464. pbi->mb.mb_to_bottom_edge -= (16 << 3);
  465. mi++; /* skip left predictor each row */
  466. }
  467. }