hvirtual/quicktime/ffmpeg/libavcodec/vc9.c File Reference

#include "common.h"
#include "dsputil.h"
#include "avcodec.h"
#include "mpegvideo.h"
#include "vc9data.h"
#include <assert.h>

Include dependency graph for vc9.c:

Go to the source code of this file.

Data Structures

struct  BitPlane
struct  VC9Context

VC-9 VLC tables and defines

Todo:
TODO move this into the context


#define VC9_BFRACTION_VLC_BITS   7
#define VC9_IMODE_VLC_BITS   4
#define VC9_NORM2_VLC_BITS   3
#define VC9_NORM6_VLC_BITS   9
#define VC9_TTMB_VLC_BITS   9
#define VC9_MV_DIFF_VLC_BITS   9
#define VC9_CBPCY_P_VLC_BITS   9
#define VC9_4MV_BLOCK_PATTERN_VLC_BITS   6
#define VC9_TTBLK_VLC_BITS   5
#define VC9_SUBBLKPAT_VLC_BITS   6
static VLC vc9_bfraction_vlc
static VLC vc9_imode_vlc
static VLC vc9_norm2_vlc
static VLC vc9_norm6_vlc
static VLC vc9_ttmb_vlc [3]
static VLC vc9_mv_diff_vlc [4]
static VLC vc9_cbpcy_p_vlc [4]
static VLC vc9_4mv_block_pattern_vlc [4]
static VLC vc9_ttblk_vlc [3]
static VLC vc9_subblkpat_vlc [3]

Defines

#define MB_INTRA_VLC_BITS   9
#define DC_VLC_BITS   9
#define HAS_ADVANCED_PROFILE   0
#define TRACE   1
#define INIT_VLC(vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, use_static)
#define BI_TYPE   7
#define IMODE_RAW   0
#define IMODE_NORM2   1
#define IMODE_DIFF2   2
#define IMODE_NORM6   3
#define IMODE_DIFF6   4
#define IMODE_ROWSKIP   5
#define IMODE_COLSKIP   6
#define GET_MQUANT()
 Get macroblock-level quantizer scale.
#define GET_MVDATA(_dmv_x, _dmv_y)
 Get MV differentials.
#define PROFILE_SIMPLE   0
#define PROFILE_MAIN   1
#define PROFILE_COMPLEX   2
 TODO: WMV9 specific.
#define PROFILE_ADVANCED   3
#define QUANT_FRAME_IMPLICIT   0
 Implicitly specified at frame level.
#define QUANT_FRAME_EXPLICIT   1
 Explicitly specified at frame level.
#define QUANT_NON_UNIFORM   2
 Non-uniform quant used for all frames.
#define QUANT_UNIFORM   3
 Uniform quant used for all frames.
Where quant can be changed
#define DQPROFILE_FOUR_EDGES   0
#define DQPROFILE_FOUR_EDGES   0
#define DQSINGLE_BEDGE_LEFT   0
#define DQSINGLE_BEDGE_TOP   1
#define DQSINGLE_BEDGE_RIGHT   2
#define DQSINGLE_BEDGE_BOTTOM   3
#define DQPROFILE_DOUBLE_EDGES   1
#define DQPROFILE_SINGLE_EDGE   2
#define DQPROFILE_ALL_MBS   3
#define DQDOUBLE_BEDGE_TOPLEFT   0
#define DQDOUBLE_BEDGE_TOPRIGHT   1
#define DQDOUBLE_BEDGE_BOTTOMRIGHT   2
#define DQDOUBLE_BEDGE_BOTTOMLEFT   3
#define MV_PMODE_1MV_HPEL_BILIN   0
#define MV_PMODE_1MV   1
#define MV_PMODE_1MV_HPEL   2
#define MV_PMODE_MIXED_MV   3
#define MV_PMODE_INTENSITY_COMP   4
MV types for B frames


