Go to the documentation of this file.
39 for (y = 0; y <
height; y++) {
40 for (x = 0; x <
width; x++)
54 for (y = 0; y <
size; y++) {
55 for (x = 0; x <
size; x++) {
89 int16_t *coeffs = (int16_t *) _coeffs;
91 int size = 1 << log2_size;
95 for (y = 0; y <
size - 1; y++) {
96 for (x = 0; x <
size; x++)
97 coeffs[x] += coeffs[x -
size];
101 for (y = 0; y <
size; y++) {
102 for (x = 1; x <
size; x++)
103 coeffs[x] += coeffs[x - 1];
113 int size = 1 << log2_size;
117 for (y = 0; y <
size; y++) {
118 for (x = 0; x <
size; x++) {
124 for (y = 0; y <
size; y++) {
125 for (x = 0; x <
size; x++) {
126 *coeffs = *(uint16_t*)coeffs << -
shift;
133 #define SET(dst, x) (dst) = (x)
134 #define SCALE(dst, x) (dst) = av_clip_int16(((x) + add) >> shift)
136 #define TR_4x4_LUMA(dst, src, step, assign) \
138 int c0 = src[0 * step] + src[2 * step]; \
139 int c1 = src[2 * step] + src[3 * step]; \
140 int c2 = src[0 * step] - src[3 * step]; \
141 int c3 = 74 * src[1 * step]; \
143 assign(dst[2 * step], 74 * (src[0 * step] - \
146 assign(dst[0 * step], 29 * c0 + 55 * c1 + c3); \
147 assign(dst[1 * step], 55 * c2 - 29 * c1 + c3); \
148 assign(dst[3 * step], 55 * c0 + 29 * c2 - c3); \
155 int add = 1 << (
shift - 1);
156 int16_t *
src = coeffs;
158 for (
i = 0;
i < 4;
i++) {
164 add = 1 << (
shift - 1);
165 for (
i = 0;
i < 4;
i++) {
173 #define TR_4(dst, src, dstep, sstep, assign, end) \
175 const int e0 = 64 * src[0 * sstep] + 64 * src[2 * sstep]; \
176 const int e1 = 64 * src[0 * sstep] - 64 * src[2 * sstep]; \
177 const int o0 = 83 * src[1 * sstep] + 36 * src[3 * sstep]; \
178 const int o1 = 36 * src[1 * sstep] - 83 * src[3 * sstep]; \
180 assign(dst[0 * dstep], e0 + o0); \
181 assign(dst[1 * dstep], e1 + o1); \
182 assign(dst[2 * dstep], e1 - o1); \
183 assign(dst[3 * dstep], e0 - o0); \
186 #define TR_8(dst, src, dstep, sstep, assign, end) \
190 int o_8[4] = { 0 }; \
191 for (i = 0; i < 4; i++) \
192 for (j = 1; j < end; j += 2) \
193 o_8[i] += transform[4 * j][i] * src[j * sstep]; \
194 TR_4(e_8, src, 1, 2 * sstep, SET, 4); \
196 for (i = 0; i < 4; i++) { \
197 assign(dst[i * dstep], e_8[i] + o_8[i]); \
198 assign(dst[(7 - i) * dstep], e_8[i] - o_8[i]); \
202 #define TR_16(dst, src, dstep, sstep, assign, end) \
206 int o_16[8] = { 0 }; \
207 for (i = 0; i < 8; i++) \
208 for (j = 1; j < end; j += 2) \
209 o_16[i] += transform[2 * j][i] * src[j * sstep]; \
210 TR_8(e_16, src, 1, 2 * sstep, SET, 8); \
212 for (i = 0; i < 8; i++) { \
213 assign(dst[i * dstep], e_16[i] + o_16[i]); \
214 assign(dst[(15 - i) * dstep], e_16[i] - o_16[i]); \
218 #define TR_32(dst, src, dstep, sstep, assign, end) \
222 int o_32[16] = { 0 }; \
223 for (i = 0; i < 16; i++) \
224 for (j = 1; j < end; j += 2) \
225 o_32[i] += transform[j][i] * src[j * sstep]; \
226 TR_16(e_32, src, 1, 2 * sstep, SET, end / 2); \
228 for (i = 0; i < 16; i++) { \
229 assign(dst[i * dstep], e_32[i] + o_32[i]); \
230 assign(dst[(31 - i) * dstep], e_32[i] - o_32[i]); \
234 #define IDCT_VAR4(H) \
235 int limit2 = FFMIN(col_limit + 4, H)
236 #define IDCT_VAR8(H) \
237 int limit = FFMIN(col_limit, H); \
238 int limit2 = FFMIN(col_limit + 4, H)
239 #define IDCT_VAR16(H) IDCT_VAR8(H)
240 #define IDCT_VAR32(H) IDCT_VAR8(H)
243 static void FUNC(idct_ ## H ## x ## H )(int16_t *coeffs, \
248 int add = 1 << (shift - 1); \
249 int16_t *src = coeffs; \
252 for (i = 0; i < H; i++) { \
253 TR_ ## H(src, src, H, H, SCALE, limit2); \
254 if (limit2 < H && i%4 == 0 && !!i) \
259 shift = 20 - BIT_DEPTH; \
260 add = 1 << (shift - 1); \
261 for (i = 0; i < H; i++) { \
262 TR_ ## H(coeffs, coeffs, 1, 1, SCALE, limit); \
268 static void FUNC(idct_ ## H ## x ## H ## _dc)(int16_t *coeffs) \
271 int shift = 14 - BIT_DEPTH; \
272 int add = 1 << (shift - 1); \
273 int coeff = (((coeffs[0] + 1) >> 1) + add) >> shift; \
275 for (j = 0; j < H; j++) { \
276 for (i = 0; i < H; i++) { \
277 coeffs[i + j * H] = coeff; \
303 #define ff_hevc_pel_filters ff_hevc_qpel_filters
304 #define DECL_HV_FILTER(f) \
305 const int8_t *hf = ff_hevc_ ## f ## _filters[mx]; \
306 const int8_t *vf = ff_hevc_ ## f ## _filters[my];
308 #define FW_PUT(p, f, t) \
309 static void FUNC(put_hevc_## f)(int16_t *dst, const uint8_t *src, ptrdiff_t srcstride, int height, \
310 intptr_t mx, intptr_t my, int width) \
313 FUNC(put_ ## t)(dst, src, srcstride, height, hf, vf, width); \
316 #define FW_PUT_UNI(p, f, t) \
317 static void FUNC(put_hevc_ ## f)(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, \
318 ptrdiff_t srcstride, int height, intptr_t mx, intptr_t my, int width) \
321 FUNC(put_ ## t)(dst, dststride, src, srcstride, height, hf, vf, width); \
324 #define FW_PUT_UNI_W(p, f, t) \
325 static void FUNC(put_hevc_ ## f)(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, \
326 ptrdiff_t srcstride,int height, int denom, int wx, int ox, \
327 intptr_t mx, intptr_t my, int width) \
330 FUNC(put_ ## t)(dst, dststride, src, srcstride, height, denom, wx, ox, hf, vf, width); \
333 #define FW_PUT_FUNCS(f, t, dir) \
334 FW_PUT(f, f ## _ ## dir, t ## _ ## dir) \
335 FW_PUT_UNI(f, f ## _uni_ ## dir, uni_ ## t ## _ ## dir) \
336 FW_PUT_UNI_W(f, f ## _uni_w_ ## dir, uni_## t ## _w_ ## dir)
338 FW_PUT(pel, pel_pixels, pixels)
366 for (y = 0; y <
height; y++) {
367 for (x = 0; x <
width; x++)
377 int height,
int denom,
int wx0,
int wx1,
378 int ox0,
int ox1, intptr_t
mx, intptr_t
my,
int width)
387 int log2Wd = denom +
shift - 1;
391 for (y = 0; y <
height; y++) {
392 for (x = 0; x <
width; x++) {
404 #define QPEL_FILTER(src, stride) \
405 (filter[0] * src[x - 3 * stride] + \
406 filter[1] * src[x - 2 * stride] + \
407 filter[2] * src[x - stride] + \
408 filter[3] * src[x ] + \
409 filter[4] * src[x + stride] + \
410 filter[5] * src[x + 2 * stride] + \
411 filter[6] * src[x + 3 * stride] + \
412 filter[7] * src[x + 4 * stride])
433 for (y = 0; y <
height; y++) {
434 for (x = 0; x <
width; x++)
461 for (y = 0; y <
height; y++) {
462 for (x = 0; x <
width; x++)
481 int16_t *
tmp = tmp_array;
492 for (x = 0; x <
width; x++)
501 for (y = 0; y <
height; y++) {
502 for (x = 0; x <
width; x++)
512 int height,
int denom,
int wx0,
int wx1,
513 int ox0,
int ox1, intptr_t
mx, intptr_t
my,
int width)
524 int log2Wd = denom +
shift - 1;
528 for (y = 0; y <
height; y++) {
529 for (x = 0; x <
width; x++)
531 ((ox0 + ox1 + 1) * (1 << log2Wd))) >> (log2Wd + 1));
540 int height,
int denom,
int wx0,
int wx1,
541 int ox0,
int ox1, intptr_t
mx, intptr_t
my,
int width)
552 int log2Wd = denom +
shift - 1;
556 for (y = 0; y <
height; y++) {
557 for (x = 0; x <
width; x++)
559 ((ox0 + ox1 + 1) * (1 << log2Wd))) >> (log2Wd + 1));
568 int height,
int denom,
int wx0,
int wx1,
569 int ox0,
int ox1, intptr_t
mx, intptr_t
my,
int width)
578 int16_t *
tmp = tmp_array;
580 int log2Wd = denom +
shift - 1;
585 for (x = 0; x <
width; x++)
596 for (y = 0; y <
height; y++) {
597 for (x = 0; x <
width; x++)
599 ((ox0 + ox1 + 1) * (1 << log2Wd))) >> (log2Wd + 1));
609 #define EPEL_FILTER(src, stride) \
610 (filter[0] * src[x - stride] + \
611 filter[1] * src[x] + \
612 filter[2] * src[x + stride] + \
613 filter[3] * src[x + 2 * stride])
632 for (y = 0; y <
height; y++) {
633 for (x = 0; x <
width; x++) {
659 for (y = 0; y <
height; y++) {
660 for (x = 0; x <
width; x++)
679 int16_t *
tmp = tmp_array;
690 for (x = 0; x <
width; x++)
699 for (y = 0; y <
height; y++) {
700 for (x = 0; x <
width; x++)
710 int height,
int denom,
int wx0,
int wx1,
711 int ox0,
int ox1, intptr_t
mx, intptr_t
my,
int width)
720 int log2Wd = denom +
shift - 1;
724 for (y = 0; y <
height; y++) {
725 for (x = 0; x <
width; x++)
727 ((ox0 + ox1 + 1) * (1 << log2Wd))) >> (log2Wd + 1));
736 int height,
int denom,
int wx0,
int wx1,
737 int ox0,
int ox1, intptr_t
mx, intptr_t
my,
int width)
746 int log2Wd = denom +
shift - 1;
750 for (y = 0; y <
height; y++) {
751 for (x = 0; x <
width; x++)
753 ((ox0 + ox1 + 1) * (1 << log2Wd))) >> (log2Wd + 1));
762 int height,
int denom,
int wx0,
int wx1,
763 int ox0,
int ox1, intptr_t
mx, intptr_t
my,
int width)
772 int16_t *
tmp = tmp_array;
774 int log2Wd = denom +
shift - 1;
779 for (x = 0; x <
width; x++)
790 for (y = 0; y <
height; y++) {
791 for (x = 0; x <
width; x++)
793 ((ox0 + ox1 + 1) * (1 << log2Wd))) >> (log2Wd + 1));
801 #define P3 pix[-4 * xstride]
802 #define P2 pix[-3 * xstride]
803 #define P1 pix[-2 * xstride]
804 #define P0 pix[-1 * xstride]
805 #define Q0 pix[0 * xstride]
806 #define Q1 pix[1 * xstride]
807 #define Q2 pix[2 * xstride]
808 #define Q3 pix[3 * xstride]
811 #define TP3 pix[-4 * xstride + 3 * ystride]
812 #define TP2 pix[-3 * xstride + 3 * ystride]
813 #define TP1 pix[-2 * xstride + 3 * ystride]
814 #define TP0 pix[-1 * xstride + 3 * ystride]
815 #define TQ0 pix[0 * xstride + 3 * ystride]
816 #define TQ1 pix[1 * xstride + 3 * ystride]
817 #define TQ2 pix[2 * xstride + 3 * ystride]
818 #define TQ3 pix[3 * xstride + 3 * ystride]
823 ptrdiff_t _xstride, ptrdiff_t _ystride,
824 int beta,
const int *_tc,
825 const uint8_t *_no_p,
const uint8_t *_no_q)
827 ptrdiff_t xstride = _xstride /
sizeof(
pixel);
828 ptrdiff_t ystride = _ystride /
sizeof(
pixel);
832 for (
int j = 0; j < 2; j++) {
838 const int d0 = dp0 + dq0;
839 const int d3 = dp3 + dq3;
840 const int tc = _tc[j] << (
BIT_DEPTH - 8);
841 const int no_p = _no_p[j];
842 const int no_q = _no_q[j];
844 if (d0 + d3 < beta) {
845 const int beta_3 = beta >> 3;
846 const int beta_2 = beta >> 2;
847 const int tc25 = ((tc * 5 + 1) >> 1);
851 (d0 << 1) < beta_2 && (d3 << 1) < beta_2) {
852 const int tc2 = tc << 1;
857 if (dp0 + dp3 < ((beta + (beta >> 1)) >> 3))
859 if (dq0 + dq3 < ((beta + (beta >> 1)) >> 3))
868 ptrdiff_t _ystride,
const int *_tc,
869 const uint8_t *_no_p,
const uint8_t *_no_q)
872 ptrdiff_t xstride = _xstride /
sizeof(
pixel);
873 ptrdiff_t ystride = _ystride /
sizeof(
pixel);
876 for (
int j = 0; j < 2; j++) {
878 const int tc = _tc[j] << (
BIT_DEPTH - 8);
889 const int32_t *tc,
const uint8_t *no_p,
896 const int32_t *tc,
const uint8_t *no_p,
903 int beta,
const int32_t *tc,
const uint8_t *no_p,
907 beta, tc, no_p, no_q);
911 int beta,
const int32_t *tc,
const uint8_t *no_p,
915 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 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 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)
#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)
#define i(width, name, range_min, range_max)
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 av_always_inline void FUNC() add_residual(uint8_t *_dst, const int16_t *res, ptrdiff_t stride, int size)
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)