libavcodec/rv34.c File Reference

RV30/40 decoder common data. More...

#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
#include "golomb.h"
#include "mathops.h"
#include "rectangle.h"
#include "rv34vlc.h"
#include "rv34data.h"
#include "rv34.h"

Go to the source code of this file.

Functions

static void ZERO8x2 (void *dst, int stride)
static void rv34_apply_differences (RV34DecContext *r, int cbp)
static int is_mv_diff_gt_3 (int16_t(*motion_val)[2], int step)
static int rv34_set_deblock_coef (RV34DecContext *r)
static int rv34_decode_macroblock (RV34DecContext *r, int8_t *intra_types)
static int check_slice_end (RV34DecContext *r, MpegEncContext *s)
static int slice_compare (SliceInfo *si1, SliceInfo *si2)
static int rv34_decode_slice (RV34DecContext *r, int end, const uint8_t *buf, int buf_size)
av_cold int ff_rv34_decode_init (AVCodecContext *avctx)
 Initialize decoder.
static int get_slice_offset (AVCodecContext *avctx, const uint8_t *buf, int n)
int ff_rv34_decode_frame (AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
av_cold int ff_rv34_decode_end (AVCodecContext *avctx)
RV30/40 inverse transform functions
static av_always_inline void rv34_row_transform (int temp[16], DCTELEM *block)
static void rv34_inv_transform (DCTELEM *block)
 Real Video 3.0/4.0 inverse transform Code is almost the same as in SVQ3, only scaling is different.
static void rv34_inv_transform_noround (DCTELEM *block)
 RealVideo 3.0/4.0 inverse transform for DC block.
RV30/40 4x4 block decoding functions
static int rv34_decode_cbp (GetBitContext *gb, RV34VLC *vlc, int table)
 Decode coded block pattern.
static void decode_coeff (DCTELEM *dst, int coef, int esc, GetBitContext *gb, VLC *vlc)
 Get one coefficient value from the bistream and store it.
static void decode_subblock (DCTELEM *dst, int code, const int is_block2, GetBitContext *gb, VLC *vlc)
 Decode 2x2 subblock of coefficients.
static void rv34_decode_block (DCTELEM *dst, GetBitContext *gb, RV34VLC *rvlc, int fc, int sc)
 Decode coefficients for 4x4 block.
static void rv34_dequant4x4 (DCTELEM *block, int Qdc, int Q)
 Dequantize ordinary 4x4 block.
static void rv34_dequant4x4_16x16 (DCTELEM *block, int Qdc, int Q)
 Dequantize 4x4 block of DC values for 16x16 macroblock.
RV30/40 bitstream parsing
int ff_rv34_get_start_offset (GetBitContext *gb, int mb_size)
 Decode starting slice position.
static RV34VLCchoose_vlc_set (int quant, int mod, int type)
 Select VLC set for decoding from current quantizer, modifier and frame type.
static int rv34_decode_dquant (GetBitContext *gb, int quant)
 Decode quantizer difference and return modified quantizer.
static int rv34_decode_mb_header (RV34DecContext *r, int8_t *intra_types)
 Decode macroblock header and return CBP in case of success, -1 otherwise.

Variables

static const int rv34_mb_type_to_lavc [12]
 translation of RV30/40 macroblock types to lavc ones
static RV34VLC intra_vlcs [NUM_INTRA_TABLES]
static RV34VLC inter_vlcs [NUM_INTER_TABLES]

motion vector related code (prediction, reconstruction, motion compensation)

#define GET_PTS_DIFF(a, b)   ((a - b + 8192) & 0x1FFF)
static const uint8_t part_sizes_w [RV34_MB_TYPES] = { 2, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2 }
 macroblock partition width in 8x8 blocks
static const uint8_t part_sizes_h [RV34_MB_TYPES] = { 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2 }
 macroblock partition height in 8x8 blocks
static const uint8_t avail_indexes [4] = { 6, 7, 10, 11 }
 availability index for subblocks
static const int chroma_coeffs [3] = { 0, 3, 5 }
static const int num_mvs [RV34_MB_TYPES] = { 0, 0, 1, 4, 1, 1, 0, 0, 2, 2, 2, 1 }
 number of motion vectors in each macroblock type
static int rv34_decode_mv (RV34DecContext *r, int block_type)
 Decode motion vector differences and perform motion vector reconstruction and motion compensation.
static void rv34_pred_mv (RV34DecContext *r, int block_type, int subblock_no, int dmv_no)
 motion vector prediction
static int calc_add_mv (RV34DecContext *r, int dir, int val)
 Calculate motion vector component that should be added for direct blocks.
static void rv34_pred_b_vector (int A[2], int B[2], int C[2], int A_avail, int B_avail, int C_avail, int *mx, int *my)
 Predict motion vector for B-frame macroblock.
static void rv34_pred_mv_b (RV34DecContext *r, int block_type, int dir)
 motion vector prediction for B-frames
static void rv34_pred_mv_rv3 (RV34DecContext *r, int block_type, int dir)
 motion vector prediction - RV3 version
static void rv34_mc (RV34DecContext *r, const int block_type, const int xoff, const int yoff, int mv_off, const int width, const int height, int dir, const int thirdpel, qpel_mc_func(*qpel_mc)[16], h264_chroma_mc_func(*chroma_mc))
 generic motion compensation function
static void rv34_mc_1mv (RV34DecContext *r, const int block_type, const int xoff, const int yoff, int mv_off, const int width, const int height, int dir)
static void rv34_mc_2mv (RV34DecContext *r, const int block_type)
static void rv34_mc_2mv_skip (RV34DecContext *r)

Macroblock reconstruction functions

#define LUMA_CBP_BLOCK_MASK   0x33
 mask for retrieving all bits in coded block pattern corresponding to one 8x8 block
#define U_CBP_MASK   0x0F0000
#define V_CBP_MASK   0xF00000
static const int ittrans [9]
 mapping of RV30/40 intra prediction types to standard H.264 types
static const int ittrans16 [4]
 mapping of RV30/40 intra 16x16 prediction types to standard H.264 types
static void rv34_pred_4x4_block (RV34DecContext *r, uint8_t *dst, int stride, int itype, int up, int left, int down, int right)
 Perform 4x4 intra prediction.
static void rv34_add_4x4_block (uint8_t *dst, int stride, DCTELEM block[64], int off)
 add_pixels_clamped for 4x4 block
static int adjust_pred16 (int itype, int up, int left)
static void rv34_output_macroblock (RV34DecContext *r, int8_t *intra_types, int cbp, int is16)

RV30/40 VLC generating functions

static const int table_offs []
static VLC_TYPE table_data [117592][2]
static void rv34_gen_vlc (const uint8_t *bits, int size, VLC *vlc, const uint8_t *insyms, const int num)
 Generate VLC from codeword lengths.
static av_cold void rv34_init_tables (void)
 Initialize all tables.


Detailed Description

RV30/40 decoder common data.

Definition in file rv34.c.


Define Documentation

#define GET_PTS_DIFF ( a,
 )     ((a - b + 8192) & 0x1FFF)

