FFmpeg
Macros | Functions
vp9block.c File Reference
#include "libavutil/avassert.h"
#include "threadframe.h"
#include "vp89_rac.h"
#include "vp9.h"
#include "vp9data.h"
#include "vp9dec.h"
#include "vpx_rac.h"

Go to the source code of this file.

Macros

#define SPLAT_CTX(var, val, n)
 
#define SET_CTXS(perf, dir, off, n)
 
#define STORE_COEF(c, i, v)
 
#define MERGE(la, end, step, rd)
 
#define MERGE_CTX(step, rd)
 
#define DECODE_Y_COEF_LOOP(step, mode_index, v)
 
#define SPLAT(la, end, step, cond)
 
#define SPLAT_CTX(step)
 
#define DECODE_UV_COEF_LOOP(step, v)
 
#define SPLAT_ZERO_CTX(v, n)
 
#define SPLAT_ZERO_YUV(dir, var, off, n, dir2)
 

Functions

static av_always_inline void setctx_2d (uint8_t *ptr, int w, int h, ptrdiff_t stride, int v)
 
static void decode_mode (VP9TileData *td)
 
static av_always_inline int decode_coeffs_b_generic (VPXRangeCoder *c, int16_t *coef, int n_coeffs, int is_tx32x32, int is8bitsperpixel, int bpp, unsigned(*cnt)[6][3], unsigned(*eob)[6][2], const 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_b_8bpp (VP9TileData *td, int16_t *coef, int n_coeffs, unsigned(*cnt)[6][3], unsigned(*eob)[6][2], const 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_b32_8bpp (VP9TileData *td, int16_t *coef, int n_coeffs, unsigned(*cnt)[6][3], unsigned(*eob)[6][2], const 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_b_16bpp (VP9TileData *td, int16_t *coef, int n_coeffs, unsigned(*cnt)[6][3], unsigned(*eob)[6][2], const 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_b32_16bpp (VP9TileData *td, int16_t *coef, int n_coeffs, unsigned(*cnt)[6][3], unsigned(*eob)[6][2], const 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 av_always_inline int decode_coeffs (VP9TileData *td, int is8bitsperpixel)
 
static int decode_coeffs_8bpp (VP9TileData *td)
 
static int decode_coeffs_16bpp (VP9TileData *td)
 
static av_always_inline void mask_edges (uint8_t(*mask)[8][4], int ss_h, int ss_v, int row_and_7, int col_and_7, int w, int h, int col_end, int row_end, enum TxfmMode tx, int skip_inter)
 
void ff_vp9_decode_block (VP9TileData *td, int row, int col, VP9Filter *lflvl, ptrdiff_t yoff, ptrdiff_t uvoff, enum BlockLevel bl, enum BlockPartition bp)
 

Macro Definition Documentation

◆ SPLAT_CTX [1/2]

#define SPLAT_CTX (   var,
  val,
 
)
Value:
switch (n) { \
case 1: var = val; break; \
case 2: AV_WN16A(&var, val * 0x0101); break; \
case 4: AV_WN32A(&var, val * 0x01010101); break; \
case 8: { \
uint32_t v32 = val * 0x01010101; \
AV_WN32A( &var, v32); \
AV_WN32A(&((uint8_t *) &var)[4], v32); \
break; \
} \
case 16: { \
uint32_t v32 = val * 0x01010101; \
AV_WN32A( &var, v32); \
AV_WN32A(&((uint8_t *) &var)[4], v32); \
AV_WN32A(&((uint8_t *) &var)[8], v32); \
AV_WN32A(&((uint8_t *) &var)[12], v32); \
break; \
} \
}

◆ SET_CTXS

#define SET_CTXS (   perf,
  dir,
  off,
 
)
Value:
do { \
SPLAT_CTX(perf->dir##_skip_ctx[off], b->skip, n); \
SPLAT_CTX(perf->dir##_txfm_ctx[off], b->tx, n); \
SPLAT_CTX(perf->dir##_partition_ctx[off], dir##_ctx[b->bs], n); \
if (!s->s.h.keyframe && !s->s.h.intraonly) { \
SPLAT_CTX(perf->dir##_intra_ctx[off], b->intra, n); \
SPLAT_CTX(perf->dir##_comp_ctx[off], b->comp, n); \
SPLAT_CTX(perf->dir##_mode_ctx[off], b->mode[3], n); \
if (!b->intra) { \
SPLAT_CTX(perf->dir##_ref_ctx[off], vref, n); \
if (s->s.h.filtermode == FILTER_SWITCHABLE) { \
SPLAT_CTX(perf->dir##_filter_ctx[off], filter_id, n); \
} \
} \
} \
} while (0)

◆ STORE_COEF

#define STORE_COEF (   c,
  i,
 
)
Value:
do { \
if (is8bitsperpixel) { \
c[i] = v; \
} else { \
AV_WN32A(&c[i * 2], v); \
} \
} while (0)

◆ MERGE

#define MERGE (   la,
  end,
  step,
  rd 
)
Value:
for (n = 0; n < end; n += step) \
la[n] = !!rd(&la[n])

◆ MERGE_CTX

#define MERGE_CTX (   step,
  rd 
)
Value:
do { \
MERGE(l, end_y, step, rd); \
MERGE(a, end_x, step, rd); \
} while (0)

◆ DECODE_Y_COEF_LOOP

#define DECODE_Y_COEF_LOOP (   step,
  mode_index,
 
)
Value:
for (n = 0, y = 0; y < end_y; y += step) { \
for (x = 0; x < end_x; x += step, n += step * step) { \
enum TxfmType txtp = ff_vp9_intra_txfm_type[b->mode[mode_index]]; \
ret = (is8bitsperpixel ? decode_coeffs_b##v##_8bpp : decode_coeffs_b##v##_16bpp) \
(td, td->block + 16 * n * bytesperpixel, 16 * step * step, \
c, e, p, a[x] + l[y], yscans[txtp], \
ynbs[txtp], y_band_counts, qmul[0]); \
a[x] = l[y] = !!ret; \
total_coeff |= !!ret; \
if (step >= 4) { \
AV_WN16A(&td->eob[n], ret); \
} else { \
td->eob[n] = ret; \
} \
} \
}

◆ SPLAT

#define SPLAT (   la,
  end,
  step,
  cond 
)
Value:
if (step == 2) { \
for (n = 1; n < end; n += step) \
la[n] = la[n - 1]; \
} else if (step == 4) { \
if (cond) { \
for (n = 0; n < end; n += step) \
AV_WN32A(&la[n], la[n] * 0x01010101); \
} else { \
for (n = 0; n < end; n += step) \
memset(&la[n + 1], la[n], FFMIN(end - n - 1, 3)); \
} \
} else /* step == 8 */ { \
if (cond) { \
if (HAVE_FAST_64BIT) { \
for (n = 0; n < end; n += step) \
AV_WN64A(&la[n], la[n] * 0x0101010101010101ULL); \
} else { \
for (n = 0; n < end; n += step) { \
uint32_t v32 = la[n] * 0x01010101; \
AV_WN32A(&la[n], v32); \
AV_WN32A(&la[n + 4], v32); \
} \
} \
} else { \
for (n = 0; n < end; n += step) \
memset(&la[n + 1], la[n], FFMIN(end - n - 1, 7)); \
} \
}

◆ SPLAT_CTX [2/2]

#define SPLAT_CTX (   step)
Value:
do { \
SPLAT(a, end_x, step, end_x == w4); \
SPLAT(l, end_y, step, end_y == h4); \
} while (0)

◆ DECODE_UV_COEF_LOOP

#define DECODE_UV_COEF_LOOP (   step,
 
)
Value:
for (n = 0, y = 0; y < end_y; y += step) { \
for (x = 0; x < end_x; x += step, n += step * step) { \
ret = (is8bitsperpixel ? decode_coeffs_b##v##_8bpp : decode_coeffs_b##v##_16bpp) \
(td, td->uvblock[pl] + 16 * n * bytesperpixel, \
16 * step * step, c, e, p, a[x] + l[y], \
uvscan, uvnb, uv_band_counts, qmul[1]); \
a[x] = l[y] = !!ret; \
total_coeff |= !!ret; \
if (step >= 4) { \
AV_WN16A(&td->uveob[pl][n], ret); \
} else { \
td->uveob[pl][n] = ret; \
} \
} \
}

◆ SPLAT_ZERO_CTX

#define SPLAT_ZERO_CTX (   v,
 
)
Value:
switch (n) { \
case 1: v = 0; break; \
case 2: AV_ZERO16(&v); break; \
case 4: AV_ZERO32(&v); break; \
case 8: AV_ZERO64(&v); break; \
case 16: AV_ZERO128(&v); break; \
}

◆ SPLAT_ZERO_YUV

#define SPLAT_ZERO_YUV (   dir,
  var,
  off,
  n,
  dir2 
)
Value:
do { \
SPLAT_ZERO_CTX(dir##_y_##var[off * 2], n * 2); \
if (s->ss_##dir2) { \
SPLAT_ZERO_CTX(dir##_uv_##var[0][off], n); \
SPLAT_ZERO_CTX(dir##_uv_##var[1][off], n); \
} else { \
SPLAT_ZERO_CTX(dir##_uv_##var[0][off * 2], n * 2); \
SPLAT_ZERO_CTX(dir##_uv_##var[1][off * 2], n * 2); \
} \
} while (0)

Function Documentation

◆ setctx_2d()

static av_always_inline void setctx_2d ( uint8_t *  ptr,
int  w,
int  h,
ptrdiff_t  stride,
int  v 
)
static

Definition at line 33 of file vp9block.c.

Referenced by decode_mode(), and ff_vp9_decode_block().

◆ decode_mode()

static void decode_mode ( VP9TileData td)
static

Definition at line 79 of file vp9block.c.

Referenced by ff_vp9_decode_block().

◆ decode_coeffs_b_generic()

static av_always_inline int decode_coeffs_b_generic ( VPXRangeCoder c,
int16_t *  coef,
int  n_coeffs,
int  is_tx32x32,
int  is8bitsperpixel,
int  bpp,
unsigned(*)  cnt[6][3],
unsigned(*)  eob[6][2],
const 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

◆ decode_coeffs_b_8bpp()

static int decode_coeffs_b_8bpp ( VP9TileData td,
int16_t *  coef,
int  n_coeffs,
unsigned(*)  cnt[6][3],
unsigned(*)  eob[6][2],
const 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 924 of file vp9block.c.

◆ decode_coeffs_b32_8bpp()

static int decode_coeffs_b32_8bpp ( VP9TileData td,
int16_t *  coef,
int  n_coeffs,
unsigned(*)  cnt[6][3],
unsigned(*)  eob[6][2],
const 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 934 of file vp9block.c.

◆ decode_coeffs_b_16bpp()

static int decode_coeffs_b_16bpp ( VP9TileData td,
int16_t *  coef,
int  n_coeffs,
unsigned(*)  cnt[6][3],
unsigned(*)  eob[6][2],
const 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 944 of file vp9block.c.

◆ decode_coeffs_b32_16bpp()

static int decode_coeffs_b32_16bpp ( VP9TileData td,
int16_t *  coef,
int  n_coeffs,
unsigned(*)  cnt[6][3],
unsigned(*)  eob[6][2],
const 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 954 of file vp9block.c.

◆ decode_coeffs()

static av_always_inline int decode_coeffs ( VP9TileData td,
int  is8bitsperpixel 
)
static

Definition at line 964 of file vp9block.c.

Referenced by decode_coeffs_16bpp(), and decode_coeffs_8bpp().

◆ decode_coeffs_8bpp()

static int decode_coeffs_8bpp ( VP9TileData td)
static

Definition at line 1131 of file vp9block.c.

Referenced by ff_vp9_decode_block().

◆ decode_coeffs_16bpp()

static int decode_coeffs_16bpp ( VP9TileData td)
static

Definition at line 1136 of file vp9block.c.

Referenced by ff_vp9_decode_block().

◆ mask_edges()

static av_always_inline void mask_edges ( uint8_t(*)  mask[8][4],
int  ss_h,
int  ss_v,
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 1141 of file vp9block.c.

Referenced by ff_vp9_decode_block().

◆ ff_vp9_decode_block()

void ff_vp9_decode_block ( VP9TileData td,
int  row,
int  col,
VP9Filter lflvl,
ptrdiff_t  yoff,
ptrdiff_t  uvoff,
enum BlockLevel  bl,
enum BlockPartition  bp 
)

Definition at line 1263 of file vp9block.c.

Referenced by decode_sb(), and decode_sb_mem().

td
#define td
Definition: regdef.h:70
step
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
Definition: rate_distortion.txt:58
b
#define b
Definition: input.c:41
AV_WN32A
#define AV_WN32A(p, v)
Definition: intreadwrite.h:538
FILTER_SWITCHABLE
@ FILTER_SWITCHABLE
Definition: vp9.h:70
val
static double val(void *priv, double ch)
Definition: aeval.c:77
s
#define s(width, name)
Definition: cbs_vp9.c:256
AV_ZERO64
#define AV_ZERO64(d)
Definition: intreadwrite.h:633
AV_ZERO32
#define AV_ZERO32(d)
Definition: intreadwrite.h:629
AV_WN16A
#define AV_WN16A(p, v)
Definition: intreadwrite.h:534
AV_ZERO128
#define AV_ZERO128(d)
Definition: intreadwrite.h:637
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
TxfmType
TxfmType
Definition: vp9.h:37
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
ff_vp9_intra_txfm_type
enum TxfmType ff_vp9_intra_txfm_type[14]
Definition: vp9data.c:437
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
ret
ret
Definition: filter_design.txt:187
AV_WN64A
#define AV_WN64A(p, v)
Definition: intreadwrite.h:542
AV_ZERO16
#define AV_ZERO16(d)
Definition: intreadwrite.h:625
cond
int(* cond)(enum AVPixelFormat pix_fmt)
Definition: pixdesc_query.c:28