#define BMV_TYPE_BACKWARD   0
#define BMV_TYPE_BACKWARD   0
#define BMV_TYPE_FORWARD   1
#define BMV_TYPE_INTERPOLATED   3

Functions

static int get_prefix (GetBitContext *gb, int stop, int len)
static int vc9_init_common (VC9Context *v)
static int decode_sequence_header (AVCodecContext *avctx, GetBitContext *gb)
int alloc_bitplane (BitPlane *bp, int width, int height)
void free_bitplane (BitPlane *bp)
static void decode_rowskip (uint8_t *plane, int width, int height, int stride, GetBitContext *gb)
static void decode_colskip (uint8_t *plane, int width, int height, int stride, GetBitContext *gb)
static int bitplane_decoding (BitPlane *bp, VC9Context *v)
static int vop_dquant_decoding (VC9Context *v)
static int decode_b_picture_primary_header (VC9Context *v)
static int decode_b_picture_secondary_header (VC9Context *v)
static int decode_i_picture_primary_header (VC9Context *v)
static int decode_i_picture_secondary_header (VC9Context *v)
static int decode_p_picture_primary_header (VC9Context *v)
static int decode_p_picture_secondary_header (VC9Context *v)
static int standard_decode_picture_primary_header (VC9Context *v)
static int standard_decode_picture_secondary_header (VC9Context *v)
static int vc9_pred_dc (MpegEncContext *s, int n, uint16_t **dc_val_ptr, int *dir_ptr)
int vc9_decode_block (VC9Context *v, DCTELEM block[64], int n, int coded, int mquant)
static int vc9_coded_block_pred (MpegEncContext *s, int n, uint8_t **coded_block_ptr)
int vc9_decode_i_mb (VC9Context *v, DCTELEM block[6][64])
int vc9_decode_p_mb (VC9Context *v, DCTELEM block[6][64])
int vc9_decode_b_mb (VC9Context *v, DCTELEM block[6][64])
static int standard_decode_mbs (VC9Context *v)
static int vc9_decode_init (AVCodecContext *avctx)
static int vc9_decode_frame (AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size)
static int vc9_decode_end (AVCodecContext *avctx)

Variables

const uint32_t ff_table0_dc_lum [120][2]
const uint32_t ff_table1_dc_lum [120][2]
const uint32_t ff_table0_dc_chroma [120][2]
const uint32_t ff_table1_dc_chroma [120][2]
VLC ff_msmp4_dc_luma_vlc [2]
VLC ff_msmp4_dc_chroma_vlc [2]
VLC ff_msmp4_mb_i_vlc
static const uint16_t table_mb_intra [64][2]
static const uint8_t mv_pmode_table [2][5]
static const int fps_nr [5] = { 24, 25, 30, 50, 60 }
static const int fps_dr [2] = { 1000, 1001 }
static const uint8_t pquant_table [3][32]
AVCodec vc9_decoder
AVCodec wmv3_decoder


Detailed Description

VC-9 and WMV3 decoder

TODO: most AP stuff, optimize, most of MB layer, transform, filtering and motion compensation, etc TODO: use MPV_ !!

Definition in file vc9.c.


Define Documentation

#define BI_TYPE   7

#define BMV_TYPE_BACKWARD   0

Definition at line 121 of file vc9.c.

#define BMV_TYPE_BACKWARD   0

Definition at line 121 of file vc9.c.

Referenced by vc9_decode_b_mb().

#define BMV_TYPE_FORWARD   1

Definition at line 122 of file vc9.c.

#define BMV_TYPE_INTERPOLATED   3

Definition at line 123 of file vc9.c.

Referenced by vc9_decode_b_mb().

#define DC_VLC_BITS   9

Definition at line 44 of file vc9.c.

#define DQDOUBLE_BEDGE_BOTTOMLEFT   3

Definition at line 106 of file vc9.c.

#define DQDOUBLE_BEDGE_BOTTOMRIGHT   2

Definition at line 105 of file vc9.c.

#define DQDOUBLE_BEDGE_TOPLEFT   0

