31 #define MAX_TABLE_DEPTH(table_bits, max_bits) ((max_bits+table_bits-1)/table_bits)
37 #define DC_VLC_MTD MAX_TABLE_DEPTH(DC_VLC_BITS, MAX_DC_VLC_BITS)
38 #define AC_VLC_MTD MAX_TABLE_DEPTH(AC_VLC_BITS, MAX_AC_VLC_BITS)
39 #define OR_VLC_MTD MAX_TABLE_DEPTH(OR_VLC_BITS, MAX_OR_VLC_BITS)
49 static const uint16_t
sizes[8*4 + 8*2 + 2 + 4] = {
50 576, 548, 582, 618, 546, 616, 560, 642,
51 584, 582, 704, 664, 512, 544, 656, 640,
52 512, 648, 582, 566, 532, 614, 596, 648,
53 586, 552, 584, 590, 544, 578, 584, 624,
55 528, 528, 526, 528, 536, 528, 526, 544,
56 544, 512, 512, 528, 528, 544, 512, 544,
58 128, 128, 128, 128, 128, 128};
62 #define init_ac_vlc(dst,src) \
63 dst.table = &table[offset]; \
64 dst.table_allocated = sizes[sizeidx]; \
65 offset += sizes[sizeidx++]; \
70 INIT_VLC_USE_NEW_STATIC)
81 #define init_dc_vlc(dst,src) \
82 dst.table = &table[offset]; \
83 dst.table_allocated = sizes[sizeidx]; \
84 offset += sizes[sizeidx++]; \
89 INIT_VLC_USE_NEW_STATIC);
97 #define init_or_vlc(dst,src) \
98 dst.table = &table[offset]; \
99 dst.table_allocated = sizes[sizeidx]; \
100 offset += sizes[sizeidx++]; \
105 INIT_VLC_USE_NEW_STATIC);
112 if (offset !=
sizeof(table)/
sizeof(
VLC_TYPE)/2)
132 w->
j_ac_vlc[mode] = &j_ac_vlc[w->
quant<13][mode>>1][table_index];
150 #define extra_bits(eb) (eb)
151 #define extra_run (0xFF<<8)
152 #define extra_level (0x00<<8)
153 #define run_offset(r) ((r)<<16)
154 #define level_offset(l) ((l)<<24)
199 int *
const run,
int *
const level,
int *
const final){
214 (*final) = t = (i>22);
223 l=(0xE50000>>(i&(0x1E)))&3;
224 t=(0x01030F>>(l<<3));
238 (*run) =(sm&0xff) + (e&( mask));
239 (*level)=(sm>>8) + (e&(~mask));
242 static const uint8_t crazy_mix_runlevel[32]={
243 0x22,0x32,0x33,0x53,0x23,0x42,0x43,0x63,
244 0x24,0x52,0x34,0x73,0x25,0x62,0x44,0x83,
245 0x26,0x72,0x35,0x54,0x27,0x82,0x45,0x64,
246 0x28,0x92,0x36,0x74,0x29,0xa2,0x46,0x84};
250 (*run) =crazy_mix_runlevel[e]>>4;
251 (*level)=crazy_mix_runlevel[e]&0x0F;
261 static const uint8_t
dc_index_offset[] ={ 0, 1,2, 3,4, 5,7, 9,13, 17,25, 33,49, 65,97, 129,193};
295 (*level)= (i ^ e) - e;
308 &range, &sum, w->
edges);
317 if(range < quant || range < 3){
329 if(range < 2*w->quant){
330 if( (w->
edges&3) == 0){
338 static const uint8_t prediction_table[3][12]={
339 {0,8,4, 10,11, 2,6,9,1,3,5,7},
340 {4,0,8, 11,10, 3,5,2,6,9,1,7},
341 {8,0,4, 10,11, 1,7,2,6,9,3,5}
418 i=( 0xFFEAF4C4>>(2*b+8*
a) )&3;
420 else w->
orient=( 0xFFEAD8>>(2*c+8*(w->
quant>12)) )&3;
441 #define B(x,y) s->block[0][s->dsp.idct_permutation[(x)+(y)*8]]
442 #define T(x) ((x) * dc_level + 0x8000) >> 16;
517 256, 256, 256, 256, 256, 256, 259, 262,
518 265, 269, 272, 275, 278, 282, 285, 288,
519 292, 295, 299, 303, 306, 310, 314, 317,
520 321, 325, 329, 333, 337, 341, 345, 349,
521 353, 358, 362, 366, 371, 375, 379, 384,
522 389, 393, 398, 403, 408, 413, 417, 422,
523 428, 433, 438, 443, 448, 454, 459, 465,
524 470, 476, 482, 488, 493, 499, 505, 511
532 int ac_mode,dc_mode,est_run,dc_level;
535 int use_quant_matrix;
557 use_quant_matrix = 0;
591 level= (level+1) * w->
dquant;
595 level = (level ^ sign) - sign;
597 if(use_quant_matrix){
606 if(w->
flat_dc && ((
unsigned)(dc_level+1)) < 3){
609 int32_t dc_quant = !chroma ? w->
quant:
613 dc_level+= (w->
predicted_dc*divide_quant + (1<<12) )>>13;
620 zeros_only = (dc_level == 0);
629 if( (
unsigned int)(dc_level+1) >= 3 && (w->
edges&3) != 3 ){
633 direction= (0x6A017C>>(w->
orient*2))&3;
658 uint8_t* ptr = s->
dest[chroma];
661 if(!( (w->
edges&2) || ( zeros_only && (w->
orient|4)==4 ) )){
664 if(!( (w->
edges&1) || ( zeros_only && (w->
orient|8)==8 ) )){
681 s->
dest[0] += s->
mb_y * linesize << 3;
682 s->
dest[1] += ( s->
mb_y&(~1) ) * uvlinesize << 2;
683 s->
dest[2] += ( s->
mb_y&(~1) ) * uvlinesize << 2;
732 w->
quant = dquant >> 1;
733 w->
qsum = quant_offset;
static void x8_get_prediction(IntraX8Context *const w)
static void x8_ac_compensation(IntraX8Context *const w, int const direction, int const dc_level)
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
void(* x8_v_loop_filter)(uint8_t *src, int stride, int qscale)
static void dsp_x8_put_solidcolor(uint8_t const pix, uint8_t *dst, int const linesize)
static void x8_update_predictions(IntraX8Context *const w, const int orient, const int est_run)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
void(* idct_add)(uint8_t *dest, int line_size, DCTELEM *block)
block -> idct -> add dest -> clip to unsigned 8 bit -> dest.
static const uint16_t x8_ac0_highquant_table[8][77][2]
void(* x8_setup_spatial_compensation)(uint8_t *src, uint8_t *dst, int linesize, int *range, int *sum, int edges)
static int x8_decode_intra_mb(IntraX8Context *const w, const int chroma)
static void x8_reset_vlc_tables(IntraX8Context *w)
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
Picture current_picture
copy of the current picture structure.
#define init_ac_vlc(dst, src)
static const uint16_t x8_orient_highquant_table[2][12][2]
bitstream reader API header.
uint8_t idct_permutation[64]
idct input permutation.
static int x8_get_dc_rlf(IntraX8Context *const w, int const mode, int *const level, int *const final)
int mb_height
number of MBs horizontally & vertically
static const uint16_t mask[17]
static int x8_get_orient_vlc(IntraX8Context *w)
static const int16_t quant_table[64]
uint8_t * edge_emu_buffer
temporary buffer for if MVs point to out-of-frame data
static const uint16_t x8_ac0_lowquant_table[8][77][2]
void av_log(void *avcl, int level, const char *fmt,...)
void(* clear_block)(DCTELEM *block)
int resync_mb_x
x position of last resync marker
void ff_er_add_slice(MpegEncContext *s, int startx, int starty, int endx, int endy, int status)
Add a slice.
static const uint16_t x8_orient_lowquant_table[4][12][2]
av_cold void ff_intrax8_common_init(IntraX8Context *w, MpegEncContext *const s)
Initialize IntraX8 frame decoder.
av_cold void ff_intrax8_common_end(IntraX8Context *w)
Destroy IntraX8 frame structure.
uint8_t * mbskip_table
used to avoid copy if macroblock skipped (for black regions for example) and used for b-frame encodin...
static VLC j_dc_vlc[2][8]
static const uint32_t ac_decode_table[]
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
uint8_t * mbintra_table
used to avoid setting {ac, dc, cbp}-pred stuff to zero on inter MB decoding
static const uint16_t x8_dc_lowquant_table[8][34][2]
static const uint8_t dc_index_offset[]
static VLC j_ac_vlc[2][2][8]
const uint8_t wmv1_scantable[WMV1_SCANTABLE_COUNT][64]
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
#define init_dc_vlc(dst, src)
static const uint16_t x8_ac1_highquant_table[8][77][2]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const uint16_t x8_dc_highquant_table[8][34][2]
static unsigned int get_bits1(GetBitContext *s)
void ff_draw_horiz_band(MpegEncContext *s, int y, int h)
static void x8_init_block_index(MpegEncContext *s)
DSPContext dsp
pointers for accelerated dsp functions
int ff_intrax8_decode_picture(IntraX8Context *const w, int dquant, int quant_offset)
Decode single IntraX8 frame.
DCTELEM(* block)[64]
points to one of the following blocks
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int8_t * qscale_table
QP table.
int mb_stride
mb_width+1 used for some arrays to allow simple addressing of left & top MBs without sig11 ...
static void x8_get_ac_rlf(IntraX8Context *const w, const int mode, int *const run, int *const level, int *const final)
static void x8_select_ac_table(IntraX8Context *const w, int mode)
#define init_or_vlc(dst, src)
void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable)
int resync_mb_y
y position of last resync marker
static const uint16_t x8_ac1_lowquant_table[8][77][2]
VLC_TYPE(* table)[2]
code, bits
static void x8_get_prediction_chroma(IntraX8Context *const w)
static int x8_setup_spatial_predictor(IntraX8Context *const w, const int chroma)
static av_cold void x8_vlc_init(void)
int divide_quant_dc_chroma
void(* x8_h_loop_filter)(uint8_t *src, int stride, int qscale)
static VLC j_orient_vlc[2][4]
void(* x8_spatial_compensation[12])(uint8_t *src, uint8_t *dst, int linesize)
static const int sizes[][2]
uint8_t * prediction_table