1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

Merge remote-tracking branch 'qatar/master'

* qatar/master: (34 commits)
  h264: reset h->ref_count in case of errors in ff_h264_decode_ref_pic_list_reordering()
  error_resilience: fix the check for missing references in ff_er_frame_end() for H264
  4xm: prevent NULL dereference with invalid huffman table
  4xmdemux: prevent use of uninitialized memory
  4xm: clear FF_INPUT_BUFFER_PADDING_SIZE bytes in temporary buffers
  ptx: check for out of bound reads
  tiffdec: fix out of bound reads/writes
  eacmv: check for out of bound reads
  eacmv: fix potential pointer arithmetic overflows
  adpcm: fix out of bound reads due to integer overflow
  anm: prevent infinite loop
  avsdemux: check for out of bound writes
  avs: check for out of bound reads
  avsdemux: check for corrupted data
  AVOptions: refactor set_number/write_number
  AVOptions: cosmetics, rename static av_set_number2() to write_number().
  AVOptions: cosmetics, move and rename static av_set_number().
  AVOptions: split av_set_string3 into opt type-specific functions
  avidec: fix signed overflow in avi_sync()
  mxfdec: Fix some buffer overreads caused by the misuse of AVPacket related functions.
  ...

Conflicts:
	Changelog
	configure
	libavcodec/ptx.c
	libavcodec/ra144.c
	libavcodec/vaapi_vc1.c
	libavcodec/vc1.c
	libavcodec/version.h
	libavformat/4xm.c
	libavformat/avidec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2011-10-11 02:39:50 +02:00
commit 41f55277fa
18 changed files with 3272 additions and 848 deletions

View File

@ -62,6 +62,7 @@ easier to use. The changes are:
- CELT in Ogg demuxing - CELT in Ogg demuxing
- G.723.1 demuxer and decoder - G.723.1 demuxer and decoder
- libmodplug support (--enable-libmodplug) - libmodplug support (--enable-libmodplug)
- VC-1 interlaced decoding
version 0.8: version 0.8:

1
configure vendored
View File

@ -3163,6 +3163,7 @@ check_cflags -Wtype-limits
check_cflags -Wundef check_cflags -Wundef
check_cflags -Wmissing-prototypes check_cflags -Wmissing-prototypes
check_cflags -Wno-pointer-to-int-cast check_cflags -Wno-pointer-to-int-cast
check_cflags -Wstrict-prototypes
enabled extra_warnings && check_cflags -Winline enabled extra_warnings && check_cflags -Winline
# add some linker flags # add some linker flags

View File

@ -60,7 +60,6 @@ static int ptx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
avctx->pix_fmt = PIX_FMT_RGB555; avctx->pix_fmt = PIX_FMT_RGB555;
if (buf_end - buf < offset) if (buf_end - buf < offset)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
if (offset != 0x2c) if (offset != 0x2c)

View File

