45 unsigned mb_array_size =
s->mb_height *
s->mb_stride;
48 if (!
s->error_status_table)
51 if (!
s->er_temp_buffer)
80 uint8_t *dest_cr,
int mb_x,
int mb_y)
82 int *linesize =
s->cur_pic.f->linesize;
83 int dc, dcu, dcv, y,
i;
84 for (
i = 0;
i < 4;
i++) {
85 dc =
s->dc_val[0][mb_x * 2 + (
i & 1) + (mb_y * 2 + (
i >> 1)) *
s->b8_stride];
90 for (y = 0; y < 8; y++) {
92 for (x = 0; x < 8; x++)
93 dest_y[x + (
i & 1) * 8 + (y + (
i >> 1) * 8) * linesize[0]] =
dc / 8;
96 dcu =
s->dc_val[1][mb_x + mb_y *
s->mb_stride];
97 dcv =
s->dc_val[2][mb_x + mb_y *
s->mb_stride];
108 for (y = 0; y < 8; y++) {
110 for (x = 0; x < 8; x++) {
111 dest_cb[x + y * linesize[1]] = dcu / 8;
112 dest_cr[x + y * linesize[2]] = dcv / 8;
122 for (y = 1; y <
height - 1; y++) {
125 for (x = 1; x <
width - 1; x++) {
130 dc = (
av_clip(
dc, INT_MIN/10923, INT_MAX/10923 - 32768) * 10923 + 32768) >> 16;
137 for (x = 1; x <
width - 1; x++) {
138 int prev_dc =
data[x];
140 for (y = 1; y <
height - 1; y++) {
146 dc = (
av_clip(
dc, INT_MIN/10923, INT_MAX/10923 - 32768) * 10923 + 32768) >> 16;
159 int h, ptrdiff_t
stride,
int is_luma)
170 for(b_y=0; b_y<
h; b_y++){
173 for(b_x=0; b_x<
w; b_x++){
174 int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*
s->mb_stride;
175 int error_j=
s->error_status_table[mb_index_j];
176 int intra_j =
IS_INTRA(
s->cur_pic.mb_type[mb_index_j]);
186 for(b_x=
w-1; b_x>=0; b_x--){
187 int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*
s->mb_stride;
188 int error_j=
s->error_status_table[mb_index_j];
189 int intra_j =
IS_INTRA(
s->cur_pic.mb_type[mb_index_j]);
198 for(b_x=0; b_x<
w; b_x++){
201 for(b_y=0; b_y<
h; b_y++){
202 int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*
s->mb_stride;
203 int error_j=
s->error_status_table[mb_index_j];
204 int intra_j =
IS_INTRA(
s->cur_pic.mb_type[mb_index_j]);
214 for(b_y=
h-1; b_y>=0; b_y--){
215 int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*
s->mb_stride;
216 int error_j=
s->error_status_table[mb_index_j];
217 int intra_j =
IS_INTRA(
s->cur_pic.mb_type[mb_index_j]);
227 for (b_y = 0; b_y <
h; b_y++) {
228 for (b_x = 0; b_x <
w; b_x++) {
229 int mb_index,
error, j;
231 mb_index = (b_x >> is_luma) + (b_y >> is_luma) *
s->mb_stride;
232 error =
s->error_status_table[mb_index];
234 if (
IS_INTER(
s->cur_pic.mb_type[mb_index]))
241 for (j = 0; j < 4; j++) {
246 guess = (guess + weight_sum / 2) / weight_sum;
262 int h, ptrdiff_t
stride,
int is_luma)
265 ptrdiff_t mvx_stride, mvy_stride;
268 mvx_stride >>= is_luma;
269 mvy_stride *= mvx_stride;
271 for (b_y = 0; b_y <
h; b_y++) {
272 for (b_x = 0; b_x <
w - 1; b_x++) {
274 int left_status =
s->error_status_table[( b_x >> is_luma) + (b_y >> is_luma) *
s->mb_stride];
275 int right_status =
s->error_status_table[((b_x + 1) >> is_luma) + (b_y >> is_luma) *
s->mb_stride];
276 int left_intra =
IS_INTRA(
s->cur_pic.mb_type[( b_x >> is_luma) + (b_y >> is_luma) *
s->mb_stride]);
277 int right_intra =
IS_INTRA(
s->cur_pic.mb_type[((b_x + 1) >> is_luma) + (b_y >> is_luma) *
s->mb_stride]);
281 int16_t *left_mv =
s->cur_pic.motion_val[0][mvy_stride * b_y + mvx_stride * b_x];
282 int16_t *right_mv =
s->cur_pic.motion_val[0][mvy_stride * b_y + mvx_stride * (b_x + 1)];
283 if (!(left_damage || right_damage))
285 if ((!left_intra) && (!right_intra) &&
286 FFABS(left_mv[0] - right_mv[0]) +
287 FFABS(left_mv[1] + right_mv[1]) < 2)
290 for (y = 0; y < 8; y++) {
305 if (!(left_damage && right_damage))
331 ptrdiff_t
stride,
int is_luma)
334 ptrdiff_t mvx_stride, mvy_stride;
337 mvx_stride >>= is_luma;
338 mvy_stride *= mvx_stride;
340 for (b_y = 0; b_y <
h - 1; b_y++) {
341 for (b_x = 0; b_x <
w; b_x++) {
343 int top_status =
s->error_status_table[(b_x >> is_luma) + (b_y >> is_luma) *
s->mb_stride];
344 int bottom_status =
s->error_status_table[(b_x >> is_luma) + ((b_y + 1) >> is_luma) *
s->mb_stride];
345 int top_intra =
IS_INTRA(
s->cur_pic.mb_type[(b_x >> is_luma) + ( b_y >> is_luma) *
s->mb_stride]);
346 int bottom_intra =
IS_INTRA(
s->cur_pic.mb_type[(b_x >> is_luma) + ((b_y + 1) >> is_luma) *
s->mb_stride]);
351 int16_t *top_mv =
s->cur_pic.motion_val[0][mvy_stride * b_y + mvx_stride * b_x];
352 int16_t *bottom_mv =
s->cur_pic.motion_val[0][mvy_stride * (b_y + 1) + mvx_stride * b_x];
354 if (!(top_damage || bottom_damage))
357 if ((!top_intra) && (!bottom_intra) &&
358 FFABS(top_mv[0] - bottom_mv[0]) +
359 FFABS(top_mv[1] + bottom_mv[1]) < 2)
362 for (x = 0; x < 8; x++) {
377 if (!(top_damage && bottom_damage))
399 #define MV_UNCHANGED 2
406 blocklist[ *blocklist_length ][0] = mb_x;
407 blocklist[(*blocklist_length)++][1] = mb_y;
412 int (*blocklist)[2], (*next_blocklist)[2];
414 const ptrdiff_t mb_stride =
s->mb_stride;
415 const int mb_width =
s->mb_width;
416 int mb_height =
s->mb_height;
419 ptrdiff_t mot_step, mot_stride;
420 int blocklist_length, next_blocklist_length;
422 if (
s->last_pic.f &&
s->last_pic.f->data[0])
423 mb_height =
FFMIN(mb_height, (
s->last_pic.f->height+15)>>4);
424 if (
s->next_pic.f &&
s->next_pic.f->data[0])
425 mb_height =
FFMIN(mb_height, (
s->next_pic.f->height+15)>>4);
427 blocklist = (int (*)[2])
s->er_temp_buffer;
428 next_blocklist = blocklist +
s->mb_stride *
s->mb_height;
429 fixed = (uint8_t *)(next_blocklist +
s->mb_stride *
s->mb_height);
434 if (
s->last_pic.motion_val[0]) {
440 for (
i = 0;
i < mb_width * mb_height;
i++) {
441 const int mb_xy =
s->mb_index2xy[
i];
443 int error =
s->error_status_table[mb_xy];
453 else if(
s->last_pic.f->data[0] &&
s->last_pic.motion_val[0]){
454 const int mb_y= mb_xy /
s->mb_stride;
455 const int mb_x= mb_xy %
s->mb_stride;
456 const int mot_index= (mb_x + mb_y*mot_stride) * mot_step;
457 s->cur_pic.motion_val[0][mot_index][0]=
s->last_pic.motion_val[0][mot_index][0];
458 s->cur_pic.motion_val[0][mot_index][1]=
s->last_pic.motion_val[0][mot_index][1];
459 s->cur_pic.ref_index[0][4*mb_xy] =
s->last_pic.ref_index[0][4*mb_xy];
464 num_avail <=
FFMAX(mb_width, mb_height) / 2) {
465 for (mb_y = 0; mb_y < mb_height; mb_y++) {
466 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
467 const int mb_xy = mb_x + mb_y *
s->mb_stride;
484 blocklist_length = 0;
485 for (mb_y = 0; mb_y < mb_height; mb_y++) {
486 for (mb_x = 0; mb_x < mb_width; mb_x++) {
487 const int mb_xy = mb_x + mb_y * mb_stride;
489 if (mb_x)
add_blocklist(blocklist, &blocklist_length,
fixed, mb_x - 1, mb_y, mb_xy - 1);
490 if (mb_y)
add_blocklist(blocklist, &blocklist_length,
fixed, mb_x, mb_y - 1, mb_xy - mb_stride);
491 if (mb_x+1 < mb_width)
add_blocklist(blocklist, &blocklist_length,
fixed, mb_x + 1, mb_y, mb_xy + 1);
492 if (mb_y+1 < mb_height)
add_blocklist(blocklist, &blocklist_length,
fixed, mb_x, mb_y + 1, mb_xy + mb_stride);
498 int changed, pass, none_left;
503 for (pass = 0; (changed || pass < 2) && pass < 10; pass++) {
505 for (blocklist_index = 0; blocklist_index < blocklist_length; blocklist_index++) {
506 const int mb_x = blocklist[blocklist_index][0];
507 const int mb_y = blocklist[blocklist_index][1];
508 const int mb_xy = mb_x + mb_y * mb_stride;
509 int mv_predictor[8][2];
516 int prev_x, prev_y, prev_ref;
518 if ((mb_x ^ mb_y ^ pass) & 1)
528 j |=
fixed[mb_xy - 1];
529 if (mb_x + 1 < mb_width)
530 j |=
fixed[mb_xy + 1];
532 j |=
fixed[mb_xy - mb_stride];
533 if (mb_y + 1 < mb_height)
534 j |=
fixed[mb_xy + mb_stride];
543 mot_index = (mb_x + mb_y * mot_stride) * mot_step;
545 if (mb_x > 0 &&
fixed[mb_xy - 1] > 1) {
546 mv_predictor[pred_count][0] =
547 s->cur_pic.motion_val[0][mot_index - mot_step][0];
548 mv_predictor[pred_count][1] =
549 s->cur_pic.motion_val[0][mot_index - mot_step][1];
551 s->cur_pic.ref_index[0][4 * (mb_xy - 1)];
554 if (mb_x + 1 < mb_width &&
fixed[mb_xy + 1] > 1) {
555 mv_predictor[pred_count][0] =
556 s->cur_pic.motion_val[0][mot_index + mot_step][0];
557 mv_predictor[pred_count][1] =
558 s->cur_pic.motion_val[0][mot_index + mot_step][1];
560 s->cur_pic.ref_index[0][4 * (mb_xy + 1)];
563 if (mb_y > 0 &&
fixed[mb_xy - mb_stride] > 1) {
564 mv_predictor[pred_count][0] =
565 s->cur_pic.motion_val[0][mot_index - mot_stride * mot_step][0];
566 mv_predictor[pred_count][1] =
567 s->cur_pic.motion_val[0][mot_index - mot_stride * mot_step][1];
569 s->cur_pic.ref_index[0][4 * (mb_xy -
s->mb_stride)];
572 if (mb_y + 1<mb_height &&
fixed[mb_xy + mb_stride] > 1) {
573 mv_predictor[pred_count][0] =
574 s->cur_pic.motion_val[0][mot_index + mot_stride * mot_step][0];
575 mv_predictor[pred_count][1] =
576 s->cur_pic.motion_val[0][mot_index + mot_stride * mot_step][1];
578 s->cur_pic.ref_index[0][4 * (mb_xy +
s->mb_stride)];
584 if (pred_count > 1) {
585 int sum_x = 0, sum_y = 0, sum_r = 0;
586 int max_x, max_y, min_x, min_y, max_r, min_r;
588 for (j = 0; j < pred_count; j++) {
589 sum_x += mv_predictor[j][0];
590 sum_y += mv_predictor[j][1];
592 if (j &&
ref[j] !=
ref[j - 1])
593 goto skip_mean_and_median;
597 mv_predictor[pred_count][0] = sum_x / j;
598 mv_predictor[pred_count][1] = sum_y / j;
599 ref[pred_count] = sum_r / j;
602 if (pred_count >= 3) {
603 min_y = min_x = min_r = 99999;
604 max_y = max_x = max_r = -99999;
606 min_x = min_y = max_x = max_y = min_r = max_r = 0;
608 for (j = 0; j < pred_count; j++) {
609 max_x =
FFMAX(max_x, mv_predictor[j][0]);
610 max_y =
FFMAX(max_y, mv_predictor[j][1]);
612 min_x =
FFMIN(min_x, mv_predictor[j][0]);
613 min_y =
FFMIN(min_y, mv_predictor[j][1]);
616 mv_predictor[pred_count + 1][0] = sum_x - max_x - min_x;
617 mv_predictor[pred_count + 1][1] = sum_y - max_y - min_y;
618 ref[pred_count + 1] = sum_r - max_r - min_r;
620 if (pred_count == 4) {
621 mv_predictor[pred_count + 1][0] /= 2;
622 mv_predictor[pred_count + 1][1] /= 2;
623 ref[pred_count + 1] /= 2;
628 skip_mean_and_median:
630 mv_predictor[pred_count][0] =
631 mv_predictor[pred_count][1] =
635 prev_x =
s->cur_pic.motion_val[0][mot_index][0];
636 prev_y =
s->cur_pic.motion_val[0][mot_index][1];
637 prev_ref =
s->cur_pic.ref_index[0][4 * mb_xy];
640 mv_predictor[pred_count][0] = prev_x;
641 mv_predictor[pred_count][1] = prev_y;
642 ref[pred_count] = prev_ref;
646 best_score = 256 * 256 * 256 * 64;
647 for (j = 0; j < pred_count; j++) {
648 int *linesize =
s->cur_pic.f->linesize;
650 uint8_t *
src =
s->cur_pic.f->data[0] +
651 mb_x * 16 + mb_y * 16 * linesize[0];
653 s->cur_pic.motion_val[0][mot_index][0] =
654 s->mv[0][0][0] = mv_predictor[j][0];
655 s->cur_pic.motion_val[0][mot_index][1] =
656 s->mv[0][0][1] = mv_predictor[j][1];
665 if (mb_x > 0 &&
fixed[mb_xy - 1] > 1) {
667 for (k = 0; k < 16; k++)
668 score +=
FFABS(
src[k * linesize[0] - 1] -
669 src[k * linesize[0]]);
671 if (mb_x + 1 < mb_width &&
fixed[mb_xy + 1] > 1) {
673 for (k = 0; k < 16; k++)
674 score +=
FFABS(
src[k * linesize[0] + 15] -
675 src[k * linesize[0] + 16]);
677 if (mb_y > 0 &&
fixed[mb_xy - mb_stride] > 1) {
679 for (k = 0; k < 16; k++)
682 if (mb_y + 1 < mb_height &&
fixed[mb_xy + mb_stride] > 1) {
684 for (k = 0; k < 16; k++)
685 score +=
FFABS(
src[k + linesize[0] * 15] -
686 src[k + linesize[0] * 16]);
689 if (score <= best_score) {
694 s->mv[0][0][0] = mv_predictor[best_pred][0];
695 s->mv[0][0][1] = mv_predictor[best_pred][1];
697 for (
i = 0;
i < mot_step;
i++)
698 for (j = 0; j < mot_step; j++) {
699 s->cur_pic.motion_val[0][mot_index +
i + j * mot_stride][0] =
s->mv[0][0][0];
700 s->cur_pic.motion_val[0][mot_index +
i + j * mot_stride][1] =
s->mv[0][0][1];
707 if (
s->mv[0][0][0] != prev_x ||
s->mv[0][0][1] != prev_y) {
718 next_blocklist_length = 0;
720 for (blocklist_index = 0; blocklist_index < blocklist_length; blocklist_index++) {
721 const int mb_x = blocklist[blocklist_index][0];
722 const int mb_y = blocklist[blocklist_index][1];
723 const int mb_xy = mb_x + mb_y * mb_stride;
728 add_blocklist(next_blocklist, &next_blocklist_length,
fixed, mb_x - 1, mb_y, mb_xy - 1);
730 add_blocklist(next_blocklist, &next_blocklist_length,
fixed, mb_x, mb_y - 1, mb_xy - mb_stride);
731 if (mb_x + 1 < mb_width)
732 add_blocklist(next_blocklist, &next_blocklist_length,
fixed, mb_x + 1, mb_y, mb_xy + 1);
733 if (mb_y + 1 < mb_height)
734 add_blocklist(next_blocklist, &next_blocklist_length,
fixed, mb_x, mb_y + 1, mb_xy + mb_stride);
737 av_assert0(next_blocklist_length <= mb_height * mb_width);
738 FFSWAP(
int , blocklist_length, next_blocklist_length);
739 FFSWAP(
void*, blocklist, next_blocklist);
745 int is_intra_likely,
i, j, undamaged_count, skip_amount, mb_x, mb_y;
747 if (!
s->last_pic.f || !
s->last_pic.f->data[0])
754 for (
i = 0;
i <
s->mb_num;
i++) {
755 const int mb_xy =
s->mb_index2xy[
i];
756 const int error =
s->error_status_table[mb_xy];
761 if (undamaged_count < 5)
764 skip_amount =
FFMAX(undamaged_count / 50, 1);
768 for (mb_y = 0; mb_y <
s->mb_height - 1; mb_y++) {
769 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
771 const int mb_xy = mb_x + mb_y *
s->mb_stride;
773 error =
s->error_status_table[mb_xy];
779 if ((j % skip_amount) != 0)
783 int *linesize =
s->cur_pic.f->linesize;
784 uint8_t *mb_ptr =
s->cur_pic.f->data[0] +
785 mb_x * 16 + mb_y * 16 * linesize[0];
786 uint8_t *last_mb_ptr =
s->last_pic.f->data[0] +
787 mb_x * 16 + mb_y * 16 * linesize[0];
794 is_intra_likely +=
s->sad(
NULL, last_mb_ptr, mb_ptr,
797 is_intra_likely -=
s->sad(
NULL, last_mb_ptr,
798 last_mb_ptr + linesize[0] * 16,
809 return is_intra_likely > 0;
814 if (!
s->avctx->error_concealment)
818 s->mb_stride *
s->mb_height *
sizeof(uint8_t));
820 s->error_occurred = 0;
825 if (
s->avctx->hwaccel ||
827 s->cur_pic.field_picture
841 int endx,
int endy,
int status)
843 const int start_i =
av_clip(startx + starty *
s->mb_width, 0,
s->mb_num - 1);
844 const int end_i =
av_clip(endx + endy *
s->mb_width, 0,
s->mb_num);
845 const int start_xy =
s->mb_index2xy[start_i];
846 const int end_xy =
s->mb_index2xy[end_i];
849 if (
s->avctx->hwaccel)
852 if (start_i > end_i || start_xy > end_xy) {
854 "internal error, slice end before start\n");
858 if (!
s->avctx->error_concealment)
876 s->error_occurred = 1;
881 memset(&
s->error_status_table[start_xy], 0,
882 (end_xy - start_xy) *
sizeof(uint8_t));
885 for (
i = start_xy;
i < end_xy;
i++)
886 s->error_status_table[
i] &=
mask;
889 if (end_i ==
s->mb_num)
892 s->error_status_table[end_xy] &=
mask;
893 s->error_status_table[end_xy] |=
status;
896 s->error_status_table[start_xy] |=
VP_START;
900 int prev_status =
s->error_status_table[
s->mb_index2xy[start_i - 1]];
904 s->error_occurred = 1;
912 int *linesize =
NULL;
913 int i, mb_x, mb_y,
error, error_type, dc_error, mv_error, ac_error;
915 int threshold_part[4] = { 100, 100, 100 };
918 int size =
s->b8_stride * 2 *
s->mb_height;
923 if (!
s->avctx->error_concealment || !
atomic_load(&
s->error_count) ||
927 (
s->avctx->skip_top +
s->avctx->skip_bottom)) {
930 linesize =
s->cur_pic.f->linesize;
933 && (
FFALIGN(
s->avctx->height, 16)&16)
934 &&
atomic_load(&
s->error_count) == 3 *
s->mb_width * (
s->avctx->skip_top +
s->avctx->skip_bottom + 1)) {
935 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
936 int status =
s->error_status_table[mb_x + (
s->mb_height - 1) *
s->mb_stride];
941 if (mb_x ==
s->mb_width) {
948 if (
s->last_pic.f->width !=
s->cur_pic.f->width ||
949 s->last_pic.f->height !=
s->cur_pic.f->height ||
950 s->last_pic.f->format !=
s->cur_pic.f->format) {
952 memset(&
s->last_pic, 0,
sizeof(
s->last_pic));
956 if (
s->next_pic.f->width !=
s->cur_pic.f->width ||
957 s->next_pic.f->height !=
s->cur_pic.f->height ||
958 s->next_pic.f->format !=
s->cur_pic.f->format) {
960 memset(&
s->next_pic, 0,
sizeof(
s->next_pic));
964 if (!
s->cur_pic.motion_val[0] || !
s->cur_pic.ref_index[0]) {
967 for (
i = 0;
i < 2;
i++) {
968 s->ref_index[
i] =
av_calloc(
s->mb_stride *
s->mb_height, 4 *
sizeof(uint8_t));
970 if (!
s->ref_index[
i] || !
s->motion_val_base[
i])
972 s->cur_pic.ref_index[
i] =
s->ref_index[
i];
973 s->cur_pic.motion_val[
i] =
s->motion_val_base[
i] + 4;
978 for (mb_y = 0; mb_y <
s->mb_height; mb_y++) {
979 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
980 int status =
s->error_status_table[mb_x + mb_y *
s->mb_stride];
990 for (error_type = 1; error_type <= 3; error_type++) {
993 for (
i =
s->mb_num - 1;
i >= 0;
i--) {
994 const int mb_xy =
s->mb_index2xy[
i];
995 int error =
s->error_status_table[mb_xy];
997 if (
error & (1 << error_type))
999 if (
error & (8 << error_type))
1003 s->error_status_table[mb_xy] |= 1 << error_type;
1012 if (
s->partitioned_frame) {
1015 for (
i =
s->mb_num - 1;
i >= 0;
i--) {
1016 const int mb_xy =
s->mb_index2xy[
i];
1017 int error =
s->error_status_table[mb_xy];
1039 for (
i =
s->mb_num - 2;
i >=
s->mb_width + 100;
i--) {
1040 const int mb_xy =
s->mb_index2xy[
i];
1041 int error1 =
s->error_status_table[mb_xy];
1042 int error2 =
s->error_status_table[
s->mb_index2xy[
i + 1]];
1063 for (error_type = 1; error_type <= 3; error_type++) {
1064 for (
i =
s->mb_num - 1;
i >= 0;
i--) {
1065 const int mb_xy =
s->mb_index2xy[
i];
1066 int error =
s->error_status_table[mb_xy];
1068 if (!
s->mbskip_table || !
s->mbskip_table[mb_xy])
1070 if (
error & (1 << error_type))
1073 if (
s->partitioned_frame) {
1074 if (
distance < threshold_part[error_type - 1])
1075 s->error_status_table[mb_xy] |= 1 << error_type;
1078 s->error_status_table[mb_xy] |= 1 << error_type;
1089 for (
i = 0;
i <
s->mb_num;
i++) {
1090 const int mb_xy =
s->mb_index2xy[
i];
1091 int old_error =
s->error_status_table[mb_xy];
1097 s->error_status_table[mb_xy] |=
error;
1102 if (!
s->partitioned_frame) {
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];
1108 s->error_status_table[mb_xy] =
error;
1113 dc_error = ac_error = mv_error = 0;
1114 for (
i = 0;
i <
s->mb_num;
i++) {
1115 const int mb_xy =
s->mb_index2xy[
i];
1116 int error =
s->error_status_table[mb_xy];
1127 if (decode_error_flags)
1137 for (
i = 0;
i <
s->mb_num;
i++) {
1138 const int mb_xy =
s->mb_index2xy[
i];
1139 int error =
s->error_status_table[mb_xy];
1143 s->cur_pic.mb_type[mb_xy] = guessed_mb_type;
1147 if (!(
s->last_pic.f &&
s->last_pic.f->data[0]) &&
1148 !(
s->next_pic.f &&
s->next_pic.f->data[0]))
1149 for (
i = 0;
i <
s->mb_num;
i++) {
1150 const int mb_xy =
s->mb_index2xy[
i];
1151 if (!
IS_INTRA(
s->cur_pic.mb_type[mb_xy]))
1156 for (mb_y = 0; mb_y <
s->mb_height; mb_y++) {
1157 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
1158 const int mb_xy = mb_x + mb_y *
s->mb_stride;
1159 const int mb_type =
s->cur_pic.mb_type[mb_xy];
1160 const int dir = !(
s->last_pic.f &&
s->last_pic.f->data[0]);
1164 int error =
s->error_status_table[mb_xy];
1174 int mb_index = mb_x * 2 + mb_y * 2 *
s->b8_stride;
1177 for (j = 0; j < 4; j++) {
1178 s->mv[0][j][0] =
s->cur_pic.motion_val[dir][mb_index + (j & 1) + (j >> 1) *
s->b8_stride][0];
1179 s->mv[0][j][1] =
s->cur_pic.motion_val[dir][mb_index + (j & 1) + (j >> 1) *
s->b8_stride][1];
1183 s->mv[0][0][0] =
s->cur_pic.motion_val[dir][mb_x * 2 + mb_y * 2 *
s->b8_stride][0];
1184 s->mv[0][0][1] =
s->cur_pic.motion_val[dir][mb_x * 2 + mb_y * 2 *
s->b8_stride][1];
1187 s->decode_mb(
s->opaque, 0 ,
1188 mv_dir, mv_type, &
s->mv, mb_x, mb_y, 0, 0);
1194 for (mb_y = 0; mb_y <
s->mb_height; mb_y++) {
1195 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
1196 int xy = mb_x * 2 + mb_y * 2 *
s->b8_stride;
1197 const int mb_xy = mb_x + mb_y *
s->mb_stride;
1198 const int mb_type =
s->cur_pic.mb_type[mb_xy];
1201 int error =
s->error_status_table[mb_xy];
1210 if (!(
s->last_pic.f &&
s->last_pic.f->data[0]))
1212 if (!(
s->next_pic.f &&
s->next_pic.f->data[0]))
1216 int time_pp =
s->pp_time;
1217 int time_pb =
s->pb_time;
1222 s->mv[0][0][0] =
s->next_pic.motion_val[0][xy][0] * time_pb / time_pp;
1223 s->mv[0][0][1] =
s->next_pic.motion_val[0][xy][1] * time_pb / time_pp;
1224 s->mv[1][0][0] =
s->next_pic.motion_val[0][xy][0] * (time_pb - time_pp) / time_pp;
1225 s->mv[1][0][1] =
s->next_pic.motion_val[0][xy][1] * (time_pb - time_pp) / time_pp;
1241 for (mb_y = 0; mb_y <
s->mb_height; mb_y++) {
1242 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
1243 int dc, dcu, dcv, y, n;
1245 uint8_t *dest_y, *dest_cb, *dest_cr;
1246 const int mb_xy = mb_x + mb_y *
s->mb_stride;
1247 const int mb_type =
s->cur_pic.mb_type[mb_xy];
1251 if (
IS_INTRA(mb_type) &&
s->partitioned_frame)
1256 dest_y =
s->cur_pic.f->data[0] + mb_x * 16 + mb_y * 16 * linesize[0];
1257 dest_cb =
s->cur_pic.f->data[1] + mb_x * 8 + mb_y * 8 * linesize[1];
1258 dest_cr =
s->cur_pic.f->data[2] + mb_x * 8 + mb_y * 8 * linesize[2];
1260 dc_ptr = &
s->dc_val[0][mb_x * 2 + mb_y * 2 *
s->b8_stride];
1261 for (n = 0; n < 4; n++) {
1263 for (y = 0; y < 8; y++) {
1265 for (x = 0; x < 8; x++)
1266 dc += dest_y[x + (n & 1) * 8 +
1267 (y + (n >> 1) * 8) * linesize[0]];
1269 dc_ptr[(n & 1) + (n >> 1) *
s->b8_stride] = (
dc + 4) >> 3;
1272 if (!
s->cur_pic.f->data[2])
1276 for (y = 0; y < 8; y++) {
1278 for (x = 0; x < 8; x++) {
1279 dcu += dest_cb[x + y * linesize[1]];
1280 dcv += dest_cr[x + y * linesize[2]];
1283 s->dc_val[1][mb_x + mb_y *
s->mb_stride] = (dcu + 4) >> 3;
1284 s->dc_val[2][mb_x + mb_y *
s->mb_stride] = (dcv + 4) >> 3;
1289 guess_dc(
s,
s->dc_val[0],
s->mb_width*2,
s->mb_height*2,
s->b8_stride, 1);
1290 guess_dc(
s,
s->dc_val[1],
s->mb_width ,
s->mb_height ,
s->mb_stride, 0);
1291 guess_dc(
s,
s->dc_val[2],
s->mb_width ,
s->mb_height ,
s->mb_stride, 0);
1295 filter181(
s->dc_val[0],
s->mb_width * 2,
s->mb_height * 2,
s->b8_stride);
1299 for (mb_y = 0; mb_y <
s->mb_height; mb_y++) {
1300 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
1301 uint8_t *dest_y, *dest_cb, *dest_cr;
1302 const int mb_xy = mb_x + mb_y *
s->mb_stride;
1303 const int mb_type =
s->cur_pic.mb_type[mb_xy];
1305 int error =
s->error_status_table[mb_xy];
1312 dest_y =
s->cur_pic.f->data[0] + mb_x * 16 + mb_y * 16 * linesize[0];
1313 dest_cb =
s->cur_pic.f->data[1] + mb_x * 8 + mb_y * 8 * linesize[1];
1314 dest_cr =
s->cur_pic.f->data[2] + mb_x * 8 + mb_y * 8 * linesize[2];
1315 if (!
s->cur_pic.f->data[2])
1316 dest_cb = dest_cr =
NULL;
1318 put_dc(
s, dest_y, dest_cb, dest_cr, mb_x, mb_y);
1326 s->mb_height * 2, linesize[0], 1);
1330 s->mb_height * 2, linesize[0], 1);
1332 if (
s->cur_pic.f->data[2]) {
1334 s->mb_height, linesize[1], 0);
1336 s->mb_height, linesize[2], 0);
1338 s->mb_height, linesize[1], 0);
1340 s->mb_height, linesize[2], 0);
1345 for (
i = 0;
i <
s->mb_num;
i++) {
1346 const int mb_xy =
s->mb_index2xy[
i];
1347 int error =
s->error_status_table[mb_xy];
1351 s->mbskip_table[mb_xy] = 0;
1353 if (
s->mbintra_table)
1354 s->mbintra_table[mb_xy] = 1;
1362 for (
i = 0;
i < 2;
i++) {
1365 s->cur_pic.ref_index[
i] =
NULL;
1366 s->cur_pic.motion_val[
i] =
NULL;