Which pair of edges is quantized with ALTPQUANT

Definition at line 103 of file vc9.c.

#define DQDOUBLE_BEDGE_TOPRIGHT   1

Definition at line 104 of file vc9.c.

#define DQPROFILE_ALL_MBS   3

Definition at line 88 of file vc9.c.

Referenced by vop_dquant_decoding().

#define DQPROFILE_DOUBLE_EDGES   1

Definition at line 86 of file vc9.c.

Referenced by vop_dquant_decoding().

#define DQPROFILE_FOUR_EDGES   0

Where quant can be changed

Definition at line 94 of file vc9.c.

#define DQPROFILE_FOUR_EDGES   0

Where quant can be changed

Definition at line 94 of file vc9.c.

#define DQPROFILE_SINGLE_EDGE   2

Definition at line 87 of file vc9.c.

Referenced by vop_dquant_decoding().

#define DQSINGLE_BEDGE_BOTTOM   3

Definition at line 98 of file vc9.c.

#define DQSINGLE_BEDGE_LEFT   0

Definition at line 95 of file vc9.c.

#define DQSINGLE_BEDGE_RIGHT   2

Definition at line 97 of file vc9.c.

#define DQSINGLE_BEDGE_TOP   1

Definition at line 96 of file vc9.c.

#define HAS_ADVANCED_PROFILE   0

Definition at line 48 of file vc9.c.

#define INIT_VLC ( vlc,
nb_bits,
nb_codes,
bits,
bits_wrap,
bits_size,
codes,
codes_wrap,
codes_size,
use_static   ) 

Value:

