50 #define V2_INTRA_CBPC_VLC_BITS 3
51 #define V2_MB_TYPE_VLC_BITS 7
53 #define V2_MV_VLC_BITS 9
54 #define TEX_VLC_BITS 9
56 #define DEFAULT_INTER_INDEX 3
62 int level, uni_code, uni_len;
64 for(level=-256; level<256; level++){
75 l= (-
level) ^ ((1 << size) - 1);
82 uni_code ^= (1<<uni_len)-1;
85 uni_code<<=
size; uni_code|=l;
88 uni_code<<=1; uni_code|=1;
98 uni_code ^= (1<<uni_len)-1;
101 uni_code<<=
size; uni_code|=l;
104 uni_code<<=1; uni_code|=1;
116 static int initialized=0;
138 #if CONFIG_VC1_DECODER
215 return FASTDIV((sum + (scale>>1)), scale);
220 int16_t **dc_val_ptr,
int *dir_ptr)
239 b = dc_val[ - 1 -
wrap];
250 #if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE
252 "movl %3, %%eax \n\t"
253 "shrl $1, %%eax \n\t"
254 "addl %%eax, %2 \n\t"
255 "addl %%eax, %1 \n\t"
256 "addl %0, %%eax \n\t"
258 "movl %%edx, %0 \n\t"
259 "movl %1, %%eax \n\t"
261 "movl %%edx, %1 \n\t"
262 "movl %2, %%eax \n\t"
264 "movl %%edx, %2 \n\t"
265 :
"+b" (
a),
"+c" (b),
"+D" (c)
275 a = (a + (8 >> 1)) / 8;
276 b = (b + (8 >> 1)) / 8;
277 c = (c + (8 >> 1)) / 8;
279 a =
FASTDIV((a + (scale >> 1)), scale);
280 b =
FASTDIV((b + (scale >> 1)), scale);
281 c =
FASTDIV((c + (scale >> 1)), scale);
298 if (abs(a - b) < abs(b - c)) {
313 if(s->
mb_x==0) a= (1024 + (scale>>1))/
scale;
314 else a=
get_dc(dest-8, wrap, scale*8);
315 if(s->
mb_y==0) c= (1024 + (scale>>1))/
scale;
316 else c=
get_dc(dest-8*wrap, wrap, scale*8);
343 if (abs(a - b) < abs(b - c)) {
352 if (abs(a - b) <= abs(b - c)) {
362 *dc_val_ptr = &dc_val[0];
380 int code, val, sign, shift;
383 av_dlog(s,
"MV code %d at %d %d pred: %d\n", code, s->
mb_x,s->
mb_y, pred);
393 val = (val - 1) << shift;
433 if(code<0 || code>7){
485 for (i = 0; i < 6; i++) {
534 int val = ((code >> (5 - i)) & 1);
540 cbp |= val << (5 - i);
560 ((cbp & 3) ? 1 : 0) +((cbp & 0x3C)? 2 : 0),
576 for (i = 0; i < 6; i++) {
702 if(start_code!=0x00000100){
720 if(!had_i)
return -1;
856 if(left>=length && left<length+8)
865 else if(left<length+8)
907 }
else if (level != 0) {
938 int n,
int coded,
const uint8_t *scan_table)
979 if (dc_pred_dir == 0)
989 qadd = (s->
qscale - 1) | 1;
1058 if(sign) level= -
level;
1061 #if 0 // waste of time / this will detect very few errors
1063 const int abs_level=
FFABS(level);
1064 const int run1= run - rl->
max_run[last][abs_level] - run_diff;
1066 if(abs_level <= rl->max_level[last][run]){
1068 return DECODING_AC_LOST;
1070 if(abs_level <= rl->max_level[last][run]*2){
1072 return DECODING_AC_LOST;
1074 if(run1>=0 && abs_level <= rl->max_level[last][run1]){
1076 return DECODING_AC_LOST;
1082 if (level>0) level= level * qmul + qadd;
1083 else level= level * qmul - qadd;
1084 #if 0 // waste of time too :(
1085 if(level>2048 || level<-2048){
1087 return DECODING_AC_LOST;
1092 #ifdef ERROR_DETAILS
1095 else if((i>62 && i<192) || i>192+63)
1102 i+= run + rl->
max_run[run>>7][level/qmul] + run_diff;
1105 #ifdef ERROR_DETAILS
1108 else if((i>62 && i<192) || i>192+63)
1117 level = level + rl->
max_level[run>>7][(run-1)&63] * qmul;
1120 #ifdef ERROR_DETAILS
1123 else if((i>62 && i<192) || i>192+63)
1131 #ifdef ERROR_DETAILS
1134 else if((i>62 && i<192) || i>192+63)
1151 block[scan_table[i]] =
level;
1155 block[scan_table[i]] =
level;
1173 int *mx_ptr,
int *my_ptr)
1185 if (code == mv->
n) {
1211 .
name =
"msmpeg4v1",
1224 .
name =
"msmpeg4v2",
av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
void ff_mpeg4_pred_ac(MpegEncContext *s, DCTELEM *block, int n, int dir)
Predict the ac.
ScanTable intra_v_scantable
const uint8_t ff_mpeg4_c_dc_scale_table[32]
struct MpegEncContext MpegEncContext
MpegEncContext.
const uint8_t * y_dc_scale_table
qscale -> y_dc_scale table
uint32_t ff_v2_dc_lum_table[512][2]
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
const uint32_t ff_table0_dc_lum[120][2]
VLC ff_h263_intra_MCBPC_vlc
uint32_t ff_v2_dc_chroma_table[512][2]
#define SKIP_COUNTER(name, gb, num)
int msmpeg4_version
0=not msmpeg4, 1=mp41, 2=mp42, 3=mp43/divx3 4=wmv1/7 5=wmv2/8
void ff_init_rl(RLTable *rl, uint8_t static_store[2][2 *MAX_RUN+MAX_LEVEL+3])
AVCodec ff_msmpeg4v2_decoder
int ff_msmpeg4_decode_block(MpegEncContext *s, DCTELEM *block, int n, int coded, const uint8_t *scan_table)
#define DEFAULT_INTER_INDEX
av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (%s)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic?ac->func_descr_generic:ac->func_descr)
#define MB_NON_INTRA_VLC_BITS
av_cold void ff_msmpeg4_common_init(MpegEncContext *s)
int16_t * ff_h263_pred_motion(MpegEncContext *s, int block, int dir, int *px, int *py)
static int msmpeg4v34_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
#define CONFIG_WMV2_DECODER
int8_t * max_run[2]
encoding & decoding
VLC ff_mb_non_intra_vlc[4]
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
const uint32_t ff_inverse[257]
const uint8_t ff_v2_intra_cbpc[4][2]
#define INIT_VLC_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size)
uint8_t ff_static_rl_table_store[NB_RL_TABLES][2][2 *MAX_RUN+MAX_LEVEL+3]
const uint8_t ff_mvtab[33][2]
const uint8_t ff_wmv3_dc_scale_table[32]
int no_rounding
apply no rounding to motion compensation (MPEG4, msmpeg4, ...) for b-frames rounding mode is always 0...
Picture current_picture
copy of the current picture structure.
const uint8_t ff_mpeg4_DCtab_chrom[13][2]
static int msmpeg4_decode_dc(MpegEncContext *s, int n, int *dir_ptr)
int ff_wmv2_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
static int get_bits_count(const GetBitContext *s)
int8_t * max_level[2]
encoding & decoding
uint8_t idct_permutation[64]
idct input permutation.
const uint32_t ff_table0_dc_chroma[120][2]
int mb_height
number of MBs horizontally & vertically
enum AVPixelFormat ff_pixfmt_list_420[]
const uint8_t ff_wmv1_c_dc_scale_table[32]
static int init(AVCodecParserContext *s)
static int get_bits_left(GetBitContext *gb)
int16_t * dc_val[3]
used for mpeg4 DC prediction, all 3 arrays must be continuous
#define UPDATE_CACHE(name, gb)
const uint16_t ff_msmp4_mb_i_table[64][2]
int last_dc[3]
last DC values for MPEG1
int rl_chroma_table_index
int mb_skipped
MUST BE SET only during DECODING.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define FF_DEBUG_PICT_INFO
#define INTER_MCBPC_VLC_BITS
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
#define CLOSE_READER(name, gb)
static int msmpeg4v1_pred_dc(MpegEncContext *s, int n, int32_t **dc_val_ptr)
#define INIT_VLC_RL(rl, static_size)
#define V2_MB_TYPE_VLC_BITS
#define SKIP_BITS(name, gb, num)
int(* decode_mb)(struct MpegEncContext *s, DCTELEM block[6][64])
int ff_h263_decode_init(AVCodecContext *avctx)
const uint8_t ff_mpeg4_DCtab_lum[13][2]
const uint8_t ff_wmv1_scantable[WMV1_SCANTABLE_COUNT][64]
VLC ff_h263_inter_MCBPC_vlc
int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
const uint8_t ff_v2_mb_type[8][2]
int ff_msmpeg4_pred_dc(MpegEncContext *s, int n, int16_t **dc_val_ptr, int *dir_ptr)
const uint8_t * table_mvx
const uint8_t ff_mpeg4_y_dc_scale_table[32]
#define V2_INTRA_CBPC_VLC_BITS
#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update)
const uint8_t * table_mv_bits
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
int ff_msmpeg4_decode_ext_header(MpegEncContext *s, int buf_size)
#define LAST_SKIP_BITS(name, gb, num)
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
int block_last_index[12]
last non zero coefficient in block
const uint32_t ff_table1_dc_chroma[120][2]
RL_VLC_ELEM * rl_vlc[32]
decoding only
#define SHOW_UBITS(name, gb, num)
int block_index[6]
index to current MB in block based arrays with edges
static const float pred[4]
static const int8_t mv[256][2]
uint32_t * mb_type
macroblock type table mb_type_base + mb_width + 2
#define MV_TYPE_16X16
1 vector for the whole mb
int first_slice_line
used in mpeg4 too to handle resync markers
AVCodec ff_msmpeg4v1_decoder
main external API structure.
static void close(AVCodecParserContext *s)
ScanTable intra_scantable
uint8_t * coded_block
used for coded block pattern prediction (msmpeg4v3, wmv1)
int height
picture size. must be a multiple of 16
#define OPEN_READER(name, gb)
const uint16_t * table_mv_code
const uint8_t ff_mpeg1_dc_scale_table[128]
const uint32_t ff_table1_dc_lum[120][2]
static unsigned int get_bits1(GetBitContext *s)
ScanTable intra_h_scantable
static void skip_bits(GetBitContext *s, int n)
int ff_msmpeg4_decode_motion(MpegEncContext *s, int *mx_ptr, int *my_ptr)
#define GET_CACHE(name, gb)
#define MB_INTRA_VLC_BITS
int slice_height
in macroblocks
DSPContext dsp
pointers for accelerated dsp functions
#define SKIP_CACHE(name, gb, num)
static int msmpeg4v2_decode_motion(MpegEncContext *s, int pred, int f_code)
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
int pict_type
AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ...
int bit_rate
wanted bit rate
DCTELEM(* block)[64]
points to one of the following blocks
RLTable ff_rl_table[NB_RL_TABLES]
int ff_msmpeg4_decode_picture_header(MpegEncContext *s)
static const uint16_t scale[4]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
const uint8_t * c_dc_scale_table
qscale -> c_dc_scale table
int mv[2][4][2]
motion vectors for a macroblock first coordinate : 0 = forward 1 = backward second " : depend...
int b8_stride
2*mb_width+1 used for some 8x8 block arrays to allow simple addressing
void(* clear_blocks)(DCTELEM *blocks)
struct AVCodecContext * avctx
#define SHOW_SBITS(name, gb, num)
int mb_stride
mb_width+1 used for some arrays to allow simple addressing of left & top MBs without sig11 ...
const uint8_t ff_wmv1_y_dc_scale_table[32]
int ff_h263_decode_end(AVCodecContext *avctx)
const uint32_t(*const [WMV2_INTER_CBP_TABLE_COUNT] ff_wmv2_inter_table)[2]
void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable)
static int decode012(GetBitContext *gb)
VLC_TYPE(* table)[2]
code, bits
static VLC v2_intra_cbpc_vlc
int linesize
line size, in bytes, may be different from width
int chroma_qscale
chroma QP
const uint8_t ff_old_ff_y_dc_scale_table[32]
#define INTER_INTRA_VLC_BITS
const uint8_t * table_mvy
int workaround_bugs
workaround bugs in encoders which cannot be detected automatically
ScanTable inter_scantable
if inter == intra then intra should be used to reduce tha cache usage
int ff_msmpeg4_coded_block_pred(MpegEncContext *s, int n, uint8_t **coded_block_ptr)
static int msmpeg4v12_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
int h263_aic_dir
AIC direction: 0 = left, 1 = top.
int uvlinesize
line size, for chroma in bytes, may be different from width
static av_cold void init_h263_dc_for_msmpeg4(void)
AVCodec ff_msmpeg4v3_decoder
#define CODEC_CAP_DRAW_HORIZ_BAND
static VLC v2_dc_chroma_vlc
static VLC v2_mb_type_vlc
const uint8_t ff_table_inter_intra[4][2]
VLC ff_msmp4_dc_luma_vlc[2]
#define INTRA_MCBPC_VLC_BITS
VLC ff_msmp4_dc_chroma_vlc[2]
static int get_dc(uint8_t *src, int stride, int scale)