libavcodec/bink.c File Reference

#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "dsputil.h"
#include "binkdata.h"
#include "binkdsp.h"
#include "mathops.h"
#include "get_bits.h"

Go to the source code of this file.

Data Structures

struct  Tree
 data needed to decode 4-bit Huffman-coded value More...
struct  Bundle
 data structure used for decoding single Bink data type More...
struct  BinkContext

Defines

#define BITSTREAM_READER_LE
#define BINK_FLAG_ALPHA   0x00100000
#define BINK_FLAG_GRAY   0x00020000
#define GET_HUFF(gb, tree)
#define CHECK_READ_VAL(gb, b, t)
 common check before starting decoding bundle data
#define DC_START_BITS   11
 number of bits used to store first DC value in bundle

Enumerations

enum  OldSources {
  BINKB_SRC_BLOCK_TYPES = 0, BINKB_SRC_COLORS, BINKB_SRC_PATTERN, BINKB_SRC_X_OFF,
  BINKB_SRC_Y_OFF, BINKB_SRC_INTRA_DC, BINKB_SRC_INTER_DC, BINKB_SRC_INTRA_Q,
  BINKB_SRC_INTER_Q, BINKB_SRC_INTER_COEFS, BINKB_NB_SRC
}
 IDs for different data types used in old version of Bink video codec. More...
enum  Sources {
  BINK_SRC_BLOCK_TYPES = 0, BINK_SRC_SUB_BLOCK_TYPES, BINK_SRC_COLORS, BINK_SRC_PATTERN,
  BINK_SRC_X_OFF, BINK_SRC_Y_OFF, BINK_SRC_INTRA_DC, BINK_SRC_INTER_DC,
  BINK_SRC_RUN, BINK_NB_SRC
}
 IDs for different data types used in Bink video codec. More...
enum  BlockTypes {
  SKIP_BLOCK = 0, SCALED_BLOCK, MOTION_BLOCK, RUN_BLOCK,
  RESIDUE_BLOCK, INTRA_BLOCK, FILL_BLOCK, INTER_BLOCK,
  PATTERN_BLOCK, RAW_BLOCK
}
 Bink video block types. More...

Functions

static void init_lengths (BinkContext *c, int width, int bw)
 Initialize length length in all bundles.
static av_cold void init_bundles (BinkContext *c)
 Allocate memory for bundles.
static av_cold void free_bundles (BinkContext *c)
 Free memory used by bundles.
static void merge (GetBitContext *gb, uint8_t *dst, uint8_t *src, int size)
 Merge two consequent lists of equal size depending on bits read.
static void read_tree (GetBitContext *gb, Tree *tree)
 Read information about Huffman tree used to decode data.
static void read_bundle (GetBitContext *gb, BinkContext *c, int bundle_num)
 Prepare bundle for decoding data.
static int read_runs (AVCodecContext *avctx, GetBitContext *gb, Bundle *b)
static int read_motion_values (AVCodecContext *avctx, GetBitContext *gb, Bundle *b)
static int read_block_types (AVCodecContext *avctx, GetBitContext *gb, Bundle *b)
static int read_patterns (AVCodecContext *avctx, GetBitContext *gb, Bundle *b)
static int read_colors (GetBitContext *gb, Bundle *b, BinkContext *c)
static int read_dcs (AVCodecContext *avctx, GetBitContext *gb, Bundle *b, int start_bits, int has_sign)
static int get_value (BinkContext *c, int bundle)
 Retrieve next value from bundle.
static void binkb_init_bundle (BinkContext *c, int bundle_num)
static void binkb_init_bundles (BinkContext *c)
static int binkb_read_bundle (BinkContext *c, GetBitContext *gb, int bundle_num)
static int binkb_get_value (BinkContext *c, int bundle_num)
static int read_dct_coeffs (GetBitContext *gb, int32_t block[64], const uint8_t *scan, const int32_t quant_matrices[16][64], int q)
 Read 8x8 block of DCT coefficients.
static int read_residue (GetBitContext *gb, DCTELEM block[64], int masks_count)
 Read 8x8 block with residue after motion compensation.