Definition at line 575 of file rv34.c.

Referenced by calc_add_mv().

#define LUMA_CBP_BLOCK_MASK   0x33

mask for retrieving all bits in coded block pattern corresponding to one 8x8 block

Definition at line 1102 of file rv34.c.

Referenced by rv34_apply_differences().

#define U_CBP_MASK   0x0F0000

Definition at line 1104 of file rv34.c.

Referenced by rv34_apply_differences().

#define V_CBP_MASK   0xF00000

Definition at line 1105 of file rv34.c.

Referenced by rv34_apply_differences().


Function Documentation

static int adjust_pred16 ( int  itype,
int  up,
int  left 
) [inline, static]

Definition at line 1009 of file rv34.c.

Referenced by rv34_output_macroblock().

static int calc_add_mv ( RV34DecContext r,
int  dir,
int  val 
) [static]

Calculate motion vector component that should be added for direct blocks.

Definition at line 580 of file rv34.c.

Referenced by rv34_decode_mv().

static int check_slice_end ( RV34DecContext r,
MpegEncContext s 
) [static]

Definition at line 1243 of file rv34.c.

Referenced by rv34_decode_slice().

static RV34VLC* choose_vlc_set ( int  quant,
int  mod,
int  type 
) [inline, static]

Select VLC set for decoding from current quantizer, modifier and frame type.

Definition at line 418 of file rv34.c.

Referenced by rv34_decode_macroblock(), and rv34_decode_mb_header().

static void decode_coeff ( DCTELEM dst,
int  coef,
int  esc,
GetBitContext gb,
VLC vlc 
) [inline, static]

Get one coefficient value from the bistream and store it.

Definition at line 291 of file rv34.c.

Referenced by decode_subblock().

static void decode_subblock ( DCTELEM dst,
int  code,
const int  is_block2,
GetBitContext gb,
VLC vlc 
) [inline, static]

