FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Typedefs | Functions | Variables
ivi_common.c File Reference

This file contains functions and data shared by both Indeo4 and Indeo5 decoders. More...

#include <inttypes.h>
#include "libavutil/attributes.h"
#include "libavutil/timer.h"
#include "avcodec.h"
#include "get_bits.h"
#include "internal.h"
#include "mathops.h"
#include "ivi_common.h"
#include "ivi_dsp.h"

Go to the source code of this file.

Macros

#define BITSTREAM_READER_LE
 

Typedefs

typedef void(* ivi_mc_func )(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type)
 
typedef void(* ivi_mc_avg_func )(int16_t *buf, const int16_t *ref_buf1, const int16_t *ref_buf2, uint32_t pitch, int mc_type, int mc_type2)
 

Functions

static int ivi_mc (IVIBandDesc *band, ivi_mc_func mc, ivi_mc_avg_func mc_avg, int offs, int mv_x, int mv_y, int mv_x2, int mv_y2, int mc_type, int mc_type2)
 
static uint16_t inv_bits (uint16_t val, int nbits)
 Reverse "nbits" bits of the value "val" and return the result in the least significant bits.
 
static int ivi_create_huff_from_desc (const IVIHuffDesc *cb, VLC *vlc, int flag)
 
av_cold void ff_ivi_init_static_vlc (void)
 Initialize static codes used for macroblock and block decoding.
 
static void ivi_huff_desc_copy (IVIHuffDesc *dst, const IVIHuffDesc *src)
 
static int ivi_huff_desc_cmp (const IVIHuffDesc *desc1, const IVIHuffDesc *desc2)
 
int ff_ivi_dec_huff_desc (GetBitContext *gb, int desc_coded, int which_tab, IVIHuffTab *huff_tab, AVCodecContext *avctx)
 Decode a huffman codebook descriptor from the bitstream and select specified huffman table.
 
static av_cold void ivi_free_buffers (IVIPlaneDesc *planes)
 
av_cold int ff_ivi_init_planes (IVIPlaneDesc *planes, const IVIPicConfig *cfg, int is_indeo4)
 Initialize planes (prepares descriptors, allocates buffers etc).
 
static int ivi_init_tiles (IVIBandDesc *band, IVITile *ref_tile, int p, int b, int t_height, int t_width)
 
av_cold int ff_ivi_init_tiles (IVIPlaneDesc *planes, int tile_width, int tile_height)
 Initialize tile and macroblock descriptors.
 
static int ivi_dec_tile_data_size (GetBitContext *gb)
 
static int ivi_dc_transform (IVIBandDesc *band, int *prev_dc, int buf_offs, int blk_size)
 
static int ivi_decode_coded_blocks (GetBitContext *gb, IVIBandDesc *band, ivi_mc_func mc, ivi_mc_avg_func mc_avg, int mv_x, int mv_y, int mv_x2, int mv_y2, int *prev_dc, int is_intra, int mc_type, int mc_type2, uint32_t quant, int offs, AVCodecContext *avctx)
 
static int ivi_decode_blocks (GetBitContext *gb, IVIBandDesc *band, IVITile *tile, AVCodecContext *avctx)
 
static int ivi_process_empty_tile (AVCodecContext *avctx, IVIBandDesc *band, IVITile *tile, int32_t mv_scale)
 Handle empty tiles by performing data copying and motion compensation respectively.
 
static void ivi_output_plane (IVIPlaneDesc *plane, uint8_t *dst, int dst_pitch)
 
static int decode_band (IVI45DecContext *ctx, IVIBandDesc *band, AVCodecContext *avctx)
 Decode an Indeo 4 or 5 band.
 
