decodemv.c 17 KB

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