Decode 2x2 subblock of coefficients.

Definition at line 311 of file rv34.c.

Referenced by rv34_decode_block().

av_cold int ff_rv34_decode_end ( AVCodecContext avctx  ) 

Definition at line 1531 of file rv34.c.

int ff_rv34_decode_frame ( AVCodecContext avctx,
void *  data,
int *  data_size,
AVPacket avpkt 
)

Definition at line 1419 of file rv34.c.

av_cold int ff_rv34_decode_init ( AVCodecContext avctx  ) 

Initialize decoder.

Definition at line 1372 of file rv34.c.

Referenced by rv30_decode_init(), and rv40_decode_init().

int ff_rv34_get_start_offset ( GetBitContext gb,
int  mb_size 
)

Decode starting slice position.

common decoding functions

Todo:
Maybe replace with ff_h263_decode_mba() ?

Definition at line 406 of file rv34.c.

Referenced by rv30_parse_slice_header(), and rv40_parse_slice_header().

static int get_slice_offset ( AVCodecContext avctx,
const uint8_t *  buf,
int  n 
) [static]

Definition at line 1413 of file rv34.c.

static int is_mv_diff_gt_3 ( int16_t(*)  motion_val[2],
int  step 
) [static]

Definition at line 1125 of file rv34.c.

Referenced by rv34_set_deblock_coef().

static void rv34_add_4x4_block ( uint8_t *  dst,
int  stride,
DCTELEM  block[64],
int  off 
) [static]

add_pixels_clamped for 4x4 block

Definition at line 1001 of file rv34.c.

Referenced by rv34_output_macroblock().

static void rv34_apply_differences ( RV34DecContext r,
int  cbp 
) [static]

Definition at line 1110 of file rv34.c.

Referenced by rv34_decode_macroblock().

static void rv34_decode_block ( DCTELEM dst,
GetBitContext gb,
RV34VLC rvlc,
int  fc,
int  sc 
) [inline, static]

Decode coefficients for 4x4 block.

This is done by filling 2x2 subblocks with decoded coefficients in this order (the same for subblocks and subblock coefficients): o--o / / o--o

Definition at line 341 of file rv34.c.

Referenced by rv34_decode_macroblock().

static int rv34_decode_cbp ( GetBitContext gb,
RV34VLC vlc,
int  table 
) [static]

Decode coded block pattern.

Definition at line 258 of file rv34.c.

Referenced by rv34_decode_mb_header().

static int rv34_decode_dquant ( GetBitContext gb,
int  quant 
) [inline, static]

Decode quantizer difference and return modified quantizer.

Definition at line 429 of file rv34.c.

static int rv34_decode_macroblock ( RV34DecContext r,
int8_t *  intra_types 
) [static]

Definition at line 1167 of file rv34.c.

Referenced by rv34_decode_slice().

static int rv34_decode_mb_header ( RV34DecContext r,
int8_t *  intra_types 
) [static]

Decode macroblock header and return CBP in case of success, -1 otherwise.

Definition at line 440 of file rv34.c.

Referenced by rv34_decode_macroblock().

static int rv34_decode_mv ( RV34DecContext r,
int  block_type 
) [static]

Decode motion vector differences and perform motion vector reconstruction and motion compensation.

Definition at line 868 of file rv34.c.

Referenced by rv34_decode_mb_header().

static int rv34_decode_slice ( RV34DecContext r,
int  end,
const uint8_t *  buf,
int  buf_size 
) [static]

Definition at line 1267 of file rv34.c.

Referenced by ff_rv34_decode_frame().

static void rv34_dequant4x4 ( DCTELEM block,
int  Qdc,
int  Q 
) [inline, static]

Dequantize ordinary 4x4 block.

Todo:
optimize

Definition at line 371 of file rv34.c.

Referenced by rv34_decode_macroblock().

static void rv34_dequant4x4_16x16 ( DCTELEM block,
int  Qdc,
int  Q 
) [inline, static]

Dequantize 4x4 block of DC values for 16x16 macroblock.

Todo:
optimize

Definition at line 385 of file rv34.c.

Referenced by rv34_decode_macroblock().

static void rv34_gen_vlc ( const uint8_t *  bits,
int  size,
VLC vlc,
const uint8_t *  insyms,
const int  num 
) [static]

Generate VLC from codeword lengths.

Parameters:
bits codeword lengths (zeroes are accepted)
size length of input data
vlc output VLC
insyms symbols for input codes (NULL for default ones)
num VLC table number (for static initialization)

