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 ox0,
int ox1, intptr_t
mx, intptr_t
my,
int width)
406 int log2Wd = denom +
shift - 1;
410 for (y = 0; y <
height; y++) {
411 for (x = 0; x <
width; x++) {
423 #define QPEL_FILTER(src, stride) \
424 (filter[0] * src[x - 3 * stride] + \
425 filter[1] * src[x - 2 * stride] + \
426 filter[2] * src[x - stride] + \
427 filter[3] * src[x ] + \
428 filter[4] * src[x + stride] + \
429 filter[5] * src[x + 2 * stride] + \
430 filter[6] * src[x + 3 * stride] + \
431 filter[7] * src[x + 4 * stride])
452 for (y = 0; y <
height; y++) {
453 for (x = 0; x <
width; x++)
480 for (y = 0; y <
height; y++) {
481 for (x = 0; x <
width; x++)
500 int16_t *
tmp = tmp_array;
511 for (x = 0; x <
width; x++)
520 for (y = 0; y <
height; y++) {
521 for (x = 0; x <
width; x++)
531 int height,
int denom,
int wx0,
int wx1,
532 int ox0,
int ox1, intptr_t
mx, intptr_t
my,
int width)
543 int log2Wd = denom +
shift - 1;
547 for (y = 0; y <
height; y++) {
548 for (x = 0; x <
width; x++)
550 ((ox0 + ox1 + 1) * (1 << log2Wd))) >> (log2Wd + 1));
559 int height,
int denom,
int wx0,
int wx1,
560 int ox0,
int ox1, intptr_t
mx, intptr_t
my,
int width)
571 int log2Wd = denom +
shift - 1;
575 for (y = 0; y <
height; y++) {
576 for (x = 0; x <
width; x++)
578 ((ox0 + ox1 + 1) * (1 << log2Wd))) >> (log2Wd + 1));
587 int height,
int denom,
int wx0,
int wx1,
588 int ox0,
int ox1, intptr_t
mx, intptr_t
my,
int width)
597 int16_t *
tmp = tmp_array;
599 int log2Wd = denom +
shift - 1;
604 for (x = 0; x <
width; x++)
615 for (y = 0; y <
height; y++) {
616 for (x = 0; x <
width; x++)
618 ((ox0 + ox1 + 1) * (1 << log2Wd))) >> (log2Wd + 1));
628 #define EPEL_FILTER(src, stride) \
629 (filter[0] * src[x - stride] + \
630 filter[1] * src[x] + \
631 filter[2] * src[x + stride] + \
632 filter[3] * src[x + 2 * stride])
651 for (y = 0; y <
height; y++) {
652 for (x = 0; x <
width; x++) {
678 for (y = 0; y <
height; y++) {
679 for (x = 0; x <
width; x++)
698 int16_t *
tmp = tmp_array;
709 for (x = 0; x <
width; x++)
718 for (y = 0; y <
height; y++) {
719 for (x = 0; x <
width; x++)
729 int height,
int denom,
int wx0,
int wx1,
730 int ox0,
int ox1, intptr_t
mx, intptr_t
my,
int width)
739 int log2Wd = denom +
shift - 1;
743 for (y = 0; y <
height; y++) {
744 for (x = 0; x <
width; x++)
746 ((ox0 + ox1 + 1) * (1 << log2Wd))) >> (log2Wd + 1));
755 int height,
int denom,
int wx0,
int wx1,
756 int ox0,
int ox1, intptr_t
mx, intptr_t
my,
int width)
765 int log2Wd = denom +
shift - 1;
769 for (y = 0; y <
height; y++) {
770 for (x = 0; x <
width; x++)
772 ((ox0 + ox1 + 1) * (1 << log2Wd))) >> (log2Wd + 1));
781 int height,
int denom,
int wx0,
int wx1,
782 int ox0,
int ox1, intptr_t
mx, intptr_t
my,
int width)
791 int16_t *
tmp = tmp_array;
793 int log2Wd = denom +
shift - 1;
798 for (x = 0; x <
width; x++)
809 for (y = 0; y <
height; y++) {
810 for (x = 0; x <
width; x++)
812 ((ox0 + ox1 + 1) * (1 << log2Wd))) >> (log2Wd + 1));
820 #define P3 pix[-4 * xstride]
821 #define P2 pix[-3 * xstride]
822 #define P1 pix[-2 * xstride]
823 #define P0 pix[-1 * xstride]
824 #define Q0 pix[0 * xstride]
825 #define Q1 pix[1 * xstride]
826 #define Q2 pix[2 * xstride]
827 #define Q3 pix[3 * xstride]
830 #define TP3 pix[-4 * xstride + 3 * ystride]
831 #define TP2 pix[-3 * xstride + 3 * ystride]
832 #define TP1 pix[-2 * xstride + 3 * ystride]
833 #define TP0 pix[-1 * xstride + 3 * ystride]
834 #define TQ0 pix[0 * xstride + 3 * ystride]
835 #define TQ1 pix[1 * xstride + 3 * ystride]
836 #define TQ2 pix[2 * xstride + 3 * ystride]
837 #define TQ3 pix[3 * xstride + 3 * ystride]
842 ptrdiff_t _xstride, ptrdiff_t _ystride,
843 int beta,
const int *_tc,
844 const uint8_t *_no_p,
const uint8_t *_no_q)
846 ptrdiff_t xstride = _xstride /
sizeof(
pixel);
847 ptrdiff_t ystride = _ystride /
sizeof(
pixel);
851 for (
int j = 0; j < 2; j++) {
857 const int d0 = dp0 + dq0;
858 const int d3 = dp3 + dq3;
859 const int tc = _tc[j] << (
BIT_DEPTH - 8);
860 const int no_p = _no_p[j];
861 const int no_q = _no_q[j];
863 if (d0 + d3 < beta) {
864 const int beta_3 = beta >> 3;
865 const int beta_2 = beta >> 2;
866 const int tc25 = ((tc * 5 + 1) >> 1);
870 (d0 << 1) < beta_2 && (d3 << 1) < beta_2) {
871 const int tc2 = tc << 1;
876 if (dp0 + dp3 < ((beta + (beta >> 1)) >> 3))
878 if (dq0 + dq3 < ((beta + (beta >> 1)) >> 3))
887 ptrdiff_t _ystride,
const int *_tc,
888 const uint8_t *_no_p,
const uint8_t *_no_q)
891 ptrdiff_t xstride = _xstride /
sizeof(
pixel);
892 ptrdiff_t ystride = _ystride /
sizeof(
pixel);
895 for (
int j = 0; j < 2; j++) {
897 const int tc = _tc[j] << (
BIT_DEPTH - 8);
908 const int32_t *tc,
const uint8_t *no_p,
915 const int32_t *tc,
const uint8_t *no_p,
922 int beta,
const int32_t *tc,
const uint8_t *no_p,
926 beta, tc, no_p, no_q);
930 int beta,
const int32_t *tc,
const uint8_t *no_p,
934 beta, tc, no_p, 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 ox0, int ox1, intptr_t mx, intptr_t my, int width)
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)
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 ox0, int ox1, 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)
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_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 ox0, int ox1, 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 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 ox0, int ox1, intptr_t mx, intptr_t my, int width)
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
#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() 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 ox0, int ox1, intptr_t mx, intptr_t my, int width)
static void FUNC() add_residual16x16(uint8_t *_dst, const int16_t *res, ptrdiff_t stride)
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 ox0, int ox1, intptr_t mx, intptr_t my, int width)
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_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 ox0, int ox1, intptr_t mx, intptr_t my, int width)