33 #define MAX_TABLE_DEPTH(table_bits, max_bits) \ 34 ((max_bits + table_bits - 1) / table_bits) 40 #define DC_VLC_MTD MAX_TABLE_DEPTH(DC_VLC_BITS, MAX_DC_VLC_BITS) 41 #define AC_VLC_MTD MAX_TABLE_DEPTH(AC_VLC_BITS, MAX_AC_VLC_BITS) 42 #define OR_VLC_MTD MAX_TABLE_DEPTH(OR_VLC_BITS, MAX_OR_VLC_BITS) 53 static const uint16_t
sizes[8 * 4 + 8 * 2 + 2 + 4] = {
54 576, 548, 582, 618, 546, 616, 560, 642,
55 584, 582, 704, 664, 512, 544, 656, 640,
56 512, 648, 582, 566, 532, 614, 596, 648,
57 586, 552, 584, 590, 544, 578, 584, 624,
59 528, 528, 526, 528, 536, 528, 526, 544,
60 544, 512, 512, 528, 528, 544, 512, 544,
62 128, 128, 128, 128, 128, 128,
68 #define init_ac_vlc(dst, src) \ 70 dst.table = &table[offset]; \ 71 dst.table_allocated = sizes[sizeidx]; \ 72 offset += sizes[sizeidx++]; \ 73 init_vlc(&dst, AC_VLC_BITS, 77, &src[1], 4, 2, &src[0], 4, 2, \ 74 INIT_VLC_USE_NEW_STATIC); \ 77 for (i = 0; i < 8; i++) {
86 #define init_dc_vlc(dst, src) \ 88 dst.table = &table[offset]; \ 89 dst.table_allocated = sizes[sizeidx]; \ 90 offset += sizes[sizeidx++]; \ 91 init_vlc(&dst, DC_VLC_BITS, 34, &src[1], 4, 2, &src[0], 4, 2, \ 92 INIT_VLC_USE_NEW_STATIC); \ 95 for (i = 0; i < 8; i++) {
102 #define init_or_vlc(dst, src) \ 104 dst.table = &table[offset]; \ 105 dst.table_allocated = sizes[sizeidx]; \ 106 offset += sizes[sizeidx++]; \ 107 init_vlc(&dst, OR_VLC_BITS, 12, &src[1], 4, 2, &src[0], 4, 2, \ 108 INIT_VLC_USE_NEW_STATIC); \ 111 for (i = 0; i < 2; i++)
113 for (i = 0; i < 4; i++)
117 if (offset !=
sizeof(table) /
sizeof(
VLC_TYPE) / 2) {
119 sizeof(table) /
sizeof(
VLC_TYPE) / 2, offset);
144 w->
j_ac_vlc[mode] = &j_ac_vlc[w->
quant < 13][mode >> 1][table_index];
161 #define extra_bits(eb) (eb) // 3 bits 162 #define extra_run (0xFF << 8) // 1 bit 163 #define extra_level (0x00 << 8) // 1 bit 164 #define run_offset(r) ((r) << 16) // 6 bits 165 #define level_offset(l) ((l) << 24) // 5 bits 209 int *
const run,
int *
const level,
int *
const final)
238 l = (0xE50000 >> (i & 0x1E)) & 3;
242 t = 0x01030F >> (l << 3);
258 *run = (sm & 0xff) + (e & mask);
259 *level = (sm >> 8) + (e & ~mask);
260 *
final = i > (58 - 46);
262 static const uint8_t crazy_mix_runlevel[32] = {
263 0x22, 0x32, 0x33, 0x53, 0x23, 0x42, 0x43, 0x63,
264 0x24, 0x52, 0x34, 0x73, 0x25, 0x62, 0x44, 0x83,
265 0x26, 0x72, 0x35, 0x54, 0x27, 0x82, 0x45, 0x64,
266 0x28, 0x92, 0x36, 0x74, 0x29, 0xa2, 0x46, 0x84,
271 *run = crazy_mix_runlevel[e] >> 4;
272 *level = crazy_mix_runlevel[e] & 0x0F;
285 0, 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
289 int *
const level,
int *
const final)
320 *level = (i ^ e) - e;
334 &range, &sum, w->
edges);
343 if (range < quant || range < 3) {
358 if (range < 2 * w->quant) {
359 if ((w->
edges & 3) == 0) {
369 static const uint8_t prediction_table[3][12] = {
370 { 0, 8, 4, 10, 11, 2, 6, 9, 1, 3, 5, 7 },
371 { 4, 0, 8, 11, 10, 3, 5, 2, 6, 9, 1, 7 },
372 { 8, 0, 4, 10, 11, 1, 7, 2, 6, 9, 3, 5 },
418 switch (w->
edges & 3) {
453 i = (0xFFEAF4C4 >> (2 * b + 8 *
a)) & 3;
457 w->
orient = (0xFFEAD8 >> (2 * c + 8 * (w->
quant > 12))) & 3;
483 #define B(x, y) w->block[0][w->idsp.idct_permutation[(x) + (y) * 8]] 484 #define T(x) ((x) * dc_level + 0x8000) >> 16; 554 for (k = 0; k < 8; k++) {
561 256, 256, 256, 256, 256, 256, 259, 262,
562 265, 269, 272, 275, 278, 282, 285, 288,
563 292, 295, 299, 303, 306, 310, 314, 317,
564 321, 325, 329, 333, 337, 341, 345, 349,
565 353, 358, 362, 366, 371, 375, 379, 384,
566 389, 393, 398, 403, 408, 413, 417, 422,
567 428, 433, 438, 443, 448, 454, 459, 465,
568 470, 476, 482, 488, 493, 499, 505, 511,
575 int ac_mode, dc_mode, est_run, dc_level;
578 int use_quant_matrix;
600 use_quant_matrix = 0;
634 level = (level + 1) * w->
dquant;
638 level = (level ^ sign) - sign;
640 if (use_quant_matrix)
649 if (w->
flat_dc && ((
unsigned) (dc_level + 1)) < 3) {
657 dc_level += (w->
predicted_dc * divide_quant + (1 << 12)) >> 13;
665 zeros_only = dc_level == 0;
673 if ((
unsigned int) (dc_level + 1) >= 3 && (w->
edges & 3) != 3) {
677 direction = (0x6A017C >> (w->
orient * 2)) & 3;
678 if (direction != 3) {
705 if (!((w->
edges & 2) || (zeros_only && (w->
orient | 4) == 4)))
708 if (!((w->
edges & 1) || (zeros_only && (w->
orient | 8) == 8)))
719 const int linesize = frame->
linesize[0];
720 const int uvlinesize = frame->
linesize[1];
726 w->
dest[0] += w->
mb_y * linesize << 3;
728 w->
dest[1] += (w->
mb_y & ~1) * uvlinesize << 2;
729 w->
dest[2] += (w->
mb_y & ~1) * uvlinesize << 2;
734 int16_t (*
block)[64],
735 int block_last_index[12],
736 int mb_width,
int mb_height)
774 int dquant,
int quant_offset,
775 int loopfilter,
int lowdelay)
781 w->
quant = dquant >> 1;
782 w->
qsum = quant_offset;
833 (w->
mb_y - 1) * 8, 16,
static void x8_get_prediction(IntraX8Context *const w)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
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(* spatial_compensation[12])(uint8_t *src, uint8_t *dst, int linesize)
void(* clear_block)(int16_t *block)
static void dsp_x8_put_solidcolor(const uint8_t pix, uint8_t *dst, const int linesize)
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, 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)
void(* idct_add)(uint8_t *dest, int line_size, int16_t *block)
block -> idct -> add dest -> clip to unsigned 8 bit -> dest.
static const uint16_t x8_ac0_highquant_table[8][77][2]
static int x8_decode_intra_mb(IntraX8Context *const w, const int chroma)
void ff_draw_horiz_band(AVCodecContext *avctx, AVFrame *cur, AVFrame *last, int y, int h, int picture_structure, int first_field, int low_delay)
Draw a horizontal band if supported.
av_cold int ff_intrax8_common_init(AVCodecContext *avctx, IntraX8Context *w, IDCTDSPContext *idsp, int16_t(*block)[64], int block_last_index[12], int mb_width, int mb_height)
Initialize IntraX8 frame decoder.
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 ...
int ff_intrax8_decode_picture(IntraX8Context *const w, Picture *pict, GetBitContext *gb, int *mb_x, int *mb_y, int dquant, int quant_offset, int loopfilter, int lowdelay)
Decode single IntraX8 frame.
#define init_ac_vlc(dst, src)
static const uint16_t x8_orient_highquant_table[2][12][2]
bitstream reader API header.
static void x8_init_block_index(IntraX8Context *w, AVFrame *frame)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const uint16_t mask[17]
static const int sizes[][2]
static int x8_get_orient_vlc(IntraX8Context *w)
static const int16_t quant_table[64]
static const uint16_t x8_ac0_lowquant_table[8][77][2]
int * block_last_index
last nonzero coefficient in block
const uint8_t ff_wmv1_scantable[WMV1_SCANTABLE_COUNT][64]
static const uint16_t x8_orient_lowquant_table[4][12][2]
av_cold void ff_intrax8_common_end(IntraX8Context *w)
Destroy IntraX8 frame structure.
static VLC j_dc_vlc[2][8]
void(* setup_spatial_compensation)(uint8_t *src, uint8_t *dst, int linesize, int *range, int *sum, int edges)
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.
uint8_t idct_permutation[64]
IDCT input permutation.
static const uint16_t x8_dc_lowquant_table[8][34][2]
if(ac->has_optimized_func)
static const uint8_t dc_index_offset[]
static VLC j_ac_vlc[2][2][8]
Libavcodec external API header.
av_cold void ff_blockdsp_init(BlockDSPContext *c, AVCodecContext *avctx)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
#define init_dc_vlc(dst, src)
static const uint16_t x8_ac1_highquant_table[8][77][2]
main external API structure.
static const uint16_t x8_dc_highquant_table[8][34][2]
static unsigned int get_bits1(GetBitContext *s)
av_cold void ff_intrax8dsp_init(IntraX8DSPContext *dsp)
static av_cold int x8_vlc_init(void)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
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)
void(* h_loop_filter)(uint8_t *src, int stride, int qscale)
#define init_or_vlc(dst, src)
static int x8_get_dc_rlf(IntraX8Context *const w, const int mode, int *const level, int *const final)
av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable)
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)
int divide_quant_dc_chroma
static VLC j_orient_vlc[2][4]
void(* v_loop_filter)(uint8_t *src, int stride, int qscale)
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
uint8_t * prediction_table
static void x8_ac_compensation(IntraX8Context *const w, const int direction, const int dc_level)