60 uint8_t *dest_cr,
int mb_x,
int mb_y)
62 int *linesize =
s->cur_pic.f->linesize;
63 int dc, dcu, dcv, y,
i;
64 for (
i = 0;
i < 4;
i++) {
65 dc =
s->dc_val[0][mb_x * 2 + (
i & 1) + (mb_y * 2 + (
i >> 1)) *
s->b8_stride];
70 for (y = 0; y < 8; y++) {
72 for (x = 0; x < 8; x++)
73 dest_y[x + (
i & 1) * 8 + (y + (
i >> 1) * 8) * linesize[0]] =
dc / 8;
76 dcu =
s->dc_val[1][mb_x + mb_y *
s->mb_stride];
77 dcv =
s->dc_val[2][mb_x + mb_y *
s->mb_stride];
88 for (y = 0; y < 8; y++) {
90 for (x = 0; x < 8; x++) {
91 dest_cb[x + y * linesize[1]] = dcu / 8;
92 dest_cr[x + y * linesize[2]] = dcv / 8;
102 for (y = 1; y <
height - 1; y++) {
105 for (x = 1; x <
width - 1; x++) {
110 dc = (av_clip(
dc, INT_MIN/10923, INT_MAX/10923 - 32768) * 10923 + 32768) >> 16;
117 for (x = 1; x <
width - 1; x++) {
118 int prev_dc =
data[x];
120 for (y = 1; y <
height - 1; y++) {
126 dc = (av_clip(
dc, INT_MIN/10923, INT_MAX/10923 - 32768) * 10923 + 32768) >> 16;
139 int h, ptrdiff_t
stride,
int is_luma)
150 for(b_y=0; b_y<
h; b_y++){
153 for(b_x=0; b_x<
w; b_x++){
154 int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*
s->mb_stride;
155 int error_j=
s->error_status_table[mb_index_j];
156 int intra_j =
IS_INTRA(
s->cur_pic.mb_type[mb_index_j]);
166 for(b_x=
w-1; b_x>=0; b_x--){
167 int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*
s->mb_stride;
168 int error_j=
s->error_status_table[mb_index_j];
169 int intra_j =
IS_INTRA(
s->cur_pic.mb_type[mb_index_j]);
178 for(b_x=0; b_x<
w; b_x++){
181 for(b_y=0; b_y<
h; b_y++){
182 int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*
s->mb_stride;
183 int error_j=
s->error_status_table[mb_index_j];
184 int intra_j =
IS_INTRA(
s->cur_pic.mb_type[mb_index_j]);
194 for(b_y=
h-1; b_y>=0; b_y--){
195 int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*
s->mb_stride;
196 int error_j=
s->error_status_table[mb_index_j];
197 int intra_j =
IS_INTRA(
s->cur_pic.mb_type[mb_index_j]);
207 for (b_y = 0; b_y <
h; b_y++) {
208 for (b_x = 0; b_x <
w; b_x++) {
209 int mb_index,
error, j;
210 int64_t guess, weight_sum;
211 mb_index = (b_x >> is_luma) + (b_y >> is_luma) *
s->mb_stride;
212 error =
s->error_status_table[mb_index];
214 if (
IS_INTER(
s->cur_pic.mb_type[mb_index]))
221 for (j = 0; j < 4; j++) {
226 guess = (guess + weight_sum / 2) / weight_sum;
242 int h, ptrdiff_t
stride,
int is_luma)
245 ptrdiff_t mvx_stride, mvy_stride;
248 mvx_stride >>= is_luma;
249 mvy_stride *= mvx_stride;
251 for (b_y = 0; b_y <
h; b_y++) {
252 for (b_x = 0; b_x <
w - 1; b_x++) {
254 int left_status =
s->error_status_table[( b_x >> is_luma) + (b_y >> is_luma) *
s->mb_stride];
255 int right_status =
s->error_status_table[((b_x + 1) >> is_luma) + (b_y >> is_luma) *
s->mb_stride];
256 int left_intra =
IS_INTRA(
s->cur_pic.mb_type[( b_x >> is_luma) + (b_y >> is_luma) *
s->mb_stride]);
257 int right_intra =
IS_INTRA(
s->cur_pic.mb_type[((b_x + 1) >> is_luma) + (b_y >> is_luma) *
s->mb_stride]);
261 int16_t *left_mv =
s->cur_pic.motion_val[0][mvy_stride * b_y + mvx_stride * b_x];
262 int16_t *right_mv =
s->cur_pic.motion_val[0][mvy_stride * b_y + mvx_stride * (b_x + 1)];
263 if (!(left_damage || right_damage))
265 if ((!left_intra) && (!right_intra) &&
266 FFABS(left_mv[0] - right_mv[0]) +
267 FFABS(left_mv[1] + right_mv[1]) < 2)
270 for (y = 0; y < 8; y++) {
285 if (!(left_damage && right_damage))
311 ptrdiff_t
stride,
int is_luma)
314 ptrdiff_t mvx_stride, mvy_stride;
317 mvx_stride >>= is_luma;
318 mvy_stride *= mvx_stride;
320 for (b_y = 0; b_y <
h - 1; b_y++) {
321 for (b_x = 0; b_x <
w; b_x++) {
323 int top_status =
s->error_status_table[(b_x >> is_luma) + (b_y >> is_luma) *
s->mb_stride];
324 int bottom_status =
s->error_status_table[(b_x >> is_luma) + ((b_y + 1) >> is_luma) *
s->mb_stride];
325 int top_intra =
IS_INTRA(
s->cur_pic.mb_type[(b_x >> is_luma) + ( b_y >> is_luma) *
s->mb_stride]);
326 int bottom_intra =
IS_INTRA(
s->cur_pic.mb_type[(b_x >> is_luma) + ((b_y + 1) >> is_luma) *
s->mb_stride]);
331 int16_t *top_mv =
s->cur_pic.motion_val[0][mvy_stride * b_y + mvx_stride * b_x];
332 int16_t *bottom_mv =
s->cur_pic.motion_val[0][mvy_stride * (b_y + 1) + mvx_stride * b_x];
334 if (!(top_damage || bottom_damage))
337 if ((!top_intra) && (!bottom_intra) &&
338 FFABS(top_mv[0] - bottom_mv[0]) +
339 FFABS(top_mv[1] + bottom_mv[1]) < 2)
342 for (x = 0; x < 8; x++) {
357 if (!(top_damage && bottom_damage))
379 #define MV_UNCHANGED 2
386 blocklist[ *blocklist_length ][0] = mb_x;
387 blocklist[(*blocklist_length)++][1] = mb_y;
392 int (*blocklist)[2], (*next_blocklist)[2];
394 const ptrdiff_t mb_stride =
s->mb_stride;
395 const int mb_width =
s->mb_width;
396 int mb_height =
s->mb_height;
397 int i, depth, num_avail;
399 ptrdiff_t mot_step, mot_stride;
400 int blocklist_length, next_blocklist_length;
402 if (
s->last_pic.f &&
s->last_pic.f->data[0])
403 mb_height =
FFMIN(mb_height, (
s->last_pic.f->height+15)>>4);
404 if (
s->next_pic.f &&
s->next_pic.f->data[0])
405 mb_height =
FFMIN(mb_height, (
s->next_pic.f->height+15)>>4);
407 blocklist = (
int (*)[2])
s->er_temp_buffer;
408 next_blocklist = blocklist +
s->mb_stride *
s->mb_height;
409 fixed = (
uint8_t *)(next_blocklist +
s->mb_stride *
s->mb_height);
414 if (
s->last_pic.motion_val[0])
416 for (
i = 0;
i < mb_width * mb_height;
i++) {
417 const int mb_xy =
s->mb_index2xy[
i];
419 int error =
s->error_status_table[mb_xy];
429 else if(
s->last_pic.f->data[0] &&
s->last_pic.motion_val[0]){
430 const int mb_y= mb_xy /
s->mb_stride;
431 const int mb_x= mb_xy %
s->mb_stride;
432 const int mot_index= (mb_x + mb_y*mot_stride) * mot_step;
433 s->cur_pic.motion_val[0][mot_index][0]=
s->last_pic.motion_val[0][mot_index][0];
434 s->cur_pic.motion_val[0][mot_index][1]=
s->last_pic.motion_val[0][mot_index][1];
435 s->cur_pic.ref_index[0][4*mb_xy] =
s->last_pic.ref_index[0][4*mb_xy];
440 num_avail <=
FFMAX(mb_width, mb_height) / 2) {
441 for (mb_y = 0; mb_y < mb_height; mb_y++) {
442 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
443 const int mb_xy = mb_x + mb_y *
s->mb_stride;
460 blocklist_length = 0;
461 for (mb_y = 0; mb_y < mb_height; mb_y++) {
462 for (mb_x = 0; mb_x < mb_width; mb_x++) {
463 const int mb_xy = mb_x + mb_y * mb_stride;
465 if (mb_x)
add_blocklist(blocklist, &blocklist_length,
fixed, mb_x - 1, mb_y, mb_xy - 1);
466 if (mb_y)
add_blocklist(blocklist, &blocklist_length,
fixed, mb_x, mb_y - 1, mb_xy - mb_stride);
467 if (mb_x+1 < mb_width)
add_blocklist(blocklist, &blocklist_length,
fixed, mb_x + 1, mb_y, mb_xy + 1);
468 if (mb_y+1 < mb_height)
add_blocklist(blocklist, &blocklist_length,
fixed, mb_x, mb_y + 1, mb_xy + mb_stride);
473 for (depth = 0; ; depth++) {
474 int changed,
pass, none_left;
483 for (blocklist_index = 0; blocklist_index < blocklist_length; blocklist_index++) {
484 const int mb_x = blocklist[blocklist_index][0];
485 const int mb_y = blocklist[blocklist_index][1];
486 const int mb_xy = mb_x + mb_y * mb_stride;
487 int mv_predictor[8][2];
494 int prev_x, prev_y, prev_ref;
496 if ((mb_x ^ mb_y ^
pass) & 1)
506 j |=
fixed[mb_xy - 1];
507 if (mb_x + 1 < mb_width)
508 j |=
fixed[mb_xy + 1];
510 j |=
fixed[mb_xy - mb_stride];
511 if (mb_y + 1 < mb_height)
512 j |=
fixed[mb_xy + mb_stride];
521 mot_index = (mb_x + mb_y * mot_stride) * mot_step;
523 if (mb_x > 0 &&
fixed[mb_xy - 1] > 1) {
524 mv_predictor[pred_count][0] =
525 s->cur_pic.motion_val[0][mot_index - mot_step][0];
526 mv_predictor[pred_count][1] =
527 s->cur_pic.motion_val[0][mot_index - mot_step][1];
529 s->cur_pic.ref_index[0][4 * (mb_xy - 1)];
532 if (mb_x + 1 < mb_width &&
fixed[mb_xy + 1] > 1) {
533 mv_predictor[pred_count][0] =
534 s->cur_pic.motion_val[0][mot_index + mot_step][0];
535 mv_predictor[pred_count][1] =
536 s->cur_pic.motion_val[0][mot_index + mot_step][1];
538 s->cur_pic.ref_index[0][4 * (mb_xy + 1)];
541 if (mb_y > 0 &&
fixed[mb_xy - mb_stride] > 1) {
542 mv_predictor[pred_count][0] =
543 s->cur_pic.motion_val[0][mot_index - mot_stride * mot_step][0];
544 mv_predictor[pred_count][1] =
545 s->cur_pic.motion_val[0][mot_index - mot_stride * mot_step][1];
547 s->cur_pic.ref_index[0][4 * (mb_xy -
s->mb_stride)];
550 if (mb_y + 1<mb_height &&
fixed[mb_xy + mb_stride] > 1) {
551 mv_predictor[pred_count][0] =
552 s->cur_pic.motion_val[0][mot_index + mot_stride * mot_step][0];
553 mv_predictor[pred_count][1] =
554 s->cur_pic.motion_val[0][mot_index + mot_stride * mot_step][1];
556 s->cur_pic.ref_index[0][4 * (mb_xy +
s->mb_stride)];
562 if (pred_count > 1) {
563 int sum_x = 0, sum_y = 0, sum_r = 0;
564 int max_x, max_y, min_x, min_y, max_r, min_r;
566 for (j = 0; j < pred_count; j++) {
567 sum_x += mv_predictor[j][0];
568 sum_y += mv_predictor[j][1];
570 if (j &&
ref[j] !=
ref[j - 1])
571 goto skip_mean_and_median;
575 mv_predictor[pred_count][0] = sum_x / j;
576 mv_predictor[pred_count][1] = sum_y / j;
577 ref[pred_count] = sum_r / j;
580 if (pred_count >= 3) {
581 min_y = min_x = min_r = 99999;
582 max_y = max_x = max_r = -99999;
584 min_x = min_y = max_x = max_y = min_r = max_r = 0;
586 for (j = 0; j < pred_count; j++) {
587 max_x =
FFMAX(max_x, mv_predictor[j][0]);
588 max_y =
FFMAX(max_y, mv_predictor[j][1]);
590 min_x =
FFMIN(min_x, mv_predictor[j][0]);
591 min_y =
FFMIN(min_y, mv_predictor[j][1]);
594 mv_predictor[pred_count + 1][0] = sum_x - max_x - min_x;
595 mv_predictor[pred_count + 1][1] = sum_y - max_y - min_y;
596 ref[pred_count + 1] = sum_r - max_r - min_r;
598 if (pred_count == 4) {
599 mv_predictor[pred_count + 1][0] /= 2;
600 mv_predictor[pred_count + 1][1] /= 2;
601 ref[pred_count + 1] /= 2;
606 skip_mean_and_median:
608 mv_predictor[pred_count][0] =
609 mv_predictor[pred_count][1] =
613 prev_x =
s->cur_pic.motion_val[0][mot_index][0];
614 prev_y =
s->cur_pic.motion_val[0][mot_index][1];
615 prev_ref =
s->cur_pic.ref_index[0][4 * mb_xy];
618 mv_predictor[pred_count][0] = prev_x;
619 mv_predictor[pred_count][1] = prev_y;
620 ref[pred_count] = prev_ref;
624 best_score = 256 * 256 * 256 * 64;
625 for (j = 0; j < pred_count; j++) {
626 int *linesize =
s->cur_pic.f->linesize;
629 mb_x * 16 + mb_y * 16 * linesize[0];
631 s->cur_pic.motion_val[0][mot_index][0] =
632 s->mv[0][0][0] = mv_predictor[j][0];
633 s->cur_pic.motion_val[0][mot_index][1] =
634 s->mv[0][0][1] = mv_predictor[j][1];
643 if (mb_x > 0 &&
fixed[mb_xy - 1] > 1) {
645 for (k = 0; k < 16; k++)
646 score +=
FFABS(
src[k * linesize[0] - 1] -
647 src[k * linesize[0]]);
649 if (mb_x + 1 < mb_width &&
fixed[mb_xy + 1] > 1) {
651 for (k = 0; k < 16; k++)
652 score +=
FFABS(
src[k * linesize[0] + 15] -
653 src[k * linesize[0] + 16]);
655 if (mb_y > 0 &&
fixed[mb_xy - mb_stride] > 1) {
657 for (k = 0; k < 16; k++)
660 if (mb_y + 1 < mb_height &&
fixed[mb_xy + mb_stride] > 1) {
662 for (k = 0; k < 16; k++)
663 score +=
FFABS(
src[k + linesize[0] * 15] -
664 src[k + linesize[0] * 16]);
667 if (score <= best_score) {
672 score_sum += best_score;
673 s->mv[0][0][0] = mv_predictor[best_pred][0];
674 s->mv[0][0][1] = mv_predictor[best_pred][1];
676 for (
i = 0;
i < mot_step;
i++)
677 for (j = 0; j < mot_step; j++) {
678 s->cur_pic.motion_val[0][mot_index +
i + j * mot_stride][0] =
s->mv[0][0][0];
679 s->cur_pic.motion_val[0][mot_index +
i + j * mot_stride][1] =
s->mv[0][0][1];
686 if (
s->mv[0][0][0] != prev_x ||
s->mv[0][0][1] != prev_y) {
697 next_blocklist_length = 0;
699 for (blocklist_index = 0; blocklist_index < blocklist_length; blocklist_index++) {
700 const int mb_x = blocklist[blocklist_index][0];
701 const int mb_y = blocklist[blocklist_index][1];
702 const int mb_xy = mb_x + mb_y * mb_stride;
707 add_blocklist(next_blocklist, &next_blocklist_length,
fixed, mb_x - 1, mb_y, mb_xy - 1);
709 add_blocklist(next_blocklist, &next_blocklist_length,
fixed, mb_x, mb_y - 1, mb_xy - mb_stride);
710 if (mb_x + 1 < mb_width)
711 add_blocklist(next_blocklist, &next_blocklist_length,
fixed, mb_x + 1, mb_y, mb_xy + 1);
712 if (mb_y + 1 < mb_height)
713 add_blocklist(next_blocklist, &next_blocklist_length,
fixed, mb_x, mb_y + 1, mb_xy + mb_stride);
716 av_assert0(next_blocklist_length <= mb_height * mb_width);
717 FFSWAP(
int , blocklist_length, next_blocklist_length);
718 FFSWAP(
void*, blocklist, next_blocklist);
724 int is_intra_likely,
i, j, undamaged_count, skip_amount, mb_x, mb_y;
726 if (!
s->last_pic.f || !
s->last_pic.f->data[0])
733 for (
i = 0;
i <
s->mb_num;
i++) {
734 const int mb_xy =
s->mb_index2xy[
i];
735 const int error =
s->error_status_table[mb_xy];
740 if (undamaged_count < 5)
745 s->avctx->hwaccel &&
s->avctx->hwaccel->decode_mb &&
749 skip_amount =
FFMAX(undamaged_count / 50, 1);
753 for (mb_y = 0; mb_y <
s->mb_height - 1; mb_y++) {
754 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
756 const int mb_xy = mb_x + mb_y *
s->mb_stride;
758 error =
s->error_status_table[mb_xy];
764 if ((j % skip_amount) != 0)
768 int *linesize =
s->cur_pic.f->linesize;
769 uint8_t *mb_ptr =
s->cur_pic.f->data[0] +
770 mb_x * 16 + mb_y * 16 * linesize[0];
771 uint8_t *last_mb_ptr =
s->last_pic.f->data[0] +
772 mb_x * 16 + mb_y * 16 * linesize[0];
779 is_intra_likely +=
s->mecc.sad[0](
NULL, last_mb_ptr, mb_ptr,
782 is_intra_likely -=
s->mecc.sad[0](
NULL, last_mb_ptr,
783 last_mb_ptr + linesize[0] * 16,
794 return is_intra_likely > 0;
799 if (!
s->avctx->error_concealment)
802 if (!
s->mecc_inited) {
808 s->mb_stride *
s->mb_height *
sizeof(
uint8_t));
810 s->error_occurred = 0;
815 if(
s->avctx->hwaccel &&
s->avctx->hwaccel->decode_slice ||
817 s->cur_pic.field_picture
831 int endx,
int endy,
int status)
833 const int start_i = av_clip(startx + starty *
s->mb_width, 0,
s->mb_num - 1);
834 const int end_i = av_clip(endx + endy *
s->mb_width, 0,
s->mb_num);
835 const int start_xy =
s->mb_index2xy[start_i];
836 const int end_xy =
s->mb_index2xy[end_i];
839 if (
s->avctx->hwaccel &&
s->avctx->hwaccel->decode_slice)
842 if (start_i > end_i || start_xy > end_xy) {
844 "internal error, slice end before start\n");
848 if (!
s->avctx->error_concealment)
866 s->error_occurred = 1;
871 memset(&
s->error_status_table[start_xy], 0,
872 (end_xy - start_xy) *
sizeof(
uint8_t));
875 for (
i = start_xy;
i < end_xy;
i++)
876 s->error_status_table[
i] &=
mask;
879 if (end_i ==
s->mb_num)
882 s->error_status_table[end_xy] &=
mask;
883 s->error_status_table[end_xy] |=
status;
886 s->error_status_table[start_xy] |=
VP_START;
890 int prev_status =
s->error_status_table[
s->mb_index2xy[start_i - 1]];
894 s->error_occurred = 1;
902 int *linesize =
NULL;
903 int i, mb_x, mb_y,
error, error_type, dc_error, mv_error, ac_error;
905 int threshold_part[4] = { 100, 100, 100 };
908 int size =
s->b8_stride * 2 *
s->mb_height;
912 if (!
s->avctx->error_concealment || !
atomic_load(&
s->error_count) ||
916 (
s->avctx->skip_top +
s->avctx->skip_bottom)) {
919 linesize =
s->cur_pic.f->linesize;
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
928 && (
FFALIGN(
s->avctx->height, 16)&16)
929 &&
atomic_load(&
s->error_count) == 3 *
s->mb_width * (
s->avctx->skip_top +
s->avctx->skip_bottom + 1)
936 if (
s->last_pic.f->width !=
s->cur_pic.f->width ||
937 s->last_pic.f->height !=
s->cur_pic.f->height ||
938 s->last_pic.f->format !=
s->cur_pic.f->format) {
940 memset(&
s->last_pic, 0,
sizeof(
s->last_pic));
944 if (
s->next_pic.f->width !=
s->cur_pic.f->width ||
945 s->next_pic.f->height !=
s->cur_pic.f->height ||
946 s->next_pic.f->format !=
s->cur_pic.f->format) {
948 memset(&
s->next_pic, 0,
sizeof(
s->next_pic));
952 if (!
s->cur_pic.motion_val[0] || !
s->cur_pic.ref_index[0]) {
955 for (
i = 0;
i < 2;
i++) {
958 if (!
s->ref_index_buf[
i] || !
s->motion_val_buf[
i])
960 s->cur_pic.ref_index[
i] =
s->ref_index_buf[
i]->data;
961 s->cur_pic.motion_val[
i] = (int16_t (*)[2])
s->motion_val_buf[
i]->data + 4;
964 for (
i = 0;
i < 2;
i++) {
967 s->cur_pic.ref_index[
i] =
NULL;
968 s->cur_pic.motion_val[
i] =
NULL;
975 for (mb_y = 0; mb_y <
s->mb_height; mb_y++) {
976 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
977 int status =
s->error_status_table[mb_x + mb_y *
s->mb_stride];
987 for (error_type = 1; error_type <= 3; error_type++) {
990 for (
i =
s->mb_num - 1;
i >= 0;
i--) {
991 const int mb_xy =
s->mb_index2xy[
i];
992 int error =
s->error_status_table[mb_xy];
994 if (
error & (1 << error_type))
996 if (
error & (8 << error_type))
1000 s->error_status_table[mb_xy] |= 1 << error_type;
1009 if (
s->partitioned_frame) {
1012 for (
i =
s->mb_num - 1;
i >= 0;
i--) {
1013 const int mb_xy =
s->mb_index2xy[
i];
1014 int error =
s->error_status_table[mb_xy];
1036 for (
i =
s->mb_num - 2;
i >=
s->mb_width + 100;
i--) {
1037 const int mb_xy =
s->mb_index2xy[
i];
1038 int error1 =
s->error_status_table[mb_xy];
1039 int error2 =
s->error_status_table[
s->mb_index2xy[
i + 1]];
1060 for (error_type = 1; error_type <= 3; error_type++) {
1061 for (
i =
s->mb_num - 1;
i >= 0;
i--) {
1062 const int mb_xy =
s->mb_index2xy[
i];
1063 int error =
s->error_status_table[mb_xy];
1065 if (!
s->mbskip_table || !
s->mbskip_table[mb_xy])
1067 if (
error & (1 << error_type))
1070 if (
s->partitioned_frame) {
1071 if (
distance < threshold_part[error_type - 1])
1072 s->error_status_table[mb_xy] |= 1 << error_type;
1075 s->error_status_table[mb_xy] |= 1 << error_type;
1086 for (
i = 0;
i <
s->mb_num;
i++) {
1087 const int mb_xy =
s->mb_index2xy[
i];
1088 int old_error =
s->error_status_table[mb_xy];
1094 s->error_status_table[mb_xy] |=
error;
1099 if (!
s->partitioned_frame) {
1100 for (
i = 0;
i <
s->mb_num;
i++) {
1101 const int mb_xy =
s->mb_index2xy[
i];
1102 int error =
s->error_status_table[mb_xy];
1105 s->error_status_table[mb_xy] =
error;
1110 dc_error = ac_error = mv_error = 0;
1111 for (
i = 0;
i <
s->mb_num;
i++) {
1112 const int mb_xy =
s->mb_index2xy[
i];
1113 int error =
s->error_status_table[mb_xy];
1129 for (
i = 0;
i <
s->mb_num;
i++) {
1130 const int mb_xy =
s->mb_index2xy[
i];
1131 int error =
s->error_status_table[mb_xy];
1135 if (is_intra_likely)
1142 if (!(
s->last_pic.f &&
s->last_pic.f->data[0]) &&
1143 !(
s->next_pic.f &&
s->next_pic.f->data[0]))
1144 for (
i = 0;
i <
s->mb_num;
i++) {
1145 const int mb_xy =
s->mb_index2xy[
i];
1146 if (!
IS_INTRA(
s->cur_pic.mb_type[mb_xy]))
1151 for (mb_y = 0; mb_y <
s->mb_height; mb_y++) {
1152 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
1153 const int mb_xy = mb_x + mb_y *
s->mb_stride;
1154 const int mb_type =
s->cur_pic.mb_type[mb_xy];
1155 const int dir = !(
s->last_pic.f &&
s->last_pic.f->data[0]);
1159 int error =
s->error_status_table[mb_xy];
1169 int mb_index = mb_x * 2 + mb_y * 2 *
s->b8_stride;
1172 for (j = 0; j < 4; j++) {
1173 s->mv[0][j][0] =
s->cur_pic.motion_val[dir][mb_index + (j & 1) + (j >> 1) *
s->b8_stride][0];
1174 s->mv[0][j][1] =
s->cur_pic.motion_val[dir][mb_index + (j & 1) + (j >> 1) *
s->b8_stride][1];
1178 s->mv[0][0][0] =
s->cur_pic.motion_val[dir][mb_x * 2 + mb_y * 2 *
s->b8_stride][0];
1179 s->mv[0][0][1] =
s->cur_pic.motion_val[dir][mb_x * 2 + mb_y * 2 *
s->b8_stride][1];
1182 s->decode_mb(
s->opaque, 0 ,
1183 mv_dir, mv_type, &
s->mv, mb_x, mb_y, 0, 0);
1189 for (mb_y = 0; mb_y <
s->mb_height; mb_y++) {
1190 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
1191 int xy = mb_x * 2 + mb_y * 2 *
s->b8_stride;
1192 const int mb_xy = mb_x + mb_y *
s->mb_stride;
1193 const int mb_type =
s->cur_pic.mb_type[mb_xy];
1196 int error =
s->error_status_table[mb_xy];
1205 if (!(
s->last_pic.f &&
s->last_pic.f->data[0]))
1207 if (!(
s->next_pic.f &&
s->next_pic.f->data[0]))
1211 int time_pp =
s->pp_time;
1212 int time_pb =
s->pb_time;
1217 s->mv[0][0][0] =
s->next_pic.motion_val[0][xy][0] * time_pb / time_pp;
1218 s->mv[0][0][1] =
s->next_pic.motion_val[0][xy][1] * time_pb / time_pp;
1219 s->mv[1][0][0] =
s->next_pic.motion_val[0][xy][0] * (time_pb - time_pp) / time_pp;
1220 s->mv[1][0][1] =
s->next_pic.motion_val[0][xy][1] * (time_pb - time_pp) / time_pp;
1236 if (CONFIG_XVMC &&
s->avctx->hwaccel &&
s->avctx->hwaccel->decode_mb)
1239 for (mb_y = 0; mb_y <
s->mb_height; mb_y++) {
1240 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
1241 int dc, dcu, dcv, y, n;
1243 uint8_t *dest_y, *dest_cb, *dest_cr;
1244 const int mb_xy = mb_x + mb_y *
s->mb_stride;
1245 const int mb_type =
s->cur_pic.mb_type[mb_xy];
1249 if (
IS_INTRA(mb_type) &&
s->partitioned_frame)
1254 dest_y =
s->cur_pic.f->data[0] + mb_x * 16 + mb_y * 16 * linesize[0];
1255 dest_cb =
s->cur_pic.f->data[1] + mb_x * 8 + mb_y * 8 * linesize[1];
1256 dest_cr =
s->cur_pic.f->data[2] + mb_x * 8 + mb_y * 8 * linesize[2];
1258 dc_ptr = &
s->dc_val[0][mb_x * 2 + mb_y * 2 *
s->b8_stride];
1259 for (n = 0; n < 4; n++) {
1261 for (y = 0; y < 8; y++) {
1263 for (x = 0; x < 8; x++)
1264 dc += dest_y[x + (n & 1) * 8 +
1265 (y + (n >> 1) * 8) * linesize[0]];
1267 dc_ptr[(n & 1) + (n >> 1) *
s->b8_stride] = (
dc + 4) >> 3;
1270 if (!
s->cur_pic.f->data[2])
1274 for (y = 0; y < 8; y++) {
1276 for (x = 0; x < 8; x++) {
1277 dcu += dest_cb[x + y * linesize[1]];
1278 dcv += dest_cr[x + y * linesize[2]];
1281 s->dc_val[1][mb_x + mb_y *
s->mb_stride] = (dcu + 4) >> 3;
1282 s->dc_val[2][mb_x + mb_y *
s->mb_stride] = (dcv + 4) >> 3;
1287 guess_dc(
s,
s->dc_val[0],
s->mb_width*2,
s->mb_height*2,
s->b8_stride, 1);
1288 guess_dc(
s,
s->dc_val[1],
s->mb_width ,
s->mb_height ,
s->mb_stride, 0);
1289 guess_dc(
s,
s->dc_val[2],
s->mb_width ,
s->mb_height ,
s->mb_stride, 0);
1293 filter181(
s->dc_val[0],
s->mb_width * 2,
s->mb_height * 2,
s->b8_stride);
1297 for (mb_y = 0; mb_y <
s->mb_height; mb_y++) {
1298 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
1299 uint8_t *dest_y, *dest_cb, *dest_cr;
1300 const int mb_xy = mb_x + mb_y *
s->mb_stride;
1301 const int mb_type =
s->cur_pic.mb_type[mb_xy];
1303 int error =
s->error_status_table[mb_xy];
1310 dest_y =
s->cur_pic.f->data[0] + mb_x * 16 + mb_y * 16 * linesize[0];
1311 dest_cb =
s->cur_pic.f->data[1] + mb_x * 8 + mb_y * 8 * linesize[1];
1312 dest_cr =
s->cur_pic.f->data[2] + mb_x * 8 + mb_y * 8 * linesize[2];
1313 if (!
s->cur_pic.f->data[2])
1314 dest_cb = dest_cr =
NULL;
1316 put_dc(
s, dest_y, dest_cb, dest_cr, mb_x, mb_y);
1324 s->mb_height * 2, linesize[0], 1);
1328 s->mb_height * 2, linesize[0], 1);
1330 if (
s->cur_pic.f->data[2]) {
1332 s->mb_height, linesize[1], 0);
1334 s->mb_height, linesize[2], 0);
1336 s->mb_height, linesize[1], 0);
1338 s->mb_height, linesize[2], 0);
1344 for (
i = 0;
i <
s->mb_num;
i++) {
1345 const int mb_xy =
s->mb_index2xy[
i];
1346 int error =
s->error_status_table[mb_xy];
1350 s->mbskip_table[mb_xy] = 0;
1352 if (
s->mbintra_table)
1353 s->mbintra_table[mb_xy] = 1;
1356 for (
i = 0;
i < 2;
i++) {
1359 s->cur_pic.ref_index[
i] =
NULL;
1360 s->cur_pic.motion_val[
i] =
NULL;