@ -1544,22 +1544,22 @@ void ff_copy_and_dup(int16_t *target, const int16_t *source, int offset)
int ff_eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx) int ff_eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx)
{ {
int b, i, j; int b, i, j;
int buffer1[10]; int buffer1[LPC_ORDER];
int buffer2[10]; int buffer2[LPC_ORDER];
int *bp1 = buffer1; int *bp1 = buffer1;
int *bp2 = buffer2; int *bp2 = buffer2;
for (i=0; i < 10; i++) for (i=0; i < LPC_ORDER; i++)
buffer2[i] = coefs[i]; buffer2[i] = coefs[i];
refl[9] = bp2[9]; refl[LPC_ORDER-1] = bp2[LPC_ORDER-1];
if ((unsigned) bp2[9] + 0x1000 > 0x1fff) { if ((unsigned) bp2[LPC_ORDER-1] + 0x1000 > 0x1fff) {
av_log(avctx, AV_LOG_ERROR, "Overflow. Broken sample?\n"); av_log(avctx, AV_LOG_ERROR, "Overflow. Broken sample?\n");
return 1; return 1;
} }
for (i=8; i >= 0; i--) { for (i = LPC_ORDER-2; i >= 0; i--) {
b = 0x1000-((bp2[i+1] * bp2[i+1]) >> 12); b = 0x1000-((bp2[i+1] * bp2[i+1]) >> 12);
if (!b) if (!b)
@ -1584,12 +1584,12 @@ int ff_eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx)
*/ */
void ff_eval_coefs(int *coefs, const int *refl) void ff_eval_coefs(int *coefs, const int *refl)
{ {
int buffer[10]; int buffer[LPC_ORDER];
int *b1 = buffer; int *b1 = buffer;
int *b2 = coefs; int *b2 = coefs;
int i, j; int i, j;
for (i=0; i < 10; i++) { for (i=0; i < LPC_ORDER; i++) {
b1[i] = refl[i] << 4; b1[i] = refl[i] << 4;
for (j=0; j < i; j++) for (j=0; j < i; j++)
@ -1598,7 +1598,7 @@ void ff_eval_coefs(int *coefs, const int *refl)
FFSWAP(int *, b1, b2); FFSWAP(int *, b1, b2);
} }
for (i=0; i < 10; i++) for (i=0; i < LPC_ORDER; i++)
coefs[i] >>= 4; coefs[i] >>= 4;
} }
@ -1606,7 +1606,7 @@ void ff_int_to_int16(int16_t *out, const int *inp)
{ {
int i; int i;
for (i=0; i < 10; i++) for (i = 0; i < LPC_ORDER; i++)
*out++ = *inp++; *out++ = *inp++;
} }
@ -1629,9 +1629,9 @@ unsigned int ff_rms(const int *data)
{ {
int i; int i;
unsigned int res = 0x10000; unsigned int res = 0x10000;
int b = 10; int b = LPC_ORDER;
for (i=0; i < 10; i++) { for (i = 0; i < LPC_ORDER; i++) {
res = (((0x1000000 - data[i]*data[i]) >> 12) * res) >> 12; res = (((0x1000000 - data[i]*data[i]) >> 12) * res) >> 12;
if (res == 0) if (res == 0)
@ -1648,13 +1648,13 @@ unsigned int ff_rms(const int *data)
int ff_interp(RA144Context *ractx, int16_t *out, int a, int copyold, int energy) int ff_interp(RA144Context *ractx, int16_t *out, int a, int copyold, int energy)
{ {
int work[10]; int work[LPC_ORDER];
int b = NBLOCKS - a; int b = NBLOCKS - a;
int i; int i;
// Interpolate block coefficients from the this frame's forth block and // Interpolate block coefficients from the this frame's forth block and
// last frame's forth block. // last frame's forth block.
for (i=0; i<10; i++) for (i = 0; i < LPC_ORDER; i++)
out[i] = (a * ractx->lpc_coef[0][i] + b * ractx->lpc_coef[1][i])>> 2; out[i] = (a * ractx->lpc_coef[0][i] + b * ractx->lpc_coef[1][i])>> 2;
if (ff_eval_refl(work, out, ractx->avctx)) { if (ff_eval_refl(work, out, ractx->avctx)) {
@ -1690,7 +1690,7 @@ void ff_subblock_synthesis(RA144Context *ractx, const uint16_t *lpc_coefs,
int cba_idx, int cb1_idx, int cb2_idx, int cba_idx, int cb1_idx, int cb2_idx,
int gval, int gain) int gval, int gain)
{ {
uint16_t buffer_a[40]; uint16_t buffer_a[BLOCKSIZE];
uint16_t *block; uint16_t *block;
int m[3]; int m[3];
@ -1711,10 +1711,10 @@ void ff_subblock_synthesis(RA144Context *ractx, const uint16_t *lpc_coefs,
ff_add_wav(block, gain, cba_idx, m, cba_idx? buffer_a: NULL, ff_add_wav(block, gain, cba_idx, m, cba_idx? buffer_a: NULL,
ff_cb1_vects[cb1_idx], ff_cb2_vects[cb2_idx]); ff_cb1_vects[cb1_idx], ff_cb2_vects[cb2_idx]);
memcpy(ractx->curr_sblock, ractx->curr_sblock + 40, memcpy(ractx->curr_sblock, ractx->curr_sblock + BLOCKSIZE,
10*sizeof(*ractx->curr_sblock)); LPC_ORDER*sizeof(*ractx->curr_sblock));
if (ff_celp_lp_synthesis_filter(ractx->curr_sblock + 10, lpc_coefs, if (ff_celp_lp_synthesis_filter(ractx->curr_sblock + LPC_ORDER, lpc_coefs,
block, BLOCKSIZE, 10, 1, 0, 0xfff)) block, BLOCKSIZE, LPC_ORDER, 1, 0, 0xfff))
memset(ractx->curr_sblock, 0, 50*sizeof(*ractx->curr_sblock)); memset(ractx->curr_sblock, 0, (LPC_ORDER+BLOCKSIZE)*sizeof(*ractx->curr_sblock));
} }

View File

@ -59,29 +59,33 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata,
{ {
const uint8_t *buf = avpkt->data; const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size; int buf_size = avpkt->size;
static const uint8_t sizes[10] = {6, 5, 5, 4, 4, 3, 3, 3, 3, 2}; static const uint8_t sizes[LPC_ORDER] = {6, 5, 5, 4, 4, 3, 3, 3, 3, 2};
unsigned int refl_rms[4]; // RMS of the reflection coefficients unsigned int refl_rms[NBLOCKS]; // RMS of the reflection coefficients
uint16_t block_coefs[4][10]; // LPC coefficients of each sub-block uint16_t block_coefs[NBLOCKS][LPC_ORDER]; // LPC coefficients of each sub-block
unsigned int lpc_refl[10]; // LPC reflection coefficients of the frame unsigned int lpc_refl[LPC_ORDER]; // LPC reflection coefficients of the frame
int i, j; int i, j;
int out_size;
int16_t *data = vdata; int16_t *data = vdata;
unsigned int energy; unsigned int energy;
RA144Context *ractx = avctx->priv_data; RA144Context *ractx = avctx->priv_data;
GetBitContext gb; GetBitContext gb;
if (*data_size < 2*160) out_size = NBLOCKS * BLOCKSIZE * av_get_bytes_per_sample(avctx->sample_fmt);
return -1; if (*data_size < out_size) {
av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
return AVERROR(EINVAL);
}
if(buf_size < 20) { if(buf_size < FRAMESIZE) {
av_log(avctx, AV_LOG_ERROR, av_log(avctx, AV_LOG_ERROR,
"Frame too small (%d bytes). Truncated file?\n", buf_size); "Frame too small (%d bytes). Truncated file?\n", buf_size);
*data_size = 0; *data_size = 0;
return buf_size; return buf_size;
} }
init_get_bits(&gb, buf, 20 * 8); init_get_bits(&gb, buf, FRAMESIZE * 8);
for (i=0; i<10; i++) for (i = 0; i < LPC_ORDER; i++)
lpc_refl[i] = ff_lpc_refl_cb[i][get_bits(&gb, sizes[i])]; lpc_refl[i] = ff_lpc_refl_cb[i][get_bits(&gb, sizes[i])];
ff_eval_coefs(ractx->lpc_coef[0], lpc_refl); ff_eval_coefs(ractx->lpc_coef[0], lpc_refl);
@ -98,7 +102,7 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata,
ff_int_to_int16(block_coefs[3], ractx->lpc_coef[0]); ff_int_to_int16(block_coefs[3], ractx->lpc_coef[0]);
for (i=0; i < 4; i++) { for (i=0; i < NBLOCKS; i++) {
do_output_subblock(ractx, block_coefs[i], refl_rms[i], &gb); do_output_subblock(ractx, block_coefs[i], refl_rms[i], &gb);
for (j=0; j < BLOCKSIZE; j++) for (j=0; j < BLOCKSIZE; j++)
@ -110,8 +114,8 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata,
FFSWAP(unsigned int *, ractx->lpc_coef[0], ractx->lpc_coef[1]); FFSWAP(unsigned int *, ractx->lpc_coef[0], ractx->lpc_coef[1]);
*data_size = 2*160; *data_size = out_size;
return 20; return FRAMESIZE;
} }
AVCodec ff_ra_144_decoder = { AVCodec ff_ra_144_decoder = {

View File

@ -31,6 +31,9 @@
#define MAX_BACKWARD_FILTER_LEN 40 #define MAX_BACKWARD_FILTER_LEN 40
#define MAX_BACKWARD_FILTER_NONREC 35 #define MAX_BACKWARD_FILTER_NONREC 35
#define RA288_BLOCK_SIZE 5
#define RA288_BLOCKS_PER_FRAME 32
typedef struct { typedef struct {
float sp_lpc[36]; ///< LPC coefficients for speech data (spec: A) float sp_lpc[36]; ///< LPC coefficients for speech data (spec: A)
float gain_lpc[10]; ///< LPC coefficients for gain (spec: GB) float gain_lpc[10]; ///< LPC coefficients for gain (spec: GB)
@ -165,7 +168,7 @@ static int ra288_decode_frame(AVCodecContext * avctx, void *data,
const uint8_t *buf = avpkt->data; const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size; int buf_size = avpkt->size;
float *out = data; float *out = data;
int i, j; int i, j, out_size;
RA288Context *ractx = avctx->priv_data; RA288Context *ractx = avctx->priv_data;
GetBitContext gb; GetBitContext gb;
@ -176,18 +179,22 @@ static int ra288_decode_frame(AVCodecContext * avctx, void *data,
return 0; return 0;
} }
if (*data_size < 32*5*4) out_size = RA288_BLOCK_SIZE * RA288_BLOCKS_PER_FRAME *
return -1; av_get_bytes_per_sample(avctx->sample_fmt);
if (*data_size < out_size) {
av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
return AVERROR(EINVAL);
}
init_get_bits(&gb, buf, avctx->block_align * 8); init_get_bits(&gb, buf, avctx->block_align * 8);
for (i=0; i < 32; i++) { for (i=0; i < RA288_BLOCKS_PER_FRAME; i++) {
float gain = amptable[get_bits(&gb, 3)]; float gain = amptable[get_bits(&gb, 3)];
int cb_coef = get_bits(&gb, 6 + (i&1)); int cb_coef = get_bits(&gb, 6 + (i&1));
decode(ractx, gain, cb_coef); decode(ractx, gain, cb_coef);
for (j=0; j < 5; j++) for (j=0; j < RA288_BLOCK_SIZE; j++)
*(out++) = ractx->sp_hist[70 + 36 + j]; *(out++) = ractx->sp_hist[70 + 36 + j];
if ((i & 7) == 3) { if ((i & 7) == 3) {
@ -199,7 +206,7 @@ static int ra288_decode_frame(AVCodecContext * avctx, void *data,
} }
} }
*data_size = (char *)out - (char *)data; *data_size = out_size;
return avctx->block_align; return avctx->block_align;
} }

File diff suppressed because it is too large Load Diff

View File

@ -105,12 +105,25 @@ enum MVModes {
}; };
//@} //@}
/** MBMODE for interlaced frame P-picture */
//@{
enum MBModesIntfr {
MV_PMODE_INTFR_1MV,
MV_PMODE_INTFR_2MV_FIELD,
MV_PMODE_INTFR_2MV,
MV_PMODE_INTFR_4MV_FIELD,
MV_PMODE_INTFR_4MV,
MV_PMODE_INTFR_INTRA,
};
//@}
/** @name MV types for B frames */ /** @name MV types for B frames */
//@{ //@{
enum BMVTypes { enum BMVTypes {
BMV_TYPE_BACKWARD, BMV_TYPE_BACKWARD,
BMV_TYPE_FORWARD, BMV_TYPE_FORWARD,
BMV_TYPE_INTERPOLATED BMV_TYPE_INTERPOLATED,
BMV_TYPE_DIRECT
}; };
//@} //@}
@ -260,16 +273,18 @@ typedef struct VC1Context{
* -# 2 -> [-512, 511.f] x [-128, 127.f] * -# 2 -> [-512, 511.f] x [-128, 127.f]
* -# 3 -> [-1024, 1023.f] x [-256, 255.f] * -# 3 -> [-1024, 1023.f] x [-256, 255.f]
*/ */
uint8_t mvrange; uint8_t mvrange; ///< Extended MV range flag
uint8_t pquantizer; ///< Uniform (over sequence) quantizer in use uint8_t pquantizer; ///< Uniform (over sequence) quantizer in use
VLC *cbpcy_vlc; ///< CBPCY VLC table VLC *cbpcy_vlc; ///< CBPCY VLC table
int tt_index; ///< Index for Transform Type tables int tt_index; ///< Index for Transform Type tables (to decode TTMB)
uint8_t* mv_type_mb_plane; ///< bitplane for mv_type == (4MV) uint8_t* mv_type_mb_plane; ///< bitplane for mv_type == (4MV)
uint8_t* direct_mb_plane; ///< bitplane for "direct" MBs uint8_t* direct_mb_plane; ///< bitplane for "direct" MBs
uint8_t* forward_mb_plane; ///< bitplane for "forward" MBs
int mv_type_is_raw; ///< mv type mb plane is not coded int mv_type_is_raw; ///< mv type mb plane is not coded
int dmb_is_raw; ///< direct mb plane is raw int dmb_is_raw; ///< direct mb plane is raw
int fmb_is_raw; ///< forward mb plane is raw
int skip_is_raw; ///< skip mb plane is not coded int skip_is_raw; ///< skip mb plane is not coded
uint8_t luty[256], lutuv[256]; // lookup tables used for intensity compensation uint8_t luty[256], lutuv[256];///< lookup tables used for intensity compensation
int use_ic; ///< use intensity compensation in B-frames int use_ic; ///< use intensity compensation in B-frames
int rnd; ///< rounding control int rnd; ///< rounding control
@ -307,6 +322,44 @@ typedef struct VC1Context{
uint8_t range_mapuv; uint8_t range_mapuv;
//@} //@}
/** Frame decoding info for interlaced picture */
uint8_t dmvrange; ///< Extended differential MV range flag
int fourmvswitch;
int intcomp;
uint8_t lumscale2; ///< for interlaced field P picture
uint8_t lumshift2;
uint8_t luty2[256], lutuv2[256]; // lookup tables used for intensity compensation
VLC* mbmode_vlc;
VLC* imv_vlc;
VLC* twomvbp_vlc;
VLC* fourmvbp_vlc;
uint8_t twomvbp;
uint8_t fourmvbp;
uint8_t* fieldtx_plane;
int fieldtx_is_raw;
int8_t zzi_8x8[64];
uint8_t *blk_mv_type_base, *blk_mv_type; ///< 0: frame MV, 1: field MV (interlaced frame)
uint8_t *mv_f_base, *mv_f[2]; ///< 0: MV obtained from same field, 1: opposite field
uint8_t *mv_f_last_base, *mv_f_last[2];
uint8_t *mv_f_next_base, *mv_f_next[2];
int field_mode; ///< 1 for interlaced field pictures
int fptype;
int second_field;
int refdist; ///< distance of the current picture from reference
int numref; ///< number of past field pictures used as reference
// 0 corresponds to 1 and 1 corresponds to 2 references
int reffield; ///< if numref = 0 (1 reference) then reffield decides which
// field to use among the two fields from previous frame
int intcompfield; ///< which of the two fields to be intensity compensated
// 0: both fields, 1: bottom field, 2: top field
int cur_field_type; ///< 0: top, 1: bottom
int ref_field_type[2]; ///< forward and backward reference field type (top or bottom)
int blocks_off, mb_off;
int qs_last; ///< if qpel has been used in the previous (tr.) picture
int bmvtype;
int frfd, brfd; ///< reference frame distance (forward or backward)
int pic_header_flag;
/** Frame decoding info for sprite modes */ /** Frame decoding info for sprite modes */
//@{ //@{
int new_sprite; int new_sprite;

View File

@ -1,5 +1,6 @@
/* /*
* VC-1 and WMV3 decoder * VC-1 and WMV3 decoder
* copyright (c) 2011 Mashiat Sarker Shakkhar
* copyright (c) 2006 Konstantin Shishkov * copyright (c) 2006 Konstantin Shishkov
* (c) 2005 anonymous, Alex Beregszaszi, Michael Niedermayer * (c) 2005 anonymous, Alex Beregszaszi, Michael Niedermayer
* *
@ -48,6 +49,40 @@ const uint8_t ff_vc1_mv_pmode_table2[2][4] = {
{ MV_PMODE_1MV, MV_PMODE_MIXED_MV, MV_PMODE_1MV_HPEL, MV_PMODE_1MV_HPEL_BILIN } { MV_PMODE_1MV, MV_PMODE_MIXED_MV, MV_PMODE_1MV_HPEL, MV_PMODE_1MV_HPEL_BILIN }
}; };
/* MBMODE table for interlaced frame P-picture */
const uint8_t ff_vc1_mbmode_intfrp[2][15][4] = {
{ /* 1: 4-MV, 0: non-4-MV */
/* Type, FIELDTX, 1-MV Differential present, Residuals (CBP) present */
/* Table 164 - Table 167 */
{ MV_PMODE_INTFR_1MV , 0, 1, 1},
{ MV_PMODE_INTFR_1MV , 1, 1, 1},
{ MV_PMODE_INTFR_1MV , 0, 1, 0},
{ MV_PMODE_INTFR_1MV , 0, 0, 1},
{ MV_PMODE_INTFR_1MV , 1, 0, 1},
{ MV_PMODE_INTFR_2MV_FIELD , 0, 0, 1},
{ MV_PMODE_INTFR_2MV_FIELD , 1, 0, 1},
{ MV_PMODE_INTFR_2MV_FIELD , 0, 0, 0},
{ MV_PMODE_INTFR_INTRA , 0, 0, 0} },
{
/* Table 160 - Table 163 */
{ MV_PMODE_INTFR_1MV , 0, 1, 1 },
{ MV_PMODE_INTFR_1MV , 1, 1, 1 },
{ MV_PMODE_INTFR_1MV , 0, 1, 0 },
{ MV_PMODE_INTFR_1MV , 0, 0, 1 },
{ MV_PMODE_INTFR_1MV , 1, 0, 1 },
{ MV_PMODE_INTFR_2MV_FIELD , 0, 0, 1 },
{ MV_PMODE_INTFR_2MV_FIELD , 1, 0, 1 },
{ MV_PMODE_INTFR_2MV_FIELD , 0, 0, 0 },
{ MV_PMODE_INTFR_4MV , 0, 0, 1 },
{ MV_PMODE_INTFR_4MV , 1, 0, 1 },
{ MV_PMODE_INTFR_4MV , 0, 0, 0 },
{ MV_PMODE_INTFR_4MV_FIELD , 0, 0, 1 },
{ MV_PMODE_INTFR_4MV_FIELD , 1, 0, 1 },
{ MV_PMODE_INTFR_4MV_FIELD , 0, 0, 0 },
{ MV_PMODE_INTFR_INTRA , 0, 0, 0 }
}
};
const int ff_vc1_fps_nr[5] = { 24, 25, 30, 50, 60 }, const int ff_vc1_fps_nr[5] = { 24, 25, 30, 50, 60 },
ff_vc1_fps_dr[2] = { 1000, 1001 }; ff_vc1_fps_dr[2] = { 1000, 1001 };
const uint8_t ff_vc1_pquant_table[3][32] = { const uint8_t ff_vc1_pquant_table[3][32] = {
@ -84,14 +119,33 @@ VLC ff_vc1_ttmb_vlc[3];
VLC ff_vc1_mv_diff_vlc[4]; VLC ff_vc1_mv_diff_vlc[4];
#define VC1_CBPCY_P_VLC_BITS 9 //14 #define VC1_CBPCY_P_VLC_BITS 9 //14
VLC ff_vc1_cbpcy_p_vlc[4]; VLC ff_vc1_cbpcy_p_vlc[4];
#define VC1_ICBPCY_VLC_BITS 9
VLC ff_vc1_icbpcy_vlc[8];
#define VC1_4MV_BLOCK_PATTERN_VLC_BITS 6 #define VC1_4MV_BLOCK_PATTERN_VLC_BITS 6
VLC ff_vc1_4mv_block_pattern_vlc[4]; VLC ff_vc1_4mv_block_pattern_vlc[4];
#define VC1_2MV_BLOCK_PATTERN_VLC_BITS 3
VLC ff_vc1_2mv_block_pattern_vlc[4];
#define VC1_TTBLK_VLC_BITS 5 #define VC1_TTBLK_VLC_BITS 5
VLC ff_vc1_ttblk_vlc[3]; VLC ff_vc1_ttblk_vlc[3];
#define VC1_SUBBLKPAT_VLC_BITS 6 #define VC1_SUBBLKPAT_VLC_BITS 6
VLC ff_vc1_subblkpat_vlc[3]; VLC ff_vc1_subblkpat_vlc[3];
#define VC1_INTFR_4MV_MBMODE_VLC_BITS 9
VLC ff_vc1_intfr_4mv_mbmode_vlc[4];
#define VC1_INTFR_NON4MV_MBMODE_VLC_BITS 6
VLC ff_vc1_intfr_non4mv_mbmode_vlc[4];
#define VC1_IF_MMV_MBMODE_VLC_BITS 5
VLC ff_vc1_if_mmv_mbmode_vlc[8];
#define VC1_IF_1MV_MBMODE_VLC_BITS 5
VLC ff_vc1_if_1mv_mbmode_vlc[8];
#define VC1_1REF_MVDATA_VLC_BITS 9
VLC ff_vc1_1ref_mvdata_vlc[4];
#define VC1_2REF_MVDATA_VLC_BITS 9
VLC ff_vc1_2ref_mvdata_vlc[8];
VLC ff_vc1_ac_coeff_table[8]; VLC ff_vc1_ac_coeff_table[8];
#define VC1_IF_MBMODE_VLC_BITS 5 // as a placeholder for VC1_IF_MMV_MBMODE_VLC_BITS
// or VC1_IF_1MV_MBMODE_VLC_BITS since they are the same
//@} //@}
@ -202,6 +256,273 @@ const uint8_t ff_vc1_4mv_block_pattern_bits[4][16] = {
{ 2, 4, 4, 4, 4, 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4} { 2, 4, 4, 4, 4, 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4}
}; };
/* 2MV Block pattern VLC tables */
const uint8_t ff_vc1_2mv_block_pattern_codes[4][4] = {
{ 2, 1, 0, 3}, { 1, 0, 2, 3}, { 2, 0, 3, 1}, { 1, 3, 2, 0}
};
const uint8_t ff_vc1_2mv_block_pattern_bits[4][4] = {
{ 2, 2, 2, 2}, { 1, 2, 3, 3}, { 3, 2, 3, 1}, { 1, 3, 3, 2}
};
/* Interlaced frame picture 4MV MBMODE VLC tables (p. 246, p. 360) */
const uint16_t ff_vc1_intfr_4mv_mbmode_codes[4][15] = {
{ 22, 17, 0, 47, 32, 10, 1, 3, 67, 133, 132, 92, 19, 93, 18},
{ 3, 45, 0, 7, 23, 6, 1, 2, 10, 39, 44, 8, 18, 77, 76},
{ 15, 6, 28, 9, 41, 6, 2, 15, 14, 8, 40, 29, 0, 21, 11},
{ 7, 198, 1, 2, 193, 13, 25, 0, 97, 1599, 98, 398, 798, 192, 1598}
};
const uint8_t ff_vc1_intfr_4mv_mbmode_bits[4][15] = {
{ 5, 5, 2, 6, 6, 4, 2, 2, 7, 8, 8, 7, 5, 7, 5},
{ 3, 6, 3, 3, 5, 3, 3, 3, 4, 6, 6, 4, 5, 7, 7},
{ 4, 3, 5, 5, 7, 4, 2, 5, 5, 5, 7, 5, 2, 6, 5},
{ 4, 9, 1, 3, 9, 5, 6, 2, 8, 12, 8, 10, 11, 9, 12}
};
/* Interlaced frame picture NON-4MV MBMODE VLC tables (p. 363) */
const uint8_t ff_vc1_intfr_non4mv_mbmode_codes[4][9] = {
{ 9, 22, 0, 17, 16, 10, 1, 3, 23},
{ 7, 0, 5, 2, 1, 1, 6, 3, 4},
{ 1, 0, 10, 23, 44, 8, 3, 9, 45},
{ 7, 97, 1, 2, 49, 13, 25, 0, 96}
};
const uint8_t ff_vc1_intfr_non4mv_mbmode_bits[4][9] = {
{ 4, 5, 2, 5, 5, 4, 2, 2, 5},
{ 3, 4, 6, 2, 3, 2, 3, 5, 6},
{ 2, 2, 4, 5, 6, 4, 2, 4, 6},
{ 4, 8, 1, 3, 7, 5, 6, 2, 8}
};
/* Interlaced field picture MBMODE VLC tables (p. 356 - 11.4.1, 11.4.2) */
/* mixed-MV */
const uint8_t ff_vc1_if_mmv_mbmode_codes[8][8] = {
{ 16, 17, 3, 3, 0, 5, 9, 2 },
{ 8, 9, 3, 6, 7, 0, 5, 2 },
{ 16, 17, 5, 3, 0, 3, 9, 2 },
{ 56, 57, 15, 4, 5, 6, 29, 0 },
{ 52, 53, 27, 14, 15, 2, 12, 0 },
{ 56, 57, 29, 5, 6, 0, 15, 4 },
{ 16, 17, 6, 7, 0, 1, 9, 5 },
{ 56, 57, 0, 5, 6, 29, 4, 15 }
};
const uint8_t ff_vc1_if_mmv_mbmode_bits[8][8] = {
{ 6, 6, 2, 3, 2, 4, 5, 2 },
{ 5, 5, 3, 3, 3, 2, 4, 2 },
{ 6, 6, 4, 3, 2, 2, 5, 2 },
{ 6, 6, 4, 3, 3, 3, 5, 1 },
{ 6, 6, 5, 4, 4, 2, 4, 1 },
{ 6, 6, 5, 3, 3, 1, 4, 3 },
{ 5, 5, 3, 3, 2, 2, 4, 3 },
{ 6, 6, 1, 3, 3, 5, 3, 4 }
};
/* 1MV */
const uint8_t ff_vc1_if_1mv_mbmode_codes[8][6] = {
{ 0, 1, 1, 1, 1, 1 },
{ 0, 1, 1, 1, 1, 1 },
{ 16, 17, 3, 0, 9, 5 },
{ 20, 21, 3, 11, 0, 4 },
{ 4, 5, 2, 3, 3, 0 },
{ 4, 5, 3, 2, 0, 3 },
{ 0, 1, 1, 1, 1, 1 },
{ 16, 17, 9, 5, 3, 0 }
};
const uint8_t ff_vc1_if_1mv_mbmode_bits[8][6] = {
{ 5, 5, 1, 3, 2, 4 },
{ 5, 5, 1, 2, 3, 4 },
{ 5, 5, 2, 1, 4, 3 },
{ 5, 5, 2, 4, 1, 3 },
{ 4, 4, 2, 3, 2, 2 },
{ 4, 4, 3, 2, 2, 2 },
{ 5, 5, 3, 4, 1, 2 },
{ 5, 5, 4, 3, 2, 1 }
};
/* Interlaced frame/field picture MVDATA VLC tables */
/* 1-reference tables */
const uint32_t ff_vc1_1ref_mvdata_codes[4][72] = { /* uint32_t may be too big */
{5, 12, 30, 18, 12, 52, 117, 112, 0, 8, 27, 8, 29, 124, 214, 478, 431, 5, 27, 38, 30, 18, 118, 77,
502, 500, 57, 127, 39, 106, 113, 53, 113, 104, 476, 39, 115, 255, 232, 233, 126, 505, 501, 509, 62, 458, 1017, 76,
105, 506, 479, 503, 112, 477, 3661, 1831, 914, 456, 459, 1016, 430, 504, 507, 58574, 58575, 29280, 29281, 29282, 29283, 29284, 29285, 29286},
{7, 1, 7, 22, 1, 69, 24, 694, 6, 4, 23, 16, 41, 44, 346, 102, 414, 9, 40, 23, 0, 42, 4, 91,
181, 206, 6, 68, 15, 70, 14, 172, 50, 55, 4587, 10, 26, 287, 22, 20, 43, 360, 85, 9173, 87, 47, 54, 46,
361, 84, 1147, 415, 11133, 142, 2782, 1145, 1390, 2292, 5567, 1144, 9172, 44529, 22265, 712462, 712463, 356224, 356225, 356226, 356227, 356228, 356229, 356230},
{2, 6, 7, 13, 7, 48, 255, 496, 2, 0, 5, 25, 30, 7, 99, 253, 35, 14, 27, 26, 6, 9, 24, 197,
51, 497, 2, 1019, 499, 34, 508, 66, 1571, 131, 1568, 125, 64, 67, 996, 997, 401, 4073, 261, 520, 252, 1572, 1570, 400,
1574, 2037, 3147, 8144, 4173, 101, 3138, 201, 1575, 3139, 3146, 4174, 8145, 4175, 1042, 66766, 66767, 33376, 33377, 33378, 33379, 33380, 33381, 33382},
{13, 1, 4, 0, 23, 5, 127, 77, 3, 17, 62, 59, 23, 103, 74, 195, 242, 10, 44, 50, 61, 21, 40, 147,
204, 150, 3, 117, 32, 45, 33, 41, 144, 464, 507, 28, 76, 96, 9, 8, 45, 159, 506, 317, 49, 252, 88, 146,
240, 241, 205, 389, 357, 78, 145, 233, 388, 465, 486, 151, 487, 179, 316, 5710, 5711, 2848, 2849, 2850, 2851, 2852, 2853, 2854}
};
const uint8_t ff_vc1_1ref_mvdata_bits[4][72] = {
{3, 4, 5, 5, 5, 6, 7, 7, 2, 4, 5, 5, 6, 7, 8, 9, 9, 4, 6, 6, 6, 6, 7, 8,
9, 9, 6, 8, 7, 7, 7, 7, 8, 8, 9, 6, 8, 8, 8, 8, 8, 9, 9, 9, 7, 10, 10, 8,
8, 9, 9, 9, 8, 9, 13, 12, 11, 10, 10, 10, 9, 9, 9, 17, 17, 16, 16, 16, 16, 16, 16, 16},
{3, 3, 4, 5, 5, 7, 8, 10, 3, 4, 5, 5, 6, 7, 9, 10, 12, 4, 6, 6, 5, 6, 6, 8,
9, 11, 4, 7, 7, 7, 7, 8, 9, 9, 13, 5, 8, 9, 8, 8, 9, 10, 10, 14, 7, 9, 9, 9,
10, 10, 11, 12, 14, 8, 12, 11, 11, 12, 13, 11, 14, 16, 15, 20, 20, 19, 19, 19, 19, 19, 19, 19},
{3, 4, 4, 4, 5, 6, 8, 9, 2, 4, 5, 5, 5, 6, 7, 8, 8, 4, 7, 7, 6, 6, 7, 8,
8, 9, 5, 10, 9, 8, 9, 9, 11, 10, 11, 7, 9, 9, 10, 10, 11, 12, 11, 12, 8, 11, 11, 11,
11, 11, 12, 13, 15, 9, 12, 10, 11, 12, 12, 15, 13, 15, 13, 19, 19, 18, 18, 18, 18, 18, 18, 18},
{4, 4, 4, 4, 5, 5, 7, 7, 3, 5, 6, 6, 6, 7, 7, 8, 8, 4, 6, 6, 6, 6, 7, 8,
8, 8, 4, 7, 6, 6, 6, 7, 8, 9, 9, 5, 7, 7, 6, 6, 7, 8, 9, 9, 6, 8, 8, 8,
8, 8, 8, 9, 10, 7, 8, 8, 9, 9, 9, 8, 9, 9, 9, 14, 14, 13, 13, 13, 13, 13, 13, 13}
};
/* 2-reference tables */
const uint32_t ff_vc1_2ref_mvdata_codes[8][126] = { /* table 132 - table 139 */
{12, 28, 11, 0, 14, 42, 80, 872, 2, 26, 4, 58, 29, 108,
239, 444, 351, 15, 3, 28, 13, 11, 62, 167, 326, 409, 6, 31,
4, 60, 7, 446, 139, 44, 1971, 5, 219, 86, 236, 82, 445, 120,
207, 1395, 9, 35, 237, 24, 6, 68, 245, 121, 1746, 110, 43, 349,
23, 895, 324, 206, 40, 171, 16, 437, 247, 166, 123, 40, 493, 489,
1789, 4, 245, 41, 650, 651, 655, 3577, 821, 7813, 238, 701, 43, 984,
977, 408, 489, 1309, 180, 63, 1109, 555, 553, 1105, 1400, 1970, 1392, 341,
50, 976, 84, 1747, 1393, 1108, 820, 7153, 183, 41, 7812, 364, 411, 7152,
1401, 3907, 181, 2209, 42, 365, 2208, 1952, 977, 2789, 340, 2788, 2617, 2616},
{3, 9, 22, 16, 215, 821, 1396, 1365, 0, 29, 9, 23, 44, 173,
884, 1715, 1399, 15, 24, 10, 46, 34, 380, 3707, 7049, 5592, 8, 52,
109, 35, 450, 886, 723, 7242, 13066, 20, 106, 114, 108, 227, 411, 1855,
7408, 2881, 50, 230, 224, 207, 171, 412, 683, 3627, 5593, 111, 451, 175,
191, 172, 381, 1763, 3625, 6532, 84, 181, 378, 429, 409, 376, 856, 722,
7243, 91, 680, 817, 904, 907, 880, 1811, 3267, 7409, 441, 1519, 1848, 754,
827, 697, 1771, 1392, 3620, 925, 1442, 1443, 3709, 1518, 1849, 1364, 2725, 2724,
887, 7413, 3022, 3705, 1632, 1652, 1770, 3708, 3429, 758, 5594, 7048, 1441, 7412,
1510, 3624, 1397, 3428, 820, 13067, 5595, 2880, 3023, 3525, 3626, 1653, 1393, 1363},
{4, 2, 16, 3, 23, 69, 62, 126, 3, 2, 40, 30, 21, 71,
2, 333, 96, 11, 38, 36, 20, 50, 111, 195, 1329, 1765, 21, 63,
45, 1, 318, 221, 246, 773, 817, 14, 3, 52, 51, 26, 330, 197,
244, 1764, 1, 60, 125, 141, 157, 49, 110, 662, 205, 37, 329, 50,
137, 54, 136, 111, 3, 797, 14, 426, 638, 97, 334, 335, 103, 255,
387, 54, 855, 245, 198, 194, 665, 281, 561, 848, 44, 399, 1328, 663,
4, 440, 192, 634, 785, 156, 1569, 409, 796, 247, 995, 854, 393, 5,
107, 2242, 816, 1279, 1264, 849, 1266, 498, 883, 0, 3137, 2243, 2540, 994,
772, 1271, 1265, 496, 328, 3136, 2541, 2240, 2241, 1267, 1278, 254, 499, 425},
{0, 4, 47, 82, 16, 173, 1291, 400, 3, 22, 7, 13, 187, 371,
201, 1295, 5932, 3, 17, 5, 67, 35, 75, 814, 11867, 1154, 9, 42,
20, 42, 264, 1482, 1626, 8502, 8498, 11, 19, 65, 184, 372, 256, 5338,
16462, 5175, 43, 133, 167, 160, 332, 666, 812, 8499, 5162, 81, 644, 172,
258, 69, 68, 2075, 1630, 3255, 24, 1292, 530, 740, 515, 148, 290, 2074,
1621, 51, 698, 582, 578, 2670, 1036, 2056, 8500, 16463, 373, 1029, 583, 298,
2580, 699, 401, 2127, 5176, 175, 2967, 1155, 5179, 811, 579, 5163, 2392, 10687,
73, 2668, 5339, 1197, 5342, 2126, 5172, 599, 11866, 519, 5173, 5177, 3254, 5178,
404, 1620, 8501, 21372, 348, 576, 4114, 21373, 2393, 4248, 5174, 1631, 8230, 8503},
{5, 25, 22, 17, 62, 94, 239, 226, 0, 57, 43, 38, 40, 18,
194, 237, 285, 13, 49, 42, 37, 32, 92, 493, 589, 1904, 6, 122,
96, 79, 72, 57, 390, 531, 3782, 15, 38, 95, 117, 112, 39, 475,
966, 1935, 63, 166, 240, 58, 82, 78, 227, 473, 783, 16, 477, 167,
247, 34, 146, 964, 751, 1890, 121, 143, 474, 135, 232, 186, 374, 238,
944, 133, 281, 782, 264, 466, 268, 1907, 1060, 1076, 113, 1501, 449, 935,
295, 141, 539, 1970, 479, 984, 1892, 3812, 947, 1869, 472, 1500, 2122, 1177,
965, 7566, 1893, 1077, 1905, 450, 280, 956, 897, 903, 31539, 4247, 4246, 7885,
3737, 3868, 3869, 3813, 284, 31538, 15768, 7567, 3736, 3943, 957, 896, 1176, 902},
{13, 16, 46, 57, 13, 116, 237, 182, 1, 2, 0, 48, 41, 112,
243, 140, 358, 9, 51, 120, 6, 196, 11, 355, 204, 1470, 31, 47,
100, 24, 198, 10, 354, 704, 3827, 7, 15, 227, 202, 178, 399, 942,
1887, 3153, 21, 71, 238, 226, 234, 9, 362, 707, 1437, 61, 8, 473,
50, 14, 366, 812, 1627, 6507, 2, 15, 472, 141, 180, 484, 103, 791,
1940, 34, 958, 789, 52, 55, 734, 108, 3838, 1644, 40, 971, 940, 53,
363, 957, 705, 1580, 7678, 14, 1438, 1471, 218, 1577, 1412, 3767, 2826, 1645,
12, 1918, 1436, 1912, 1886, 1882, 1581, 823, 820, 407, 7767, 7652, 6506, 7766,
3152, 2879, 7764, 2827, 398, 438, 7765, 3252, 2878, 3766, 7653, 7679, 821, 439},
{1, 11, 25, 111, 42, 117, 2027, 355, 1, 14, 26, 62, 28, 45,
356, 2028, 357, 4, 6, 54, 127, 174, 344, 348, 1389, 1037584, 0, 4,
123, 243, 59, 2029, 691, 716, 1390, 24, 62, 23, 30, 175, 1015, 1391,
717, 1037585, 20, 173, 170, 20, 168, 339, 232, 510, 3535, 120, 440, 338,
254, 689, 349, 352, 1037586, 1037587, 122, 688, 485, 233, 252, 1766, 3528, 1412,
1037588, 171, 3550, 345, 1012, 3529, 3530, 506, 1037589, 1037590, 252, 511, 484, 175,
346, 359, 3531, 1413, 1037591, 1015, 16213, 1037592, 3548, 1414, 16214, 1037593, 16215, 1037594,
442, 1415, 1416, 3551, 690, 1037595, 3534, 1014, 1037596, 4052, 1037597, 1037598, 1037599, 518784,
518785, 1388, 518786, 518787, 886, 1417, 1418, 518788, 518789, 3549, 518790, 518791, 1419, 32425},
{3, 14, 15, 126, 98, 198, 3289, 1598, 2, 2, 0, 24, 12, 105,
57, 1799, 3198, 2, 13, 27, 15, 410, 1607, 6711, 214724, 13421, 1, 30,
127, 10, 225, 1633, 3300, 214725, 214726, 29, 48, 13, 203, 409, 800, 142,
25902, 214727, 62, 57, 53, 51, 415, 448, 3290, 214728, 214729, 11, 208, 414,
34, 56, 398, 798, 12948, 572, 50, 18, 19, 113, 413, 32, 3207, 3264,
214730, 824, 1619, 418, 810, 802, 3303, 132, 287, 214731, 805, 1609, 811, 119,
1608, 1602, 3206, 3212, 214732, 58, 6583, 67, 807, 140, 141, 3213, 214733, 214734,
823, 3301, 133, 806, 839, 3236, 3199, 3354, 214735, 808, 107360, 107361, 3288, 1676,
12949, 12950, 25903, 26328, 817, 1798, 573, 118, 3265, 898, 3302, 26329, 26330, 26331}
};
const uint8_t ff_vc1_2ref_mvdata_bits[8][126] = {
{4, 5, 5, 5, 6, 7, 8, 10, 2, 5, 5, 6, 6, 7,
8, 9, 10, 4, 5, 6, 6, 7, 8, 9, 10, 11, 4, 6,
6, 7, 7, 9, 9, 10, 12, 5, 8, 8, 8, 8, 9, 9,
10, 12, 5, 7, 8, 7, 7, 8, 9, 9, 11, 7, 9, 10,
9, 10, 10, 10, 10, 12, 6, 9, 9, 9, 9, 9, 10, 10,
11, 7, 10, 10, 11, 11, 11, 12, 12, 14, 8, 11, 10, 11,
11, 11, 11, 12, 12, 8, 12, 11, 11, 12, 12, 12, 12, 13,
8, 12, 11, 11, 12, 12, 12, 13, 12, 9, 14, 13, 11, 13,
12, 13, 12, 13, 9, 13, 13, 12, 12, 13, 13, 13, 13, 13},
{3, 4, 5, 6, 8, 10, 11, 11, 2, 5, 5, 6, 7, 8,
10, 11, 11, 4, 5, 5, 6, 7, 9, 12, 13, 13, 4, 6,
7, 7, 9, 10, 11, 13, 14, 5, 7, 7, 7, 8, 9, 11,
13, 13, 6, 8, 8, 8, 8, 9, 10, 12, 13, 7, 9, 8,
8, 8, 9, 11, 12, 13, 7, 9, 9, 9, 9, 9, 10, 11,
13, 8, 10, 10, 10, 10, 10, 11, 12, 13, 9, 11, 11, 10,
10, 10, 11, 11, 12, 10, 12, 12, 12, 11, 11, 11, 12, 12,
10, 13, 12, 12, 11, 11, 11, 12, 12, 10, 13, 13, 12, 13,
11, 12, 11, 12, 10, 14, 13, 13, 12, 12, 12, 11, 11, 11},
{4, 4, 5, 5, 6, 7, 8, 9, 2, 5, 6, 6, 6, 7,
7, 9, 9, 4, 6, 6, 6, 7, 8, 9, 11, 12, 5, 7,
7, 7, 9, 9, 10, 11, 12, 5, 7, 7, 7, 7, 9, 9,
10, 12, 5, 8, 8, 8, 8, 8, 9, 10, 10, 6, 9, 8,
8, 8, 8, 9, 9, 11, 6, 10, 10, 9, 9, 9, 9, 10,
10, 7, 11, 10, 9, 9, 10, 9, 10, 11, 7, 10, 11, 10,
10, 10, 9, 10, 11, 8, 12, 11, 11, 10, 11, 11, 10, 10,
8, 12, 12, 11, 11, 11, 11, 10, 11, 8, 13, 12, 12, 11,
11, 11, 11, 10, 9, 13, 12, 12, 12, 11, 11, 10, 10, 10},
{3, 4, 6, 7, 7, 9, 11, 11, 2, 5, 5, 6, 8, 9,
10, 11, 13, 3, 5, 5, 7, 8, 9, 12, 14, 13, 4, 6,
6, 7, 9, 11, 13, 14, 14, 5, 7, 7, 8, 9, 9, 13,
15, 13, 6, 8, 8, 8, 9, 10, 12, 14, 13, 7, 10, 9,
9, 9, 9, 12, 13, 14, 7, 11, 10, 10, 10, 10, 11, 12,
13, 8, 11, 12, 12, 12, 11, 12, 14, 15, 9, 11, 12, 11,
12, 11, 11, 12, 13, 9, 12, 13, 13, 12, 12, 13, 14, 14,
9, 12, 13, 13, 13, 12, 13, 12, 14, 10, 13, 13, 14, 13,
11, 13, 14, 15, 10, 12, 13, 15, 14, 13, 13, 13, 14, 14},
{4, 5, 5, 5, 6, 7, 8, 8, 2, 6, 6, 6, 6, 6,
8, 9, 10, 4, 6, 6, 6, 6, 7, 9, 10, 11, 4, 7,
7, 7, 7, 7, 9, 10, 12, 5, 7, 7, 7, 7, 7, 9,
10, 11, 6, 8, 8, 7, 7, 7, 8, 9, 10, 6, 9, 8,
8, 7, 8, 10, 10, 11, 7, 9, 9, 8, 8, 8, 9, 9,
10, 8, 10, 10, 9, 9, 9, 11, 11, 11, 8, 11, 10, 10,
9, 9, 10, 11, 10, 10, 12, 12, 11, 11, 10, 11, 12, 11,
10, 13, 12, 11, 11, 10, 10, 11, 11, 11, 15, 13, 13, 13,
12, 12, 12, 12, 10, 15, 14, 13, 12, 12, 11, 11, 11, 11},
{4, 5, 6, 6, 6, 7, 8, 8, 2, 4, 5, 6, 6, 7,
8, 8, 9, 4, 6, 7, 7, 8, 8, 9, 10, 11, 5, 6,
7, 7, 8, 8, 9, 10, 12, 5, 7, 8, 8, 8, 9, 10,
11, 12, 5, 7, 8, 8, 8, 8, 9, 10, 11, 6, 8, 9,
8, 8, 9, 10, 11, 13, 5, 8, 9, 8, 8, 9, 9, 10,
11, 6, 10, 10, 9, 9, 10, 10, 12, 13, 6, 10, 10, 9,
9, 10, 10, 11, 13, 7, 11, 11, 11, 11, 11, 12, 12, 13,
7, 11, 11, 11, 11, 11, 11, 12, 12, 9, 13, 13, 13, 13,
12, 12, 13, 12, 9, 12, 13, 12, 12, 12, 13, 13, 12, 12},
{3, 5, 6, 8, 9, 10, 12, 12, 1, 5, 6, 7, 8, 9,
12, 12, 12, 4, 6, 7, 8, 9, 12, 12, 14, 21, 4, 6,
8, 9, 9, 12, 13, 13, 14, 6, 9, 8, 8, 9, 13, 14,
13, 21, 6, 9, 9, 8, 9, 10, 11, 12, 13, 8, 10, 10,
11, 11, 12, 12, 21, 21, 8, 11, 10, 11, 11, 12, 13, 14,
21, 9, 13, 10, 11, 13, 13, 12, 21, 21, 9, 12, 10, 11,
12, 12, 13, 14, 21, 11, 15, 21, 13, 14, 15, 21, 15, 21,
10, 14, 14, 13, 13, 21, 13, 13, 21, 13, 21, 21, 21, 20,
20, 14, 20, 20, 11, 14, 14, 20, 20, 13, 20, 20, 14, 16},
{2, 5, 6, 8, 9, 10, 13, 13, 2, 4, 5, 6, 8, 9,
10, 13, 14, 3, 5, 7, 8, 10, 12, 15, 20, 16, 4, 6,
8, 8, 10, 12, 13, 20, 20, 7, 8, 8, 9, 10, 11, 12,
16, 20, 7, 8, 8, 8, 10, 11, 13, 20, 20, 8, 10, 10,
10, 10, 11, 12, 15, 14, 8, 9, 9, 9, 10, 10, 13, 13,
20, 11, 12, 11, 11, 11, 13, 12, 13, 20, 11, 12, 11, 11,
12, 12, 13, 13, 20, 10, 14, 11, 11, 12, 12, 13, 20, 20,
11, 13, 12, 11, 12, 13, 14, 14, 20, 11, 19, 19, 13, 13,
15, 15, 16, 16, 11, 13, 14, 11, 13, 12, 13, 16, 16, 16}
};
const uint8_t wmv3_dc_scale_table[32]={ const uint8_t wmv3_dc_scale_table[32]={
0, 2, 4, 8, 8, 8, 9, 9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21 0, 2, 4, 8, 8, 8, 9, 9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21
}; };
@ -262,6 +583,112 @@ const uint8_t ff_vc1_cbpcy_p_bits[4][64] = {
} }
}; };
/* Interlaced CBPCY VLC tables (Table 124 - Table 131) */
const uint16_t ff_vc1_icbpcy_p_codes[8][63] = {
{
12058, 12059, 6028, 144, 680, 681, 3015, 145, 682, 683, 1504, 74, 150,
151, 189, 146, 684, 685, 1505, 152, 306, 307, 377, 308, 618, 619, 764,
78, 64, 65, 43, 147, 686, 687, 1506, 310, 622, 623, 765, 158, 318,
319, 383, 80, 66, 67, 44, 81, 164, 165, 190, 83, 68, 69, 45,
84, 70, 71, 46, 3, 0, 1, 1
}, {
65, 66, 256, 67, 136, 137, 257, 69, 140, 141, 258, 16, 34,
35, 36, 71, 16, 17, 259, 37, 88, 89, 90, 91, 90, 91, 92,
12, 48, 49, 25, 9, 20, 21, 44, 92, 93, 94, 95, 38, 93,
94, 95, 13, 52, 53, 27, 20, 39, 42, 43, 14, 56, 57, 29,
15, 60, 61, 31, 5, 9, 0, 3
}, {
50, 51, 26, 38, 228, 229, 486, 39, 230, 231, 487, 14, 99,
108, 119, 40, 232, 233, 488, 123, 218, 219, 236, 245, 440, 441, 474,
33, 75, 84, 43, 41, 234, 235, 489, 74, 442, 443, 475, 32, 222,
223, 242, 34, 85, 88, 45, 15, 112, 113, 120, 35, 89, 92, 47,
36, 93, 98, 48, 2, 31, 6, 0
}, {
40, 41, 157, 0, 490, 491, 492, 1, 493, 494, 495, 5, 240,
241, 59, 2, 496, 497, 498, 63, 348, 349, 153, 16, 976, 977, 304,
15, 158, 159, 251, 3, 499, 500, 501, 17, 978, 979, 305, 9, 350,
351, 156, 16, 168, 169, 56, 6, 242, 243, 77, 17, 170, 171, 57,
18, 172, 173, 58, 6, 22, 23, 14
}, {
60, 61, 31, 10, 97, 98, 2, 11, 99, 100, 3, 7, 3,
4, 11, 12, 101, 102, 4, 18, 10, 11, 20, 27, 24, 25, 52,
44, 103, 104, 53, 13, 105, 108, 5, 96, 26, 27, 53, 19, 14,
15, 21, 45, 109, 110, 56, 8, 8, 9, 12, 46, 111, 114, 58,
47, 115, 0, 59, 7, 20, 21, 4
}, {
56, 57, 157, 10, 145, 146, 147, 11, 148, 149, 150, 3, 238,
239, 54, 12, 151, 152, 153, 8, 484, 485, 106, 24, 972, 973, 214,
14, 158, 159, 245, 13, 154, 155, 156, 25, 974, 975, 215, 9, 488,
489, 144, 15, 232, 233, 246, 5, 240, 241, 55, 16, 234, 235, 247,
17, 236, 237, 52, 0, 62, 63, 2
}, {
60, 61, 463, 0, 191, 224, 508, 1, 225, 226, 509, 9, 497,
498, 499, 2, 227, 228, 510, 17, 1006, 1007, 1008, 33, 2018, 2019, 2020,
24, 1015, 1022, 1023, 3, 229, 230, 128, 46, 2021, 2022, 2023, 22, 1012,
1013, 1014, 25, 258, 259, 260, 10, 500, 501, 502, 26, 261, 262, 263,
27, 376, 377, 462, 29, 189, 190, 496
}, {
3, 4, 438, 4, 46, 47, 14, 5, 48, 49, 15, 3, 10,
11, 20, 6, 50, 51, 16, 5, 48, 49, 50, 9, 102, 103, 104,
29, 439, 440, 441, 7, 52, 53, 17, 22, 105, 106, 107, 10, 54,
55, 216, 30, 442, 443, 444, 4, 21, 22, 23, 31, 445, 446, 447,
0, 16, 17, 18, 28, 217, 218, 19
}
};
const uint8_t ff_vc1_icbpcy_p_bits[8][63] = {
{
15, 15, 14, 9, 11, 11, 13, 9, 11, 11, 12, 8, 9,
9, 9, 9, 11, 11, 12, 9, 10, 10, 10, 10, 11, 11, 11,
8, 8, 8, 7, 9, 11, 11, 12, 10, 11, 11, 11, 9, 10,
10, 10, 8, 8, 8, 7, 8, 9, 9, 9, 8, 8, 8, 7,
8, 8, 8, 7, 3, 3, 3, 1
}, {
7, 7, 9, 7, 8, 8, 9, 7, 8, 8, 9, 6, 7,
7, 7, 7, 7, 7, 9, 7, 8, 8, 8, 8, 9, 9, 9,
6, 7, 7, 6, 6, 7, 7, 8, 8, 9, 9, 9, 7, 8,
8, 8, 6, 7, 7, 6, 6, 7, 7, 7, 6, 7, 7, 6,
6, 7, 7, 6, 3, 4, 3, 2
}, {
6, 6, 5, 6, 8, 8, 9, 6, 8, 8, 9, 5, 7,
7, 7, 6, 8, 8, 9, 7, 8, 8, 8, 8, 9, 9, 9,
6, 7, 7, 6, 6, 8, 8, 9, 7, 9, 9, 9, 6, 8,
8, 8, 6, 7, 7, 6, 5, 7, 7, 7, 6, 7, 7, 6,
6, 7, 7, 6, 3, 5, 4, 2
}, {
6, 6, 8, 4, 9, 9, 9, 4, 9, 9, 9, 4, 8,
8, 7, 4, 9, 9, 9, 6, 9, 9, 8, 6, 10, 10, 9,
5, 8, 8, 8, 4, 9, 9, 9, 6, 10, 10, 9, 5, 9,
9, 8, 5, 8, 8, 7, 4, 8, 8, 7, 5, 8, 8, 7,
5, 8, 8, 7, 3, 5, 5, 4
}, {
6, 6, 5, 5, 7, 7, 7, 5, 7, 7, 7, 5, 6,
6, 6, 5, 7, 7, 7, 6, 7, 7, 7, 7, 8, 8, 8,
6, 7, 7, 6, 5, 7, 7, 7, 7, 8, 8, 8, 6, 7,
7, 7, 6, 7, 7, 6, 5, 6, 6, 6, 6, 7, 7, 6,
6, 7, 6, 6, 4, 5, 5, 3
}, {
6, 6, 8, 4, 8, 8, 8, 4, 8, 8, 8, 4, 8,
8, 7, 4, 8, 8, 8, 5, 9, 9, 8, 6, 10, 10, 9,
5, 8, 8, 8, 4, 8, 8, 8, 6, 10, 10, 9, 5, 9,
9, 8, 5, 8, 8, 8, 4, 8, 8, 7, 5, 8, 8, 8,
5, 8, 8, 7, 3, 6, 6, 4
}, {
6, 6, 9, 3, 8, 8, 9, 3, 8, 8, 9, 4, 9,
9, 9, 3, 8, 8, 9, 5, 10, 10, 10, 6, 11, 11, 11,
5, 10, 10, 10, 3, 8, 8, 8, 6, 11, 11, 11, 5, 10,
10, 10, 5, 9, 9, 9, 4, 9, 9, 9, 5, 9, 9, 9,
5, 9, 9, 9, 5, 8, 8, 9
}, {
6, 6, 10, 3, 7, 7, 7, 3, 7, 7, 7, 4, 8,
8, 8, 3, 7, 7, 7, 5, 9, 9, 9, 6, 10, 10, 10,
6, 10, 10, 10, 3, 7, 7, 7, 6, 10, 10, 10, 5, 9,
9, 9, 6, 10, 10, 10, 4, 8, 8, 8, 6, 10, 10, 10,
5, 9, 9, 9, 6, 9, 9, 9
}
};
/* MacroBlock Transform Type: 7.1.3.11, p89 /* MacroBlock Transform Type: 7.1.3.11, p89
* 8x8:B * 8x8:B
* 8x4:B:btm 8x4:B:top 8x4:B:both, * 8x4:B:btm 8x4:B:top 8x4:B:both,
@ -520,3 +947,38 @@ const int32_t ff_vc1_dqscale[63] = {
0x14E6, 0x147B, 0x1414, 0x13B1, 0x1352, 0x12F7, 0x129E, 0x1249, 0x14E6, 0x147B, 0x1414, 0x13B1, 0x1352, 0x12F7, 0x129E, 0x1249,
0x11F7, 0x11A8, 0x115B, 0x1111, 0x10C9, 0x1084, 0x1000 0x11F7, 0x11A8, 0x115B, 0x1111, 0x10C9, 0x1084, 0x1000
}; };
/* P Interlaced field picture MV predictor scaling values (Table 114) */
const uint16_t vc1_field_mvpred_scales[2][7][4] = {
// Refdist 0 1 2 3 or greater
{ // current field is first
{ 128, 192, 213, 224}, // SCALEOPP
{ 512, 341, 307, 293}, // SCALESAME1
{ 219, 236, 242, 245}, // SCALESAME2
{ 32, 48, 53, 56}, // SCALEZONE1_X
{ 8, 12, 13, 14}, // SCALEZONE1_Y
{ 37, 20, 14, 11}, // ZONE1OFFSET_X
{ 10, 5, 4, 3} // ZONE1OFFSET_Y
},
{ // current field is second
{ 128, 64, 43, 32}, // SCALEOPP
{ 512, 1024, 1536, 2048}, // SCALESAME1
{ 219, 204, 200, 198}, // SCALESAME2
{ 32, 16, 11, 8}, // SCALEZONE1_X
{ 8, 4, 3, 2}, // SCALEZONE1_Y
{ 37, 52, 56, 58}, // ZONE1OFFSET_X
{ 10, 13, 14, 15} // ZONE1OFFSET_Y
}
};
/* B Interlaced field picture backward MV predictor scaling values for first field (Table 115) */
const uint16_t vc1_b_field_mvpred_scales[7][4] = {
// BRFD 0 1 2 3 or greater
{ 171, 205, 219, 228}, // SCALESAME
{ 384, 320, 299, 288}, // SCALEOPP1
{ 230, 239, 244, 246}, // SCALEOPP2
{ 43, 51, 55, 57}, // SCALEZONE1_X
{ 11, 13, 14, 14}, // SCALEZONE1_Y
{ 26, 17, 12, 10}, // ZONE1OFFSET_X
{ 7, 4, 3, 3} // ZONE1OFFSET_Y
};

View File

@ -44,6 +44,9 @@ extern const uint8_t ff_vc1_mv_pmode_table2[2][4];
extern const int ff_vc1_fps_nr[5], ff_vc1_fps_dr[2]; extern const int ff_vc1_fps_nr[5], ff_vc1_fps_dr[2];
extern const uint8_t ff_vc1_pquant_table[3][32]; extern const uint8_t ff_vc1_pquant_table[3][32];
/* MBMODE table for interlaced frame P-picture */
extern const uint8_t ff_vc1_mbmode_intfrp[2][15][4];
/** @name VC-1 VLC tables and defines /** @name VC-1 VLC tables and defines
* @todo TODO move this into the context * @todo TODO move this into the context
*/ */
@ -63,14 +66,32 @@ extern VLC ff_vc1_ttmb_vlc[3];
extern VLC ff_vc1_mv_diff_vlc[4]; extern VLC ff_vc1_mv_diff_vlc[4];
#define VC1_CBPCY_P_VLC_BITS 9 //14 #define VC1_CBPCY_P_VLC_BITS 9 //14
extern VLC ff_vc1_cbpcy_p_vlc[4]; extern VLC ff_vc1_cbpcy_p_vlc[4];
#define VC1_ICBPCY_VLC_BITS 9
extern VLC ff_vc1_icbpcy_vlc[8];
#define VC1_4MV_BLOCK_PATTERN_VLC_BITS 6 #define VC1_4MV_BLOCK_PATTERN_VLC_BITS 6
extern VLC ff_vc1_4mv_block_pattern_vlc[4]; extern VLC ff_vc1_4mv_block_pattern_vlc[4];
#define VC1_2MV_BLOCK_PATTERN_VLC_BITS 3
extern VLC ff_vc1_2mv_block_pattern_vlc[4];
#define VC1_TTBLK_VLC_BITS 5 #define VC1_TTBLK_VLC_BITS 5
extern VLC ff_vc1_ttblk_vlc[3]; extern VLC ff_vc1_ttblk_vlc[3];
#define VC1_SUBBLKPAT_VLC_BITS 6 #define VC1_SUBBLKPAT_VLC_BITS 6
extern VLC ff_vc1_subblkpat_vlc[3]; extern VLC ff_vc1_subblkpat_vlc[3];
#define VC1_INTFR_4MV_MBMODE_VLC_BITS 9
extern VLC ff_vc1_intfr_4mv_mbmode_vlc[4];
#define VC1_INTFR_NON4MV_MBMODE_VLC_BITS 6
extern VLC ff_vc1_intfr_non4mv_mbmode_vlc[4];
#define VC1_IF_MMV_MBMODE_VLC_BITS 5
extern VLC ff_vc1_if_mmv_mbmode_vlc[8];
#define VC1_IF_1MV_MBMODE_VLC_BITS 5
extern VLC ff_vc1_if_1mv_mbmode_vlc[8];
#define VC1_1REF_MVDATA_VLC_BITS 9
extern VLC ff_vc1_1ref_mvdata_vlc[4];
#define VC1_2REF_MVDATA_VLC_BITS 9
extern VLC ff_vc1_2ref_mvdata_vlc[8];
extern VLC ff_vc1_ac_coeff_table[8]; extern VLC ff_vc1_ac_coeff_table[8];
#define VC1_IF_MBMODE_VLC_BITS 5
//@} //@}
@ -101,12 +122,20 @@ extern const uint8_t ff_vc1_norm6_spec[64][5];
extern const uint8_t ff_vc1_4mv_block_pattern_codes[4][16]; extern const uint8_t ff_vc1_4mv_block_pattern_codes[4][16];
extern const uint8_t ff_vc1_4mv_block_pattern_bits[4][16]; extern const uint8_t ff_vc1_4mv_block_pattern_bits[4][16];
/* 2MV Block pattern VLC tables */
extern const uint8_t ff_vc1_2mv_block_pattern_codes[4][4];
extern const uint8_t ff_vc1_2mv_block_pattern_bits[4][4];
extern const uint8_t wmv3_dc_scale_table[32]; extern const uint8_t wmv3_dc_scale_table[32];
/* P-Picture CBPCY VLC tables */ /* P-Picture CBPCY VLC tables */
extern const uint16_t ff_vc1_cbpcy_p_codes[4][64]; extern const uint16_t ff_vc1_cbpcy_p_codes[4][64];
extern const uint8_t ff_vc1_cbpcy_p_bits[4][64]; extern const uint8_t ff_vc1_cbpcy_p_bits[4][64];
/* Interlaced CBPCY VLC tables (Table 124 - Table 131) */
extern const uint16_t ff_vc1_icbpcy_p_codes[8][63];
extern const uint8_t ff_vc1_icbpcy_p_bits[8][63];
/* MacroBlock Transform Type: 7.1.3.11, p89 /* MacroBlock Transform Type: 7.1.3.11, p89
* 8x8:B * 8x8:B
* 8x4:B:btm 8x4:B:top 8x4:B:both, * 8x4:B:btm 8x4:B:top 8x4:B:both,
@ -131,6 +160,26 @@ extern const uint8_t ff_vc1_subblkpat_bits[3][15];
extern const uint16_t ff_vc1_mv_diff_codes[4][73]; extern const uint16_t ff_vc1_mv_diff_codes[4][73];
extern const uint8_t ff_vc1_mv_diff_bits[4][73]; extern const uint8_t ff_vc1_mv_diff_bits[4][73];
/* Interlaced frame picture MBMODE VLC tables (p. 246, p. 360) */
extern const uint16_t ff_vc1_intfr_4mv_mbmode_codes[4][15];
extern const uint8_t ff_vc1_intfr_4mv_mbmode_bits[4][15];
extern const uint8_t ff_vc1_intfr_non4mv_mbmode_codes[4][9];
extern const uint8_t ff_vc1_intfr_non4mv_mbmode_bits[4][9];
/* Interlaced field picture MBMODE VLC tables (p. 356 - 11.4.1, 11.4.2) */
extern const uint8_t ff_vc1_if_mmv_mbmode_codes[8][8];
extern const uint8_t ff_vc1_if_mmv_mbmode_bits[8][8];
extern const uint8_t ff_vc1_if_1mv_mbmode_codes[8][6];
extern const uint8_t ff_vc1_if_1mv_mbmode_bits[8][6];
/* Interlaced frame/field picture MVDATA VLC tables */
/* 1-reference tables */
extern const uint32_t ff_vc1_1ref_mvdata_codes[4][72];
extern const uint8_t ff_vc1_1ref_mvdata_bits[4][72];
/* 2-reference tables */
extern const uint32_t ff_vc1_2ref_mvdata_codes[8][126];
extern const uint8_t ff_vc1_2ref_mvdata_bits[8][126];
/* DC differentials low+hi-mo, p217 are the same as in msmpeg4data .h */ /* DC differentials low+hi-mo, p217 are the same as in msmpeg4data .h */
/* Scantables/ZZ scan are at 11.9 (p262) and 8.1.1.12 (p10) */ /* Scantables/ZZ scan are at 11.9 (p262) and 8.1.1.12 (p10) */
@ -141,8 +190,14 @@ extern const int8_t ff_vc1_adv_interlaced_8x8_zz [64];
extern const int8_t ff_vc1_adv_interlaced_8x4_zz [32]; extern const int8_t ff_vc1_adv_interlaced_8x4_zz [32];
extern const int8_t ff_vc1_adv_interlaced_4x8_zz [32]; extern const int8_t ff_vc1_adv_interlaced_4x8_zz [32];
extern const int8_t ff_vc1_adv_interlaced_4x4_zz [16]; extern const int8_t ff_vc1_adv_interlaced_4x4_zz [16];
extern const int8_t ff_vc1_intra_horz_8x8_zz [64];
extern const int8_t ff_vc1_intra_vert_8x8_zz [64];
/* DQScale as specified in 8.1.3.9 - almost identical to 0x40000/i */ /* DQScale as specified in 8.1.3.9 - almost identical to 0x40000/i */
extern const int32_t ff_vc1_dqscale[63]; extern const int32_t ff_vc1_dqscale[63];
/* P Interlaced field picture MV predictor scaling values (Table 114) */
extern const uint16_t vc1_field_mvpred_scales[2][7][4];
/* B Interlaced field picture backward MV predictor scaling values for first field (Table 115) */
extern const uint16_t vc1_b_field_mvpred_scales[7][4];
#endif /* AVCODEC_VC1DATA_H */ #endif /* AVCODEC_VC1DATA_H */

File diff suppressed because it is too large Load Diff

View File

@ -688,6 +688,26 @@ static void put_no_rnd_vc1_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*a
} }
} }
static void put_no_rnd_vc1_chroma_mc4_c(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y){
const int A=(8-x)*(8-y);
const int B=( x)*(8-y);
const int C=(8-x)*( y);
const int D=( x)*( y);
int i;
assert(x<8 && y<8 && x>=0 && y>=0);
for(i=0; i<h; i++)
{
dst[0] = (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + 32 - 4) >> 6;
dst[1] = (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + 32 - 4) >> 6;
dst[2] = (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + 32 - 4) >> 6;
dst[3] = (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + 32 - 4) >> 6;
dst+= stride;
src+= stride;
}
}
#define avg2(a,b) ((a+b+1)>>1) #define avg2(a,b) ((a+b+1)>>1)
static void avg_no_rnd_vc1_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){ static void avg_no_rnd_vc1_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){
const int A=(8-x)*(8-y); const int A=(8-x)*(8-y);
@ -829,6 +849,7 @@ av_cold void ff_vc1dsp_init(VC1DSPContext* dsp) {
dsp->put_no_rnd_vc1_chroma_pixels_tab[0]= put_no_rnd_vc1_chroma_mc8_c; dsp->put_no_rnd_vc1_chroma_pixels_tab[0]= put_no_rnd_vc1_chroma_mc8_c;
dsp->avg_no_rnd_vc1_chroma_pixels_tab[0]= avg_no_rnd_vc1_chroma_mc8_c; dsp->avg_no_rnd_vc1_chroma_pixels_tab[0]= avg_no_rnd_vc1_chroma_mc8_c;
dsp->put_no_rnd_vc1_chroma_pixels_tab[1] = put_no_rnd_vc1_chroma_mc4_c;
#if CONFIG_WMV3IMAGE_DECODER || CONFIG_VC1IMAGE_DECODER #if CONFIG_WMV3IMAGE_DECODER || CONFIG_VC1IMAGE_DECODER
dsp->sprite_h = sprite_h_c; dsp->sprite_h = sprite_h_c;

View File

@ -22,7 +22,7 @@
#define LIBAVCODEC_VERSION_MAJOR 53 #define LIBAVCODEC_VERSION_MAJOR 53
#define LIBAVCODEC_VERSION_MINOR 20 #define LIBAVCODEC_VERSION_MINOR 20
#define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_MICRO 1
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \ LIBAVCODEC_VERSION_MINOR, \

View File

@ -177,7 +177,7 @@ static int fourxm_read_header(AVFormatContext *s,
sizeof(AudioTrack), sizeof(AudioTrack),
current_track + 1); current_track + 1);
if (!fourxm->tracks) { if (!fourxm->tracks) {
ret= AVERROR(ENOMEM); ret = AVERROR(ENOMEM);
goto fail; goto fail;
} }
memset(&fourxm->tracks[fourxm->track_count], 0, memset(&fourxm->tracks[fourxm->track_count], 0,

View File

@ -874,12 +874,13 @@ static int avi_sync(AVFormatContext *s, int exit_early)
{ {
AVIContext *avi = s->priv_data; AVIContext *avi = s->priv_data;
AVIOContext *pb = s->pb; AVIOContext *pb = s->pb;
int n, d[8]; int n;
unsigned int d[8];
unsigned int size; unsigned int size;
int64_t i, sync; int64_t i, sync;
start_sync: start_sync:
memset(d, -1, sizeof(int)*8); memset(d, -1, sizeof(d));
for(i=sync=avio_tell(pb); !url_feof(pb); i++) { for(i=sync=avio_tell(pb); !url_feof(pb); i++) {
int j; int j;
@ -891,7 +892,7 @@ start_sync:
n= get_stream_idx(d+2); n= get_stream_idx(d+2);
//av_log(s, AV_LOG_DEBUG, "%X %X %X %X %X %X %X %X %"PRId64" %d %d\n", d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], i, size, n); //av_log(s, AV_LOG_DEBUG, "%X %X %X %X %X %X %X %X %"PRId64" %d %d\n", d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], i, size, n);
if(i + (uint64_t)size > avi->fsize || d[0]<0) if(i + (uint64_t)size > avi->fsize || d[0] > 127)
continue; continue;
//parse ix## //parse ix##

View File

@ -256,12 +256,13 @@ static int mxf_get_d10_aes3_packet(AVIOContext *pb, AVStream *st, AVPacket *pkt,
if (length > 61444) /* worst case PAL 1920 samples 8 channels */ if (length > 61444) /* worst case PAL 1920 samples 8 channels */
return -1; return -1;
av_new_packet(pkt, length); length = av_get_packet(pb, pkt, length);
avio_read(pb, pkt->data, length); if (length < 0)
return length;
data_ptr = pkt->data; data_ptr = pkt->data;
end_ptr = pkt->data + length; end_ptr = pkt->data + length;
buf_ptr = pkt->data + 4; /* skip SMPTE 331M header */ buf_ptr = pkt->data + 4; /* skip SMPTE 331M header */
for (; buf_ptr < end_ptr; ) { for (; buf_ptr + st->codec->channels*4 < end_ptr; ) {
for (i = 0; i < st->codec->channels; i++) { for (i = 0; i < st->codec->channels; i++) {
uint32_t sample = bytestream_get_le32(&buf_ptr); uint32_t sample = bytestream_get_le32(&buf_ptr);
if (st->codec->bits_per_coded_sample == 24) if (st->codec->bits_per_coded_sample == 24)
@ -271,7 +272,7 @@ static int mxf_get_d10_aes3_packet(AVIOContext *pb, AVStream *st, AVPacket *pkt,
} }
buf_ptr += 32 - st->codec->channels*4; // always 8 channels stored SMPTE 331M buf_ptr += 32 - st->codec->channels*4; // always 8 channels stored SMPTE 331M
} }
pkt->size = data_ptr - pkt->data; av_shrink_packet(pkt, data_ptr - pkt->data);
return 0; return 0;
} }
@ -323,12 +324,16 @@ static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv
if (memcmp(tmpbuf, checkv, 16)) if (memcmp(tmpbuf, checkv, 16))
av_log(s, AV_LOG_ERROR, "probably incorrect decryption key\n"); av_log(s, AV_LOG_ERROR, "probably incorrect decryption key\n");
size -= 32; size -= 32;
av_get_packet(pb, pkt, size); size = av_get_packet(pb, pkt, size);
if (size < 0)
return size;
else if (size < plaintext_size)
return AVERROR_INVALIDDATA;
size -= plaintext_size; size -= plaintext_size;
if (mxf->aesc) if (mxf->aesc)
av_aes_crypt(mxf->aesc, &pkt->data[plaintext_size], av_aes_crypt(mxf->aesc, &pkt->data[plaintext_size],
&pkt->data[plaintext_size], size >> 4, ivec, 1); &pkt->data[plaintext_size], size >> 4, ivec, 1);
pkt->size = orig_size; av_shrink_packet(pkt, orig_size);
pkt->stream_index = index; pkt->stream_index = index;
avio_skip(pb, end - avio_tell(pb)); avio_skip(pb, end - avio_tell(pb));
return 0; return 0;
@ -365,8 +370,11 @@ static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt)
av_log(s, AV_LOG_ERROR, "error reading D-10 aes3 frame\n"); av_log(s, AV_LOG_ERROR, "error reading D-10 aes3 frame\n");
return -1; return -1;
} }
} else } else {
av_get_packet(s->pb, pkt, klv.length); int ret = av_get_packet(s->pb, pkt, klv.length);
if (ret < 0)
return ret;
}
pkt->stream_index = index; pkt->stream_index = index;
pkt->pos = klv.offset; pkt->pos = klv.offset;
return 0; return 0;

View File

@ -53,22 +53,13 @@ const AVOption *av_next_option(void *obj, const AVOption *last)
else return (*(AVClass**)obj)->option; else return (*(AVClass**)obj)->option;
} }
static int av_set_number2(void *obj, const char *name, double num, int den, int64_t intnum, const AVOption **o_out) static int write_number(void *obj, const AVOption *o, void *dst, double num, int den, int64_t intnum)
{ {
const AVOption *o = av_opt_find(obj, name, NULL, 0, 0);
void *dst;
if (o_out)
*o_out= o;
if (!o)
return AVERROR_OPTION_NOT_FOUND;
if (o->max*den < num*intnum || o->min*den > num*intnum) { if (o->max*den < num*intnum || o->min*den > num*intnum) {
av_log(obj, AV_LOG_ERROR, "Value %lf for parameter '%s' out of range\n", num, name); av_log(obj, AV_LOG_ERROR, "Value %lf for parameter '%s' out of range\n", num, o->name);
return AVERROR(ERANGE); return AVERROR(ERANGE);
} }
dst= ((uint8_t*)obj) + o->offset;
switch (o->type) { switch (o->type) {
case FF_OPT_TYPE_FLAGS: case FF_OPT_TYPE_FLAGS:
case FF_OPT_TYPE_INT: *(int *)dst= llrint(num/den)*intnum; break; case FF_OPT_TYPE_INT: *(int *)dst= llrint(num/den)*intnum; break;
@ -85,15 +76,6 @@ static int av_set_number2(void *obj, const char *name, double num, int den, int6
return 0; return 0;
} }
static const AVOption *av_set_number(void *obj, const char *name, double num, int den, int64_t intnum)
{
const AVOption *o = NULL;
if (av_set_number2(obj, name, num, den, intnum, &o) < 0)
return NULL;
else
return o;
}
static const double const_values[] = { static const double const_values[] = {
M_PI, M_PI,
M_E, M_E,
@ -115,10 +97,98 @@ static int hexchar2int(char c) {
return -1; return -1;
} }
static int set_string_binary(void *obj, const AVOption *o, const char *val, uint8_t **dst)
{
int *lendst = (int *)(dst + 1);
uint8_t *bin, *ptr;
int len = strlen(val);
av_freep(dst);
*lendst = 0;
if (len & 1)
return AVERROR(EINVAL);
len /= 2;
ptr = bin = av_malloc(len);
while (*val) {
int a = hexchar2int(*val++);
int b = hexchar2int(*val++);
if (a < 0 || b < 0) {
av_free(bin);
return AVERROR(EINVAL);
}
*ptr++ = (a << 4) | b;
}
*dst = bin;
*lendst = len;
return 0;
}
static int set_string(void *obj, const AVOption *o, const char *val, uint8_t **dst)
{
av_freep(dst);
*dst = av_strdup(val);
return 0;
}
static int set_string_number(void *obj, const AVOption *o, const char *val, void *dst)
{
int ret = 0, notfirst = 0;
for (;;) {
int i;
char buf[256];
int cmd = 0;
double d;
if (*val == '+' || *val == '-')
cmd = *(val++);
for (i = 0; i < sizeof(buf) - 1 && val[i] && val[i] != '+' && val[i] != '-'; i++)
buf[i] = val[i];
buf[i] = 0;
{
const AVOption *o_named = av_opt_find(obj, buf, o->unit, 0, 0);
if (o_named && o_named->type == FF_OPT_TYPE_CONST)
d = o_named->default_val.dbl;
else if (!strcmp(buf, "default")) d = o->default_val.dbl;
else if (!strcmp(buf, "max" )) d = o->max;
else if (!strcmp(buf, "min" )) d = o->min;
else if (!strcmp(buf, "none" )) d = 0;
else if (!strcmp(buf, "all" )) d = ~0;
else {
int res = av_expr_parse_and_eval(&d, buf, const_names, const_values, NULL, NULL, NULL, NULL, NULL, 0, obj);
if (res < 0) {
av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\"\n", val);
return res;
}
}
}
if (o->type == FF_OPT_TYPE_FLAGS) {
if (cmd == '+') d = av_get_int(obj, o->name, NULL) | (int64_t)d;
else if (cmd == '-') d = av_get_int(obj, o->name, NULL) &~(int64_t)d;
} else {
if (cmd == '+') d = notfirst*av_get_double(obj, o->name, NULL) + d;
else if (cmd == '-') d = notfirst*av_get_double(obj, o->name, NULL) - d;
}
if ((ret = write_number(obj, o, dst, d, 1, 1)) < 0)
return ret;
val += i;
if (!*val)
return 0;
notfirst = 1;
}
return 0;
}
int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out) int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out)
{ {
int ret;
const AVOption *o = av_opt_find(obj, name, NULL, 0, 0); const AVOption *o = av_opt_find(obj, name, NULL, 0, 0);
void *dst;
if (o_out) if (o_out)
*o_out = o; *o_out = o;
if (!o) if (!o)
@ -126,100 +196,50 @@ int av_set_string3(void *obj, const char *name, const char *val, int alloc, cons
if (!val && o->type != FF_OPT_TYPE_STRING) if (!val && o->type != FF_OPT_TYPE_STRING)
return AVERROR(EINVAL); return AVERROR(EINVAL);
if (o->type == FF_OPT_TYPE_BINARY) { dst = ((uint8_t*)obj) + o->offset;
uint8_t **dst = (uint8_t **)(((uint8_t*)obj) + o->offset); switch (o->type) {
int *lendst = (int *)(dst + 1); case FF_OPT_TYPE_STRING: return set_string(obj, o, val, dst);
uint8_t *bin, *ptr; case FF_OPT_TYPE_BINARY: return set_string_binary(obj, o, val, dst);
int len = strlen(val); case FF_OPT_TYPE_FLAGS:
av_freep(dst); case FF_OPT_TYPE_INT:
*lendst = 0; case FF_OPT_TYPE_INT64:
if (len & 1) return AVERROR(EINVAL); case FF_OPT_TYPE_FLOAT:
len /= 2; case FF_OPT_TYPE_DOUBLE:
ptr = bin = av_malloc(len); case FF_OPT_TYPE_RATIONAL: return set_string_number(obj, o, val, dst);
while (*val) {
int a = hexchar2int(*val++);
int b = hexchar2int(*val++);
if (a < 0 || b < 0) {
av_free(bin);
return AVERROR(EINVAL);
}
*ptr++ = (a << 4) | b;
}
*dst = bin;
*lendst = len;
return 0;
}
if (o->type != FF_OPT_TYPE_STRING) {
int notfirst=0;
for (;;) {
int i;
char buf[256];
int cmd=0;
double d;
if (*val == '+' || *val == '-')
cmd= *(val++);
for (i=0; i<sizeof(buf)-1 && val[i] && val[i]!='+' && val[i]!='-'; i++)
buf[i]= val[i];
buf[i]=0;
{
const AVOption *o_named = av_opt_find(obj, buf, o->unit, 0, 0);
if (o_named && o_named->type == FF_OPT_TYPE_CONST)
d= o_named->default_val.dbl;
else if (!strcmp(buf, "default")) d= o->default_val.dbl;
else if (!strcmp(buf, "max" )) d= o->max;
else if (!strcmp(buf, "min" )) d= o->min;
else if (!strcmp(buf, "none" )) d= 0;
else if (!strcmp(buf, "all" )) d= ~0;
else {
int res = av_expr_parse_and_eval(&d, buf, const_names, const_values, NULL, NULL, NULL, NULL, NULL, 0, obj);
if (res < 0) {
av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\"\n", val);
return res;
}
}
}
if (o->type == FF_OPT_TYPE_FLAGS) {
if (cmd=='+') d= av_get_int(obj, name, NULL) | (int64_t)d;
else if (cmd=='-') d= av_get_int(obj, name, NULL) &~(int64_t)d;
} else {
if (cmd=='+') d= notfirst*av_get_double(obj, name, NULL) + d;
else if (cmd=='-') d= notfirst*av_get_double(obj, name, NULL) - d;
}
if ((ret = av_set_number2(obj, name, d, 1, 1, o_out)) < 0)
return ret;
val+= i;
if (!*val)
return 0;
notfirst=1;
}
} }
if (alloc) { av_log(obj, AV_LOG_ERROR, "Invalid option type.\n");
av_free(*(void**)(((uint8_t*)obj) + o->offset)); return AVERROR(EINVAL);
val= av_strdup(val); }
}
memcpy(((uint8_t*)obj) + o->offset, &val, sizeof(val)); static const AVOption *set_number(void *obj, const char *name, double num, int den, int64_t intnum)
return 0; {
const AVOption *o = av_opt_find(obj, name, NULL, 0, 0);
void *dst;
if (!o)
return NULL;
dst = ((uint8_t*)obj) + o->offset;
if (write_number(obj, o, dst, num, den, intnum) < 0)
return NULL;
else
return o;
} }
const AVOption *av_set_double(void *obj, const char *name, double n) const AVOption *av_set_double(void *obj, const char *name, double n)
{ {
return av_set_number(obj, name, n, 1, 1); return set_number(obj, name, n, 1, 1);
} }
const AVOption *av_set_q(void *obj, const char *name, AVRational n) const AVOption *av_set_q(void *obj, const char *name, AVRational n)
{ {
return av_set_number(obj, name, n.num, n.den, 1); return set_number(obj, name, n.num, n.den, 1);
} }
const AVOption *av_set_int(void *obj, const char *name, int64_t n) const AVOption *av_set_int(void *obj, const char *name, int64_t n)
{ {
return av_set_number(obj, name, 1, 1, n); return set_number(obj, name, 1, 1, n);
} }
/** /**

View File

@ -129,9 +129,7 @@ const AVOption *av_find_opt(void *obj, const char *name, const char *unit, int m
* similarly, '-' unsets a flag. * similarly, '-' unsets a flag.
* @param[out] o_out if non-NULL put here a pointer to the AVOption * @param[out] o_out if non-NULL put here a pointer to the AVOption
* found * found
* @param alloc when 1 then the old value will be av_freed() and the * @param alloc this parameter is currently ignored
* new av_strduped()
* when 0 then no av_free() nor av_strdup() will be used
* @return 0 if the value has been set, or an AVERROR code in case of * @return 0 if the value has been set, or an AVERROR code in case of
* error: * error:
* AVERROR_OPTION_NOT_FOUND if no matching option exists * AVERROR_OPTION_NOT_FOUND if no matching option exists