1cabdff1aSopenharmony_ci/*
2cabdff1aSopenharmony_ci * VP9 compatible video decoder
3cabdff1aSopenharmony_ci *
4cabdff1aSopenharmony_ci * Copyright (C) 2013 Ronald S. Bultje <rsbultje gmail com>
5cabdff1aSopenharmony_ci * Copyright (C) 2013 Clément Bœsch <u pkh me>
6cabdff1aSopenharmony_ci *
7cabdff1aSopenharmony_ci * This file is part of FFmpeg.
8cabdff1aSopenharmony_ci *
9cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or
10cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public
11cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either
12cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version.
13cabdff1aSopenharmony_ci *
14cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful,
15cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
16cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17cabdff1aSopenharmony_ci * Lesser General Public License for more details.
18cabdff1aSopenharmony_ci *
19cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public
20cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software
21cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22cabdff1aSopenharmony_ci */
23cabdff1aSopenharmony_ci
24cabdff1aSopenharmony_ci#ifndef AVCODEC_VP9DSP_H
25cabdff1aSopenharmony_ci#define AVCODEC_VP9DSP_H
26cabdff1aSopenharmony_ci
27cabdff1aSopenharmony_ci#include <stddef.h>
28cabdff1aSopenharmony_ci#include <stdint.h>
29cabdff1aSopenharmony_ci
30cabdff1aSopenharmony_ci#include "libavcodec/vp9.h"
31cabdff1aSopenharmony_ci
32cabdff1aSopenharmony_citypedef void (*vp9_mc_func)(uint8_t *dst, ptrdiff_t dst_stride,
33cabdff1aSopenharmony_ci                            const uint8_t *ref, ptrdiff_t ref_stride,
34cabdff1aSopenharmony_ci                            int h, int mx, int my);
35cabdff1aSopenharmony_citypedef void (*vp9_scaled_mc_func)(uint8_t *dst, ptrdiff_t dst_stride,
36cabdff1aSopenharmony_ci                                   const uint8_t *ref, ptrdiff_t ref_stride,
37cabdff1aSopenharmony_ci                                   int h, int mx, int my, int dx, int dy);
38cabdff1aSopenharmony_ci
39cabdff1aSopenharmony_citypedef struct VP9DSPContext {
40cabdff1aSopenharmony_ci    /*
41cabdff1aSopenharmony_ci     * dimension 1: 0=4x4, 1=8x8, 2=16x16, 3=32x32
42cabdff1aSopenharmony_ci     * dimension 2: intra prediction modes
43cabdff1aSopenharmony_ci     *
44cabdff1aSopenharmony_ci     * dst/left/top is aligned by transform-size (i.e. 4, 8, 16 or 32 pixels)
45cabdff1aSopenharmony_ci     * stride is aligned by 16 pixels
46cabdff1aSopenharmony_ci     * top[-1] is top/left; top[4,7] is top-right for 4x4
47cabdff1aSopenharmony_ci     */
48cabdff1aSopenharmony_ci    // FIXME(rbultje) maybe replace left/top pointers with HAVE_TOP/
49cabdff1aSopenharmony_ci    // HAVE_LEFT/HAVE_TOPRIGHT flags instead, and then handle it in-place?
50cabdff1aSopenharmony_ci    // also needs to fit in with what H.264/VP8/etc do
51cabdff1aSopenharmony_ci    void (*intra_pred[N_TXFM_SIZES][N_INTRA_PRED_MODES])(uint8_t *dst,
52cabdff1aSopenharmony_ci                                                         ptrdiff_t stride,
53cabdff1aSopenharmony_ci                                                         const uint8_t *left,
54cabdff1aSopenharmony_ci                                                         const uint8_t *top);
55cabdff1aSopenharmony_ci
56cabdff1aSopenharmony_ci    /*
57cabdff1aSopenharmony_ci     * dimension 1: 0=4x4, 1=8x8, 2=16x16, 3=32x32, 4=lossless (3-4=dct only)
58cabdff1aSopenharmony_ci     * dimension 2: 0=dct/dct, 1=dct/adst, 2=adst/dct, 3=adst/adst
59cabdff1aSopenharmony_ci     *
60cabdff1aSopenharmony_ci     * dst is aligned by transform-size (i.e. 4, 8, 16 or 32 pixels)
61cabdff1aSopenharmony_ci     * stride is aligned by 16 pixels
62cabdff1aSopenharmony_ci     * block is 16-byte aligned
63cabdff1aSopenharmony_ci     * eob indicates the position (+1) of the last non-zero coefficient,
64cabdff1aSopenharmony_ci     * in scan-order. This can be used to write faster versions, e.g. a
65cabdff1aSopenharmony_ci     * dc-only 4x4/8x8/16x16/32x32, or a 4x4-only (eob<10) 8x8/16x16/32x32,
66cabdff1aSopenharmony_ci     * etc.
67cabdff1aSopenharmony_ci     */
68cabdff1aSopenharmony_ci    // FIXME also write idct_add_block() versions for whole (inter) pred
69cabdff1aSopenharmony_ci    // blocks, so we can do 2 4x4s at once
70cabdff1aSopenharmony_ci    void (*itxfm_add[N_TXFM_SIZES + 1][N_TXFM_TYPES])(uint8_t *dst,
71cabdff1aSopenharmony_ci                                                      ptrdiff_t stride,
72cabdff1aSopenharmony_ci                                                      int16_t *block, int eob);
73cabdff1aSopenharmony_ci
74cabdff1aSopenharmony_ci    /*
75cabdff1aSopenharmony_ci     * dimension 1: width of filter (0=4, 1=8, 2=16)
76cabdff1aSopenharmony_ci     * dimension 2: 0=col-edge filter (h), 1=row-edge filter (v)
77cabdff1aSopenharmony_ci     *
78cabdff1aSopenharmony_ci     * dst/stride are aligned by 8
79cabdff1aSopenharmony_ci     */
80cabdff1aSopenharmony_ci    void (*loop_filter_8[3][2])(uint8_t *dst, ptrdiff_t stride,
81cabdff1aSopenharmony_ci                                int mb_lim, int lim, int hev_thr);
82cabdff1aSopenharmony_ci
83cabdff1aSopenharmony_ci    /*
84cabdff1aSopenharmony_ci     * dimension 1: 0=col-edge filter (h), 1=row-edge filter (v)
85cabdff1aSopenharmony_ci     *
86cabdff1aSopenharmony_ci     * The width of filter is assumed to be 16; dst/stride are aligned by 16
87cabdff1aSopenharmony_ci     */
88cabdff1aSopenharmony_ci    void (*loop_filter_16[2])(uint8_t *dst, ptrdiff_t stride,
89cabdff1aSopenharmony_ci                              int mb_lim, int lim, int hev_thr);
90cabdff1aSopenharmony_ci
91cabdff1aSopenharmony_ci    /*
92cabdff1aSopenharmony_ci     * dimension 1/2: width of filter (0=4, 1=8) for each filter half
93cabdff1aSopenharmony_ci     * dimension 3: 0=col-edge filter (h), 1=row-edge filter (v)
94cabdff1aSopenharmony_ci     *
95cabdff1aSopenharmony_ci     * dst/stride are aligned by operation size
96cabdff1aSopenharmony_ci     * this basically calls loop_filter[d1][d3][0](), followed by
97cabdff1aSopenharmony_ci     * loop_filter[d2][d3][0]() on the next 8 pixels
98cabdff1aSopenharmony_ci     * mb_lim/lim/hev_thr contain two values in the lowest two bytes of the
99cabdff1aSopenharmony_ci     * integer.
100cabdff1aSopenharmony_ci     */
101cabdff1aSopenharmony_ci    // FIXME perhaps a mix4 that operates on 32px (for AVX2)
102cabdff1aSopenharmony_ci    void (*loop_filter_mix2[2][2][2])(uint8_t *dst, ptrdiff_t stride,
103cabdff1aSopenharmony_ci                                      int mb_lim, int lim, int hev_thr);
104cabdff1aSopenharmony_ci
105cabdff1aSopenharmony_ci    /*
106cabdff1aSopenharmony_ci     * dimension 1: hsize (0: 64, 1: 32, 2: 16, 3: 8, 4: 4)
107cabdff1aSopenharmony_ci     * dimension 2: filter type (0: smooth, 1: regular, 2: sharp, 3: bilin)
108cabdff1aSopenharmony_ci     * dimension 3: averaging type (0: put, 1: avg)
109cabdff1aSopenharmony_ci     * dimension 4: x subpel interpolation (0: none, 1: 8tap/bilin)
110cabdff1aSopenharmony_ci     * dimension 5: y subpel interpolation (0: none, 1: 8tap/bilin)
111cabdff1aSopenharmony_ci     *
112cabdff1aSopenharmony_ci     * dst/stride are aligned by hsize
113cabdff1aSopenharmony_ci     */
114cabdff1aSopenharmony_ci    vp9_mc_func mc[5][N_FILTERS][2][2][2];
115cabdff1aSopenharmony_ci
116cabdff1aSopenharmony_ci    /*
117cabdff1aSopenharmony_ci     * for scalable MC, first 3 dimensions identical to above, the other two
118cabdff1aSopenharmony_ci     * don't exist since it changes per stepsize.
119cabdff1aSopenharmony_ci     */
120cabdff1aSopenharmony_ci    vp9_scaled_mc_func smc[5][N_FILTERS][2];
121cabdff1aSopenharmony_ci} VP9DSPContext;
122cabdff1aSopenharmony_ci
123cabdff1aSopenharmony_ciextern const int16_t ff_vp9_subpel_filters[3][16][8];
124cabdff1aSopenharmony_ci
125cabdff1aSopenharmony_civoid ff_vp9dsp_init(VP9DSPContext *dsp, int bpp, int bitexact);
126cabdff1aSopenharmony_ci
127cabdff1aSopenharmony_civoid ff_vp9dsp_init_8(VP9DSPContext *dsp);
128cabdff1aSopenharmony_civoid ff_vp9dsp_init_10(VP9DSPContext *dsp);
129cabdff1aSopenharmony_civoid ff_vp9dsp_init_12(VP9DSPContext *dsp);
130cabdff1aSopenharmony_ci
131cabdff1aSopenharmony_civoid ff_vp9dsp_init_aarch64(VP9DSPContext *dsp, int bpp);
132cabdff1aSopenharmony_civoid ff_vp9dsp_init_arm(VP9DSPContext *dsp, int bpp);
133cabdff1aSopenharmony_civoid ff_vp9dsp_init_x86(VP9DSPContext *dsp, int bpp, int bitexact);
134cabdff1aSopenharmony_civoid ff_vp9dsp_init_mips(VP9DSPContext *dsp, int bpp);
135cabdff1aSopenharmony_civoid ff_vp9dsp_init_loongarch(VP9DSPContext *dsp, int bpp);
136cabdff1aSopenharmony_ci
137cabdff1aSopenharmony_ci#endif /* AVCODEC_VP9DSP_H */
138