35 #define VLC_BUFFER_SIZE 28150 37 #define MAX_TABLE_DEPTH(table_bits, max_bits) \ 38 ((max_bits + table_bits - 1) / table_bits) 44 #define DC_VLC_MTD MAX_TABLE_DEPTH(DC_VLC_BITS, MAX_DC_VLC_BITS) 45 #define AC_VLC_MTD MAX_TABLE_DEPTH(AC_VLC_BITS, MAX_AC_VLC_BITS) 46 #define OR_VLC_MTD MAX_TABLE_DEPTH(OR_VLC_BITS, MAX_OR_VLC_BITS) 70 for (
int i = 0; i < 2; i++)
71 for (
int j = 0; j < 2; j++)
72 for (
int k = 0; k < 8; k++)
77 for (
int i = 0; i < 2; i++)
78 for (
int j = 0; j < 8; j++)
83 for (i = 0; i < 2; i++)
86 for (i = 0; i < 4; i++)
125 #define extra_bits(eb) (eb) // 3 bits 126 #define extra_run (0xFF << 8) // 1 bit 127 #define extra_level (0x00 << 8) // 1 bit 128 #define run_offset(r) ((r) << 16) // 6 bits 129 #define level_offset(l) ((l) << 24) // 5 bits 173 int *
const run,
int *
const level,
int *
const final)
202 l = (0xE50000 >> (i & 0x1E)) & 3;
206 t = 0x01030F >> (l << 3);
222 *run = (sm & 0xff) + (e & mask);
223 *level = (sm >> 8) + (e & ~mask);
224 *
final = i > (58 - 46);
226 static const uint8_t crazy_mix_runlevel[32] = {
227 0x22, 0x32, 0x33, 0x53, 0x23, 0x42, 0x43, 0x63,
228 0x24, 0x52, 0x34, 0x73, 0x25, 0x62, 0x44, 0x83,
229 0x26, 0x72, 0x35, 0x54, 0x27, 0x82, 0x45, 0x64,
230 0x28, 0x92, 0x36, 0x74, 0x29, 0xa2, 0x46, 0x84,
235 *run = crazy_mix_runlevel[e] >> 4;
236 *level = crazy_mix_runlevel[e] & 0x0F;
249 0, 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
253 int *
const level,
int *
const final)
282 *level = (i ^ e) - e;
296 &range, &sum, w->
edges);
305 if (range < quant || range < 3) {
320 if (range < 2 * w->quant) {
321 if ((w->
edges & 3) == 0) {
331 static const uint8_t prediction_table[3][12] = {
332 { 0, 8, 4, 10, 11, 2, 6, 9, 1, 3, 5, 7 },
333 { 4, 0, 8, 11, 10, 3, 5, 2, 6, 9, 1, 7 },
334 { 8, 0, 4, 10, 11, 1, 7, 2, 6, 9, 3, 5 },
380 switch (w->
edges & 3) {
415 i = (0xFFEAF4C4 >> (2 * b + 8 *
a)) & 3;
419 w->
orient = (0xFFEAD8 >> (2 * c + 8 * (w->
quant > 12))) & 3;
445 #define B(x,y) w->block[0][w->idct_permutation[(x) + (y) * 8]] 446 #define T(x) ((x) * dc_level + 0x8000) >> 16; 513 const ptrdiff_t linesize)
516 for (k = 0; k < 8; k++) {
523 256, 256, 256, 256, 256, 256, 259, 262,
524 265, 269, 272, 275, 278, 282, 285, 288,
525 292, 295, 299, 303, 306, 310, 314, 317,
526 321, 325, 329, 333, 337, 341, 345, 349,
527 353, 358, 362, 366, 371, 375, 379, 384,
528 389, 393, 398, 403, 408, 413, 417, 422,
529 428, 433, 438, 443, 448, 454, 459, 465,
530 470, 476, 482, 488, 493, 499, 505, 511,
537 int ac_mode, dc_mode, est_run, dc_level;
540 int use_quant_matrix;
562 use_quant_matrix = 0;
596 level = (level + 1) * w->
dquant;
600 level = (level ^ sign) - sign;
602 if (use_quant_matrix)
611 if (w->
flat_dc && ((
unsigned) (dc_level + 1)) < 3) {
619 dc_level += (w->
predicted_dc * divide_quant + (1 << 12)) >> 13;
627 zeros_only = dc_level == 0;
635 if ((
unsigned int) (dc_level + 1) >= 3 && (w->
edges & 3) != 3) {
639 direction = (0x6A017C >> (w->
orient * 2)) & 3;
640 if (direction != 3) {
667 if (!((w->
edges & 2) || (zeros_only && (w->
orient | 4) == 4)))
670 if (!((w->
edges & 1) || (zeros_only && (w->
orient | 8) == 8)))
681 const ptrdiff_t linesize = frame->
linesize[0];
682 const ptrdiff_t uvlinesize = frame->
linesize[1];
688 w->
dest[0] += w->
mb_y * linesize << 3;
690 w->
dest[1] += (w->
mb_y & ~1) * uvlinesize << 2;
691 w->
dest[2] += (w->
mb_y & ~1) * uvlinesize << 2;
696 int16_t (*
block)[64],
697 int block_last_index[12],
698 int mb_width,
int mb_height)
741 int dquant,
int quant_offset,
742 int loopfilter,
int lowdelay)
748 w->
quant = dquant >> 1;
749 w->
qsum = quant_offset;
802 (w->
mb_y - 1) * 8, 16,
static void x8_get_prediction(IntraX8Context *const w)
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(* clear_block)(int16_t *block)
av_cold void ff_blockdsp_init(BlockDSPContext *c, AVCodecContext *avctx)
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static int x8_decode_intra_mb(IntraX8Context *const w, const int chroma)
static void error(const char *err)
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)
static const uint8_t x8_orient_highquant_table[2][12][2]
The exact code depends on how similar the blocks are and how related they are to the block
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int ff_intrax8_decode_picture(IntraX8Context *w, Picture *pict, GetBitContext *gb, int *mb_x, int *mb_y, int dquant, int quant_offset, int loopfilter, int lowdelay)
Decode single IntraX8 frame.
bitstream reader API header.
static const uint16_t table[]
static void x8_init_block_index(IntraX8Context *w, AVFrame *frame)
static int get_bits_left(GetBitContext *gb)
static const uint16_t mask[17]
static const uint8_t x8_ac_quant_table[2][2][8][77][2]
static int x8_get_orient_vlc(IntraX8Context *w)
static const int16_t quant_table[64]
int * block_last_index
last nonzero coefficient in block
simple assert() macros that are a bit more flexible than ISO C assert().
av_cold void ff_wmv2dsp_init(WMV2DSPContext *c)
static const uint8_t x8_dc_quant_table[2][8][34][2]
const uint8_t ff_wmv1_scantable[WMV1_SCANTABLE_COUNT][64]
av_cold void ff_init_scantable_permutation(uint8_t *idct_permutation, enum idct_permutation_type perm_type)
void(* setup_spatial_compensation)(uint8_t *src, uint8_t *dst, ptrdiff_t stride, int *range, int *sum, int edges)
av_cold void ff_intrax8_common_end(IntraX8Context *w)
Destroy IntraX8 frame structure.
static VLC j_dc_vlc[2][8]
static const uint32_t ac_decode_table[]
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
static const uint8_t dc_index_offset[]
static VLC j_ac_vlc[2][2][8]
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
void(* h_loop_filter)(uint8_t *src, ptrdiff_t stride, int qscale)
void(* spatial_compensation[12])(uint8_t *src, uint8_t *dst, ptrdiff_t stride)
static unsigned int get_bits1(GetBitContext *s)
int ff_init_vlc_from_lengths(VLC *vlc_arg, int nb_bits, int nb_codes, const int8_t *lens, int lens_wrap, const void *symbols, int symbols_wrap, int symbols_size, int offset, int flags, void *logctx)
Build VLC decoding tables suitable for use with get_vlc2()
static const uint8_t x8_orient_lowquant_table[4][12][2]
uint8_t idct_permutation[64]
av_cold void ff_intrax8dsp_init(IntraX8DSPContext *dsp)
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)
static int x8_get_dc_rlf(IntraX8Context *const w, const int mode, int *const level, int *const final)
void(* v_loop_filter)(uint8_t *src, ptrdiff_t stride, int qscale)
av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable)
static int ff_thread_once(char *control, void(*routine)(void))
static av_cold void x8_init_vlc(VLC *vlc, int nb_bits, int nb_codes, int *offset, const uint8_t table[][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
static VLC_TYPE vlc_buf[16716][2]
static VLC j_orient_vlc[2][4]
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
#define INIT_VLC_STATIC_OVERLONG
void(* idct_add)(uint8_t *dest, ptrdiff_t line_size, int16_t *block)
mode
Use these values in ebur128_init (or'ed).
static void dsp_x8_put_solidcolor(const uint8_t pix, uint8_t *dst, const ptrdiff_t linesize)
uint8_t * prediction_table
static void x8_ac_compensation(IntraX8Context *const w, const int direction, const int dc_level)