58 uint8_t *dest_cr,
int mb_x,
int mb_y)
60 int *linesize =
s->cur_pic.f->linesize;
61 int dc, dcu, dcv, y,
i;
62 for (
i = 0;
i < 4;
i++) {
63 dc =
s->dc_val[0][mb_x * 2 + (
i & 1) + (mb_y * 2 + (
i >> 1)) *
s->b8_stride];
68 for (y = 0; y < 8; y++) {
70 for (x = 0; x < 8; x++)
71 dest_y[x + (
i & 1) * 8 + (y + (
i >> 1) * 8) * linesize[0]] =
dc / 8;
74 dcu =
s->dc_val[1][mb_x + mb_y *
s->mb_stride];
75 dcv =
s->dc_val[2][mb_x + mb_y *
s->mb_stride];
86 for (y = 0; y < 8; y++) {
88 for (x = 0; x < 8; x++) {
89 dest_cb[x + y * linesize[1]] = dcu / 8;
90 dest_cr[x + y * linesize[2]] = dcv / 8;
100 for (y = 1; y <
height - 1; y++) {
103 for (x = 1; x <
width - 1; x++) {
108 dc = (
av_clip(
dc, INT_MIN/10923, INT_MAX/10923 - 32768) * 10923 + 32768) >> 16;
115 for (x = 1; x <
width - 1; x++) {
116 int prev_dc =
data[x];
118 for (y = 1; y <
height - 1; y++) {
124 dc = (
av_clip(
dc, INT_MIN/10923, INT_MAX/10923 - 32768) * 10923 + 32768) >> 16;
137 int h, ptrdiff_t
stride,
int is_luma)
148 for(b_y=0; b_y<
h; b_y++){
151 for(b_x=0; b_x<
w; b_x++){
152 int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*
s->mb_stride;
153 int error_j=
s->error_status_table[mb_index_j];
154 int intra_j =
IS_INTRA(
s->cur_pic.mb_type[mb_index_j]);
164 for(b_x=
w-1; b_x>=0; b_x--){
165 int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*
s->mb_stride;
166 int error_j=
s->error_status_table[mb_index_j];
167 int intra_j =
IS_INTRA(
s->cur_pic.mb_type[mb_index_j]);
176 for(b_x=0; b_x<
w; b_x++){
179 for(b_y=0; b_y<
h; b_y++){
180 int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*
s->mb_stride;
181 int error_j=
s->error_status_table[mb_index_j];
182 int intra_j =
IS_INTRA(
s->cur_pic.mb_type[mb_index_j]);
192 for(b_y=
h-1; b_y>=0; b_y--){
193 int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*
s->mb_stride;
194 int error_j=
s->error_status_table[mb_index_j];
195 int intra_j =
IS_INTRA(
s->cur_pic.mb_type[mb_index_j]);
205 for (b_y = 0; b_y <
h; b_y++) {
206 for (b_x = 0; b_x <
w; b_x++) {
207 int mb_index,
error, j;
208 int64_t guess, weight_sum;
209 mb_index = (b_x >> is_luma) + (b_y >> is_luma) *
s->mb_stride;
210 error =
s->error_status_table[mb_index];
212 if (
IS_INTER(
s->cur_pic.mb_type[mb_index]))
219 for (j = 0; j < 4; j++) {
224 guess = (guess + weight_sum / 2) / weight_sum;
240 int h, ptrdiff_t
stride,
int is_luma)
243 ptrdiff_t mvx_stride, mvy_stride;
246 mvx_stride >>= is_luma;
247 mvy_stride *= mvx_stride;
249 for (b_y = 0; b_y <
h; b_y++) {
250 for (b_x = 0; b_x <
w - 1; b_x++) {
252 int left_status =
s->error_status_table[( b_x >> is_luma) + (b_y >> is_luma) *
s->mb_stride];
253 int right_status =
s->error_status_table[((b_x + 1) >> is_luma) + (b_y >> is_luma) *
s->mb_stride];
254 int left_intra =
IS_INTRA(
s->cur_pic.mb_type[( b_x >> is_luma) + (b_y >> is_luma) *
s->mb_stride]);
255 int right_intra =
IS_INTRA(
s->cur_pic.mb_type[((b_x + 1) >> is_luma) + (b_y >> is_luma) *
s->mb_stride]);
259 int16_t *left_mv =
s->cur_pic.motion_val[0][mvy_stride * b_y + mvx_stride * b_x];
260 int16_t *right_mv =
s->cur_pic.motion_val[0][mvy_stride * b_y + mvx_stride * (b_x + 1)];
261 if (!(left_damage || right_damage))
263 if ((!left_intra) && (!right_intra) &&
264 FFABS(left_mv[0] - right_mv[0]) +
265 FFABS(left_mv[1] + right_mv[1]) < 2)
268 for (y = 0; y < 8; y++) {
283 if (!(left_damage && right_damage))
309 ptrdiff_t
stride,
int is_luma)
312 ptrdiff_t mvx_stride, mvy_stride;
315 mvx_stride >>= is_luma;
316 mvy_stride *= mvx_stride;
318 for (b_y = 0; b_y <
h - 1; b_y++) {
319 for (b_x = 0; b_x <
w; b_x++) {
321 int top_status =
s->error_status_table[(b_x >> is_luma) + (b_y >> is_luma) *
s->mb_stride];
322 int bottom_status =
s->error_status_table[(b_x >> is_luma) + ((b_y + 1) >> is_luma) *
s->mb_stride];
323 int top_intra =
IS_INTRA(
s->cur_pic.mb_type[(b_x >> is_luma) + ( b_y >> is_luma) *
s->mb_stride]);
324 int bottom_intra =
IS_INTRA(
s->cur_pic.mb_type[(b_x >> is_luma) + ((b_y + 1) >> is_luma) *
s->mb_stride]);
329 int16_t *top_mv =
s->cur_pic.motion_val[0][mvy_stride * b_y + mvx_stride * b_x];
330 int16_t *bottom_mv =
s->cur_pic.motion_val[0][mvy_stride * (b_y + 1) + mvx_stride * b_x];
332 if (!(top_damage || bottom_damage))
335 if ((!top_intra) && (!bottom_intra) &&
336 FFABS(top_mv[0] - bottom_mv[0]) +
337 FFABS(top_mv[1] + bottom_mv[1]) < 2)
340 for (x = 0; x < 8; x++) {
355 if (!(top_damage && bottom_damage))
377 #define MV_UNCHANGED 2
384 blocklist[ *blocklist_length ][0] = mb_x;
385 blocklist[(*blocklist_length)++][1] = mb_y;
390 int (*blocklist)[2], (*next_blocklist)[2];
392 const ptrdiff_t mb_stride =
s->mb_stride;
393 const int mb_width =
s->mb_width;
394 int mb_height =
s->mb_height;
397 ptrdiff_t mot_step, mot_stride;
398 int blocklist_length, next_blocklist_length;
400 if (
s->last_pic.f &&
s->last_pic.f->data[0])
401 mb_height =
FFMIN(mb_height, (
s->last_pic.f->height+15)>>4);
402 if (
s->next_pic.f &&
s->next_pic.f->data[0])
403 mb_height =
FFMIN(mb_height, (
s->next_pic.f->height+15)>>4);
405 blocklist = (
int (*)[2])
s->er_temp_buffer;
406 next_blocklist = blocklist +
s->mb_stride *
s->mb_height;
407 fixed = (uint8_t *)(next_blocklist +
s->mb_stride *
s->mb_height);
412 if (
s->last_pic.motion_val[0])
414 for (
i = 0;
i < mb_width * mb_height;
i++) {
415 const int mb_xy =
s->mb_index2xy[
i];
417 int error =
s->error_status_table[mb_xy];
427 else if(
s->last_pic.f->data[0] &&
s->last_pic.motion_val[0]){
428 const int mb_y= mb_xy /
s->mb_stride;
429 const int mb_x= mb_xy %
s->mb_stride;
430 const int mot_index= (mb_x + mb_y*mot_stride) * mot_step;
431 s->cur_pic.motion_val[0][mot_index][0]=
s->last_pic.motion_val[0][mot_index][0];
432 s->cur_pic.motion_val[0][mot_index][1]=
s->last_pic.motion_val[0][mot_index][1];
433 s->cur_pic.ref_index[0][4*mb_xy] =
s->last_pic.ref_index[0][4*mb_xy];
438 num_avail <=
FFMAX(mb_width, mb_height) / 2) {
439 for (mb_y = 0; mb_y < mb_height; mb_y++) {
440 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
441 const int mb_xy = mb_x + mb_y *
s->mb_stride;
458 blocklist_length = 0;
459 for (mb_y = 0; mb_y < mb_height; mb_y++) {
460 for (mb_x = 0; mb_x < mb_width; mb_x++) {
461 const int mb_xy = mb_x + mb_y * mb_stride;
463 if (mb_x)
add_blocklist(blocklist, &blocklist_length,
fixed, mb_x - 1, mb_y, mb_xy - 1);
464 if (mb_y)
add_blocklist(blocklist, &blocklist_length,
fixed, mb_x, mb_y - 1, mb_xy - mb_stride);
465 if (mb_x+1 < mb_width)
add_blocklist(blocklist, &blocklist_length,
fixed, mb_x + 1, mb_y, mb_xy + 1);
466 if (mb_y+1 < mb_height)
add_blocklist(blocklist, &blocklist_length,
fixed, mb_x, mb_y + 1, mb_xy + mb_stride);
472 int changed, pass, none_left;
477 for (pass = 0; (changed || pass < 2) && pass < 10; pass++) {
479 for (blocklist_index = 0; blocklist_index < blocklist_length; blocklist_index++) {
480 const int mb_x = blocklist[blocklist_index][0];
481 const int mb_y = blocklist[blocklist_index][1];
482 const int mb_xy = mb_x + mb_y * mb_stride;
483 int mv_predictor[8][2];
490 int prev_x, prev_y, prev_ref;
492 if ((mb_x ^ mb_y ^ pass) & 1)
502 j |=
fixed[mb_xy - 1];
503 if (mb_x + 1 < mb_width)
504 j |=
fixed[mb_xy + 1];
506 j |=
fixed[mb_xy - mb_stride];
507 if (mb_y + 1 < mb_height)
508 j |=
fixed[mb_xy + mb_stride];
517 mot_index = (mb_x + mb_y * mot_stride) * mot_step;
519 if (mb_x > 0 &&
fixed[mb_xy - 1] > 1) {
520 mv_predictor[pred_count][0] =
521 s->cur_pic.motion_val[0][mot_index - mot_step][0];
522 mv_predictor[pred_count][1] =
523 s->cur_pic.motion_val[0][mot_index - mot_step][1];
525 s->cur_pic.ref_index[0][4 * (mb_xy - 1)];
528 if (mb_x + 1 < mb_width &&
fixed[mb_xy + 1] > 1) {
529 mv_predictor[pred_count][0] =
530 s->cur_pic.motion_val[0][mot_index + mot_step][0];
531 mv_predictor[pred_count][1] =
532 s->cur_pic.motion_val[0][mot_index + mot_step][1];
534 s->cur_pic.ref_index[0][4 * (mb_xy + 1)];
537 if (mb_y > 0 &&
fixed[mb_xy - mb_stride] > 1) {
538 mv_predictor[pred_count][0] =
539 s->cur_pic.motion_val[0][mot_index - mot_stride * mot_step][0];
540 mv_predictor[pred_count][1] =
541 s->cur_pic.motion_val[0][mot_index - mot_stride * mot_step][1];
543 s->cur_pic.ref_index[0][4 * (mb_xy -
s->mb_stride)];
546 if (mb_y + 1<mb_height &&
fixed[mb_xy + mb_stride] > 1) {
547 mv_predictor[pred_count][0] =
548 s->cur_pic.motion_val[0][mot_index + mot_stride * mot_step][0];
549 mv_predictor[pred_count][1] =
550 s->cur_pic.motion_val[0][mot_index + mot_stride * mot_step][1];
552 s->cur_pic.ref_index[0][4 * (mb_xy +
s->mb_stride)];
558 if (pred_count > 1) {
559 int sum_x = 0, sum_y = 0, sum_r = 0;
560 int max_x, max_y, min_x, min_y, max_r, min_r;
562 for (j = 0; j < pred_count; j++) {
563 sum_x += mv_predictor[j][0];
564 sum_y += mv_predictor[j][1];
566 if (j &&
ref[j] !=
ref[j - 1])
567 goto skip_mean_and_median;
571 mv_predictor[pred_count][0] = sum_x / j;
572 mv_predictor[pred_count][1] = sum_y / j;
573 ref[pred_count] = sum_r / j;
576 if (pred_count >= 3) {
577 min_y = min_x = min_r = 99999;
578 max_y = max_x = max_r = -99999;
580 min_x = min_y = max_x = max_y = min_r = max_r = 0;
582 for (j = 0; j < pred_count; j++) {
583 max_x =
FFMAX(max_x, mv_predictor[j][0]);
584 max_y =
FFMAX(max_y, mv_predictor[j][1]);
586 min_x =
FFMIN(min_x, mv_predictor[j][0]);
587 min_y =
FFMIN(min_y, mv_predictor[j][1]);
590 mv_predictor[pred_count + 1][0] = sum_x - max_x - min_x;
591 mv_predictor[pred_count + 1][1] = sum_y - max_y - min_y;
592 ref[pred_count + 1] = sum_r - max_r - min_r;
594 if (pred_count == 4) {
595 mv_predictor[pred_count + 1][0] /= 2;
596 mv_predictor[pred_count + 1][1] /= 2;
597 ref[pred_count + 1] /= 2;
602 skip_mean_and_median:
604 mv_predictor[pred_count][0] =
605 mv_predictor[pred_count][1] =
609 prev_x =
s->cur_pic.motion_val[0][mot_index][0];
610 prev_y =
s->cur_pic.motion_val[0][mot_index][1];
611 prev_ref =
s->cur_pic.ref_index[0][4 * mb_xy];
614 mv_predictor[pred_count][0] = prev_x;
615 mv_predictor[pred_count][1] = prev_y;
616 ref[pred_count] = prev_ref;
620 best_score = 256 * 256 * 256 * 64;
621 for (j = 0; j < pred_count; j++) {
622 int *linesize =
s->cur_pic.f->linesize;
624 uint8_t *
src =
s->cur_pic.f->data[0] +
625 mb_x * 16 + mb_y * 16 * linesize[0];
627 s->cur_pic.motion_val[0][mot_index][0] =
628 s->mv[0][0][0] = mv_predictor[j][0];
629 s->cur_pic.motion_val[0][mot_index][1] =
630 s->mv[0][0][1] = mv_predictor[j][1];
639 if (mb_x > 0 &&
fixed[mb_xy - 1] > 1) {
641 for (k = 0; k < 16; k++)
642 score +=
FFABS(
src[k * linesize[0] - 1] -
643 src[k * linesize[0]]);
645 if (mb_x + 1 < mb_width &&
fixed[mb_xy + 1] > 1) {
647 for (k = 0; k < 16; k++)
648 score +=
FFABS(
src[k * linesize[0] + 15] -
649 src[k * linesize[0] + 16]);
651 if (mb_y > 0 &&
fixed[mb_xy - mb_stride] > 1) {
653 for (k = 0; k < 16; k++)
656 if (mb_y + 1 < mb_height &&
fixed[mb_xy + mb_stride] > 1) {
658 for (k = 0; k < 16; k++)
659 score +=
FFABS(
src[k + linesize[0] * 15] -
660 src[k + linesize[0] * 16]);
663 if (score <= best_score) {
668 s->mv[0][0][0] = mv_predictor[best_pred][0];
669 s->mv[0][0][1] = mv_predictor[best_pred][1];
671 for (
i = 0;
i < mot_step;
i++)
672 for (j = 0; j < mot_step; j++) {
673 s->cur_pic.motion_val[0][mot_index +
i + j * mot_stride][0] =
s->mv[0][0][0];
674 s->cur_pic.motion_val[0][mot_index +
i + j * mot_stride][1] =
s->mv[0][0][1];
681 if (
s->mv[0][0][0] != prev_x ||
s->mv[0][0][1] != prev_y) {
692 next_blocklist_length = 0;
694 for (blocklist_index = 0; blocklist_index < blocklist_length; blocklist_index++) {
695 const int mb_x = blocklist[blocklist_index][0];
696 const int mb_y = blocklist[blocklist_index][1];
697 const int mb_xy = mb_x + mb_y * mb_stride;
702 add_blocklist(next_blocklist, &next_blocklist_length,
fixed, mb_x - 1, mb_y, mb_xy - 1);
704 add_blocklist(next_blocklist, &next_blocklist_length,
fixed, mb_x, mb_y - 1, mb_xy - mb_stride);
705 if (mb_x + 1 < mb_width)
706 add_blocklist(next_blocklist, &next_blocklist_length,
fixed, mb_x + 1, mb_y, mb_xy + 1);
707 if (mb_y + 1 < mb_height)
708 add_blocklist(next_blocklist, &next_blocklist_length,
fixed, mb_x, mb_y + 1, mb_xy + mb_stride);
711 av_assert0(next_blocklist_length <= mb_height * mb_width);
712 FFSWAP(
int , blocklist_length, next_blocklist_length);
713 FFSWAP(
void*, blocklist, next_blocklist);
719 int is_intra_likely,
i, j, undamaged_count, skip_amount, mb_x, mb_y;
721 if (!
s->last_pic.f || !
s->last_pic.f->data[0])
728 for (
i = 0;
i <
s->mb_num;
i++) {
729 const int mb_xy =
s->mb_index2xy[
i];
730 const int error =
s->error_status_table[mb_xy];
735 if (undamaged_count < 5)
738 skip_amount =
FFMAX(undamaged_count / 50, 1);
742 for (mb_y = 0; mb_y <
s->mb_height - 1; mb_y++) {
743 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
745 const int mb_xy = mb_x + mb_y *
s->mb_stride;
747 error =
s->error_status_table[mb_xy];
753 if ((j % skip_amount) != 0)
757 int *linesize =
s->cur_pic.f->linesize;
758 uint8_t *mb_ptr =
s->cur_pic.f->data[0] +
759 mb_x * 16 + mb_y * 16 * linesize[0];
760 uint8_t *last_mb_ptr =
s->last_pic.f->data[0] +
761 mb_x * 16 + mb_y * 16 * linesize[0];
768 is_intra_likely +=
s->sad(
NULL, last_mb_ptr, mb_ptr,
771 is_intra_likely -=
s->sad(
NULL, last_mb_ptr,
772 last_mb_ptr + linesize[0] * 16,
783 return is_intra_likely > 0;
788 if (!
s->avctx->error_concealment)
791 if (!
s->mecc_inited) {
794 s->sad = mecc.
sad[0];
799 s->mb_stride *
s->mb_height *
sizeof(uint8_t));
801 s->error_occurred = 0;
806 if (
s->avctx->hwaccel ||
808 s->cur_pic.field_picture
822 int endx,
int endy,
int status)
824 const int start_i =
av_clip(startx + starty *
s->mb_width, 0,
s->mb_num - 1);
825 const int end_i =
av_clip(endx + endy *
s->mb_width, 0,
s->mb_num);
826 const int start_xy =
s->mb_index2xy[start_i];
827 const int end_xy =
s->mb_index2xy[end_i];
830 if (
s->avctx->hwaccel)
833 if (start_i > end_i || start_xy > end_xy) {
835 "internal error, slice end before start\n");
839 if (!
s->avctx->error_concealment)
857 s->error_occurred = 1;
862 memset(&
s->error_status_table[start_xy], 0,
863 (end_xy - start_xy) *
sizeof(uint8_t));
866 for (
i = start_xy;
i < end_xy;
i++)
867 s->error_status_table[
i] &=
mask;
870 if (end_i ==
s->mb_num)
873 s->error_status_table[end_xy] &=
mask;
874 s->error_status_table[end_xy] |=
status;
877 s->error_status_table[start_xy] |=
VP_START;
881 int prev_status =
s->error_status_table[
s->mb_index2xy[start_i - 1]];
885 s->error_occurred = 1;
893 int *linesize =
NULL;
894 int i, mb_x, mb_y,
error, error_type, dc_error, mv_error, ac_error;
896 int threshold_part[4] = { 100, 100, 100 };
899 int size =
s->b8_stride * 2 *
s->mb_height;
903 if (!
s->avctx->error_concealment || !
atomic_load(&
s->error_count) ||
907 (
s->avctx->skip_top +
s->avctx->skip_bottom)) {
910 linesize =
s->cur_pic.f->linesize;
913 && (
FFALIGN(
s->avctx->height, 16)&16)
914 &&
atomic_load(&
s->error_count) == 3 *
s->mb_width * (
s->avctx->skip_top +
s->avctx->skip_bottom + 1)) {
915 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
916 int status =
s->error_status_table[mb_x + (
s->mb_height - 1) *
s->mb_stride];
921 if (mb_x ==
s->mb_width) {
928 if (
s->last_pic.f->width !=
s->cur_pic.f->width ||
929 s->last_pic.f->height !=
s->cur_pic.f->height ||
930 s->last_pic.f->format !=
s->cur_pic.f->format) {
932 memset(&
s->last_pic, 0,
sizeof(
s->last_pic));
936 if (
s->next_pic.f->width !=
s->cur_pic.f->width ||
937 s->next_pic.f->height !=
s->cur_pic.f->height ||
938 s->next_pic.f->format !=
s->cur_pic.f->format) {
940 memset(&
s->next_pic, 0,
sizeof(
s->next_pic));
944 if (!
s->cur_pic.motion_val[0] || !
s->cur_pic.ref_index[0]) {
947 for (
i = 0;
i < 2;
i++) {
948 s->ref_index[
i] =
av_calloc(
s->mb_stride *
s->mb_height, 4 *
sizeof(uint8_t));
950 if (!
s->ref_index[
i] || !
s->motion_val_base[
i])
952 s->cur_pic.ref_index[
i] =
s->ref_index[
i];
953 s->cur_pic.motion_val[
i] =
s->motion_val_base[
i] + 4;
956 for (
i = 0;
i < 2;
i++) {
959 s->cur_pic.ref_index[
i] =
NULL;
960 s->cur_pic.motion_val[
i] =
NULL;
967 for (mb_y = 0; mb_y <
s->mb_height; mb_y++) {
968 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
969 int status =
s->error_status_table[mb_x + mb_y *
s->mb_stride];
979 for (error_type = 1; error_type <= 3; error_type++) {
982 for (
i =
s->mb_num - 1;
i >= 0;
i--) {
983 const int mb_xy =
s->mb_index2xy[
i];
984 int error =
s->error_status_table[mb_xy];
986 if (
error & (1 << error_type))
988 if (
error & (8 << error_type))
992 s->error_status_table[mb_xy] |= 1 << error_type;
1001 if (
s->partitioned_frame) {
1004 for (
i =
s->mb_num - 1;
i >= 0;
i--) {
1005 const int mb_xy =
s->mb_index2xy[
i];
1006 int error =
s->error_status_table[mb_xy];
1028 for (
i =
s->mb_num - 2;
i >=
s->mb_width + 100;
i--) {
1029 const int mb_xy =
s->mb_index2xy[
i];
1030 int error1 =
s->error_status_table[mb_xy];
1031 int error2 =
s->error_status_table[
s->mb_index2xy[
i + 1]];
1052 for (error_type = 1; error_type <= 3; error_type++) {
1053 for (
i =
s->mb_num - 1;
i >= 0;
i--) {
1054 const int mb_xy =
s->mb_index2xy[
i];
1055 int error =
s->error_status_table[mb_xy];
1057 if (!
s->mbskip_table || !
s->mbskip_table[mb_xy])
1059 if (
error & (1 << error_type))
1062 if (
s->partitioned_frame) {
1063 if (
distance < threshold_part[error_type - 1])
1064 s->error_status_table[mb_xy] |= 1 << error_type;
1067 s->error_status_table[mb_xy] |= 1 << error_type;
1078 for (
i = 0;
i <
s->mb_num;
i++) {
1079 const int mb_xy =
s->mb_index2xy[
i];
1080 int old_error =
s->error_status_table[mb_xy];
1086 s->error_status_table[mb_xy] |=
error;
1091 if (!
s->partitioned_frame) {
1092 for (
i = 0;
i <
s->mb_num;
i++) {
1093 const int mb_xy =
s->mb_index2xy[
i];
1094 int error =
s->error_status_table[mb_xy];
1097 s->error_status_table[mb_xy] =
error;
1102 dc_error = ac_error = mv_error = 0;
1103 for (
i = 0;
i <
s->mb_num;
i++) {
1104 const int mb_xy =
s->mb_index2xy[
i];
1105 int error =
s->error_status_table[mb_xy];
1116 if (decode_error_flags)
1124 for (
i = 0;
i <
s->mb_num;
i++) {
1125 const int mb_xy =
s->mb_index2xy[
i];
1126 int error =
s->error_status_table[mb_xy];
1130 if (is_intra_likely)
1137 if (!(
s->last_pic.f &&
s->last_pic.f->data[0]) &&
1138 !(
s->next_pic.f &&
s->next_pic.f->data[0]))
1139 for (
i = 0;
i <
s->mb_num;
i++) {
1140 const int mb_xy =
s->mb_index2xy[
i];
1141 if (!
IS_INTRA(
s->cur_pic.mb_type[mb_xy]))
1146 for (mb_y = 0; mb_y <
s->mb_height; mb_y++) {
1147 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
1148 const int mb_xy = mb_x + mb_y *
s->mb_stride;
1149 const int mb_type =
s->cur_pic.mb_type[mb_xy];
1150 const int dir = !(
s->last_pic.f &&
s->last_pic.f->data[0]);
1154 int error =
s->error_status_table[mb_xy];
1164 int mb_index = mb_x * 2 + mb_y * 2 *
s->b8_stride;
1167 for (j = 0; j < 4; j++) {
1168 s->mv[0][j][0] =
s->cur_pic.motion_val[dir][mb_index + (j & 1) + (j >> 1) *
s->b8_stride][0];
1169 s->mv[0][j][1] =
s->cur_pic.motion_val[dir][mb_index + (j & 1) + (j >> 1) *
s->b8_stride][1];
1173 s->mv[0][0][0] =
s->cur_pic.motion_val[dir][mb_x * 2 + mb_y * 2 *
s->b8_stride][0];
1174 s->mv[0][0][1] =
s->cur_pic.motion_val[dir][mb_x * 2 + mb_y * 2 *
s->b8_stride][1];
1177 s->decode_mb(
s->opaque, 0 ,
1178 mv_dir, mv_type, &
s->mv, mb_x, mb_y, 0, 0);
1184 for (mb_y = 0; mb_y <
s->mb_height; mb_y++) {
1185 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
1186 int xy = mb_x * 2 + mb_y * 2 *
s->b8_stride;
1187 const int mb_xy = mb_x + mb_y *
s->mb_stride;
1188 const int mb_type =
s->cur_pic.mb_type[mb_xy];
1191 int error =
s->error_status_table[mb_xy];
1200 if (!(
s->last_pic.f &&
s->last_pic.f->data[0]))
1202 if (!(
s->next_pic.f &&
s->next_pic.f->data[0]))
1206 int time_pp =
s->pp_time;
1207 int time_pb =
s->pb_time;
1212 s->mv[0][0][0] =
s->next_pic.motion_val[0][xy][0] * time_pb / time_pp;
1213 s->mv[0][0][1] =
s->next_pic.motion_val[0][xy][1] * time_pb / time_pp;
1214 s->mv[1][0][0] =
s->next_pic.motion_val[0][xy][0] * (time_pb - time_pp) / time_pp;
1215 s->mv[1][0][1] =
s->next_pic.motion_val[0][xy][1] * (time_pb - time_pp) / time_pp;
1231 for (mb_y = 0; mb_y <
s->mb_height; mb_y++) {
1232 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
1233 int dc, dcu, dcv, y, n;
1235 uint8_t *dest_y, *dest_cb, *dest_cr;
1236 const int mb_xy = mb_x + mb_y *
s->mb_stride;
1237 const int mb_type =
s->cur_pic.mb_type[mb_xy];
1241 if (
IS_INTRA(mb_type) &&
s->partitioned_frame)
1246 dest_y =
s->cur_pic.f->data[0] + mb_x * 16 + mb_y * 16 * linesize[0];
1247 dest_cb =
s->cur_pic.f->data[1] + mb_x * 8 + mb_y * 8 * linesize[1];
1248 dest_cr =
s->cur_pic.f->data[2] + mb_x * 8 + mb_y * 8 * linesize[2];
1250 dc_ptr = &
s->dc_val[0][mb_x * 2 + mb_y * 2 *
s->b8_stride];
1251 for (n = 0; n < 4; n++) {
1253 for (y = 0; y < 8; y++) {
1255 for (x = 0; x < 8; x++)
1256 dc += dest_y[x + (n & 1) * 8 +
1257 (y + (n >> 1) * 8) * linesize[0]];
1259 dc_ptr[(n & 1) + (n >> 1) *
s->b8_stride] = (
dc + 4) >> 3;
1262 if (!
s->cur_pic.f->data[2])
1266 for (y = 0; y < 8; y++) {
1268 for (x = 0; x < 8; x++) {
1269 dcu += dest_cb[x + y * linesize[1]];
1270 dcv += dest_cr[x + y * linesize[2]];
1273 s->dc_val[1][mb_x + mb_y *
s->mb_stride] = (dcu + 4) >> 3;
1274 s->dc_val[2][mb_x + mb_y *
s->mb_stride] = (dcv + 4) >> 3;
1279 guess_dc(
s,
s->dc_val[0],
s->mb_width*2,
s->mb_height*2,
s->b8_stride, 1);
1280 guess_dc(
s,
s->dc_val[1],
s->mb_width ,
s->mb_height ,
s->mb_stride, 0);
1281 guess_dc(
s,
s->dc_val[2],
s->mb_width ,
s->mb_height ,
s->mb_stride, 0);
1285 filter181(
s->dc_val[0],
s->mb_width * 2,
s->mb_height * 2,
s->b8_stride);
1289 for (mb_y = 0; mb_y <
s->mb_height; mb_y++) {
1290 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
1291 uint8_t *dest_y, *dest_cb, *dest_cr;
1292 const int mb_xy = mb_x + mb_y *
s->mb_stride;
1293 const int mb_type =
s->cur_pic.mb_type[mb_xy];
1295 int error =
s->error_status_table[mb_xy];
1302 dest_y =
s->cur_pic.f->data[0] + mb_x * 16 + mb_y * 16 * linesize[0];
1303 dest_cb =
s->cur_pic.f->data[1] + mb_x * 8 + mb_y * 8 * linesize[1];
1304 dest_cr =
s->cur_pic.f->data[2] + mb_x * 8 + mb_y * 8 * linesize[2];
1305 if (!
s->cur_pic.f->data[2])
1306 dest_cb = dest_cr =
NULL;
1308 put_dc(
s, dest_y, dest_cb, dest_cr, mb_x, mb_y);
1316 s->mb_height * 2, linesize[0], 1);
1320 s->mb_height * 2, linesize[0], 1);
1322 if (
s->cur_pic.f->data[2]) {
1324 s->mb_height, linesize[1], 0);
1326 s->mb_height, linesize[2], 0);
1328 s->mb_height, linesize[1], 0);
1330 s->mb_height, linesize[2], 0);
1335 for (
i = 0;
i <
s->mb_num;
i++) {
1336 const int mb_xy =
s->mb_index2xy[
i];
1337 int error =
s->error_status_table[mb_xy];
1341 s->mbskip_table[mb_xy] = 0;
1343 if (
s->mbintra_table)
1344 s->mbintra_table[mb_xy] = 1;
1347 for (
i = 0;
i < 2;
i++) {
1350 s->cur_pic.ref_index[
i] =
NULL;
1351 s->cur_pic.motion_val[
i] =
NULL;