FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
diracdec.c File Reference

Dirac Decoder. More...

#include "libavutil/pixdesc.h"
#include "libavutil/thread.h"
#include "avcodec.h"
#include "get_bits.h"
#include "bytestream.h"
#include "internal.h"
#include "golomb.h"
#include "dirac_arith.h"
#include "dirac_vlc.h"
#include "mpeg12data.h"
#include "libavcodec/mpegvideo.h"
#include "mpegvideoencdsp.h"
#include "dirac_dwt.h"
#include "dirac.h"
#include "diractab.h"
#include "diracdsp.h"
#include "videodsp.h"

Go to the source code of this file.

Data Structures

struct  DiracFrame
 
struct  DiracBlock
 
struct  SubBand
 
struct  Plane
 
struct  DiracSlice
 
struct  DiracContext
 
struct  SliceCoeffs
 

Macros

#define MAX_REFERENCE_FRAMES   8
 The spec limits this to 3 for frame coding, but in practice can be as high as 6. More...
 
#define MAX_DELAY   5 /* limit for main profile for frame coding (TODO: field coding) */
 
#define MAX_FRAMES   (MAX_REFERENCE_FRAMES + MAX_DELAY + 1)
 
#define MAX_QUANT   255 /* max quant for VC-2 */
 
#define MAX_BLOCKSIZE   32 /* maximum xblen/yblen we support */
 
#define DIRAC_REF_MASK_REF1   1
 DiracBlock->ref flags, if set then the block does MC from the given ref. More...
 
#define DIRAC_REF_MASK_REF2   2
 
#define DIRAC_REF_MASK_GLOBAL   4
 
#define DELAYED_PIC_REF   4
 Value of Picture.reference when Picture is not a reference picture, but is held for delayed output. More...
 
#define CALC_PADDING(size, depth)   (((size + (1 << depth) - 1) >> depth) << depth)
 
#define DIVRNDUP(a, b)   (((a) + (b) - 1) / (b))
 
#define SIGN_CTX(x)   (CTX_SIGN_ZERO + ((x) > 0) - ((x) < 0))
 
#define UNPACK_ARITH(n, type)
 
#define INTRA_DC_PRED(n, type)
 Dirac Specification -> 13.3 intra_dc_prediction(band) More...
 
#define PARSE_VALUES(type, x, gb, ebits, buf1, buf2)
 
#define CHECKEDREAD(dst, cond, errmsg)
 
#define ROLLOFF(i)
 
#define DATA_UNIT_HEADER_SIZE   13
 Dirac Specification -> 9.6 Parse Info Header Syntax. More...
 

Enumerations

enum  dirac_subband {
  subband_ll = 0, subband_hl = 1, subband_lh = 2, subband_hh = 3,
  subband_nb
}
 

Functions

static int divide3 (int x)
 
static DiracFrameremove_frame (DiracFrame *framelist[], int picnum)
 
static int add_frame (DiracFrame *framelist[], int maxframes, DiracFrame *frame)
 
static int alloc_sequence_buffers (DiracContext *s)
 
static int alloc_buffers (DiracContext *s, int stride)
 
static void free_sequence_buffers (DiracContext *s)
 
static av_cold int dirac_decode_init (AVCodecContext *avctx)
 
static void dirac_decode_flush (AVCodecContext *avctx)
 
static av_cold int dirac_decode_end (AVCodecContext *avctx)
 
static int coeff_unpack_golomb (GetBitContext *gb, int qfactor, int qoffset)
 
static int codeblock (DiracContext *s, SubBand *b, GetBitContext *gb, DiracArith *c, int left, int right, int top, int bottom, int blockcnt_one, int is_arith)
 Decode the coeffs in the rectangle defined by left, right, top, bottom [DIRAC_STD] 13.4.3.2 Codeblock unpacking loop. More...
 
static av_always_inline int decode_subband_internal (DiracContext *s, SubBand *b, int is_arith)
 Dirac Specification -> 13.4.2 Non-skipped subbands. More...
 
static int decode_subband_arith (AVCodecContext *avctx, void *b)
 
static int decode_subband_golomb (AVCodecContext *avctx, void *arg)
 
static int decode_component (DiracContext *s, int comp)
 Dirac Specification -> [DIRAC_STD] 13.4.1 core_transform_data() More...
 
static void decode_subband (DiracContext *s, GetBitContext *gb, int quant, int slice_x, int slice_y, int bits_end, SubBand *b1, SubBand *b2)
 
static int decode_lowdelay_slice (AVCodecContext *avctx, void *arg)
 Dirac Specification -> 13.5.2 Slices. More...
 
static int subband_coeffs (DiracContext *s, int x, int y, int p, SliceCoeffs c[MAX_DWT_LEVELS])
 
static int decode_hq_slice (DiracContext *s, DiracSlice *slice, uint8_t *tmp_buf)
 VC-2 Specification -> 13.5.3 hq_slice(sx,sy) More...
 
