FFmpeg
Macros | Functions | Variables
intrax8.c File Reference

IntraX8 (J-Frame) subdecoder, used by WMV2 and VC-1. More...

#include "libavutil/avassert.h"
#include "libavutil/mem.h"
#include "libavutil/thread.h"
#include "avcodec.h"
#include "get_bits.h"
#include "idctdsp.h"
#include "msmpeg4_vc1_data.h"
#include "intrax8huf.h"
#include "intrax8.h"
#include "intrax8dsp.h"
#include "mpegutils.h"

Go to the source code of this file.

Macros

#define VLC_BUFFER_SIZE   28150
 
#define MAX_TABLE_DEPTH(table_bits, max_bits)   ((max_bits + table_bits - 1) / table_bits)
 
#define DC_VLC_BITS   9
 
#define AC_VLC_BITS   9
 
#define OR_VLC_BITS   7
 
#define DC_VLC_MTD   MAX_TABLE_DEPTH(DC_VLC_BITS, MAX_DC_VLC_BITS)
 
#define AC_VLC_MTD   MAX_TABLE_DEPTH(AC_VLC_BITS, MAX_AC_VLC_BITS)
 
#define OR_VLC_MTD   MAX_TABLE_DEPTH(OR_VLC_BITS, MAX_OR_VLC_BITS)
 
#define extra_bits(eb)   (eb)
 
#define extra_run   (0xFF << 8)
 
#define extra_level   (0x00 << 8)
 
#define run_offset(r)   ((r) << 16)
 
#define level_offset(l)   ((l) << 24)
 
#define B(x, y)   w->block[0][w->idct_permutation[(x) + (y) * 8]]
 
#define T(x)   ((x) * dc_level + 0x8000) >> 16;
 

Functions

static const av_cold VLCElemx8_init_vlc (VLCInitState *state, int nb_bits, int nb_codes, const uint8_t table[][2])
 
static av_cold void x8_vlc_init (void)
 
static void x8_reset_vlc_tables (IntraX8Context *w)
 
static void x8_select_ac_table (IntraX8Context *const w, int mode)
 
static int x8_get_orient_vlc (IntraX8Context *w)
 
static void x8_get_ac_rlf (IntraX8Context *const w, const int mode, int *const run, int *const level, int *const final)
 
static int x8_get_dc_rlf (IntraX8Context *const w, const int mode, int *const level, int *const final)
 
static int x8_setup_spatial_predictor (IntraX8Context *const w, const int chroma)
 
static void x8_update_predictions (IntraX8Context *const w, const int orient, const int est_run)
 
static void x8_get_prediction_chroma (IntraX8Context *const w)
 
static void x8_get_prediction (IntraX8Context *const w)
 
static void x8_ac_compensation (IntraX8Context *const w, const int direction, const int dc_level)
 
static void dsp_x8_put_solidcolor (const uint8_t pix, uint8_t *dst, const ptrdiff_t linesize)
 
static int x8_decode_intra_mb (IntraX8Context *const w, const int chroma)
 
static void x8_init_block_index (IntraX8Context *w, AVFrame *frame)
 
av_cold int ff_intrax8_common_init (AVCodecContext *avctx, IntraX8Context *w, int16_t(*block)[64], int block_last_index[12], int mb_width, int mb_height)
 Initialize IntraX8 frame decoder. More...
 
av_cold void ff_intrax8_common_end (IntraX8Context *w)
 Destroy IntraX8 frame structure. More...
 
int ff_intrax8_decode_picture (IntraX8Context *w, MPVPicture *pict, GetBitContext *gb, int *mb_x, int *mb_y, int dquant, int quant_offset, int loopfilter, int lowdelay)
 Decode single IntraX8 frame. More...
 

Variables

static const VLCElemj_ac_vlc [2][2][8]
 
static const VLCElemj_dc_vlc [2][8]
 
static const VLCElemj_orient_vlc [2][4]
 
static const uint32_t ac_decode_table []
 
static const uint8_t dc_index_offset []
 
static const int16_t quant_table [64]
 

Detailed Description

IntraX8 (J-Frame) subdecoder, used by WMV2 and VC-1.

Definition in file intrax8.c.

Macro Definition Documentation

◆ VLC_BUFFER_SIZE

#define VLC_BUFFER_SIZE   28150

Definition at line 36 of file intrax8.c.

◆ MAX_TABLE_DEPTH

#define MAX_TABLE_DEPTH (   table_bits,
  max_bits 
)    ((max_bits + table_bits - 1) / table_bits)

