Go to the documentation of this file.
39 for (y = 0; y <
height; y++) {
40 for (x = 0; x <
width; x++)
51 for (y = 0; y <
size; y++) {
53 for (x = 0; x <
size; x++) {
87 int16_t *coeffs = (int16_t *) _coeffs;
89 int size = 1 << log2_size;
93 for (y = 0; y <
size - 1; y++) {
94 for (x = 0; x <
size; x++)
95 coeffs[x] += coeffs[x -
size];
99 for (y = 0; y <
size; y++) {
100 for (x = 1; x <
size; x++)
101 coeffs[x] += coeffs[x - 1];
131 int size = 1 << log2_size;
133 if (BIT_DEPTH <= 9 || shift > 0) {
135 for (y = 0; y <
size; y++) {
136 for (x = 0; x <
size; x++) {
142 for (y = 0; y <
size; y++) {
143 for (x = 0; x <
size; x++) {
144 *coeffs = *(uint16_t*)coeffs << -
shift;
152 #define SET(dst, x) (dst) = (x)
153 #define SCALE(dst, x) (dst) = av_clip_int16(((x) + add) >> shift)
155 #define TR_4x4_LUMA(dst, src, step, assign) \
157 int c0 = src[0 * step] + src[2 * step]; \
158 int c1 = src[2 * step] + src[3 * step]; \
159 int c2 = src[0 * step] - src[3 * step]; \
160 int c3 = 74 * src[1 * step]; \
162 assign(dst[2 * step], 74 * (src[0 * step] - \
165 assign(dst[0 * step], 29 * c0 + 55 * c1 + c3); \
166 assign(dst[1 * step], 55 * c2 - 29 * c1 + c3); \
167 assign(dst[3 * step], 55 * c0 + 29 * c2 - c3); \
174 int add = 1 << (
shift - 1);
175 int16_t *
src = coeffs;
177 for (
i = 0;
i < 4;
i++) {
183 add = 1 << (
shift - 1);
184 for (
i = 0;
i < 4;
i++) {
192 #define TR_4(dst, src, dstep, sstep, assign, end) \
194 const int e0 = 64 * src[0 * sstep] + 64 * src[2 * sstep]; \
195 const int e1 = 64 * src[0 * sstep] - 64 * src[2 * sstep]; \
196 const int o0 = 83 * src[1 * sstep] + 36 * src[3 * sstep]; \
197 const int o1 = 36 * src[1 * sstep] - 83 * src[3 * sstep]; \
199 assign(dst[0 * dstep], e0 + o0); \
200 assign(dst[1 * dstep], e1 + o1); \
201 assign(dst[2 * dstep], e1 - o1); \
202 assign(dst[3 * dstep], e0 - o0); \
205 #define TR_8(dst, src, dstep, sstep, assign, end) \
209 int o_8[4] = { 0 }; \
210 for (i = 0; i < 4; i++) \
211 for (j = 1; j < end; j += 2) \
212 o_8[i] += transform[4 * j][i] * src[j * sstep]; \
213 TR_4(e_8, src, 1, 2 * sstep, SET, 4); \
215 for (i = 0; i < 4; i++) { \
216 assign(dst[i * dstep], e_8[i] + o_8[i]); \
217 assign(dst[(7 - i) * dstep], e_8[i] - o_8[i]); \
221 #define TR_16(dst, src, dstep, sstep, assign, end) \
225 int o_16[8] = { 0 }; \
226 for (i = 0; i < 8; i++) \
227 for (j = 1; j < end; j += 2) \
228 o_16[i] += transform[2 * j][i] * src[j * sstep]; \
229 TR_8(e_16, src, 1, 2 * sstep, SET, 8); \
231 for (i = 0; i < 8; i++) { \
232 assign(dst[i * dstep], e_16[i] + o_16[i]); \
233 assign(dst[(15 - i) * dstep], e_16[i] - o_16[i]); \
237 #define TR_32(dst, src, dstep, sstep, assign, end) \
241 int o_32[16] = { 0 }; \
242 for (i = 0; i < 16; i++) \
243 for (j = 1; j < end; j += 2) \
244 o_32[i] += transform[j][i] * src[j * sstep]; \
245 TR_16(e_32, src, 1, 2 * sstep, SET, end / 2); \
247 for (i = 0; i < 16; i++) { \
248 assign(dst[i * dstep], e_32[i] + o_32[i]); \
249 assign(dst[(31 - i) * dstep], e_32[i] - o_32[i]); \
253 #define IDCT_VAR4(H) \
254 int limit2 = FFMIN(col_limit + 4, H)
255 #define IDCT_VAR8(H) \
256 int limit = FFMIN(col_limit, H); \
257 int limit2 = FFMIN(col_limit + 4, H)
258 #define IDCT_VAR16(H) IDCT_VAR8(H)
259 #define IDCT_VAR32(H) IDCT_VAR8(H)
262 static void FUNC(idct_ ## H ## x ## H )(int16_t *coeffs, \
267 int add = 1 << (shift - 1); \
268 int16_t *src = coeffs; \
271 for (i = 0; i < H; i++) { \
272 TR_ ## H(src, src, H, H, SCALE, limit2); \
273 if (limit2 < H && i%4 == 0 && !!i) \
278 shift = 20 - BIT_DEPTH; \
279 add = 1 << (shift - 1); \
280 for (i = 0; i < H; i++) { \
281 TR_ ## H(coeffs, coeffs, 1, 1, SCALE, limit); \
287 static void FUNC(idct_ ## H ## x ## H ## _dc)(int16_t *coeffs) \
290 int shift = 14 - BIT_DEPTH; \
291 int add = 1 << (shift - 1); \
292 int coeff = (((coeffs[0] + 1) >> 1) + add) >> shift; \
294 for (j = 0; j < H; j++) { \
295 for (i = 0; i < H; i++) { \
296 coeffs[i + j * H] = coeff; \
322 #define ff_hevc_pel_filters ff_hevc_qpel_filters
323 #define DECL_HV_FILTER(f) \
324 const int8_t *hf = ff_hevc_ ## f ## _filters[mx]; \
325 const int8_t *vf = ff_hevc_ ## f ## _filters[my];
327 #define FW_PUT(p, f, t) \
328 static void FUNC(put_hevc_## f)(int16_t *dst, const uint8_t *src, ptrdiff_t srcstride, int height, \
329 intptr_t mx, intptr_t my, int width) \
332 FUNC(put_ ## t)(dst, src, srcstride, height, hf, vf, width); \
335 #define FW_PUT_UNI(p, f, t) \
336 static void FUNC(put_hevc_ ## f)(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, \
337 ptrdiff_t srcstride, int height, intptr_t mx, intptr_t my, int width) \
340 FUNC(put_ ## t)(dst, dststride, src, srcstride, height, hf, vf, width); \
343 #define FW_PUT_UNI_W(p, f, t) \
344 static void FUNC(put_hevc_ ## f)(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, \
345 ptrdiff_t srcstride,int height, int denom, int wx, int ox, \
346 intptr_t mx, intptr_t my, int width) \
349 FUNC(put_ ## t)(dst, dststride, src, srcstride, height, denom, wx, ox, hf, vf, width); \
352 #define FW_PUT_FUNCS(f, t, dir) \
353 FW_PUT(f, f ## _ ## dir, t ## _ ## dir) \
354 FW_PUT_UNI(f, f ## _uni_ ## dir, uni_ ## t ## _ ## dir) \
355 FW_PUT_UNI_W(f, f ## _uni_w_ ## dir, uni_## t ## _w_ ## dir)
357 FW_PUT(pel, pel_pixels, pixels)
385 for (y = 0; y <
height; y++) {
386 for (x = 0; x <
width; x++)
396 int height,
int denom,
int wx0,
int wx1,
397 int ox, intptr_t
mx, intptr_t
my,
int width)
406 int log2Wd = denom +
shift - 1;
409 for (y = 0; y <
height; y++) {
410 for (x = 0; x <
width; x++) {
422 #define QPEL_FILTER(src, stride) \
423 (filter[0] * src[x - 3 * stride] + \
424 filter[1] * src[x - 2 * stride] + \
425 filter[2] * src[x - stride] + \
426 filter[3] * src[x ] + \
427 filter[4] * src[x + stride] + \
428 filter[5] * src[x + 2 * stride] + \
429 filter[6] * src[x + 3 * stride] + \
430 filter[7] * src[x + 4 * stride])
451 for (y = 0; y <
height; y++) {
452 for (x = 0; x <
width; x++)
479 for (y = 0; y <
height; y++) {
480 for (x = 0; x <
width; x++)
499 int16_t *
tmp = tmp_array;
510 for (x = 0; x <
width; x++)
519 for (y = 0; y <
height; y++) {
520 for (x = 0; x <
width; x++)
530 int height,
int denom,
int wx0,
int wx1,
531 int ox, intptr_t
mx, intptr_t
my,
int width)
542 int log2Wd = denom +
shift - 1;
545 for (y = 0; y <
height; y++) {
546 for (x = 0; x <
width; x++)
548 ox * (1 << log2Wd)) >> (log2Wd + 1));
557 int height,
int denom,
int wx0,
int wx1,
558 int ox, intptr_t
mx, intptr_t
my,
int width)
569 int log2Wd = denom +
shift - 1;
572 for (y = 0; y <
height; y++) {
573 for (x = 0; x <
width; x++)
575 ox * (1 << log2Wd)) >> (log2Wd + 1));
584 int height,
int denom,
int wx0,
int wx1,
585 int ox, intptr_t
mx, intptr_t
my,
int width)
594 int16_t *
tmp = tmp_array;
596 int log2Wd = denom +
shift - 1;
601 for (x = 0; x <
width; x++)
611 for (y = 0; y <
height; y++) {
612 for (x = 0; x <
width; x++)
614 ox * (1 << log2Wd)) >> (log2Wd + 1));
624 #define EPEL_FILTER(src, stride) \
625 (filter[0] * src[x - stride] + \
626 filter[1] * src[x] + \
627 filter[2] * src[x + stride] + \
628 filter[3] * src[x + 2 * stride])
647 for (y = 0; y <
height; y++) {
648 for (x = 0; x <
width; x++) {
674 for (y = 0; y <
height; y++) {
675 for (x = 0; x <
width; x++)
694 int16_t *
tmp = tmp_array;
705 for (x = 0; x <
width; x++)
714 for (y = 0; y <
height; y++) {
715 for (x = 0; x <
width; x++)
725 int height,
int denom,
int wx0,
int wx1,
726 int ox, intptr_t
mx, intptr_t
my,
int width)
735 int log2Wd = denom +
shift - 1;
738 for (y = 0; y <
height; y++) {
739 for (x = 0; x <
width; x++)
741 ox * (1 << log2Wd)) >> (log2Wd + 1));
750 int height,
int denom,
int wx0,
int wx1,
751 int ox, intptr_t
mx, intptr_t
my,
int width)
760 int log2Wd = denom +
shift - 1;
763 for (y = 0; y <
height; y++) {
764 for (x = 0; x <
width; x++)
766 ox * (1 << log2Wd)) >> (log2Wd + 1));
775 int height,
int denom,
int wx0,
int wx1,
776 int ox, intptr_t
mx, intptr_t
my,
int width)
785 int16_t *
tmp = tmp_array;
787 int log2Wd = denom +
shift - 1;
792 for (x = 0; x <
width; x++)
802 for (y = 0; y <
height; y++) {
803 for (x = 0; x <
width; x++)
805 ox * (1 << log2Wd)) >> (log2Wd + 1));
813 #define P3 pix[-4 * xstride]
814 #define P2 pix[-3 * xstride]
815 #define P1 pix[-2 * xstride]
816 #define P0 pix[-1 * xstride]
817 #define Q0 pix[0 * xstride]
818 #define Q1 pix[1 * xstride]
819 #define Q2 pix[2 * xstride]
820 #define Q3 pix[3 * xstride]
823 #define TP3 pix[-4 * xstride + 3 * ystride]
824 #define TP2 pix[-3 * xstride + 3 * ystride]
825 #define TP1 pix[-2 * xstride + 3 * ystride]
826 #define TP0 pix[-1 * xstride + 3 * ystride]
827 #define TQ0 pix[0 * xstride + 3 * ystride]
828 #define TQ1 pix[1 * xstride + 3 * ystride]
829 #define TQ2 pix[2 * xstride + 3 * ystride]
830 #define TQ3 pix[3 * xstride + 3 * ystride]
835 ptrdiff_t _xstride, ptrdiff_t _ystride,
836 int beta,
const int *_tc,
837 const uint8_t *_no_p,
const uint8_t *_no_q)
839 ptrdiff_t xstride = _xstride /
sizeof(
pixel);
840 ptrdiff_t ystride = _ystride /
sizeof(
pixel);
844 for (
int j = 0; j < 2; j++) {
850 const int d0 = dp0 + dq0;
851 const int d3 = dp3 + dq3;
852 const int tc = _tc[j] << (
BIT_DEPTH - 8);
853 const int no_p = _no_p[j];
854 const int no_q = _no_q[j];
856 if (d0 + d3 < beta) {
857 const int beta_3 = beta >> 3;
858 const int beta_2 = beta >> 2;
859 const int tc25 = ((tc * 5 + 1) >> 1);
863 (d0 << 1) < beta_2 && (d3 << 1) < beta_2) {
864 const int tc2 = tc << 1;
869 if (dp0 + dp3 < ((beta + (beta >> 1)) >> 3))
871 if (dq0 + dq3 < ((beta + (beta >> 1)) >> 3))
880 ptrdiff_t _ystride,
const int *_tc,
881 const uint8_t *_no_p,
const uint8_t *_no_q)
884 ptrdiff_t xstride = _xstride /
sizeof(
pixel);
885 ptrdiff_t ystride = _ystride /
sizeof(
pixel);
888 for (
int j = 0; j < 2; j++) {
890 const int tc = _tc[j] << (
BIT_DEPTH - 8);
901 const int32_t *tc,
const uint8_t *no_p,
908 const int32_t *tc,
const uint8_t *no_p,
915 int beta,
const int32_t *tc,
const uint8_t *no_p,
919 beta, tc, no_p, no_q);
923 int beta,
const int32_t *tc,
const uint8_t *no_p,
927 beta, tc, no_p, no_q);
static void FUNC() put_hevc_qpel_bi_h(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, intptr_t mx, intptr_t my, int width)
#define QPEL_FILTER(src, stride)
const int8_t ff_hevc_epel_filters[8][4]
ff_hevc_.pel_filters[0] are dummies to simplify array addressing
static void FUNC() hevc_loop_filter_luma(uint8_t *_pix, ptrdiff_t _xstride, ptrdiff_t _ystride, int beta, const int *_tc, const uint8_t *_no_p, const uint8_t *_no_q)
static void FUNC() put_pcm(uint8_t *_dst, ptrdiff_t stride, int width, int height, GetBitContext *gb, int pcm_bit_depth)
static av_always_inline void FUNC() add_residual(uint8_t *restrict dst8, const int16_t *restrict res, ptrdiff_t stride, int size)
static void FUNC() put_hevc_qpel_bi_hv(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, intptr_t mx, intptr_t my, int width)
static void FUNC() put_hevc_epel_bi_w_v(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, int denom, int wx0, int wx1, int ox, intptr_t mx, intptr_t my, int width)
void(* filter)(uint8_t *src, int stride, int qscale)
static void FUNC() loop_filter_luma_strong(pixel *pix, const ptrdiff_t xstride, const ptrdiff_t ystride, const int32_t tc, const int32_t tc2, const int tc3, const uint8_t no_p, const uint8_t no_q)
#define EPEL_FILTER(src, stride)
uint8_t ptrdiff_t const uint8_t * _src
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t mx
static void FUNC() hevc_v_loop_filter_luma(uint8_t *pix, ptrdiff_t stride, int beta, const int32_t *tc, const uint8_t *no_p, const uint8_t *no_q)
static void FUNC() put_hevc_epel_bi_w_hv(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, int denom, int wx0, int wx1, int ox, intptr_t mx, intptr_t my, int width)
static void FUNC() put_hevc_qpel_bi_w_hv(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, int denom, int wx0, int wx1, int ox, intptr_t mx, intptr_t my, int width)
static void FUNC() transform_4x4_luma(int16_t *coeffs)
static void FUNC() hevc_h_loop_filter_luma(uint8_t *pix, ptrdiff_t stride, int beta, const int32_t *tc, const uint8_t *no_p, const uint8_t *no_q)
uint8_t ptrdiff_t const uint8_t ptrdiff_t _srcstride
static void FUNC() add_residual32x32(uint8_t *_dst, const int16_t *res, ptrdiff_t stride)
#define QPEL_EXTRA_BEFORE
const int8_t ff_hevc_qpel_filters[4][16]
static void FUNC() put_hevc_qpel_bi_v(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, intptr_t mx, intptr_t my, int width)
static void FUNC() loop_filter_chroma_weak(pixel *pix, const ptrdiff_t xstride, const ptrdiff_t ystride, const int size, const int32_t tc, const uint8_t no_p, const uint8_t no_q)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t my
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t const uint8_t ptrdiff_t srcstride
#define FW_PUT_FUNCS(f, t, dir)
static void FUNC() add_residual8x8(uint8_t *_dst, const int16_t *res, ptrdiff_t stride)
uint8_t ptrdiff_t _dststride
static int shift(int a, int b)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static void FUNC() put_hevc_qpel_bi_w_h(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, int denom, int wx0, int wx1, int ox, intptr_t mx, intptr_t my, int width)
#define i(width, name, range_min, range_max)
#define FW_PUT_UNI_W(p, f, t)
static void FUNC() hevc_h_loop_filter_chroma(uint8_t *pix, ptrdiff_t stride, const int32_t *tc, const uint8_t *no_p, const uint8_t *no_q)
static void FUNC() put_hevc_epel_bi_hv(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, intptr_t mx, intptr_t my, int width)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
static void FUNC() transform_rdpcm(int16_t *_coeffs, int16_t log2_size, int mode)
static void FUNC() dequant(int16_t *coeffs, int16_t log2_size)
HEVC transform dequantization (ITU-T H.265 8.6.3)
#define EPEL_EXTRA_BEFORE
static void FUNC() hevc_loop_filter_chroma(uint8_t *_pix, ptrdiff_t _xstride, ptrdiff_t _ystride, const int *_tc, const uint8_t *_no_p, const uint8_t *_no_q)
static void FUNC() put_hevc_epel_bi_v(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, intptr_t mx, intptr_t my, int width)
#define TR_4x4_LUMA(dst, src, step, assign)
static void FUNC() put_hevc_pel_bi_pixels(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, intptr_t mx, intptr_t my, int width)
static void FUNC() loop_filter_luma_weak(pixel *pix, const ptrdiff_t xstride, const ptrdiff_t ystride, const int32_t tc, const int32_t beta, const uint8_t no_p, const uint8_t no_q, const int nd_p, const int nd_q)
#define FW_PUT_UNI(p, f, t)
static void FUNC() add_residual4x4(uint8_t *_dst, const int16_t *res, ptrdiff_t stride)
static void FUNC() add_residual16x16(uint8_t *_dst, const int16_t *res, ptrdiff_t stride)
static void FUNC() put_hevc_epel_bi_h(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, intptr_t mx, intptr_t my, int width)
static void FUNC() hevc_v_loop_filter_chroma(uint8_t *pix, ptrdiff_t stride, const int32_t *tc, const uint8_t *no_p, const uint8_t *no_q)
static void FUNC() put_hevc_pel_bi_w_pixels(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, int denom, int wx0, int wx1, int ox, intptr_t mx, intptr_t my, int width)
static void FUNC() put_hevc_epel_bi_w_h(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, int denom, int wx0, int wx1, int ox, intptr_t mx, intptr_t my, int width)
static void FUNC() put_hevc_qpel_bi_w_v(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, int denom, int wx0, int wx1, int ox, intptr_t mx, intptr_t my, int width)