FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
vp9.c File Reference
#include "avcodec.h"
#include "get_bits.h"
#include "internal.h"
#include "videodsp.h"
#include "vp56.h"
#include "vp9.h"
#include "vp9data.h"
#include "vp9dsp.h"
#include "libavutil/avassert.h"

Go to the source code of this file.

Data Structures

struct  VP9mvrefPair
 
struct  VP9Filter
 
struct  VP9Block
 
struct  VP9Context
 

Macros

#define VP9_SYNCCODE   0x498342
 
#define assign(var, type, n)   var = (type) p; p += s->sb_cols * n * sizeof(*var)
 
#define INVALID_MV   0x80008000U
 
#define RETURN_DIRECT_MV(mv)
 
#define RETURN_MV(mv)
 
#define RETURN_SCALE_MV(mv, scale)
 
#define case_n(a, rd)
 

Enumerations

enum  CompPredMode { PRED_SINGLEREF, PRED_COMPREF, PRED_SWITCHABLE }
 
enum  BlockLevel { BL_64X64, BL_32X32, BL_16X16, BL_8X8 }
 
enum  BlockSize {
  BS_64x64, BS_64x32, BS_32x64, BS_32x32,
  BS_32x16, BS_16x32, BS_16x16, BS_16x8,
  BS_8x16, BS_8x8, BS_8x4, BS_4x8,
  BS_4x4, N_BS_SIZES
}
 

Functions

static int update_size (AVCodecContext *ctx, int w, int h)
 
static av_always_inline int get_sbits_inv (GetBitContext *gb, int n)
 
static av_always_inline int inv_recenter_nonneg (int v, int m)
 
static int update_prob (VP56RangeCoder *c, int p)
 
static int decode_frame_header (AVCodecContext *ctx, const uint8_t *data, int size, int *ref)
 
static av_always_inline void clamp_mv (VP56mv *dst, const VP56mv *src, VP9Context *s)
 
static void find_ref_mvs (VP9Context *s, VP56mv *pmv, int ref, int z, int idx, int sb)
 
static av_always_inline int read_mv_component (VP9Context *s, int idx, int hp)
 
static void fill_mv (VP9Context *s, VP56mv *mv, int mode, int sb)
 
static void decode_mode (AVCodecContext *ctx)
 
static int decode_coeffs_b (VP56RangeCoder *c, int16_t *coef, int n_coeffs, enum TxfmMode tx, unsigned(*cnt)[6][3], unsigned(*eob)[6][2], uint8_t(*p)[6][11], int nnz, const int16_t *scan, const int16_t(*nb)[2], const int16_t *band_counts, const int16_t *qmul)
 
static int decode_coeffs (AVCodecContext *ctx)
 
static av_always_inline int check_intra_mode (VP9Context *s, int mode, uint8_t **a, uint8_t *dst_edge, ptrdiff_t stride_edge, uint8_t *dst_inner, ptrdiff_t stride_inner, uint8_t *l, int col, int x, int w, int row, int y, enum TxfmMode tx, int p)
 
static void intra_recon (AVCodecContext *ctx, ptrdiff_t y_off, ptrdiff_t uv_off)
 
static av_always_inline void mc_luma_dir (VP9Context *s, vp9_mc_func(*mc)[2], uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *ref, ptrdiff_t ref_stride, ptrdiff_t y, ptrdiff_t x, const VP56mv *mv, int bw, int bh, int w, int h)
 
static av_always_inline void mc_chroma_dir (VP9Context *s, vp9_mc_func(*mc)[2], uint8_t *dst_u, uint8_t *dst_v, ptrdiff_t dst_stride, const uint8_t *ref_u, ptrdiff_t src_stride_u, const uint8_t *ref_v, ptrdiff_t src_stride_v, ptrdiff_t y, ptrdiff_t x, const VP56mv *mv, int bw, int bh, int w, int h)
 
static void inter_recon (AVCodecContext *ctx)
 
static av_always_inline void mask_edges (struct VP9Filter *lflvl, int is_uv, int row_and_7, int col_and_7, int w, int h, int col_end, int row_end, enum TxfmMode tx, int skip_inter)
 