Definition at line 38 of file intrax8.c.

◆ DC_VLC_BITS

#define DC_VLC_BITS   9

Definition at line 41 of file intrax8.c.

◆ AC_VLC_BITS

#define AC_VLC_BITS   9

Definition at line 42 of file intrax8.c.

◆ OR_VLC_BITS

#define OR_VLC_BITS   7

Definition at line 43 of file intrax8.c.

◆ DC_VLC_MTD

#define DC_VLC_MTD   MAX_TABLE_DEPTH(DC_VLC_BITS, MAX_DC_VLC_BITS)

Definition at line 45 of file intrax8.c.

◆ AC_VLC_MTD

#define AC_VLC_MTD   MAX_TABLE_DEPTH(AC_VLC_BITS, MAX_AC_VLC_BITS)

Definition at line 46 of file intrax8.c.

◆ OR_VLC_MTD

#define OR_VLC_MTD   MAX_TABLE_DEPTH(OR_VLC_BITS, MAX_OR_VLC_BITS)

Definition at line 47 of file intrax8.c.

◆ extra_bits

#define extra_bits (   eb)    (eb)

Definition at line 120 of file intrax8.c.

◆ extra_run

#define extra_run   (0xFF << 8)

Definition at line 121 of file intrax8.c.

◆ extra_level

#define extra_level   (0x00 << 8)

Definition at line 122 of file intrax8.c.

◆ run_offset

#define run_offset (   r)    ((r) << 16)

Definition at line 123 of file intrax8.c.

◆ level_offset

#define level_offset (   l)    ((l) << 24)

Definition at line 124 of file intrax8.c.

◆ B

#define B (   x,
 
)    w->block[0][w->idct_permutation[(x) + (y) * 8]]

◆ T

#define T (   x)    ((x) * dc_level + 0x8000) >> 16;

Function Documentation

◆ x8_init_vlc()

static const av_cold VLCElem* x8_init_vlc ( VLCInitState state,
int  nb_bits,
int  nb_codes,
const uint8_t  table[][2] 
)
static

Definition at line 53 of file intrax8.c.

Referenced by x8_vlc_init().

◆ x8_vlc_init()

static av_cold void x8_vlc_init ( void  )
static

Definition at line 60 of file intrax8.c.

Referenced by ff_intrax8_common_init().

◆ x8_reset_vlc_tables()

static void x8_reset_vlc_tables ( IntraX8Context w)
static

Definition at line 88 of file intrax8.c.

Referenced by ff_intrax8_decode_picture().

◆ x8_select_ac_table()

static void x8_select_ac_table ( IntraX8Context *const  w,
int  mode 
)
inlinestatic

Definition at line 95 of file intrax8.c.

Referenced by x8_decode_intra_mb().

◆ x8_get_orient_vlc()

static int x8_get_orient_vlc ( IntraX8Context w)
inlinestatic

Definition at line 110 of file intrax8.c.

Referenced by x8_setup_spatial_predictor().

◆ x8_get_ac_rlf()

static void x8_get_ac_rlf ( IntraX8Context *const  w,
const int  mode,
int *const  run,
int *const  level,
int *const  final 
)
static

Definition at line 167 of file intrax8.c.

Referenced by x8_decode_intra_mb().

◆ x8_get_dc_rlf()

static int x8_get_dc_rlf ( IntraX8Context *const  w,
const int  mode,
int *const  level,
int *const  final 
)
static

Definition at line 247 of file intrax8.c.

Referenced by x8_decode_intra_mb().

◆ x8_setup_spatial_predictor()

static int x8_setup_spatial_predictor ( IntraX8Context *const  w,
const int  chroma 
)
static

Definition at line 283 of file intrax8.c.

Referenced by ff_intrax8_decode_picture().

◆ x8_update_predictions()

static void x8_update_predictions ( IntraX8Context *const  w,
const int  orient,
const int  est_run 
)
static

Definition at line 341 of file intrax8.c.

Referenced by x8_decode_intra_mb().

◆ x8_get_prediction_chroma()

static void x8_get_prediction_chroma ( IntraX8Context *const  w)
static

Definition at line 351 of file intrax8.c.

Referenced by ff_intrax8_decode_picture().

◆ x8_get_prediction()

static void x8_get_prediction ( IntraX8Context *const  w)
static

Definition at line 367 of file intrax8.c.

Referenced by ff_intrax8_decode_picture().

◆ x8_ac_compensation()

static void x8_ac_compensation ( IntraX8Context *const  w,
const int  direction,
const int  dc_level 
)
static