Definition at line 103 of file rv34.c.

Referenced by rv34_init_tables().

static av_cold void rv34_init_tables ( void   )  [static]

Initialize all tables.

Definition at line 139 of file rv34.c.

Referenced by ff_rv34_decode_init().

static void rv34_inv_transform ( DCTELEM block  )  [static]

Real Video 3.0/4.0 inverse transform Code is almost the same as in SVQ3, only scaling is different.

Definition at line 201 of file rv34.c.

Referenced by rv34_decode_macroblock().

static void rv34_inv_transform_noround ( DCTELEM block  )  [static]

RealVideo 3.0/4.0 inverse transform for DC block.

Code is almost the same as rv34_inv_transform() but final coefficients are multiplied by 1.5 and have no rounding.

Definition at line 227 of file rv34.c.

Referenced by rv34_decode_macroblock().

static void rv34_mc ( RV34DecContext r,
const int  block_type,
const int  xoff,
const int  yoff,
int  mv_off,
const int  width,
const int  height,
int  dir,
const int  thirdpel,
qpel_mc_func(*)  qpel_mc[16],
h264_chroma_mc_func chroma_mc 
) [inline, static]

generic motion compensation function

Parameters:
r decoder context
block_type type of the current block
xoff horizontal offset from the start of the current block
yoff vertical offset from the start of the current block
mv_off offset to the motion vector information
width width of the current partition in 8x8 blocks
height height of the current partition in 8x8 blocks
dir motion compensation direction (i.e. from the last or the next reference frame)
thirdpel motion vectors are specified in 1/3 of pixel
qpel_mc a set of functions used to perform luma motion compensation
chroma_mc a set of functions used to perform chroma motion compensation

Definition at line 732 of file rv34.c.

Referenced by rv34_mc_1mv(), rv34_mc_2mv(), and rv34_mc_2mv_skip().

static void rv34_mc_1mv ( RV34DecContext r,
const int  block_type,
const int  xoff,
const int  yoff,
int  mv_off,
const int  width,
const int  height,
int  dir 
) [static]

Definition at line 818 of file rv34.c.

Referenced by rv34_decode_mv().

static void rv34_mc_2mv ( RV34DecContext r,
const int  block_type 
) [static]

Definition at line 829 of file rv34.c.

Referenced by rv34_decode_mv().

static void rv34_mc_2mv_skip ( RV34DecContext r  )  [static]

Definition at line 843 of file rv34.c.

Referenced by rv34_decode_mv().

static void rv34_output_macroblock ( RV34DecContext r,
int8_t *  intra_types,
int  cbp,
int  is16 
) [static]

Definition at line 1025 of file rv34.c.

Referenced by rv34_decode_macroblock().

static void rv34_pred_4x4_block ( RV34DecContext r,
uint8_t *  dst,
int  stride,
int  itype,
int  up,
int  left,
int  down,
int  right 
) [static]

Perform 4x4 intra prediction.

Definition at line 973 of file rv34.c.

Referenced by rv34_output_macroblock().

static void rv34_pred_b_vector ( int  A[2],
int  B[2],
int  C[2],
int  A_avail,
int  B_avail,
int  C_avail,
int *  mx,
int *  my 
) [inline, static]

Predict motion vector for B-frame macroblock.

Definition at line 594 of file rv34.c.

Referenced by rv34_pred_mv_b().

static void rv34_pred_mv ( RV34DecContext r,
int  block_type,
int  subblock_no,
int  dmv_no 
) [static]

motion vector prediction

Motion prediction performed for the block by using median prediction of motion vectors from the left, top and right top blocks but in corner cases some other vectors may be used instead.

Definition at line 526 of file rv34.c.

Referenced by rv34_decode_mv().

static void rv34_pred_mv_b ( RV34DecContext r,
int  block_type,
int  dir 
) [static]

motion vector prediction for B-frames

Definition at line 614 of file rv34.c.

Referenced by rv34_decode_mv().

static void rv34_pred_mv_rv3 ( RV34DecContext r,
int  block_type,
int  dir 
) [static]

motion vector prediction - RV3 version

Definition at line 669 of file rv34.c.

Referenced by rv34_decode_mv().

static av_always_inline void rv34_row_transform ( int  temp[16],
DCTELEM block 
) [static]

Definition at line 180 of file rv34.c.

Referenced by rv34_inv_transform(), and rv34_inv_transform_noround().

static int rv34_set_deblock_coef ( RV34DecContext r  )  [static]