static int decode_hq_slice_row (AVCodecContext *avctx, void *arg, int jobnr, int threadnr)
 
static int decode_lowdelay (DiracContext *s)
 Dirac Specification -> 13.5.1 low_delay_transform_data() More...
 
static void init_planes (DiracContext *s)
 
static int dirac_unpack_prediction_parameters (DiracContext *s)
 Unpack the motion compensation parameters Dirac Specification -> 11.2 Picture prediction data. More...
 
static int dirac_unpack_idwt_params (DiracContext *s)
 Dirac Specification -> 11.3 Wavelet transform data. More...
 
static int pred_sbsplit (uint8_t *sbsplit, int stride, int x, int y)
 
static int pred_block_mode (DiracBlock *block, int stride, int x, int y, int refmask)
 
static void pred_block_dc (DiracBlock *block, int stride, int x, int y)
 
static void pred_mv (DiracBlock *block, int stride, int x, int y, int ref)
 
static void global_mv (DiracContext *s, DiracBlock *block, int x, int y, int ref)
 
static void decode_block_params (DiracContext *s, DiracArith arith[8], DiracBlock *block, int stride, int x, int y)
 
static void propagate_block_data (DiracBlock *block, int stride, int size)
 Copies the current block to the other blocks covered by the current superblock split mode. More...
 
static int dirac_unpack_block_motion_data (DiracContext *s)
 Dirac Specification -> More...
 
static int weight (int i, int blen, int offset)
 
static void init_obmc_weight_row (Plane *p, uint8_t *obmc_weight, int stride, int left, int right, int wy)
 
static void init_obmc_weight (Plane *p, uint8_t *obmc_weight, int stride, int left, int right, int top, int bottom)
 
static void init_obmc_weights (DiracContext *s, Plane *p, int by)
 
static int mc_subpel (DiracContext *s, DiracBlock *block, const uint8_t *src[5], int x, int y, int ref, int plane)
 For block x,y, determine which of the hpel planes to do bilinear interpolation from and set src[] to the location in each hpel plane to MC from. More...
 
static void add_dc (uint16_t *dst, int dc, int stride, uint8_t *obmc_weight, int xblen, int yblen)
 
static void block_mc (DiracContext *s, DiracBlock *block, uint16_t *mctmp, uint8_t *obmc_weight, int plane, int dstx, int dsty)
 
static void mc_row (DiracContext *s, DiracBlock *block, uint16_t *mctmp, int plane, int dsty)
 
static void select_dsp_funcs (DiracContext *s, int width, int height, int xblen, int yblen)
 
static int interpolate_refplane (DiracContext *s, DiracFrame *ref, int plane, int width, int height)
 
static int dirac_decode_frame_internal (DiracContext *s)
 Dirac Specification -> 13.0 Transform data syntax. More...
 
static int get_buffer_with_edge (AVCodecContext *avctx, AVFrame *f, int flags)
 
static int dirac_decode_picture_header (DiracContext *s)
 Dirac Specification -> 11.1.1 Picture Header. More...
 
static int get_delayed_pic (DiracContext *s, AVFrame *picture, int *got_frame)
 
static int dirac_decode_data_unit (AVCodecContext *avctx, const uint8_t *buf, int size)
 
static int dirac_decode_frame (AVCodecContext *avctx, void *data, int *got_frame, AVPacket *pkt)
 

Variables

static AVOnce dirac_arith_init = AV_ONCE_INIT
 
static const uint8_t epel_weights [4][4][4]
 
AVCodec ff_dirac_decoder
 

Detailed Description

Dirac Decoder.

Author
Marco Gerards marco.nosp@m.@gnu.nosp@m..org, David Conrad, Jordi Ortiz nenjo.nosp@m.rdi@.nosp@m.gmail.nosp@m..com

Definition in file diracdec.c.

Macro Definition Documentation

#define MAX_REFERENCE_FRAMES   8

The spec limits this to 3 for frame coding, but in practice can be as high as 6.

Definition at line 50 of file diracdec.c.

Referenced by dirac_decode_picture_header().

#define MAX_DELAY   5 /* limit for main profile for frame coding (TODO: field coding) */

Definition at line 51 of file diracdec.c.

Referenced by dirac_decode_frame().

#define MAX_FRAMES   (MAX_REFERENCE_FRAMES + MAX_DELAY + 1)
#define MAX_QUANT   255 /* max quant for VC-2 */

Definition at line 53 of file diracdec.c.

#define MAX_BLOCKSIZE   32 /* maximum xblen/yblen we support */
#define DIRAC_REF_MASK_REF1   1

DiracBlock->ref flags, if set then the block does MC from the given ref.

Definition at line 59 of file diracdec.c.

Referenced by decode_block_params().

#define DIRAC_REF_MASK_REF2   2

Definition at line 60 of file diracdec.c.

Referenced by decode_block_params().

#define DIRAC_REF_MASK_GLOBAL   4

Definition at line 61 of file diracdec.c.

Referenced by decode_block_params(), and pred_mv().