Definition at line 436 of file intrax8.c.

Referenced by x8_decode_intra_mb().

◆ dsp_x8_put_solidcolor()

static void dsp_x8_put_solidcolor ( const uint8_t  pix,
uint8_t *  dst,
const ptrdiff_t  linesize 
)
static

Definition at line 507 of file intrax8.c.

Referenced by x8_decode_intra_mb().

◆ x8_decode_intra_mb()

static int x8_decode_intra_mb ( IntraX8Context *const  w,
const int  chroma 
)
static

Definition at line 528 of file intrax8.c.

Referenced by ff_intrax8_decode_picture().

◆ x8_init_block_index()

static void x8_init_block_index ( IntraX8Context w,
AVFrame frame 
)
static

Definition at line 672 of file intrax8.c.

Referenced by ff_intrax8_decode_picture().

◆ ff_intrax8_common_init()

av_cold int ff_intrax8_common_init ( AVCodecContext avctx,
IntraX8Context w,
int16_t(*)  block[64],
int  block_last_index[12],
int  mb_width,
int  mb_height 
)

Initialize IntraX8 frame decoder.

Parameters
avctxpointer to AVCodecContext
wpointer to IntraX8Context
blockpointer to block array
block_last_indexpointer to index array
mb_widthmacroblock width
mb_heightmacroblock height
Returns
0 on success, a negative AVERROR value on error

Definition at line 689 of file intrax8.c.

Referenced by vc1_decode_init_alloc_tables(), and wmv2_decode_init().

◆ ff_intrax8_common_end()

av_cold void ff_intrax8_common_end ( IntraX8Context w)

Destroy IntraX8 frame structure.

Parameters
wpointer to IntraX8Context

Definition at line 728 of file intrax8.c.

Referenced by vc1_decode_reset(), and wmv2_decode_end().

◆ ff_intrax8_decode_picture()

int ff_intrax8_decode_picture ( IntraX8Context w,
MPVPicture pict,
GetBitContext gb,
int *  mb_x,
int *  mb_y,
int  quant,
int  halfpq,
int  loopfilter,
int  lowdelay 
)

Decode single IntraX8 frame.

lowres decoding is theoretically impossible.

Parameters
wpointer to IntraX8Context
pictthe output Picture containing an AVFrame
gbopen bitstream reader
mb_xpointer to the x coordinate of the current macroblock
mb_ypointer to the y coordinate of the current macroblock
dquantdoubled quantizer, it would be odd in case of VC-1 halfpq==1.
quant_offsetoffset away from zero
loopfilterenable filter after decoding a block

Definition at line 733 of file intrax8.c.

Referenced by ff_vc1_decode_blocks(), and ff_wmv2_decode_secondary_picture_header().

Variable Documentation

◆ j_ac_vlc

const VLCElem* j_ac_vlc[2][2][8]
static

Definition at line 49 of file intrax8.c.

Referenced by x8_select_ac_table(), and x8_vlc_init().

◆ j_dc_vlc

const VLCElem* j_dc_vlc[2][8]
static

Definition at line 50 of file intrax8.c.

Referenced by x8_get_dc_rlf(), and x8_vlc_init().

◆ j_orient_vlc

const VLCElem* j_orient_vlc[2][4]
static

Definition at line 51 of file intrax8.c.

Referenced by x8_get_orient_vlc(), and x8_vlc_init().

◆ ac_decode_table

const uint32_t ac_decode_table[]
static

Definition at line 125 of file intrax8.c.

Referenced by x8_get_ac_rlf().

◆ dc_index_offset

const uint8_t dc_index_offset[]
static
Initial value:
= {
0, 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
}

Definition at line 243 of file intrax8.c.

Referenced by x8_get_dc_rlf().

◆ quant_table

const int16_t quant_table[64]
static
Initial value:
= {
256, 256, 256, 256, 256, 256, 259, 262,
265, 269, 272, 275, 278, 282, 285, 288,
292, 295, 299, 303, 306, 310, 314, 317,
321, 325, 329, 333, 337, 341, 345, 349,
353, 358, 362, 366, 371, 375, 379, 384,
389, 393, 398, 403, 408, 413, 417, 422,
428, 433, 438, 443, 448, 454, 459, 465,
470, 476, 482, 488, 493, 499, 505, 511,
}

Definition at line 517 of file intrax8.c.

Referenced by decode_line(), get_context_TMPL(), read_quant_table(), read_quant_tables(), write_quant_table(), write_quant_tables(), and x8_decode_intra_mb().