static int decode_b (AVCodecContext *ctx, int row, int col, struct VP9Filter *lflvl, ptrdiff_t yoff, ptrdiff_t uvoff, enum BlockLevel bl, enum BlockPartition bp)
 
static int decode_sb (AVCodecContext *ctx, int row, int col, struct VP9Filter *lflvl, ptrdiff_t yoff, ptrdiff_t uvoff, enum BlockLevel bl)
 
static void loopfilter_sb (AVCodecContext *ctx, struct VP9Filter *lflvl, int row, int col, ptrdiff_t yoff, ptrdiff_t uvoff)
 
static void set_tile_offset (int *start, int *end, int idx, int log2_n, int n)
 
static av_always_inline void adapt_prob (uint8_t *p, unsigned ct0, unsigned ct1, int max_count, int update_factor)
 
static void adapt_probs (VP9Context *s)
 
static int vp9_decode_frame (AVCodecContext *ctx, void *out_pic, int *got_frame, const uint8_t *data, int size)
 
static int vp9_decode_packet (AVCodecContext *avctx, void *out_pic, int *got_frame, AVPacket *avpkt)
 
static void vp9_decode_flush (AVCodecContext *ctx)
 
static av_cold int vp9_decode_init (AVCodecContext *ctx)
 
static av_cold int vp9_decode_free (AVCodecContext *ctx)
 

Variables

static const uint8_t bwh_tab [2][N_BS_SIZES][2]
 
AVCodec ff_vp9_decoder
 

Macro Definition Documentation

#define VP9_SYNCCODE   0x498342

Definition at line 34 of file vp9.c.

Referenced by decode_frame_header().

#define assign (   var,
  type,
  n 
)    var = (type) p; p += s->sb_cols * n * sizeof(*var)

Referenced by update_size().

#define INVALID_MV   0x80008000U

Referenced by find_ref_mvs().

#define RETURN_DIRECT_MV (   mv)
Value:
do { \
uint32_t m = AV_RN32A(&mv); \
if (!idx) { \
AV_WN32A(pmv, m); \
return; \
} else if (mem == INVALID_MV) { \
mem = m; \
} else if (m != mem) { \
AV_WN32A(pmv, m); \
return; \
} \
} while (0)

Referenced by find_ref_mvs().

#define RETURN_MV (   mv)
Value:
do { \
if (sb > 0) { \
VP56mv tmp; \
uint32_t m; \
clamp_mv(&tmp, &mv, s); \
m = AV_RN32A(&tmp); \
if (!idx) { \
AV_WN32A(pmv, m); \
return; \
} else if (mem == INVALID_MV) { \
mem = m; \
} else if (m != mem) { \
AV_WN32A(pmv, m); \
return; \
} \
} else { \
uint32_t m = AV_RN32A(&mv); \
if (!idx) { \
clamp_mv(pmv, &mv, s); \
return; \
} else if (mem == INVALID_MV) { \
mem = m; \
} else if (m != mem) { \
clamp_mv(pmv, &mv, s); \
return; \
} \
} \
} while (0)

Referenced by find_ref_mvs().

#define RETURN_SCALE_MV (   mv,
  scale 
)
Value:
do { \
if (scale) { \
VP56mv mv_temp = { -mv.x, -mv.y }; \
RETURN_MV(mv_temp); \
} else { \
RETURN_MV(mv); \
} \
} while (0)

Referenced by find_ref_mvs().

#define case_n (   a,
  rd 
)
Value:
case a: \
while (n_frames--) { \
int sz = rd; \
idx += a; \
if (sz > size) { \
av_log(avctx, AV_LOG_ERROR, \
"Superframe packet size too big: %d > %d\n", \
sz, size); \
} \
res = vp9_decode_frame(avctx, out_pic, got_frame, \
data, sz); \
if (res < 0) \
return res; \
data += sz; \
size -= sz; \
} \
break;

Referenced by vp9_decode_packet().

Enumeration Type Documentation

Enumerator:
PRED_SINGLEREF 
PRED_COMPREF 
PRED_SWITCHABLE 

Definition at line 36 of file vp9.c.

enum BlockLevel
Enumerator:
BL_64X64 
BL_32X32 
BL_16X16 
BL_8X8 

Definition at line 42 of file vp9.c.