#define DELAYED_PIC_REF   4

Value of Picture.reference when Picture is not a reference picture, but is held for delayed output.

Definition at line 67 of file diracdec.c.

Referenced by dirac_decode_frame(), dirac_decode_picture_header(), get_delayed_pic(), h264_field_start(), h264_select_output_frame(), pic_is_unused(), send_next_delayed_frame(), and unreference_pic().

#define CALC_PADDING (   size,
  depth 
)    (((size + (1 << depth) - 1) >> depth) << depth)

Definition at line 69 of file diracdec.c.

Referenced by alloc_sequence_buffers(), dirac_decode_data_unit(), and init_planes().

#define DIVRNDUP (   a,
  b 
)    (((a) + (b) - 1) / (b))

Definition at line 72 of file diracdec.c.

Referenced by alloc_sequence_buffers(), and dirac_unpack_block_motion_data().

#define SIGN_CTX (   x)    (CTX_SIGN_ZERO + ((x) > 0) - ((x) < 0))

Definition at line 448 of file diracdec.c.

#define UNPACK_ARITH (   n,
  type 
)
Value:
static inline void coeff_unpack_arith_##n(DiracArith *c, int qfactor, int qoffset, \
SubBand *b, type *buf, int x, int y) \
{ \
int sign, sign_pred = 0, pred_ctx = CTX_ZPZN_F1; \
unsigned coeff; \
const int mstride = -(b->stride >> (1+b->pshift)); \
if (b->parent) { \
const type *pbuf = (type *)b->parent->ibuf; \
const int stride = b->parent->stride >> (1+b->parent->pshift); \
pred_ctx += !!pbuf[stride * (y>>1) + (x>>1)] << 1; \
} \
if (b->orientation == subband_hl) \
sign_pred = buf[mstride]; \
if (x) { \
pred_ctx += !(buf[-1] | buf[mstride] | buf[-1 + mstride]); \
if (b->orientation == subband_lh) \
sign_pred = buf[-1]; \
} else { \
pred_ctx += !buf[mstride]; \
} \
if (coeff) { \
coeff = (coeff * qfactor + qoffset) >> 2; \
sign = dirac_get_arith_bit(c, SIGN_CTX(sign_pred)); \
coeff = (coeff ^ -sign) + sign; \
} \
*buf = coeff; \
} \
#define SIGN_CTX(x)
Definition: diracdec.c:448
GLint GLenum type
Definition: opengl_enc.c:104
static int dirac_get_arith_uint(DiracArith *c, int follow_ctx, int data_ctx)
Definition: dirac_arith.h:175
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
Definition: cfhd.h:44
#define b
Definition: input.c:41
int n
Definition: avisynth_c.h:760
if(ret)
void * buf
Definition: avisynth_c.h:766
static int dirac_get_arith_bit(DiracArith *c, int ctx)
Definition: dirac_arith.h:134
GLint GLenum GLboolean GLsizei stride
Definition: opengl_enc.c:104
int
static const double coeff[2][5]
Definition: vf_owdenoise.c:72

Definition at line 450 of file diracdec.c.

#define INTRA_DC_PRED (   n,
  type 
)
Value:
static inline void intra_dc_prediction_##n(SubBand *b) \
{ \
type *buf = (type*)b->ibuf; \
int x, y; \
\
for (x = 1; x < b->width; x++) \
buf[x] += buf[x-1]; \
buf += (b->stride >> (1+b->pshift)); \
for (y = 1; y < b->height; y++) { \
buf[0] += buf[-(b->stride >> (1+b->pshift))]; \
for (x = 1; x < b->width; x++) { \
int pred = buf[x - 1] + buf[x - (b->stride >> (1+b->pshift))] + buf[x - (b->stride >> (1+b->pshift))-1]; \
buf[x] += divide3(pred); \
} \
buf += (b->stride >> (1+b->pshift)); \
} \
} \
static int divide3(int x)
Definition: diracdec.c:250
GLint GLenum type
Definition: opengl_enc.c:104
Definition: cfhd.h:44
#define b
Definition: input.c:41
int n
Definition: avisynth_c.h:760
static const float pred[4]
Definition: siprdata.h:259
void * buf
Definition: avisynth_c.h:766
int
for(j=16;j >0;--j)

Dirac Specification -> 13.3 intra_dc_prediction(band)

Definition at line 569 of file diracdec.c.

#define PARSE_VALUES (   type,
  x,
  gb,
  ebits,
  buf1,
  buf2 
)
Value:
type *buf = (type *)buf1; \
buf[x] = coeff_unpack_golomb(gb, qfactor, qoffset); \
if (get_bits_count(gb) >= ebits) \
if (buf2) { \
buf = (type *)buf2; \
buf[x] = coeff_unpack_golomb(gb, qfactor, qoffset); \
if (get_bits_count(gb) >= ebits) \
} \
GLint GLenum type
Definition: opengl_enc.c:104
static int coeff_unpack_golomb(Get