FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vp9dec.h
Go to the documentation of this file.
1 /*
2  * VP9 compatible video decoder
3  *
4  * Copyright (C) 2013 Ronald S. Bultje <rsbultje gmail com>
5  * Copyright (C) 2013 Clément Bœsch <u pkh me>
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * FFmpeg is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 #ifndef AVCODEC_VP9DEC_H
25 #define AVCODEC_VP9DEC_H
26 
27 #include <stddef.h>
28 #include <stdint.h>
29 
30 #include "libavutil/buffer.h"
31 #include "libavutil/internal.h"
32 
33 #include "vp9.h"
34 #include "vp9dsp.h"
35 #include "vp9shared.h"
36 
37 enum MVJoint {
42 };
43 
44 typedef struct ProbContext {
45  uint8_t y_mode[4][9];
46  uint8_t uv_mode[10][9];
47  uint8_t filter[4][2];
53  uint8_t tx32p[2][3];
54  uint8_t tx16p[2][2];
58  struct {
64  uint8_t fp[3];
67  } mv_comp[2];
68  uint8_t partition[4][4][3];
69 } ProbContext;
70 
71 typedef struct VP9Filter {
72  uint8_t level[8 * 8];
73  uint8_t /* bit=col */ mask[2 /* 0=y, 1=uv */][2 /* 0=col, 1=row */]
74  [8 /* rows */][4 /* 0=16, 1=8, 2=4, 3=inner4 */];
75 } VP9Filter;
76 
77 typedef struct VP9Block {
80  VP56mv mv[4 /* b_idx */][2 /* ref */];
81  enum BlockSize bs;
82  enum TxfmMode tx, uvtx;
83  enum BlockLevel bl;
85 } VP9Block;
86 
87 typedef struct VP9Context {
89 
95  unsigned c_b_size;
97  int pass;
98  int row, row7, col, col7;
99  uint8_t *dst[3];
100  ptrdiff_t y_stride, uv_stride;
101 
105  // sb_cols/rows, rows/cols and last_fmt are used for allocating all internal
106  // arrays, and are thus per-thread. w/h and gf_fmt are synced between threads
107  // and are therefore per-stream. pix_fmt represents the value in the header
108  // of the currently processed frame.
109  int w, h;
110  enum AVPixelFormat pix_fmt, last_fmt, gf_fmt;
111  unsigned sb_cols, sb_rows, rows, cols;
113 
114  struct {
117  } filter_lut;
119  struct {
121  uint8_t coef[4][2][2][6][6][3];
122  } prob_ctx[4];
123  struct {
124  ProbContext p;
125  uint8_t coef[4][2][2][6][6][11];
126  } prob;
127  struct {
128  unsigned y_mode[4][10];
129  unsigned uv_mode[10][10];
130  unsigned filter[4][3];
131  unsigned mv_mode[7][4];
132  unsigned intra[4][2];
133  unsigned comp[5][2];
134  unsigned single_ref[5][2][2];
135  unsigned comp_ref[5][2];
136  unsigned tx32p[2][4];
137  unsigned tx16p[2][3];
138  unsigned tx8p[2][2];
139  unsigned skip[3][2];
140  unsigned mv_joint[4];
141  struct {
142  unsigned sign[2];
143  unsigned classes[11];
144  unsigned class0[2];
145  unsigned bits[10][2];
146  unsigned class0_fp[2][4];
147  unsigned fp[4];
148  unsigned class0_hp[2];
149  unsigned hp[2];
150  } mv_comp[2];
151  unsigned partition[4][4][4];
152  unsigned coef[4][2][2][6][6][3];
153  unsigned eob[4][2][2][6][6][2];
154  } counts;
155 
156  // contextual (left/above) cache
171  // FIXME maybe merge some of the below in a flags field?
182 
183  // whole-frame cache
187 
188  // block reconstruction intermediates
190  int16_t *block_base, *block, *uvblock_base[2], *uvblock[2];
192  struct { int x, y; } min_mv, max_mv;
193  DECLARE_ALIGNED(32, uint8_t, tmp_y)[64 * 64 * 2];
194  DECLARE_ALIGNED(32, uint8_t, tmp_uv)[2][64 * 64 * 2];
195  uint16_t mvscale[3][2];
197 } VP9Context;
198 
199 void ff_vp9_fill_mv(VP9Context *s, VP56mv *mv, int mode, int sb);
200 
202 
203 void ff_vp9_decode_block(AVCodecContext *ctx, int row, int col,
204  VP9Filter *lflvl, ptrdiff_t yoff, ptrdiff_t uvoff,
205  enum BlockLevel bl, enum BlockPartition bp);
206 
207 void ff_vp9_loopfilter_sb(AVCodecContext *avctx, VP9Filter *lflvl,
208  int row, int col, ptrdiff_t yoff, ptrdiff_t uvoff);
209 
211  ptrdiff_t y_off, ptrdiff_t uv_off);
213  ptrdiff_t y_off, ptrdiff_t uv_off);
216 
217 #endif /* AVCODEC_VP9DEC_H */
unsigned hp[2]
Definition: vp9dec.h:149
const char * s
Definition: avisynth_c.h:768
static enum AVPixelFormat pix_fmt
unsigned comp_ref[5][2]
Definition: vp9dec.h:135
uint8_t mblim_lut[64]
Definition: vp9dec.h:116
uint8_t left_segpred_ctx[8]
Definition: vp9dec.h:164
uint8_t * above_skip_ctx
Definition: vp9dec.h:174
uint8_t * eob_base
Definition: vp9dec.h:191
uint8_t mvstep[3][2]
Definition: vp9dec.h:196
int row
Definition: vp9dec.h:98
VideoDSPContext vdsp
Definition: vp9dec.h:91
ProbContext p
Definition: vp9dec.h:120
uint8_t last_keyframe
Definition: vp9dec.h:104
uint8_t ss_v
Definition: vp9dec.h:102
struct ProbContext::@145 mv_comp[2]
uint8_t tx32p[2][3]
Definition: vp9dec.h:53
unsigned skip[3][2]
Definition: vp9dec.h:139
uint8_t left_uv_nnz_ctx[2][16]
Definition: vp9dec.h:160
VP9Filter * lflvl
Definition: vp9dec.h:185
unsigned cols
Definition: vp9dec.h:111
unsigned tile_col_end
Definition: vp9dec.h:118
uint8_t ref[2]
Definition: vp9dec.h:78
uint8_t comp_ref[5]
Definition: vp9dec.h:52
unsigned fp[4]
Definition: vp9dec.h:147
uint8_t * intra_pred_data[3]
Definition: vp9dec.h:184
int y
Definition: vp9dec.h:192
unsigned uv_mode[10][10]
Definition: vp9dec.h:129
void ff_vp9_inter_recon_8bpp(AVCodecContext *avctx)
Definition: vp9recon.c:631
uint8_t coef[4][2][2][6][6][3]
Definition: vp9dec.h:121
uint8_t
unsigned y_mode[4][10]
Definition: vp9dec.h:128
void ff_vp9_adapt_probs(VP9Context *s)
Definition: vp9prob.c:46
uint8_t * uveob_base[2]
Definition: vp9dec.h:191
int col
Definition: vp9dec.h:98
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
Definition: mem.h:104
uint8_t skip[3]
Definition: vp9dec.h:56
uint8_t * above_uv_nnz_ctx[2]
Definition: vp9dec.h:173
VP9DSPContext dsp
Definition: vp9dec.h:90
uint8_t lim_lut[64]
Definition: vp9dec.h:115
unsigned sign[2]
Definition: vp9dec.h:142
uint16_t mvscale[3][2]
Definition: vp9dec.h:195
uint8_t left_ref_ctx[8]
Definition: vp9dec.h:167
int x
Definition: vp9dec.h:192
uint8_t * above_txfm_ctx
Definition: vp9dec.h:175
int h
Definition: vp9dec.h:109
int16_t * block
Definition: vp9dec.h:190
uint8_t uv_mode[10][9]
Definition: vp9dec.h:46
uint8_t bytesperpixel
Definition: vp9dec.h:103
void ff_vp9_loopfilter_sb(AVCodecContext *avctx, VP9Filter *lflvl, int row, int col, ptrdiff_t yoff, ptrdiff_t uvoff)
Definition: vp9lpf.c:178
uint8_t mask[2][2][8][4]
Definition: vp9dec.h:74
int16_t * uvblock[2]
Definition: vp9dec.h:190
uint8_t partition[4][4][3]
Definition: vp9dec.h:68
uint8_t hp
Definition: vp9dec.h:66
uint8_t sign
Definition: vp9dec.h:59
void ff_vp9_intra_recon_8bpp(AVCodecContext *avctx, ptrdiff_t y_off, ptrdiff_t uv_off)
Definition: vp9recon.c:287
unsigned mv_mode[7][4]
Definition: vp9dec.h:131
uint8_t left_partition_ctx[8]
Definition: vp9dec.h:161
GetBitContext gb
Definition: vp9dec.h:92
uint8_t fp[3]
Definition: vp9dec.h:64
ptrdiff_t uv_stride
Definition: vp9dec.h:100
unsigned mv_joint[4]
Definition: vp9dec.h:140
unsigned tile_row_start
Definition: vp9dec.h:118
uint8_t bpp_index
Definition: vp9dec.h:103
uint8_t intra
Definition: vp9dec.h:78
TxfmMode
Definition: vp9.h:27
uint8_t intra[4]
Definition: vp9dec.h:49
unsigned comp[5][2]
Definition: vp9dec.h:133
unsigned tx8p[2][2]
Definition: vp9dec.h:138
int16_t * uvblock_base[2]
Definition: vp9dec.h:190
uint8_t * above_filter_ctx
Definition: vp9dec.h:180
struct VP9Context::@149::@151 mv_comp[2]
void ff_vp9_inter_recon_16bpp(AVCodecContext *avctx)
Definition: vp9recon.c:636
common internal API header
uint8_t comp[5]
Definition: vp9dec.h:50
unsigned c_b_size
Definition: vp9dec.h:95
unsigned class0_fp[2][4]
Definition: vp9dec.h:146
VP56mv left_mv_ctx[16][2]
Definition: vp9dec.h:159
uint8_t left_y_nnz_ctx[16]
Definition: vp9dec.h:157
BlockSize
Definition: vp9shared.h:77
uint8_t level[8 *8]
Definition: vp9dec.h:72
int col7
Definition: vp9dec.h:98
uint8_t left_mode_ctx[16]
Definition: vp9dec.h:158
unsigned eob[4][2][2][6][6][2]
Definition: vp9dec.h:153
uint8_t tx16p[2][2]
Definition: vp9dec.h:54
unsigned tx32p[2][4]
Definition: vp9dec.h:136
unsigned tx16p[2][3]
Definition: vp9dec.h:137
AVFormatContext * ctx
Definition: movenc.c:48
uint8_t class0_hp
Definition: vp9dec.h:65
VP9SharedContext s
Definition: vp9dec.h:88
uint8_t uvmode
Definition: vp9dec.h:78
uint8_t * above_partition_ctx
Definition: vp9dec.h:169
uint8_t tmp_y[64 *64 *2]
Definition: vp9dec.h:193
uint8_t left_comp_ctx[8]
Definition: vp9dec.h:166
uint8_t mv_mode[7][3]
Definition: vp9dec.h:48
MVJoint
Definition: vp9dec.h:37
uint8_t * above_segpred_ctx
Definition: vp9dec.h:176
void ff_vp9_intra_recon_16bpp(AVCodecContext *avctx, ptrdiff_t y_off, ptrdiff_t uv_off)
Definition: vp9recon.c:292
unsigned tile_col_start
Definition: vp9dec.h:118
unsigned intra[4][2]
Definition: vp9dec.h:132
unsigned rows
Definition: vp9dec.h:111
unsigned sb_cols
Definition: vp9dec.h:111
static const int8_t mv[256][2]
Definition: 4xm.c:77
int row7
Definition: vp9dec.h:98
FilterMode
Definition: vp9.h:64
void ff_vp9_decode_block(AVCodecContext *ctx, int row, int col, VP9Filter *lflvl, ptrdiff_t yoff, ptrdiff_t uvoff, enum BlockLevel bl, enum BlockPartition bp)
Definition: vp9block.c:1267
unsigned class0[2]
Definition: vp9dec.h:144
VP56mv(* above_mv_ctx)[2]
Definition: vp9dec.h:181
int16_t * block_base
Definition: vp9dec.h:190
BlockLevel
Definition: vp9shared.h:70
uint8_t filter[4][2]
Definition: vp9dec.h:47
uint8_t class0_fp[2][3]
Definition: vp9dec.h:63
int pass
Definition: vp9dec.h:97
uint8_t left_skip_ctx[8]
Definition: vp9dec.h:162
main external API structure.
Definition: avcodec.h:1732
uint8_t left_txfm_ctx[8]
Definition: vp9dec.h:163
void ff_vp9_fill_mv(VP9Context *s, VP56mv *mv, int mode, int sb)
Definition: vp9mvs.c:289
VP56RangeCoder * c_b
Definition: vp9dec.h:94
enum TxfmMode tx uvtx
Definition: vp9dec.h:82
unsigned single_ref[5][2][2]
Definition: vp9dec.h:134
unsigned partition[4][4][4]
Definition: vp9dec.h:151
uint8_t * above_y_nnz_ctx
Definition: vp9dec.h:172
struct VP9Context::@147 prob_ctx[4]
uint8_t tx8p[2]
Definition: vp9dec.h:55
uint8_t seg_id
Definition: vp9dec.h:78
uint8_t ss_h
Definition: vp9dec.h:102
uint8_t y_mode[4][9]
Definition: vp9dec.h:45
refcounted data buffer API
uint8_t left_filter_ctx[8]
Definition: vp9dec.h:168
uint8_t last_bpp
Definition: vp9dec.h:103
uint8_t * above_intra_ctx
Definition: vp9dec.h:177
enum BlockSize bs
Definition: vp9dec.h:81
uint8_t * dst[3]
Definition: vp9dec.h:99
VP56mv mv[4][2]
Definition: vp9dec.h:80
enum BlockPartition bp
Definition: vp9dec.h:84
VP9Block * b
Definition: vp9dec.h:96
uint8_t * uveob[2]
Definition: vp9dec.h:191
uint8_t * above_mode_ctx
Definition: vp9dec.h:170
uint8_t single_ref[5][2]
Definition: vp9dec.h:51
Definition: vp56.h:66
uint8_t comp
Definition: vp9dec.h:78
uint8_t bits[10]
Definition: vp9dec.h:62
ThreadFrame next_refs[8]
Definition: vp9dec.h:112
unsigned class0_hp[2]
Definition: vp9dec.h:148
unsigned filter[4][3]
Definition: vp9dec.h:130
int w
Definition: vp9dec.h:109
uint8_t tmp_uv[2][64 *64 *2]
Definition: vp9dec.h:194
enum AVPixelFormat pix_fmt last_fmt gf_fmt
Definition: vp9dec.h:110
unsigned sb_rows
Definition: vp9dec.h:111
struct VP9Context::@148 prob
struct VP9Context::@149 counts
uint8_t mv_joint[3]
Definition: vp9dec.h:57
enum BlockLevel bl
Definition: vp9dec.h:83
unsigned bits[10][2]
Definition: vp9dec.h:145
struct VP9Context::@146 filter_lut
uint8_t class0
Definition: vp9dec.h:61
unsigned tile_row_end
Definition: vp9dec.h:118
enum FilterMode filter
Definition: vp9dec.h:79
uint8_t edge_emu_buffer[135 *144 *2]
Definition: vp9dec.h:186
VP9Block * b_base
Definition: vp9dec.h:96
struct VP9Context::@150 min_mv
ptrdiff_t y_stride
Definition: vp9dec.h:100
uint8_t skip
Definition: vp9dec.h:78
uint8_t * above_ref_ctx
Definition: vp9dec.h:179
BlockPartition
Definition: vp9shared.h:34
struct VP9Context::@150 max_mv
uint8_t left_intra_ctx[8]
Definition: vp9dec.h:165
unsigned classes[11]
Definition: vp9dec.h:143
uint8_t classes[10]
Definition: vp9dec.h:60
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
mode
Use these values in ebur128_init (or'ed).
Definition: ebur128.h:83
uint8_t * above_comp_ctx
Definition: vp9dec.h:178
int block_alloc_using_2pass
Definition: vp9dec.h:189
VP56RangeCoder c
Definition: vp9dec.h:93