enum BlockSize
Enumerator:
BS_64x64 
BS_64x32 
BS_32x64 
BS_32x32 
BS_32x16 
BS_16x32 
BS_16x16 
BS_16x8 
BS_8x16 
BS_8x8 
BS_8x4 
BS_4x8 
BS_4x4 
N_BS_SIZES 

Definition at line 49 of file vp9.c.

Function Documentation

static int update_size ( AVCodecContext ctx,
int  w,
int  h 
)
static

Definition at line 241 of file vp9.c.

Referenced by decode_frame_header().

static av_always_inline int get_sbits_inv ( GetBitContext gb,
int  n 
)
static

Definition at line 288 of file vp9.c.

Referenced by decode_frame_header().

static av_always_inline int inv_recenter_nonneg ( int  v,
int  m 
)
static

Definition at line 294 of file vp9.c.

Referenced by update_prob().

static int update_prob ( VP56RangeCoder c,
int  p 
)
static

Definition at line 300 of file vp9.c.

Referenced by decode_frame_header().

static int decode_frame_header ( AVCodecContext ctx,
const uint8_t data,
int  size,
int *  ref 
)
static

Definition at line 357 of file vp9.c.

Referenced by vp9_decode_frame().

static av_always_inline void clamp_mv ( VP56mv dst,
const VP56mv src,
VP9Context s 
)
static

Definition at line 822 of file vp9.c.

static void find_ref_mvs ( VP9Context s,
VP56mv pmv,
int  ref,
int  z,
int  idx,
int  sb 
)
static

Definition at line 829 of file vp9.c.

Referenced by fill_mv().

static av_always_inline int read_mv_component ( VP9Context s,
int  idx,
int  hp 
)
static

Definition at line 1011 of file vp9.c.

Referenced by fill_mv().

static void fill_mv ( VP9Context s,
VP56mv mv,
int  mode,
int  sb 
)
static

Definition at line 1064 of file vp9.c.

Referenced by decode_mode().

static void decode_mode ( AVCodecContext ctx)
static

Definition at line 1137 of file vp9.c.

Referenced by decode_b().

static int decode_coeffs_b ( VP56RangeCoder c,
int16_t *  coef,
int  n_coeffs,
enum TxfmMode  tx,
unsigned(*)  cnt[6][3],
unsigned(*)  eob[6][2],
uint8_t(*)  p[6][11],
int  nnz,
const int16_t *  scan,
const int16_t(*)  nb[2],
const int16_t *  band_counts,
const int16_t *  qmul 
)
static

Definition at line 1785 of file vp9.c.

Referenced by decode_coeffs().

static int decode_coeffs ( AVCodecContext ctx)
static

Definition at line 1892 of file vp9.c.

Referenced by decode_b().

static av_always_inline int check_intra_mode ( VP9Context s,
int  mode,
uint8_t **  a,
uint8_t dst_edge,
ptrdiff_t  stride_edge,
uint8_t dst_inner,
ptrdiff_t  stride_inner,
uint8_t l,
int  col,
int  x,
int  w,
int  row,
int  y,
enum TxfmMode  tx,
int  p 
)
static

Definition at line 2001 of file vp9.c.

Referenced by intra_recon().

static void intra_recon ( AVCodecContext ctx,
ptrdiff_t  y_off,
ptrdiff_t  uv_off 
)
static

Definition at line 2136 of file vp9.c.

Referenced by decode_b().

static av_always_inline void mc_luma_dir ( VP9Context s,
vp9_mc_func(*)  mc[2],
uint8_t dst,
ptrdiff_t  dst_stride,
const uint8_t ref,
ptrdiff_t  ref_stride,
ptrdiff_t  y,
ptrdiff_t  x,
const VP56mv mv,
int  bw,
int  bh,
int  w,
int  h 
)
static

Definition at line 2204 of file vp9.c.

Referenced by inter_recon().

static av_always_inline void mc_chroma_dir ( VP9Context s,
vp9_mc_func(*)  mc[2],
uint8_t dst_u,
uint8_t dst_v,
ptrdiff_t  dst_stride,
const uint8_t ref_u,
ptrdiff_t  src_stride_u,
const uint8_t ref_v,
ptrdiff_t  src_stride_v,
ptrdiff_t  y,
ptrdiff_t  x,
const VP56mv mv,
int  bw,
int  bh,
int  w,
int  h 
)
static

