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);
425 chroma_height, 5, weight0, weight1, 0);
427 chroma_height, 5, weight0, weight1, 0);
430 luma_weight_avg(dest_y, tmp_y, h->
mb_linesize, height,
437 chroma_weight_avg(dest_cb, tmp_cb, h->
mb_uvlinesize, chroma_height,
443 chroma_weight_avg(dest_cr, tmp_cr, h->
mb_uvlinesize, chroma_height,
452 int list = list1 ? 1 : 0;
455 mc_dir_part(h, ref, n, square, height, delta, list,
456 dest_y, dest_cb, dest_cr, x_offset, y_offset,
457 qpix_put, chroma_put, pixel_shift, chroma_idc);
492 if (chroma_idc == 3 ) {
505 int xchg,
int chroma444,
527 deblock_topleft = (h->
mb_x > 0);
538 #define XCHG(a, b, xchg) \
541 AV_SWAP64(b + 0, a + 0); \
542 AV_SWAP64(b + 8, a + 8); \
552 if (deblock_topleft) {
553 XCHG(top_border_m1 + (8 << pixel_shift),
554 src_y - (7 << pixel_shift), 1);
556 XCHG(top_border + (0 << pixel_shift), src_y + (1 << pixel_shift), xchg);
557 XCHG(top_border + (8 << pixel_shift), src_y + (9 << pixel_shift), 1);
560 src_y + (17 << pixel_shift), 1);
564 if (deblock_topleft) {
565 XCHG(top_border_m1 + (24 << pixel_shift), src_cb - (7 << pixel_shift), 1);
566 XCHG(top_border_m1 + (40 << pixel_shift), src_cr - (7 << pixel_shift), 1);
568 XCHG(top_border + (16 << pixel_shift), src_cb + (1 << pixel_shift), xchg);
569 XCHG(top_border + (24 << pixel_shift), src_cb + (9 << pixel_shift), 1);
570 XCHG(top_border + (32 << pixel_shift), src_cr + (1 << pixel_shift), xchg);
571 XCHG(top_border + (40 << pixel_shift), src_cr + (9 << pixel_shift), 1);
573 XCHG(h->
top_borders[top_idx][h->
mb_x + 1] + (16 << pixel_shift), src_cb + (17 << pixel_shift), 1);
574 XCHG(h->
top_borders[top_idx][h->
mb_x + 1] + (32 << pixel_shift), src_cr + (17 << pixel_shift), 1);
577 if (deblock_topleft) {
578 XCHG(top_border_m1 + (16 << pixel_shift), src_cb - (7 << pixel_shift), 1);
579 XCHG(top_border_m1 + (24 << pixel_shift), src_cr - (7 << pixel_shift), 1);
581 XCHG(top_border + (16 << pixel_shift), src_cb + 1 + pixel_shift, 1);
582 XCHG(top_border + (24 << pixel_shift), src_cr + 1 + pixel_shift, 1);
591 if (high_bit_depth) {
600 if (high_bit_depth) {
607 int mb_type,
int is_h264,
609 int transform_bypass,
619 block_offset += 16 * p;
622 if (transform_bypass) {
629 for (i = 0; i < 16; i += 4) {
630 uint8_t *
const ptr = dest_y + block_offset[i];
644 if (nnz == 1 &&
dctcoef_get(h->
mb, pixel_shift, i * 16 + p * 256))
645 idct_dc_add(ptr, h->
mb + (i * 16 + p * 256 << pixel_shift),
linesize);
647 idct_add(ptr, h->
mb + (i * 16 + p * 256 << pixel_shift), linesize);
652 if (transform_bypass) {
659 for (i = 0; i < 16; i++) {
660 uint8_t *
const ptr = dest_y + block_offset[i];
672 if (!topright_avail) {
674 tr_high = ((uint16_t *)ptr)[3 - linesize / 2] * 0x0001000100010001ULL;
675 topright = (
uint8_t *)&tr_high;
689 if (nnz == 1 &&
dctcoef_get(h->
mb, pixel_shift, i * 16 + p * 256))
690 idct_dc_add(ptr, h->
mb + (i * 16 + p * 256 << pixel_shift),
linesize);
692 idct_add(ptr, h->
mb + (i * 16 + p * 256 << pixel_shift), linesize);
693 }
else if (CONFIG_SVQ3_DECODER)
703 if (!transform_bypass)
708 static const uint8_t dc_mapping[16] = {
709 0 * 16, 1 * 16, 4 * 16, 5 * 16,
710 2 * 16, 3 * 16, 6 * 16, 7 * 16,
711 8 * 16, 9 * 16, 12 * 16, 13 * 16,
712 10 * 16, 11 * 16, 14 * 16, 15 * 16
714 for (i = 0; i < 16; i++)
716 pixel_shift, dc_mapping[i],
721 }
else if (CONFIG_SVQ3_DECODER)
728 int is_h264,
int simple,
729 int transform_bypass,
737 block_offset += 16 * p;
741 if (transform_bypass) {
749 for (i = 0; i < 16; i++)
753 h->
mb + (i * 16 + p * 256 << pixel_shift),
758 h->
mb + (p * 256 << pixel_shift),
762 }
else if (h->
cbp & 15) {
763 if (transform_bypass) {
764 const int di =
IS_8x8DCT(mb_type) ? 4 : 1;
767 for (i = 0; i < 16; i += di)
769 idct_add(dest_y + block_offset[i],
770 h->
mb + (i * 16 + p * 256 << pixel_shift),
775 h->
mb + (p * 256 << pixel_shift),
780 h->
mb + (p * 256 << pixel_shift),
785 }
else if (CONFIG_SVQ3_DECODER) {
786 for (i = 0; i < 16; i++)
789 uint8_t *
const ptr = dest_y + block_offset[i];
818 hl_decode_mb_444_complex(h);
820 hl_decode_mb_444_simple_8(h);
821 }
else if (is_complex) {
822 hl_decode_mb_complex(h);
824 hl_decode_mb_simple_16(h);
826 hl_decode_mb_simple_8(h);