int ff_ivi_decode_frame (AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
 
av_cold int ff_ivi_decode_close (AVCodecContext *avctx)
 Close Indeo5 decoder and clean up its context.
 

Variables

static const IVIHuffDesc ivi_mb_huff_desc [8]
 These are 2x8 predefined Huffman codebooks for coding macroblock/block signals.
 
static const IVIHuffDesc ivi_blk_huff_desc [8]
 static block huffman tables
 
static VLC ivi_mb_vlc_tabs [8]
 static macroblock Huffman tables
 
static VLC ivi_blk_vlc_tabs [8]
 static block Huffman tables
 
const uint8_t ff_ivi_vertical_scan_8x8 [64]
 Scan patterns shared between indeo4 and indeo5.
 
const uint8_t ff_ivi_horizontal_scan_8x8 [64]
 
const uint8_t ff_ivi_direct_scan_4x4 [16]
 
const RVMapDesc ff_ivi_rvmap_tabs [9]
 Run-value (RLE) tables.
 

Detailed Description

This file contains functions and data shared by both Indeo4 and Indeo5 decoders.

Definition in file ivi_common.c.

Macro Definition Documentation

#define BITSTREAM_READER_LE

Definition at line 31 of file ivi_common.c.

Typedef Documentation

typedef void(* ivi_mc_func)(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type)

Definition at line 74 of file ivi_common.c.

typedef void(* ivi_mc_avg_func)(int16_t *buf, const int16_t *ref_buf1, const int16_t *ref_buf2, uint32_t pitch, int mc_type, int mc_type2)

Definition at line 76 of file ivi_common.c.

Function Documentation

static int ivi_mc ( IVIBandDesc band,
ivi_mc_func  mc,
ivi_mc_avg_func  mc_avg,
int  offs,
int  mv_x,
int  mv_y,
int  mv_x2,
int  mv_y2,
int  mc_type,
int  mc_type2 
)
static

Definition at line 80 of file ivi_common.c.

Referenced by ivi_decode_blocks(), ivi_decode_coded_blocks(), and ivi_process_empty_tile().

static uint16_t inv_bits ( uint16_t  val,
int  nbits 
)
static

Reverse "nbits" bits of the value "val" and return the result in the least significant bits.

Definition at line 121 of file ivi_common.c.

Referenced by ivi_create_huff_from_desc().

static int ivi_create_huff_from_desc ( const IVIHuffDesc cb,
VLC vlc,
int  flag 
)
static

Definition at line 143 of file ivi_common.c.

Referenced by ff_ivi_dec_huff_desc(), and ff_ivi_init_static_vlc().

av_cold void ff_ivi_init_static_vlc ( void  )

Initialize static codes used for macroblock and block decoding.

Definition at line 177 of file ivi_common.c.

Referenced by decode_init().

static void ivi_huff_desc_copy ( IVIHuffDesc dst,
const IVIHuffDesc src 
)
static

Definition at line 204 of file ivi_common.c.

Referenced by ff_ivi_dec_huff_desc().

static int ivi_huff_desc_cmp ( const IVIHuffDesc desc1,
const IVIHuffDesc desc2 
)
static

Definition at line 217 of file ivi_common.c.

Referenced by ff_ivi_dec_huff_desc().

int ff_ivi_dec_huff_desc ( GetBitContext gb,
int  desc_coded,
int  which_tab,
IVIHuffTab huff_tab,
AVCodecContext avctx 
)

Decode a huffman codebook descriptor from the bitstream and select specified huffman table.

Parameters
[in,out]gbthe GetBit context
[in]desc_codedflag signalling if table descriptor was coded
[in]which_tabcodebook purpose (IVI_MB_HUFF or IVI_BLK_HUFF)
[out]huff_tabpointer to the descriptor of the selected table
[in]avctxAVCodecContext pointer
Returns
zero on success, negative value otherwise

Definition at line 224 of file ivi_common.c.

Referenced by decode_band_hdr(), and decode_pic_hdr().

static av_cold void ivi_free_buffers ( IVIPlaneDesc planes)
static

Definition at line 280 of file ivi_common.c.

Referenced by ff_ivi_decode_close(), and ff_ivi_init_planes().

av_cold int ff_ivi_init_planes ( IVIPlaneDesc planes,
const IVIPicConfig cfg,
int  is_indeo4 
)

Initialize planes (prepares descriptors, allocates buffers etc).

Parameters
[in,out]planespointer to the array of the plane descriptors
[in]cfgpointer to the ivi_pic_config structure describing picture layout
[in]is_indeo4flag signalling if it is Indeo 4 or not
Returns
result code: 0 - OK

Definition at line 303 of file ivi_common.c.

Referenced by decode_gop_header(), decode_init(), and decode_pic_hdr().

static int ivi_init_tiles ( IVIBandDesc band,
IVITile ref_tile,
int  p,
int  b,
int  t_height,
int  t_width 
)
static

Definition at line 380 of file ivi_common.c.

Referenced by ff_ivi_init_tiles().

av_cold int ff_ivi_init_tiles ( IVIPlaneDesc planes,
int  tile_width,
int  tile_height 
)

Initialize tile and macroblock descriptors.

Parameters
[in,out]planespointer to the array of the plane descriptors
[in]tile_widthtile width
[in]tile_heighttile height
Returns
result code: 0 - OK

Definition at line 419 of file ivi_common.c.

Referenced by decode_gop_header(), and decode_pic_hdr().

static int ivi_dec_tile_data_size ( GetBitContext gb)
static

Definition at line 469 of file ivi_common.c.

Referenced by decode_band().

static int ivi_dc_transform ( IVIBandDesc band,
int *  prev_dc,
int  buf_offs,
int  blk_size 
)
static

Definition at line 486 of file ivi_common.c.

Referenced by ivi_decode_blocks().

static int ivi_decode_coded_blocks ( GetBitContext gb,
IVIBandDesc band,
ivi_mc_func  mc,
ivi_mc_avg_func  mc_avg,
int  mv_x,
int  mv_y,
int  mv_x2,
int  mv_y2,
int *  prev_dc,
int  is_intra,
int  mc_type,
int  mc_type2,
uint32_t  quant,
int  offs,
AVCodecContext avctx 
)
static

Definition at line 501 of file ivi_common.c.

Referenced by ivi_decode_blocks().

static int ivi_decode_blocks ( GetBitContext gb,
IVIBandDesc band,
IVITile tile,
AVCodecContext avctx 
)
static

Definition at line 612 of file ivi_common.c.

Referenced by decode_band().

static int ivi_process_empty_tile ( AVCodecContext avctx,
IVIBandDesc band,
IVITile tile,
int32_t  mv_scale 
)
static

Handle empty tiles by performing data copying and motion compensation respectively.

Parameters
[in]avctxptr to the AVCodecContext
[in]bandpointer to the band descriptor
[in]tilepointer to the tile descriptor
[in]mv_scalescaling factor for motion vectors

Definition at line 759 of file ivi_common.c.

Referenced by decode_band().

static void ivi_output_plane ( IVIPlaneDesc plane,
uint8_t dst,
int  dst_pitch 
)
static

Definition at line 904 of file ivi_common.c.

Referenced by ff_ivi_decode_frame().

static int decode_band ( IVI45DecContext ctx,
IVIBandDesc band,
AVCodecContext avctx 
)
static

Decode an Indeo 4 or 5 band.

Parameters
[in,out]ctxptr to the decoder context
[in,out]bandptr to the band descriptor
[in]avctxptr to the AVCodecContext
Returns
result code: 0 = OK, -1 = error

Definition at line 929 of file ivi_common.c.

Referenced by ff_ivi_decode_frame().

int ff_ivi_decode_frame ( AVCodecContext avctx,
void data,
int *  got_frame,
AVPacket avpkt 
)

Definition at line 1052 of file ivi_common.c.

Referenced by ff_ivi_decode_frame().

av_cold int ff_ivi_decode_close ( AVCodecContext avctx)

Close Indeo5 decoder and clean up its context.

Definition at line 1180 of file ivi_common.c.

Variable Documentation

const IVIHuffDesc ivi_mb_huff_desc[8]
static
Initial value:
= {
{8, {0, 4, 5, 4, 4, 4, 6, 6}},
{12, {0, 2, 2, 3, 3, 3, 3, 5, 3, 2, 2, 2}},
{12, {0, 2, 3, 4, 3, 3, 3, 3, 4, 3, 2, 2}},
{12, {0, 3, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2}},
{13, {0, 4, 4, 3, 3, 3, 3, 2, 3, 3, 2, 1, 1}},
{9, {0, 4, 4, 4, 4, 3, 3, 3, 2}},
{10, {0, 4, 4, 4, 4, 3, 3, 2, 2, 2}},
{12, {0, 4, 4, 4, 3, 3, 2, 3, 2, 2, 2, 2}}
}

These are 2x8 predefined Huffman codebooks for coding macroblock/block signals.

They are specified using "huffman descriptors" in order to avoid huge static tables. The decoding tables will be generated at startup from these descriptors.static macroblock huffman tables

Definition at line 48 of file ivi_common.c.

const IVIHuffDesc ivi_blk_huff_desc[8]
static
Initial value:
= {
{10, {1, 2, 3, 4, 4, 7, 5, 5, 4, 1}},
{11, {2, 3, 4, 4, 4, 7, 5, 4, 3, 3, 2}},
{12, {2, 4, 5, 5, 5, 5, 6, 4, 4, 3, 1, 1}},
{13, {3, 3, 4, 4, 5, 6, 6, 4, 4, 3, 2, 1, 1}},
{11, {3, 4, 4, 5, 5, 5, 6, 5, 4, 2, 2}},
{13, {3, 4, 5, 5, 5, 5, 6, 4, 3, 3, 2, 1, 1}},
{13, {3, 4, 5, 5, 5, 6, 5, 4, 3, 3, 2, 1, 1}},
{9, {3, 4, 4, 5, 5, 5, 6, 5, 5}}
}

static block huffman tables

Definition at line 60 of file ivi_common.c.

VLC ivi_mb_vlc_tabs[8]
static

static macroblock Huffman tables

Definition at line 71 of file ivi_common.c.

VLC ivi_blk_vlc_tabs[8]
static

static block Huffman tables

Definition at line 72 of file ivi_common.c.

const uint8_t ff_ivi_vertical_scan_8x8[64]
Initial value:
= {
0, 8, 16, 24, 32, 40, 48, 56,
1, 9, 17, 25, 33, 41, 49, 57,
2, 10, 18, 26, 34, 42, 50, 58,
3, 11, 19, 27, 35, 43, 51, 59,
4, 12, 20, 28, 36, 44, 52, 60,
5, 13, 21, 29, 37, 45, 53, 61,
6, 14, 22, 30, 38, 46, 54, 62,
7, 15, 23, 31, 39, 47, 55, 63
}

Scan patterns shared between indeo4 and indeo5.

Common scan patterns (defined in ivi_common.c)

Definition at line 1215 of file ivi_common.c.

Referenced by decode_gop_header().

const uint8_t ff_ivi_horizontal_scan_8x8[64]
Initial value:
= {
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,
32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55,
56, 57, 58, 59, 60, 61, 62, 63
}

Definition at line 1226 of file ivi_common.c.

Referenced by decode_gop_header().

const uint8_t ff_ivi_direct_scan_4x4[16]
Initial value:
= {
0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15
}

Definition at line 1237 of file ivi_common.c.

Referenced by decode_gop_header().

const RVMapDesc ff_ivi_rvmap_tabs[9]

Run-value (RLE) tables.

Definition at line 1245 of file ivi_common.c.

Referenced by decode_init().