40 int height,
int y_offset,
int list)
43 int filter_height_down = (raw_my & 3) ? 3 : 0;
44 int full_my = (raw_my >> 2) + y_offset;
45 int bottom = full_my + filter_height_down +
height;
49 return FFMAX(0, bottom);
53 int height,
int y_offset,
int list0,
54 int list1,
int *nrefs)
70 if (refs[0][ref_n] < 0)
72 refs[0][ref_n] =
FFMAX(refs[0][ref_n], my);
83 if (refs[1][ref_n] < 0)
85 refs[1][ref_n] =
FFMAX(refs[1][ref_n], my);
100 int nrefs[2] = { 0 };
103 memset(refs, -1,
sizeof(refs));
123 for (i = 0; i < 4; i++) {
126 int y_offset = (i & 2) << 2;
130 IS_DIR(sub_mb_type, 0, 0),
131 IS_DIR(sub_mb_type, 0, 1),
135 IS_DIR(sub_mb_type, 0, 0),
136 IS_DIR(sub_mb_type, 0, 1),
139 IS_DIR(sub_mb_type, 0, 0),
140 IS_DIR(sub_mb_type, 0, 1),
144 IS_DIR(sub_mb_type, 0, 0),
145 IS_DIR(sub_mb_type, 0, 1),
148 IS_DIR(sub_mb_type, 0, 0),
149 IS_DIR(sub_mb_type, 0, 1),
154 for (j = 0; j < 4; j++) {
155 int sub_y_offset = y_offset + 2 * (j & 2);
157 IS_DIR(sub_mb_type, 0, 0),
158 IS_DIR(sub_mb_type, 0, 1),
165 for (list = h->
list_count - 1; list >= 0; list--)
166 for (ref = 0; ref < 48 && nrefs[list]; ref++) {
167 int row = refs[list][ref];
172 int pic_height = 16 * h->
mb_height >> ref_field_picture;
179 FFMIN((row >> 1) - !(row & 1),
183 FFMIN((row >> 1), pic_height - 1),
187 FFMIN(row * 2 + ref_field,
192 FFMIN(row, pic_height - 1),
196 FFMIN(row, pic_height - 1),
208 int src_x_offset,
int src_y_offset,
215 const int luma_xy = (mx & 3) + ((my & 3) << 2);
220 int extra_height = 0;
222 const int full_mx = mx >> 2;
223 const int full_my = my >> 2;
224 const int pic_width = 16 * h->
mb_width;
233 if (full_mx < 0 - extra_width ||
234 full_my < 0 - extra_height ||
235 full_mx + 16 > pic_width + extra_width ||
236 full_my + 16 > pic_height + extra_height) {
240 16 + 5, 16 + 5 , full_mx - 2,
241 full_my - 2, pic_width, pic_height);
253 if (chroma_idc == 3 ) {
260 full_mx - 2, full_my - 2,
261 pic_width, pic_height);
274 full_mx - 2, full_my - 2,
275 pic_width, pic_height);
284 ysh = 3 - (chroma_idc == 2 );
285 if (chroma_idc == 1 &&
MB_FIELD(h)) {
288 emu |= (my >> 3) < 0 || (my >> 3) + 8 >= (pic_height >> 1);
291 src_cb = pic->
f.
data[1] + ((mx >> 3) << pixel_shift) +
299 9, 8 * chroma_idc + 1, (mx >> 3), (my >> ysh),
300 pic_width >> 1, pic_height >> (chroma_idc == 1 ));
304 height >> (chroma_idc == 1 ),
305 mx & 7, (my << (chroma_idc == 2 )) & 7);
310 9, 8 * chroma_idc + 1, (mx >> 3), (my >> ysh),
311 pic_width >> 1, pic_height >> (chroma_idc == 1 ));
314 chroma_op(dest_cr, src_cr, h->
mb_uvlinesize, height >> (chroma_idc == 1 ),
315 mx & 7, (my << (chroma_idc == 2 )) & 7);
322 int x_offset,
int y_offset,
327 int list0,
int list1,
334 if (chroma_idc == 3 ) {
336 dest_cr += (2 * x_offset << pixel_shift) + 2 * y_offset * h->
mb_linesize;
337 }
else if (chroma_idc == 2 ) {
339 dest_cr += (x_offset << pixel_shift) + 2 * y_offset * h->
mb_uvlinesize;
342 dest_cr += (x_offset << pixel_shift) + y_offset * h->
mb_uvlinesize;
344 x_offset += 8 * h->
mb_x;
350 dest_y, dest_cb, dest_cr, x_offset, y_offset,
351 qpix_op, chroma_op, pixel_shift, chroma_idc);
354 chroma_op = chroma_avg;
360 dest_y, dest_cb, dest_cr, x_offset, y_offset,
361 qpix_op, chroma_op, pixel_shift, chroma_idc);
369 int x_offset,
int y_offset,
376 int list0,
int list1,
382 if (chroma_idc == 3 ) {
384 chroma_weight_avg = luma_weight_avg;
385 chroma_weight_op = luma_weight_op;
387 dest_cr += (2 * x_offset << pixel_shift) + 2 * y_offset * h->
mb_linesize;
388 }
else if (chroma_idc == 2 ) {
391 dest_cr += (x_offset << pixel_shift) + 2 * y_offset * h->
mb_uvlinesize;
393 chroma_height = height >> 1;
395 dest_cr += (x_offset << pixel_shift) + y_offset * h->
mb_uvlinesize;
397 x_offset += 8 * h->
mb_x;
400 if (list0 && list1) {
410 dest_y, dest_cb, dest_cr,
411 x_offset, y_offset, qpix_put, chroma_put,
412 pixel_shift, chroma_idc);
414 tmp_y, tmp_cb, tmp_cr,
415 x_offset, y_offset, qpix_put, chroma_put,
416 pixel_shift, chroma_idc);
420 int weight1 = 64 - weight0;
422 height, 5, weight0, weight1, 0);
424 chroma_height, 5, weight0, weight1, 0);
426 chroma_height, 5, weight0, weight1, 0);
428 luma_weight_avg(dest_y, tmp_y, h->
mb_linesize, height,
434 chroma_weight_avg(dest_cb, tmp_cb, h->
mb_uvlinesize, chroma_height,
440 chroma_weight_avg(dest_cr, tmp_cr, h->
mb_uvlinesize, chroma_height,
448 int list = list1 ? 1 : 0;
451 mc_dir_part(h, ref, n, square, height, delta, list,
452 dest_y, dest_cb, dest_cr, x_offset, y_offset,
453 qpix_put, chroma_put, pixel_shift, chroma_idc);
486 if (chroma_idc == 3 ) {
499 int xchg,
int chroma444,
521 deblock_topleft = (h->
mb_x > 0);
532 #define XCHG(a, b, xchg) \
535 AV_SWAP64(b + 0, a + 0); \
536 AV_SWAP64(b + 8, a + 8); \
546 if (deblock_topleft) {
547 XCHG(top_border_m1 + (8 << pixel_shift),
548 src_y - (7 << pixel_shift), 1);
550 XCHG(top_border + (0 << pixel_shift), src_y + (1 << pixel_shift), xchg);
551 XCHG(top_border + (8 << pixel_shift), src_y + (9 << pixel_shift), 1);
554 src_y + (17 << pixel_shift), 1);
558 if (deblock_topleft) {
559 XCHG(top_border_m1 + (24 << pixel_shift), src_cb - (7 << pixel_shift), 1);
560 XCHG(top_border_m1 + (40 << pixel_shift), src_cr - (7 << pixel_shift), 1);
562 XCHG(top_border + (16 << pixel_shift), src_cb + (1 << pixel_shift), xchg);
563 XCHG(top_border + (24 << pixel_shift), src_cb + (9 << pixel_shift), 1);
564 XCHG(top_border + (32 << pixel_shift), src_cr + (1 << pixel_shift), xchg);
565 XCHG(top_border + (40 << pixel_shift), src_cr + (9 << pixel_shift), 1);
567 XCHG(h->
top_borders[top_idx][h->
mb_x + 1] + (16 << pixel_shift), src_cb + (17 << pixel_shift), 1);
568 XCHG(h->
top_borders[top_idx][h->
mb_x + 1] + (32 << pixel_shift), src_cr + (17 << pixel_shift), 1);
571 if (deblock_topleft) {
572 XCHG(top_border_m1 + (16 << pixel_shift), src_cb - (7 << pixel_shift), 1);
573 XCHG(top_border_m1 + (24 << pixel_shift), src_cr - (7 << pixel_shift), 1);
575 XCHG(top_border + (16 << pixel_shift), src_cb + 1 + pixel_shift, 1);
576 XCHG(top_border + (24 << pixel_shift), src_cr + 1 + pixel_shift, 1);
585 if (high_bit_depth) {
594 if (high_bit_depth) {
601 int mb_type,
int is_h264,
603 int transform_bypass,
613 block_offset += 16 * p;
616 if (transform_bypass) {
623 for (i = 0; i < 16; i += 4) {
624 uint8_t *
const ptr = dest_y + block_offset[i];
638 if (nnz == 1 &&
dctcoef_get(h->
mb, pixel_shift, i * 16 + p * 256))
639 idct_dc_add(ptr, h->
mb + (i * 16 + p * 256 << pixel_shift),
linesize);
641 idct_add(ptr, h->
mb + (i * 16 + p * 256 << pixel_shift), linesize);
646 if (transform_bypass) {
653 for (i = 0; i < 16; i++) {
654 uint8_t *
const ptr = dest_y + block_offset[i];
666 if (!topright_avail) {
668 tr_high = ((uint16_t *)ptr)[3 - linesize / 2] * 0x0001000100010001ULL;
669 topright = (
uint8_t *)&tr_high;
683 if (nnz == 1 &&
dctcoef_get(h->
mb, pixel_shift, i * 16 + p * 256))
684 idct_dc_add(ptr, h->
mb + (i * 16 + p * 256 << pixel_shift),
linesize);
686 idct_add(ptr, h->
mb + (i * 16 + p * 256 << pixel_shift), linesize);
687 }
else if (CONFIG_SVQ3_DECODER)
697 if (!transform_bypass)
702 static const uint8_t dc_mapping[16] = {
703 0 * 16, 1 * 16, 4 * 16, 5 * 16,
704 2 * 16, 3 * 16, 6 * 16, 7 * 16,
705 8 * 16, 9 * 16, 12 * 16, 13 * 16,
706 10 * 16, 11 * 16, 14 * 16, 15 * 16
708 for (i = 0; i < 16; i++)
710 pixel_shift, dc_mapping[i],
715 }
else if (CONFIG_SVQ3_DECODER)
722 int is_h264,
int simple,
723 int transform_bypass,
731 block_offset += 16 * p;
735 if (transform_bypass) {
743 for (i = 0; i < 16; i++)
747 h->
mb + (i * 16 + p * 256 << pixel_shift),
752 h->
mb + (p * 256 << pixel_shift),
756 }
else if (h->
cbp & 15) {
757 if (transform_bypass) {
758 const int di =
IS_8x8DCT(mb_type) ? 4 : 1;
761 for (i = 0; i < 16; i += di)
763 idct_add(dest_y + block_offset[i],
764 h->
mb + (i * 16 + p * 256 << pixel_shift),
769 h->
mb + (p * 256 << pixel_shift),
774 h->
mb + (p * 256 << pixel_shift),
779 }
else if (CONFIG_SVQ3_DECODER) {
780 for (i = 0; i < 16; i++)
783 uint8_t *
const ptr = dest_y + block_offset[i];
812 hl_decode_mb_444_complex(h);
814 hl_decode_mb_444_simple_8(h);
815 }
else if (is_complex) {
816 hl_decode_mb_complex(h);
818 hl_decode_mb_simple_16(h);
820 hl_decode_mb_simple_8(h);