static void put_pixels8x8_overlapped (uint8_t *dst, uint8_t *src, int stride)
 Copy 8x8 block from source to destination, where src and dst may be overlapped.
static int binkb_decode_plane (BinkContext *c, GetBitContext *gb, int plane_idx, int is_key, int is_chroma)
static int bink_decode_plane (BinkContext *c, GetBitContext *gb, int plane_idx, int is_chroma)
static int decode_frame (AVCodecContext *avctx, void *data, int *data_size, AVPacket *pkt)
static av_cold void binkb_calc_quant (void)
 Caclulate quantization tables for version b.
static av_cold int decode_init (AVCodecContext *avctx)
static av_cold int decode_end (AVCodecContext *avctx)

Variables

static VLC bink_trees [16]
static const int binkb_bundle_sizes [BINKB_NB_SRC]
static const int binkb_bundle_signed [BINKB_NB_SRC]
static int32_t binkb_intra_quant [16][64]
static int32_t binkb_inter_quant [16][64]
static const uint8_t bink_rlelens [4] = { 4, 8, 12, 32 }
AVCodec ff_bink_decoder


Define Documentation

#define BINK_FLAG_ALPHA   0x00100000

Definition at line 33 of file bink.c.

Referenced by decode_init().

#define BINK_FLAG_GRAY   0x00020000

Definition at line 34 of file bink.c.

#define BITSTREAM_READER_LE

Definition at line 30 of file bink.c.

#define CHECK_READ_VAL ( gb,
b,
t   ) 

Value:

if (!b->cur_dec || (b->cur_dec > b->cur_ptr)) \
        return 0; \
    t = get_bits(gb, b->len); \
    if (!t) { \
        b->cur_dec = NULL; \
        return 0; \
    } \
common check before starting decoding bundle data

Parameters:
gb context for reading bits
b bundle
t variable where number of elements to decode will be stored

Definition at line 296 of file bink.c.

Referenced by binkb_read_bundle(), read_block_types(), read_colors(), read_dcs(), read_motion_values(), read_patterns(), and read_runs().

#define DC_START_BITS   11

number of bits used to store first DC value in bundle

Definition at line 455 of file bink.c.

Referenced by bink_decode_plane().

#define GET_HUFF ( gb,
tree   ) 

Value:

(tree).syms[get_vlc2(gb, bink_trees[(tree).vlc_num].table,\
                                                 bink_trees[(tree).vlc_num].bits, 1)]

Definition at line 92 of file bink.c.

Referenced by read_block_types(), read_colors(), read_motion_values(), read_patterns(), and read_runs().


Enumeration Type Documentation

enum BlockTypes

Bink video block types.

Enumerator:
SKIP_BLOCK  skipped block
SCALED_BLOCK  block has size 16x16
MOTION_BLOCK  block is copied from previous frame with some offset
RUN_BLOCK  block is composed from runs of colours with custom scan order
RESIDUE_BLOCK  motion block with some difference added
INTRA_BLOCK  intra DCT block
FILL_BLOCK  block is filled with single colour
INTER_BLOCK  motion block with DCT applied to the difference
PATTERN_BLOCK  block is filled with two colours following custom pattern
RAW_BLOCK  uncoded 8x8 block

Definition at line 127 of file bink.c.

enum OldSources

IDs for different data types used in old version of Bink video codec.

Enumerator:
BINKB_SRC_BLOCK_TYPES  8x8 block types
BINKB_SRC_COLORS  pixel values used for different block types
BINKB_SRC_PATTERN  8-bit values for 2-colour pattern fill
BINKB_SRC_X_OFF  X components of motion value.
BINKB_SRC_Y_OFF  Y components of motion value.
BINKB_SRC_INTRA_DC  DC values for intrablocks with DCT.
BINKB_SRC_INTER_DC  DC values for interblocks with DCT.
BINKB_SRC_INTRA_Q  quantizer values for intrablocks with DCT
BINKB_SRC_INTER_Q  quantizer values for interblocks with DCT
BINKB_SRC_INTER_COEFS  number of coefficients for residue blocks
BINKB_NB_SRC 

Definition at line 41 of file bink.c.

enum Sources