if (init_vlc(vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size,     \
               codes, codes_wrap, codes_size, use_static) < 0)         \
  {                                                                    \
    av_log(v->s.avctx, AV_LOG_ERROR, "Error for " # vlc " (%i)\n", i);   \
    return -1;                                                         \
  }

Definition at line 53 of file vc9.c.

Referenced by vc9_init_common().

#define MB_INTRA_VLC_BITS   9

Definition at line 42 of file vc9.c.

#define MV_PMODE_1MV   1

Definition at line 112 of file vc9.c.

Referenced by vc9_decode_p_mb().

#define MV_PMODE_1MV_HPEL   2

Definition at line 113 of file vc9.c.

#define MV_PMODE_1MV_HPEL_BILIN   0

MV modes for P frames

Definition at line 111 of file vc9.c.

#define MV_PMODE_INTENSITY_COMP   4

Definition at line 115 of file vc9.c.

Referenced by decode_p_picture_primary_header(), and decode_p_picture_secondary_header().

#define MV_PMODE_MIXED_MV   3

#define PROFILE_ADVANCED   3

#define PROFILE_COMPLEX   2

TODO: WMV9 specific.

Definition at line 71 of file vc9.c.

#define PROFILE_MAIN   1

Definition at line 70 of file vc9.c.

#define PROFILE_SIMPLE   0

Available Profiles

Definition at line 69 of file vc9.c.

Referenced by decode_b_picture_primary_header(), and decode_sequence_header().

#define QUANT_FRAME_EXPLICIT   1

Explicitly specified at frame level.

Definition at line 78 of file vc9.c.

Referenced by decode_b_picture_primary_header(), decode_i_picture_primary_header(), and decode_p_picture_primary_header().

#define QUANT_FRAME_IMPLICIT   0

Implicitly specified at frame level.

Sequence quantizer mode

Definition at line 77 of file vc9.c.

Referenced by decode_b_picture_primary_header(), decode_i_picture_primary_header(), and decode_p_picture_primary_header().

#define QUANT_NON_UNIFORM   2

Non-uniform quant used for all frames.

Definition at line 79 of file vc9.c.

#define QUANT_UNIFORM   3

Uniform quant used for all frames.

Definition at line 80 of file vc9.c.

#define TRACE   1

Definition at line 49 of file vc9.c.

#define VC9_4MV_BLOCK_PATTERN_VLC_BITS   6

Definition at line 171 of file vc9.c.

Referenced by vc9_init_common().

#define VC9_BFRACTION_VLC_BITS   7

Definition at line 156 of file vc9.c.

Referenced by decode_b_picture_primary_header(), and vc9_init_common().

#define VC9_CBPCY_P_VLC_BITS   9

Definition at line 169 of file vc9.c.

Referenced by vc9_decode_p_mb(), and vc9_init_common().

#define VC9_IMODE_VLC_BITS   4

Definition at line 158 of file vc9.c.

Referenced by bitplane_decoding(), and vc9_init_common().

#define VC9_MV_DIFF_VLC_BITS   9

Definition at line 167 of file vc9.c.

Referenced by vc9_init_common().

#define VC9_NORM2_VLC_BITS   3

Definition at line 160 of file vc9.c.

Referenced by bitplane_decoding(), and vc9_init_common().

#define VC9_NORM6_VLC_BITS   9

Definition at line 162 of file vc9.c.

Referenced by bitplane_decoding(), and vc9_init_common().

#define VC9_SUBBLKPAT_VLC_BITS   6

Definition at line 175 of file vc9.c.

Referenced by vc9_decode_block(), and vc9_init_common().

#define VC9_TTBLK_VLC_BITS   5

Definition at line 173 of file vc9.c.

Referenced by vc9_decode_block(), and vc9_init_common().

#define VC9_TTMB_VLC_BITS   9

Definition at line 165 of file vc9.c.

Referenced by vc9_decode_b_mb(), vc9_decode_p_mb(), and vc9_init_common().


Function Documentation

static int decode_sequence_header ( AVCodecContext avctx,
GetBitContext gb 
) [static]

static int get_prefix ( GetBitContext gb,
int  stop,
int  len 
) [static]

Get unary code of limited length FIXME Slow and ugly

Parameters:
gb GetBitContext
[in] stop The bitstop value (unary code of 1's or 0's)
[in] len Maximum length
Returns:
Unary length/index

Definition at line 341 of file vc9.c.

References buf, CLOSE_READER, get_bits(), GET_CACHE, LAST_SKIP_BITS, OPEN_READER, and UPDATE_CACHE.

Referenced by decode_b_picture_primary_header(), and decode_p_picture_primary_header().

Here is the call graph for this function:

static int vc9_decode_end ( AVCodecContext avctx  )  [static]

Close a VC9/WMV3 decoder

Warning:
Initial try at using MpegEncContext stuff

Definition at line 2637 of file vc9.c.

References av_freep(), VC9Context::direct_mb_plane, free_bitplane(), MPV_common_end(), VC9Context::mv_type_mb_plane, AVCodecContext::priv_data, VC9Context::s, and VC9Context::skip_mb_plane.

Here is the call graph for this function:

static int vc9_decode_frame ( AVCodecContext avctx,
void *  data,
int *  data_size,
uint8_t *  buf,
int  buf_size 
) [static]

Decode a VC9/WMV3 frame

Todo:
TODO: Handle VC-9 IDUs (Transport level?)
Warning:
Initial try at using MpegEncContext stuff

Definition at line 2423 of file vc9.c.

References av_log(), AV_LOG_DEBUG, AV_LOG_ERROR, av_mallocz(), MpegEncContext::avctx, avpicture_fill(), avpicture_get_size(), B_TYPE, BI_TYPE, MpegEncContext::bitstream_buffer_size, AVCodecContext::codec_id, CODEC_ID_VC9, MpegEncContext::context_initialized, MpegEncContext::current_picture, MpegEncContext::current_picture_ptr, decode_sequence_header(), MpegEncContext::dropable, ff_er_frame_end(), ff_er_frame_start(), ff_find_unused_picture(), ff_print_debug_info(), AVCodecContext::flags, MpegEncContext::flags, AVCodecContext::flags2, MpegEncContext::flags2, AVCodecContext::frame_number, FRAME_SKIPPED, MpegEncContext::gb, get_bits_count(), AVCodecContext::height, AVCodecContext::hurry_up, I_TYPE, init_get_bits(), MpegEncContext::last_picture, MpegEncContext::last_picture_ptr, MpegEncContext::low_delay, MPV_common_init(), MPV_frame_end(), MPV_frame_start(), VC9Context::multires, MpegEncContext::next_p_frame_damaged, MpegEncContext::next_picture_ptr, NULL, P_TYPE, MpegEncContext::pict_type, MpegEncContext::picture, MpegEncContext::picture_number, AVCodecContext::pix_fmt, AVCodecContext::priv_data, VC9Context::profile, PROFILE_ADVANCED, VC9Context::s, standard_decode_mbs(), standard_decode_picture_primary_header(), standard_decode_picture_secondary_header(), and AVCodecContext::width.

Here is the call graph for this function:

static int vc9_decode_init ( AVCodecContext avctx  )  [static]

static int vc9_init_common ( VC9Context v  )  [static]

static int vop_dquant_decoding ( VC9Context v  )  [static]


Variable Documentation

Definition at line 1044 of file msmpeg4.c.

Definition at line 1043 of file msmpeg4.c.

Definition at line 1042 of file msmpeg4.c.

Referenced by wmv2_decode_mb().

const uint32_t ff_table0_dc_chroma[120][2]

Definition at line 97 of file msmpeg4data.h.

Referenced by ff_msmpeg4_decode_init(), and msmpeg4_encode_dc().

const uint32_t ff_table0_dc_lum[120][2]

Definition at line 64 of file msmpeg4data.h.

Referenced by ff_msmpeg4_decode_init(), and msmpeg4_encode_dc().

const uint32_t ff_table1_dc_chroma[120][2]

Definition at line 165 of file msmpeg4data.h.

Referenced by ff_msmpeg4_decode_init(), and msmpeg4_encode_dc().

const uint32_t ff_table1_dc_lum[120][2]

Definition at line 132 of file msmpeg4data.h.

Referenced by ff_msmpeg4_decode_init(), and msmpeg4_encode_dc().

const int fps_dr[2] = { 1000, 1001 } [static]

Definition at line 136 of file vc9.c.

const int fps_nr[5] = { 24, 25, 30, 50, 60 } [static]

Definition at line 135 of file vc9.c.

const uint8_t mv_pmode_table[2][5] [static]

const uint8_t pquant_table[3][32] [static]

Initial value:

 {
  {  
     0,  1,  2,  3,  4,  5,  6,  7,  8,  6,  7,  8,  9, 10, 11, 12,
    13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 29, 31
  },
  {  
     0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
    16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
  },
  {  
     0,  1,  1,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13,
    14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 29, 31
  }
}

Definition at line 137 of file vc9.c.

Referenced by decode_b_picture_primary_header(), decode_i_picture_primary_header(), and decode_p_picture_primary_header().

const uint16_t table_mb_intra[64][2] [static]

Definition at line 45 of file vc9.c.

Definition at line 172 of file vc9.c.

Definition at line 157 of file vc9.c.

VLC vc9_cbpcy_p_vlc[4] [static]

Definition at line 170 of file vc9.c.

Initial value:

Definition at line 2652 of file vc9.c.

Referenced by avcodec_register_all().

VLC vc9_imode_vlc [static]

Definition at line 159 of file vc9.c.

VLC vc9_mv_diff_vlc[4] [static]

Definition at line 168 of file vc9.c.

VLC vc9_norm2_vlc [static]

Definition at line 161 of file vc9.c.

VLC vc9_norm6_vlc [static]

Definition at line 163 of file vc9.c.

VLC vc9_subblkpat_vlc[3] [static]

Definition at line 176 of file vc9.c.

VLC vc9_ttblk_vlc[3] [static]

Definition at line 174 of file vc9.c.

VLC vc9_ttmb_vlc[3] [static]

Definition at line 166 of file vc9.c.