Definition at line 2231 of file vp9.c.

Referenced by inter_recon().

static void inter_recon ( AVCodecContext ctx)
static

Definition at line 2269 of file vp9.c.

Referenced by decode_b().

static av_always_inline void mask_edges ( struct VP9Filter lflvl,
int  is_uv,
int  row_and_7,
int  col_and_7,
int  w,
int  h,
int  col_end,
int  row_end,
enum TxfmMode  tx,
int  skip_inter 
)
static

Definition at line 2453 of file vp9.c.

Referenced by decode_b().

static int decode_b ( AVCodecContext ctx,
int  row,
int  col,
struct VP9Filter lflvl,
ptrdiff_t  yoff,
ptrdiff_t  uvoff,
enum BlockLevel  bl,
enum BlockPartition  bp 
)
static

Definition at line 2586 of file vp9.c.

Referenced by decode_sb().

static int decode_sb ( AVCodecContext ctx,
int  row,
int  col,
struct VP9Filter lflvl,
ptrdiff_t  yoff,
ptrdiff_t  uvoff,
enum BlockLevel  bl 
)
static

Definition at line 2714 of file vp9.c.

Referenced by vp9_decode_frame().

static void loopfilter_sb ( AVCodecContext ctx,
struct VP9Filter lflvl,
int  row,
int  col,
ptrdiff_t  yoff,
ptrdiff_t  uvoff 
)
static

Definition at line 2794 of file vp9.c.

Referenced by vp9_decode_frame().

static void set_tile_offset ( int *  start,
int *  end,
int  idx,
int  log2_n,
int  n 
)
static

Definition at line 3030 of file vp9.c.

Referenced by vp9_decode_frame().

static av_always_inline void adapt_prob ( uint8_t p,
unsigned  ct0,
unsigned  ct1,
int  max_count,
int  update_factor 
)
static

Definition at line 3038 of file vp9.c.

Referenced by adapt_probs().

static void adapt_probs ( VP9Context s)
static

Definition at line 3056 of file vp9.c.

Referenced by vp9_decode_frame().

static int vp9_decode_frame ( AVCodecContext ctx,
void out_pic,
int *  got_frame,
const uint8_t data,
int  size 
)
static

Definition at line 3278 of file vp9.c.

Referenced by vp9_decode_packet().

static int vp9_decode_packet ( AVCodecContext avctx,
void out_pic,
int *  got_frame,
AVPacket avpkt 
)
static

Definition at line 3457 of file vp9.c.

static void vp9_decode_flush ( AVCodecContext ctx)
static

Definition at line 3508 of file vp9.c.

static av_cold int vp9_decode_init ( AVCodecContext ctx)
static

Definition at line 3521 of file vp9.c.

static av_cold int vp9_decode_free ( AVCodecContext ctx)
static

Definition at line 3541 of file vp9.c.

Variable Documentation

const uint8_t bwh_tab[2][N_BS_SIZES][2]
static
Initial value:
= {
{
{ 16, 16 }, { 16, 8 }, { 8, 16 }, { 8, 8 }, { 8, 4 }, { 4, 8 },
{ 4, 4 }, { 4, 2 }, { 2, 4 }, { 2, 2 }, { 2, 1 }, { 1, 2 }, { 1, 1 },
}, {
{ 8, 8 }, { 8, 4 }, { 4, 8 }, { 4, 4 }, { 4, 2 }, { 2, 4 },
{ 2, 2 }, { 2, 1 }, { 1, 2 }, { 1, 1 }, { 1, 1 }, { 1, 1 }, { 1, 1 },
}
}

Definition at line 231 of file vp9.c.

Referenced by decode_b(), decode_coeffs(), decode_mode(), inter_recon(), and intra_recon().

AVCodec ff_vp9_decoder
Initial value:
= {
.name = "vp9",
.long_name = NULL_IF_CONFIG_SMALL("Google VP9"),
.priv_data_size = sizeof(VP9Context),
.capabilities = CODEC_CAP_DR1,
}

Definition at line 3567 of file vp9.c.