IDs for different data types used in Bink video codec.

Enumerator:
BINK_SRC_BLOCK_TYPES  8x8 block types
BINK_SRC_SUB_BLOCK_TYPES  16x16 block types (a subset of 8x8 block types)
BINK_SRC_COLORS  pixel values used for different block types
BINK_SRC_PATTERN  8-bit values for 2-colour pattern fill
BINK_SRC_X_OFF  X components of motion value.
BINK_SRC_Y_OFF  Y components of motion value.
BINK_SRC_INTRA_DC  DC values for intrablocks with DCT.
BINK_SRC_INTER_DC  DC values for interblocks with DCT.
BINK_SRC_RUN  run lengths for special fill block
BINK_NB_SRC 

Definition at line 70 of file bink.c.


Function Documentation

static int bink_decode_plane ( BinkContext c,
GetBitContext gb,
int  plane_idx,
int  is_chroma 
) [static]

Definition at line 938 of file bink.c.

Referenced by decode_frame().

static av_cold void binkb_calc_quant ( void   )  [static]

Caclulate quantization tables for version b.

Definition at line 1222 of file bink.c.

Referenced by decode_init().

static int binkb_decode_plane ( BinkContext c,
GetBitContext gb,
int  plane_idx,
int  is_key,
int  is_chroma 
) [static]

Definition at line 792 of file bink.c.

Referenced by decode_frame().

static int binkb_get_value ( BinkContext c,
int  bundle_num 
) [inline, static]

Definition at line 570 of file bink.c.

Referenced by binkb_decode_plane().

static void binkb_init_bundle ( BinkContext c,
int  bundle_num 
) [static]

Definition at line 522 of file bink.c.

Referenced by binkb_init_bundles().

static void binkb_init_bundles ( BinkContext c  )  [static]

Definition at line 529 of file bink.c.

Referenced by binkb_decode_plane().

static int binkb_read_bundle ( BinkContext c,
GetBitContext gb,
int  bundle_num 
) [static]

Definition at line 536 of file bink.c.

Referenced by binkb_decode_plane().

static av_cold int decode_end ( AVCodecContext avctx  )  [static]

Definition at line 1316 of file bink.c.

static int decode_frame ( AVCodecContext avctx,
void *  data,
int *  data_size,
AVPacket pkt 
) [static]

Definition at line 1162 of file bink.c.

static av_cold int decode_init ( AVCodecContext avctx  )  [static]

Definition at line 1264 of file bink.c.

static av_cold void free_bundles ( BinkContext c  )  [static]

Free memory used by bundles.

Parameters:
c decoder context

Definition at line 190 of file bink.c.

Referenced by decode_end().

static int get_value ( BinkContext c,
int  bundle 
) [inline, static]

Retrieve next value from bundle.

Parameters:
c decoder context
bundle bundle number

Definition at line 509 of file bink.c.

Referenced by asf_read_ext_content_desc(), bink_decode_plane(), and get_tag().

static av_cold void init_bundles ( BinkContext c  )  [static]

Allocate memory for bundles.

Parameters:
c decoder context

Definition at line 170 of file bink.c.

Referenced by decode_init().

static void init_lengths ( BinkContext c,
int  width,
int  bw 
) [static]

Initialize length length in all bundles.

Parameters:
c decoder context
width plane width
bw plane width in 8x8 blocks

Definition at line 147 of file bink.c.

Referenced by bink_decode_plane().

static void merge ( GetBitContext gb,
uint8_t *  dst,
uint8_t *  src,
int  size 
) [static]

Merge two consequent lists of equal size depending on bits read.

Parameters:
gb context for reading bits
dst buffer where merged list will be written to
src pointer to the head of the first list (the second lists starts at src+size)
size input lists size

Definition at line 205 of file bink.c.

Referenced by read_tree().

static void put_pixels8x8_overlapped ( uint8_t *  dst,
uint8_t *  src,
int  stride 
) [inline, static]

Copy 8x8 block from source to destination, where src and dst may be overlapped.

Definition at line 782 of file bink.c.

Referenced by binkb_decode_plane().

static int read_block_types ( AVCodecContext avctx,
GetBitContext gb,
Bundle b 
) [static]

