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];
133 int size = 1 << log2_size;
137 for (y = 0; y <
size; y++) {
138 for (x = 0; x <
size; x++) {
143 }
else if (
shift < 0) {
144 for (y = 0; y <
size; y++) {
145 for (x = 0; x <
size; x++) {
146 *coeffs = *(uint16_t*)coeffs << -
shift;
154 #define SET(dst, x) (dst) = (x)
155 #define SCALE(dst, x) (dst) = av_clip_int16(((x) + add) >> shift)
157 #define TR_4x4_LUMA(dst, src, step, assign) \
159 int c0 = src[0 * step] + src[2 * step]; \
160 int c1 = src[2 * step] + src[3 * step]; \
161 int c2 = src[0 * step] - src[3 * step]; \
162 int c3 = 74 * src[1 * step]; \
164 assign(dst[2 * step], 74 * (src[0 * step] - \
167 assign(dst[0 * step], 29 * c0 + 55 * c1 + c3); \
168 assign(dst[1 * step], 55 * c2 - 29 * c1 + c3); \
169 assign(dst[3 * step], 55 * c0 + 29 * c2 - c3); \
176 int add = 1 << (
shift - 1);
177 int16_t *
src = coeffs;
179 for (
i = 0;
i < 4;
i++) {
185 add = 1 << (
shift - 1);
186 for (
i = 0;
i < 4;
i++) {
194 #define TR_4(dst, src, dstep, sstep, assign, end) \
196 const int e0 = 64 * src[0 * sstep] + 64 * src[2 * sstep]; \
197 const int e1 = 64 * src[0 * sstep] - 64 * src[2 * sstep]; \
198 const int o0 = 83 * src[1 * sstep] + 36 * src[3 * sstep]; \
199 const int o1 = 36 * src[1 * sstep] - 83 * src[3 * sstep]; \
201 assign(dst[0 * dstep], e0 + o0); \
202 assign(dst[1 * dstep], e1 + o1); \
203 assign(dst[2 * dstep], e1 - o1); \
204 assign(dst[3 * dstep], e0 - o0); \
207 #define TR_8(dst, src, dstep, sstep, assign, end) \
211 int o_8[4] = { 0 }; \
212 for (i = 0; i < 4; i++) \
213 for (j = 1; j < end; j += 2) \
214 o_8[i] += transform[4 * j][i] * src[j * sstep]; \
215 TR_4(e_8, src, 1, 2 * sstep, SET, 4); \
217 for (i = 0; i < 4; i++) { \
218 assign(dst[i * dstep], e_8[i] + o_8[i]); \
219 assign(dst[(7 - i) * dstep], e_8[i] - o_8[i]); \
223 #define TR_16(dst, src, dstep, sstep, assign, end) \
227 int o_16[8] = { 0 }; \
228 for (i = 0; i < 8; i++) \
229 for (j = 1; j < end; j += 2) \
230 o_16[i] += transform[2 * j][i] * src[j * sstep]; \
231 TR_8(e_16, src, 1, 2 * sstep, SET, 8); \
233 for (i = 0; i < 8; i++) { \
234 assign(dst[i * dstep], e_16[i] + o_16[i]); \
235 assign(dst[(15 - i) * dstep], e_16[i] - o_16[i]); \
239 #define TR_32(dst, src, dstep, sstep, assign, end) \
243 int o_32[16] = { 0 }; \
244 for (i = 0; i < 16; i++) \
245 for (j = 1; j < end; j += 2) \
246 o_32[i] += transform[j][i] * src[j * sstep]; \
247 TR_16(e_32, src, 1, 2 * sstep, SET, end / 2); \
249 for (i = 0; i < 16; i++) { \
250 assign(dst[i * dstep], e_32[i] + o_32[i]); \
251 assign(dst[(31 - i) * dstep], e_32[i] - o_32[i]); \
255 #define IDCT_VAR4(H) \
256 int limit2 = FFMIN(col_limit + 4, H)
257 #define IDCT_VAR8(H) \
258 int limit = FFMIN(col_limit, H); \
259 int limit2 = FFMIN(col_limit + 4, H)
260 #define IDCT_VAR16(H) IDCT_VAR8(H)
261 #define IDCT_VAR32(H) IDCT_VAR8(H)
264 static void FUNC(idct_ ## H ## x ## H )(int16_t *coeffs, \
269 int add = 1 << (shift - 1); \
270 int16_t *src = coeffs; \
273 for (i = 0; i < H; i++) { \
274 TR_ ## H(src, src, H, H, SCALE, limit2); \
275 if (limit2 < H && i%4 == 0 && !!i) \
280 shift = 20 - BIT_DEPTH; \
281 add = 1 << (shift - 1); \
282 for (i = 0; i < H; i++) { \
283 TR_ ## H(coeffs, coeffs, 1, 1, SCALE, limit); \
289 static void FUNC(idct_ ## H ## x ## H ## _dc)(int16_t *coeffs) \
292 int shift = 14 - BIT_DEPTH; \
293 int add = 1 << (shift - 1); \
294 int coeff = (((coeffs[0] + 1) >> 1) + add) >> shift; \
296 for (j = 0; j < H; j++) { \
297 for (i = 0; i < H; i++) { \
298 coeffs[i + j * H] = coeff; \
324 #define ff_hevc_pel_filters ff_hevc_qpel_filters
325 #define DECL_HV_FILTER(f) \
326 const int8_t *hf = ff_hevc_ ## f ## _filters[mx]; \
327 const int8_t *vf = ff_hevc_ ## f ## _filters[my];
329 #define FW_PUT(p, f, t) \
330 static void FUNC(put_hevc_## f)(int16_t *dst, const uint8_t *src, ptrdiff_t srcstride, int height, \
331 intptr_t mx, intptr_t my, int width) \
334 FUNC(put_ ## t)(dst, src, srcstride, height, hf, vf, width); \
337 #define FW_PUT_UNI(p, f, t) \
338 static void FUNC(put_hevc_ ## f)(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, \
339 ptrdiff_t srcstride, int height, intptr_t mx, intptr_t my, int width) \
342 FUNC(put_ ## t)(dst, dststride, src, srcstride, height, hf, vf, width); \
345 #define FW_PUT_UNI_W(p, f, t) \
346 static void FUNC(put_hevc_ ## f)(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, \
347 ptrdiff_t srcstride,int height, int denom, int wx, int ox, \
348 intptr_t mx, intptr_t my, int width) \
351 FUNC(put_ ## t)(dst, dststride, src, srcstride, height, denom, wx, ox, hf, vf, width); \
354 #define FW_PUT_FUNCS(f, t, dir) \
355 FW_PUT(f, f ## _ ## dir, t ## _ ## dir) \
356 FW_PUT_UNI(f, f ## _uni_ ## dir, uni_ ## t ## _ ## dir) \
357 FW_PUT_UNI_W(f, f ## _uni_w_ ## dir, uni_## t ## _w_ ## dir)
359 FW_PUT(pel, pel_pixels, pixels)
387 for (y = 0; y <
height; y++) {
388 for (x = 0; x <
width; x++)
398 int height,
int denom,
int wx0,
int wx1,
399 int ox0,
int ox1, intptr_t
mx, intptr_t
my,
int width)
408 int log2Wd = denom +
shift - 1;
412 for (y = 0; y <
height; y++) {
413 for (x = 0; x <
width; x++) {
425 #define QPEL_FILTER(src, stride) \
426 (filter[0] * src[x - 3 * stride] + \
427 filter[1] * src[x - 2 * stride] + \
428 filter[2] * src[x - stride] + \
429 filter[3] * src[x ] + \
430 filter[4] * src[x + stride] + \
431 filter[5] * src[x + 2 * stride] + \
432 filter[6] * src[x + 3 * stride] + \
433 filter[7] * src[x + 4 * stride])
454 for (y = 0; y <
height; y++) {
455 for (x = 0; x <
width; x++)
482 for (y = 0; y <
height; y++) {
483 for (x = 0; x <
width; x++)
502 int16_t *
tmp = tmp_array;
513 for (x = 0; x <
width; x++)
522 for (y = 0; y <
height; y++) {
523 for (x = 0; x <
width; x++)
533 int height,
int denom,
int wx0,
int wx1,
534 int ox0,
int ox1, intptr_t
mx, intptr_t
my,
int width)
545 int log2Wd = denom +
shift - 1;
549 for (y = 0; y <
height; y++) {
550 for (x = 0; x <
width; x++)
552 ((ox0 + ox1 + 1) * (1 << log2Wd))) >> (log2Wd + 1));
561 int height,
int denom,
int wx0,
int wx1,
562 int ox0,
int ox1, intptr_t
mx, intptr_t
my,
int width)
573 int log2Wd = denom +
shift - 1;
577 for (y = 0; y <
height; y++) {
578 for (x = 0; x <
width; x++)
580 ((ox0 + ox1 + 1) * (1 << log2Wd))) >> (log2Wd + 1));
589 int height,
int denom,
int wx0,
int wx1,
590 int ox0,
int ox1, intptr_t
mx, intptr_t
my,
int width)
599 int16_t *
tmp = tmp_array;
601 int log2Wd = denom +
shift - 1;
606 for (x = 0; x <
width; x++)
617 for (y = 0; y <
height; y++) {
618 for (x = 0; x <
width; x++)
620 ((ox0 + ox1 + 1) * (1 << log2Wd))) >> (log2Wd + 1));
630 #define EPEL_FILTER(src, stride) \
631 (filter[0] * src[x - stride] + \
632 filter[1] * src[x] + \
633 filter[2] * src[x + stride] + \
634 filter[3] * src[x + 2 * stride])
653 for (y = 0; y <
height; y++) {
654 for (x = 0; x <
width; x++) {
680 for (y = 0; y <
height; y++) {
681 for (x = 0; x <
width; x++)
700 int16_t *
tmp = tmp_array;
711 for (x = 0; x <
width; x++)
720 for (y = 0; y <
height; y++) {
721 for (x = 0; x <
width; x++)
731 int height,
int denom,
int wx0,
int wx1,
732 int ox0,
int ox1, intptr_t
mx, intptr_t
my,
int width)
741 int log2Wd = denom +
shift - 1;
745 for (y = 0; y <
height; y++) {
746 for (x = 0; x <
width; x++)
748 ((ox0 + ox1 + 1) * (1 << log2Wd))) >> (log2Wd + 1));
757 int height,
int denom,
int wx0,
int wx1,
758 int ox0,
int ox1, intptr_t
mx, intptr_t
my,
int width)
767 int log2Wd = denom +
shift - 1;
771 for (y = 0; y <
height; y++) {
772 for (x = 0; x <
width; x++)
774 ((ox0 + ox1 + 1) * (1 << log2Wd))) >> (log2Wd + 1));
783 int height,
int denom,
int wx0,
int wx1,
784 int ox0,
int ox1, intptr_t
mx, intptr_t
my,
int width)
793 int16_t *
tmp = tmp_array;
795 int log2Wd = denom +
shift - 1;
800 for (x = 0; x <
width; x++)
811 for (y = 0; y <
height; y++) {
812 for (x = 0; x <
width; x++)
814 ((ox0 + ox1 + 1) * (1 << log2Wd))) >> (log2Wd + 1));
822 #define P3 pix[-4 * xstride]
823 #define P2 pix[-3 * xstride]
824 #define P1 pix[-2 * xstride]
825 #define P0 pix[-1 * xstride]
826 #define Q0 pix[0 * xstride]
827 #define Q1 pix[1 * xstride]
828 #define Q2 pix[2 * xstride]
829 #define Q3 pix[3 * xstride]
832 #define TP3 pix[-4 * xstride + 3 * ystride]
833 #define TP2 pix[-3 * xstride + 3 * ystride]
834 #define TP1 pix[-2 * xstride + 3 * ystride]
835 #define TP0 pix[-1 * xstride + 3 * ystride]
836 #define TQ0 pix[0 * xstride + 3 * ystride]
837 #define TQ1 pix[1 * xstride + 3 * ystride]
838 #define TQ2 pix[2 * xstride + 3 * ystride]
839 #define TQ3 pix[3 * xstride + 3 * ystride]
844 ptrdiff_t _xstride, ptrdiff_t _ystride,
845 int beta,
const int *_tc,
846 const uint8_t *_no_p,
const uint8_t *_no_q)
848 ptrdiff_t xstride = _xstride /
sizeof(
pixel);
849 ptrdiff_t ystride = _ystride /
sizeof(
pixel);
853 for (
int j = 0; j < 2; j++) {
859 const int d0 = dp0 + dq0;
860 const int d3 = dp3 + dq3;
861 const int tc = _tc[j] << (
BIT_DEPTH - 8);
862 const int no_p = _no_p[j];
863 const int no_q = _no_q[j];
865 if (d0 + d3 < beta) {
866 const int beta_3 = beta >> 3;
867 const int beta_2 = beta >> 2;
868 const int tc25 = ((tc * 5 + 1) >> 1);
872 (d0 << 1) < beta_2 && (d3 << 1) < beta_2) {
873 const int tc2 = tc << 1;
878 if (dp0 + dp3 < ((beta + (beta >> 1)) >> 3))
880 if (dq0 + dq3 < ((beta + (beta >> 1)) >> 3))
889 ptrdiff_t _ystride,
const int *_tc,
890 const uint8_t *_no_p,
const uint8_t *_no_q)
893 ptrdiff_t xstride = _xstride /
sizeof(
pixel);
894 ptrdiff_t ystride = _ystride /
sizeof(
pixel);
897 for (
int j = 0; j < 2; j++) {
899 const int tc = _tc[j] << (
BIT_DEPTH - 8);
910 const int32_t *tc,
const uint8_t *no_p,
917 const int32_t *tc,
const uint8_t *no_p,
924 int beta,
const int32_t *tc,
const uint8_t *no_p,
928 beta, tc, no_p, no_q);
932 int beta,
const int32_t *tc,
const uint8_t *no_p,
936 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)
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)
#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)