36 for (y = 0; y <
size; y++) {
37 for (x = 0; x <
size; x++)
51 for (y = 0; y <
size; y++) {
52 for (x = 0; x <
size; x++) {
88 int offset = 1 << (shift - 1);
94 for (y = 0; y < 4 * 4; y += 4) {
95 for (x = 0; x < 4; x++)
96 coeffs[y + x] = (coeffs[y + x] + offset) >> shift;
100 #define SET(dst, x) (dst) = (x) 101 #define SCALE(dst, x) (dst) = av_clip_int16(((x) + add) >> shift) 103 #define TR_4x4_LUMA(dst, src, step, assign) \ 105 int c0 = src[0 * step] + src[2 * step]; \ 106 int c1 = src[2 * step] + src[3 * step]; \ 107 int c2 = src[0 * step] - src[3 * step]; \ 108 int c3 = 74 * src[1 * step]; \ 110 assign(dst[2 * step], 74 * (src[0 * step] - \ 113 assign(dst[0 * step], 29 * c0 + 55 * c1 + c3); \ 114 assign(dst[1 * step], 55 * c2 - 29 * c1 + c3); \ 115 assign(dst[3 * step], 55 * c0 + 29 * c2 - c3); \ 122 int add = 1 << (shift - 1);
123 int16_t *
src = coeffs;
125 for (i = 0; i < 4; i++) {
131 add = 1 << (shift - 1);
132 for (i = 0; i < 4; i++) {
140 #define TR_4(dst, src, dstep, sstep, assign, end) \ 142 const int e0 = transform[8 * 0][0] * src[0 * sstep] + \ 143 transform[8 * 2][0] * src[2 * sstep]; \ 144 const int e1 = transform[8 * 0][1] * src[0 * sstep] + \ 145 transform[8 * 2][1] * src[2 * sstep]; \ 146 const int o0 = transform[8 * 1][0] * src[1 * sstep] + \ 147 transform[8 * 3][0] * src[3 * sstep]; \ 148 const int o1 = transform[8 * 1][1] * src[1 * sstep] + \ 149 transform[8 * 3][1] * src[3 * sstep]; \ 151 assign(dst[0 * dstep], e0 + o0); \ 152 assign(dst[1 * dstep], e1 + o1); \ 153 assign(dst[2 * dstep], e1 - o1); \ 154 assign(dst[3 * dstep], e0 - o0); \ 157 #define TR_8(dst, src, dstep, sstep, assign, end) \ 161 int o_8[4] = { 0 }; \ 162 for (i = 0; i < 4; i++) \ 163 for (j = 1; j < end; j += 2) \ 164 o_8[i] += transform[4 * j][i] * src[j * sstep]; \ 165 TR_4(e_8, src, 1, 2 * sstep, SET, 4); \ 167 for (i = 0; i < 4; i++) { \ 168 assign(dst[i * dstep], e_8[i] + o_8[i]); \ 169 assign(dst[(7 - i) * dstep], e_8[i] - o_8[i]); \ 173 #define TR_16(dst, src, dstep, sstep, assign, end) \ 177 int o_16[8] = { 0 }; \ 178 for (i = 0; i < 8; i++) \ 179 for (j = 1; j < end; j += 2) \ 180 o_16[i] += transform[2 * j][i] * src[j * sstep]; \ 181 TR_8(e_16, src, 1, 2 * sstep, SET, 8); \ 183 for (i = 0; i < 8; i++) { \ 184 assign(dst[i * dstep], e_16[i] + o_16[i]); \ 185 assign(dst[(15 - i) * dstep], e_16[i] - o_16[i]); \ 189 #define TR_32(dst, src, dstep, sstep, assign, end) \ 193 int o_32[16] = { 0 }; \ 194 for (i = 0; i < 16; i++) \ 195 for (j = 1; j < end; j += 2) \ 196 o_32[i] += transform[j][i] * src[j * sstep]; \ 197 TR_16(e_32, src, 1, 2 * sstep, SET, end / 2); \ 199 for (i = 0; i < 16; i++) { \ 200 assign(dst[i * dstep], e_32[i] + o_32[i]); \ 201 assign(dst[(31 - i) * dstep], e_32[i] - o_32[i]); \ 205 #define IDCT_VAR4(H) \ 206 int limit2 = FFMIN(col_limit + 4, H) 207 #define IDCT_VAR8(H) \ 208 int limit = FFMIN(col_limit, H); \ 209 int limit2 = FFMIN(col_limit + 4, H) 210 #define IDCT_VAR16(H) IDCT_VAR8(H) 211 #define IDCT_VAR32(H) IDCT_VAR8(H) 214 static void FUNC(idct_ ## H ## x ## H )(int16_t *coeffs, \ 219 int add = 1 << (shift - 1); \ 220 int16_t *src = coeffs; \ 223 for (i = 0; i < H; i++) { \ 224 TR_ ## H(src, src, H, H, SCALE, limit2); \ 225 if (limit2 < H && i%4 == 0 && !!i) \ 230 shift = 20 - BIT_DEPTH; \ 231 add = 1 << (shift - 1); \ 232 for (i = 0; i < H; i++) { \ 233 TR_ ## H(coeffs, coeffs, 1, 1, SCALE, limit); \ 239 static void FUNC(idct_ ## H ## x ## H ## _dc)(int16_t *coeffs) \ 242 int shift = 14 - BIT_DEPTH; \ 243 int add = 1 << (shift - 1); \ 244 int coeff = (((coeffs[0] + 1) >> 1) + add) >> shift; \ 246 for (j = 0; j < H; j++) { \ 247 for (i = 0; i < H; i++) { \ 248 coeffs[i + j * H] = coeff; \ 273 int c_idx,
int class)
279 int chroma = !!c_idx;
281 int *sao_offset_val = sao->offset_val[c_idx];
282 int sao_left_class = sao->band_position[c_idx];
283 int init_y = 0, init_x = 0;
285 stride /=
sizeof(
pixel);
290 width -= (8 >> chroma) + 2;
292 height -= (4 >> chroma) + 2;
295 init_y = -(4 >> chroma) - 2;
297 width -= (8 >> chroma) + 2;
298 height = (4 >> chroma) + 2;
301 init_x = -(8 >> chroma) - 2;
302 width = (8 >> chroma) + 2;
304 height -= (4 >> chroma) + 2;
307 init_y = -(4 >> chroma) - 2;
308 init_x = -(8 >> chroma) - 2;
309 width = (8 >> chroma) + 2;
310 height = (4 >> chroma) + 2;
314 dst = dst + (init_y * stride + init_x);
315 src = src + (init_y * stride + init_x);
316 for (k = 0; k < 4; k++)
317 offset_table[(k + sao_left_class) & 31] = sao_offset_val[k + 1];
318 for (y = 0; y <
height; y++) {
319 for (x = 0; x <
width; x++)
320 dst[x] =
av_clip_pixel(src[x] + offset_table[src[x] >> shift]);
364 int *borders,
int _width,
int _height,
371 int chroma = !!c_idx;
372 int *sao_offset_val = sao->offset_val[c_idx];
373 int sao_eo_class = sao->eo_class[c_idx];
374 int init_x = 0, init_y = 0, width = _width, height = _height;
376 static const int8_t pos[4][2][2] = {
377 { { -1, 0 }, { 1, 0 } },
378 { { 0, -1 }, { 0, 1 } },
379 { { -1, -1 }, { 1, 1 } },
380 { { 1, -1 }, { -1, 1 } },
382 static const uint8_t edge_idx[] = { 1, 2, 0, 3, 4 };
384 #define CMP(a, b) ((a) > (b) ? 1 : ((a) == (b) ? 0 : -1)) 386 stride /=
sizeof(
pixel);
389 width -= (8 >> chroma) + 2;
391 height -= (4 >> chroma) + 2;
393 dst = dst + (init_y * stride + init_x);
394 src = src + (init_y * stride + init_x);
400 for (y = 0; y <
height; y++) {
408 int x_stride = width - 1;
409 for (x = 0; x <
height; x++) {
419 for (x = init_x; x <
width; x++)
425 int y_stride = stride * (height - 1);
426 for (x = init_x; x <
width; x++)
427 dst[x + y_stride] =
av_clip_pixel(src[x + y_stride] + offset_val);
432 int y_stride = init_y *
stride;
433 int pos_0_0 = pos[sao_eo_class][0][0];
434 int pos_0_1 = pos[sao_eo_class][0][1];
435 int pos_1_0 = pos[sao_eo_class][1][0];
436 int pos_1_1 = pos[sao_eo_class][1][1];
438 int y_stride_0_1 = (init_y + pos_0_1) * stride;
439 int y_stride_1_1 = (init_y + pos_1_1) * stride;
440 for (y = init_y; y <
height; y++) {
441 for (x = init_x; x <
width; x++) {
442 int diff0 =
CMP(src[x + y_stride], src[x + pos_0_0 + y_stride_0_1]);
443 int diff1 =
CMP(src[x + y_stride], src[x + pos_1_0 + y_stride_1_1]);
445 dst[x + y_stride] =
av_clip_pixel(src[x + y_stride] + sao_offset_val[offset_val]);
455 int save_upper_left = !diag_edge && sao_eo_class ==
SAO_EO_135D && !borders[0] && !borders[1];
457 for (y = init_y+save_upper_left; y<
height; y++)
458 dst[y*stride] = src[y*stride];
460 for(x = init_x+save_upper_left; x<
width; x++)
471 int *borders,
int _width,
int _height,
478 int chroma = !!c_idx;
479 int *sao_offset_val = sao->offset_val[c_idx];
480 int sao_eo_class = sao->eo_class[c_idx];
481 int init_x = 0, init_y = 0, width = _width, height = _height;
483 static const int8_t pos[4][2][2] = {
484 { { -1, 0 }, { 1, 0 } },
485 { { 0, -1 }, { 0, 1 } },
486 { { -1, -1 }, { 1, 1 } },
487 { { 1, -1 }, { -1, 1 } },
489 static const uint8_t edge_idx[] = { 1, 2, 0, 3, 4 };
491 #define CMP(a, b) ((a) > (b) ? 1 : ((a) == (b) ? 0 : -1)) 493 stride /=
sizeof(
pixel);
495 init_y = -(4 >> chroma) - 2;
497 width -= (8 >> chroma) + 2;
498 height = (4 >> chroma) + 2;
500 dst = dst + (init_y * stride + init_x);
501 src = src + (init_y * stride + init_x);
507 for (y = 0; y <
height; y++) {
515 int x_stride = width - 1;
516 for (x = 0; x <
height; x++) {
524 int y_stride = init_y *
stride;
525 int pos_0_0 = pos[sao_eo_class][0][0];
526 int pos_0_1 = pos[sao_eo_class][0][1];
527 int pos_1_0 = pos[sao_eo_class][1][0];
528 int pos_1_1 = pos[sao_eo_class][1][1];
530 int y_stride_0_1 = (init_y + pos_0_1) * stride;
531 int y_stride_1_1 = (init_y + pos_1_1) * stride;
532 for (y = init_y; y <
height; y++) {
533 for (x = init_x; x <
width; x++) {
534 int diff0 =
CMP(src[x + y_stride], src[x + pos_0_0 + y_stride_0_1]);
535 int diff1 =
CMP(src[x + y_stride], src[x + pos_1_0 + y_stride_1_1]);
537 dst[x + y_stride] =
av_clip_pixel(src[x + y_stride] + sao_offset_val[offset_val]);
547 int save_lower_left = !diag_edge && sao_eo_class ==
SAO_EO_45D && !borders[0];
549 for(y = init_y; y< height-save_lower_left; y++)
550 dst[y*stride] = src[y*stride];
552 for(x = init_x+save_lower_left; x<
width; x++)
553 dst[(height-1)*stride+x] = src[(height-1)*stride+x];
555 dst[stride*(height-1)] = src[stride*(height-1)];
563 int *borders,
int _width,
int _height,
570 int chroma = !!c_idx;
571 int *sao_offset_val = sao->offset_val[c_idx];
572 int sao_eo_class = sao->eo_class[c_idx];
573 int init_x = 0, init_y = 0, width = _width, height = _height;
575 static const int8_t pos[4][2][2] = {
576 { { -1, 0 }, { 1, 0 } },
577 { { 0, -1 }, { 0, 1 } },
578 { { -1, -1 }, { 1, 1 } },
579 { { 1, -1 }, { -1, 1 } },
581 static const uint8_t edge_idx[] = { 1, 2, 0, 3, 4 };
583 #define CMP(a, b) ((a) > (b) ? 1 : ((a) == (b) ? 0 : -1)) 585 stride /=
sizeof(
pixel);
587 init_x = -(8 >> chroma) - 2;
588 width = (8 >> chroma) + 2;
590 height -= (4 >> chroma) + 2;
592 dst = dst + (init_y * stride + init_x);
593 src = src + (init_y * stride + init_x);
598 for (x = init_x; x <
width; x++)
604 int y_stride = stride * (height - 1);
605 for (x = init_x; x <
width; x++)
606 dst[x + y_stride] =
av_clip_pixel(src[x + y_stride] + offset_val);
611 int y_stride = init_y *
stride;
612 int pos_0_0 = pos[sao_eo_class][0][0];
613 int pos_0_1 = pos[sao_eo_class][0][1];
614 int pos_1_0 = pos[sao_eo_class][1][0];
615 int pos_1_1 = pos[sao_eo_class][1][1];
617 int y_stride_0_1 = (init_y + pos_0_1) * stride;
618 int y_stride_1_1 = (init_y + pos_1_1) * stride;
619 for (y = init_y; y <
height; y++) {
620 for (x = init_x; x <
width; x++) {
621 int diff0 =
CMP(src[x + y_stride], src[x + pos_0_0 + y_stride_0_1]);
622 int diff1 =
CMP(src[x + y_stride], src[x + pos_1_0 + y_stride_1_1]);
624 dst[x + y_stride] =
av_clip_pixel(src[x + y_stride] + sao_offset_val[offset_val]);
634 int save_upper_right = !diag_edge && sao_eo_class ==
SAO_EO_45D && !borders[1];
636 for(y = init_y+save_upper_right; y<
height; y++)
637 dst[y*stride+width-1] = src[y*stride+width-1];
639 for(x = init_x; x<width-save_upper_right; x++)
642 dst[width-1] = src[width-1];
649 int *borders,
int _width,
int _height,
656 int chroma = !!c_idx;
657 int *sao_offset_val = sao->offset_val[c_idx];
658 int sao_eo_class = sao->eo_class[c_idx];
659 int init_x = 0, init_y = 0, width = _width, height = _height;
661 static const int8_t pos[4][2][2] = {
662 { { -1, 0 }, { 1, 0 } },
663 { { 0, -1 }, { 0, 1 } },
664 { { -1, -1 }, { 1, 1 } },
665 { { 1, -1 }, { -1, 1 } },
667 static const uint8_t edge_idx[] = { 1, 2, 0, 3, 4 };
669 #define CMP(a, b) ((a) > (b) ? 1 : ((a) == (b) ? 0 : -1)) 671 stride /=
sizeof(
pixel);
673 init_y = -(4 >> chroma) - 2;
674 init_x = -(8 >> chroma) - 2;
675 width = (8 >> chroma) + 2;
676 height = (4 >> chroma) + 2;
679 dst = dst + (init_y * stride + init_x);
680 src = src + (init_y * stride + init_x);
684 int y_stride = init_y *
stride;
685 int pos_0_0 = pos[sao_eo_class][0][0];
686 int pos_0_1 = pos[sao_eo_class][0][1];
687 int pos_1_0 = pos[sao_eo_class][1][0];
688 int pos_1_1 = pos[sao_eo_class][1][1];
690 int y_stride_0_1 = (init_y + pos_0_1) * stride;
691 int y_stride_1_1 = (init_y + pos_1_1) * stride;
693 for (y = init_y; y <
height; y++) {
694 for (x = init_x; x <
width; x++) {
695 int diff0 =
CMP(src[x + y_stride], src[x + pos_0_0 + y_stride_0_1]);
696 int diff1 =
CMP(src[x + y_stride], src[x + pos_1_0 + y_stride_1_1]);
698 dst[x + y_stride] =
av_clip_pixel(src[x + y_stride] + sao_offset_val[offset_val]);
708 int save_lower_right = !diag_edge && sao_eo_class ==
SAO_EO_135D;
710 for(y = init_y; y< height-save_lower_right; y++)
711 dst[y*stride+width-1] = src[y*stride+width-1];
713 for(x = init_x; x<width-save_lower_right; x++)
714 dst[(height-1)*stride+x] = src[(height-1)*stride+x];
716 dst[stride*(height-1)+width-1] = src[stride*(height-1)+width-1];
730 uint8_t *_src, ptrdiff_t _srcstride,
736 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
738 dststride /=
sizeof(*dst);
739 for (y = 0; y <
height; y++) {
740 for (x = 0; x <
width; x++)
747 #define QPEL_FILTER_1(src, stride) \ 748 (1 * -src[x - 3 * stride] + \ 749 4 * src[x - 2 * stride] - \ 750 10 * src[x - stride] + \ 752 17 * src[x + stride] - \ 753 5 * src[x + 2 * stride] + \ 754 1 * src[x + 3 * stride]) 756 #define QPEL_FILTER_2(src, stride) \ 757 (1 * -src[x - 3 * stride] + \ 758 4 * src[x - 2 * stride] - \ 759 11 * src[x - stride] + \ 761 40 * src[x + stride] - \ 762 11 * src[x + 2 * stride] + \ 763 4 * src[x + 3 * stride] - \ 764 1 * src[x + 4 * stride]) 766 #define QPEL_FILTER_3(src, stride) \ 767 (1 * src[x - 2 * stride] - \ 768 5 * src[x - stride] + \ 770 58 * src[x + stride] - \ 771 10 * src[x + 2 * stride] + \ 772 4 * src[x + 3 * stride] - \ 773 1 * src[x + 4 * stride]) 776 #define PUT_HEVC_QPEL_H(H) \ 777 static void FUNC(put_hevc_qpel_h ## H)(int16_t *dst, ptrdiff_t dststride, \ 778 uint8_t *_src, ptrdiff_t _srcstride, \ 779 int width, int height, \ 783 pixel *src = (pixel*)_src; \ 784 ptrdiff_t srcstride = _srcstride / sizeof(pixel); \ 786 dststride /= sizeof(*dst); \ 787 for (y = 0; y < height; y++) { \ 788 for (x = 0; x < width; x++) \ 789 dst[x] = QPEL_FILTER_ ## H(src, 1) >> (BIT_DEPTH - 8); \ 795 #define PUT_HEVC_QPEL_V(V) \ 796 static void FUNC(put_hevc_qpel_v ## V)(int16_t *dst, ptrdiff_t dststride, \ 797 uint8_t *_src, ptrdiff_t _srcstride, \ 798 int width, int height, \ 802 pixel *src = (pixel*)_src; \ 803 ptrdiff_t srcstride = _srcstride / sizeof(pixel); \ 805 dststride /= sizeof(*dst); \ 806 for (y = 0; y < height; y++) { \ 807 for (x = 0; x < width; x++) \ 808 dst[x] = QPEL_FILTER_ ## V(src, srcstride) >> (BIT_DEPTH - 8); \ 814 #define PUT_HEVC_QPEL_HV(H, V) \ 815 static void FUNC(put_hevc_qpel_h ## H ## v ## V)(int16_t *dst, \ 816 ptrdiff_t dststride, \ 818 ptrdiff_t _srcstride, \ 819 int width, int height, \ 823 pixel *src = (pixel*)_src; \ 824 ptrdiff_t srcstride = _srcstride / sizeof(pixel); \ 826 int16_t tmp_array[(MAX_PB_SIZE + 7) * MAX_PB_SIZE]; \ 827 int16_t *tmp = tmp_array; \ 829 dststride /= sizeof(*dst); \ 830 src -= ff_hevc_qpel_extra_before[V] * srcstride; \ 832 for (y = 0; y < height + ff_hevc_qpel_extra[V]; y++) { \ 833 for (x = 0; x < width; x++) \ 834 tmp[x] = QPEL_FILTER_ ## H(src, 1) >> (BIT_DEPTH - 8); \ 836 tmp += MAX_PB_SIZE; \ 839 tmp = tmp_array + ff_hevc_qpel_extra_before[V] * MAX_PB_SIZE; \ 841 for (y = 0; y < height; y++) { \ 842 for (x = 0; x < width; x++) \ 843 dst[x] = QPEL_FILTER_ ## V(tmp, MAX_PB_SIZE) >> 6; \ 844 tmp += MAX_PB_SIZE; \ 856 PUT_HEVC_QPEL_HV(1, 2)
857 PUT_HEVC_QPEL_HV(1, 3)
858 PUT_HEVC_QPEL_HV(2, 1)
859 PUT_HEVC_QPEL_HV(2, 2)
860 PUT_HEVC_QPEL_HV(2, 3)
861 PUT_HEVC_QPEL_HV(3, 1)
862 PUT_HEVC_QPEL_HV(3, 2)
863 PUT_HEVC_QPEL_HV(3, 3)
866 static void FUNC(put_hevc_qpel_pixels_ ## W)(int16_t *dst, ptrdiff_t dststride, \ 867 uint8_t *src, ptrdiff_t srcstride, \ 868 int height, int mx, int my, \ 871 FUNC(put_hevc_qpel_pixels)(dst, dststride, src, srcstride, W, height, \ 875 static void FUNC(put_hevc_qpel_h_ ## W)(int16_t *dst, ptrdiff_t dststride, \ 876 uint8_t *src, ptrdiff_t srcstride, \ 877 int height, int mx, int my, \ 881 FUNC(put_hevc_qpel_h1)(dst, dststride, src, srcstride, W, height, mcbuffer); \ 883 FUNC(put_hevc_qpel_h2)(dst, dststride, src, srcstride, W, height, mcbuffer); \ 885 FUNC(put_hevc_qpel_h3)(dst, dststride, src, srcstride, W, height, mcbuffer); \ 888 static void FUNC(put_hevc_qpel_v_ ## W)(int16_t *dst, ptrdiff_t dststride, \ 889 uint8_t *src, ptrdiff_t srcstride, \ 890 int height, int mx, int my, \ 894 FUNC(put_hevc_qpel_v1)(dst, dststride, src, srcstride, W, height, mcbuffer); \ 896 FUNC(put_hevc_qpel_v2)(dst, dststride, src, srcstride, W, height, mcbuffer); \ 898 FUNC(put_hevc_qpel_v3)(dst, dststride, src, srcstride, W, height, mcbuffer); \ 901 static void FUNC(put_hevc_qpel_hv_ ## W)(int16_t *dst, ptrdiff_t dststride, \ 902 uint8_t *src, ptrdiff_t srcstride, \ 903 int height, int mx, int my, \ 908 FUNC(put_hevc_qpel_h1v1)(dst, dststride, src, srcstride, W, height, mcbuffer); \ 910 FUNC(put_hevc_qpel_h2v1)(dst, dststride, src, srcstride, W, height, mcbuffer); \ 912 FUNC(put_hevc_qpel_h3v1)(dst, dststride, src, srcstride, W, height, mcbuffer); \ 913 } else if (my == 2) { \ 915 FUNC(put_hevc_qpel_h1v2)(dst, dststride, src, srcstride, W, height, mcbuffer); \ 917 FUNC(put_hevc_qpel_h2v2)(dst, dststride, src, srcstride, W, height, mcbuffer); \ 919 FUNC(put_hevc_qpel_h3v2)(dst, dststride, src, srcstride, W, height, mcbuffer); \ 922 FUNC(put_hevc_qpel_h1v3)(dst, dststride, src, srcstride, W, height, mcbuffer); \ 924 FUNC(put_hevc_qpel_h2v3)(dst, dststride, src, srcstride, W, height, mcbuffer); \ 926 FUNC(put_hevc_qpel_h3v3)(dst, dststride, src, srcstride, W, height, mcbuffer); \ 940 uint8_t *_src, ptrdiff_t _srcstride,
941 int width,
int height,
int mx,
int my,
946 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
948 dststride /=
sizeof(*dst);
949 for (y = 0; y <
height; y++) {
950 for (x = 0; x <
width; x++)
957 #define EPEL_FILTER(src, stride) \ 958 (filter_0 * src[x - stride] + \ 959 filter_1 * src[x] + \ 960 filter_2 * src[x + stride] + \ 961 filter_3 * src[x + 2 * stride]) 964 uint8_t *_src, ptrdiff_t _srcstride,
970 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
972 int8_t filter_0 = filter[0];
973 int8_t filter_1 = filter[1];
974 int8_t filter_2 = filter[2];
975 int8_t filter_3 = filter[3];
976 dststride /=
sizeof(*dst);
977 for (y = 0; y <
height; y++) {
978 for (x = 0; x <
width; x++)
986 uint8_t *_src, ptrdiff_t _srcstride,
992 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
994 int8_t filter_0 = filter[0];
995 int8_t filter_1 = filter[1];
996 int8_t filter_2 = filter[2];
997 int8_t filter_3 = filter[3];
999 dststride /=
sizeof(*dst);
1000 for (y = 0; y <
height; y++) {
1001 for (x = 0; x <
width; x++)
1009 uint8_t *_src, ptrdiff_t _srcstride,
1015 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
1018 int8_t filter_0 = filter_h[0];
1019 int8_t filter_1 = filter_h[1];
1020 int8_t filter_2 = filter_h[2];
1021 int8_t filter_3 = filter_h[3];
1023 int16_t *
tmp = tmp_array;
1025 dststride /=
sizeof(*dst);
1029 for (x = 0; x <
width; x++)
1036 filter_0 = filter_v[0];
1037 filter_1 = filter_v[1];
1038 filter_2 = filter_v[2];
1039 filter_3 = filter_v[3];
1040 for (y = 0; y <
height; y++) {
1041 for (x = 0; x <
width; x++)
1049 static void FUNC(put_hevc_epel_pixels_ ## W)(int16_t *dst, ptrdiff_t dststride, \ 1050 uint8_t *src, ptrdiff_t srcstride, \ 1051 int height, int mx, int my, \ 1052 int16_t *mcbuffer) \ 1054 FUNC(put_hevc_epel_pixels)(dst, dststride, src, srcstride, \ 1055 W, height, mx, my, mcbuffer); \ 1057 static void FUNC(put_hevc_epel_h_ ## W)(int16_t *dst, ptrdiff_t dststride, \ 1058 uint8_t *src, ptrdiff_t srcstride, \ 1059 int height, int mx, int my, \ 1060 int16_t *mcbuffer) \ 1062 FUNC(put_hevc_epel_h)(dst, dststride, src, srcstride, \ 1063 W, height, mx, my, mcbuffer); \ 1065 static void FUNC(put_hevc_epel_v_ ## W)(int16_t *dst, ptrdiff_t dststride, \ 1066 uint8_t *src, ptrdiff_t srcstride, \ 1067 int height, int mx, int my, \ 1068 int16_t *mcbuffer) \ 1070 FUNC(put_hevc_epel_v)(dst, dststride, src, srcstride, \ 1071 W, height, mx, my, mcbuffer); \ 1073 static void FUNC(put_hevc_epel_hv_ ## W)(int16_t *dst, ptrdiff_t dststride, \ 1074 uint8_t *src, ptrdiff_t srcstride, \ 1075 int height, int mx, int my, \ 1076 int16_t *mcbuffer) \ 1078 FUNC(put_hevc_epel_hv)(dst, dststride, src, srcstride, \ 1079 W, height, mx, my, mcbuffer); \ 1093 int16_t *src, ptrdiff_t srcstride,
1094 int width,
int height)
1098 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
1102 int offset = 1 << (shift - 1);
1106 srcstride /=
sizeof(*src);
1107 for (y = 0; y <
height; y++) {
1108 for (x = 0; x <
width; x++)
1117 int16_t *
src1, int16_t *src2,
1118 ptrdiff_t srcstride,
1123 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
1127 int offset = 1 << (shift - 1);
1132 srcstride /=
sizeof(*src1);
1133 for (y = 0; y <
height; y++) {
1134 for (x = 0; x <
width; x++)
1135 dst[x] =
av_clip_pixel((src1[x] + src2[x] + offset) >> shift);
1144 uint8_t *_dst, ptrdiff_t _dststride,
1145 int16_t *
src, ptrdiff_t srcstride,
1148 int shift, log2Wd, wx, ox, x, y, offset;
1150 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
1153 log2Wd = denom + shift;
1154 offset = 1 << (log2Wd - 1);
1158 srcstride /=
sizeof(*src);
1159 for (y = 0; y <
height; y++) {
1160 for (x = 0; x <
width; x++) {
1162 dst[x] =
av_clip_pixel(((src[x] * wx + offset) >> log2Wd) + ox);
1174 int16_t wl0Flag, int16_t wl1Flag,
1175 int16_t ol0Flag, int16_t ol1Flag,
1176 uint8_t *_dst, ptrdiff_t _dststride,
1177 int16_t *
src1, int16_t *src2,
1178 ptrdiff_t srcstride,
1181 int shift, log2Wd, w0, w1, o0, o1, x, y;
1183 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
1186 log2Wd = denom + shift;
1192 srcstride /=
sizeof(*src1);
1193 for (y = 0; y <
height; y++) {
1194 for (x = 0; x <
width; x++)
1196 ((o0 + o1 + 1) << log2Wd)) >> (log2Wd + 1));
1203 #define PUT_PRED(w) \ 1204 static void FUNC(put_unweighted_pred_ ## w)(uint8_t *dst, ptrdiff_t dststride, \ 1205 int16_t *src, ptrdiff_t srcstride, \ 1208 FUNC(put_unweighted_pred)(dst, dststride, src, srcstride, w, height); \ 1210 static void FUNC(put_unweighted_pred_avg_ ## w)(uint8_t *dst, ptrdiff_t dststride, \ 1211 int16_t *src1, int16_t *src2, \ 1212 ptrdiff_t srcstride, int height) \ 1214 FUNC(put_unweighted_pred_avg)(dst, dststride, src1, src2, srcstride, w, height); \ 1216 static void FUNC(put_weighted_pred_ ## w)(uint8_t denom, int16_t weight, int16_t offset, \ 1217 uint8_t *dst, ptrdiff_t dststride, \ 1218 int16_t *src, ptrdiff_t srcstride, int height) \ 1220 FUNC(weighted_pred)(denom, weight, offset, \ 1221 dst, dststride, src, srcstride, w, height); \ 1223 static void FUNC(put_weighted_pred_avg_ ## w)(uint8_t denom, int16_t weight0, int16_t weight1, \ 1224 int16_t offset0, int16_t offset1, \ 1225 uint8_t *dst, ptrdiff_t dststride, \ 1226 int16_t *src1, int16_t *src2, \ 1227 ptrdiff_t srcstride, int height) \ 1229 FUNC(weighted_pred_avg)(denom, weight0, weight1, offset0, offset1, \ 1230 dst, dststride, src1, src2, srcstride, w, height); \ 1245 #define P3 pix[-4 * xstride] 1246 #define P2 pix[-3 * xstride] 1247 #define P1 pix[-2 * xstride] 1248 #define P0 pix[-1 * xstride] 1249 #define Q0 pix[0 * xstride] 1250 #define Q1 pix[1 * xstride] 1251 #define Q2 pix[2 * xstride] 1252 #define Q3 pix[3 * xstride] 1255 #define TP3 pix[-4 * xstride + 3 * ystride] 1256 #define TP2 pix[-3 * xstride + 3 * ystride] 1257 #define TP1 pix[-2 * xstride + 3 * ystride] 1258 #define TP0 pix[-1 * xstride + 3 * ystride] 1259 #define TQ0 pix[0 * xstride + 3 * ystride] 1260 #define TQ1 pix[1 * xstride + 3 * ystride] 1261 #define TQ2 pix[2 * xstride + 3 * ystride] 1262 #define TQ3 pix[3 * xstride + 3 * ystride] 1265 ptrdiff_t _xstride, ptrdiff_t _ystride,
1271 ptrdiff_t xstride = _xstride /
sizeof(
pixel);
1272 ptrdiff_t ystride = _ystride /
sizeof(
pixel);
1276 for (j = 0; j < 2; j++) {
1277 const int dp0 = abs(
P2 - 2 *
P1 +
P0);
1278 const int dq0 = abs(
Q2 - 2 *
Q1 +
Q0);
1279 const int dp3 = abs(
TP2 - 2 *
TP1 +
TP0);
1280 const int dq3 = abs(
TQ2 - 2 *
TQ1 +
TQ0);
1281 const int d0 = dp0 + dq0;
1282 const int d3 = dp3 + dq3;
1283 const int tc = _tc[j] << (
BIT_DEPTH - 8);
1284 const int no_p = _no_p[j];
1285 const int no_q = _no_q[j];
1287 if (d0 + d3 >= beta) {
1291 const int beta_3 = beta >> 3;
1292 const int beta_2 = beta >> 2;
1293 const int tc25 = ((tc * 5 + 1) >> 1);
1295 if (abs(
P3 -
P0) + abs(
Q3 -
Q0) < beta_3 && abs(
P0 -
Q0) < tc25 &&
1297 (d0 << 1) < beta_2 && (d3 << 1) < beta_2) {
1299 const int tc2 = tc << 1;
1300 for (d = 0; d < 4; d++) {
1310 P0 = p0 + av_clip(((p2 + 2 * p1 + 2 * p0 + 2 * q0 + q1 + 4) >> 3) - p0, -tc2, tc2);
1311 P1 = p1 + av_clip(((p2 + p1 + p0 + q0 + 2) >> 2) - p1, -tc2, tc2);
1312 P2 = p2 + av_clip(((2 * p3 + 3 * p2 + p1 + p0 + q0 + 4) >> 3) - p2, -tc2, tc2);
1315 Q0 = q0 + av_clip(((p1 + 2 * p0 + 2 * q0 + 2 * q1 + q2 + 4) >> 3) - q0, -tc2, tc2);
1316 Q1 = q1 + av_clip(((p0 + q0 + q1 + q2 + 2) >> 2) - q1, -tc2, tc2);
1317 Q2 = q2 + av_clip(((2 * q3 + 3 * q2 + q1 + q0 + p0 + 4) >> 3) - q2, -tc2, tc2);
1324 const int tc_2 = tc >> 1;
1325 if (dp0 + dp3 < ((beta + (beta >> 1)) >> 3))
1327 if (dq0 + dq3 < ((beta + (beta >> 1)) >> 3))
1330 for (d = 0; d < 4; d++) {
1337 int delta0 = (9 * (q0 - p0) - 3 * (q1 - p1) + 8) >> 4;
1338 if (abs(delta0) < 10 * tc) {
1339 delta0 = av_clip(delta0, -tc, tc);
1344 if (!no_p && nd_p > 1) {
1345 const int deltap1 = av_clip((((p2 + p0 + 1) >> 1) - p1 + delta0) >> 1, -tc_2, tc_2);
1348 if (!no_q && nd_q > 1) {
1349 const int deltaq1 = av_clip((((q2 + q0 + 1) >> 1) - q1 - delta0) >> 1, -tc_2, tc_2);
1361 ptrdiff_t _ystride,
int *_tc,
1364 int d, j, no_p, no_q;
1366 ptrdiff_t xstride = _xstride /
sizeof(
pixel);
1367 ptrdiff_t ystride = _ystride /
sizeof(
pixel);
1369 for (j = 0; j < 2; j++) {
1370 const int tc = _tc[j] << (
BIT_DEPTH - 8);
1378 for (d = 0; d < 4; d++) {
1384 delta0 = av_clip((((q0 - p0) * 4) + p1 - q1 + 4) >> 3, -tc, tc);
1409 int beta,
int *tc,
uint8_t *no_p,
1413 beta, tc, no_p, no_q);
1417 int beta,
int *tc,
uint8_t *no_p,
1421 beta, tc, no_p, no_q);
static void FUNC() add_residual16x16(uint8_t *_dst, int16_t *res, ptrdiff_t stride)
static void FUNC() hevc_h_loop_filter_luma(uint8_t *pix, ptrdiff_t stride, int beta, int *tc, uint8_t *no_p, uint8_t *no_q)
static void FUNC() sao_edge_filter_3(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride, SAOParams *sao, int *borders, int _width, int _height, int c_idx, uint8_t vert_edge, uint8_t horiz_edge, uint8_t diag_edge)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static void FUNC() put_hevc_epel_h(int16_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride, int width, int height, int mx, int my, int16_t *mcbuffer)
#define PUT_HEVC_QPEL_HV(H, V)
static av_always_inline void FUNC() add_residual(uint8_t *_dst, int16_t *res, ptrdiff_t stride, int size)
static void FUNC() sao_edge_filter_1(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride, SAOParams *sao, int *borders, int _width, int _height, int c_idx, uint8_t vert_edge, uint8_t horiz_edge, uint8_t diag_edge)
static void FUNC() sao_band_filter_1(uint8_t *dst, uint8_t *src, ptrdiff_t stride, SAOParams *sao, int *borders, int width, int height, int c_idx)
static void FUNC() add_residual4x4(uint8_t *_dst, int16_t *res, ptrdiff_t stride)
static void FUNC() add_residual32x32(uint8_t *_dst, int16_t *res, ptrdiff_t stride)
const int16_t ff_hevc_epel_coeffs[7][16]
static av_always_inline void FUNC() weighted_pred(uint8_t denom, int16_t wlxFlag, int16_t olxFlag, uint8_t *_dst, ptrdiff_t _dststride, int16_t *src, ptrdiff_t srcstride, int width, int height)
bitstream reader API header.
#define EPEL_EXTRA_BEFORE
static void FUNC() hevc_v_loop_filter_chroma(uint8_t *pix, ptrdiff_t stride, int *tc, uint8_t *no_p, uint8_t *no_q)
static av_always_inline void FUNC() put_unweighted_pred(uint8_t *_dst, ptrdiff_t _dststride, int16_t *src, ptrdiff_t srcstride, int width, int height)
static void FUNC() put_pcm(uint8_t *_dst, ptrdiff_t stride, int size, GetBitContext *gb, int pcm_bit_depth)
static void FUNC() hevc_v_loop_filter_luma(uint8_t *pix, ptrdiff_t stride, int beta, int *tc, uint8_t *no_p, uint8_t *no_q)
static av_always_inline void FUNC() weighted_pred_avg(uint8_t denom, int16_t wl0Flag, int16_t wl1Flag, int16_t ol0Flag, int16_t ol1Flag, uint8_t *_dst, ptrdiff_t _dststride, int16_t *src1, int16_t *src2, ptrdiff_t srcstride, int width, int height)
static void FUNC() sao_band_filter(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride, SAOParams *sao, int *borders, int width, int height, int c_idx, int class)
static void FUNC() add_residual8x8(uint8_t *_dst, int16_t *res, ptrdiff_t stride)
#define EPEL_FILTER(src, stride)
static void filter(MpegAudioContext *s, int ch, const short *samples, int incr)
static av_always_inline void FUNC() put_hevc_qpel_pixels(int16_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride, int width, int height, int mx, int my, int16_t *mcbuffer)
int offset_val[3][5]
SaoOffsetVal.
static void FUNC() put_hevc_epel_v(int16_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride, int width, int height, int mx, int my, int16_t *mcbuffer)
#define PUT_HEVC_QPEL_H(H)
static void FUNC() hevc_loop_filter_chroma(uint8_t *_pix, ptrdiff_t _xstride, ptrdiff_t _ystride, int *_tc, uint8_t *_no_p, uint8_t *_no_q)
static void FUNC() sao_edge_filter_2(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride, SAOParams *sao, int *borders, int _width, int _height, int c_idx, uint8_t vert_edge, uint8_t horiz_edge, uint8_t diag_edge)
static void FUNC() put_hevc_epel_hv(int16_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride, int width, int height, int mx, int my, int16_t *mcbuffer)
static void FUNC() sao_band_filter_3(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride, SAOParams *sao, int *borders, int width, int height, int c_idx)
static void FUNC() sao_band_filter_0(uint8_t *dst, uint8_t *src, ptrdiff_t stride, SAOParams *sao, int *borders, int width, int height, int c_idx)
static av_always_inline void FUNC() put_unweighted_pred_avg(uint8_t *_dst, ptrdiff_t _dststride, int16_t *src1, int16_t *src2, ptrdiff_t srcstride, int width, int height)
#define PUT_HEVC_QPEL_V(V)
static void FUNC() sao_band_filter_2(uint8_t *dst, uint8_t *src, ptrdiff_t stride, SAOParams *sao, int *borders, int width, int height, int c_idx)
#define TR_4x4_LUMA(dst, src, step, assign)
static void FUNC() put_hevc_epel_pixels(int16_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride, int width, int height, int mx, int my, int16_t *mcbuffer)
static const uint8_t offset_table[]
static void FUNC() transform_4x4_luma(int16_t *coeffs)
static void FUNC() hevc_h_loop_filter_chroma(uint8_t *pix, ptrdiff_t stride, int *tc, uint8_t *no_p, uint8_t *no_q)
static void FUNC() hevc_loop_filter_luma(uint8_t *_pix, ptrdiff_t _xstride, ptrdiff_t _ystride, int beta, int *_tc, uint8_t *_no_p, uint8_t *_no_q)
static void FUNC() dequant(int16_t *coeffs)
static void FUNC() sao_edge_filter_0(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride, SAOParams *sao, int *borders, int _width, int _height, int c_idx, uint8_t vert_edge, uint8_t horiz_edge, uint8_t diag_edge)