Definition at line 361 of file bink.c.

Referenced by bink_decode_plane().

static void read_bundle ( GetBitContext gb,
BinkContext c,
int  bundle_num 
) [static]

Prepare bundle for decoding data.

Parameters:
gb context for reading bits
c decoder context
bundle_num number of the bundle to initialize

Definition at line 274 of file bink.c.

Referenced by bink_decode_plane().

static int read_colors ( GetBitContext gb,
Bundle b,
BinkContext c 
) [static]

Definition at line 416 of file bink.c.

Referenced by bink_decode_plane().

static int read_dcs ( AVCodecContext avctx,
GetBitContext gb,
Bundle b,
int  start_bits,
int  has_sign 
) [static]

Definition at line 457 of file bink.c.

Referenced by bink_decode_plane().

static int read_dct_coeffs ( GetBitContext gb,
int32_t  block[64],
const uint8_t *  scan,
const int32_t  quant_matrices[16][64],
int  q 
) [static]

Read 8x8 block of DCT coefficients.

Parameters:
gb context for reading bits
block place for storing coefficients
scan scan order table
quant_matrices quantization matrices
Returns:
0 for success, negative value in other cases

Definition at line 593 of file bink.c.

Referenced by bink_decode_plane(), and binkb_decode_plane().

static int read_motion_values ( AVCodecContext avctx,
GetBitContext gb,
Bundle b 
) [static]

Definition at line 327 of file bink.c.

Referenced by bink_decode_plane().

static int read_patterns ( AVCodecContext avctx,
GetBitContext gb,
Bundle b 
) [static]

Definition at line 396 of file bink.c.

Referenced by bink_decode_plane().

static int read_residue ( GetBitContext gb,
DCTELEM  block[64],
int  masks_count 
) [static]

Read 8x8 block with residue after motion compensation.

Parameters:
gb context for reading bits
block place to store read data
masks_count number of masks to decode
Returns:
0 on success, negative value in other cases

Definition at line 697 of file bink.c.

Referenced by bink_decode_plane(), and binkb_decode_plane().

static int read_runs ( AVCodecContext avctx,
GetBitContext gb,
Bundle b 
) [static]

Definition at line 305 of file bink.c.

Referenced by bink_decode_plane().

static void read_tree ( GetBitContext gb,
Tree tree 
) [static]

Read information about Huffman tree used to decode data.

Parameters:
gb context for reading bits
tree pointer for storing tree data

Definition at line 232 of file bink.c.

Referenced by read_bundle().


Variable Documentation

const uint8_t bink_rlelens[4] = { 4, 8, 12, 32 } [static]

Definition at line 359 of file bink.c.

Referenced by read_block_types().

VLC bink_trees[16] [static]

Definition at line 36 of file bink.c.

const int binkb_bundle_signed[BINKB_NB_SRC] [static]

Initial value:

 {
    0, 0, 0, 1, 1, 0, 1, 0, 0, 0
}

Definition at line 60 of file bink.c.

Referenced by binkb_get_value(), and binkb_read_bundle().

const int binkb_bundle_sizes[BINKB_NB_SRC] [static]

Initial value:

 {
    4, 8, 8, 5, 5, 11, 11, 4, 4, 7
}

Definition at line 56 of file bink.c.

Referenced by binkb_get_value(), and binkb_read_bundle().

int32_t binkb_inter_quant[16][64] [static]

Definition at line 65 of file bink.c.

Referenced by binkb_calc_quant(), and binkb_decode_plane().

int32_t binkb_intra_quant[16][64] [static]

Definition at line 64 of file bink.c.

Referenced by binkb_calc_quant(), and binkb_decode_plane().

Initial value:

 {
    .name           = "binkvideo",
    .type           = AVMEDIA_TYPE_VIDEO,
    .id             = CODEC_ID_BINKVIDEO,
    .priv_data_size = sizeof(BinkContext),
    .init           = decode_init,
    .close          = decode_end,
    .decode         = decode_frame,
    .long_name = NULL_IF_CONFIG_SMALL("Bink video"),
}

Definition at line 1329 of file bink.c.


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