59 uint8_t *dest_cr,
int mb_x,
int mb_y)
61 int *linesize =
s->cur_pic.f->linesize;
62 int dc, dcu, dcv, y,
i;
63 for (
i = 0;
i < 4;
i++) {
64 dc =
s->dc_val[0][mb_x * 2 + (
i & 1) + (mb_y * 2 + (
i >> 1)) *
s->b8_stride];
69 for (y = 0; y < 8; y++) {
71 for (x = 0; x < 8; x++)
72 dest_y[x + (
i & 1) * 8 + (y + (
i >> 1) * 8) * linesize[0]] =
dc / 8;
75 dcu =
s->dc_val[1][mb_x + mb_y *
s->mb_stride];
76 dcv =
s->dc_val[2][mb_x + mb_y *
s->mb_stride];
87 for (y = 0; y < 8; y++) {
89 for (x = 0; x < 8; x++) {
90 dest_cb[x + y * linesize[1]] = dcu / 8;
91 dest_cr[x + y * linesize[2]] = dcv / 8;
101 for (y = 1; y <
height - 1; y++) {
104 for (x = 1; x <
width - 1; x++) {
109 dc = (
av_clip(
dc, INT_MIN/10923, INT_MAX/10923 - 32768) * 10923 + 32768) >> 16;
116 for (x = 1; x <
width - 1; x++) {
117 int prev_dc =
data[x];
119 for (y = 1; y <
height - 1; y++) {
125 dc = (
av_clip(
dc, INT_MIN/10923, INT_MAX/10923 - 32768) * 10923 + 32768) >> 16;
138 int h, ptrdiff_t
stride,
int is_luma)
149 for(b_y=0; b_y<
h; b_y++){
152 for(b_x=0; b_x<
w; b_x++){
153 int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*
s->mb_stride;
154 int error_j=
s->error_status_table[mb_index_j];
155 int intra_j =
IS_INTRA(
s->cur_pic.mb_type[mb_index_j]);
165 for(b_x=
w-1; b_x>=0; b_x--){
166 int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*
s->mb_stride;
167 int error_j=
s->error_status_table[mb_index_j];
168 int intra_j =
IS_INTRA(
s->cur_pic.mb_type[mb_index_j]);
177 for(b_x=0; b_x<
w; b_x++){
180 for(b_y=0; b_y<
h; b_y++){
181 int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*
s->mb_stride;
182 int error_j=
s->error_status_table[mb_index_j];
183 int intra_j =
IS_INTRA(
s->cur_pic.mb_type[mb_index_j]);
193 for(b_y=
h-1; b_y>=0; b_y--){
194 int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*
s->mb_stride;
195 int error_j=
s->error_status_table[mb_index_j];
196 int intra_j =
IS_INTRA(
s->cur_pic.mb_type[mb_index_j]);
206 for (b_y = 0; b_y <
h; b_y++) {
207 for (b_x = 0; b_x <
w; b_x++) {
208 int mb_index,
error, j;
209 int64_t guess, weight_sum;
210 mb_index = (b_x >> is_luma) + (b_y >> is_luma) *
s->mb_stride;
211 error =
s->error_status_table[mb_index];
213 if (
IS_INTER(
s->cur_pic.mb_type[mb_index]))
220 for (j = 0; j < 4; j++) {
225 guess = (guess + weight_sum / 2) / weight_sum;
241 int h, ptrdiff_t
stride,
int is_luma)
244 ptrdiff_t mvx_stride, mvy_stride;
247 mvx_stride >>= is_luma;
248 mvy_stride *= mvx_stride;
250 for (b_y = 0; b_y <
h; b_y++) {
251 for (b_x = 0; b_x <
w - 1; b_x++) {
253 int left_status =
s->error_status_table[( b_x >> is_luma) + (b_y >> is_luma) *
s->mb_stride];
254 int right_status =
s->error_status_table[((b_x + 1) >> is_luma) + (b_y >> is_luma) *
s->mb_stride];
255 int left_intra =
IS_INTRA(
s->cur_pic.mb_type[( b_x >> is_luma) + (b_y >> is_luma) *
s->mb_stride]);
256 int right_intra =
IS_INTRA(
s->cur_pic.mb_type[((b_x + 1) >> is_luma) + (b_y >> is_luma) *
s->mb_stride]);
260 int16_t *left_mv =
s->cur_pic.motion_val[0][mvy_stride * b_y + mvx_stride * b_x];
261 int16_t *right_mv =
s->cur_pic.motion_val[0][mvy_stride * b_y + mvx_stride * (b_x + 1)];
262 if (!(left_damage || right_damage))
264 if ((!left_intra) && (!right_intra) &&
265 FFABS(left_mv[0] - right_mv[0]) +
266 FFABS(left_mv[1] + right_mv[1]) < 2)
269 for (y = 0; y < 8; y++) {
284 if (!(left_damage && right_damage))
310 ptrdiff_t
stride,
int is_luma)
313 ptrdiff_t mvx_stride, mvy_stride;
316 mvx_stride >>= is_luma;
317 mvy_stride *= mvx_stride;
319 for (b_y = 0; b_y <
h - 1; b_y++) {
320 for (b_x = 0; b_x <
w; b_x++) {
322 int top_status =
s->error_status_table[(b_x >> is_luma) + (b_y >> is_luma) *
s->mb_stride];
323 int bottom_status =
s->error_status_table[(b_x >> is_luma) + ((b_y + 1) >> is_luma) *
s->mb_stride];
324 int top_intra =
IS_INTRA(
s->cur_pic.mb_type[(b_x >> is_luma) + ( b_y >> is_luma) *
s->mb_stride]);
325 int bottom_intra =
IS_INTRA(
s->cur_pic.mb_type[(b_x >> is_luma) + ((b_y + 1) >> is_luma) *
s->mb_stride]);
330 int16_t *top_mv =
s->cur_pic.motion_val[0][mvy_stride * b_y + mvx_stride * b_x];
331 int16_t *bottom_mv =
s->cur_pic.motion_val[0][mvy_stride * (b_y + 1) + mvx_stride * b_x];
333 if (!(top_damage || bottom_damage))
336 if ((!top_intra) && (!bottom_intra) &&
337 FFABS(top_mv[0] - bottom_mv[0]) +
338 FFABS(top_mv[1] + bottom_mv[1]) < 2)
341 for (x = 0; x < 8; x++) {
356 if (!(top_damage && bottom_damage))
378 #define MV_UNCHANGED 2
385 blocklist[ *blocklist_length ][0] = mb_x;
386 blocklist[(*blocklist_length)++][1] = mb_y;
391 int (*blocklist)[2], (*next_blocklist)[2];
393 const ptrdiff_t mb_stride =
s->mb_stride;
394 const int mb_width =
s->mb_width;
395 int mb_height =
s->mb_height;
396 int i, depth, num_avail;
398 ptrdiff_t mot_step, mot_stride;
399 int blocklist_length, next_blocklist_length;
401 if (
s->last_pic.f &&
s->last_pic.f->data[0])
402 mb_height =
FFMIN(mb_height, (
s->last_pic.f->height+15)>>4);
403 if (
s->next_pic.f &&
s->next_pic.f->data[0])
404 mb_height =
FFMIN(mb_height, (
s->next_pic.f->height+15)>>4);
406 blocklist = (
int (*)[2])
s->er_temp_buffer;
407 next_blocklist = blocklist +
s->mb_stride *
s->mb_height;
408 fixed = (uint8_t *)(next_blocklist +
s->mb_stride *
s->mb_height);
413 if (
s->last_pic.motion_val[0])
415 for (
i = 0;
i < mb_width * mb_height;
i++) {
416 const int mb_xy =
s->mb_index2xy[
i];
418 int error =
s->error_status_table[mb_xy];
428 else if(
s->last_pic.f->data[0] &&
s->last_pic.motion_val[0]){
429 const int mb_y= mb_xy /
s->mb_stride;
430 const int mb_x= mb_xy %
s->mb_stride;
431 const int mot_index= (mb_x + mb_y*mot_stride) * mot_step;
432 s->cur_pic.motion_val[0][mot_index][0]=
s->last_pic.motion_val[0][mot_index][0];
433 s->cur_pic.motion_val[0][mot_index][1]=
s->last_pic.motion_val[0][mot_index][1];
434 s->cur_pic.ref_index[0][4*mb_xy] =
s->last_pic.ref_index[0][4*mb_xy];
439 num_avail <=
FFMAX(mb_width, mb_height) / 2) {
440 for (mb_y = 0; mb_y < mb_height; mb_y++) {
441 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
442 const int mb_xy = mb_x + mb_y *
s->mb_stride;
459 blocklist_length = 0;
460 for (mb_y = 0; mb_y < mb_height; mb_y++) {
461 for (mb_x = 0; mb_x < mb_width; mb_x++) {
462 const int mb_xy = mb_x + mb_y * mb_stride;
464 if (mb_x)
add_blocklist(blocklist, &blocklist_length,
fixed, mb_x - 1, mb_y, mb_xy - 1);
465 if (mb_y)
add_blocklist(blocklist, &blocklist_length,
fixed, mb_x, mb_y - 1, mb_xy - mb_stride);
466 if (mb_x+1 < mb_width)
add_blocklist(blocklist, &blocklist_length,
fixed, mb_x + 1, mb_y, mb_xy + 1);
467 if (mb_y+1 < mb_height)
add_blocklist(blocklist, &blocklist_length,
fixed, mb_x, mb_y + 1, mb_xy + mb_stride);
472 for (depth = 0; ; depth++) {
473 int changed,
pass, none_left;
480 for (blocklist_index = 0; blocklist_index < blocklist_length; blocklist_index++) {
481 const int mb_x = blocklist[blocklist_index][0];
482 const int mb_y = blocklist[blocklist_index][1];
483 const int mb_xy = mb_x + mb_y * mb_stride;
484 int mv_predictor[8][2];
491 int prev_x, prev_y, prev_ref;
493 if ((mb_x ^ mb_y ^
pass) & 1)
503 j |=
fixed[mb_xy - 1];
504 if (mb_x + 1 < mb_width)
505 j |=
fixed[mb_xy + 1];
507 j |=
fixed[mb_xy - mb_stride];
508 if (mb_y + 1 < mb_height)
509 j |=
fixed[mb_xy + mb_stride];
518 mot_index = (mb_x + mb_y * mot_stride) * mot_step;
520 if (mb_x > 0 &&
fixed[mb_xy - 1] > 1) {
521 mv_predictor[pred_count][0] =
522 s->cur_pic.motion_val[0][mot_index - mot_step][0];
523 mv_predictor[pred_count][1] =
524 s->cur_pic.motion_val[0][mot_index - mot_step][1];
526 s->cur_pic.ref_index[0][4 * (mb_xy - 1)];
529 if (mb_x + 1 < mb_width &&
fixed[mb_xy + 1] > 1) {
530 mv_predictor[pred_count][0] =
531 s->cur_pic.motion_val[0][mot_index + mot_step][0];
532 mv_predictor[pred_count][1] =
533 s->cur_pic.motion_val[0][mot_index + mot_step][1];
535 s->cur_pic.ref_index[0][4 * (mb_xy + 1)];
538 if (mb_y > 0 &&
fixed[mb_xy - mb_stride] > 1) {
539 mv_predictor[pred_count][0] =
540 s->cur_pic.motion_val[0][mot_index - mot_stride * mot_step][0];
541 mv_predictor[pred_count][1] =
542 s->cur_pic.motion_val[0][mot_index - mot_stride * mot_step][1];
544 s->cur_pic.ref_index[0][4 * (mb_xy -
s->mb_stride)];
547 if (mb_y + 1<mb_height &&
fixed[mb_xy + mb_stride] > 1) {
548 mv_predictor[pred_count][0] =
549 s->cur_pic.motion_val[0][mot_index + mot_stride * mot_step][0];
550 mv_predictor[pred_count][1] =
551 s->cur_pic.motion_val[0][mot_index + mot_stride * mot_step][1];
553 s->cur_pic.ref_index[0][4 * (mb_xy +
s->mb_stride)];
559 if (pred_count > 1) {
560 int sum_x = 0, sum_y = 0, sum_r = 0;
561 int max_x, max_y, min_x, min_y, max_r, min_r;
563 for (j = 0; j < pred_count; j++) {
564 sum_x += mv_predictor[j][0];
565 sum_y += mv_predictor[j][1];
567 if (j &&
ref[j] !=
ref[j - 1])
568 goto skip_mean_and_median;
572 mv_predictor[pred_count][0] = sum_x / j;
573 mv_predictor[pred_count][1] = sum_y / j;
574 ref[pred_count] = sum_r / j;
577 if (pred_count >= 3) {
578 min_y = min_x = min_r = 99999;
579 max_y = max_x = max_r = -99999;
581 min_x = min_y = max_x = max_y = min_r = max_r = 0;
583 for (j = 0; j < pred_count; j++) {
584 max_x =
FFMAX(max_x, mv_predictor[j][0]);
585 max_y =
FFMAX(max_y, mv_predictor[j][1]);
587 min_x =
FFMIN(min_x, mv_predictor[j][0]);
588 min_y =
FFMIN(min_y, mv_predictor[j][1]);
591 mv_predictor[pred_count + 1][0] = sum_x - max_x - min_x;
592 mv_predictor[pred_count + 1][1] = sum_y - max_y - min_y;
593 ref[pred_count + 1] = sum_r - max_r - min_r;
595 if (pred_count == 4) {
596 mv_predictor[pred_count + 1][0] /= 2;
597 mv_predictor[pred_count + 1][1] /= 2;
598 ref[pred_count + 1] /= 2;
603 skip_mean_and_median:
605 mv_predictor[pred_count][0] =
606 mv_predictor[pred_count][1] =
610 prev_x =
s->cur_pic.motion_val[0][mot_index][0];
611 prev_y =
s->cur_pic.motion_val[0][mot_index][1];
612 prev_ref =
s->cur_pic.ref_index[0][4 * mb_xy];
615 mv_predictor[pred_count][0] = prev_x;
616 mv_predictor[pred_count][1] = prev_y;
617 ref[pred_count] = prev_ref;
621 best_score = 256 * 256 * 256 * 64;
622 for (j = 0; j < pred_count; j++) {
623 int *linesize =
s->cur_pic.f->linesize;
625 uint8_t *
src =
s->cur_pic.f->data[0] +
626 mb_x * 16 + mb_y * 16 * linesize[0];
628 s->cur_pic.motion_val[0][mot_index][0] =
629 s->mv[0][0][0] = mv_predictor[j][0];
630 s->cur_pic.motion_val[0][mot_index][1] =
631 s->mv[0][0][1] = mv_predictor[j][1];
640 if (mb_x > 0 &&
fixed[mb_xy - 1] > 1) {
642 for (k = 0; k < 16; k++)
643 score +=
FFABS(
src[k * linesize[0] - 1] -
644 src[k * linesize[0]]);
646 if (mb_x + 1 < mb_width &&
fixed[mb_xy + 1] > 1) {
648 for (k = 0; k < 16; k++)
649 score +=
FFABS(
src[k * linesize[0] + 15] -
650 src[k * linesize[0] + 16]);
652 if (mb_y > 0 &&
fixed[mb_xy - mb_stride] > 1) {
654 for (k = 0; k < 16; k++)
657 if (mb_y + 1 < mb_height &&
fixed[mb_xy + mb_stride] > 1) {
659 for (k = 0; k < 16; k++)
660 score +=
FFABS(
src[k + linesize[0] * 15] -
661 src[k + linesize[0] * 16]);
664 if (score <= best_score) {
669 s->mv[0][0][0] = mv_predictor[best_pred][0];
670 s->mv[0][0][1] = mv_predictor[best_pred][1];
672 for (
i = 0;
i < mot_step;
i++)
673 for (j = 0; j < mot_step; j++) {
674 s->cur_pic.motion_val[0][mot_index +
i + j * mot_stride][0] =
s->mv[0][0][0];
675 s->cur_pic.motion_val[0][mot_index +
i + j * mot_stride][1] =
s->mv[0][0][1];
682 if (
s->mv[0][0][0] != prev_x ||
s->mv[0][0][1] != prev_y) {
693 next_blocklist_length = 0;
695 for (blocklist_index = 0; blocklist_index < blocklist_length; blocklist_index++) {
696 const int mb_x = blocklist[blocklist_index][0];
697 const int mb_y = blocklist[blocklist_index][1];
698 const int mb_xy = mb_x + mb_y * mb_stride;
703 add_blocklist(next_blocklist, &next_blocklist_length,
fixed, mb_x - 1, mb_y, mb_xy - 1);
705 add_blocklist(next_blocklist, &next_blocklist_length,
fixed, mb_x, mb_y - 1, mb_xy - mb_stride);
706 if (mb_x + 1 < mb_width)
707 add_blocklist(next_blocklist, &next_blocklist_length,
fixed, mb_x + 1, mb_y, mb_xy + 1);
708 if (mb_y + 1 < mb_height)
709 add_blocklist(next_blocklist, &next_blocklist_length,
fixed, mb_x, mb_y + 1, mb_xy + mb_stride);
712 av_assert0(next_blocklist_length <= mb_height * mb_width);
713 FFSWAP(
int , blocklist_length, next_blocklist_length);
714 FFSWAP(
void*, blocklist, next_blocklist);
720 int is_intra_likely,
i, j, undamaged_count, skip_amount, mb_x, mb_y;
722 if (!
s->last_pic.f || !
s->last_pic.f->data[0])
729 for (
i = 0;
i <
s->mb_num;
i++) {
730 const int mb_xy =
s->mb_index2xy[
i];
731 const int error =
s->error_status_table[mb_xy];
736 if (undamaged_count < 5)
741 s->avctx->hwaccel &&
s->avctx->hwaccel->decode_mb &&
745 skip_amount =
FFMAX(undamaged_count / 50, 1);
749 for (mb_y = 0; mb_y <
s->mb_height - 1; mb_y++) {
750 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
752 const int mb_xy = mb_x + mb_y *
s->mb_stride;
754 error =
s->error_status_table[mb_xy];
760 if ((j % skip_amount) != 0)
764 int *linesize =
s->cur_pic.f->linesize;
765 uint8_t *mb_ptr =
s->cur_pic.f->data[0] +
766 mb_x * 16 + mb_y * 16 * linesize[0];
767 uint8_t *last_mb_ptr =
s->last_pic.f->data[0] +
768 mb_x * 16 + mb_y * 16 * linesize[0];
775 is_intra_likely +=
s->mecc.sad[0](
NULL, last_mb_ptr, mb_ptr,
778 is_intra_likely -=
s->mecc.sad[0](
NULL, last_mb_ptr,
779 last_mb_ptr + linesize[0] * 16,
790 return is_intra_likely > 0;
795 if (!
s->avctx->error_concealment)
798 if (!
s->mecc_inited) {
804 s->mb_stride *
s->mb_height *
sizeof(uint8_t));
806 s->error_occurred = 0;
811 if(
s->avctx->hwaccel &&
s->avctx->hwaccel->decode_slice ||
813 s->cur_pic.field_picture
827 int endx,
int endy,
int status)
829 const int start_i =
av_clip(startx + starty *
s->mb_width, 0,
s->mb_num - 1);
830 const int end_i =
av_clip(endx + endy *
s->mb_width, 0,
s->mb_num);
831 const int start_xy =
s->mb_index2xy[start_i];
832 const int end_xy =
s->mb_index2xy[end_i];
835 if (
s->avctx->hwaccel &&
s->avctx->hwaccel->decode_slice)
838 if (start_i > end_i || start_xy > end_xy) {
840 "internal error, slice end before start\n");
844 if (!
s->avctx->error_concealment)
862 s->error_occurred = 1;
867 memset(&
s->error_status_table[start_xy], 0,
868 (end_xy - start_xy) *
sizeof(uint8_t));
871 for (
i = start_xy;
i < end_xy;
i++)
872 s->error_status_table[
i] &=
mask;
875 if (end_i ==
s->mb_num)
878 s->error_status_table[end_xy] &=
mask;
879 s->error_status_table[end_xy] |=
status;
882 s->error_status_table[start_xy] |=
VP_START;
886 int prev_status =
s->error_status_table[
s->mb_index2xy[start_i - 1]];
890 s->error_occurred = 1;
898 int *linesize =
NULL;
899 int i, mb_x, mb_y,
error, error_type, dc_error, mv_error, ac_error;
901 int threshold_part[4] = { 100, 100, 100 };
904 int size =
s->b8_stride * 2 *
s->mb_height;
908 if (!
s->avctx->error_concealment || !
atomic_load(&
s->error_count) ||
912 (
s->avctx->skip_top +
s->avctx->skip_bottom)) {
915 linesize =
s->cur_pic.f->linesize;
918 && (
FFALIGN(
s->avctx->height, 16)&16)
919 &&
atomic_load(&
s->error_count) == 3 *
s->mb_width * (
s->avctx->skip_top +
s->avctx->skip_bottom + 1)) {
920 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
921 int status =
s->error_status_table[mb_x + (
s->mb_height - 1) *
s->mb_stride];
926 if (mb_x ==
s->mb_width) {
933 if (
s->last_pic.f->width !=
s->cur_pic.f->width ||
934 s->last_pic.f->height !=
s->cur_pic.f->height ||
935 s->last_pic.f->format !=
s->cur_pic.f->format) {
937 memset(&
s->last_pic, 0,
sizeof(
s->last_pic));
941 if (
s->next_pic.f->width !=
s->cur_pic.f->width ||
942 s->next_pic.f->height !=
s->cur_pic.f->height ||
943 s->next_pic.f->format !=
s->cur_pic.f->format) {
945 memset(&
s->next_pic, 0,
sizeof(
s->next_pic));
949 if (!
s->cur_pic.motion_val[0] || !
s->cur_pic.ref_index[0]) {
952 for (
i = 0;
i < 2;
i++) {
955 if (!
s->ref_index_buf[
i] || !
s->motion_val_buf[
i])
957 s->cur_pic.ref_index[
i] =
s->ref_index_buf[
i]->data;
958 s->cur_pic.motion_val[
i] = (int16_t (*)[2])
s->motion_val_buf[
i]->data + 4;
961 for (
i = 0;
i < 2;
i++) {
964 s->cur_pic.ref_index[
i] =
NULL;
965 s->cur_pic.motion_val[
i] =
NULL;
972 for (mb_y = 0; mb_y <
s->mb_height; mb_y++) {
973 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
974 int status =
s->error_status_table[mb_x + mb_y *
s->mb_stride];
984 for (error_type = 1; error_type <= 3; error_type++) {
987 for (
i =
s->mb_num - 1;
i >= 0;
i--) {
988 const int mb_xy =
s->mb_index2xy[
i];
989 int error =
s->error_status_table[mb_xy];
991 if (
error & (1 << error_type))
993 if (
error & (8 << error_type))
997 s->error_status_table[mb_xy] |= 1 << error_type;
1006 if (
s->partitioned_frame) {
1009 for (
i =
s->mb_num - 1;
i >= 0;
i--) {
1010 const int mb_xy =
s->mb_index2xy[
i];
1011 int error =
s->error_status_table[mb_xy];
1033 for (
i =
s->mb_num - 2;
i >=
s->mb_width + 100;
i--) {
1034 const int mb_xy =
s->mb_index2xy[
i];
1035 int error1 =
s->error_status_table[mb_xy];
1036 int error2 =
s->error_status_table[
s->mb_index2xy[
i + 1]];
1057 for (error_type = 1; error_type <= 3; error_type++) {
1058 for (
i =
s->mb_num - 1;
i >= 0;
i--) {
1059 const int mb_xy =
s->mb_index2xy[
i];
1060 int error =
s->error_status_table[mb_xy];
1062 if (!
s->mbskip_table || !
s->mbskip_table[mb_xy])
1064 if (
error & (1 << error_type))
1067 if (
s->partitioned_frame) {
1068 if (
distance < threshold_part[error_type - 1])
1069 s->error_status_table[mb_xy] |= 1 << error_type;
1072 s->error_status_table[mb_xy] |= 1 << error_type;
1083 for (
i = 0;
i <
s->mb_num;
i++) {
1084 const int mb_xy =
s->mb_index2xy[
i];
1085 int old_error =
s->error_status_table[mb_xy];
1091 s->error_status_table[mb_xy] |=
error;
1096 if (!
s->partitioned_frame) {
1097 for (
i = 0;
i <
s->mb_num;
i++) {
1098 const int mb_xy =
s->mb_index2xy[
i];
1099 int error =
s->error_status_table[mb_xy];
1102 s->error_status_table[mb_xy] =
error;
1107 dc_error = ac_error = mv_error = 0;
1108 for (
i = 0;
i <
s->mb_num;
i++) {
1109 const int mb_xy =
s->mb_index2xy[
i];
1110 int error =
s->error_status_table[mb_xy];
1126 for (
i = 0;
i <
s->mb_num;
i++) {
1127 const int mb_xy =
s->mb_index2xy[
i];
1128 int error =
s->error_status_table[mb_xy];
1132 if (is_intra_likely)
1139 if (!(
s->last_pic.f &&
s->last_pic.f->data[0]) &&
1140 !(
s->next_pic.f &&
s->next_pic.f->data[0]))
1141 for (
i = 0;
i <
s->mb_num;
i++) {
1142 const int mb_xy =
s->mb_index2xy[
i];
1143 if (!
IS_INTRA(
s->cur_pic.mb_type[mb_xy]))
1148 for (mb_y = 0; mb_y <
s->mb_height; mb_y++) {
1149 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
1150 const int mb_xy = mb_x + mb_y *
s->mb_stride;
1151 const int mb_type =
s->cur_pic.mb_type[mb_xy];
1152 const int dir = !(
s->last_pic.f &&
s->last_pic.f->data[0]);
1156 int error =
s->error_status_table[mb_xy];
1166 int mb_index = mb_x * 2 + mb_y * 2 *
s->b8_stride;
1169 for (j = 0; j < 4; j++) {
1170 s->mv[0][j][0] =
s->cur_pic.motion_val[dir][mb_index + (j & 1) + (j >> 1) *
s->b8_stride][0];
1171 s->mv[0][j][1] =
s->cur_pic.motion_val[dir][mb_index + (j & 1) + (j >> 1) *
s->b8_stride][1];
1175 s->mv[0][0][0] =
s->cur_pic.motion_val[dir][mb_x * 2 + mb_y * 2 *
s->b8_stride][0];
1176 s->mv[0][0][1] =
s->cur_pic.motion_val[dir][mb_x * 2 + mb_y * 2 *
s->b8_stride][1];
1179 s->decode_mb(
s->opaque, 0 ,
1180 mv_dir, mv_type, &
s->mv, mb_x, mb_y, 0, 0);
1186 for (mb_y = 0; mb_y <
s->mb_height; mb_y++) {
1187 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
1188 int xy = mb_x * 2 + mb_y * 2 *
s->b8_stride;
1189 const int mb_xy = mb_x + mb_y *
s->mb_stride;
1190 const int mb_type =
s->cur_pic.mb_type[mb_xy];
1193 int error =
s->error_status_table[mb_xy];
1202 if (!(
s->last_pic.f &&
s->last_pic.f->data[0]))
1204 if (!(
s->next_pic.f &&
s->next_pic.f->data[0]))
1208 int time_pp =
s->pp_time;
1209 int time_pb =
s->pb_time;
1214 s->mv[0][0][0] =
s->next_pic.motion_val[0][xy][0] * time_pb / time_pp;
1215 s->mv[0][0][1] =
s->next_pic.motion_val[0][xy][1] * time_pb / time_pp;
1216 s->mv[1][0][0] =
s->next_pic.motion_val[0][xy][0] * (time_pb - time_pp) / time_pp;
1217 s->mv[1][0][1] =
s->next_pic.motion_val[0][xy][1] * (time_pb - time_pp) / time_pp;
1233 if (CONFIG_XVMC &&
s->avctx->hwaccel &&
s->avctx->hwaccel->decode_mb)
1236 for (mb_y = 0; mb_y <
s->mb_height; mb_y++) {
1237 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
1238 int dc, dcu, dcv, y, n;
1240 uint8_t *dest_y, *dest_cb, *dest_cr;
1241 const int mb_xy = mb_x + mb_y *
s->mb_stride;
1242 const int mb_type =
s->cur_pic.mb_type[mb_xy];
1246 if (
IS_INTRA(mb_type) &&
s->partitioned_frame)
1251 dest_y =
s->cur_pic.f->data[0] + mb_x * 16 + mb_y * 16 * linesize[0];
1252 dest_cb =
s->cur_pic.f->data[1] + mb_x * 8 + mb_y * 8 * linesize[1];
1253 dest_cr =
s->cur_pic.f->data[2] + mb_x * 8 + mb_y * 8 * linesize[2];
1255 dc_ptr = &
s->dc_val[0][mb_x * 2 + mb_y * 2 *
s->b8_stride];
1256 for (n = 0; n < 4; n++) {
1258 for (y = 0; y < 8; y++) {
1260 for (x = 0; x < 8; x++)
1261 dc += dest_y[x + (n & 1) * 8 +
1262 (y + (n >> 1) * 8) * linesize[0]];
1264 dc_ptr[(n & 1) + (n >> 1) *
s->b8_stride] = (
dc + 4) >> 3;
1267 if (!
s->cur_pic.f->data[2])
1271 for (y = 0; y < 8; y++) {
1273 for (x = 0; x < 8; x++) {
1274 dcu += dest_cb[x + y * linesize[1]];
1275 dcv += dest_cr[x + y * linesize[2]];
1278 s->dc_val[1][mb_x + mb_y *
s->mb_stride] = (dcu + 4) >> 3;
1279 s->dc_val[2][mb_x + mb_y *
s->mb_stride] = (dcv + 4) >> 3;
1284 guess_dc(
s,
s->dc_val[0],
s->mb_width*2,
s->mb_height*2,
s->b8_stride, 1);
1285 guess_dc(
s,
s->dc_val[1],
s->mb_width ,
s->mb_height ,
s->mb_stride, 0);
1286 guess_dc(
s,
s->dc_val[2],
s->mb_width ,
s->mb_height ,
s->mb_stride, 0);
1290 filter181(
s->dc_val[0],
s->mb_width * 2,
s->mb_height * 2,
s->b8_stride);
1294 for (mb_y = 0; mb_y <
s->mb_height; mb_y++) {
1295 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
1296 uint8_t *dest_y, *dest_cb, *dest_cr;
1297 const int mb_xy = mb_x + mb_y *
s->mb_stride;
1298 const int mb_type =
s->cur_pic.mb_type[mb_xy];
1300 int error =
s->error_status_table[mb_xy];
1307 dest_y =
s->cur_pic.f->data[0] + mb_x * 16 + mb_y * 16 * linesize[0];
1308 dest_cb =
s->cur_pic.f->data[1] + mb_x * 8 + mb_y * 8 * linesize[1];
1309 dest_cr =
s->cur_pic.f->data[2] + mb_x * 8 + mb_y * 8 * linesize[2];
1310 if (!
s->cur_pic.f->data[2])
1311 dest_cb = dest_cr =
NULL;
1313 put_dc(
s, dest_y, dest_cb, dest_cr, mb_x, mb_y);
1321 s->mb_height * 2, linesize[0], 1);
1325 s->mb_height * 2, linesize[0], 1);
1327 if (
s->cur_pic.f->data[2]) {
1329 s->mb_height, linesize[1], 0);
1331 s->mb_height, linesize[2], 0);
1333 s->mb_height, linesize[1], 0);
1335 s->mb_height, linesize[2], 0);
1341 for (
i = 0;
i <
s->mb_num;
i++) {
1342 const int mb_xy =
s->mb_index2xy[
i];
1343 int error =
s->error_status_table[mb_xy];
1347 s->mbskip_table[mb_xy] = 0;
1349 if (
s->mbintra_table)
1350 s->mbintra_table[mb_xy] = 1;
1353 for (
i = 0;
i < 2;
i++) {
1356 s->cur_pic.ref_index[
i] =
NULL;
1357 s->cur_pic.motion_val[
i] =
NULL;