Definition at line 1137 of file rv34.c.

Referenced by rv34_decode_macroblock().

static int slice_compare ( SliceInfo si1,
SliceInfo si2 
) [inline, static]

Definition at line 1258 of file rv34.c.

static void ZERO8x2 ( void *  dst,
int  stride 
) [inline, static]

Definition at line 40 of file rv34.c.

Referenced by rv34_decode_mv(), and rv34_pred_mv_b().


Variable Documentation

const uint8_t avail_indexes[4] = { 6, 7, 10, 11 } [static]

availability index for subblocks

Definition at line 517 of file rv34.c.

Referenced by rv34_pred_mv(), and rv34_pred_mv_rv3().

const int chroma_coeffs[3] = { 0, 3, 5 } [static]

Definition at line 715 of file rv34.c.

Referenced by rv34_mc().

RV34VLC inter_vlcs[NUM_INTER_TABLES] [static]

Definition at line 63 of file rv34.c.

RV34VLC intra_vlcs[NUM_INTRA_TABLES] [static]

Definition at line 63 of file rv34.c.

const int ittrans[9] [static]

Initial value:

mapping of RV30/40 intra prediction types to standard H.264 types

Definition at line 960 of file rv34.c.

const int ittrans16[4] [static]

Initial value:

mapping of RV30/40 intra 16x16 prediction types to standard H.264 types

Definition at line 966 of file rv34.c.

const int num_mvs[RV34_MB_TYPES] = { 0, 0, 1, 4, 1, 1, 0, 0, 2, 2, 2, 1 } [static]

number of motion vectors in each macroblock type

Definition at line 862 of file rv34.c.

Referenced by tgv_decode_inter().

const uint8_t part_sizes_h[RV34_MB_TYPES] = { 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2 } [static]

macroblock partition height in 8x8 blocks

Definition at line 514 of file rv34.c.

Referenced by rv34_pred_mv().

const uint8_t part_sizes_w[RV34_MB_TYPES] = { 2, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2 } [static]

macroblock partition width in 8x8 blocks

Definition at line 511 of file rv34.c.

Referenced by rv34_pred_mv().

const int rv34_mb_type_to_lavc[12] [static]

VLC_TYPE table_data[117592][2] [static]

Definition at line 93 of file rv34.c.

Referenced by ff_ivi_init_static_vlc(), and rv34_gen_vlc().

const int table_offs[] [static]

Initial value:

 {
      0,   1818,   3622,   4144,   4698,   5234,   5804,   5868,   5900,   5932,
   5996,   6252,   6316,   6348,   6380,   7674,   8944,  10274,  11668,  12250,
  14060,  15846,  16372,  16962,  17512,  18148,  18180,  18212,  18244,  18308,
  18564,  18628,  18660,  18692,  20036,  21314,  22648,  23968,  24614,  26384,
  28190,  28736,  29366,  29938,  30608,  30640,  30672,  30704,  30768,  31024,
  31088,  31120,  31184,  32570,  33898,  35236,  36644,  37286,  39020,  40802,
  41368,  42052,  42692,  43348,  43380,  43412,  43444,  43476,  43604,  43668,
  43700,  43732,  45100,  46430,  47778,  49160,  49802,  51550,  53340,  53972,
  54648,  55348,  55994,  56122,  56154,  56186,  56218,  56346,  56410,  56442,
  56474,  57878,  59290,  60636,  62036,  62682,  64460,  64524,  64588,  64716,
  64844,  66076,  67466,  67978,  68542,  69064,  69648,  70296,  72010,  72074,
  72138,  72202,  72330,  73572,  74936,  75454,  76030,  76566,  77176,  77822,
  79582,  79646,  79678,  79742,  79870,  81180,  82536,  83064,  83672,  84242,
  84934,  85576,  87384,  87448,  87480,  87544,  87672,  88982,  90340,  90902,
  91598,  92182,  92846,  93488,  95246,  95278,  95310,  95374,  95502,  96878,
  98266,  98848,  99542, 100234, 100884, 101524, 103320, 103352, 103384, 103416,
 103480, 104874, 106222, 106910, 107584, 108258, 108902, 109544, 111366, 111398,
 111430, 111462, 111494, 112878, 114320, 114988, 115660, 116310, 116950, 117592
}

Definition at line 72 of file rv34.c.

Referenced by rv34_gen_vlc().


Generated on Fri Oct 26 02:39:46 2012 for FFmpeg by  doxygen 1.5.8