code
stringlengths
1
2.01M
repo_name
stringlengths
3
62
path
stringlengths
1
267
language
stringclasses
231 values
license
stringclasses
13 values
size
int64
1
2.01M
/* * Generate a header file for hardcoded MDCT tables * * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <stdlib.h> #define CONFIG_HARDCODED_TABLES 0 #define SINETABLE_CONST #define SINETABLE(size) \ float ff_sine_##size[size] #define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) #ifndef M_PI #define M_PI 3.14159265358979323846 #endif #include "mdct_tablegen.h" #include "tableprint.h" int main(void) { int i; write_fileheader(); for (i = 5; i <= 12; i++) { ff_init_ff_sine_windows(i); printf("SINETABLE(%4i) = {\n", 1 << i); write_float_array(ff_sine_windows[i], 1 << i); printf("};\n"); } return 0; }
123linslouis-android-video-cutter
jni/libavcodec/mdct_tablegen.c
C
asf20
1,459
/* * H261 decoder * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * Copyright (c) 2004 Maarten Daniels * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * H.261 decoder. */ #include "dsputil.h" #include "avcodec.h" #include "mpegvideo.h" #include "h263.h" #include "h261.h" #include "h261data.h" #define H261_MBA_VLC_BITS 9 #define H261_MTYPE_VLC_BITS 6 #define H261_MV_VLC_BITS 7 #define H261_CBP_VLC_BITS 9 #define TCOEFF_VLC_BITS 9 #define MBA_STUFFING 33 #define MBA_STARTCODE 34 extern uint8_t ff_h261_rl_table_store[2][2*MAX_RUN + MAX_LEVEL + 3]; static VLC h261_mba_vlc; static VLC h261_mtype_vlc; static VLC h261_mv_vlc; static VLC h261_cbp_vlc; static int h261_decode_block(H261Context * h, DCTELEM * block, int n, int coded); static av_cold void h261_decode_init_vlc(H261Context *h){ static int done = 0; if(!done){ done = 1; INIT_VLC_STATIC(&h261_mba_vlc, H261_MBA_VLC_BITS, 35, h261_mba_bits, 1, 1, h261_mba_code, 1, 1, 662); INIT_VLC_STATIC(&h261_mtype_vlc, H261_MTYPE_VLC_BITS, 10, h261_mtype_bits, 1, 1, h261_mtype_code, 1, 1, 80); INIT_VLC_STATIC(&h261_mv_vlc, H261_MV_VLC_BITS, 17, &h261_mv_tab[0][1], 2, 1, &h261_mv_tab[0][0], 2, 1, 144); INIT_VLC_STATIC(&h261_cbp_vlc, H261_CBP_VLC_BITS, 63, &h261_cbp_tab[0][1], 2, 1, &h261_cbp_tab[0][0], 2, 1, 512); init_rl(&h261_rl_tcoeff, ff_h261_rl_table_store); INIT_VLC_RL(h261_rl_tcoeff, 552); } } static av_cold int h261_decode_init(AVCodecContext *avctx){ H261Context *h= avctx->priv_data; MpegEncContext * const s = &h->s; // set defaults MPV_decode_defaults(s); s->avctx = avctx; s->width = s->avctx->coded_width; s->height = s->avctx->coded_height; s->codec_id = s->avctx->codec->id; s->out_format = FMT_H261; s->low_delay= 1; avctx->pix_fmt= PIX_FMT_YUV420P; s->codec_id= avctx->codec->id; h261_decode_init_vlc(h); h->gob_start_code_skipped = 0; return 0; } /** * decodes the group of blocks header or slice header. * @return <0 if an error occurred */ static int h261_decode_gob_header(H261Context *h){ unsigned int val; MpegEncContext * const s = &h->s; if ( !h->gob_start_code_skipped ){ /* Check for GOB Start Code */ val = show_bits(&s->gb, 15); if(val) return -1; /* We have a GBSC */ skip_bits(&s->gb, 16); } h->gob_start_code_skipped = 0; h->gob_number = get_bits(&s->gb, 4); /* GN */ s->qscale = get_bits(&s->gb, 5); /* GQUANT */ /* Check if gob_number is valid */ if (s->mb_height==18){ //cif if ((h->gob_number<=0) || (h->gob_number>12)) return -1; } else{ //qcif if ((h->gob_number!=1) && (h->gob_number!=3) && (h->gob_number!=5)) return -1; } /* GEI */ while (get_bits1(&s->gb) != 0) { skip_bits(&s->gb, 8); } if(s->qscale==0) { av_log(s->avctx, AV_LOG_ERROR, "qscale has forbidden 0 value\n"); if (s->avctx->error_recognition >= FF_ER_COMPLIANT) return -1; } // For the first transmitted macroblock in a GOB, MBA is the absolute address. For // subsequent macroblocks, MBA is the difference between the absolute addresses of // the macroblock and the last transmitted macroblock. h->current_mba = 0; h->mba_diff = 0; return 0; } /** * decodes the group of blocks / video packet header. * @return <0 if no resync found */ static int ff_h261_resync(H261Context *h){ MpegEncContext * const s = &h->s; int left, ret; if ( h->gob_start_code_skipped ){ ret= h261_decode_gob_header(h); if(ret>=0) return 0; } else{ if(show_bits(&s->gb, 15)==0){ ret= h261_decode_gob_header(h); if(ret>=0) return 0; } //OK, it is not where it is supposed to be ... s->gb= s->last_resync_gb; align_get_bits(&s->gb); left= get_bits_left(&s->gb); for(;left>15+1+4+5; left-=8){ if(show_bits(&s->gb, 15)==0){ GetBitContext bak= s->gb; ret= h261_decode_gob_header(h); if(ret>=0) return 0; s->gb= bak; } skip_bits(&s->gb, 8); } } return -1; } /** * decodes skipped macroblocks * @return 0 */ static int h261_decode_mb_skipped(H261Context *h, int mba1, int mba2 ) { MpegEncContext * const s = &h->s; int i; s->mb_intra = 0; for(i=mba1; i<mba2; i++){ int j, xy; s->mb_x= ((h->gob_number-1) % 2) * 11 + i % 11; s->mb_y= ((h->gob_number-1) / 2) * 3 + i / 11; xy = s->mb_x + s->mb_y * s->mb_stride; ff_init_block_index(s); ff_update_block_index(s); for(j=0;j<6;j++) s->block_last_index[j] = -1; s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_16X16; s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0; s->mv[0][0][0] = 0; s->mv[0][0][1] = 0; s->mb_skipped = 1; h->mtype &= ~MB_TYPE_H261_FIL; MPV_decode_mb(s, s->block); } return 0; } static int decode_mv_component(GetBitContext *gb, int v){ int mv_diff = get_vlc2(gb, h261_mv_vlc.table, H261_MV_VLC_BITS, 2); /* check if mv_diff is valid */ if ( mv_diff < 0 ) return v; mv_diff = mvmap[mv_diff]; if(mv_diff && !get_bits1(gb)) mv_diff= -mv_diff; v += mv_diff; if (v <=-16) v+= 32; else if(v >= 16) v-= 32; return v; } static int h261_decode_mb(H261Context *h){ MpegEncContext * const s = &h->s; int i, cbp, xy; cbp = 63; // Read mba do{ h->mba_diff = get_vlc2(&s->gb, h261_mba_vlc.table, H261_MBA_VLC_BITS, 2); /* Check for slice end */ /* NOTE: GOB can be empty (no MB data) or exist only of MBA_stuffing */ if (h->mba_diff == MBA_STARTCODE){ // start code h->gob_start_code_skipped = 1; return SLICE_END; } } while( h->mba_diff == MBA_STUFFING ); // stuffing if ( h->mba_diff < 0 ){ if ( get_bits_count(&s->gb) + 7 >= s->gb.size_in_bits ) return SLICE_END; av_log(s->avctx, AV_LOG_ERROR, "illegal mba at %d %d\n", s->mb_x, s->mb_y); return SLICE_ERROR; } h->mba_diff += 1; h->current_mba += h->mba_diff; if ( h->current_mba > MBA_STUFFING ) return SLICE_ERROR; s->mb_x= ((h->gob_number-1) % 2) * 11 + ((h->current_mba-1) % 11); s->mb_y= ((h->gob_number-1) / 2) * 3 + ((h->current_mba-1) / 11); xy = s->mb_x + s->mb_y * s->mb_stride; ff_init_block_index(s); ff_update_block_index(s); // Read mtype h->mtype = get_vlc2(&s->gb, h261_mtype_vlc.table, H261_MTYPE_VLC_BITS, 2); h->mtype = h261_mtype_map[h->mtype]; // Read mquant if ( IS_QUANT ( h->mtype ) ){ ff_set_qscale(s, get_bits(&s->gb, 5)); } s->mb_intra = IS_INTRA4x4(h->mtype); // Read mv if ( IS_16X16 ( h->mtype ) ){ // Motion vector data is included for all MC macroblocks. MVD is obtained from the macroblock vector by subtracting the // vector of the preceding macroblock. For this calculation the vector of the preceding macroblock is regarded as zero in the // following three situations: // 1) evaluating MVD for macroblocks 1, 12 and 23; // 2) evaluating MVD for macroblocks in which MBA does not represent a difference of 1; // 3) MTYPE of the previous macroblock was not MC. if ( ( h->current_mba == 1 ) || ( h->current_mba == 12 ) || ( h->current_mba == 23 ) || ( h->mba_diff != 1)) { h->current_mv_x = 0; h->current_mv_y = 0; } h->current_mv_x= decode_mv_component(&s->gb, h->current_mv_x); h->current_mv_y= decode_mv_component(&s->gb, h->current_mv_y); }else{ h->current_mv_x = 0; h->current_mv_y = 0; } // Read cbp if ( HAS_CBP( h->mtype ) ){ cbp = get_vlc2(&s->gb, h261_cbp_vlc.table, H261_CBP_VLC_BITS, 2) + 1; } if(s->mb_intra){ s->current_picture.mb_type[xy]= MB_TYPE_INTRA; goto intra; } //set motion vectors s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_16X16; s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0; s->mv[0][0][0] = h->current_mv_x * 2;//gets divided by 2 in motion compensation s->mv[0][0][1] = h->current_mv_y * 2; intra: /* decode each block */ if(s->mb_intra || HAS_CBP(h->mtype)){ s->dsp.clear_blocks(s->block[0]); for (i = 0; i < 6; i++) { if (h261_decode_block(h, s->block[i], i, cbp&32) < 0){ return SLICE_ERROR; } cbp+=cbp; } }else{ for (i = 0; i < 6; i++) s->block_last_index[i]= -1; } MPV_decode_mb(s, s->block); return SLICE_OK; } /** * decodes a macroblock * @return <0 if an error occurred */ static int h261_decode_block(H261Context * h, DCTELEM * block, int n, int coded) { MpegEncContext * const s = &h->s; int code, level, i, j, run; RLTable *rl = &h261_rl_tcoeff; const uint8_t *scan_table; // For the variable length encoding there are two code tables, one being used for // the first transmitted LEVEL in INTER, INTER+MC and INTER+MC+FIL blocks, the second // for all other LEVELs except the first one in INTRA blocks which is fixed length // coded with 8 bits. // NOTE: the two code tables only differ in one VLC so we handle that manually. scan_table = s->intra_scantable.permutated; if (s->mb_intra){ /* DC coef */ level = get_bits(&s->gb, 8); // 0 (00000000b) and -128 (10000000b) are FORBIDDEN if((level&0x7F) == 0){ av_log(s->avctx, AV_LOG_ERROR, "illegal dc %d at %d %d\n", level, s->mb_x, s->mb_y); return -1; } // The code 1000 0000 is not used, the reconstruction level of 1024 being coded as 1111 1111. if (level == 255) level = 128; block[0] = level; i = 1; }else if(coded){ // Run Level Code // EOB Not possible for first level when cbp is available (that's why the table is different) // 0 1 1s // * * 0* int check = show_bits(&s->gb, 2); i = 0; if ( check & 0x2 ){ skip_bits(&s->gb, 2); block[0] = ( check & 0x1 ) ? -1 : 1; i = 1; } }else{ i = 0; } if(!coded){ s->block_last_index[n] = i - 1; return 0; } for(;;){ code = get_vlc2(&s->gb, rl->vlc.table, TCOEFF_VLC_BITS, 2); if (code < 0){ av_log(s->avctx, AV_LOG_ERROR, "illegal ac vlc code at %dx%d\n", s->mb_x, s->mb_y); return -1; } if (code == rl->n) { /* escape */ // The remaining combinations of (run, level) are encoded with a 20-bit word consisting of 6 bits escape, 6 bits run and 8 bits level. run = get_bits(&s->gb, 6); level = get_sbits(&s->gb, 8); }else if(code == 0){ break; }else{ run = rl->table_run[code]; level = rl->table_level[code]; if (get_bits1(&s->gb)) level = -level; } i += run; if (i >= 64){ av_log(s->avctx, AV_LOG_ERROR, "run overflow at %dx%d\n", s->mb_x, s->mb_y); return -1; } j = scan_table[i]; block[j] = level; i++; } s->block_last_index[n] = i-1; return 0; } /** * decodes the H261 picture header. * @return <0 if no startcode found */ static int h261_decode_picture_header(H261Context *h){ MpegEncContext * const s = &h->s; int format, i; uint32_t startcode= 0; for(i= get_bits_left(&s->gb); i>24; i-=1){ startcode = ((startcode << 1) | get_bits(&s->gb, 1)) & 0x000FFFFF; if(startcode == 0x10) break; } if (startcode != 0x10){ av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n"); return -1; } /* temporal reference */ i= get_bits(&s->gb, 5); /* picture timestamp */ if(i < (s->picture_number&31)) i += 32; s->picture_number = (s->picture_number&~31) + i; s->avctx->time_base= (AVRational){1001, 30000}; s->current_picture.pts= s->picture_number; /* PTYPE starts here */ skip_bits1(&s->gb); /* split screen off */ skip_bits1(&s->gb); /* camera off */ skip_bits1(&s->gb); /* freeze picture release off */ format = get_bits1(&s->gb); //only 2 formats possible if (format == 0){//QCIF s->width = 176; s->height = 144; s->mb_width = 11; s->mb_height = 9; }else{//CIF s->width = 352; s->height = 288; s->mb_width = 22; s->mb_height = 18; } s->mb_num = s->mb_width * s->mb_height; skip_bits1(&s->gb); /* still image mode off */ skip_bits1(&s->gb); /* Reserved */ /* PEI */ while (get_bits1(&s->gb) != 0){ skip_bits(&s->gb, 8); } // h261 has no I-FRAMES, but if we pass FF_I_TYPE for the first frame, the codec crashes if it does // not contain all I-blocks (e.g. when a packet is lost) s->pict_type = FF_P_TYPE; h->gob_number = 0; return 0; } static int h261_decode_gob(H261Context *h){ MpegEncContext * const s = &h->s; ff_set_qscale(s, s->qscale); /* decode mb's */ while(h->current_mba <= MBA_STUFFING) { int ret; /* DCT & quantize */ ret= h261_decode_mb(h); if(ret<0){ if(ret==SLICE_END){ h261_decode_mb_skipped(h, h->current_mba, 33); return 0; } av_log(s->avctx, AV_LOG_ERROR, "Error at MB: %d\n", s->mb_x + s->mb_y*s->mb_stride); return -1; } h261_decode_mb_skipped(h, h->current_mba-h->mba_diff, h->current_mba-1); } return -1; } /** * returns the number of bytes consumed for building the current frame */ static int get_consumed_bytes(MpegEncContext *s, int buf_size){ int pos= get_bits_count(&s->gb)>>3; if(pos==0) pos=1; //avoid infinite loops (i doubt that is needed but ...) if(pos+10>buf_size) pos=buf_size; // oops ;) return pos; } static int h261_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; H261Context *h= avctx->priv_data; MpegEncContext *s = &h->s; int ret; AVFrame *pict = data; dprintf(avctx, "*****frame %d size=%d\n", avctx->frame_number, buf_size); dprintf(avctx, "bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]); s->flags= avctx->flags; s->flags2= avctx->flags2; h->gob_start_code_skipped=0; retry: init_get_bits(&s->gb, buf, buf_size*8); if(!s->context_initialized){ if (MPV_common_init(s) < 0) //we need the idct permutaton for reading a custom matrix return -1; } //we need to set current_picture_ptr before reading the header, otherwise we cannot store anyting im there if(s->current_picture_ptr==NULL || s->current_picture_ptr->data[0]){ int i= ff_find_unused_picture(s, 0); s->current_picture_ptr= &s->picture[i]; } ret = h261_decode_picture_header(h); /* skip if the header was thrashed */ if (ret < 0){ av_log(s->avctx, AV_LOG_ERROR, "header damaged\n"); return -1; } if (s->width != avctx->coded_width || s->height != avctx->coded_height){ ParseContext pc= s->parse_context; //FIXME move this demuxing hack to libavformat s->parse_context.buffer=0; MPV_common_end(s); s->parse_context= pc; } if (!s->context_initialized) { avcodec_set_dimensions(avctx, s->width, s->height); goto retry; } // for hurry_up==5 s->current_picture.pict_type= s->pict_type; s->current_picture.key_frame= s->pict_type == FF_I_TYPE; /* skip everything if we are in a hurry>=5 */ if(avctx->hurry_up>=5) return get_consumed_bytes(s, buf_size); if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==FF_B_TYPE) ||(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=FF_I_TYPE) || avctx->skip_frame >= AVDISCARD_ALL) return get_consumed_bytes(s, buf_size); if(MPV_frame_start(s, avctx) < 0) return -1; ff_er_frame_start(s); /* decode each macroblock */ s->mb_x=0; s->mb_y=0; while(h->gob_number < (s->mb_height==18 ? 12 : 5)){ if(ff_h261_resync(h)<0) break; h261_decode_gob(h); } MPV_frame_end(s); assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type); assert(s->current_picture.pict_type == s->pict_type); *pict= *(AVFrame*)s->current_picture_ptr; ff_print_debug_info(s, pict); *data_size = sizeof(AVFrame); return get_consumed_bytes(s, buf_size); } static av_cold int h261_decode_end(AVCodecContext *avctx) { H261Context *h= avctx->priv_data; MpegEncContext *s = &h->s; MPV_common_end(s); return 0; } AVCodec h261_decoder = { "h261", AVMEDIA_TYPE_VIDEO, CODEC_ID_H261, sizeof(H261Context), h261_decode_init, NULL, h261_decode_end, h261_decode_frame, CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("H.261"), };
123linslouis-android-video-cutter
jni/libavcodec/h261dec.c
C
asf20
18,644
/** * @file * huffman tree builder and VLC generator * Copyright (c) 2006 Konstantin Shishkov * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avcodec.h" #include "get_bits.h" #include "huffman.h" /* symbol for Huffman tree node */ #define HNODE -1 static void get_tree_codes(uint32_t *bits, int16_t *lens, uint8_t *xlat, Node *nodes, int node, uint32_t pfx, int pl, int *pos, int no_zero_count) { int s; s = nodes[node].sym; if(s != HNODE || (no_zero_count && !nodes[node].count)){ bits[*pos] = pfx; lens[*pos] = pl; xlat[*pos] = s; (*pos)++; }else{ pfx <<= 1; pl++; get_tree_codes(bits, lens, xlat, nodes, nodes[node].n0, pfx, pl, pos, no_zero_count); pfx |= 1; get_tree_codes(bits, lens, xlat, nodes, nodes[node].n0+1, pfx, pl, pos, no_zero_count); } } static int build_huff_tree(VLC *vlc, Node *nodes, int head, int flags) { int no_zero_count = !(flags & FF_HUFFMAN_FLAG_ZERO_COUNT); uint32_t bits[256]; int16_t lens[256]; uint8_t xlat[256]; int pos = 0; get_tree_codes(bits, lens, xlat, nodes, head, 0, 0, &pos, no_zero_count); return init_vlc_sparse(vlc, 9, pos, lens, 2, 2, bits, 4, 4, xlat, 1, 1, 0); } /** * nodes size must be 2*nb_codes * first nb_codes nodes.count must be set */ int ff_huff_build_tree(AVCodecContext *avctx, VLC *vlc, int nb_codes, Node *nodes, HuffCmp cmp, int flags) { int i, j; int cur_node; int64_t sum = 0; for(i = 0; i < nb_codes; i++){ nodes[i].sym = i; nodes[i].n0 = -2; sum += nodes[i].count; } if(sum >> 31) { av_log(avctx, AV_LOG_ERROR, "Too high symbol frequencies. Tree construction is not possible\n"); return -1; } qsort(nodes, nb_codes, sizeof(Node), cmp); cur_node = nb_codes; nodes[nb_codes*2-1].count = 0; for(i = 0; i < nb_codes*2-1; i += 2){ nodes[cur_node].sym = HNODE; nodes[cur_node].count = nodes[i].count + nodes[i+1].count; nodes[cur_node].n0 = i; for(j = cur_node; j > 0; j--){ if(nodes[j].count > nodes[j-1].count || (nodes[j].count == nodes[j-1].count && (!(flags & FF_HUFFMAN_FLAG_HNODE_FIRST) || nodes[j].n0==j-1 || nodes[j].n0==j-2 || (nodes[j].sym!=HNODE && nodes[j-1].sym!=HNODE)))) break; FFSWAP(Node, nodes[j], nodes[j-1]); } cur_node++; } if(build_huff_tree(vlc, nodes, nb_codes*2-2, flags) < 0){ av_log(avctx, AV_LOG_ERROR, "Error building tree\n"); return -1; } return 0; }
123linslouis-android-video-cutter
jni/libavcodec/huffman.c
C
asf20
3,442
/* * FLV Encoding specific code. * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mpegvideo.h" #include "h263.h" #include "flv.h" void ff_flv_encode_picture_header(MpegEncContext * s, int picture_number) { int format; align_put_bits(&s->pb); put_bits(&s->pb, 17, 1); put_bits(&s->pb, 5, (s->h263_flv-1)); /* 0: h263 escape codes 1: 11-bit escape codes */ put_bits(&s->pb, 8, (((int64_t)s->picture_number * 30 * s->avctx->time_base.num) / //FIXME use timestamp s->avctx->time_base.den) & 0xff); /* TemporalReference */ if (s->width == 352 && s->height == 288) format = 2; else if (s->width == 176 && s->height == 144) format = 3; else if (s->width == 128 && s->height == 96) format = 4; else if (s->width == 320 && s->height == 240) format = 5; else if (s->width == 160 && s->height == 120) format = 6; else if (s->width <= 255 && s->height <= 255) format = 0; /* use 1 byte width & height */ else format = 1; /* use 2 bytes width & height */ put_bits(&s->pb, 3, format); /* PictureSize */ if (format == 0) { put_bits(&s->pb, 8, s->width); put_bits(&s->pb, 8, s->height); } else if (format == 1) { put_bits(&s->pb, 16, s->width); put_bits(&s->pb, 16, s->height); } put_bits(&s->pb, 2, s->pict_type == FF_P_TYPE); /* PictureType */ put_bits(&s->pb, 1, 1); /* DeblockingFlag: on */ put_bits(&s->pb, 5, s->qscale); /* Quantizer */ put_bits(&s->pb, 1, 0); /* ExtraInformation */ if(s->h263_aic){ s->y_dc_scale_table= s->c_dc_scale_table= ff_aic_dc_scale_table; }else{ s->y_dc_scale_table= s->c_dc_scale_table= ff_mpeg1_dc_scale_table; } } void ff_flv2_encode_ac_esc(PutBitContext *pb, int slevel, int level, int run, int last){ if(level < 64) { // 7-bit level put_bits(pb, 1, 0); put_bits(pb, 1, last); put_bits(pb, 6, run); put_sbits(pb, 7, slevel); } else { /* 11-bit level */ put_bits(pb, 1, 1); put_bits(pb, 1, last); put_bits(pb, 6, run); put_sbits(pb, 11, slevel); } } AVCodec flv_encoder = { "flv", AVMEDIA_TYPE_VIDEO, CODEC_ID_FLV1, sizeof(MpegEncContext), MPV_encode_init, MPV_encode_picture, MPV_encode_end, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("Flash Video (FLV) / Sorenson Spark / Sorenson H.263"), };
123linslouis-android-video-cutter
jni/libavcodec/flvenc.c
C
asf20
3,315
/* * Copyright (c) 2002 The FFmpeg Project * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AVCODEC_WMV2_H #define AVCODEC_WMV2_H #include "avcodec.h" #include "dsputil.h" #include "mpegvideo.h" #include "intrax8.h" #define SKIP_TYPE_NONE 0 #define SKIP_TYPE_MPEG 1 #define SKIP_TYPE_ROW 2 #define SKIP_TYPE_COL 3 typedef struct Wmv2Context{ MpegEncContext s; IntraX8Context x8; int j_type_bit; int j_type; int abt_flag; int abt_type; int abt_type_table[6]; int per_mb_abt; int per_block_abt; int mspel_bit; int cbp_table_index; int top_left_mv_flag; int per_mb_rl_bit; int skip_type; int hshift; ScanTable abt_scantable[2]; DECLARE_ALIGNED(16, DCTELEM, abt_block2)[6][64]; }Wmv2Context; void ff_wmv2_common_init(Wmv2Context * w); #endif /* AVCODEC_WMV2_H */
123linslouis-android-video-cutter
jni/libavcodec/wmv2.h
C
asf20
1,560
/* * COOK compatible decoder * Copyright (c) 2003 Sascha Sommer * Copyright (c) 2005 Benjamin Larsson * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * Cook compatible decoder. Bastardization of the G.722.1 standard. * This decoder handles RealNetworks, RealAudio G2 data. * Cook is identified by the codec name cook in RM files. * * To use this decoder, a calling application must supply the extradata * bytes provided from the RM container; 8+ bytes for mono streams and * 16+ for stereo streams (maybe more). * * Codec technicalities (all this assume a buffer length of 1024): * Cook works with several different techniques to achieve its compression. * In the timedomain the buffer is divided into 8 pieces and quantized. If * two neighboring pieces have different quantization index a smooth * quantization curve is used to get a smooth overlap between the different * pieces. * To get to the transformdomain Cook uses a modulated lapped transform. * The transform domain has 50 subbands with 20 elements each. This * means only a maximum of 50*20=1000 coefficients are used out of the 1024 * available. */ #include <math.h> #include <stddef.h> #include <stdio.h> #include "libavutil/lfg.h" #include "libavutil/random_seed.h" #include "avcodec.h" #include "get_bits.h" #include "dsputil.h" #include "bytestream.h" #include "fft.h" #include "cookdata.h" /* the different Cook versions */ #define MONO 0x1000001 #define STEREO 0x1000002 #define JOINT_STEREO 0x1000003 #define MC_COOK 0x2000000 //multichannel Cook, not supported #define SUBBAND_SIZE 20 #define MAX_SUBPACKETS 5 //#define COOKDEBUG typedef struct { int *now; int *previous; } cook_gains; typedef struct { int ch_idx; int size; int num_channels; int cookversion; int samples_per_frame; int subbands; int js_subband_start; int js_vlc_bits; int samples_per_channel; int log2_numvector_size; unsigned int channel_mask; VLC ccpl; ///< channel coupling int joint_stereo; int bits_per_subpacket; int bits_per_subpdiv; int total_subbands; int numvector_size; ///< 1 << log2_numvector_size; float mono_previous_buffer1[1024]; float mono_previous_buffer2[1024]; /** gain buffers */ cook_gains gains1; cook_gains gains2; int gain_1[9]; int gain_2[9]; int gain_3[9]; int gain_4[9]; } COOKSubpacket; typedef struct cook { /* * The following 5 functions provide the lowlevel arithmetic on * the internal audio buffers. */ void (* scalar_dequant)(struct cook *q, int index, int quant_index, int* subband_coef_index, int* subband_coef_sign, float* mlt_p); void (* decouple) (struct cook *q, COOKSubpacket *p, int subband, float f1, float f2, float *decode_buffer, float *mlt_buffer1, float *mlt_buffer2); void (* imlt_window) (struct cook *q, float *buffer1, cook_gains *gains_ptr, float *previous_buffer); void (* interpolate) (struct cook *q, float* buffer, int gain_index, int gain_index_next); void (* saturate_output) (struct cook *q, int chan, int16_t *out); AVCodecContext* avctx; GetBitContext gb; /* stream data */ int nb_channels; int bit_rate; int sample_rate; int num_vectors; int samples_per_channel; /* states */ AVLFG random_state; /* transform data */ FFTContext mdct_ctx; float* mlt_window; /* VLC data */ VLC envelope_quant_index[13]; VLC sqvh[7]; //scalar quantization /* generatable tables and related variables */ int gain_size_factor; float gain_table[23]; /* data buffers */ uint8_t* decoded_bytes_buffer; DECLARE_ALIGNED(16, float,mono_mdct_output)[2048]; float decode_buffer_1[1024]; float decode_buffer_2[1024]; float decode_buffer_0[1060]; /* static allocation for joint decode */ const float *cplscales[5]; int num_subpackets; COOKSubpacket subpacket[MAX_SUBPACKETS]; } COOKContext; static float pow2tab[127]; static float rootpow2tab[127]; /* debug functions */ #ifdef COOKDEBUG static void dump_float_table(float* table, int size, int delimiter) { int i=0; av_log(NULL,AV_LOG_ERROR,"\n[%d]: ",i); for (i=0 ; i<size ; i++) { av_log(NULL, AV_LOG_ERROR, "%5.1f, ", table[i]); if ((i+1)%delimiter == 0) av_log(NULL,AV_LOG_ERROR,"\n[%d]: ",i+1); } } static void dump_int_table(int* table, int size, int delimiter) { int i=0; av_log(NULL,AV_LOG_ERROR,"\n[%d]: ",i); for (i=0 ; i<size ; i++) { av_log(NULL, AV_LOG_ERROR, "%d, ", table[i]); if ((i+1)%delimiter == 0) av_log(NULL,AV_LOG_ERROR,"\n[%d]: ",i+1); } } static void dump_short_table(short* table, int size, int delimiter) { int i=0; av_log(NULL,AV_LOG_ERROR,"\n[%d]: ",i); for (i=0 ; i<size ; i++) { av_log(NULL, AV_LOG_ERROR, "%d, ", table[i]); if ((i+1)%delimiter == 0) av_log(NULL,AV_LOG_ERROR,"\n[%d]: ",i+1); } } #endif /*************** init functions ***************/ /* table generator */ static av_cold void init_pow2table(void){ int i; for (i=-63 ; i<64 ; i++){ pow2tab[63+i]= pow(2, i); rootpow2tab[63+i]=sqrt(pow(2, i)); } } /* table generator */ static av_cold void init_gain_table(COOKContext *q) { int i; q->gain_size_factor = q->samples_per_channel/8; for (i=0 ; i<23 ; i++) { q->gain_table[i] = pow(pow2tab[i+52] , (1.0/(double)q->gain_size_factor)); } } static av_cold int init_cook_vlc_tables(COOKContext *q) { int i, result; result = 0; for (i=0 ; i<13 ; i++) { result |= init_vlc (&q->envelope_quant_index[i], 9, 24, envelope_quant_index_huffbits[i], 1, 1, envelope_quant_index_huffcodes[i], 2, 2, 0); } av_log(q->avctx,AV_LOG_DEBUG,"sqvh VLC init\n"); for (i=0 ; i<7 ; i++) { result |= init_vlc (&q->sqvh[i], vhvlcsize_tab[i], vhsize_tab[i], cvh_huffbits[i], 1, 1, cvh_huffcodes[i], 2, 2, 0); } for(i=0;i<q->num_subpackets;i++){ if (q->subpacket[i].joint_stereo==1){ result |= init_vlc (&q->subpacket[i].ccpl, 6, (1<<q->subpacket[i].js_vlc_bits)-1, ccpl_huffbits[q->subpacket[i].js_vlc_bits-2], 1, 1, ccpl_huffcodes[q->subpacket[i].js_vlc_bits-2], 2, 2, 0); av_log(q->avctx,AV_LOG_DEBUG,"subpacket %i Joint-stereo VLC used.\n",i); } } av_log(q->avctx,AV_LOG_DEBUG,"VLC tables initialized.\n"); return result; } static av_cold int init_cook_mlt(COOKContext *q) { int j; int mlt_size = q->samples_per_channel; if ((q->mlt_window = av_malloc(sizeof(float)*mlt_size)) == 0) return -1; /* Initialize the MLT window: simple sine window. */ ff_sine_window_init(q->mlt_window, mlt_size); for(j=0 ; j<mlt_size ; j++) q->mlt_window[j] *= sqrt(2.0 / q->samples_per_channel); /* Initialize the MDCT. */ if (ff_mdct_init(&q->mdct_ctx, av_log2(mlt_size)+1, 1, 1.0)) { av_free(q->mlt_window); return -1; } av_log(q->avctx,AV_LOG_DEBUG,"MDCT initialized, order = %d.\n", av_log2(mlt_size)+1); return 0; } static const float *maybe_reformat_buffer32 (COOKContext *q, const float *ptr, int n) { if (1) return ptr; } static av_cold void init_cplscales_table (COOKContext *q) { int i; for (i=0;i<5;i++) q->cplscales[i] = maybe_reformat_buffer32 (q, cplscales[i], (1<<(i+2))-1); } /*************** init functions end ***********/ /** * Cook indata decoding, every 32 bits are XORed with 0x37c511f2. * Why? No idea, some checksum/error detection method maybe. * * Out buffer size: extra bytes are needed to cope with * padding/misalignment. * Subpackets passed to the decoder can contain two, consecutive * half-subpackets, of identical but arbitrary size. * 1234 1234 1234 1234 extraA extraB * Case 1: AAAA BBBB 0 0 * Case 2: AAAA ABBB BB-- 3 3 * Case 3: AAAA AABB BBBB 2 2 * Case 4: AAAA AAAB BBBB BB-- 1 5 * * Nice way to waste CPU cycles. * * @param inbuffer pointer to byte array of indata * @param out pointer to byte array of outdata * @param bytes number of bytes */ #define DECODE_BYTES_PAD1(bytes) (3 - ((bytes)+3) % 4) #define DECODE_BYTES_PAD2(bytes) ((bytes) % 4 + DECODE_BYTES_PAD1(2 * (bytes))) static inline int decode_bytes(const uint8_t* inbuffer, uint8_t* out, int bytes){ int i, off; uint32_t c; const uint32_t* buf; uint32_t* obuf = (uint32_t*) out; /* FIXME: 64 bit platforms would be able to do 64 bits at a time. * I'm too lazy though, should be something like * for(i=0 ; i<bitamount/64 ; i++) * (int64_t)out[i] = 0x37c511f237c511f2^be2me_64(int64_t)in[i]); * Buffer alignment needs to be checked. */ off = (intptr_t)inbuffer & 3; buf = (const uint32_t*) (inbuffer - off); c = be2me_32((0x37c511f2 >> (off*8)) | (0x37c511f2 << (32-(off*8)))); bytes += 3 + off; for (i = 0; i < bytes/4; i++) obuf[i] = c ^ buf[i]; return off; } /** * Cook uninit */ static av_cold int cook_decode_close(AVCodecContext *avctx) { int i; COOKContext *q = avctx->priv_data; av_log(avctx,AV_LOG_DEBUG, "Deallocating memory.\n"); /* Free allocated memory buffers. */ av_free(q->mlt_window); av_free(q->decoded_bytes_buffer); /* Free the transform. */ ff_mdct_end(&q->mdct_ctx); /* Free the VLC tables. */ for (i=0 ; i<13 ; i++) { free_vlc(&q->envelope_quant_index[i]); } for (i=0 ; i<7 ; i++) { free_vlc(&q->sqvh[i]); } for (i=0 ; i<q->num_subpackets ; i++) { free_vlc(&q->subpacket[i].ccpl); } av_log(avctx,AV_LOG_DEBUG,"Memory deallocated.\n"); return 0; } /** * Fill the gain array for the timedomain quantization. * * @param q pointer to the COOKContext * @param gaininfo[9] array of gain indexes */ static void decode_gain_info(GetBitContext *gb, int *gaininfo) { int i, n; while (get_bits1(gb)) {} n = get_bits_count(gb) - 1; //amount of elements*2 to update i = 0; while (n--) { int index = get_bits(gb, 3); int gain = get_bits1(gb) ? get_bits(gb, 4) - 7 : -1; while (i <= index) gaininfo[i++] = gain; } while (i <= 8) gaininfo[i++] = 0; } /** * Create the quant index table needed for the envelope. * * @param q pointer to the COOKContext * @param quant_index_table pointer to the array */ static void decode_envelope(COOKContext *q, COOKSubpacket *p, int* quant_index_table) { int i,j, vlc_index; quant_index_table[0]= get_bits(&q->gb,6) - 6; //This is used later in categorize for (i=1 ; i < p->total_subbands ; i++){ vlc_index=i; if (i >= p->js_subband_start * 2) { vlc_index-=p->js_subband_start; } else { vlc_index/=2; if(vlc_index < 1) vlc_index = 1; } if (vlc_index>13) vlc_index = 13; //the VLC tables >13 are identical to No. 13 j = get_vlc2(&q->gb, q->envelope_quant_index[vlc_index-1].table, q->envelope_quant_index[vlc_index-1].bits,2); quant_index_table[i] = quant_index_table[i-1] + j - 12; //differential encoding } } /** * Calculate the category and category_index vector. * * @param q pointer to the COOKContext * @param quant_index_table pointer to the array * @param category pointer to the category array * @param category_index pointer to the category_index array */ static void categorize(COOKContext *q, COOKSubpacket *p, int* quant_index_table, int* category, int* category_index){ int exp_idx, bias, tmpbias1, tmpbias2, bits_left, num_bits, index, v, i, j; int exp_index2[102]; int exp_index1[102]; int tmp_categorize_array[128*2]; int tmp_categorize_array1_idx=p->numvector_size; int tmp_categorize_array2_idx=p->numvector_size; bits_left = p->bits_per_subpacket - get_bits_count(&q->gb); if(bits_left > q->samples_per_channel) { bits_left = q->samples_per_channel + ((bits_left - q->samples_per_channel)*5)/8; //av_log(q->avctx, AV_LOG_ERROR, "bits_left = %d\n",bits_left); } memset(&exp_index1,0,102*sizeof(int)); memset(&exp_index2,0,102*sizeof(int)); memset(&tmp_categorize_array,0,128*2*sizeof(int)); bias=-32; /* Estimate bias. */ for (i=32 ; i>0 ; i=i/2){ num_bits = 0; index = 0; for (j=p->total_subbands ; j>0 ; j--){ exp_idx = av_clip((i - quant_index_table[index] + bias) / 2, 0, 7); index++; num_bits+=expbits_tab[exp_idx]; } if(num_bits >= bits_left - 32){ bias+=i; } } /* Calculate total number of bits. */ num_bits=0; for (i=0 ; i<p->total_subbands ; i++) { exp_idx = av_clip((bias - quant_index_table[i]) / 2, 0, 7); num_bits += expbits_tab[exp_idx]; exp_index1[i] = exp_idx; exp_index2[i] = exp_idx; } tmpbias1 = tmpbias2 = num_bits; for (j = 1 ; j < p->numvector_size ; j++) { if (tmpbias1 + tmpbias2 > 2*bits_left) { /* ---> */ int max = -999999; index=-1; for (i=0 ; i<p->total_subbands ; i++){ if (exp_index1[i] < 7) { v = (-2*exp_index1[i]) - quant_index_table[i] + bias; if ( v >= max) { max = v; index = i; } } } if(index==-1)break; tmp_categorize_array[tmp_categorize_array1_idx++] = index; tmpbias1 -= expbits_tab[exp_index1[index]] - expbits_tab[exp_index1[index]+1]; ++exp_index1[index]; } else { /* <--- */ int min = 999999; index=-1; for (i=0 ; i<p->total_subbands ; i++){ if(exp_index2[i] > 0){ v = (-2*exp_index2[i])-quant_index_table[i]+bias; if ( v < min) { min = v; index = i; } } } if(index == -1)break; tmp_categorize_array[--tmp_categorize_array2_idx] = index; tmpbias2 -= expbits_tab[exp_index2[index]] - expbits_tab[exp_index2[index]-1]; --exp_index2[index]; } } for(i=0 ; i<p->total_subbands ; i++) category[i] = exp_index2[i]; for(i=0 ; i<p->numvector_size-1 ; i++) category_index[i] = tmp_categorize_array[tmp_categorize_array2_idx++]; } /** * Expand the category vector. * * @param q pointer to the COOKContext * @param category pointer to the category array * @param category_index pointer to the category_index array */ static inline void expand_category(COOKContext *q, int* category, int* category_index){ int i; for(i=0 ; i<q->num_vectors ; i++){ ++category[category_index[i]]; } } /** * The real requantization of the mltcoefs * * @param q pointer to the COOKContext * @param index index * @param quant_index quantisation index * @param subband_coef_index array of indexes to quant_centroid_tab * @param subband_coef_sign signs of coefficients * @param mlt_p pointer into the mlt buffer */ static void scalar_dequant_float(COOKContext *q, int index, int quant_index, int* subband_coef_index, int* subband_coef_sign, float* mlt_p){ int i; float f1; for(i=0 ; i<SUBBAND_SIZE ; i++) { if (subband_coef_index[i]) { f1 = quant_centroid_tab[index][subband_coef_index[i]]; if (subband_coef_sign[i]) f1 = -f1; } else { /* noise coding if subband_coef_index[i] == 0 */ f1 = dither_tab[index]; if (av_lfg_get(&q->random_state) < 0x80000000) f1 = -f1; } mlt_p[i] = f1 * rootpow2tab[quant_index+63]; } } /** * Unpack the subband_coef_index and subband_coef_sign vectors. * * @param q pointer to the COOKContext * @param category pointer to the category array * @param subband_coef_index array of indexes to quant_centroid_tab * @param subband_coef_sign signs of coefficients */ static int unpack_SQVH(COOKContext *q, COOKSubpacket *p, int category, int* subband_coef_index, int* subband_coef_sign) { int i,j; int vlc, vd ,tmp, result; vd = vd_tab[category]; result = 0; for(i=0 ; i<vpr_tab[category] ; i++){ vlc = get_vlc2(&q->gb, q->sqvh[category].table, q->sqvh[category].bits, 3); if (p->bits_per_subpacket < get_bits_count(&q->gb)){ vlc = 0; result = 1; } for(j=vd-1 ; j>=0 ; j--){ tmp = (vlc * invradix_tab[category])/0x100000; subband_coef_index[vd*i+j] = vlc - tmp * (kmax_tab[category]+1); vlc = tmp; } for(j=0 ; j<vd ; j++){ if (subband_coef_index[i*vd + j]) { if(get_bits_count(&q->gb) < p->bits_per_subpacket){ subband_coef_sign[i*vd+j] = get_bits1(&q->gb); } else { result=1; subband_coef_sign[i*vd+j]=0; } } else { subband_coef_sign[i*vd+j]=0; } } } return result; } /** * Fill the mlt_buffer with mlt coefficients. * * @param q pointer to the COOKContext * @param category pointer to the category array * @param quant_index_table pointer to the array * @param mlt_buffer pointer to mlt coefficients */ static void decode_vectors(COOKContext* q, COOKSubpacket* p, int* category, int *quant_index_table, float* mlt_buffer){ /* A zero in this table means that the subband coefficient is random noise coded. */ int subband_coef_index[SUBBAND_SIZE]; /* A zero in this table means that the subband coefficient is a positive multiplicator. */ int subband_coef_sign[SUBBAND_SIZE]; int band, j; int index=0; for(band=0 ; band<p->total_subbands ; band++){ index = category[band]; if(category[band] < 7){ if(unpack_SQVH(q, p, category[band], subband_coef_index, subband_coef_sign)){ index=7; for(j=0 ; j<p->total_subbands ; j++) category[band+j]=7; } } if(index>=7) { memset(subband_coef_index, 0, sizeof(subband_coef_index)); memset(subband_coef_sign, 0, sizeof(subband_coef_sign)); } q->scalar_dequant(q, index, quant_index_table[band], subband_coef_index, subband_coef_sign, &mlt_buffer[band * SUBBAND_SIZE]); } if(p->total_subbands*SUBBAND_SIZE >= q->samples_per_channel){ return; } /* FIXME: should this be removed, or moved into loop above? */ } /** * function for decoding mono data * * @param q pointer to the COOKContext * @param mlt_buffer pointer to mlt coefficients */ static void mono_decode(COOKContext *q, COOKSubpacket *p, float* mlt_buffer) { int category_index[128]; int quant_index_table[102]; int category[128]; memset(&category, 0, 128*sizeof(int)); memset(&category_index, 0, 128*sizeof(int)); decode_envelope(q, p, quant_index_table); q->num_vectors = get_bits(&q->gb,p->log2_numvector_size); categorize(q, p, quant_index_table, category, category_index); expand_category(q, category, category_index); decode_vectors(q, p, category, quant_index_table, mlt_buffer); } /** * the actual requantization of the timedomain samples * * @param q pointer to the COOKContext * @param buffer pointer to the timedomain buffer * @param gain_index index for the block multiplier * @param gain_index_next index for the next block multiplier */ static void interpolate_float(COOKContext *q, float* buffer, int gain_index, int gain_index_next){ int i; float fc1, fc2; fc1 = pow2tab[gain_index+63]; if(gain_index == gain_index_next){ //static gain for(i=0 ; i<q->gain_size_factor ; i++){ buffer[i]*=fc1; } return; } else { //smooth gain fc2 = q->gain_table[11 + (gain_index_next-gain_index)]; for(i=0 ; i<q->gain_size_factor ; i++){ buffer[i]*=fc1; fc1*=fc2; } return; } } /** * Apply transform window, overlap buffers. * * @param q pointer to the COOKContext * @param inbuffer pointer to the mltcoefficients * @param gains_ptr current and previous gains * @param previous_buffer pointer to the previous buffer to be used for overlapping */ static void imlt_window_float (COOKContext *q, float *buffer1, cook_gains *gains_ptr, float *previous_buffer) { const float fc = pow2tab[gains_ptr->previous[0] + 63]; int i; /* The weird thing here, is that the two halves of the time domain * buffer are swapped. Also, the newest data, that we save away for * next frame, has the wrong sign. Hence the subtraction below. * Almost sounds like a complex conjugate/reverse data/FFT effect. */ /* Apply window and overlap */ for(i = 0; i < q->samples_per_channel; i++){ buffer1[i] = buffer1[i] * fc * q->mlt_window[i] - previous_buffer[i] * q->mlt_window[q->samples_per_channel - 1 - i]; } } /** * The modulated lapped transform, this takes transform coefficients * and transforms them into timedomain samples. * Apply transform window, overlap buffers, apply gain profile * and buffer management. * * @param q pointer to the COOKContext * @param inbuffer pointer to the mltcoefficients * @param gains_ptr current and previous gains * @param previous_buffer pointer to the previous buffer to be used for overlapping */ static void imlt_gain(COOKContext *q, float *inbuffer, cook_gains *gains_ptr, float* previous_buffer) { float *buffer0 = q->mono_mdct_output; float *buffer1 = q->mono_mdct_output + q->samples_per_channel; int i; /* Inverse modified discrete cosine transform */ ff_imdct_calc(&q->mdct_ctx, q->mono_mdct_output, inbuffer); q->imlt_window (q, buffer1, gains_ptr, previous_buffer); /* Apply gain profile */ for (i = 0; i < 8; i++) { if (gains_ptr->now[i] || gains_ptr->now[i + 1]) q->interpolate(q, &buffer1[q->gain_size_factor * i], gains_ptr->now[i], gains_ptr->now[i + 1]); } /* Save away the current to be previous block. */ memcpy(previous_buffer, buffer0, sizeof(float)*q->samples_per_channel); } /** * function for getting the jointstereo coupling information * * @param q pointer to the COOKContext * @param decouple_tab decoupling array * */ static void decouple_info(COOKContext *q, COOKSubpacket *p, int* decouple_tab){ int length, i; if(get_bits1(&q->gb)) { if(cplband[p->js_subband_start] > cplband[p->subbands-1]) return; length = cplband[p->subbands-1] - cplband[p->js_subband_start] + 1; for (i=0 ; i<length ; i++) { decouple_tab[cplband[p->js_subband_start] + i] = get_vlc2(&q->gb, p->ccpl.table, p->ccpl.bits, 2); } return; } if(cplband[p->js_subband_start] > cplband[p->subbands-1]) return; length = cplband[p->subbands-1] - cplband[p->js_subband_start] + 1; for (i=0 ; i<length ; i++) { decouple_tab[cplband[p->js_subband_start] + i] = get_bits(&q->gb, p->js_vlc_bits); } return; } /* * function decouples a pair of signals from a single signal via multiplication. * * @param q pointer to the COOKContext * @param subband index of the current subband * @param f1 multiplier for channel 1 extraction * @param f2 multiplier for channel 2 extraction * @param decode_buffer input buffer * @param mlt_buffer1 pointer to left channel mlt coefficients * @param mlt_buffer2 pointer to right channel mlt coefficients */ static void decouple_float (COOKContext *q, COOKSubpacket *p, int subband, float f1, float f2, float *decode_buffer, float *mlt_buffer1, float *mlt_buffer2) { int j, tmp_idx; for (j=0 ; j<SUBBAND_SIZE ; j++) { tmp_idx = ((p->js_subband_start + subband)*SUBBAND_SIZE)+j; mlt_buffer1[SUBBAND_SIZE*subband + j] = f1 * decode_buffer[tmp_idx]; mlt_buffer2[SUBBAND_SIZE*subband + j] = f2 * decode_buffer[tmp_idx]; } } /** * function for decoding joint stereo data * * @param q pointer to the COOKContext * @param mlt_buffer1 pointer to left channel mlt coefficients * @param mlt_buffer2 pointer to right channel mlt coefficients */ static void joint_decode(COOKContext *q, COOKSubpacket *p, float* mlt_buffer1, float* mlt_buffer2) { int i,j; int decouple_tab[SUBBAND_SIZE]; float *decode_buffer = q->decode_buffer_0; int idx, cpl_tmp; float f1,f2; const float* cplscale; memset(decouple_tab, 0, sizeof(decouple_tab)); memset(decode_buffer, 0, sizeof(decode_buffer)); /* Make sure the buffers are zeroed out. */ memset(mlt_buffer1,0, 1024*sizeof(float)); memset(mlt_buffer2,0, 1024*sizeof(float)); decouple_info(q, p, decouple_tab); mono_decode(q, p, decode_buffer); /* The two channels are stored interleaved in decode_buffer. */ for (i=0 ; i<p->js_subband_start ; i++) { for (j=0 ; j<SUBBAND_SIZE ; j++) { mlt_buffer1[i*20+j] = decode_buffer[i*40+j]; mlt_buffer2[i*20+j] = decode_buffer[i*40+20+j]; } } /* When we reach js_subband_start (the higher frequencies) the coefficients are stored in a coupling scheme. */ idx = (1 << p->js_vlc_bits) - 1; for (i=p->js_subband_start ; i<p->subbands ; i++) { cpl_tmp = cplband[i]; idx -=decouple_tab[cpl_tmp]; cplscale = q->cplscales[p->js_vlc_bits-2]; //choose decoupler table f1 = cplscale[decouple_tab[cpl_tmp]]; f2 = cplscale[idx-1]; q->decouple (q, p, i, f1, f2, decode_buffer, mlt_buffer1, mlt_buffer2); idx = (1 << p->js_vlc_bits) - 1; } } /** * First part of subpacket decoding: * decode raw stream bytes and read gain info. * * @param q pointer to the COOKContext * @param inbuffer pointer to raw stream data * @param gain_ptr array of current/prev gain pointers */ static inline void decode_bytes_and_gain(COOKContext *q, COOKSubpacket *p, const uint8_t *inbuffer, cook_gains *gains_ptr) { int offset; offset = decode_bytes(inbuffer, q->decoded_bytes_buffer, p->bits_per_subpacket/8); init_get_bits(&q->gb, q->decoded_bytes_buffer + offset, p->bits_per_subpacket); decode_gain_info(&q->gb, gains_ptr->now); /* Swap current and previous gains */ FFSWAP(int *, gains_ptr->now, gains_ptr->previous); } /** * Saturate the output signal to signed 16bit integers. * * @param q pointer to the COOKContext * @param chan channel to saturate * @param out pointer to the output vector */ static void saturate_output_float (COOKContext *q, int chan, int16_t *out) { int j; float *output = q->mono_mdct_output + q->samples_per_channel; /* Clip and convert floats to 16 bits. */ for (j = 0; j < q->samples_per_channel; j++) { out[chan + q->nb_channels * j] = av_clip_int16(lrintf(output[j])); } } /** * Final part of subpacket decoding: * Apply modulated lapped transform, gain compensation, * clip and convert to integer. * * @param q pointer to the COOKContext * @param decode_buffer pointer to the mlt coefficients * @param gain_ptr array of current/prev gain pointers * @param previous_buffer pointer to the previous buffer to be used for overlapping * @param out pointer to the output buffer * @param chan 0: left or single channel, 1: right channel */ static inline void mlt_compensate_output(COOKContext *q, float *decode_buffer, cook_gains *gains, float *previous_buffer, int16_t *out, int chan) { imlt_gain(q, decode_buffer, gains, previous_buffer); q->saturate_output (q, chan, out); } /** * Cook subpacket decoding. This function returns one decoded subpacket, * usually 1024 samples per channel. * * @param q pointer to the COOKContext * @param inbuffer pointer to the inbuffer * @param sub_packet_size subpacket size * @param outbuffer pointer to the outbuffer */ static void decode_subpacket(COOKContext *q, COOKSubpacket* p, const uint8_t *inbuffer, int16_t *outbuffer) { int sub_packet_size = p->size; /* packet dump */ // for (i=0 ; i<sub_packet_size ; i++) { // av_log(q->avctx, AV_LOG_ERROR, "%02x", inbuffer[i]); // } // av_log(q->avctx, AV_LOG_ERROR, "\n"); memset(q->decode_buffer_1,0,sizeof(q->decode_buffer_1)); decode_bytes_and_gain(q, p, inbuffer, &p->gains1); if (p->joint_stereo) { joint_decode(q, p, q->decode_buffer_1, q->decode_buffer_2); } else { mono_decode(q, p, q->decode_buffer_1); if (p->num_channels == 2) { decode_bytes_and_gain(q, p, inbuffer + sub_packet_size/2, &p->gains2); mono_decode(q, p, q->decode_buffer_2); } } mlt_compensate_output(q, q->decode_buffer_1, &p->gains1, p->mono_previous_buffer1, outbuffer, p->ch_idx); if (p->num_channels == 2) { if (p->joint_stereo) { mlt_compensate_output(q, q->decode_buffer_2, &p->gains1, p->mono_previous_buffer2, outbuffer, p->ch_idx + 1); } else { mlt_compensate_output(q, q->decode_buffer_2, &p->gains2, p->mono_previous_buffer2, outbuffer, p->ch_idx + 1); } } } /** * Cook frame decoding * * @param avctx pointer to the AVCodecContext */ static int cook_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; COOKContext *q = avctx->priv_data; int i; int offset = 0; int chidx = 0; if (buf_size < avctx->block_align) return buf_size; /* estimate subpacket sizes */ q->subpacket[0].size = avctx->block_align; for(i=1;i<q->num_subpackets;i++){ q->subpacket[i].size = 2 * buf[avctx->block_align - q->num_subpackets + i]; q->subpacket[0].size -= q->subpacket[i].size + 1; if (q->subpacket[0].size < 0) { av_log(avctx,AV_LOG_DEBUG,"frame subpacket size total > avctx->block_align!\n"); return -1; } } /* decode supbackets */ *data_size = 0; for(i=0;i<q->num_subpackets;i++){ q->subpacket[i].bits_per_subpacket = (q->subpacket[i].size*8)>>q->subpacket[i].bits_per_subpdiv; q->subpacket[i].ch_idx = chidx; av_log(avctx,AV_LOG_DEBUG,"subpacket[%i] size %i js %i %i block_align %i\n",i,q->subpacket[i].size,q->subpacket[i].joint_stereo,offset,avctx->block_align); decode_subpacket(q, &q->subpacket[i], buf + offset, (int16_t*)data); offset += q->subpacket[i].size; chidx += q->subpacket[i].num_channels; av_log(avctx,AV_LOG_DEBUG,"subpacket[%i] %i %i\n",i,q->subpacket[i].size * 8,get_bits_count(&q->gb)); } *data_size = sizeof(int16_t) * q->nb_channels * q->samples_per_channel; /* Discard the first two frames: no valid audio. */ if (avctx->frame_number < 2) *data_size = 0; return avctx->block_align; } #ifdef COOKDEBUG static void dump_cook_context(COOKContext *q) { //int i=0; #define PRINT(a,b) av_log(q->avctx,AV_LOG_ERROR," %s = %d\n", a, b); av_log(q->avctx,AV_LOG_ERROR,"COOKextradata\n"); av_log(q->avctx,AV_LOG_ERROR,"cookversion=%x\n",q->subpacket[0].cookversion); if (q->subpacket[0].cookversion > STEREO) { PRINT("js_subband_start",q->subpacket[0].js_subband_start); PRINT("js_vlc_bits",q->subpacket[0].js_vlc_bits); } av_log(q->avctx,AV_LOG_ERROR,"COOKContext\n"); PRINT("nb_channels",q->nb_channels); PRINT("bit_rate",q->bit_rate); PRINT("sample_rate",q->sample_rate); PRINT("samples_per_channel",q->subpacket[0].samples_per_channel); PRINT("samples_per_frame",q->subpacket[0].samples_per_frame); PRINT("subbands",q->subpacket[0].subbands); PRINT("random_state",q->random_state); PRINT("js_subband_start",q->subpacket[0].js_subband_start); PRINT("log2_numvector_size",q->subpacket[0].log2_numvector_size); PRINT("numvector_size",q->subpacket[0].numvector_size); PRINT("total_subbands",q->subpacket[0].total_subbands); } #endif static av_cold int cook_count_channels(unsigned int mask){ int i; int channels = 0; for(i = 0;i<32;i++){ if(mask & (1<<i)) ++channels; } return channels; } /** * Cook initialization * * @param avctx pointer to the AVCodecContext */ static av_cold int cook_decode_init(AVCodecContext *avctx) { COOKContext *q = avctx->priv_data; const uint8_t *edata_ptr = avctx->extradata; const uint8_t *edata_ptr_end = edata_ptr + avctx->extradata_size; int extradata_size = avctx->extradata_size; int s = 0; unsigned int channel_mask = 0; q->avctx = avctx; /* Take care of the codec specific extradata. */ if (extradata_size <= 0) { av_log(avctx,AV_LOG_ERROR,"Necessary extradata missing!\n"); return -1; } av_log(avctx,AV_LOG_DEBUG,"codecdata_length=%d\n",avctx->extradata_size); /* Take data from the AVCodecContext (RM container). */ q->sample_rate = avctx->sample_rate; q->nb_channels = avctx->channels; q->bit_rate = avctx->bit_rate; /* Initialize RNG. */ av_lfg_init(&q->random_state, 0); while(edata_ptr < edata_ptr_end){ /* 8 for mono, 16 for stereo, ? for multichannel Swap to right endianness so we don't need to care later on. */ if (extradata_size >= 8){ q->subpacket[s].cookversion = bytestream_get_be32(&edata_ptr); q->subpacket[s].samples_per_frame = bytestream_get_be16(&edata_ptr); q->subpacket[s].subbands = bytestream_get_be16(&edata_ptr); extradata_size -= 8; } if (avctx->extradata_size >= 8){ bytestream_get_be32(&edata_ptr); //Unknown unused q->subpacket[s].js_subband_start = bytestream_get_be16(&edata_ptr); q->subpacket[s].js_vlc_bits = bytestream_get_be16(&edata_ptr); extradata_size -= 8; } /* Initialize extradata related variables. */ q->subpacket[s].samples_per_channel = q->subpacket[s].samples_per_frame / q->nb_channels; q->subpacket[s].bits_per_subpacket = avctx->block_align * 8; /* Initialize default data states. */ q->subpacket[s].log2_numvector_size = 5; q->subpacket[s].total_subbands = q->subpacket[s].subbands; q->subpacket[s].num_channels = 1; /* Initialize version-dependent variables */ av_log(avctx,AV_LOG_DEBUG,"subpacket[%i].cookversion=%x\n",s,q->subpacket[s].cookversion); q->subpacket[s].joint_stereo = 0; switch (q->subpacket[s].cookversion) { case MONO: if (q->nb_channels != 1) { av_log(avctx,AV_LOG_ERROR,"Container channels != 1, report sample!\n"); return -1; } av_log(avctx,AV_LOG_DEBUG,"MONO\n"); break; case STEREO: if (q->nb_channels != 1) { q->subpacket[s].bits_per_subpdiv = 1; q->subpacket[s].num_channels = 2; } av_log(avctx,AV_LOG_DEBUG,"STEREO\n"); break; case JOINT_STEREO: if (q->nb_channels != 2) { av_log(avctx,AV_LOG_ERROR,"Container channels != 2, report sample!\n"); return -1; } av_log(avctx,AV_LOG_DEBUG,"JOINT_STEREO\n"); if (avctx->extradata_size >= 16){ q->subpacket[s].total_subbands = q->subpacket[s].subbands + q->subpacket[s].js_subband_start; q->subpacket[s].joint_stereo = 1; q->subpacket[s].num_channels = 2; } if (q->subpacket[s].samples_per_channel > 256) { q->subpacket[s].log2_numvector_size = 6; } if (q->subpacket[s].samples_per_channel > 512) { q->subpacket[s].log2_numvector_size = 7; } break; case MC_COOK: av_log(avctx,AV_LOG_DEBUG,"MULTI_CHANNEL\n"); if(extradata_size >= 4) channel_mask |= q->subpacket[s].channel_mask = bytestream_get_be32(&edata_ptr); if(cook_count_channels(q->subpacket[s].channel_mask) > 1){ q->subpacket[s].total_subbands = q->subpacket[s].subbands + q->subpacket[s].js_subband_start; q->subpacket[s].joint_stereo = 1; q->subpacket[s].num_channels = 2; q->subpacket[s].samples_per_channel = q->subpacket[s].samples_per_frame >> 1; if (q->subpacket[s].samples_per_channel > 256) { q->subpacket[s].log2_numvector_size = 6; } if (q->subpacket[s].samples_per_channel > 512) { q->subpacket[s].log2_numvector_size = 7; } }else q->subpacket[s].samples_per_channel = q->subpacket[s].samples_per_frame; break; default: av_log(avctx,AV_LOG_ERROR,"Unknown Cook version, report sample!\n"); return -1; break; } if(s > 1 && q->subpacket[s].samples_per_channel != q->samples_per_channel) { av_log(avctx,AV_LOG_ERROR,"different number of samples per channel!\n"); return -1; } else q->samples_per_channel = q->subpacket[0].samples_per_channel; /* Initialize variable relations */ q->subpacket[s].numvector_size = (1 << q->subpacket[s].log2_numvector_size); /* Try to catch some obviously faulty streams, othervise it might be exploitable */ if (q->subpacket[s].total_subbands > 53) { av_log(avctx,AV_LOG_ERROR,"total_subbands > 53, report sample!\n"); return -1; } if ((q->subpacket[s].js_vlc_bits > 6) || (q->subpacket[s].js_vlc_bits < 0)) { av_log(avctx,AV_LOG_ERROR,"js_vlc_bits = %d, only >= 0 and <= 6 allowed!\n",q->subpacket[s].js_vlc_bits); return -1; } if (q->subpacket[s].subbands > 50) { av_log(avctx,AV_LOG_ERROR,"subbands > 50, report sample!\n"); return -1; } q->subpacket[s].gains1.now = q->subpacket[s].gain_1; q->subpacket[s].gains1.previous = q->subpacket[s].gain_2; q->subpacket[s].gains2.now = q->subpacket[s].gain_3; q->subpacket[s].gains2.previous = q->subpacket[s].gain_4; q->num_subpackets++; s++; if (s > MAX_SUBPACKETS) { av_log(avctx,AV_LOG_ERROR,"Too many subpackets > 5, report file!\n"); return -1; } } /* Generate tables */ init_pow2table(); init_gain_table(q); init_cplscales_table(q); if (init_cook_vlc_tables(q) != 0) return -1; if(avctx->block_align >= UINT_MAX/2) return -1; /* Pad the databuffer with: DECODE_BYTES_PAD1 or DECODE_BYTES_PAD2 for decode_bytes(), FF_INPUT_BUFFER_PADDING_SIZE, for the bitstreamreader. */ q->decoded_bytes_buffer = av_mallocz(avctx->block_align + DECODE_BYTES_PAD1(avctx->block_align) + FF_INPUT_BUFFER_PADDING_SIZE); if (q->decoded_bytes_buffer == NULL) return -1; /* Initialize transform. */ if ( init_cook_mlt(q) != 0 ) return -1; /* Initialize COOK signal arithmetic handling */ if (1) { q->scalar_dequant = scalar_dequant_float; q->decouple = decouple_float; q->imlt_window = imlt_window_float; q->interpolate = interpolate_float; q->saturate_output = saturate_output_float; } /* Try to catch some obviously faulty streams, othervise it might be exploitable */ if ((q->samples_per_channel == 256) || (q->samples_per_channel == 512) || (q->samples_per_channel == 1024)) { } else { av_log(avctx,AV_LOG_ERROR,"unknown amount of samples_per_channel = %d, report sample!\n",q->samples_per_channel); return -1; } avctx->sample_fmt = SAMPLE_FMT_S16; if (channel_mask) avctx->channel_layout = channel_mask; else avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO; #ifdef COOKDEBUG dump_cook_context(q); #endif return 0; } AVCodec cook_decoder = { .name = "cook", .type = AVMEDIA_TYPE_AUDIO, .id = CODEC_ID_COOK, .priv_data_size = sizeof(COOKContext), .init = cook_decode_init, .close = cook_decode_close, .decode = cook_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("COOK"), };
123linslouis-android-video-cutter
jni/libavcodec/cook.c
C
asf20
44,331
/* * MLP decoder * Copyright (c) 2007-2008 Ian Caulfield * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * MLP decoder */ #include <stdint.h> #include "avcodec.h" #include "dsputil.h" #include "libavutil/intreadwrite.h" #include "get_bits.h" #include "libavutil/crc.h" #include "parser.h" #include "mlp_parser.h" #include "mlp.h" /** number of bits used for VLC lookup - longest Huffman code is 9 */ #define VLC_BITS 9 static const char* sample_message = "Please file a bug report following the instructions at " "http://ffmpeg.org/bugreports.html and include " "a sample of this file."; typedef struct SubStream { //! Set if a valid restart header has been read. Otherwise the substream cannot be decoded. uint8_t restart_seen; //@{ /** restart header data */ //! The type of noise to be used in the rematrix stage. uint16_t noise_type; //! The index of the first channel coded in this substream. uint8_t min_channel; //! The index of the last channel coded in this substream. uint8_t max_channel; //! The number of channels input into the rematrix stage. uint8_t max_matrix_channel; //! For each channel output by the matrix, the output channel to map it to uint8_t ch_assign[MAX_CHANNELS]; //! Channel coding parameters for channels in the substream ChannelParams channel_params[MAX_CHANNELS]; //! The left shift applied to random noise in 0x31ea substreams. uint8_t noise_shift; //! The current seed value for the pseudorandom noise generator(s). uint32_t noisegen_seed; //! Set if the substream contains extra info to check the size of VLC blocks. uint8_t data_check_present; //! Bitmask of which parameter sets are conveyed in a decoding parameter block. uint8_t param_presence_flags; #define PARAM_BLOCKSIZE (1 << 7) #define PARAM_MATRIX (1 << 6) #define PARAM_OUTSHIFT (1 << 5) #define PARAM_QUANTSTEP (1 << 4) #define PARAM_FIR (1 << 3) #define PARAM_IIR (1 << 2) #define PARAM_HUFFOFFSET (1 << 1) #define PARAM_PRESENCE (1 << 0) //@} //@{ /** matrix data */ //! Number of matrices to be applied. uint8_t num_primitive_matrices; //! matrix output channel uint8_t matrix_out_ch[MAX_MATRICES]; //! Whether the LSBs of the matrix output are encoded in the bitstream. uint8_t lsb_bypass[MAX_MATRICES]; //! Matrix coefficients, stored as 2.14 fixed point. int32_t matrix_coeff[MAX_MATRICES][MAX_CHANNELS]; //! Left shift to apply to noise values in 0x31eb substreams. uint8_t matrix_noise_shift[MAX_MATRICES]; //@} //! Left shift to apply to Huffman-decoded residuals. uint8_t quant_step_size[MAX_CHANNELS]; //! number of PCM samples in current audio block uint16_t blocksize; //! Number of PCM samples decoded so far in this frame. uint16_t blockpos; //! Left shift to apply to decoded PCM values to get final 24-bit output. int8_t output_shift[MAX_CHANNELS]; //! Running XOR of all output samples. int32_t lossless_check_data; } SubStream; typedef struct MLPDecodeContext { AVCodecContext *avctx; //! Current access unit being read has a major sync. int is_major_sync_unit; //! Set if a valid major sync block has been read. Otherwise no decoding is possible. uint8_t params_valid; //! Number of substreams contained within this stream. uint8_t num_substreams; //! Index of the last substream to decode - further substreams are skipped. uint8_t max_decoded_substream; //! number of PCM samples contained in each frame int access_unit_size; //! next power of two above the number of samples in each frame int access_unit_size_pow2; SubStream substream[MAX_SUBSTREAMS]; int matrix_changed; int filter_changed[MAX_CHANNELS][NUM_FILTERS]; int8_t noise_buffer[MAX_BLOCKSIZE_POW2]; int8_t bypassed_lsbs[MAX_BLOCKSIZE][MAX_CHANNELS]; int32_t sample_buffer[MAX_BLOCKSIZE][MAX_CHANNELS]; DSPContext dsp; } MLPDecodeContext; static VLC huff_vlc[3]; /** Initialize static data, constant between all invocations of the codec. */ static av_cold void init_static(void) { if (!huff_vlc[0].bits) { INIT_VLC_STATIC(&huff_vlc[0], VLC_BITS, 18, &ff_mlp_huffman_tables[0][0][1], 2, 1, &ff_mlp_huffman_tables[0][0][0], 2, 1, 512); INIT_VLC_STATIC(&huff_vlc[1], VLC_BITS, 16, &ff_mlp_huffman_tables[1][0][1], 2, 1, &ff_mlp_huffman_tables[1][0][0], 2, 1, 512); INIT_VLC_STATIC(&huff_vlc[2], VLC_BITS, 15, &ff_mlp_huffman_tables[2][0][1], 2, 1, &ff_mlp_huffman_tables[2][0][0], 2, 1, 512); } ff_mlp_init_crc(); } static inline int32_t calculate_sign_huff(MLPDecodeContext *m, unsigned int substr, unsigned int ch) { SubStream *s = &m->substream[substr]; ChannelParams *cp = &s->channel_params[ch]; int lsb_bits = cp->huff_lsbs - s->quant_step_size[ch]; int sign_shift = lsb_bits + (cp->codebook ? 2 - cp->codebook : -1); int32_t sign_huff_offset = cp->huff_offset; if (cp->codebook > 0) sign_huff_offset -= 7 << lsb_bits; if (sign_shift >= 0) sign_huff_offset -= 1 << sign_shift; return sign_huff_offset; } /** Read a sample, consisting of either, both or neither of entropy-coded MSBs * and plain LSBs. */ static inline int read_huff_channels(MLPDecodeContext *m, GetBitContext *gbp, unsigned int substr, unsigned int pos) { SubStream *s = &m->substream[substr]; unsigned int mat, channel; for (mat = 0; mat < s->num_primitive_matrices; mat++) if (s->lsb_bypass[mat]) m->bypassed_lsbs[pos + s->blockpos][mat] = get_bits1(gbp); for (channel = s->min_channel; channel <= s->max_channel; channel++) { ChannelParams *cp = &s->channel_params[channel]; int codebook = cp->codebook; int quant_step_size = s->quant_step_size[channel]; int lsb_bits = cp->huff_lsbs - quant_step_size; int result = 0; if (codebook > 0) result = get_vlc2(gbp, huff_vlc[codebook-1].table, VLC_BITS, (9 + VLC_BITS - 1) / VLC_BITS); if (result < 0) return -1; if (lsb_bits > 0) result = (result << lsb_bits) + get_bits(gbp, lsb_bits); result += cp->sign_huff_offset; result <<= quant_step_size; m->sample_buffer[pos + s->blockpos][channel] = result; } return 0; } static av_cold int mlp_decode_init(AVCodecContext *avctx) { MLPDecodeContext *m = avctx->priv_data; int substr; init_static(); m->avctx = avctx; for (substr = 0; substr < MAX_SUBSTREAMS; substr++) m->substream[substr].lossless_check_data = 0xffffffff; dsputil_init(&m->dsp, avctx); return 0; } /** Read a major sync info header - contains high level information about * the stream - sample rate, channel arrangement etc. Most of this * information is not actually necessary for decoding, only for playback. */ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb) { MLPHeaderInfo mh; int substr; if (ff_mlp_read_major_sync(m->avctx, &mh, gb) != 0) return -1; if (mh.group1_bits == 0) { av_log(m->avctx, AV_LOG_ERROR, "invalid/unknown bits per sample\n"); return -1; } if (mh.group2_bits > mh.group1_bits) { av_log(m->avctx, AV_LOG_ERROR, "Channel group 2 cannot have more bits per sample than group 1.\n"); return -1; } if (mh.group2_samplerate && mh.group2_samplerate != mh.group1_samplerate) { av_log(m->avctx, AV_LOG_ERROR, "Channel groups with differing sample rates are not currently supported.\n"); return -1; } if (mh.group1_samplerate == 0) { av_log(m->avctx, AV_LOG_ERROR, "invalid/unknown sampling rate\n"); return -1; } if (mh.group1_samplerate > MAX_SAMPLERATE) { av_log(m->avctx, AV_LOG_ERROR, "Sampling rate %d is greater than the supported maximum (%d).\n", mh.group1_samplerate, MAX_SAMPLERATE); return -1; } if (mh.access_unit_size > MAX_BLOCKSIZE) { av_log(m->avctx, AV_LOG_ERROR, "Block size %d is greater than the supported maximum (%d).\n", mh.access_unit_size, MAX_BLOCKSIZE); return -1; } if (mh.access_unit_size_pow2 > MAX_BLOCKSIZE_POW2) { av_log(m->avctx, AV_LOG_ERROR, "Block size pow2 %d is greater than the supported maximum (%d).\n", mh.access_unit_size_pow2, MAX_BLOCKSIZE_POW2); return -1; } if (mh.num_substreams == 0) return -1; if (m->avctx->codec_id == CODEC_ID_MLP && mh.num_substreams > 2) { av_log(m->avctx, AV_LOG_ERROR, "MLP only supports up to 2 substreams.\n"); return -1; } if (mh.num_substreams > MAX_SUBSTREAMS) { av_log(m->avctx, AV_LOG_ERROR, "Number of substreams %d is larger than the maximum supported " "by the decoder. %s\n", mh.num_substreams, sample_message); return -1; } m->access_unit_size = mh.access_unit_size; m->access_unit_size_pow2 = mh.access_unit_size_pow2; m->num_substreams = mh.num_substreams; m->max_decoded_substream = m->num_substreams - 1; m->avctx->sample_rate = mh.group1_samplerate; m->avctx->frame_size = mh.access_unit_size; m->avctx->bits_per_raw_sample = mh.group1_bits; if (mh.group1_bits > 16) m->avctx->sample_fmt = SAMPLE_FMT_S32; else m->avctx->sample_fmt = SAMPLE_FMT_S16; m->params_valid = 1; for (substr = 0; substr < MAX_SUBSTREAMS; substr++) m->substream[substr].restart_seen = 0; return 0; } /** Read a restart header from a block in a substream. This contains parameters * required to decode the audio that do not change very often. Generally * (always) present only in blocks following a major sync. */ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp, const uint8_t *buf, unsigned int substr) { SubStream *s = &m->substream[substr]; unsigned int ch; int sync_word, tmp; uint8_t checksum; uint8_t lossless_check; int start_count = get_bits_count(gbp); const int max_matrix_channel = m->avctx->codec_id == CODEC_ID_MLP ? MAX_MATRIX_CHANNEL_MLP : MAX_MATRIX_CHANNEL_TRUEHD; sync_word = get_bits(gbp, 13); if (sync_word != 0x31ea >> 1) { av_log(m->avctx, AV_LOG_ERROR, "restart header sync incorrect (got 0x%04x)\n", sync_word); return -1; } s->noise_type = get_bits1(gbp); if (m->avctx->codec_id == CODEC_ID_MLP && s->noise_type) { av_log(m->avctx, AV_LOG_ERROR, "MLP must have 0x31ea sync word.\n"); return -1; } skip_bits(gbp, 16); /* Output timestamp */ s->min_channel = get_bits(gbp, 4); s->max_channel = get_bits(gbp, 4); s->max_matrix_channel = get_bits(gbp, 4); if (s->max_matrix_channel > max_matrix_channel) { av_log(m->avctx, AV_LOG_ERROR, "Max matrix channel cannot be greater than %d.\n", max_matrix_channel); return -1; } if (s->max_channel != s->max_matrix_channel) { av_log(m->avctx, AV_LOG_ERROR, "Max channel must be equal max matrix channel.\n"); return -1; } /* This should happen for TrueHD streams with >6 channels and MLP's noise * type. It is not yet known if this is allowed. */ if (s->max_channel > MAX_MATRIX_CHANNEL_MLP && !s->noise_type) { av_log(m->avctx, AV_LOG_ERROR, "Number of channels %d is larger than the maximum supported " "by the decoder. %s\n", s->max_channel+2, sample_message); return -1; } if (s->min_channel > s->max_channel) { av_log(m->avctx, AV_LOG_ERROR, "Substream min channel cannot be greater than max channel.\n"); return -1; } if (m->avctx->request_channels > 0 && s->max_channel + 1 >= m->avctx->request_channels && substr < m->max_decoded_substream) { av_log(m->avctx, AV_LOG_DEBUG, "Extracting %d channel downmix from substream %d. " "Further substreams will be skipped.\n", s->max_channel + 1, substr); m->max_decoded_substream = substr; } s->noise_shift = get_bits(gbp, 4); s->noisegen_seed = get_bits(gbp, 23); skip_bits(gbp, 19); s->data_check_present = get_bits1(gbp); lossless_check = get_bits(gbp, 8); if (substr == m->max_decoded_substream && s->lossless_check_data != 0xffffffff) { tmp = xor_32_to_8(s->lossless_check_data); if (tmp != lossless_check) av_log(m->avctx, AV_LOG_WARNING, "Lossless check failed - expected %02x, calculated %02x.\n", lossless_check, tmp); } skip_bits(gbp, 16); memset(s->ch_assign, 0, sizeof(s->ch_assign)); for (ch = 0; ch <= s->max_matrix_channel; ch++) { int ch_assign = get_bits(gbp, 6); if (ch_assign > s->max_matrix_channel) { av_log(m->avctx, AV_LOG_ERROR, "Assignment of matrix channel %d to invalid output channel %d. %s\n", ch, ch_assign, sample_message); return -1; } s->ch_assign[ch_assign] = ch; } checksum = ff_mlp_restart_checksum(buf, get_bits_count(gbp) - start_count); if (checksum != get_bits(gbp, 8)) av_log(m->avctx, AV_LOG_ERROR, "restart header checksum error\n"); /* Set default decoding parameters. */ s->param_presence_flags = 0xff; s->num_primitive_matrices = 0; s->blocksize = 8; s->lossless_check_data = 0; memset(s->output_shift , 0, sizeof(s->output_shift )); memset(s->quant_step_size, 0, sizeof(s->quant_step_size)); for (ch = s->min_channel; ch <= s->max_channel; ch++) { ChannelParams *cp = &s->channel_params[ch]; cp->filter_params[FIR].order = 0; cp->filter_params[IIR].order = 0; cp->filter_params[FIR].shift = 0; cp->filter_params[IIR].shift = 0; /* Default audio coding is 24-bit raw PCM. */ cp->huff_offset = 0; cp->sign_huff_offset = (-1) << 23; cp->codebook = 0; cp->huff_lsbs = 24; } if (substr == m->max_decoded_substream) m->avctx->channels = s->max_matrix_channel + 1; return 0; } /** Read parameters for one of the prediction filters. */ static int read_filter_params(MLPDecodeContext *m, GetBitContext *gbp, unsigned int substr, unsigned int channel, unsigned int filter) { SubStream *s = &m->substream[substr]; FilterParams *fp = &s->channel_params[channel].filter_params[filter]; const int max_order = filter ? MAX_IIR_ORDER : MAX_FIR_ORDER; const char fchar = filter ? 'I' : 'F'; int i, order; // Filter is 0 for FIR, 1 for IIR. assert(filter < 2); if (m->filter_changed[channel][filter]++ > 1) { av_log(m->avctx, AV_LOG_ERROR, "Filters may change only once per access unit.\n"); return -1; } order = get_bits(gbp, 4); if (order > max_order) { av_log(m->avctx, AV_LOG_ERROR, "%cIR filter order %d is greater than maximum %d.\n", fchar, order, max_order); return -1; } fp->order = order; if (order > 0) { int32_t *fcoeff = s->channel_params[channel].coeff[filter]; int coeff_bits, coeff_shift; fp->shift = get_bits(gbp, 4); coeff_bits = get_bits(gbp, 5); coeff_shift = get_bits(gbp, 3); if (coeff_bits < 1 || coeff_bits > 16) { av_log(m->avctx, AV_LOG_ERROR, "%cIR filter coeff_bits must be between 1 and 16.\n", fchar); return -1; } if (coeff_bits + coeff_shift > 16) { av_log(m->avctx, AV_LOG_ERROR, "Sum of coeff_bits and coeff_shift for %cIR filter must be 16 or less.\n", fchar); return -1; } for (i = 0; i < order; i++) fcoeff[i] = get_sbits(gbp, coeff_bits) << coeff_shift; if (get_bits1(gbp)) { int state_bits, state_shift; if (filter == FIR) { av_log(m->avctx, AV_LOG_ERROR, "FIR filter has state data specified.\n"); return -1; } state_bits = get_bits(gbp, 4); state_shift = get_bits(gbp, 4); /* TODO: Check validity of state data. */ for (i = 0; i < order; i++) fp->state[i] = get_sbits(gbp, state_bits) << state_shift; } } return 0; } /** Read parameters for primitive matrices. */ static int read_matrix_params(MLPDecodeContext *m, unsigned int substr, GetBitContext *gbp) { SubStream *s = &m->substream[substr]; unsigned int mat, ch; const int max_primitive_matrices = m->avctx->codec_id == CODEC_ID_MLP ? MAX_MATRICES_MLP : MAX_MATRICES_TRUEHD; if (m->matrix_changed++ > 1) { av_log(m->avctx, AV_LOG_ERROR, "Matrices may change only once per access unit.\n"); return -1; } s->num_primitive_matrices = get_bits(gbp, 4); if (s->num_primitive_matrices > max_primitive_matrices) { av_log(m->avctx, AV_LOG_ERROR, "Number of primitive matrices cannot be greater than %d.\n", max_primitive_matrices); return -1; } for (mat = 0; mat < s->num_primitive_matrices; mat++) { int frac_bits, max_chan; s->matrix_out_ch[mat] = get_bits(gbp, 4); frac_bits = get_bits(gbp, 4); s->lsb_bypass [mat] = get_bits1(gbp); if (s->matrix_out_ch[mat] > s->max_matrix_channel) { av_log(m->avctx, AV_LOG_ERROR, "Invalid channel %d specified as output from matrix.\n", s->matrix_out_ch[mat]); return -1; } if (frac_bits > 14) { av_log(m->avctx, AV_LOG_ERROR, "Too many fractional bits specified.\n"); return -1; } max_chan = s->max_matrix_channel; if (!s->noise_type) max_chan+=2; for (ch = 0; ch <= max_chan; ch++) { int coeff_val = 0; if (get_bits1(gbp)) coeff_val = get_sbits(gbp, frac_bits + 2); s->matrix_coeff[mat][ch] = coeff_val << (14 - frac_bits); } if (s->noise_type) s->matrix_noise_shift[mat] = get_bits(gbp, 4); else s->matrix_noise_shift[mat] = 0; } return 0; } /** Read channel parameters. */ static int read_channel_params(MLPDecodeContext *m, unsigned int substr, GetBitContext *gbp, unsigned int ch) { SubStream *s = &m->substream[substr]; ChannelParams *cp = &s->channel_params[ch]; FilterParams *fir = &cp->filter_params[FIR]; FilterParams *iir = &cp->filter_params[IIR]; if (s->param_presence_flags & PARAM_FIR) if (get_bits1(gbp)) if (read_filter_params(m, gbp, substr, ch, FIR) < 0) return -1; if (s->param_presence_flags & PARAM_IIR) if (get_bits1(gbp)) if (read_filter_params(m, gbp, substr, ch, IIR) < 0) return -1; if (fir->order + iir->order > 8) { av_log(m->avctx, AV_LOG_ERROR, "Total filter orders too high.\n"); return -1; } if (fir->order && iir->order && fir->shift != iir->shift) { av_log(m->avctx, AV_LOG_ERROR, "FIR and IIR filters must use the same precision.\n"); return -1; } /* The FIR and IIR filters must have the same precision. * To simplify the filtering code, only the precision of the * FIR filter is considered. If only the IIR filter is employed, * the FIR filter precision is set to that of the IIR filter, so * that the filtering code can use it. */ if (!fir->order && iir->order) fir->shift = iir->shift; if (s->param_presence_flags & PARAM_HUFFOFFSET) if (get_bits1(gbp)) cp->huff_offset = get_sbits(gbp, 15); cp->codebook = get_bits(gbp, 2); cp->huff_lsbs = get_bits(gbp, 5); if (cp->huff_lsbs > 24) { av_log(m->avctx, AV_LOG_ERROR, "Invalid huff_lsbs.\n"); return -1; } cp->sign_huff_offset = calculate_sign_huff(m, substr, ch); return 0; } /** Read decoding parameters that change more often than those in the restart * header. */ static int read_decoding_params(MLPDecodeContext *m, GetBitContext *gbp, unsigned int substr) { SubStream *s = &m->substream[substr]; unsigned int ch; if (s->param_presence_flags & PARAM_PRESENCE) if (get_bits1(gbp)) s->param_presence_flags = get_bits(gbp, 8); if (s->param_presence_flags & PARAM_BLOCKSIZE) if (get_bits1(gbp)) { s->blocksize = get_bits(gbp, 9); if (s->blocksize < 8 || s->blocksize > m->access_unit_size) { av_log(m->avctx, AV_LOG_ERROR, "Invalid blocksize."); s->blocksize = 0; return -1; } } if (s->param_presence_flags & PARAM_MATRIX) if (get_bits1(gbp)) if (read_matrix_params(m, substr, gbp) < 0) return -1; if (s->param_presence_flags & PARAM_OUTSHIFT) if (get_bits1(gbp)) for (ch = 0; ch <= s->max_matrix_channel; ch++) s->output_shift[ch] = get_sbits(gbp, 4); if (s->param_presence_flags & PARAM_QUANTSTEP) if (get_bits1(gbp)) for (ch = 0; ch <= s->max_channel; ch++) { ChannelParams *cp = &s->channel_params[ch]; s->quant_step_size[ch] = get_bits(gbp, 4); cp->sign_huff_offset = calculate_sign_huff(m, substr, ch); } for (ch = s->min_channel; ch <= s->max_channel; ch++) if (get_bits1(gbp)) if (read_channel_params(m, substr, gbp, ch) < 0) return -1; return 0; } #define MSB_MASK(bits) (-1u << bits) /** Generate PCM samples using the prediction filters and residual values * read from the data stream, and update the filter state. */ static void filter_channel(MLPDecodeContext *m, unsigned int substr, unsigned int channel) { SubStream *s = &m->substream[substr]; const int32_t *fircoeff = s->channel_params[channel].coeff[FIR]; int32_t state_buffer[NUM_FILTERS][MAX_BLOCKSIZE + MAX_FIR_ORDER]; int32_t *firbuf = state_buffer[FIR] + MAX_BLOCKSIZE; int32_t *iirbuf = state_buffer[IIR] + MAX_BLOCKSIZE; FilterParams *fir = &s->channel_params[channel].filter_params[FIR]; FilterParams *iir = &s->channel_params[channel].filter_params[IIR]; unsigned int filter_shift = fir->shift; int32_t mask = MSB_MASK(s->quant_step_size[channel]); memcpy(firbuf, fir->state, MAX_FIR_ORDER * sizeof(int32_t)); memcpy(iirbuf, iir->state, MAX_IIR_ORDER * sizeof(int32_t)); m->dsp.mlp_filter_channel(firbuf, fircoeff, fir->order, iir->order, filter_shift, mask, s->blocksize, &m->sample_buffer[s->blockpos][channel]); memcpy(fir->state, firbuf - s->blocksize, MAX_FIR_ORDER * sizeof(int32_t)); memcpy(iir->state, iirbuf - s->blocksize, MAX_IIR_ORDER * sizeof(int32_t)); } /** Read a block of PCM residual data (or actual if no filtering active). */ static int read_block_data(MLPDecodeContext *m, GetBitContext *gbp, unsigned int substr) { SubStream *s = &m->substream[substr]; unsigned int i, ch, expected_stream_pos = 0; if (s->data_check_present) { expected_stream_pos = get_bits_count(gbp); expected_stream_pos += get_bits(gbp, 16); av_log(m->avctx, AV_LOG_WARNING, "This file contains some features " "we have not tested yet. %s\n", sample_message); } if (s->blockpos + s->blocksize > m->access_unit_size) { av_log(m->avctx, AV_LOG_ERROR, "too many audio samples in frame\n"); return -1; } memset(&m->bypassed_lsbs[s->blockpos][0], 0, s->blocksize * sizeof(m->bypassed_lsbs[0])); for (i = 0; i < s->blocksize; i++) if (read_huff_channels(m, gbp, substr, i) < 0) return -1; for (ch = s->min_channel; ch <= s->max_channel; ch++) filter_channel(m, substr, ch); s->blockpos += s->blocksize; if (s->data_check_present) { if (get_bits_count(gbp) != expected_stream_pos) av_log(m->avctx, AV_LOG_ERROR, "block data length mismatch\n"); skip_bits(gbp, 8); } return 0; } /** Data table used for TrueHD noise generation function. */ static const int8_t noise_table[256] = { 30, 51, 22, 54, 3, 7, -4, 38, 14, 55, 46, 81, 22, 58, -3, 2, 52, 31, -7, 51, 15, 44, 74, 30, 85, -17, 10, 33, 18, 80, 28, 62, 10, 32, 23, 69, 72, 26, 35, 17, 73, 60, 8, 56, 2, 6, -2, -5, 51, 4, 11, 50, 66, 76, 21, 44, 33, 47, 1, 26, 64, 48, 57, 40, 38, 16, -10, -28, 92, 22, -18, 29, -10, 5, -13, 49, 19, 24, 70, 34, 61, 48, 30, 14, -6, 25, 58, 33, 42, 60, 67, 17, 54, 17, 22, 30, 67, 44, -9, 50, -11, 43, 40, 32, 59, 82, 13, 49, -14, 55, 60, 36, 48, 49, 31, 47, 15, 12, 4, 65, 1, 23, 29, 39, 45, -2, 84, 69, 0, 72, 37, 57, 27, 41, -15, -16, 35, 31, 14, 61, 24, 0, 27, 24, 16, 41, 55, 34, 53, 9, 56, 12, 25, 29, 53, 5, 20, -20, -8, 20, 13, 28, -3, 78, 38, 16, 11, 62, 46, 29, 21, 24, 46, 65, 43, -23, 89, 18, 74, 21, 38, -12, 19, 12, -19, 8, 15, 33, 4, 57, 9, -8, 36, 35, 26, 28, 7, 83, 63, 79, 75, 11, 3, 87, 37, 47, 34, 40, 39, 19, 20, 42, 27, 34, 39, 77, 13, 42, 59, 64, 45, -1, 32, 37, 45, -5, 53, -6, 7, 36, 50, 23, 6, 32, 9, -21, 18, 71, 27, 52, -25, 31, 35, 42, -1, 68, 63, 52, 26, 43, 66, 37, 41, 25, 40, 70, }; /** Noise generation functions. * I'm not sure what these are for - they seem to be some kind of pseudorandom * sequence generators, used to generate noise data which is used when the * channels are rematrixed. I'm not sure if they provide a practical benefit * to compression, or just obfuscate the decoder. Are they for some kind of * dithering? */ /** Generate two channels of noise, used in the matrix when * restart sync word == 0x31ea. */ static void generate_2_noise_channels(MLPDecodeContext *m, unsigned int substr) { SubStream *s = &m->substream[substr]; unsigned int i; uint32_t seed = s->noisegen_seed; unsigned int maxchan = s->max_matrix_channel; for (i = 0; i < s->blockpos; i++) { uint16_t seed_shr7 = seed >> 7; m->sample_buffer[i][maxchan+1] = ((int8_t)(seed >> 15)) << s->noise_shift; m->sample_buffer[i][maxchan+2] = ((int8_t) seed_shr7) << s->noise_shift; seed = (seed << 16) ^ seed_shr7 ^ (seed_shr7 << 5); } s->noisegen_seed = seed; } /** Generate a block of noise, used when restart sync word == 0x31eb. */ static void fill_noise_buffer(MLPDecodeContext *m, unsigned int substr) { SubStream *s = &m->substream[substr]; unsigned int i; uint32_t seed = s->noisegen_seed; for (i = 0; i < m->access_unit_size_pow2; i++) { uint8_t seed_shr15 = seed >> 15; m->noise_buffer[i] = noise_table[seed_shr15]; seed = (seed << 8) ^ seed_shr15 ^ (seed_shr15 << 5); } s->noisegen_seed = seed; } /** Apply the channel matrices in turn to reconstruct the original audio * samples. */ static void rematrix_channels(MLPDecodeContext *m, unsigned int substr) { SubStream *s = &m->substream[substr]; unsigned int mat, src_ch, i; unsigned int maxchan; maxchan = s->max_matrix_channel; if (!s->noise_type) { generate_2_noise_channels(m, substr); maxchan += 2; } else { fill_noise_buffer(m, substr); } for (mat = 0; mat < s->num_primitive_matrices; mat++) { int matrix_noise_shift = s->matrix_noise_shift[mat]; unsigned int dest_ch = s->matrix_out_ch[mat]; int32_t mask = MSB_MASK(s->quant_step_size[dest_ch]); int32_t *coeffs = s->matrix_coeff[mat]; int index = s->num_primitive_matrices - mat; int index2 = 2 * index + 1; /* TODO: DSPContext? */ for (i = 0; i < s->blockpos; i++) { int32_t bypassed_lsb = m->bypassed_lsbs[i][mat]; int32_t *samples = m->sample_buffer[i]; int64_t accum = 0; for (src_ch = 0; src_ch <= maxchan; src_ch++) accum += (int64_t) samples[src_ch] * coeffs[src_ch]; if (matrix_noise_shift) { index &= m->access_unit_size_pow2 - 1; accum += m->noise_buffer[index] << (matrix_noise_shift + 7); index += index2; } samples[dest_ch] = ((accum >> 14) & mask) + bypassed_lsb; } } } /** Write the audio data into the output buffer. */ static int output_data_internal(MLPDecodeContext *m, unsigned int substr, uint8_t *data, unsigned int *data_size, int is32) { SubStream *s = &m->substream[substr]; unsigned int i, out_ch = 0; int32_t *data_32 = (int32_t*) data; int16_t *data_16 = (int16_t*) data; if (*data_size < (s->max_channel + 1) * s->blockpos * (is32 ? 4 : 2)) return -1; for (i = 0; i < s->blockpos; i++) { for (out_ch = 0; out_ch <= s->max_matrix_channel; out_ch++) { int mat_ch = s->ch_assign[out_ch]; int32_t sample = m->sample_buffer[i][mat_ch] << s->output_shift[mat_ch]; s->lossless_check_data ^= (sample & 0xffffff) << mat_ch; if (is32) *data_32++ = sample << 8; else *data_16++ = sample >> 8; } } *data_size = i * out_ch * (is32 ? 4 : 2); return 0; } static int output_data(MLPDecodeContext *m, unsigned int substr, uint8_t *data, unsigned int *data_size) { if (m->avctx->sample_fmt == SAMPLE_FMT_S32) return output_data_internal(m, substr, data, data_size, 1); else return output_data_internal(m, substr, data, data_size, 0); } /** Read an access unit from the stream. * Returns < 0 on error, 0 if not enough data is present in the input stream * otherwise returns the number of bytes consumed. */ static int read_access_unit(AVCodecContext *avctx, void* data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; MLPDecodeContext *m = avctx->priv_data; GetBitContext gb; unsigned int length, substr; unsigned int substream_start; unsigned int header_size = 4; unsigned int substr_header_size = 0; uint8_t substream_parity_present[MAX_SUBSTREAMS]; uint16_t substream_data_len[MAX_SUBSTREAMS]; uint8_t parity_bits; if (buf_size < 4) return 0; length = (AV_RB16(buf) & 0xfff) * 2; if (length < 4 || length > buf_size) return -1; init_get_bits(&gb, (buf + 4), (length - 4) * 8); m->is_major_sync_unit = 0; if (show_bits_long(&gb, 31) == (0xf8726fba >> 1)) { if (read_major_sync(m, &gb) < 0) goto error; m->is_major_sync_unit = 1; header_size += 28; } if (!m->params_valid) { av_log(m->avctx, AV_LOG_WARNING, "Stream parameters not seen; skipping frame.\n"); *data_size = 0; return length; } substream_start = 0; for (substr = 0; substr < m->num_substreams; substr++) { int extraword_present, checkdata_present, end, nonrestart_substr; extraword_present = get_bits1(&gb); nonrestart_substr = get_bits1(&gb); checkdata_present = get_bits1(&gb); skip_bits1(&gb); end = get_bits(&gb, 12) * 2; substr_header_size += 2; if (extraword_present) { if (m->avctx->codec_id == CODEC_ID_MLP) { av_log(m->avctx, AV_LOG_ERROR, "There must be no extraword for MLP.\n"); goto error; } skip_bits(&gb, 16); substr_header_size += 2; } if (!(nonrestart_substr ^ m->is_major_sync_unit)) { av_log(m->avctx, AV_LOG_ERROR, "Invalid nonrestart_substr.\n"); goto error; } if (end + header_size + substr_header_size > length) { av_log(m->avctx, AV_LOG_ERROR, "Indicated length of substream %d data goes off end of " "packet.\n", substr); end = length - header_size - substr_header_size; } if (end < substream_start) { av_log(avctx, AV_LOG_ERROR, "Indicated end offset of substream %d data " "is smaller than calculated start offset.\n", substr); goto error; } if (substr > m->max_decoded_substream) continue; substream_parity_present[substr] = checkdata_present; substream_data_len[substr] = end - substream_start; substream_start = end; } parity_bits = ff_mlp_calculate_parity(buf, 4); parity_bits ^= ff_mlp_calculate_parity(buf + header_size, substr_header_size); if ((((parity_bits >> 4) ^ parity_bits) & 0xF) != 0xF) { av_log(avctx, AV_LOG_ERROR, "Parity check failed.\n"); goto error; } buf += header_size + substr_header_size; for (substr = 0; substr <= m->max_decoded_substream; substr++) { SubStream *s = &m->substream[substr]; init_get_bits(&gb, buf, substream_data_len[substr] * 8); m->matrix_changed = 0; memset(m->filter_changed, 0, sizeof(m->filter_changed)); s->blockpos = 0; do { if (get_bits1(&gb)) { if (get_bits1(&gb)) { /* A restart header should be present. */ if (read_restart_header(m, &gb, buf, substr) < 0) goto next_substr; s->restart_seen = 1; } if (!s->restart_seen) goto next_substr; if (read_decoding_params(m, &gb, substr) < 0) goto next_substr; } if (!s->restart_seen) goto next_substr; if (read_block_data(m, &gb, substr) < 0) return -1; if (get_bits_count(&gb) >= substream_data_len[substr] * 8) goto substream_length_mismatch; } while (!get_bits1(&gb)); skip_bits(&gb, (-get_bits_count(&gb)) & 15); if (substream_data_len[substr] * 8 - get_bits_count(&gb) >= 32) { int shorten_by; if (get_bits(&gb, 16) != 0xD234) return -1; shorten_by = get_bits(&gb, 16); if (m->avctx->codec_id == CODEC_ID_TRUEHD && shorten_by & 0x2000) s->blockpos -= FFMIN(shorten_by & 0x1FFF, s->blockpos); else if (m->avctx->codec_id == CODEC_ID_MLP && shorten_by != 0xD234) return -1; if (substr == m->max_decoded_substream) av_log(m->avctx, AV_LOG_INFO, "End of stream indicated.\n"); } if (substream_parity_present[substr]) { uint8_t parity, checksum; if (substream_data_len[substr] * 8 - get_bits_count(&gb) != 16) goto substream_length_mismatch; parity = ff_mlp_calculate_parity(buf, substream_data_len[substr] - 2); checksum = ff_mlp_checksum8 (buf, substream_data_len[substr] - 2); if ((get_bits(&gb, 8) ^ parity) != 0xa9 ) av_log(m->avctx, AV_LOG_ERROR, "Substream %d parity check failed.\n", substr); if ( get_bits(&gb, 8) != checksum) av_log(m->avctx, AV_LOG_ERROR, "Substream %d checksum failed.\n" , substr); } if (substream_data_len[substr] * 8 != get_bits_count(&gb)) goto substream_length_mismatch; next_substr: if (!s->restart_seen) av_log(m->avctx, AV_LOG_ERROR, "No restart header present in substream %d.\n", substr); buf += substream_data_len[substr]; } rematrix_channels(m, m->max_decoded_substream); if (output_data(m, m->max_decoded_substream, data, data_size) < 0) return -1; return length; substream_length_mismatch: av_log(m->avctx, AV_LOG_ERROR, "substream %d length mismatch\n", substr); return -1; error: m->params_valid = 0; return -1; } AVCodec mlp_decoder = { "mlp", AVMEDIA_TYPE_AUDIO, CODEC_ID_MLP, sizeof(MLPDecodeContext), mlp_decode_init, NULL, NULL, read_access_unit, .long_name = NULL_IF_CONFIG_SMALL("MLP (Meridian Lossless Packing)"), }; #if CONFIG_TRUEHD_DECODER AVCodec truehd_decoder = { "truehd", AVMEDIA_TYPE_AUDIO, CODEC_ID_TRUEHD, sizeof(MLPDecodeContext), mlp_decode_init, NULL, NULL, read_access_unit, .long_name = NULL_IF_CONFIG_SMALL("TrueHD"), }; #endif /* CONFIG_TRUEHD_DECODER */
123linslouis-android-video-cutter
jni/libavcodec/mlpdec.c
C
asf20
39,153
/* * copyright (c) 2008 Michael Niedermayer <michaelni@gmx.at> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "fft.h" #include "synth_filter.h" static void synth_filter_float(FFTContext *imdct, float *synth_buf_ptr, int *synth_buf_offset, float synth_buf2[32], const float window[512], float out[32], const float in[32], float scale, float bias) { float *synth_buf= synth_buf_ptr + *synth_buf_offset; int i, j; ff_imdct_half(imdct, synth_buf, in); for (i = 0; i < 16; i++){ float a= synth_buf2[i ]; float b= synth_buf2[i + 16]; float c= 0; float d= 0; for (j = 0; j < 512 - *synth_buf_offset; j += 64){ a += window[i + j ]*(-synth_buf[15 - i + j ]); b += window[i + j + 16]*( synth_buf[ i + j ]); c += window[i + j + 32]*( synth_buf[16 + i + j ]); d += window[i + j + 48]*( synth_buf[31 - i + j ]); } for ( ; j < 512; j += 64){ a += window[i + j ]*(-synth_buf[15 - i + j - 512]); b += window[i + j + 16]*( synth_buf[ i + j - 512]); c += window[i + j + 32]*( synth_buf[16 + i + j - 512]); d += window[i + j + 48]*( synth_buf[31 - i + j - 512]); } out[i ] = a*scale + bias; out[i + 16] = b*scale + bias; synth_buf2[i ] = c; synth_buf2[i + 16] = d; } *synth_buf_offset= (*synth_buf_offset - 32)&511; } av_cold void ff_synth_filter_init(SynthFilterContext *c) { c->synth_filter_float = synth_filter_float; if (ARCH_ARM) ff_synth_filter_init_arm(c); }
123linslouis-android-video-cutter
jni/libavcodec/synth_filter.c
C
asf20
2,436
/* * Beam Software VB decoder * Copyright (c) 2007 Konstantin Shishkov * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * VB Video decoder */ #include <stdio.h> #include <stdlib.h> #include "avcodec.h" #include "bytestream.h" enum VBFlags{ VB_HAS_GMC = 0x01, VB_HAS_AUDIO = 0x04, VB_HAS_VIDEO = 0x08, VB_HAS_PALETTE = 0x10, VB_HAS_LENGTH = 0x20 }; typedef struct VBDecContext { AVCodecContext *avctx; AVFrame pic; uint8_t *frame, *prev_frame; uint32_t pal[AVPALETTE_COUNT]; const uint8_t *stream; } VBDecContext; static const uint16_t vb_patterns[64] = { 0x0660, 0xFF00, 0xCCCC, 0xF000, 0x8888, 0x000F, 0x1111, 0xFEC8, 0x8CEF, 0x137F, 0xF731, 0xC800, 0x008C, 0x0013, 0x3100, 0xCC00, 0x00CC, 0x0033, 0x3300, 0x0FF0, 0x6666, 0x00F0, 0x0F00, 0x2222, 0x4444, 0xF600, 0x8CC8, 0x006F, 0x1331, 0x318C, 0xC813, 0x33CC, 0x6600, 0x0CC0, 0x0066, 0x0330, 0xF900, 0xC88C, 0x009F, 0x3113, 0x6000, 0x0880, 0x0006, 0x0110, 0xCC88, 0xFC00, 0x00CF, 0x88CC, 0x003F, 0x1133, 0x3311, 0xF300, 0x6FF6, 0x0603, 0x08C6, 0x8C63, 0xC631, 0x6310, 0xC060, 0x0136, 0x136C, 0x36C8, 0x6C80, 0x324C }; static void vb_decode_palette(VBDecContext *c, int data_size) { int start, size, i; start = bytestream_get_byte(&c->stream); size = (bytestream_get_byte(&c->stream) - 1) & 0xFF; if(start + size > 255){ av_log(c->avctx, AV_LOG_ERROR, "Palette change runs beyond entry 256\n"); return; } if(size*3+2 > data_size){ av_log(c->avctx, AV_LOG_ERROR, "Palette data runs beyond chunk size\n"); return; } for(i = start; i <= start + size; i++) c->pal[i] = bytestream_get_be24(&c->stream); } static inline int check_pixel(uint8_t *buf, uint8_t *start, uint8_t *end) { return buf >= start && buf < end; } static inline int check_line(uint8_t *buf, uint8_t *start, uint8_t *end) { return buf >= start && (buf + 4) <= end; } static int vb_decode_framedata(VBDecContext *c, const uint8_t *buf, int data_size, int offset) { uint8_t *prev, *cur; const uint8_t* data_end = buf + data_size; int blk, blocks, t, blk2; int blocktypes = 0; int x, y, a, b; int pattype, pattern; const int width = c->avctx->width; uint8_t *pstart = c->prev_frame; uint8_t *pend = c->prev_frame + width*c->avctx->height; prev = c->prev_frame + offset; cur = c->frame; blocks = (c->avctx->width >> 2) * (c->avctx->height >> 2); blk2 = 0; for(blk = 0; blk < blocks; blk++){ if(!(blk & 3)) { if(buf >= data_end){ av_log(c->avctx, AV_LOG_ERROR, "Data pointer out of bounds\n"); return -1; } blocktypes = bytestream_get_byte(&buf); } switch(blocktypes & 0xC0){ case 0x00: //skip for(y = 0; y < 4; y++) if(check_line(prev + y*width, pstart, pend)) memcpy(cur + y*width, prev + y*width, 4); else memset(cur + y*width, 0, 4); break; case 0x40: t = bytestream_get_byte(&buf); if(!t){ //raw block if(buf + 16 > data_end){ av_log(c->avctx, AV_LOG_ERROR, "Insufficient data\n"); return -1; } for(y = 0; y < 4; y++) memcpy(cur + y*width, buf + y*4, 4); buf += 16; }else{ // motion compensation x = ((t & 0xF)^8) - 8; y = ((t >> 4) ^8) - 8; t = x + y*width; for(y = 0; y < 4; y++) if(check_line(prev + t + y*width, pstart, pend)) memcpy(cur + y*width, prev + t + y*width, 4); else memset(cur + y*width, 0, 4); } break; case 0x80: // fill t = bytestream_get_byte(&buf); for(y = 0; y < 4; y++) memset(cur + y*width, t, 4); break; case 0xC0: // pattern fill if(buf + 2 > data_end){ av_log(c->avctx, AV_LOG_ERROR, "Insufficient data\n"); return -1; } t = bytestream_get_byte(&buf); pattype = t >> 6; pattern = vb_patterns[t & 0x3F]; switch(pattype){ case 0: a = bytestream_get_byte(&buf); b = bytestream_get_byte(&buf); for(y = 0; y < 4; y++) for(x = 0; x < 4; x++, pattern >>= 1) cur[x + y*width] = (pattern & 1) ? b : a; break; case 1: pattern = ~pattern; case 2: a = bytestream_get_byte(&buf); for(y = 0; y < 4; y++) for(x = 0; x < 4; x++, pattern >>= 1) if(pattern & 1 && check_pixel(prev + x + y*width, pstart, pend)) cur[x + y*width] = prev[x + y*width]; else cur[x + y*width] = a; break; case 3: av_log(c->avctx, AV_LOG_ERROR, "Invalid opcode seen @%d\n",blk); return -1; } break; } blocktypes <<= 2; cur += 4; prev += 4; blk2++; if(blk2 == (width >> 2)){ blk2 = 0; cur += width * 3; prev += width * 3; } } return 0; } static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; VBDecContext * const c = avctx->priv_data; uint8_t *outptr, *srcptr; int i, j; int flags; uint32_t size; int rest = buf_size; int offset = 0; if(c->pic.data[0]) avctx->release_buffer(avctx, &c->pic); c->pic.reference = 1; if(avctx->get_buffer(avctx, &c->pic) < 0){ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } c->stream = buf; flags = bytestream_get_le16(&c->stream); rest -= 2; if(flags & VB_HAS_GMC){ i = (int16_t)bytestream_get_le16(&c->stream); j = (int16_t)bytestream_get_le16(&c->stream); offset = i + j * avctx->width; rest -= 4; } if(flags & VB_HAS_VIDEO){ size = bytestream_get_le32(&c->stream); if(size > rest){ av_log(avctx, AV_LOG_ERROR, "Frame size is too big\n"); return -1; } vb_decode_framedata(c, c->stream, size, offset); c->stream += size - 4; rest -= size; } if(flags & VB_HAS_PALETTE){ size = bytestream_get_le32(&c->stream); if(size > rest){ av_log(avctx, AV_LOG_ERROR, "Palette size is too big\n"); return -1; } vb_decode_palette(c, size); rest -= size; } memcpy(c->pic.data[1], c->pal, AVPALETTE_SIZE); c->pic.palette_has_changed = flags & VB_HAS_PALETTE; outptr = c->pic.data[0]; srcptr = c->frame; for(i = 0; i < avctx->height; i++){ memcpy(outptr, srcptr, avctx->width); srcptr += avctx->width; outptr += c->pic.linesize[0]; } FFSWAP(uint8_t*, c->frame, c->prev_frame); *data_size = sizeof(AVFrame); *(AVFrame*)data = c->pic; /* always report that the buffer was completely consumed */ return buf_size; } static av_cold int decode_init(AVCodecContext *avctx) { VBDecContext * const c = avctx->priv_data; c->avctx = avctx; avctx->pix_fmt = PIX_FMT_PAL8; c->frame = av_mallocz(avctx->width * avctx->height); c->prev_frame = av_mallocz(avctx->width * avctx->height); return 0; } static av_cold int decode_end(AVCodecContext *avctx) { VBDecContext *c = avctx->priv_data; av_freep(&c->frame); av_freep(&c->prev_frame); if(c->pic.data[0]) avctx->release_buffer(avctx, &c->pic); return 0; } AVCodec vb_decoder = { "vb", AVMEDIA_TYPE_VIDEO, CODEC_ID_VB, sizeof(VBDecContext), decode_init, NULL, decode_end, decode_frame, .long_name = NULL_IF_CONFIG_SMALL("Beam Software VB"), };
123linslouis-android-video-cutter
jni/libavcodec/vb.c
C
asf20
9,048
/* * VC3/DNxHD decoder. * Copyright (c) 2007 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AVCODEC_DNXHDDATA_H #define AVCODEC_DNXHDDATA_H #include <stdint.h> #include "avcodec.h" typedef struct { int cid; unsigned int width, height; int interlaced; unsigned int frame_size; unsigned int coding_unit_size; int index_bits; int bit_depth; const uint8_t *luma_weight, *chroma_weight; const uint8_t *dc_codes, *dc_bits; const uint16_t *ac_codes; const uint8_t *ac_bits, *ac_level; const uint8_t *ac_run_flag, *ac_index_flag; const uint16_t *run_codes; const uint8_t *run_bits, *run; int bit_rates[5]; ///< Helpher to choose variants, rounded to nearest 5Mb/s } CIDEntry; extern const CIDEntry ff_dnxhd_cid_table[]; int ff_dnxhd_get_cid_table(int cid); int ff_dnxhd_find_cid(AVCodecContext *avctx); #endif /* AVCODEC_DNXHDDATA_H */
123linslouis-android-video-cutter
jni/libavcodec/dnxhddata.h
C
asf20
1,699
/* * The simplest mpeg encoder (well, it was the simplest!) * Copyright (c) 2000,2001 Fabrice Bellard * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * * 4MV & hq & B-frame encoding stuff by Michael Niedermayer <michaelni@gmx.at> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * The simplest mpeg encoder (well, it was the simplest!). */ #ifndef AVCODEC_MPEGVIDEO_COMMON_H #define AVCODEC_MPEGVIDEO_COMMON_H #include <string.h> #include "avcodec.h" #include "dsputil.h" #include "mpegvideo.h" #include "mjpegenc.h" #include "msmpeg4.h" #include "faandct.h" #include <limits.h> int dct_quantize_c(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow); int dct_quantize_trellis_c(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow); void denoise_dct_c(MpegEncContext *s, DCTELEM *block); /** * allocates a Picture * The pixels are allocated/set by calling get_buffer() if shared=0 */ int alloc_picture(MpegEncContext *s, Picture *pic, int shared); /** * sets the given MpegEncContext to common defaults (same for encoding and decoding). * the changed fields will not depend upon the prior state of the MpegEncContext. */ void MPV_common_defaults(MpegEncContext *s); static inline void gmc1_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, uint8_t **ref_picture) { uint8_t *ptr; int offset, src_x, src_y, linesize, uvlinesize; int motion_x, motion_y; int emu=0; motion_x= s->sprite_offset[0][0]; motion_y= s->sprite_offset[0][1]; src_x = s->mb_x * 16 + (motion_x >> (s->sprite_warping_accuracy+1)); src_y = s->mb_y * 16 + (motion_y >> (s->sprite_warping_accuracy+1)); motion_x<<=(3-s->sprite_warping_accuracy); motion_y<<=(3-s->sprite_warping_accuracy); src_x = av_clip(src_x, -16, s->width); if (src_x == s->width) motion_x =0; src_y = av_clip(src_y, -16, s->height); if (src_y == s->height) motion_y =0; linesize = s->linesize; uvlinesize = s->uvlinesize; ptr = ref_picture[0] + (src_y * linesize) + src_x; if(s->flags&CODEC_FLAG_EMU_EDGE){ if( (unsigned)src_x >= s->h_edge_pos - 17 || (unsigned)src_y >= s->v_edge_pos - 17){ ff_emulated_edge_mc(s->edge_emu_buffer, ptr, linesize, 17, 17, src_x, src_y, s->h_edge_pos, s->v_edge_pos); ptr= s->edge_emu_buffer; } } if((motion_x|motion_y)&7){ s->dsp.gmc1(dest_y , ptr , linesize, 16, motion_x&15, motion_y&15, 128 - s->no_rounding); s->dsp.gmc1(dest_y+8, ptr+8, linesize, 16, motion_x&15, motion_y&15, 128 - s->no_rounding); }else{ int dxy; dxy= ((motion_x>>3)&1) | ((motion_y>>2)&2); if (s->no_rounding){ s->dsp.put_no_rnd_pixels_tab[0][dxy](dest_y, ptr, linesize, 16); }else{ s->dsp.put_pixels_tab [0][dxy](dest_y, ptr, linesize, 16); } } if(CONFIG_GRAY && s->flags&CODEC_FLAG_GRAY) return; motion_x= s->sprite_offset[1][0]; motion_y= s->sprite_offset[1][1]; src_x = s->mb_x * 8 + (motion_x >> (s->sprite_warping_accuracy+1)); src_y = s->mb_y * 8 + (motion_y >> (s->sprite_warping_accuracy+1)); motion_x<<=(3-s->sprite_warping_accuracy); motion_y<<=(3-s->sprite_warping_accuracy); src_x = av_clip(src_x, -8, s->width>>1); if (src_x == s->width>>1) motion_x =0; src_y = av_clip(src_y, -8, s->height>>1); if (src_y == s->height>>1) motion_y =0; offset = (src_y * uvlinesize) + src_x; ptr = ref_picture[1] + offset; if(s->flags&CODEC_FLAG_EMU_EDGE){ if( (unsigned)src_x >= (s->h_edge_pos>>1) - 9 || (unsigned)src_y >= (s->v_edge_pos>>1) - 9){ ff_emulated_edge_mc(s->edge_emu_buffer, ptr, uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1); ptr= s->edge_emu_buffer; emu=1; } } s->dsp.gmc1(dest_cb, ptr, uvlinesize, 8, motion_x&15, motion_y&15, 128 - s->no_rounding); ptr = ref_picture[2] + offset; if(emu){ ff_emulated_edge_mc(s->edge_emu_buffer, ptr, uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1); ptr= s->edge_emu_buffer; } s->dsp.gmc1(dest_cr, ptr, uvlinesize, 8, motion_x&15, motion_y&15, 128 - s->no_rounding); return; } static inline void gmc_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, uint8_t **ref_picture) { uint8_t *ptr; int linesize, uvlinesize; const int a= s->sprite_warping_accuracy; int ox, oy; linesize = s->linesize; uvlinesize = s->uvlinesize; ptr = ref_picture[0]; ox= s->sprite_offset[0][0] + s->sprite_delta[0][0]*s->mb_x*16 + s->sprite_delta[0][1]*s->mb_y*16; oy= s->sprite_offset[0][1] + s->sprite_delta[1][0]*s->mb_x*16 + s->sprite_delta[1][1]*s->mb_y*16; s->dsp.gmc(dest_y, ptr, linesize, 16, ox, oy, s->sprite_delta[0][0], s->sprite_delta[0][1], s->sprite_delta[1][0], s->sprite_delta[1][1], a+1, (1<<(2*a+1)) - s->no_rounding, s->h_edge_pos, s->v_edge_pos); s->dsp.gmc(dest_y+8, ptr, linesize, 16, ox + s->sprite_delta[0][0]*8, oy + s->sprite_delta[1][0]*8, s->sprite_delta[0][0], s->sprite_delta[0][1], s->sprite_delta[1][0], s->sprite_delta[1][1], a+1, (1<<(2*a+1)) - s->no_rounding, s->h_edge_pos, s->v_edge_pos); if(CONFIG_GRAY && s->flags&CODEC_FLAG_GRAY) return; ox= s->sprite_offset[1][0] + s->sprite_delta[0][0]*s->mb_x*8 + s->sprite_delta[0][1]*s->mb_y*8; oy= s->sprite_offset[1][1] + s->sprite_delta[1][0]*s->mb_x*8 + s->sprite_delta[1][1]*s->mb_y*8; ptr = ref_picture[1]; s->dsp.gmc(dest_cb, ptr, uvlinesize, 8, ox, oy, s->sprite_delta[0][0], s->sprite_delta[0][1], s->sprite_delta[1][0], s->sprite_delta[1][1], a+1, (1<<(2*a+1)) - s->no_rounding, s->h_edge_pos>>1, s->v_edge_pos>>1); ptr = ref_picture[2]; s->dsp.gmc(dest_cr, ptr, uvlinesize, 8, ox, oy, s->sprite_delta[0][0], s->sprite_delta[0][1], s->sprite_delta[1][0], s->sprite_delta[1][1], a+1, (1<<(2*a+1)) - s->no_rounding, s->h_edge_pos>>1, s->v_edge_pos>>1); } static inline int hpel_motion(MpegEncContext *s, uint8_t *dest, uint8_t *src, int field_based, int field_select, int src_x, int src_y, int width, int height, int stride, int h_edge_pos, int v_edge_pos, int w, int h, op_pixels_func *pix_op, int motion_x, int motion_y) { int dxy; int emu=0; dxy = ((motion_y & 1) << 1) | (motion_x & 1); src_x += motion_x >> 1; src_y += motion_y >> 1; /* WARNING: do no forget half pels */ src_x = av_clip(src_x, -16, width); //FIXME unneeded for emu? if (src_x == width) dxy &= ~1; src_y = av_clip(src_y, -16, height); if (src_y == height) dxy &= ~2; src += src_y * stride + src_x; if(s->unrestricted_mv && (s->flags&CODEC_FLAG_EMU_EDGE)){ if( (unsigned)src_x > h_edge_pos - (motion_x&1) - w || (unsigned)src_y > v_edge_pos - (motion_y&1) - h){ ff_emulated_edge_mc(s->edge_emu_buffer, src, s->linesize, w+1, (h+1)<<field_based, src_x, src_y<<field_based, h_edge_pos, s->v_edge_pos); src= s->edge_emu_buffer; emu=1; } } if(field_select) src += s->linesize; pix_op[dxy](dest, src, stride, h); return emu; } static av_always_inline void mpeg_motion_internal(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int field_based, int bottom_field, int field_select, uint8_t **ref_picture, op_pixels_func (*pix_op)[4], int motion_x, int motion_y, int h, int is_mpeg12, int mb_y) { uint8_t *ptr_y, *ptr_cb, *ptr_cr; int dxy, uvdxy, mx, my, src_x, src_y, uvsrc_x, uvsrc_y, v_edge_pos, uvlinesize, linesize; #if 0 if(s->quarter_sample) { motion_x>>=1; motion_y>>=1; } #endif v_edge_pos = s->v_edge_pos >> field_based; linesize = s->current_picture.linesize[0] << field_based; uvlinesize = s->current_picture.linesize[1] << field_based; dxy = ((motion_y & 1) << 1) | (motion_x & 1); src_x = s->mb_x* 16 + (motion_x >> 1); src_y =( mb_y<<(4-field_based)) + (motion_y >> 1); if (!is_mpeg12 && s->out_format == FMT_H263) { if((s->workaround_bugs & FF_BUG_HPEL_CHROMA) && field_based){ mx = (motion_x>>1)|(motion_x&1); my = motion_y >>1; uvdxy = ((my & 1) << 1) | (mx & 1); uvsrc_x = s->mb_x* 8 + (mx >> 1); uvsrc_y =( mb_y<<(3-field_based))+ (my >> 1); }else{ uvdxy = dxy | (motion_y & 2) | ((motion_x & 2) >> 1); uvsrc_x = src_x>>1; uvsrc_y = src_y>>1; } }else if(!is_mpeg12 && s->out_format == FMT_H261){//even chroma mv's are full pel in H261 mx = motion_x / 4; my = motion_y / 4; uvdxy = 0; uvsrc_x = s->mb_x*8 + mx; uvsrc_y = mb_y*8 + my; } else { if(s->chroma_y_shift){ mx = motion_x / 2; my = motion_y / 2; uvdxy = ((my & 1) << 1) | (mx & 1); uvsrc_x = s->mb_x* 8 + (mx >> 1); uvsrc_y =( mb_y<<(3-field_based))+ (my >> 1); } else { if(s->chroma_x_shift){ //Chroma422 mx = motion_x / 2; uvdxy = ((motion_y & 1) << 1) | (mx & 1); uvsrc_x = s->mb_x* 8 + (mx >> 1); uvsrc_y = src_y; } else { //Chroma444 uvdxy = dxy; uvsrc_x = src_x; uvsrc_y = src_y; } } } ptr_y = ref_picture[0] + src_y * linesize + src_x; ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x; ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x; if( (unsigned)src_x > s->h_edge_pos - (motion_x&1) - 16 || (unsigned)src_y > v_edge_pos - (motion_y&1) - h){ if(is_mpeg12 || s->codec_id == CODEC_ID_MPEG2VIDEO || s->codec_id == CODEC_ID_MPEG1VIDEO){ av_log(s->avctx,AV_LOG_DEBUG, "MPEG motion vector out of boundary (%d %d)\n", src_x, src_y); return; } ff_emulated_edge_mc(s->edge_emu_buffer, ptr_y, s->linesize, 17, 17+field_based, src_x, src_y<<field_based, s->h_edge_pos, s->v_edge_pos); ptr_y = s->edge_emu_buffer; if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){ uint8_t *uvbuf= s->edge_emu_buffer+18*s->linesize; ff_emulated_edge_mc(uvbuf , ptr_cb, s->uvlinesize, 9, 9+field_based, uvsrc_x, uvsrc_y<<field_based, s->h_edge_pos>>1, s->v_edge_pos>>1); ff_emulated_edge_mc(uvbuf+16, ptr_cr, s->uvlinesize, 9, 9+field_based, uvsrc_x, uvsrc_y<<field_based, s->h_edge_pos>>1, s->v_edge_pos>>1); ptr_cb= uvbuf; ptr_cr= uvbuf+16; } } if(bottom_field){ //FIXME use this for field pix too instead of the obnoxious hack which changes picture.data dest_y += s->linesize; dest_cb+= s->uvlinesize; dest_cr+= s->uvlinesize; } if(field_select){ ptr_y += s->linesize; ptr_cb+= s->uvlinesize; ptr_cr+= s->uvlinesize; } pix_op[0][dxy](dest_y, ptr_y, linesize, h); if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){ pix_op[s->chroma_x_shift][uvdxy] (dest_cb, ptr_cb, uvlinesize, h >> s->chroma_y_shift); pix_op[s->chroma_x_shift][uvdxy] (dest_cr, ptr_cr, uvlinesize, h >> s->chroma_y_shift); } if(!is_mpeg12 && (CONFIG_H261_ENCODER || CONFIG_H261_DECODER) && s->out_format == FMT_H261){ ff_h261_loop_filter(s); } } /* apply one mpeg motion vector to the three components */ static av_always_inline void mpeg_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int field_based, int bottom_field, int field_select, uint8_t **ref_picture, op_pixels_func (*pix_op)[4], int motion_x, int motion_y, int h, int mb_y) { #if !CONFIG_SMALL if(s->out_format == FMT_MPEG1) mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, field_based, bottom_field, field_select, ref_picture, pix_op, motion_x, motion_y, h, 1, mb_y); else #endif mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, field_based, bottom_field, field_select, ref_picture, pix_op, motion_x, motion_y, h, 0, mb_y); } //FIXME move to dsputil, avg variant, 16x16 version static inline void put_obmc(uint8_t *dst, uint8_t *src[5], int stride){ int x; uint8_t * const top = src[1]; uint8_t * const left = src[2]; uint8_t * const mid = src[0]; uint8_t * const right = src[3]; uint8_t * const bottom= src[4]; #define OBMC_FILTER(x, t, l, m, r, b)\ dst[x]= (t*top[x] + l*left[x] + m*mid[x] + r*right[x] + b*bottom[x] + 4)>>3 #define OBMC_FILTER4(x, t, l, m, r, b)\ OBMC_FILTER(x , t, l, m, r, b);\ OBMC_FILTER(x+1 , t, l, m, r, b);\ OBMC_FILTER(x +stride, t, l, m, r, b);\ OBMC_FILTER(x+1+stride, t, l, m, r, b); x=0; OBMC_FILTER (x , 2, 2, 4, 0, 0); OBMC_FILTER (x+1, 2, 1, 5, 0, 0); OBMC_FILTER4(x+2, 2, 1, 5, 0, 0); OBMC_FILTER4(x+4, 2, 0, 5, 1, 0); OBMC_FILTER (x+6, 2, 0, 5, 1, 0); OBMC_FILTER (x+7, 2, 0, 4, 2, 0); x+= stride; OBMC_FILTER (x , 1, 2, 5, 0, 0); OBMC_FILTER (x+1, 1, 2, 5, 0, 0); OBMC_FILTER (x+6, 1, 0, 5, 2, 0); OBMC_FILTER (x+7, 1, 0, 5, 2, 0); x+= stride; OBMC_FILTER4(x , 1, 2, 5, 0, 0); OBMC_FILTER4(x+2, 1, 1, 6, 0, 0); OBMC_FILTER4(x+4, 1, 0, 6, 1, 0); OBMC_FILTER4(x+6, 1, 0, 5, 2, 0); x+= 2*stride; OBMC_FILTER4(x , 0, 2, 5, 0, 1); OBMC_FILTER4(x+2, 0, 1, 6, 0, 1); OBMC_FILTER4(x+4, 0, 0, 6, 1, 1); OBMC_FILTER4(x+6, 0, 0, 5, 2, 1); x+= 2*stride; OBMC_FILTER (x , 0, 2, 5, 0, 1); OBMC_FILTER (x+1, 0, 2, 5, 0, 1); OBMC_FILTER4(x+2, 0, 1, 5, 0, 2); OBMC_FILTER4(x+4, 0, 0, 5, 1, 2); OBMC_FILTER (x+6, 0, 0, 5, 2, 1); OBMC_FILTER (x+7, 0, 0, 5, 2, 1); x+= stride; OBMC_FILTER (x , 0, 2, 4, 0, 2); OBMC_FILTER (x+1, 0, 1, 5, 0, 2); OBMC_FILTER (x+6, 0, 0, 5, 1, 2); OBMC_FILTER (x+7, 0, 0, 4, 2, 2); } /* obmc for 1 8x8 luma block */ static inline void obmc_motion(MpegEncContext *s, uint8_t *dest, uint8_t *src, int src_x, int src_y, op_pixels_func *pix_op, int16_t mv[5][2]/* mid top left right bottom*/) #define MID 0 { int i; uint8_t *ptr[5]; assert(s->quarter_sample==0); for(i=0; i<5; i++){ if(i && mv[i][0]==mv[MID][0] && mv[i][1]==mv[MID][1]){ ptr[i]= ptr[MID]; }else{ ptr[i]= s->obmc_scratchpad + 8*(i&1) + s->linesize*8*(i>>1); hpel_motion(s, ptr[i], src, 0, 0, src_x, src_y, s->width, s->height, s->linesize, s->h_edge_pos, s->v_edge_pos, 8, 8, pix_op, mv[i][0], mv[i][1]); } } put_obmc(dest, ptr, s->linesize); } static inline void qpel_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int field_based, int bottom_field, int field_select, uint8_t **ref_picture, op_pixels_func (*pix_op)[4], qpel_mc_func (*qpix_op)[16], int motion_x, int motion_y, int h) { uint8_t *ptr_y, *ptr_cb, *ptr_cr; int dxy, uvdxy, mx, my, src_x, src_y, uvsrc_x, uvsrc_y, v_edge_pos, linesize, uvlinesize; dxy = ((motion_y & 3) << 2) | (motion_x & 3); src_x = s->mb_x * 16 + (motion_x >> 2); src_y = s->mb_y * (16 >> field_based) + (motion_y >> 2); v_edge_pos = s->v_edge_pos >> field_based; linesize = s->linesize << field_based; uvlinesize = s->uvlinesize << field_based; if(field_based){ mx= motion_x/2; my= motion_y>>1; }else if(s->workaround_bugs&FF_BUG_QPEL_CHROMA2){ static const int rtab[8]= {0,0,1,1,0,0,0,1}; mx= (motion_x>>1) + rtab[motion_x&7]; my= (motion_y>>1) + rtab[motion_y&7]; }else if(s->workaround_bugs&FF_BUG_QPEL_CHROMA){ mx= (motion_x>>1)|(motion_x&1); my= (motion_y>>1)|(motion_y&1); }else{ mx= motion_x/2; my= motion_y/2; } mx= (mx>>1)|(mx&1); my= (my>>1)|(my&1); uvdxy= (mx&1) | ((my&1)<<1); mx>>=1; my>>=1; uvsrc_x = s->mb_x * 8 + mx; uvsrc_y = s->mb_y * (8 >> field_based) + my; ptr_y = ref_picture[0] + src_y * linesize + src_x; ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x; ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x; if( (unsigned)src_x > s->h_edge_pos - (motion_x&3) - 16 || (unsigned)src_y > v_edge_pos - (motion_y&3) - h ){ ff_emulated_edge_mc(s->edge_emu_buffer, ptr_y, s->linesize, 17, 17+field_based, src_x, src_y<<field_based, s->h_edge_pos, s->v_edge_pos); ptr_y= s->edge_emu_buffer; if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){ uint8_t *uvbuf= s->edge_emu_buffer + 18*s->linesize; ff_emulated_edge_mc(uvbuf, ptr_cb, s->uvlinesize, 9, 9 + field_based, uvsrc_x, uvsrc_y<<field_based, s->h_edge_pos>>1, s->v_edge_pos>>1); ff_emulated_edge_mc(uvbuf + 16, ptr_cr, s->uvlinesize, 9, 9 + field_based, uvsrc_x, uvsrc_y<<field_based, s->h_edge_pos>>1, s->v_edge_pos>>1); ptr_cb= uvbuf; ptr_cr= uvbuf + 16; } } if(!field_based) qpix_op[0][dxy](dest_y, ptr_y, linesize); else{ if(bottom_field){ dest_y += s->linesize; dest_cb+= s->uvlinesize; dest_cr+= s->uvlinesize; } if(field_select){ ptr_y += s->linesize; ptr_cb += s->uvlinesize; ptr_cr += s->uvlinesize; } //damn interlaced mode //FIXME boundary mirroring is not exactly correct here qpix_op[1][dxy](dest_y , ptr_y , linesize); qpix_op[1][dxy](dest_y+8, ptr_y+8, linesize); } if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){ pix_op[1][uvdxy](dest_cr, ptr_cr, uvlinesize, h >> 1); pix_op[1][uvdxy](dest_cb, ptr_cb, uvlinesize, h >> 1); } } /** * h263 chroma 4mv motion compensation. */ static inline void chroma_4mv_motion(MpegEncContext *s, uint8_t *dest_cb, uint8_t *dest_cr, uint8_t **ref_picture, op_pixels_func *pix_op, int mx, int my){ int dxy, emu=0, src_x, src_y, offset; uint8_t *ptr; /* In case of 8X8, we construct a single chroma motion vector with a special rounding */ mx= ff_h263_round_chroma(mx); my= ff_h263_round_chroma(my); dxy = ((my & 1) << 1) | (mx & 1); mx >>= 1; my >>= 1; src_x = s->mb_x * 8 + mx; src_y = s->mb_y * 8 + my; src_x = av_clip(src_x, -8, s->width/2); if (src_x == s->width/2) dxy &= ~1; src_y = av_clip(src_y, -8, s->height/2); if (src_y == s->height/2) dxy &= ~2; offset = (src_y * (s->uvlinesize)) + src_x; ptr = ref_picture[1] + offset; if(s->flags&CODEC_FLAG_EMU_EDGE){ if( (unsigned)src_x > (s->h_edge_pos>>1) - (dxy &1) - 8 || (unsigned)src_y > (s->v_edge_pos>>1) - (dxy>>1) - 8){ ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1); ptr= s->edge_emu_buffer; emu=1; } } pix_op[dxy](dest_cb, ptr, s->uvlinesize, 8); ptr = ref_picture[2] + offset; if(emu){ ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1); ptr= s->edge_emu_buffer; } pix_op[dxy](dest_cr, ptr, s->uvlinesize, 8); } static inline void prefetch_motion(MpegEncContext *s, uint8_t **pix, int dir){ /* fetch pixels for estimated mv 4 macroblocks ahead * optimized for 64byte cache lines */ const int shift = s->quarter_sample ? 2 : 1; const int mx= (s->mv[dir][0][0]>>shift) + 16*s->mb_x + 8; const int my= (s->mv[dir][0][1]>>shift) + 16*s->mb_y; int off= mx + (my + (s->mb_x&3)*4)*s->linesize + 64; s->dsp.prefetch(pix[0]+off, s->linesize, 4); off= (mx>>1) + ((my>>1) + (s->mb_x&7))*s->uvlinesize + 64; s->dsp.prefetch(pix[1]+off, pix[2]-pix[1], 2); } /** * motion compensation of a single macroblock * @param s context * @param dest_y luma destination pointer * @param dest_cb chroma cb/u destination pointer * @param dest_cr chroma cr/v destination pointer * @param dir direction (0->forward, 1->backward) * @param ref_picture array[3] of pointers to the 3 planes of the reference picture * @param pic_op halfpel motion compensation function (average or put normally) * @param pic_op qpel motion compensation function (average or put normally) * the motion vectors are taken from s->mv and the MV type from s->mv_type */ static av_always_inline void MPV_motion_internal(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int dir, uint8_t **ref_picture, op_pixels_func (*pix_op)[4], qpel_mc_func (*qpix_op)[16], int is_mpeg12) { int dxy, mx, my, src_x, src_y, motion_x, motion_y; int mb_x, mb_y, i; uint8_t *ptr, *dest; mb_x = s->mb_x; mb_y = s->mb_y; prefetch_motion(s, ref_picture, dir); if(!is_mpeg12 && s->obmc && s->pict_type != FF_B_TYPE){ int16_t mv_cache[4][4][2]; const int xy= s->mb_x + s->mb_y*s->mb_stride; const int mot_stride= s->b8_stride; const int mot_xy= mb_x*2 + mb_y*2*mot_stride; assert(!s->mb_skipped); memcpy(mv_cache[1][1], s->current_picture.motion_val[0][mot_xy ], sizeof(int16_t)*4); memcpy(mv_cache[2][1], s->current_picture.motion_val[0][mot_xy+mot_stride], sizeof(int16_t)*4); memcpy(mv_cache[3][1], s->current_picture.motion_val[0][mot_xy+mot_stride], sizeof(int16_t)*4); if(mb_y==0 || IS_INTRA(s->current_picture.mb_type[xy-s->mb_stride])){ memcpy(mv_cache[0][1], mv_cache[1][1], sizeof(int16_t)*4); }else{ memcpy(mv_cache[0][1], s->current_picture.motion_val[0][mot_xy-mot_stride], sizeof(int16_t)*4); } if(mb_x==0 || IS_INTRA(s->current_picture.mb_type[xy-1])){ *(int32_t*)mv_cache[1][0]= *(int32_t*)mv_cache[1][1]; *(int32_t*)mv_cache[2][0]= *(int32_t*)mv_cache[2][1]; }else{ *(int32_t*)mv_cache[1][0]= *(int32_t*)s->current_picture.motion_val[0][mot_xy-1]; *(int32_t*)mv_cache[2][0]= *(int32_t*)s->current_picture.motion_val[0][mot_xy-1+mot_stride]; } if(mb_x+1>=s->mb_width || IS_INTRA(s->current_picture.mb_type[xy+1])){ *(int32_t*)mv_cache[1][3]= *(int32_t*)mv_cache[1][2]; *(int32_t*)mv_cache[2][3]= *(int32_t*)mv_cache[2][2]; }else{ *(int32_t*)mv_cache[1][3]= *(int32_t*)s->current_picture.motion_val[0][mot_xy+2]; *(int32_t*)mv_cache[2][3]= *(int32_t*)s->current_picture.motion_val[0][mot_xy+2+mot_stride]; } mx = 0; my = 0; for(i=0;i<4;i++) { const int x= (i&1)+1; const int y= (i>>1)+1; int16_t mv[5][2]= { {mv_cache[y][x ][0], mv_cache[y][x ][1]}, {mv_cache[y-1][x][0], mv_cache[y-1][x][1]}, {mv_cache[y][x-1][0], mv_cache[y][x-1][1]}, {mv_cache[y][x+1][0], mv_cache[y][x+1][1]}, {mv_cache[y+1][x][0], mv_cache[y+1][x][1]}}; //FIXME cleanup obmc_motion(s, dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize, ref_picture[0], mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >>1) * 8, pix_op[1], mv); mx += mv[0][0]; my += mv[0][1]; } if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)) chroma_4mv_motion(s, dest_cb, dest_cr, ref_picture, pix_op[1], mx, my); return; } switch(s->mv_type) { case MV_TYPE_16X16: if(s->mcsel){ if(s->real_sprite_warping_points==1){ gmc1_motion(s, dest_y, dest_cb, dest_cr, ref_picture); }else{ gmc_motion(s, dest_y, dest_cb, dest_cr, ref_picture); } }else if(!is_mpeg12 && s->quarter_sample){ qpel_motion(s, dest_y, dest_cb, dest_cr, 0, 0, 0, ref_picture, pix_op, qpix_op, s->mv[dir][0][0], s->mv[dir][0][1], 16); }else if(!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) && s->mspel){ ff_mspel_motion(s, dest_y, dest_cb, dest_cr, ref_picture, pix_op, s->mv[dir][0][0], s->mv[dir][0][1], 16); }else { mpeg_motion(s, dest_y, dest_cb, dest_cr, 0, 0, 0, ref_picture, pix_op, s->mv[dir][0][0], s->mv[dir][0][1], 16, mb_y); } break; case MV_TYPE_8X8: if (!is_mpeg12) { mx = 0; my = 0; if(s->quarter_sample){ for(i=0;i<4;i++) { motion_x = s->mv[dir][i][0]; motion_y = s->mv[dir][i][1]; dxy = ((motion_y & 3) << 2) | (motion_x & 3); src_x = mb_x * 16 + (motion_x >> 2) + (i & 1) * 8; src_y = mb_y * 16 + (motion_y >> 2) + (i >>1) * 8; /* WARNING: do no forget half pels */ src_x = av_clip(src_x, -16, s->width); if (src_x == s->width) dxy &= ~3; src_y = av_clip(src_y, -16, s->height); if (src_y == s->height) dxy &= ~12; ptr = ref_picture[0] + (src_y * s->linesize) + (src_x); if(s->flags&CODEC_FLAG_EMU_EDGE){ if( (unsigned)src_x > s->h_edge_pos - (motion_x&3) - 8 || (unsigned)src_y > s->v_edge_pos - (motion_y&3) - 8 ){ ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->linesize, 9, 9, src_x, src_y, s->h_edge_pos, s->v_edge_pos); ptr= s->edge_emu_buffer; } } dest = dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize; qpix_op[1][dxy](dest, ptr, s->linesize); mx += s->mv[dir][i][0]/2; my += s->mv[dir][i][1]/2; } }else{ for(i=0;i<4;i++) { hpel_motion(s, dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize, ref_picture[0], 0, 0, mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >>1) * 8, s->width, s->height, s->linesize, s->h_edge_pos, s->v_edge_pos, 8, 8, pix_op[1], s->mv[dir][i][0], s->mv[dir][i][1]); mx += s->mv[dir][i][0]; my += s->mv[dir][i][1]; } } if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)) chroma_4mv_motion(s, dest_cb, dest_cr, ref_picture, pix_op[1], mx, my); } break; case MV_TYPE_FIELD: if (s->picture_structure == PICT_FRAME) { if(!is_mpeg12 && s->quarter_sample){ for(i=0; i<2; i++){ qpel_motion(s, dest_y, dest_cb, dest_cr, 1, i, s->field_select[dir][i], ref_picture, pix_op, qpix_op, s->mv[dir][i][0], s->mv[dir][i][1], 8); } }else{ /* top field */ mpeg_motion(s, dest_y, dest_cb, dest_cr, 1, 0, s->field_select[dir][0], ref_picture, pix_op, s->mv[dir][0][0], s->mv[dir][0][1], 8, mb_y); /* bottom field */ mpeg_motion(s, dest_y, dest_cb, dest_cr, 1, 1, s->field_select[dir][1], ref_picture, pix_op, s->mv[dir][1][0], s->mv[dir][1][1], 8, mb_y); } } else { if(s->picture_structure != s->field_select[dir][0] + 1 && s->pict_type != FF_B_TYPE && !s->first_field){ ref_picture= s->current_picture_ptr->data; } mpeg_motion(s, dest_y, dest_cb, dest_cr, 0, 0, s->field_select[dir][0], ref_picture, pix_op, s->mv[dir][0][0], s->mv[dir][0][1], 16, mb_y>>1); } break; case MV_TYPE_16X8: for(i=0; i<2; i++){ uint8_t ** ref2picture; if(s->picture_structure == s->field_select[dir][i] + 1 || s->pict_type == FF_B_TYPE || s->first_field){ ref2picture= ref_picture; }else{ ref2picture= s->current_picture_ptr->data; } mpeg_motion(s, dest_y, dest_cb, dest_cr, 0, 0, s->field_select[dir][i], ref2picture, pix_op, s->mv[dir][i][0], s->mv[dir][i][1] + 16*i, 8, mb_y>>1); dest_y += 16*s->linesize; dest_cb+= (16>>s->chroma_y_shift)*s->uvlinesize; dest_cr+= (16>>s->chroma_y_shift)*s->uvlinesize; } break; case MV_TYPE_DMV: if(s->picture_structure == PICT_FRAME){ for(i=0; i<2; i++){ int j; for(j=0; j<2; j++){ mpeg_motion(s, dest_y, dest_cb, dest_cr, 1, j, j^i, ref_picture, pix_op, s->mv[dir][2*i + j][0], s->mv[dir][2*i + j][1], 8, mb_y); } pix_op = s->dsp.avg_pixels_tab; } }else{ for(i=0; i<2; i++){ mpeg_motion(s, dest_y, dest_cb, dest_cr, 0, 0, s->picture_structure != i+1, ref_picture, pix_op, s->mv[dir][2*i][0],s->mv[dir][2*i][1],16, mb_y>>1); // after put we make avg of the same block pix_op=s->dsp.avg_pixels_tab; //opposite parity is always in the same frame if this is second field if(!s->first_field){ ref_picture = s->current_picture_ptr->data; } } } break; default: assert(0); } } static inline void MPV_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int dir, uint8_t **ref_picture, op_pixels_func (*pix_op)[4], qpel_mc_func (*qpix_op)[16]) { #if !CONFIG_SMALL if(s->out_format == FMT_MPEG1) MPV_motion_internal(s, dest_y, dest_cb, dest_cr, dir, ref_picture, pix_op, qpix_op, 1); else #endif MPV_motion_internal(s, dest_y, dest_cb, dest_cr, dir, ref_picture, pix_op, qpix_op, 0); } #endif /* AVCODEC_MPEGVIDEO_COMMON_H */
123linslouis-android-video-cutter
jni/libavcodec/mpegvideo_common.h
C
asf20
34,548
/* * Autodesk RLE Decoder * Copyright (C) 2005 the ffmpeg project * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * Autodesk RLE Video Decoder by Konstantin Shishkov */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "avcodec.h" #include "dsputil.h" #include "msrledec.h" typedef struct AascContext { AVCodecContext *avctx; AVFrame frame; } AascContext; #define FETCH_NEXT_STREAM_BYTE() \ if (stream_ptr >= buf_size) \ { \ av_log(s->avctx, AV_LOG_ERROR, " AASC: stream ptr just went out of bounds (fetch)\n"); \ break; \ } \ stream_byte = buf[stream_ptr++]; static av_cold int aasc_decode_init(AVCodecContext *avctx) { AascContext *s = avctx->priv_data; s->avctx = avctx; avctx->pix_fmt = PIX_FMT_BGR24; return 0; } static int aasc_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; AascContext *s = avctx->priv_data; int compr, i, stride; s->frame.reference = 1; s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; if (avctx->reget_buffer(avctx, &s->frame)) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return -1; } compr = AV_RL32(buf); buf += 4; buf_size -= 4; switch(compr){ case 0: stride = (avctx->width * 3 + 3) & ~3; for(i = avctx->height - 1; i >= 0; i--){ memcpy(s->frame.data[0] + i*s->frame.linesize[0], buf, avctx->width*3); buf += stride; } break; case 1: ff_msrle_decode(avctx, (AVPicture*)&s->frame, 8, buf - 4, buf_size + 4); break; default: av_log(avctx, AV_LOG_ERROR, "Unknown compression type %d\n", compr); return -1; } *data_size = sizeof(AVFrame); *(AVFrame*)data = s->frame; /* report that the buffer was completely consumed */ return buf_size; } static av_cold int aasc_decode_end(AVCodecContext *avctx) { AascContext *s = avctx->priv_data; /* release the last frame */ if (s->frame.data[0]) avctx->release_buffer(avctx, &s->frame); return 0; } AVCodec aasc_decoder = { "aasc", AVMEDIA_TYPE_VIDEO, CODEC_ID_AASC, sizeof(AascContext), aasc_decode_init, NULL, aasc_decode_end, aasc_decode_frame, CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Autodesk RLE"), };
123linslouis-android-video-cutter
jni/libavcodec/aasc.c
C
asf20
3,274
/* * Bytestream functions * copyright (c) 2006 Baptiste Coudurier <baptiste.coudurier@free.fr> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AVCODEC_BYTESTREAM_H #define AVCODEC_BYTESTREAM_H #include <string.h> #include "libavutil/common.h" #include "libavutil/intreadwrite.h" #define DEF_T(type, name, bytes, read, write) \ static av_always_inline type bytestream_get_ ## name(const uint8_t **b){\ (*b) += bytes;\ return read(*b - bytes);\ }\ static av_always_inline void bytestream_put_ ##name(uint8_t **b, const type value){\ write(*b, value);\ (*b) += bytes;\ } #define DEF(name, bytes, read, write) \ DEF_T(unsigned int, name, bytes, read, write) #define DEF64(name, bytes, read, write) \ DEF_T(uint64_t, name, bytes, read, write) DEF64(le64, 8, AV_RL64, AV_WL64) DEF (le32, 4, AV_RL32, AV_WL32) DEF (le24, 3, AV_RL24, AV_WL24) DEF (le16, 2, AV_RL16, AV_WL16) DEF64(be64, 8, AV_RB64, AV_WB64) DEF (be32, 4, AV_RB32, AV_WB32) DEF (be24, 3, AV_RB24, AV_WB24) DEF (be16, 2, AV_RB16, AV_WB16) DEF (byte, 1, AV_RB8 , AV_WB8 ) #undef DEF #undef DEF64 #undef DEF_T static av_always_inline unsigned int bytestream_get_buffer(const uint8_t **b, uint8_t *dst, unsigned int size) { memcpy(dst, *b, size); (*b) += size; return size; } static av_always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size) { memcpy(*b, src, size); (*b) += size; } #endif /* AVCODEC_BYTESTREAM_H */
123linslouis-android-video-cutter
jni/libavcodec/bytestream.h
C
asf20
2,221
/* * H263 internal header * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AVCODEC_H263_H #define AVCODEC_H263_H #include <stdint.h> #include "libavutil/rational.h" #include "get_bits.h" #include "mpegvideo.h" #include "rl.h" // The defines below define the number of bits that are read at once for // reading vlc values. Changing these may improve speed and data cache needs // be aware though that decreasing them may need the number of stages that is // passed to get_vlc* to be increased. #define INTRA_MCBPC_VLC_BITS 6 #define INTER_MCBPC_VLC_BITS 7 #define CBPY_VLC_BITS 6 #define TEX_VLC_BITS 9 extern const AVRational ff_h263_pixel_aspect[16]; extern const uint8_t ff_h263_cbpy_tab[16][2]; extern const uint8_t cbpc_b_tab[4][2]; extern const uint8_t mvtab[33][2]; extern const uint8_t ff_h263_intra_MCBPC_code[9]; extern const uint8_t ff_h263_intra_MCBPC_bits[9]; extern const uint8_t ff_h263_inter_MCBPC_code[28]; extern const uint8_t ff_h263_inter_MCBPC_bits[28]; extern const uint8_t h263_mbtype_b_tab[15][2]; extern VLC ff_h263_intra_MCBPC_vlc; extern VLC ff_h263_inter_MCBPC_vlc; extern VLC ff_h263_cbpy_vlc; extern RLTable ff_h263_rl_inter; extern RLTable rl_intra_aic; extern const uint16_t h263_format[8][2]; extern const uint8_t modified_quant_tab[2][32]; extern uint16_t ff_mba_max[6]; extern uint8_t ff_mba_length[7]; extern uint8_t ff_h263_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3]; int h263_decode_motion(MpegEncContext * s, int pred, int f_code); av_const int ff_h263_aspect_to_info(AVRational aspect); int ff_h263_decode_init(AVCodecContext *avctx); int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt); int ff_h263_decode_end(AVCodecContext *avctx); void h263_encode_mb(MpegEncContext *s, DCTELEM block[6][64], int motion_x, int motion_y); void h263_encode_picture_header(MpegEncContext *s, int picture_number); void h263_encode_gob_header(MpegEncContext * s, int mb_line); int16_t *h263_pred_motion(MpegEncContext * s, int block, int dir, int *px, int *py); void h263_encode_init(MpegEncContext *s); void h263_decode_init_vlc(MpegEncContext *s); int h263_decode_picture_header(MpegEncContext *s); int ff_h263_decode_gob_header(MpegEncContext *s); void ff_h263_update_motion_val(MpegEncContext * s); void ff_h263_loop_filter(MpegEncContext * s); int ff_h263_decode_mba(MpegEncContext *s); void ff_h263_encode_mba(MpegEncContext *s); void ff_init_qscale_tab(MpegEncContext *s); int h263_pred_dc(MpegEncContext * s, int n, int16_t **dc_val_ptr); void h263_pred_acdc(MpegEncContext * s, DCTELEM *block, int n); /** * Prints picture info if FF_DEBUG_PICT_INFO is set. */ void ff_h263_show_pict_info(MpegEncContext *s); int ff_intel_h263_decode_picture_header(MpegEncContext *s); int ff_h263_decode_mb(MpegEncContext *s, DCTELEM block[6][64]); /** * Returns the value of the 3bit "source format" syntax element. * that represents some standard picture dimensions or indicates that * width&height are explicitly stored later. */ int av_const h263_get_picture_format(int width, int height); void ff_clean_h263_qscales(MpegEncContext *s); int ff_h263_resync(MpegEncContext *s); const uint8_t *ff_h263_find_resync_marker(const uint8_t *p, const uint8_t *end); int ff_h263_get_gob_height(MpegEncContext *s); void ff_h263_encode_motion(MpegEncContext * s, int val, int f_code); static inline int h263_get_motion_length(MpegEncContext * s, int val, int f_code){ int l, bit_size, code; if (val == 0) { return mvtab[0][1]; } else { bit_size = f_code - 1; /* modulo encoding */ l= INT_BIT - 6 - bit_size; val = (val<<l)>>l; val--; code = (val >> bit_size) + 1; return mvtab[code][1] + 1 + bit_size; } } static inline void ff_h263_encode_motion_vector(MpegEncContext * s, int x, int y, int f_code){ if(s->flags2 & CODEC_FLAG2_NO_OUTPUT){ skip_put_bits(&s->pb, h263_get_motion_length(s, x, f_code) +h263_get_motion_length(s, y, f_code)); }else{ ff_h263_encode_motion(s, x, f_code); ff_h263_encode_motion(s, y, f_code); } } static inline int get_p_cbp(MpegEncContext * s, DCTELEM block[6][64], int motion_x, int motion_y){ int cbp, i; if(s->flags & CODEC_FLAG_CBP_RD){ int best_cbpy_score= INT_MAX; int best_cbpc_score= INT_MAX; int cbpc = (-1), cbpy= (-1); const int offset= (s->mv_type==MV_TYPE_16X16 ? 0 : 16) + (s->dquant ? 8 : 0); const int lambda= s->lambda2 >> (FF_LAMBDA_SHIFT - 6); for(i=0; i<4; i++){ int score= ff_h263_inter_MCBPC_bits[i + offset] * lambda; if(i&1) score += s->coded_score[5]; if(i&2) score += s->coded_score[4]; if(score < best_cbpc_score){ best_cbpc_score= score; cbpc= i; } } for(i=0; i<16; i++){ int score= ff_h263_cbpy_tab[i ^ 0xF][1] * lambda; if(i&1) score += s->coded_score[3]; if(i&2) score += s->coded_score[2]; if(i&4) score += s->coded_score[1]; if(i&8) score += s->coded_score[0]; if(score < best_cbpy_score){ best_cbpy_score= score; cbpy= i; } } cbp= cbpc + 4*cbpy; if ((motion_x | motion_y | s->dquant) == 0 && s->mv_type==MV_TYPE_16X16){ if(best_cbpy_score + best_cbpc_score + 2*lambda >= 0) cbp= 0; } for (i = 0; i < 6; i++) { if (s->block_last_index[i] >= 0 && ((cbp >> (5 - i))&1)==0 ){ s->block_last_index[i]= -1; s->dsp.clear_block(s->block[i]); } } }else{ cbp= 0; for (i = 0; i < 6; i++) { if (s->block_last_index[i] >= 0) cbp |= 1 << (5 - i); } } return cbp; } static inline int get_b_cbp(MpegEncContext * s, DCTELEM block[6][64], int motion_x, int motion_y, int mb_type){ int cbp=0, i; if(s->flags & CODEC_FLAG_CBP_RD){ int score=0; const int lambda= s->lambda2 >> (FF_LAMBDA_SHIFT - 6); for(i=0; i<6; i++){ if(s->coded_score[i] < 0){ score += s->coded_score[i]; cbp |= 1 << (5 - i); } } if(cbp){ int zero_score= -6; if ((motion_x | motion_y | s->dquant | mb_type) == 0){ zero_score-= 4; //2*MV + mb_type + cbp bit } zero_score*= lambda; if(zero_score <= score){ cbp=0; } } for (i = 0; i < 6; i++) { if (s->block_last_index[i] >= 0 && ((cbp >> (5 - i))&1)==0 ){ s->block_last_index[i]= -1; s->dsp.clear_block(s->block[i]); } } }else{ for (i = 0; i < 6; i++) { if (s->block_last_index[i] >= 0) cbp |= 1 << (5 - i); } } return cbp; } static inline void memsetw(short *tab, int val, int n) { int i; for(i=0;i<n;i++) tab[i] = val; } #endif
123linslouis-android-video-cutter
jni/libavcodec/h263.h
C
asf20
8,105
/* * huffyuv codec for libavcodec * * Copyright (c) 2002-2003 Michael Niedermayer <michaelni@gmx.at> * * see http://www.pcisys.net/~melanson/codecs/huffyuv.txt for a description of * the algorithm used * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * huffyuv codec for libavcodec. */ #include "avcodec.h" #include "get_bits.h" #include "put_bits.h" #include "dsputil.h" #define VLC_BITS 11 #if HAVE_BIGENDIAN #define B 3 #define G 2 #define R 1 #define A 0 #else #define B 0 #define G 1 #define R 2 #define A 3 #endif typedef enum Predictor{ LEFT= 0, PLANE, MEDIAN, } Predictor; typedef struct HYuvContext{ AVCodecContext *avctx; Predictor predictor; GetBitContext gb; PutBitContext pb; int interlaced; int decorrelate; int bitstream_bpp; int version; int yuy2; //use yuy2 instead of 422P int bgr32; //use bgr32 instead of bgr24 int width, height; int flags; int context; int picture_number; int last_slice_end; uint8_t *temp[3]; uint64_t stats[3][256]; uint8_t len[3][256]; uint32_t bits[3][256]; uint32_t pix_bgr_map[1<<VLC_BITS]; VLC vlc[6]; //Y,U,V,YY,YU,YV AVFrame picture; uint8_t *bitstream_buffer; unsigned int bitstream_buffer_size; DSPContext dsp; }HYuvContext; static const unsigned char classic_shift_luma[] = { 34,36,35,69,135,232,9,16,10,24,11,23,12,16,13,10,14,8,15,8, 16,8,17,20,16,10,207,206,205,236,11,8,10,21,9,23,8,8,199,70, 69,68, 0 }; static const unsigned char classic_shift_chroma[] = { 66,36,37,38,39,40,41,75,76,77,110,239,144,81,82,83,84,85,118,183, 56,57,88,89,56,89,154,57,58,57,26,141,57,56,58,57,58,57,184,119, 214,245,116,83,82,49,80,79,78,77,44,75,41,40,39,38,37,36,34, 0 }; static const unsigned char classic_add_luma[256] = { 3, 9, 5, 12, 10, 35, 32, 29, 27, 50, 48, 45, 44, 41, 39, 37, 73, 70, 68, 65, 64, 61, 58, 56, 53, 50, 49, 46, 44, 41, 38, 36, 68, 65, 63, 61, 58, 55, 53, 51, 48, 46, 45, 43, 41, 39, 38, 36, 35, 33, 32, 30, 29, 27, 26, 25, 48, 47, 46, 44, 43, 41, 40, 39, 37, 36, 35, 34, 32, 31, 30, 28, 27, 26, 24, 23, 22, 20, 19, 37, 35, 34, 33, 31, 30, 29, 27, 26, 24, 23, 21, 20, 18, 17, 15, 29, 27, 26, 24, 22, 21, 19, 17, 16, 14, 26, 25, 23, 21, 19, 18, 16, 15, 27, 25, 23, 21, 19, 17, 16, 14, 26, 25, 23, 21, 18, 17, 14, 12, 17, 19, 13, 4, 9, 2, 11, 1, 7, 8, 0, 16, 3, 14, 6, 12, 10, 5, 15, 18, 11, 10, 13, 15, 16, 19, 20, 22, 24, 27, 15, 18, 20, 22, 24, 26, 14, 17, 20, 22, 24, 27, 15, 18, 20, 23, 25, 28, 16, 19, 22, 25, 28, 32, 36, 21, 25, 29, 33, 38, 42, 45, 49, 28, 31, 34, 37, 40, 42, 44, 47, 49, 50, 52, 54, 56, 57, 59, 60, 62, 64, 66, 67, 69, 35, 37, 39, 40, 42, 43, 45, 47, 48, 51, 52, 54, 55, 57, 59, 60, 62, 63, 66, 67, 69, 71, 72, 38, 40, 42, 43, 46, 47, 49, 51, 26, 28, 30, 31, 33, 34, 18, 19, 11, 13, 7, 8, }; static const unsigned char classic_add_chroma[256] = { 3, 1, 2, 2, 2, 2, 3, 3, 7, 5, 7, 5, 8, 6, 11, 9, 7, 13, 11, 10, 9, 8, 7, 5, 9, 7, 6, 4, 7, 5, 8, 7, 11, 8, 13, 11, 19, 15, 22, 23, 20, 33, 32, 28, 27, 29, 51, 77, 43, 45, 76, 81, 46, 82, 75, 55, 56,144, 58, 80, 60, 74,147, 63, 143, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 27, 30, 21, 22, 17, 14, 5, 6,100, 54, 47, 50, 51, 53,106,107,108,109,110,111, 112,113,114,115, 4,117,118, 92, 94,121,122, 3,124,103, 2, 1, 0,129,130,131,120,119,126,125,136,137,138,139,140,141,142,134, 135,132,133,104, 64,101, 62, 57,102, 95, 93, 59, 61, 28, 97, 96, 52, 49, 48, 29, 32, 25, 24, 46, 23, 98, 45, 44, 43, 20, 42, 41, 19, 18, 99, 40, 15, 39, 38, 16, 13, 12, 11, 37, 10, 9, 8, 36, 7,128,127,105,123,116, 35, 34, 33,145, 31, 79, 42,146, 78, 26, 83, 48, 49, 50, 44, 47, 26, 31, 30, 18, 17, 19, 21, 24, 25, 13, 14, 16, 17, 18, 20, 21, 12, 14, 15, 9, 10, 6, 9, 6, 5, 8, 6, 12, 8, 10, 7, 9, 6, 4, 6, 2, 2, 3, 3, 3, 3, 2, }; static inline int sub_left_prediction(HYuvContext *s, uint8_t *dst, uint8_t *src, int w, int left){ int i; if(w<32){ for(i=0; i<w; i++){ const int temp= src[i]; dst[i]= temp - left; left= temp; } return left; }else{ for(i=0; i<16; i++){ const int temp= src[i]; dst[i]= temp - left; left= temp; } s->dsp.diff_bytes(dst+16, src+16, src+15, w-16); return src[w-1]; } } static inline void sub_left_prediction_bgr32(HYuvContext *s, uint8_t *dst, uint8_t *src, int w, int *red, int *green, int *blue){ int i; int r,g,b; r= *red; g= *green; b= *blue; for(i=0; i<FFMIN(w,4); i++){ const int rt= src[i*4+R]; const int gt= src[i*4+G]; const int bt= src[i*4+B]; dst[i*4+R]= rt - r; dst[i*4+G]= gt - g; dst[i*4+B]= bt - b; r = rt; g = gt; b = bt; } s->dsp.diff_bytes(dst+16, src+16, src+12, w*4-16); *red= src[(w-1)*4+R]; *green= src[(w-1)*4+G]; *blue= src[(w-1)*4+B]; } static int read_len_table(uint8_t *dst, GetBitContext *gb){ int i, val, repeat; for(i=0; i<256;){ repeat= get_bits(gb, 3); val = get_bits(gb, 5); if(repeat==0) repeat= get_bits(gb, 8); //printf("%d %d\n", val, repeat); if(i+repeat > 256) { av_log(NULL, AV_LOG_ERROR, "Error reading huffman table\n"); return -1; } while (repeat--) dst[i++] = val; } return 0; } static int generate_bits_table(uint32_t *dst, const uint8_t *len_table){ int len, index; uint32_t bits=0; for(len=32; len>0; len--){ for(index=0; index<256; index++){ if(len_table[index]==len) dst[index]= bits++; } if(bits & 1){ av_log(NULL, AV_LOG_ERROR, "Error generating huffman table\n"); return -1; } bits >>= 1; } return 0; } #if CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER typedef struct { uint64_t val; int name; } HeapElem; static void heap_sift(HeapElem *h, int root, int size) { while(root*2+1 < size) { int child = root*2+1; if(child < size-1 && h[child].val > h[child+1].val) child++; if(h[root].val > h[child].val) { FFSWAP(HeapElem, h[root], h[child]); root = child; } else break; } } static void generate_len_table(uint8_t *dst, const uint64_t *stats, int size){ HeapElem h[size]; int up[2*size]; int len[2*size]; int offset, i, next; for(offset=1; ; offset<<=1){ for(i=0; i<size; i++){ h[i].name = i; h[i].val = (stats[i] << 8) + offset; } for(i=size/2-1; i>=0; i--) heap_sift(h, i, size); for(next=size; next<size*2-1; next++){ // merge the two smallest entries, and put it back in the heap uint64_t min1v = h[0].val; up[h[0].name] = next; h[0].val = INT64_MAX; heap_sift(h, 0, size); up[h[0].name] = next; h[0].name = next; h[0].val += min1v; heap_sift(h, 0, size); } len[2*size-2] = 0; for(i=2*size-3; i>=size; i--) len[i] = len[up[i]] + 1; for(i=0; i<size; i++) { dst[i] = len[up[i]] + 1; if(dst[i] >= 32) break; } if(i==size) break; } } #endif /* CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER */ static void generate_joint_tables(HYuvContext *s){ uint16_t symbols[1<<VLC_BITS]; uint16_t bits[1<<VLC_BITS]; uint8_t len[1<<VLC_BITS]; if(s->bitstream_bpp < 24){ int p, i, y, u; for(p=0; p<3; p++){ for(i=y=0; y<256; y++){ int len0 = s->len[0][y]; int limit = VLC_BITS - len0; if(limit <= 0) continue; for(u=0; u<256; u++){ int len1 = s->len[p][u]; if(len1 > limit) continue; len[i] = len0 + len1; bits[i] = (s->bits[0][y] << len1) + s->bits[p][u]; symbols[i] = (y<<8) + u; if(symbols[i] != 0xffff) // reserved to mean "invalid" i++; } } free_vlc(&s->vlc[3+p]); init_vlc_sparse(&s->vlc[3+p], VLC_BITS, i, len, 1, 1, bits, 2, 2, symbols, 2, 2, 0); } }else{ uint8_t (*map)[4] = (uint8_t(*)[4])s->pix_bgr_map; int i, b, g, r, code; int p0 = s->decorrelate; int p1 = !s->decorrelate; // restrict the range to +/-16 becaues that's pretty much guaranteed to // cover all the combinations that fit in 11 bits total, and it doesn't // matter if we miss a few rare codes. for(i=0, g=-16; g<16; g++){ int len0 = s->len[p0][g&255]; int limit0 = VLC_BITS - len0; if(limit0 < 2) continue; for(b=-16; b<16; b++){ int len1 = s->len[p1][b&255]; int limit1 = limit0 - len1; if(limit1 < 1) continue; code = (s->bits[p0][g&255] << len1) + s->bits[p1][b&255]; for(r=-16; r<16; r++){ int len2 = s->len[2][r&255]; if(len2 > limit1) continue; len[i] = len0 + len1 + len2; bits[i] = (code << len2) + s->bits[2][r&255]; if(s->decorrelate){ map[i][G] = g; map[i][B] = g+b; map[i][R] = g+r; }else{ map[i][B] = g; map[i][G] = b; map[i][R] = r; } i++; } } } free_vlc(&s->vlc[3]); init_vlc(&s->vlc[3], VLC_BITS, i, len, 1, 1, bits, 2, 2, 0); } } static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length){ GetBitContext gb; int i; init_get_bits(&gb, src, length*8); for(i=0; i<3; i++){ if(read_len_table(s->len[i], &gb)<0) return -1; if(generate_bits_table(s->bits[i], s->len[i])<0){ return -1; } #if 0 for(j=0; j<256; j++){ printf("%6X, %2d, %3d\n", s->bits[i][j], s->len[i][j], j); } #endif free_vlc(&s->vlc[i]); init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0); } generate_joint_tables(s); return (get_bits_count(&gb)+7)/8; } static int read_old_huffman_tables(HYuvContext *s){ #if 1 GetBitContext gb; int i; init_get_bits(&gb, classic_shift_luma, sizeof(classic_shift_luma)*8); if(read_len_table(s->len[0], &gb)<0) return -1; init_get_bits(&gb, classic_shift_chroma, sizeof(classic_shift_chroma)*8); if(read_len_table(s->len[1], &gb)<0) return -1; for(i=0; i<256; i++) s->bits[0][i] = classic_add_luma [i]; for(i=0; i<256; i++) s->bits[1][i] = classic_add_chroma[i]; if(s->bitstream_bpp >= 24){ memcpy(s->bits[1], s->bits[0], 256*sizeof(uint32_t)); memcpy(s->len[1] , s->len [0], 256*sizeof(uint8_t)); } memcpy(s->bits[2], s->bits[1], 256*sizeof(uint32_t)); memcpy(s->len[2] , s->len [1], 256*sizeof(uint8_t)); for(i=0; i<3; i++){ free_vlc(&s->vlc[i]); init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0); } generate_joint_tables(s); return 0; #else av_log(s->avctx, AV_LOG_DEBUG, "v1 huffyuv is not supported \n"); return -1; #endif } static av_cold void alloc_temp(HYuvContext *s){ int i; if(s->bitstream_bpp<24){ for(i=0; i<3; i++){ s->temp[i]= av_malloc(s->width + 16); } }else{ s->temp[0]= av_mallocz(4*s->width + 16); } } static av_cold int common_init(AVCodecContext *avctx){ HYuvContext *s = avctx->priv_data; s->avctx= avctx; s->flags= avctx->flags; dsputil_init(&s->dsp, avctx); s->width= avctx->width; s->height= avctx->height; assert(s->width>0 && s->height>0); return 0; } #if CONFIG_HUFFYUV_DECODER || CONFIG_FFVHUFF_DECODER static av_cold int decode_init(AVCodecContext *avctx) { HYuvContext *s = avctx->priv_data; common_init(avctx); memset(s->vlc, 0, 3*sizeof(VLC)); avctx->coded_frame= &s->picture; s->interlaced= s->height > 288; s->bgr32=1; //if(avctx->extradata) // printf("extradata:%X, extradata_size:%d\n", *(uint32_t*)avctx->extradata, avctx->extradata_size); if(avctx->extradata_size){ if((avctx->bits_per_coded_sample&7) && avctx->bits_per_coded_sample != 12) s->version=1; // do such files exist at all? else s->version=2; }else s->version=0; if(s->version==2){ int method, interlace; if (avctx->extradata_size < 4) return -1; method= ((uint8_t*)avctx->extradata)[0]; s->decorrelate= method&64 ? 1 : 0; s->predictor= method&63; s->bitstream_bpp= ((uint8_t*)avctx->extradata)[1]; if(s->bitstream_bpp==0) s->bitstream_bpp= avctx->bits_per_coded_sample&~7; interlace= (((uint8_t*)avctx->extradata)[2] & 0x30) >> 4; s->interlaced= (interlace==1) ? 1 : (interlace==2) ? 0 : s->interlaced; s->context= ((uint8_t*)avctx->extradata)[2] & 0x40 ? 1 : 0; if(read_huffman_tables(s, ((uint8_t*)avctx->extradata)+4, avctx->extradata_size-4) < 0) return -1; }else{ switch(avctx->bits_per_coded_sample&7){ case 1: s->predictor= LEFT; s->decorrelate= 0; break; case 2: s->predictor= LEFT; s->decorrelate= 1; break; case 3: s->predictor= PLANE; s->decorrelate= avctx->bits_per_coded_sample >= 24; break; case 4: s->predictor= MEDIAN; s->decorrelate= 0; break; default: s->predictor= LEFT; //OLD s->decorrelate= 0; break; } s->bitstream_bpp= avctx->bits_per_coded_sample & ~7; s->context= 0; if(read_old_huffman_tables(s) < 0) return -1; } switch(s->bitstream_bpp){ case 12: avctx->pix_fmt = PIX_FMT_YUV420P; break; case 16: if(s->yuy2){ avctx->pix_fmt = PIX_FMT_YUYV422; }else{ avctx->pix_fmt = PIX_FMT_YUV422P; } break; case 24: case 32: if(s->bgr32){ avctx->pix_fmt = PIX_FMT_RGB32; }else{ avctx->pix_fmt = PIX_FMT_BGR24; } break; default: assert(0); } alloc_temp(s); // av_log(NULL, AV_LOG_DEBUG, "pred:%d bpp:%d hbpp:%d il:%d\n", s->predictor, s->bitstream_bpp, avctx->bits_per_coded_sample, s->interlaced); return 0; } #endif /* CONFIG_HUFFYUV_DECODER || CONFIG_FFVHUFF_DECODER */ #if CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER static int store_table(HYuvContext *s, const uint8_t *len, uint8_t *buf){ int i; int index= 0; for(i=0; i<256;){ int val= len[i]; int repeat=0; for(; i<256 && len[i]==val && repeat<255; i++) repeat++; assert(val < 32 && val >0 && repeat<256 && repeat>0); if(repeat>7){ buf[index++]= val; buf[index++]= repeat; }else{ buf[index++]= val | (repeat<<5); } } return index; } static av_cold int encode_init(AVCodecContext *avctx) { HYuvContext *s = avctx->priv_data; int i, j; common_init(avctx); avctx->extradata= av_mallocz(1024*30); // 256*3+4 == 772 avctx->stats_out= av_mallocz(1024*30); // 21*256*3(%llu ) + 3(\n) + 1(0) = 16132 s->version=2; avctx->coded_frame= &s->picture; switch(avctx->pix_fmt){ case PIX_FMT_YUV420P: s->bitstream_bpp= 12; break; case PIX_FMT_YUV422P: s->bitstream_bpp= 16; break; case PIX_FMT_RGB32: s->bitstream_bpp= 24; break; default: av_log(avctx, AV_LOG_ERROR, "format not supported\n"); return -1; } avctx->bits_per_coded_sample= s->bitstream_bpp; s->decorrelate= s->bitstream_bpp >= 24; s->predictor= avctx->prediction_method; s->interlaced= avctx->flags&CODEC_FLAG_INTERLACED_ME ? 1 : 0; if(avctx->context_model==1){ s->context= avctx->context_model; if(s->flags & (CODEC_FLAG_PASS1|CODEC_FLAG_PASS2)){ av_log(avctx, AV_LOG_ERROR, "context=1 is not compatible with 2 pass huffyuv encoding\n"); return -1; } }else s->context= 0; if(avctx->codec->id==CODEC_ID_HUFFYUV){ if(avctx->pix_fmt==PIX_FMT_YUV420P){ av_log(avctx, AV_LOG_ERROR, "Error: YV12 is not supported by huffyuv; use vcodec=ffvhuff or format=422p\n"); return -1; } if(avctx->context_model){ av_log(avctx, AV_LOG_ERROR, "Error: per-frame huffman tables are not supported by huffyuv; use vcodec=ffvhuff\n"); return -1; } if(s->interlaced != ( s->height > 288 )) av_log(avctx, AV_LOG_INFO, "using huffyuv 2.2.0 or newer interlacing flag\n"); } if(s->bitstream_bpp>=24 && s->predictor==MEDIAN){ av_log(avctx, AV_LOG_ERROR, "Error: RGB is incompatible with median predictor\n"); return -1; } ((uint8_t*)avctx->extradata)[0]= s->predictor | (s->decorrelate << 6); ((uint8_t*)avctx->extradata)[1]= s->bitstream_bpp; ((uint8_t*)avctx->extradata)[2]= s->interlaced ? 0x10 : 0x20; if(s->context) ((uint8_t*)avctx->extradata)[2]|= 0x40; ((uint8_t*)avctx->extradata)[3]= 0; s->avctx->extradata_size= 4; if(avctx->stats_in){ char *p= avctx->stats_in; for(i=0; i<3; i++) for(j=0; j<256; j++) s->stats[i][j]= 1; for(;;){ for(i=0; i<3; i++){ char *next; for(j=0; j<256; j++){ s->stats[i][j]+= strtol(p, &next, 0); if(next==p) return -1; p=next; } } if(p[0]==0 || p[1]==0 || p[2]==0) break; } }else{ for(i=0; i<3; i++) for(j=0; j<256; j++){ int d= FFMIN(j, 256-j); s->stats[i][j]= 100000000/(d+1); } } for(i=0; i<3; i++){ generate_len_table(s->len[i], s->stats[i], 256); if(generate_bits_table(s->bits[i], s->len[i])<0){ return -1; } s->avctx->extradata_size+= store_table(s, s->len[i], &((uint8_t*)s->avctx->extradata)[s->avctx->extradata_size]); } if(s->context){ for(i=0; i<3; i++){ int pels = s->width*s->height / (i?40:10); for(j=0; j<256; j++){ int d= FFMIN(j, 256-j); s->stats[i][j]= pels/(d+1); } } }else{ for(i=0; i<3; i++) for(j=0; j<256; j++) s->stats[i][j]= 0; } // printf("pred:%d bpp:%d hbpp:%d il:%d\n", s->predictor, s->bitstream_bpp, avctx->bits_per_coded_sample, s->interlaced); alloc_temp(s); s->picture_number=0; return 0; } #endif /* CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER */ /* TODO instead of restarting the read when the code isn't in the first level * of the joint table, jump into the 2nd level of the individual table. */ #define READ_2PIX(dst0, dst1, plane1){\ uint16_t code = get_vlc2(&s->gb, s->vlc[3+plane1].table, VLC_BITS, 1);\ if(code != 0xffff){\ dst0 = code>>8;\ dst1 = code;\ }else{\ dst0 = get_vlc2(&s->gb, s->vlc[0].table, VLC_BITS, 3);\ dst1 = get_vlc2(&s->gb, s->vlc[plane1].table, VLC_BITS, 3);\ }\ } static void decode_422_bitstream(HYuvContext *s, int count){ int i; count/=2; if(count >= (get_bits_left(&s->gb))/(31*4)){ for(i=0; i<count && get_bits_count(&s->gb) < s->gb.size_in_bits; i++){ READ_2PIX(s->temp[0][2*i ], s->temp[1][i], 1); READ_2PIX(s->temp[0][2*i+1], s->temp[2][i], 2); } }else{ for(i=0; i<count; i++){ READ_2PIX(s->temp[0][2*i ], s->temp[1][i], 1); READ_2PIX(s->temp[0][2*i+1], s->temp[2][i], 2); } } } static void decode_gray_bitstream(HYuvContext *s, int count){ int i; count/=2; if(count >= (get_bits_left(&s->gb))/(31*2)){ for(i=0; i<count && get_bits_count(&s->gb) < s->gb.size_in_bits; i++){ READ_2PIX(s->temp[0][2*i ], s->temp[0][2*i+1], 0); } }else{ for(i=0; i<count; i++){ READ_2PIX(s->temp[0][2*i ], s->temp[0][2*i+1], 0); } } } #if CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER static int encode_422_bitstream(HYuvContext *s, int offset, int count){ int i; const uint8_t *y = s->temp[0] + offset; const uint8_t *u = s->temp[1] + offset/2; const uint8_t *v = s->temp[2] + offset/2; if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < 2*4*count){ av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n"); return -1; } #define LOAD4\ int y0 = y[2*i];\ int y1 = y[2*i+1];\ int u0 = u[i];\ int v0 = v[i]; count/=2; if(s->flags&CODEC_FLAG_PASS1){ for(i=0; i<count; i++){ LOAD4; s->stats[0][y0]++; s->stats[1][u0]++; s->stats[0][y1]++; s->stats[2][v0]++; } } if(s->avctx->flags2&CODEC_FLAG2_NO_OUTPUT) return 0; if(s->context){ for(i=0; i<count; i++){ LOAD4; s->stats[0][y0]++; put_bits(&s->pb, s->len[0][y0], s->bits[0][y0]); s->stats[1][u0]++; put_bits(&s->pb, s->len[1][u0], s->bits[1][u0]); s->stats[0][y1]++; put_bits(&s->pb, s->len[0][y1], s->bits[0][y1]); s->stats[2][v0]++; put_bits(&s->pb, s->len[2][v0], s->bits[2][v0]); } }else{ for(i=0; i<count; i++){ LOAD4; put_bits(&s->pb, s->len[0][y0], s->bits[0][y0]); put_bits(&s->pb, s->len[1][u0], s->bits[1][u0]); put_bits(&s->pb, s->len[0][y1], s->bits[0][y1]); put_bits(&s->pb, s->len[2][v0], s->bits[2][v0]); } } return 0; } static int encode_gray_bitstream(HYuvContext *s, int count){ int i; if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < 4*count){ av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n"); return -1; } #define LOAD2\ int y0 = s->temp[0][2*i];\ int y1 = s->temp[0][2*i+1]; #define STAT2\ s->stats[0][y0]++;\ s->stats[0][y1]++; #define WRITE2\ put_bits(&s->pb, s->len[0][y0], s->bits[0][y0]);\ put_bits(&s->pb, s->len[0][y1], s->bits[0][y1]); count/=2; if(s->flags&CODEC_FLAG_PASS1){ for(i=0; i<count; i++){ LOAD2; STAT2; } } if(s->avctx->flags2&CODEC_FLAG2_NO_OUTPUT) return 0; if(s->context){ for(i=0; i<count; i++){ LOAD2; STAT2; WRITE2; } }else{ for(i=0; i<count; i++){ LOAD2; WRITE2; } } return 0; } #endif /* CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER */ static av_always_inline void decode_bgr_1(HYuvContext *s, int count, int decorrelate, int alpha){ int i; for(i=0; i<count; i++){ int code = get_vlc2(&s->gb, s->vlc[3].table, VLC_BITS, 1); if(code != -1){ *(uint32_t*)&s->temp[0][4*i] = s->pix_bgr_map[code]; }else if(decorrelate){ s->temp[0][4*i+G] = get_vlc2(&s->gb, s->vlc[1].table, VLC_BITS, 3); s->temp[0][4*i+B] = get_vlc2(&s->gb, s->vlc[0].table, VLC_BITS, 3) + s->temp[0][4*i+G]; s->temp[0][4*i+R] = get_vlc2(&s->gb, s->vlc[2].table, VLC_BITS, 3) + s->temp[0][4*i+G]; }else{ s->temp[0][4*i+B] = get_vlc2(&s->gb, s->vlc[0].table, VLC_BITS, 3); s->temp[0][4*i+G] = get_vlc2(&s->gb, s->vlc[1].table, VLC_BITS, 3); s->temp[0][4*i+R] = get_vlc2(&s->gb, s->vlc[2].table, VLC_BITS, 3); } if(alpha) s->temp[0][4*i+A] = get_vlc2(&s->gb, s->vlc[2].table, VLC_BITS, 3); } } static void decode_bgr_bitstream(HYuvContext *s, int count){ if(s->decorrelate){ if(s->bitstream_bpp==24) decode_bgr_1(s, count, 1, 0); else decode_bgr_1(s, count, 1, 1); }else{ if(s->bitstream_bpp==24) decode_bgr_1(s, count, 0, 0); else decode_bgr_1(s, count, 0, 1); } } static int encode_bgr_bitstream(HYuvContext *s, int count){ int i; if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < 3*4*count){ av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n"); return -1; } #define LOAD3\ int g= s->temp[0][4*i+G];\ int b= (s->temp[0][4*i+B] - g) & 0xff;\ int r= (s->temp[0][4*i+R] - g) & 0xff; #define STAT3\ s->stats[0][b]++;\ s->stats[1][g]++;\ s->stats[2][r]++; #define WRITE3\ put_bits(&s->pb, s->len[1][g], s->bits[1][g]);\ put_bits(&s->pb, s->len[0][b], s->bits[0][b]);\ put_bits(&s->pb, s->len[2][r], s->bits[2][r]); if((s->flags&CODEC_FLAG_PASS1) && (s->avctx->flags2&CODEC_FLAG2_NO_OUTPUT)){ for(i=0; i<count; i++){ LOAD3; STAT3; } }else if(s->context || (s->flags&CODEC_FLAG_PASS1)){ for(i=0; i<count; i++){ LOAD3; STAT3; WRITE3; } }else{ for(i=0; i<count; i++){ LOAD3; WRITE3; } } return 0; } #if CONFIG_HUFFYUV_DECODER || CONFIG_FFVHUFF_DECODER static void draw_slice(HYuvContext *s, int y){ int h, cy; int offset[4]; if(s->avctx->draw_horiz_band==NULL) return; h= y - s->last_slice_end; y -= h; if(s->bitstream_bpp==12){ cy= y>>1; }else{ cy= y; } offset[0] = s->picture.linesize[0]*y; offset[1] = s->picture.linesize[1]*cy; offset[2] = s->picture.linesize[2]*cy; offset[3] = 0; emms_c(); s->avctx->draw_horiz_band(s->avctx, &s->picture, offset, y, 3, h); s->last_slice_end= y + h; } static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt){ const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; HYuvContext *s = avctx->priv_data; const int width= s->width; const int width2= s->width>>1; const int height= s->height; int fake_ystride, fake_ustride, fake_vstride; AVFrame * const p= &s->picture; int table_size= 0; AVFrame *picture = data; av_fast_malloc(&s->bitstream_buffer, &s->bitstream_buffer_size, buf_size + FF_INPUT_BUFFER_PADDING_SIZE); if (!s->bitstream_buffer) return AVERROR(ENOMEM); memset(s->bitstream_buffer + buf_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); s->dsp.bswap_buf((uint32_t*)s->bitstream_buffer, (const uint32_t*)buf, buf_size/4); if(p->data[0]) avctx->release_buffer(avctx, p); p->reference= 0; if(avctx->get_buffer(avctx, p) < 0){ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } if(s->context){ table_size = read_huffman_tables(s, s->bitstream_buffer, buf_size); if(table_size < 0) return -1; } if((unsigned)(buf_size-table_size) >= INT_MAX/8) return -1; init_get_bits(&s->gb, s->bitstream_buffer+table_size, (buf_size-table_size)*8); fake_ystride= s->interlaced ? p->linesize[0]*2 : p->linesize[0]; fake_ustride= s->interlaced ? p->linesize[1]*2 : p->linesize[1]; fake_vstride= s->interlaced ? p->linesize[2]*2 : p->linesize[2]; s->last_slice_end= 0; if(s->bitstream_bpp<24){ int y, cy; int lefty, leftu, leftv; int lefttopy, lefttopu, lefttopv; if(s->yuy2){ p->data[0][3]= get_bits(&s->gb, 8); p->data[0][2]= get_bits(&s->gb, 8); p->data[0][1]= get_bits(&s->gb, 8); p->data[0][0]= get_bits(&s->gb, 8); av_log(avctx, AV_LOG_ERROR, "YUY2 output is not implemented yet\n"); return -1; }else{ leftv= p->data[2][0]= get_bits(&s->gb, 8); lefty= p->data[0][1]= get_bits(&s->gb, 8); leftu= p->data[1][0]= get_bits(&s->gb, 8); p->data[0][0]= get_bits(&s->gb, 8); switch(s->predictor){ case LEFT: case PLANE: decode_422_bitstream(s, width-2); lefty= s->dsp.add_hfyu_left_prediction(p->data[0] + 2, s->temp[0], width-2, lefty); if(!(s->flags&CODEC_FLAG_GRAY)){ leftu= s->dsp.add_hfyu_left_prediction(p->data[1] + 1, s->temp[1], width2-1, leftu); leftv= s->dsp.add_hfyu_left_prediction(p->data[2] + 1, s->temp[2], width2-1, leftv); } for(cy=y=1; y<s->height; y++,cy++){ uint8_t *ydst, *udst, *vdst; if(s->bitstream_bpp==12){ decode_gray_bitstream(s, width); ydst= p->data[0] + p->linesize[0]*y; lefty= s->dsp.add_hfyu_left_prediction(ydst, s->temp[0], width, lefty); if(s->predictor == PLANE){ if(y>s->interlaced) s->dsp.add_bytes(ydst, ydst - fake_ystride, width); } y++; if(y>=s->height) break; } draw_slice(s, y); ydst= p->data[0] + p->linesize[0]*y; udst= p->data[1] + p->linesize[1]*cy; vdst= p->data[2] + p->linesize[2]*cy; decode_422_bitstream(s, width); lefty= s->dsp.add_hfyu_left_prediction(ydst, s->temp[0], width, lefty); if(!(s->flags&CODEC_FLAG_GRAY)){ leftu= s->dsp.add_hfyu_left_prediction(udst, s->temp[1], width2, leftu); leftv= s->dsp.add_hfyu_left_prediction(vdst, s->temp[2], width2, leftv); } if(s->predictor == PLANE){ if(cy>s->interlaced){ s->dsp.add_bytes(ydst, ydst - fake_ystride, width); if(!(s->flags&CODEC_FLAG_GRAY)){ s->dsp.add_bytes(udst, udst - fake_ustride, width2); s->dsp.add_bytes(vdst, vdst - fake_vstride, width2); } } } } draw_slice(s, height); break; case MEDIAN: /* first line except first 2 pixels is left predicted */ decode_422_bitstream(s, width-2); lefty= s->dsp.add_hfyu_left_prediction(p->data[0] + 2, s->temp[0], width-2, lefty); if(!(s->flags&CODEC_FLAG_GRAY)){ leftu= s->dsp.add_hfyu_left_prediction(p->data[1] + 1, s->temp[1], width2-1, leftu); leftv= s->dsp.add_hfyu_left_prediction(p->data[2] + 1, s->temp[2], width2-1, leftv); } cy=y=1; /* second line is left predicted for interlaced case */ if(s->interlaced){ decode_422_bitstream(s, width); lefty= s->dsp.add_hfyu_left_prediction(p->data[0] + p->linesize[0], s->temp[0], width, lefty); if(!(s->flags&CODEC_FLAG_GRAY)){ leftu= s->dsp.add_hfyu_left_prediction(p->data[1] + p->linesize[2], s->temp[1], width2, leftu); leftv= s->dsp.add_hfyu_left_prediction(p->data[2] + p->linesize[1], s->temp[2], width2, leftv); } y++; cy++; } /* next 4 pixels are left predicted too */ decode_422_bitstream(s, 4); lefty= s->dsp.add_hfyu_left_prediction(p->data[0] + fake_ystride, s->temp[0], 4, lefty); if(!(s->flags&CODEC_FLAG_GRAY)){ leftu= s->dsp.add_hfyu_left_prediction(p->data[1] + fake_ustride, s->temp[1], 2, leftu); leftv= s->dsp.add_hfyu_left_prediction(p->data[2] + fake_vstride, s->temp[2], 2, leftv); } /* next line except the first 4 pixels is median predicted */ lefttopy= p->data[0][3]; decode_422_bitstream(s, width-4); s->dsp.add_hfyu_median_prediction(p->data[0] + fake_ystride+4, p->data[0]+4, s->temp[0], width-4, &lefty, &lefttopy); if(!(s->flags&CODEC_FLAG_GRAY)){ lefttopu= p->data[1][1]; lefttopv= p->data[2][1]; s->dsp.add_hfyu_median_prediction(p->data[1] + fake_ustride+2, p->data[1]+2, s->temp[1], width2-2, &leftu, &lefttopu); s->dsp.add_hfyu_median_prediction(p->data[2] + fake_vstride+2, p->data[2]+2, s->temp[2], width2-2, &leftv, &lefttopv); } y++; cy++; for(; y<height; y++,cy++){ uint8_t *ydst, *udst, *vdst; if(s->bitstream_bpp==12){ while(2*cy > y){ decode_gray_bitstream(s, width); ydst= p->data[0] + p->linesize[0]*y; s->dsp.add_hfyu_median_prediction(ydst, ydst - fake_ystride, s->temp[0], width, &lefty, &lefttopy); y++; } if(y>=height) break; } draw_slice(s, y); decode_422_bitstream(s, width); ydst= p->data[0] + p->linesize[0]*y; udst= p->data[1] + p->linesize[1]*cy; vdst= p->data[2] + p->linesize[2]*cy; s->dsp.add_hfyu_median_prediction(ydst, ydst - fake_ystride, s->temp[0], width, &lefty, &lefttopy); if(!(s->flags&CODEC_FLAG_GRAY)){ s->dsp.add_hfyu_median_prediction(udst, udst - fake_ustride, s->temp[1], width2, &leftu, &lefttopu); s->dsp.add_hfyu_median_prediction(vdst, vdst - fake_vstride, s->temp[2], width2, &leftv, &lefttopv); } } draw_slice(s, height); break; } } }else{ int y; int leftr, leftg, leftb, lefta; const int last_line= (height-1)*p->linesize[0]; if(s->bitstream_bpp==32){ lefta= p->data[0][last_line+A]= get_bits(&s->gb, 8); leftr= p->data[0][last_line+R]= get_bits(&s->gb, 8); leftg= p->data[0][last_line+G]= get_bits(&s->gb, 8); leftb= p->data[0][last_line+B]= get_bits(&s->gb, 8); }else{ leftr= p->data[0][last_line+R]= get_bits(&s->gb, 8); leftg= p->data[0][last_line+G]= get_bits(&s->gb, 8); leftb= p->data[0][last_line+B]= get_bits(&s->gb, 8); lefta= p->data[0][last_line+A]= 255; skip_bits(&s->gb, 8); } if(s->bgr32){ switch(s->predictor){ case LEFT: case PLANE: decode_bgr_bitstream(s, width-1); s->dsp.add_hfyu_left_prediction_bgr32(p->data[0] + last_line+4, s->temp[0], width-1, &leftr, &leftg, &leftb, &lefta); for(y=s->height-2; y>=0; y--){ //Yes it is stored upside down. decode_bgr_bitstream(s, width); s->dsp.add_hfyu_left_prediction_bgr32(p->data[0] + p->linesize[0]*y, s->temp[0], width, &leftr, &leftg, &leftb, &lefta); if(s->predictor == PLANE){ if(s->bitstream_bpp!=32) lefta=0; if((y&s->interlaced)==0 && y<s->height-1-s->interlaced){ s->dsp.add_bytes(p->data[0] + p->linesize[0]*y, p->data[0] + p->linesize[0]*y + fake_ystride, fake_ystride); } } } draw_slice(s, height); // just 1 large slice as this is not possible in reverse order break; default: av_log(avctx, AV_LOG_ERROR, "prediction type not supported!\n"); } }else{ av_log(avctx, AV_LOG_ERROR, "BGR24 output is not implemented yet\n"); return -1; } } emms_c(); *picture= *p; *data_size = sizeof(AVFrame); return (get_bits_count(&s->gb)+31)/32*4 + table_size; } #endif /* CONFIG_HUFFYUV_DECODER || CONFIG_FFVHUFF_DECODER */ static int common_end(HYuvContext *s){ int i; for(i=0; i<3; i++){ av_freep(&s->temp[i]); } return 0; } #if CONFIG_HUFFYUV_DECODER || CONFIG_FFVHUFF_DECODER static av_cold int decode_end(AVCodecContext *avctx) { HYuvContext *s = avctx->priv_data; int i; if (s->picture.data[0]) avctx->release_buffer(avctx, &s->picture); common_end(s); av_freep(&s->bitstream_buffer); for(i=0; i<6; i++){ free_vlc(&s->vlc[i]); } return 0; } #endif /* CONFIG_HUFFYUV_DECODER || CONFIG_FFVHUFF_DECODER */ #if CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ HYuvContext *s = avctx->priv_data; AVFrame *pict = data; const int width= s->width; const int width2= s->width>>1; const int height= s->height; const int fake_ystride= s->interlaced ? pict->linesize[0]*2 : pict->linesize[0]; const int fake_ustride= s->interlaced ? pict->linesize[1]*2 : pict->linesize[1]; const int fake_vstride= s->interlaced ? pict->linesize[2]*2 : pict->linesize[2]; AVFrame * const p= &s->picture; int i, j, size=0; *p = *pict; p->pict_type= FF_I_TYPE; p->key_frame= 1; if(s->context){ for(i=0; i<3; i++){ generate_len_table(s->len[i], s->stats[i], 256); if(generate_bits_table(s->bits[i], s->len[i])<0) return -1; size+= store_table(s, s->len[i], &buf[size]); } for(i=0; i<3; i++) for(j=0; j<256; j++) s->stats[i][j] >>= 1; } init_put_bits(&s->pb, buf+size, buf_size-size); if(avctx->pix_fmt == PIX_FMT_YUV422P || avctx->pix_fmt == PIX_FMT_YUV420P){ int lefty, leftu, leftv, y, cy; put_bits(&s->pb, 8, leftv= p->data[2][0]); put_bits(&s->pb, 8, lefty= p->data[0][1]); put_bits(&s->pb, 8, leftu= p->data[1][0]); put_bits(&s->pb, 8, p->data[0][0]); lefty= sub_left_prediction(s, s->temp[0], p->data[0], width , 0); leftu= sub_left_prediction(s, s->temp[1], p->data[1], width2, 0); leftv= sub_left_prediction(s, s->temp[2], p->data[2], width2, 0); encode_422_bitstream(s, 2, width-2); if(s->predictor==MEDIAN){ int lefttopy, lefttopu, lefttopv; cy=y=1; if(s->interlaced){ lefty= sub_left_prediction(s, s->temp[0], p->data[0]+p->linesize[0], width , lefty); leftu= sub_left_prediction(s, s->temp[1], p->data[1]+p->linesize[1], width2, leftu); leftv= sub_left_prediction(s, s->temp[2], p->data[2]+p->linesize[2], width2, leftv); encode_422_bitstream(s, 0, width); y++; cy++; } lefty= sub_left_prediction(s, s->temp[0], p->data[0]+fake_ystride, 4, lefty); leftu= sub_left_prediction(s, s->temp[1], p->data[1]+fake_ustride, 2, leftu); leftv= sub_left_prediction(s, s->temp[2], p->data[2]+fake_vstride, 2, leftv); encode_422_bitstream(s, 0, 4); lefttopy= p->data[0][3]; lefttopu= p->data[1][1]; lefttopv= p->data[2][1]; s->dsp.sub_hfyu_median_prediction(s->temp[0], p->data[0]+4, p->data[0] + fake_ystride+4, width-4 , &lefty, &lefttopy); s->dsp.sub_hfyu_median_prediction(s->temp[1], p->data[1]+2, p->data[1] + fake_ustride+2, width2-2, &leftu, &lefttopu); s->dsp.sub_hfyu_median_prediction(s->temp[2], p->data[2]+2, p->data[2] + fake_vstride+2, width2-2, &leftv, &lefttopv); encode_422_bitstream(s, 0, width-4); y++; cy++; for(; y<height; y++,cy++){ uint8_t *ydst, *udst, *vdst; if(s->bitstream_bpp==12){ while(2*cy > y){ ydst= p->data[0] + p->linesize[0]*y; s->dsp.sub_hfyu_median_prediction(s->temp[0], ydst - fake_ystride, ydst, width , &lefty, &lefttopy); encode_gray_bitstream(s, width); y++; } if(y>=height) break; } ydst= p->data[0] + p->linesize[0]*y; udst= p->data[1] + p->linesize[1]*cy; vdst= p->data[2] + p->linesize[2]*cy; s->dsp.sub_hfyu_median_prediction(s->temp[0], ydst - fake_ystride, ydst, width , &lefty, &lefttopy); s->dsp.sub_hfyu_median_prediction(s->temp[1], udst - fake_ustride, udst, width2, &leftu, &lefttopu); s->dsp.sub_hfyu_median_prediction(s->temp[2], vdst - fake_vstride, vdst, width2, &leftv, &lefttopv); encode_422_bitstream(s, 0, width); } }else{ for(cy=y=1; y<height; y++,cy++){ uint8_t *ydst, *udst, *vdst; /* encode a luma only line & y++ */ if(s->bitstream_bpp==12){ ydst= p->data[0] + p->linesize[0]*y; if(s->predictor == PLANE && s->interlaced < y){ s->dsp.diff_bytes(s->temp[1], ydst, ydst - fake_ystride, width); lefty= sub_left_prediction(s, s->temp[0], s->temp[1], width , lefty); }else{ lefty= sub_left_prediction(s, s->temp[0], ydst, width , lefty); } encode_gray_bitstream(s, width); y++; if(y>=height) break; } ydst= p->data[0] + p->linesize[0]*y; udst= p->data[1] + p->linesize[1]*cy; vdst= p->data[2] + p->linesize[2]*cy; if(s->predictor == PLANE && s->interlaced < cy){ s->dsp.diff_bytes(s->temp[1], ydst, ydst - fake_ystride, width); s->dsp.diff_bytes(s->temp[2], udst, udst - fake_ustride, width2); s->dsp.diff_bytes(s->temp[2] + width2, vdst, vdst - fake_vstride, width2); lefty= sub_left_prediction(s, s->temp[0], s->temp[1], width , lefty); leftu= sub_left_prediction(s, s->temp[1], s->temp[2], width2, leftu); leftv= sub_left_prediction(s, s->temp[2], s->temp[2] + width2, width2, leftv); }else{ lefty= sub_left_prediction(s, s->temp[0], ydst, width , lefty); leftu= sub_left_prediction(s, s->temp[1], udst, width2, leftu); leftv= sub_left_prediction(s, s->temp[2], vdst, width2, leftv); } encode_422_bitstream(s, 0, width); } } }else if(avctx->pix_fmt == PIX_FMT_RGB32){ uint8_t *data = p->data[0] + (height-1)*p->linesize[0]; const int stride = -p->linesize[0]; const int fake_stride = -fake_ystride; int y; int leftr, leftg, leftb; put_bits(&s->pb, 8, leftr= data[R]); put_bits(&s->pb, 8, leftg= data[G]); put_bits(&s->pb, 8, leftb= data[B]); put_bits(&s->pb, 8, 0); sub_left_prediction_bgr32(s, s->temp[0], data+4, width-1, &leftr, &leftg, &leftb); encode_bgr_bitstream(s, width-1); for(y=1; y<s->height; y++){ uint8_t *dst = data + y*stride; if(s->predictor == PLANE && s->interlaced < y){ s->dsp.diff_bytes(s->temp[1], dst, dst - fake_stride, width*4); sub_left_prediction_bgr32(s, s->temp[0], s->temp[1], width, &leftr, &leftg, &leftb); }else{ sub_left_prediction_bgr32(s, s->temp[0], dst, width, &leftr, &leftg, &leftb); } encode_bgr_bitstream(s, width); } }else{ av_log(avctx, AV_LOG_ERROR, "Format not supported!\n"); } emms_c(); size+= (put_bits_count(&s->pb)+31)/8; put_bits(&s->pb, 16, 0); put_bits(&s->pb, 15, 0); size/= 4; if((s->flags&CODEC_FLAG_PASS1) && (s->picture_number&31)==0){ int j; char *p= avctx->stats_out; char *end= p + 1024*30; for(i=0; i<3; i++){ for(j=0; j<256; j++){ snprintf(p, end-p, "%"PRIu64" ", s->stats[i][j]); p+= strlen(p); s->stats[i][j]= 0; } snprintf(p, end-p, "\n"); p++; } } else avctx->stats_out[0] = '\0'; if(!(s->avctx->flags2 & CODEC_FLAG2_NO_OUTPUT)){ flush_put_bits(&s->pb); s->dsp.bswap_buf((uint32_t*)buf, (uint32_t*)buf, size); } s->picture_number++; return size*4; } static av_cold int encode_end(AVCodecContext *avctx) { HYuvContext *s = avctx->priv_data; common_end(s); av_freep(&avctx->extradata); av_freep(&avctx->stats_out); return 0; } #endif /* CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER */ #if CONFIG_HUFFYUV_DECODER AVCodec huffyuv_decoder = { "huffyuv", AVMEDIA_TYPE_VIDEO, CODEC_ID_HUFFYUV, sizeof(HYuvContext), decode_init, NULL, decode_end, decode_frame, CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND, NULL, .long_name = NULL_IF_CONFIG_SMALL("Huffyuv / HuffYUV"), }; #endif #if CONFIG_FFVHUFF_DECODER AVCodec ffvhuff_decoder = { "ffvhuff", AVMEDIA_TYPE_VIDEO, CODEC_ID_FFVHUFF, sizeof(HYuvContext), decode_init, NULL, decode_end, decode_frame, CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND, NULL, .long_name = NULL_IF_CONFIG_SMALL("Huffyuv FFmpeg variant"), }; #endif #if CONFIG_HUFFYUV_ENCODER AVCodec huffyuv_encoder = { "huffyuv", AVMEDIA_TYPE_VIDEO, CODEC_ID_HUFFYUV, sizeof(HYuvContext), encode_init, encode_frame, encode_end, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV422P, PIX_FMT_RGB32, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("Huffyuv / HuffYUV"), }; #endif #if CONFIG_FFVHUFF_ENCODER AVCodec ffvhuff_encoder = { "ffvhuff", AVMEDIA_TYPE_VIDEO, CODEC_ID_FFVHUFF, sizeof(HYuvContext), encode_init, encode_frame, encode_end, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_RGB32, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("Huffyuv FFmpeg variant"), }; #endif
123linslouis-android-video-cutter
jni/libavcodec/huffyuv.c
C
asf20
48,813
/* * CGA ROM data * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <stdint.h> const uint8_t ff_cga_font[2048] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e, 0x7e, 0xff, 0xdb, 0xff, 0xc3, 0xe7, 0xff, 0x7e, 0x6c, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x38, 0x7c, 0x38, 0xfe, 0xfe, 0x7c, 0x38, 0x7c, 0x10, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x7c, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00, 0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff, 0x0f, 0x07, 0x0f, 0x7d, 0xcc, 0xcc, 0xcc, 0x78, 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x3f, 0x33, 0x3f, 0x30, 0x30, 0x70, 0xf0, 0xe0, 0x7f, 0x63, 0x7f, 0x63, 0x63, 0x67, 0xe6, 0xc0, 0x99, 0x5a, 0x3c, 0xe7, 0xe7, 0x3c, 0x5a, 0x99, 0x80, 0xe0, 0xf8, 0xfe, 0xf8, 0xe0, 0x80, 0x00, 0x02, 0x0e, 0x3e, 0xfe, 0x3e, 0x0e, 0x02, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00, 0x7f, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x00, 0x3e, 0x63, 0x38, 0x6c, 0x6c, 0x38, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x7e, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x7e, 0x3c, 0x18, 0xff, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00, 0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x78, 0x78, 0x30, 0x30, 0x00, 0x30, 0x00, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6c, 0xfe, 0x6c, 0xfe, 0x6c, 0x6c, 0x00, 0x30, 0x7c, 0xc0, 0x78, 0x0c, 0xf8, 0x30, 0x00, 0x00, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xc6, 0x00, 0x38, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0x76, 0x00, 0x60, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x60, 0x60, 0x60, 0x30, 0x18, 0x00, 0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00, 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00, 0x7c, 0xc6, 0xce, 0xde, 0xf6, 0xe6, 0x7c, 0x00, 0x30, 0x70, 0x30, 0x30, 0x30, 0x30, 0xfc, 0x00, 0x78, 0xcc, 0x0c, 0x38, 0x60, 0xcc, 0xfc, 0x00, 0x78, 0xcc, 0x0c, 0x38, 0x0c, 0xcc, 0x78, 0x00, 0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x1e, 0x00, 0xfc, 0xc0, 0xf8, 0x0c, 0x0c, 0xcc, 0x78, 0x00, 0x38, 0x60, 0xc0, 0xf8, 0xcc, 0xcc, 0x78, 0x00, 0xfc, 0xcc, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0xcc, 0xcc, 0x78, 0x00, 0x78, 0xcc, 0xcc, 0x7c, 0x0c, 0x18, 0x70, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x60, 0x18, 0x30, 0x60, 0xc0, 0x60, 0x30, 0x18, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x60, 0x30, 0x18, 0x0c, 0x18, 0x30, 0x60, 0x00, 0x78, 0xcc, 0x0c, 0x18, 0x30, 0x00, 0x30, 0x00, 0x7c, 0xc6, 0xde, 0xde, 0xde, 0xc0, 0x78, 0x00, 0x30, 0x78, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0x00, 0xfc, 0x66, 0x66, 0x7c, 0x66, 0x66, 0xfc, 0x00, 0x3c, 0x66, 0xc0, 0xc0, 0xc0, 0x66, 0x3c, 0x00, 0xf8, 0x6c, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00, 0xfe, 0x62, 0x68, 0x78, 0x68, 0x62, 0xfe, 0x00, 0xfe, 0x62, 0x68, 0x78, 0x68, 0x60, 0xf0, 0x00, 0x3c, 0x66, 0xc0, 0xc0, 0xce, 0x66, 0x3e, 0x00, 0xcc, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0xcc, 0x00, 0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, 0x1e, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78, 0x00, 0xe6, 0x66, 0x6c, 0x78, 0x6c, 0x66, 0xe6, 0x00, 0xf0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00, 0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0xc6, 0x00, 0xc6, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0xc6, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00, 0xfc, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0xdc, 0x78, 0x1c, 0x00, 0xfc, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0xe6, 0x00, 0x78, 0xcc, 0xe0, 0x70, 0x1c, 0xcc, 0x78, 0x00, 0xfc, 0xb4, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xfc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x00, 0xc6, 0xc6, 0xc6, 0xd6, 0xfe, 0xee, 0xc6, 0x00, 0xc6, 0xc6, 0x6c, 0x38, 0x38, 0x6c, 0xc6, 0x00, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x30, 0x78, 0x00, 0xfe, 0xc6, 0x8c, 0x18, 0x32, 0x66, 0xfe, 0x00, 0x78, 0x60, 0x60, 0x60, 0x60, 0x60, 0x78, 0x00, 0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x02, 0x00, 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00, 0xe0, 0x60, 0x60, 0x7c, 0x66, 0x66, 0xdc, 0x00, 0x00, 0x00, 0x78, 0xcc, 0xc0, 0xcc, 0x78, 0x00, 0x1c, 0x0c, 0x0c, 0x7c, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00, 0x38, 0x6c, 0x60, 0xf0, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8, 0xe0, 0x60, 0x6c, 0x76, 0x66, 0x66, 0xe6, 0x00, 0x30, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00, 0x0c, 0x00, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78, 0xe0, 0x60, 0x66, 0x6c, 0x78, 0x6c, 0xe6, 0x00, 0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, 0x00, 0x00, 0xcc, 0xfe, 0xfe, 0xd6, 0xc6, 0x00, 0x00, 0x00, 0xf8, 0xcc, 0xcc, 0xcc, 0xcc, 0x00, 0x00, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x7c, 0x60, 0xf0, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0x1e, 0x00, 0x00, 0xdc, 0x76, 0x66, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x7c, 0xc0, 0x78, 0x0c, 0xf8, 0x00, 0x10, 0x30, 0x7c, 0x30, 0x30, 0x34, 0x18, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x00, 0x00, 0x00, 0xc6, 0xd6, 0xfe, 0xfe, 0x6c, 0x00, 0x00, 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8, 0x00, 0x00, 0xfc, 0x98, 0x30, 0x64, 0xfc, 0x00, 0x1c, 0x30, 0x30, 0xe0, 0x30, 0x30, 0x1c, 0x00, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00, 0xe0, 0x30, 0x30, 0x1c, 0x30, 0x30, 0xe0, 0x00, 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0x00, 0x78, 0xcc, 0xc0, 0xcc, 0x78, 0x18, 0x0c, 0x78, 0x00, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0x7e, 0x00, 0x1c, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00, 0x7e, 0xc3, 0x3c, 0x06, 0x3e, 0x66, 0x3f, 0x00, 0xcc, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00, 0xe0, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00, 0x30, 0x30, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00, 0x00, 0x00, 0x78, 0xc0, 0xc0, 0x78, 0x0c, 0x38, 0x7e, 0xc3, 0x3c, 0x66, 0x7e, 0x60, 0x3c, 0x00, 0xcc, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00, 0xe0, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00, 0xcc, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00, 0x7c, 0xc6, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00, 0xe0, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00, 0xc6, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0xc6, 0x00, 0x30, 0x30, 0x00, 0x78, 0xcc, 0xfc, 0xcc, 0x00, 0x1c, 0x00, 0xfc, 0x60, 0x78, 0x60, 0xfc, 0x00, 0x00, 0x00, 0x7f, 0x0c, 0x7f, 0xcc, 0x7f, 0x00, 0x3e, 0x6c, 0xcc, 0xfe, 0xcc, 0xcc, 0xce, 0x00, 0x78, 0xcc, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0xcc, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0xe0, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00, 0x78, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0x7e, 0x00, 0x00, 0xe0, 0x00, 0xcc, 0xcc, 0xcc, 0x7e, 0x00, 0x00, 0xcc, 0x00, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8, 0xc3, 0x18, 0x3c, 0x66, 0x66, 0x3c, 0x18, 0x00, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x18, 0x18, 0x7e, 0xc0, 0xc0, 0x7e, 0x18, 0x18, 0x38, 0x6c, 0x64, 0xf0, 0x60, 0xe6, 0xfc, 0x00, 0xcc, 0xcc, 0x78, 0xfc, 0x30, 0xfc, 0x30, 0x30, 0xf8, 0xcc, 0xcc, 0xfa, 0xc6, 0xcf, 0xc6, 0xc7, 0x0e, 0x1b, 0x18, 0x3c, 0x18, 0x18, 0xd8, 0x70, 0x1c, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00, 0x38, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00, 0x00, 0x1c, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x1c, 0x00, 0xcc, 0xcc, 0xcc, 0x7e, 0x00, 0x00, 0xf8, 0x00, 0xf8, 0xcc, 0xcc, 0xcc, 0x00, 0xfc, 0x00, 0xcc, 0xec, 0xfc, 0xdc, 0xcc, 0x00, 0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0x00, 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00, 0x30, 0x00, 0x30, 0x60, 0xc0, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x0c, 0x0c, 0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xde, 0x33, 0x66, 0xcc, 0x0f, 0xc3, 0xc6, 0xcc, 0xdb, 0x37, 0x6f, 0xcf, 0x03, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x33, 0x66, 0xcc, 0x66, 0x33, 0x00, 0x00, 0x00, 0xcc, 0x66, 0x33, 0x66, 0xcc, 0x00, 0x00, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0xdb, 0x77, 0xdb, 0xee, 0xdb, 0x77, 0xdb, 0xee, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x36, 0x36, 0x36, 0x00, 0x00, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x36, 0x36, 0xf6, 0x06, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0xfe, 0x06, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x06, 0xfe, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36, 0xfe, 0x00, 0x00, 0x00, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, 0x36, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0xf7, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x36, 0x36, 0xf7, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x18, 0x18, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x3f, 0x00, 0x00, 0x00, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0x36, 0x36, 0x36, 0x18, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x18, 0x18, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0xc8, 0xdc, 0x76, 0x00, 0x00, 0x78, 0xcc, 0xf8, 0xcc, 0xf8, 0xc0, 0xc0, 0x00, 0xfc, 0xcc, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0xfe, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0xfc, 0xcc, 0x60, 0x30, 0x60, 0xcc, 0xfc, 0x00, 0x00, 0x00, 0x7e, 0xd8, 0xd8, 0xd8, 0x70, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0xc0, 0x00, 0x76, 0xdc, 0x18, 0x18, 0x18, 0x18, 0x00, 0xfc, 0x30, 0x78, 0xcc, 0xcc, 0x78, 0x30, 0xfc, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0x6c, 0x38, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x6c, 0xee, 0x00, 0x1c, 0x30, 0x18, 0x7c, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x7e, 0xdb, 0xdb, 0x7e, 0x00, 0x00, 0x06, 0x0c, 0x7e, 0xdb, 0xdb, 0x7e, 0x60, 0xc0, 0x38, 0x60, 0xc0, 0xf8, 0xc0, 0x60, 0x38, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x00, 0x00, 0xfc, 0x00, 0xfc, 0x00, 0xfc, 0x00, 0x00, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x00, 0xfc, 0x00, 0x60, 0x30, 0x18, 0x30, 0x60, 0x00, 0xfc, 0x00, 0x18, 0x30, 0x60, 0x30, 0x18, 0x00, 0xfc, 0x00, 0x0e, 0x1b, 0x1b, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0xd8, 0x70, 0x30, 0x30, 0x00, 0xfc, 0x00, 0x30, 0x30, 0x00, 0x00, 0x76, 0xdc, 0x00, 0x76, 0xdc, 0x00, 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x0f, 0x0c, 0x0c, 0x0c, 0xec, 0x6c, 0x3c, 0x1c, 0x78, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x70, 0x18, 0x30, 0x60, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; const uint32_t ff_cga_palette[16] = { 0x000000, 0x0000AA, 0x00AA00, 0x00AAAA, 0xAA0000, 0xAA00AA, 0xAA5500, 0xAAAAAA, 0x555555, 0x5555FF, 0x55FF55, 0x55FFFF, 0xFF5555, 0xFF55FF, 0xFFFF55, 0xFFFFFF, };
123linslouis-android-video-cutter
jni/libavcodec/cga_data.c
C
asf20
13,469
/* * FLAC data * Copyright (c) 2003 Alex Beregszaszi * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "internal.h" const int ff_flac_sample_rate_table[16] = { 0, 88200, 176400, 192000, 8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000, 0, 0, 0, 0 }; const int16_t ff_flac_blocksize_table[16] = { 0, 192, 576<<0, 576<<1, 576<<2, 576<<3, 0, 0, 256<<0, 256<<1, 256<<2, 256<<3, 256<<4, 256<<5, 256<<6, 256<<7 };
123linslouis-android-video-cutter
jni/libavcodec/flacdata.c
C
asf20
1,164
/* * Common bit i/o utils * Copyright (c) 2000, 2001 Fabrice Bellard * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * Copyright (c) 2010 Loren Merritt * * alternative bitstream reader & writer by Michael Niedermayer <michaelni@gmx.at> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * bitstream api. */ #include "avcodec.h" #include "get_bits.h" #include "put_bits.h" const uint8_t ff_log2_run[32]={ 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 9,10,11,12,13,14,15 }; void align_put_bits(PutBitContext *s) { #ifdef ALT_BITSTREAM_WRITER put_bits(s,( - s->index) & 7,0); #else put_bits(s,s->bit_left & 7,0); #endif } void ff_put_string(PutBitContext *pb, const char *string, int terminate_string) { while(*string){ put_bits(pb, 8, *string); string++; } if(terminate_string) put_bits(pb, 8, 0); } void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length) { int words= length>>4; int bits= length&15; int i; if(length==0) return; if(CONFIG_SMALL || words < 16 || put_bits_count(pb)&7){ for(i=0; i<words; i++) put_bits(pb, 16, AV_RB16(src + 2*i)); }else{ for(i=0; put_bits_count(pb)&31; i++) put_bits(pb, 8, src[i]); flush_put_bits(pb); memcpy(put_bits_ptr(pb), src+i, 2*words-i); skip_put_bytes(pb, 2*words-i); } put_bits(pb, bits, AV_RB16(src + 2*words)>>(16-bits)); } /* VLC decoding */ //#define DEBUG_VLC #define GET_DATA(v, table, i, wrap, size) \ {\ const uint8_t *ptr = (const uint8_t *)table + i * wrap;\ switch(size) {\ case 1:\ v = *(const uint8_t *)ptr;\ break;\ case 2:\ v = *(const uint16_t *)ptr;\ break;\ default:\ v = *(const uint32_t *)ptr;\ break;\ }\ } static int alloc_table(VLC *vlc, int size, int use_static) { int index; index = vlc->table_size; vlc->table_size += size; if (vlc->table_size > vlc->table_allocated) { if(use_static) abort(); //cant do anything, init_vlc() is used with too little memory vlc->table_allocated += (1 << vlc->bits); vlc->table = av_realloc(vlc->table, sizeof(VLC_TYPE) * 2 * vlc->table_allocated); if (!vlc->table) return -1; } return index; } static av_always_inline uint32_t bitswap_32(uint32_t x) { return av_reverse[x&0xFF]<<24 | av_reverse[(x>>8)&0xFF]<<16 | av_reverse[(x>>16)&0xFF]<<8 | av_reverse[x>>24]; } typedef struct { uint8_t bits; uint16_t symbol; /** codeword, with the first bit-to-be-read in the msb * (even if intended for a little-endian bitstream reader) */ uint32_t code; } VLCcode; static int compare_vlcspec(const void *a, const void *b) { const VLCcode *sa=a, *sb=b; return (sa->code >> 1) - (sb->code >> 1); } /** * Build VLC decoding tables suitable for use with get_vlc(). * * @param vlc the context to be initted * * @param table_nb_bits max length of vlc codes to store directly in this table * (Longer codes are delegated to subtables.) * * @param nb_codes number of elements in codes[] * * @param codes descriptions of the vlc codes * These must be ordered such that codes going into the same subtable are contiguous. * Sorting by VLCcode.code is sufficient, though not necessary. */ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, VLCcode *codes, int flags) { int table_size, table_index, index, code_prefix, symbol, subtable_bits; int i, j, k, n, nb, inc; uint32_t code; VLC_TYPE (*table)[2]; table_size = 1 << table_nb_bits; table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC); #ifdef DEBUG_VLC av_log(NULL,AV_LOG_DEBUG,"new table index=%d size=%d\n", table_index, table_size); #endif if (table_index < 0) return -1; table = &vlc->table[table_index]; for (i = 0; i < table_size; i++) { table[i][1] = 0; //bits table[i][0] = -1; //codes } /* first pass: map codes and compute auxillary table sizes */ for (i = 0; i < nb_codes; i++) { n = codes[i].bits; code = codes[i].code; symbol = codes[i].symbol; #if defined(DEBUG_VLC) && 0 av_log(NULL,AV_LOG_DEBUG,"i=%d n=%d code=0x%x\n", i, n, code); #endif if (n <= table_nb_bits) { /* no need to add another table */ j = code >> (32 - table_nb_bits); nb = 1 << (table_nb_bits - n); inc = 1; if (flags & INIT_VLC_LE) { j = bitswap_32(code); inc = 1 << n; } for (k = 0; k < nb; k++) { #ifdef DEBUG_VLC av_log(NULL, AV_LOG_DEBUG, "%4x: code=%d n=%d\n", j, i, n); #endif if (table[j][1] /*bits*/ != 0) { av_log(NULL, AV_LOG_ERROR, "incorrect codes\n"); return -1; } table[j][1] = n; //bits table[j][0] = symbol; j += inc; } } else { /* fill auxiliary table recursively */ n -= table_nb_bits; code_prefix = code >> (32 - table_nb_bits); subtable_bits = n; codes[i].bits = n; codes[i].code = code << table_nb_bits; for (k = i+1; k < nb_codes; k++) { n = codes[k].bits - table_nb_bits; if (n <= 0) break; code = codes[k].code; if (code >> (32 - table_nb_bits) != code_prefix) break; codes[k].bits = n; codes[k].code = code << table_nb_bits; subtable_bits = FFMAX(subtable_bits, n); } subtable_bits = FFMIN(subtable_bits, table_nb_bits); j = (flags & INIT_VLC_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) : code_prefix; table[j][1] = -subtable_bits; #ifdef DEBUG_VLC av_log(NULL,AV_LOG_DEBUG,"%4x: n=%d (subtable)\n", j, codes[i].bits + table_nb_bits); #endif index = build_table(vlc, subtable_bits, k-i, codes+i, flags); if (index < 0) return -1; /* note: realloc has been done, so reload tables */ table = &vlc->table[table_index]; table[j][0] = index; //code i = k-1; } } return table_index; } /* Build VLC decoding tables suitable for use with get_vlc(). 'nb_bits' set thee decoding table size (2^nb_bits) entries. The bigger it is, the faster is the decoding. But it should not be too big to save memory and L1 cache. '9' is a good compromise. 'nb_codes' : number of vlcs codes 'bits' : table which gives the size (in bits) of each vlc code. 'codes' : table which gives the bit pattern of of each vlc code. 'symbols' : table which gives the values to be returned from get_vlc(). 'xxx_wrap' : give the number of bytes between each entry of the 'bits' or 'codes' tables. 'xxx_size' : gives the number of bytes of each entry of the 'bits' or 'codes' tables. 'wrap' and 'size' allows to use any memory configuration and types (byte/word/long) to store the 'bits', 'codes', and 'symbols' tables. 'use_static' should be set to 1 for tables, which should be freed with av_free_static(), 0 if free_vlc() will be used. */ int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, const void *symbols, int symbols_wrap, int symbols_size, int flags) { VLCcode buf[nb_codes]; int i, j; vlc->bits = nb_bits; if(flags & INIT_VLC_USE_NEW_STATIC){ if(vlc->table_size && vlc->table_size == vlc->table_allocated){ return 0; }else if(vlc->table_size){ abort(); // fatal error, we are called on a partially initialized table } }else { vlc->table = NULL; vlc->table_allocated = 0; vlc->table_size = 0; } #ifdef DEBUG_VLC av_log(NULL,AV_LOG_DEBUG,"build table nb_codes=%d\n", nb_codes); #endif assert(symbols_size <= 2 || !symbols); j = 0; #define COPY(condition)\ for (i = 0; i < nb_codes; i++) {\ GET_DATA(buf[j].bits, bits, i, bits_wrap, bits_size);\ if (!(condition))\ continue;\ GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size);\ if (flags & INIT_VLC_LE)\ buf[j].code = bitswap_32(buf[j].code);\ else\ buf[j].code <<= 32 - buf[j].bits;\ if (symbols)\ GET_DATA(buf[j].symbol, symbols, i, symbols_wrap, symbols_size)\ else\ buf[j].symbol = i;\ j++;\ } COPY(buf[j].bits > nb_bits); // qsort is the slowest part of init_vlc, and could probably be improved or avoided qsort(buf, j, sizeof(VLCcode), compare_vlcspec); COPY(buf[j].bits && buf[j].bits <= nb_bits); nb_codes = j; if (build_table(vlc, nb_bits, nb_codes, buf, flags) < 0) { av_freep(&vlc->table); return -1; } if((flags & INIT_VLC_USE_NEW_STATIC) && vlc->table_size != vlc->table_allocated) av_log(NULL, AV_LOG_ERROR, "needed %d had %d\n", vlc->table_size, vlc->table_allocated); return 0; } void free_vlc(VLC *vlc) { av_freep(&vlc->table); }
123linslouis-android-video-cutter
jni/libavcodec/bitstream.c
C
asf20
10,442
/* * MPEG-4 Parametric Stereo data tables * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ static const uint8_t huff_iid_df1_bits[] = { 18, 18, 18, 18, 18, 18, 18, 18, 18, 17, 18, 17, 17, 16, 16, 15, 14, 14, 13, 12, 12, 11, 10, 10, 8, 7, 6, 5, 4, 3, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 14, 15, 16, 16, 17, 17, 18, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, }; static const uint32_t huff_iid_df1_codes[] = { 0x01FEB4, 0x01FEB5, 0x01FD76, 0x01FD77, 0x01FD74, 0x01FD75, 0x01FE8A, 0x01FE8B, 0x01FE88, 0x00FE80, 0x01FEB6, 0x00FE82, 0x00FEB8, 0x007F42, 0x007FAE, 0x003FAF, 0x001FD1, 0x001FE9, 0x000FE9, 0x0007EA, 0x0007FB, 0x0003FB, 0x0001FB, 0x0001FF, 0x00007C, 0x00003C, 0x00001C, 0x00000C, 0x000000, 0x000001, 0x000001, 0x000002, 0x000001, 0x00000D, 0x00001D, 0x00003D, 0x00007D, 0x0000FC, 0x0001FC, 0x0003FC, 0x0003F4, 0x0007EB, 0x000FEA, 0x001FEA, 0x001FD6, 0x003FD0, 0x007FAF, 0x007F43, 0x00FEB9, 0x00FE83, 0x01FEB7, 0x00FE81, 0x01FE89, 0x01FE8E, 0x01FE8F, 0x01FE8C, 0x01FE8D, 0x01FEB2, 0x01FEB3, 0x01FEB0, 0x01FEB1, }; static const uint8_t huff_iid_dt1_bits[] = { 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 14, 14, 13, 13, 13, 12, 12, 11, 10, 9, 9, 7, 6, 5, 3, 1, 2, 5, 6, 7, 8, 9, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, }; static const uint16_t huff_iid_dt1_codes[] = { 0x004ED4, 0x004ED5, 0x004ECE, 0x004ECF, 0x004ECC, 0x004ED6, 0x004ED8, 0x004F46, 0x004F60, 0x002718, 0x002719, 0x002764, 0x002765, 0x00276D, 0x0027B1, 0x0013B7, 0x0013D6, 0x0009C7, 0x0009E9, 0x0009ED, 0x0004EE, 0x0004F7, 0x000278, 0x000139, 0x00009A, 0x00009F, 0x000020, 0x000011, 0x00000A, 0x000003, 0x000001, 0x000000, 0x00000B, 0x000012, 0x000021, 0x00004C, 0x00009B, 0x00013A, 0x000279, 0x000270, 0x0004EF, 0x0004E2, 0x0009EA, 0x0009D8, 0x0013D7, 0x0013D0, 0x0027B2, 0x0027A2, 0x00271A, 0x00271B, 0x004F66, 0x004F67, 0x004F61, 0x004F47, 0x004ED9, 0x004ED7, 0x004ECD, 0x004ED2, 0x004ED3, 0x004ED0, 0x004ED1, }; static const uint8_t huff_iid_df0_bits[] = { 17, 17, 17, 17, 16, 15, 13, 10, 9, 7, 6, 5, 4, 3, 1, 3, 4, 5, 6, 6, 8, 11, 13, 14, 14, 15, 17, 18, 18, }; static const uint32_t huff_iid_df0_codes[] = { 0x01FFFB, 0x01FFFC, 0x01FFFD, 0x01FFFA, 0x00FFFC, 0x007FFC, 0x001FFD, 0x0003FE, 0x0001FE, 0x00007E, 0x00003C, 0x00001D, 0x00000D, 0x000005, 0x000000, 0x000004, 0x00000C, 0x00001C, 0x00003D, 0x00003E, 0x0000FE, 0x0007FE, 0x001FFC, 0x003FFC, 0x003FFD, 0x007FFD, 0x01FFFE, 0x03FFFE, 0x03FFFF, }; static const uint8_t huff_iid_dt0_bits[] = { 19, 19, 19, 20, 20, 20, 17, 15, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 14, 17, 19, 20, 20, 20, 20, 20, }; static const uint32_t huff_iid_dt0_codes[] = { 0x07FFF9, 0x07FFFA, 0x07FFFB, 0x0FFFF8, 0x0FFFF9, 0x0FFFFA, 0x01FFFD, 0x007FFE, 0x000FFE, 0x0003FE, 0x0000FE, 0x00003E, 0x00000E, 0x000002, 0x000000, 0x000006, 0x00001E, 0x00007E, 0x0001FE, 0x0007FE, 0x001FFE, 0x003FFE, 0x01FFFC, 0x07FFF8, 0x0FFFFB, 0x0FFFFC, 0x0FFFFD, 0x0FFFFE, 0x0FFFFF, }; static const uint8_t huff_icc_df_bits[] = { 14, 14, 12, 10, 7, 5, 3, 1, 2, 4, 6, 8, 9, 11, 13, }; static const uint16_t huff_icc_df_codes[] = { 0x3FFF, 0x3FFE, 0x0FFE, 0x03FE, 0x007E, 0x001E, 0x0006, 0x0000, 0x0002, 0x000E, 0x003E, 0x00FE, 0x01FE, 0x07FE, 0x1FFE, }; static const uint8_t huff_icc_dt_bits[] = { 14, 13, 11, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 14, }; static const uint16_t huff_icc_dt_codes[] = { 0x3FFE, 0x1FFE, 0x07FE, 0x01FE, 0x007E, 0x001E, 0x0006, 0x0000, 0x0002, 0x000E, 0x003E, 0x00FE, 0x03FE, 0x0FFE, 0x3FFF, }; static const uint8_t huff_ipd_df_bits[] = { 1, 3, 4, 4, 4, 4, 4, 4, }; static const uint8_t huff_ipd_df_codes[] = { 0x01, 0x00, 0x06, 0x04, 0x02, 0x03, 0x05, 0x07, }; static const uint8_t huff_ipd_dt_bits[] = { 1, 3, 4, 5, 5, 4, 4, 3, }; static const uint8_t huff_ipd_dt_codes[] = { 0x01, 0x02, 0x02, 0x03, 0x02, 0x00, 0x03, 0x03, }; static const uint8_t huff_opd_df_bits[] = { 1, 3, 4, 4, 5, 5, 4, 3, }; static const uint8_t huff_opd_df_codes[] = { 0x01, 0x01, 0x06, 0x04, 0x0F, 0x0E, 0x05, 0x00, }; static const uint8_t huff_opd_dt_bits[] = { 1, 3, 4, 5, 5, 4, 4, 3, }; static const uint8_t huff_opd_dt_codes[] = { 0x01, 0x02, 0x01, 0x07, 0x06, 0x00, 0x02, 0x03, }; static const int8_t huff_offset[] = { 30, 30, 14, 14, 7, 7, 0, 0, 0, 0, }; ///Table 8.48 static const int8_t k_to_i_20[] = { 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 14, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19 }; ///Table 8.49 static const int8_t k_to_i_34[] = { 0, 1, 2, 3, 4, 5, 6, 6, 7, 2, 1, 0, 10, 10, 4, 5, 6, 7, 8, 9, 10, 11, 12, 9, 14, 11, 12, 13, 14, 15, 16, 13, 16, 17, 18, 19, 20, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 30, 30, 30, 31, 31, 31, 31, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33 }; static const float g1_Q2[] = { 0.0f, 0.01899487526049f, 0.0f, -0.07293139167538f, 0.0f, 0.30596630545168f, 0.5f };
123linslouis-android-video-cutter
jni/libavcodec/aacpsdata.c
C
asf20
6,229
/* * Copyright (c) 2010, Google, Inc. * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * VP8 encoder support via libvpx */ #define VPX_DISABLE_CTRL_TYPECHECKS 1 #define VPX_CODEC_DISABLE_COMPAT 1 #include <vpx/vpx_encoder.h> #include <vpx/vp8cx.h> #include "avcodec.h" #include "libavutil/base64.h" /** * Portion of struct vpx_codec_cx_pkt from vpx_encoder.h. * One encoded frame returned from the library. */ struct FrameListData { void *buf; /**≤ compressed data buffer */ size_t sz; /**≤ length of compressed data */ int64_t pts; /**≤ time stamp to show frame (in timebase units) */ unsigned long duration; /**≤ duration to show frame (in timebase units) */ uint32_t flags; /**≤ flags for this frame */ struct FrameListData *next; }; typedef struct VP8EncoderContext { struct vpx_codec_ctx encoder; struct vpx_image rawimg; struct vpx_fixed_buf twopass_stats; unsigned long deadline; //i.e., RT/GOOD/BEST struct FrameListData *coded_frame_list; } VP8Context; /** String mappings for enum vp8e_enc_control_id */ static const char *ctlidstr[] = { [VP8E_UPD_ENTROPY] = "VP8E_UPD_ENTROPY", [VP8E_UPD_REFERENCE] = "VP8E_UPD_REFERENCE", [VP8E_USE_REFERENCE] = "VP8E_USE_REFERENCE", [VP8E_SET_ROI_MAP] = "VP8E_SET_ROI_MAP", [VP8E_SET_ACTIVEMAP] = "VP8E_SET_ACTIVEMAP", [VP8E_SET_SCALEMODE] = "VP8E_SET_SCALEMODE", [VP8E_SET_CPUUSED] = "VP8E_SET_CPUUSED", [VP8E_SET_ENABLEAUTOALTREF] = "VP8E_SET_ENABLEAUTOALTREF", [VP8E_SET_NOISE_SENSITIVITY] = "VP8E_SET_NOISE_SENSITIVITY", [VP8E_SET_SHARPNESS] = "VP8E_SET_SHARPNESS", [VP8E_SET_STATIC_THRESHOLD] = "VP8E_SET_STATIC_THRESHOLD", [VP8E_SET_TOKEN_PARTITIONS] = "VP8E_SET_TOKEN_PARTITIONS", [VP8E_GET_LAST_QUANTIZER] = "VP8E_GET_LAST_QUANTIZER", [VP8E_SET_ARNR_MAXFRAMES] = "VP8E_SET_ARNR_MAXFRAMES", [VP8E_SET_ARNR_STRENGTH] = "VP8E_SET_ARNR_STRENGTH", [VP8E_SET_ARNR_TYPE] = "VP8E_SET_ARNR_TYPE", }; static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc) { VP8Context *ctx = avctx->priv_data; const char *error = vpx_codec_error(&ctx->encoder); const char *detail = vpx_codec_error_detail(&ctx->encoder); av_log(avctx, AV_LOG_ERROR, "%s: %s\n", desc, error); if (detail) av_log(avctx, AV_LOG_ERROR, " Additional information: %s\n", detail); } static av_cold void dump_enc_cfg(AVCodecContext *avctx, const struct vpx_codec_enc_cfg *cfg) { int width = -30; int level = AV_LOG_DEBUG; av_log(avctx, level, "vpx_codec_enc_cfg\n"); av_log(avctx, level, "generic settings\n" " %*s%u\n %*s%u\n %*s%u\n %*s%u\n %*s%u\n" " %*s{%u/%u}\n %*s%u\n %*s%d\n %*s%u\n", width, "g_usage:", cfg->g_usage, width, "g_threads:", cfg->g_threads, width, "g_profile:", cfg->g_profile, width, "g_w:", cfg->g_w, width, "g_h:", cfg->g_h, width, "g_timebase:", cfg->g_timebase.num, cfg->g_timebase.den, width, "g_error_resilient:", cfg->g_error_resilient, width, "g_pass:", cfg->g_pass, width, "g_lag_in_frames:", cfg->g_lag_in_frames); av_log(avctx, level, "rate control settings\n" " %*s%u\n %*s%u\n %*s%u\n %*s%u\n" " %*s%d\n %*s%p(%zu)\n %*s%u\n", width, "rc_dropframe_thresh:", cfg->rc_dropframe_thresh, width, "rc_resize_allowed:", cfg->rc_resize_allowed, width, "rc_resize_up_thresh:", cfg->rc_resize_up_thresh, width, "rc_resize_down_thresh:", cfg->rc_resize_down_thresh, width, "rc_end_usage:", cfg->rc_end_usage, width, "rc_twopass_stats_in:", cfg->rc_twopass_stats_in.buf, cfg->rc_twopass_stats_in.sz, width, "rc_target_bitrate:", cfg->rc_target_bitrate); av_log(avctx, level, "quantizer settings\n" " %*s%u\n %*s%u\n", width, "rc_min_quantizer:", cfg->rc_min_quantizer, width, "rc_max_quantizer:", cfg->rc_max_quantizer); av_log(avctx, level, "bitrate tolerance\n" " %*s%u\n %*s%u\n", width, "rc_undershoot_pct:", cfg->rc_undershoot_pct, width, "rc_overshoot_pct:", cfg->rc_overshoot_pct); av_log(avctx, level, "decoder buffer model\n" " %*s%u\n %*s%u\n %*s%u\n", width, "rc_buf_sz:", cfg->rc_buf_sz, width, "rc_buf_initial_sz:", cfg->rc_buf_initial_sz, width, "rc_buf_optimal_sz:", cfg->rc_buf_optimal_sz); av_log(avctx, level, "2 pass rate control settings\n" " %*s%u\n %*s%u\n %*s%u\n", width, "rc_2pass_vbr_bias_pct:", cfg->rc_2pass_vbr_bias_pct, width, "rc_2pass_vbr_minsection_pct:", cfg->rc_2pass_vbr_minsection_pct, width, "rc_2pass_vbr_maxsection_pct:", cfg->rc_2pass_vbr_maxsection_pct); av_log(avctx, level, "keyframing settings\n" " %*s%d\n %*s%u\n %*s%u\n", width, "kf_mode:", cfg->kf_mode, width, "kf_min_dist:", cfg->kf_min_dist, width, "kf_max_dist:", cfg->kf_max_dist); av_log(avctx, level, "\n"); } static void coded_frame_add(void *list, struct FrameListData *cx_frame) { struct FrameListData **p = list; while (*p != NULL) p = &(*p)->next; *p = cx_frame; cx_frame->next = NULL; } static av_cold void free_coded_frame(struct FrameListData *cx_frame) { av_freep(&cx_frame->buf); av_freep(&cx_frame); } static av_cold void free_frame_list(struct FrameListData *list) { struct FrameListData *p = list; while (p) { list = list->next; free_coded_frame(p); p = list; } } static av_cold int codecctl_int(AVCodecContext *avctx, enum vp8e_enc_control_id id, int val) { VP8Context *ctx = avctx->priv_data; char buf[80]; int width = -30; int res; snprintf(buf, sizeof(buf), "%s:", ctlidstr[id]); av_log(avctx, AV_LOG_DEBUG, " %*s%d\n", width, buf, val); res = vpx_codec_control(&ctx->encoder, id, val); if (res != VPX_CODEC_OK) { snprintf(buf, sizeof(buf), "Failed to set %s codec control", ctlidstr[id]); log_encoder_error(avctx, buf); } return res == VPX_CODEC_OK ? 0 : AVERROR(EINVAL); } static av_cold int vp8_free(AVCodecContext *avctx) { VP8Context *ctx = avctx->priv_data; vpx_codec_destroy(&ctx->encoder); av_freep(&ctx->twopass_stats.buf); av_freep(&avctx->coded_frame); av_freep(&avctx->stats_out); free_frame_list(ctx->coded_frame_list); return 0; } static av_cold int vp8_init(AVCodecContext *avctx) { VP8Context *ctx = avctx->priv_data; const struct vpx_codec_iface *iface = &vpx_codec_vp8_cx_algo; int cpuused = 3; struct vpx_codec_enc_cfg enccfg; int res; av_log(avctx, AV_LOG_INFO, "%s\n", vpx_codec_version_str()); av_log(avctx, AV_LOG_VERBOSE, "%s\n", vpx_codec_build_config()); if ((res = vpx_codec_enc_config_default(iface, &enccfg, 0)) != VPX_CODEC_OK) { av_log(avctx, AV_LOG_ERROR, "Failed to get config: %s\n", vpx_codec_err_to_string(res)); return AVERROR(EINVAL); } dump_enc_cfg(avctx, &enccfg); enccfg.g_w = avctx->width; enccfg.g_h = avctx->height; enccfg.g_timebase.num = avctx->time_base.num; enccfg.g_timebase.den = avctx->time_base.den; enccfg.g_threads = avctx->thread_count; if (avctx->flags & CODEC_FLAG_PASS1) enccfg.g_pass = VPX_RC_FIRST_PASS; else if (avctx->flags & CODEC_FLAG_PASS2) enccfg.g_pass = VPX_RC_LAST_PASS; else enccfg.g_pass = VPX_RC_ONE_PASS; if (avctx->rc_min_rate == avctx->rc_max_rate && avctx->rc_min_rate == avctx->bit_rate) enccfg.rc_end_usage = VPX_CBR; enccfg.rc_target_bitrate = av_rescale_rnd(avctx->bit_rate, 1, 1000, AV_ROUND_NEAR_INF); //convert [1,51] -> [0,63] enccfg.rc_min_quantizer = ((avctx->qmin * 5 + 1) >> 2) - 1; enccfg.rc_max_quantizer = ((avctx->qmax * 5 + 1) >> 2) - 1; if (avctx->keyint_min == avctx->gop_size) enccfg.kf_mode = VPX_KF_FIXED; //_enc_init() will balk if kf_min_dist is set in this case if (enccfg.kf_mode != VPX_KF_AUTO) enccfg.kf_min_dist = avctx->keyint_min; enccfg.kf_max_dist = avctx->gop_size; if (enccfg.g_pass == VPX_RC_FIRST_PASS) enccfg.g_lag_in_frames = 0; else if (enccfg.g_pass == VPX_RC_LAST_PASS) { int decode_size; if (!avctx->stats_in) { av_log(avctx, AV_LOG_ERROR, "No stats file for second pass\n"); return AVERROR_INVALIDDATA; } ctx->twopass_stats.sz = strlen(avctx->stats_in) * 3 / 4; ctx->twopass_stats.buf = av_malloc(ctx->twopass_stats.sz); if (!ctx->twopass_stats.buf) { av_log(avctx, AV_LOG_ERROR, "Stat buffer alloc (%zu bytes) failed\n", ctx->twopass_stats.sz); return AVERROR(ENOMEM); } decode_size = av_base64_decode(ctx->twopass_stats.buf, avctx->stats_in, ctx->twopass_stats.sz); if (decode_size < 0) { av_log(avctx, AV_LOG_ERROR, "Stat buffer decode failed\n"); return AVERROR_INVALIDDATA; } ctx->twopass_stats.sz = decode_size; enccfg.rc_twopass_stats_in = ctx->twopass_stats; } ctx->deadline = VPX_DL_GOOD_QUALITY; dump_enc_cfg(avctx, &enccfg); /* Construct Encoder Context */ res = vpx_codec_enc_init(&ctx->encoder, iface, &enccfg, 0); if (res != VPX_CODEC_OK) { log_encoder_error(avctx, "Failed to initialize encoder"); return AVERROR(EINVAL); } //codec control failures are currently treated only as warnings av_log(avctx, AV_LOG_DEBUG, "vpx_codec_control\n"); codecctl_int(avctx, VP8E_SET_CPUUSED, cpuused); codecctl_int(avctx, VP8E_SET_NOISE_SENSITIVITY, avctx->noise_reduction); //provide dummy value to initialize wrapper, values will be updated each _encode() vpx_img_wrap(&ctx->rawimg, VPX_IMG_FMT_I420, avctx->width, avctx->height, 1, (unsigned char*)1); avctx->coded_frame = avcodec_alloc_frame(); if (!avctx->coded_frame) { av_log(avctx, AV_LOG_ERROR, "Error allocating coded frame\n"); vp8_free(avctx); return AVERROR(ENOMEM); } return 0; } static inline void cx_pktcpy(struct FrameListData *dst, const struct vpx_codec_cx_pkt *src) { dst->pts = src->data.frame.pts; dst->duration = src->data.frame.duration; dst->flags = src->data.frame.flags; dst->sz = src->data.frame.sz; dst->buf = src->data.frame.buf; } /** * Store coded frame information in format suitable for return from encode(). * * Write buffer information from @a cx_frame to @a buf & @a buf_size. * Timing/frame details to @a coded_frame. * @return Frame size written to @a buf on success * @return AVERROR(EINVAL) on error */ static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame, uint8_t *buf, int buf_size, AVFrame *coded_frame) { if ((int) cx_frame->sz <= buf_size) { buf_size = cx_frame->sz; memcpy(buf, cx_frame->buf, buf_size); coded_frame->pts = cx_frame->pts; coded_frame->key_frame = !!(cx_frame->flags & VPX_FRAME_IS_KEY); if (coded_frame->key_frame) coded_frame->pict_type = FF_I_TYPE; else coded_frame->pict_type = FF_P_TYPE; } else { av_log(avctx, AV_LOG_ERROR, "Compressed frame larger than storage provided! (%zu/%d)\n", cx_frame->sz, buf_size); return AVERROR(EINVAL); } return buf_size; } /** * Queue multiple output frames from the encoder, returning the front-most. * In cases where vpx_codec_get_cx_data() returns more than 1 frame append * the frame queue. Return the head frame if available. * @return Stored frame size * @return AVERROR(EINVAL) on output size error * @return AVERROR(ENOMEM) on coded frame queue data allocation error */ static int queue_frames(AVCodecContext *avctx, uint8_t *buf, int buf_size, AVFrame *coded_frame) { VP8Context *ctx = avctx->priv_data; const struct vpx_codec_cx_pkt *pkt; const void *iter = NULL; int size = 0; if (ctx->coded_frame_list) { struct FrameListData *cx_frame = ctx->coded_frame_list; /* return the leading frame if we've already begun queueing */ size = storeframe(avctx, cx_frame, buf, buf_size, coded_frame); if (size < 0) return AVERROR(EINVAL); ctx->coded_frame_list = cx_frame->next; free_coded_frame(cx_frame); } /* consume all available output from the encoder before returning. buffers are only good through the next vpx_codec call */ while ((pkt = vpx_codec_get_cx_data(&ctx->encoder, &iter))) { switch (pkt->kind) { case VPX_CODEC_CX_FRAME_PKT: if (!size) { struct FrameListData cx_frame; /* avoid storing the frame when the list is empty and we haven't yet provided a frame for output */ assert(!ctx->coded_frame_list); cx_pktcpy(&cx_frame, pkt); size = storeframe(avctx, &cx_frame, buf, buf_size, coded_frame); if (size < 0) return AVERROR(EINVAL); } else { struct FrameListData *cx_frame = av_malloc(sizeof(struct FrameListData)); if (!cx_frame) { av_log(avctx, AV_LOG_ERROR, "Frame queue element alloc failed\n"); return AVERROR(ENOMEM); } cx_pktcpy(cx_frame, pkt); cx_frame->buf = av_malloc(cx_frame->sz); if (!cx_frame->buf) { av_log(avctx, AV_LOG_ERROR, "Data buffer alloc (%zu bytes) failed\n", cx_frame->sz); return AVERROR(ENOMEM); } memcpy(cx_frame->buf, pkt->data.frame.buf, pkt->data.frame.sz); coded_frame_add(&ctx->coded_frame_list, cx_frame); } break; case VPX_CODEC_STATS_PKT: { struct vpx_fixed_buf *stats = &ctx->twopass_stats; stats->buf = av_realloc(stats->buf, stats->sz + pkt->data.twopass_stats.sz); if (!stats->buf) { av_log(avctx, AV_LOG_ERROR, "Stat buffer realloc failed\n"); return AVERROR(ENOMEM); } memcpy((uint8_t*)stats->buf + stats->sz, pkt->data.twopass_stats.buf, pkt->data.twopass_stats.sz); stats->sz += pkt->data.twopass_stats.sz; break; } case VPX_CODEC_PSNR_PKT: //FIXME add support for CODEC_FLAG_PSNR case VPX_CODEC_CUSTOM_PKT: //ignore unsupported/unrecognized packet types break; } } return size; } static int vp8_encode(AVCodecContext *avctx, uint8_t *buf, int buf_size, void *data) { VP8Context *ctx = avctx->priv_data; AVFrame *frame = data; struct vpx_image *rawimg = NULL; int64_t timestamp = 0; int res, coded_size; if (frame) { rawimg = &ctx->rawimg; rawimg->planes[VPX_PLANE_Y] = frame->data[0]; rawimg->planes[VPX_PLANE_U] = frame->data[1]; rawimg->planes[VPX_PLANE_V] = frame->data[2]; rawimg->stride[VPX_PLANE_Y] = frame->linesize[0]; rawimg->stride[VPX_PLANE_U] = frame->linesize[1]; rawimg->stride[VPX_PLANE_V] = frame->linesize[2]; timestamp = frame->pts; } res = vpx_codec_encode(&ctx->encoder, rawimg, timestamp, avctx->ticks_per_frame, 0, ctx->deadline); if (res != VPX_CODEC_OK) { log_encoder_error(avctx, "Error encoding frame"); return AVERROR_INVALIDDATA; } coded_size = queue_frames(avctx, buf, buf_size, avctx->coded_frame); if (!frame && avctx->flags & CODEC_FLAG_PASS1) { unsigned int b64_size = ((ctx->twopass_stats.sz + 2) / 3) * 4 + 1; avctx->stats_out = av_malloc(b64_size); if (!avctx->stats_out) { av_log(avctx, AV_LOG_ERROR, "Stat buffer alloc (%d bytes) failed\n", b64_size); return AVERROR(ENOMEM); } av_base64_encode(avctx->stats_out, b64_size, ctx->twopass_stats.buf, ctx->twopass_stats.sz); } return coded_size; } AVCodec libvpx_encoder = { "libvpx", AVMEDIA_TYPE_VIDEO, CODEC_ID_VP8, sizeof(VP8Context), vp8_init, vp8_encode, vp8_free, NULL, CODEC_CAP_DELAY, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("libvpx VP8"), };
123linslouis-android-video-cutter
jni/libavcodec/libvpxenc.c
C
asf20
18,366
/* * Duck Truemotion v1 Decoding Tables * * Data in this file was originally part of VpVision from On2 which is * distributed under the GNU GPL. It is redistributed with ffmpeg under the * GNU LGPL using the common understanding that data tables necessary for * decoding algorithms are not necessarily licensable. * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AVCODEC_TRUEMOTION1DATA_H #define AVCODEC_TRUEMOTION1DATA_H #include <stdint.h> #include <stdlib.h> /* Y delta tables, skinny and fat */ static const int16_t ydt1[8] = { 0, -2, 2, -6, 6, -12, 12, -12 }; static const int16_t ydt2[8] = { 0, -2, 4, -6, 8, -12, 12, -12 }; static const int16_t ydt3[8] = { 4, -6, 20, -20, 46, -46, 94, -94 }; static const int16_t fat_ydt3[8] = { 0, -15, 50, -50, 115, -115, 235, -235 }; static const int16_t ydt4[8] = { 0, -4, 4, -16, 16, -36, 36, -80 }; /* NOTE: This table breaks the [+,-] pattern that the rest of the * tables maintain. Is this intentional? */ static const int16_t fat_ydt4[8] = { 0, 40, 80, -76, 160, -154, 236, -236 }; /* C delta tables, skinny and fat */ static const int16_t cdt1[8] = { 0, -1, 1, -2, 3, -4, 5, -4 }; static const int16_t cdt2[8] = { 0, -4, 3, -16, 20, -32, 36, -32 }; static const int16_t fat_cdt2[8] = { 0, -20, 15, -80, 100, -160, 180, -160 }; static const int16_t cdt3[8] = { 0, -2, 2, -8, 8, -18, 18, -40 }; /* all the delta tables to choose from, at all 4 delta levels */ static const int16_t * const ydts[] = { ydt1, ydt2, ydt3, ydt4, NULL }; static const int16_t * const fat_ydts[] = { fat_ydt3, fat_ydt3, fat_ydt3, fat_ydt4, NULL }; static const int16_t * const cdts[] = { cdt1, cdt1, cdt2, cdt3, NULL }; static const int16_t * const fat_cdts[] = { fat_cdt2, fat_cdt2, fat_cdt2, fat_ydt4, NULL }; static const uint8_t pc_tbl2[] = { 0x8,0x00,0x00,0x00,0x00, 0x8,0x00,0x00,0x00,0x00, 0x8,0x10,0x00,0x00,0x00, 0x8,0x01,0x00,0x00,0x00, 0x8,0x00,0x10,0x00,0x00, 0x8,0x00,0x01,0x00,0x00, 0x8,0x00,0x00,0x10,0x00, 0x8,0x00,0x00,0x01,0x00, 0x8,0x00,0x00,0x00,0x10, 0x8,0x00,0x00,0x00,0x01, 0x6,0x00,0x00,0x00, 0x6,0x10,0x00,0x00, 0x6,0x01,0x00,0x00, 0x6,0x00,0x10,0x00, 0x6,0x00,0x01,0x00, 0x6,0x00,0x00,0x01, 0x6,0x00,0x00,0x10, 0x6,0x00,0x00,0x02, 0x6,0x00,0x00,0x20, 0x6,0x20,0x10,0x00, 0x6,0x00,0x02,0x01, 0x6,0x00,0x20,0x10, 0x6,0x02,0x01,0x00, 0x6,0x11,0x00,0x00, 0x6,0x00,0x20,0x00, 0x6,0x00,0x02,0x00, 0x6,0x20,0x00,0x00, 0x6,0x01,0x10,0x00, 0x6,0x02,0x00,0x00, 0x6,0x01,0x00,0x02, 0x6,0x10,0x00,0x20, 0x6,0x00,0x01,0x02, 0x6,0x10,0x01,0x00, 0x6,0x00,0x10,0x20, 0x6,0x10,0x10,0x00, 0x6,0x10,0x00,0x01, 0x6,0x20,0x00,0x10, 0x6,0x02,0x00,0x01, 0x6,0x01,0x01,0x00, 0x6,0x01,0x00,0x10, 0x6,0x00,0x11,0x00, 0x6,0x10,0x00,0x02, 0x6,0x00,0x01,0x10, 0x6,0x00,0x00,0x11, 0x6,0x10,0x00,0x10, 0x6,0x01,0x00,0x01, 0x6,0x00,0x00,0x22, 0x6,0x02,0x01,0x01, 0x6,0x10,0x20,0x10, 0x6,0x01,0x02,0x01, 0x6,0x20,0x10,0x10, 0x6,0x01,0x00,0x20, 0x6,0x00,0x10,0x01, 0x6,0x21,0x10,0x00, 0x6,0x10,0x02,0x01, 0x6,0x12,0x01,0x00, 0x6,0x01,0x20,0x10, 0x6,0x01,0x02,0x00, 0x6,0x10,0x20,0x00, 0x6,0x00,0x10,0x02, 0x6,0x00,0x01,0x20, 0x6,0x00,0x02,0x21, 0x6,0x00,0x02,0x20, 0x6,0x00,0x00,0x12, 0x6,0x00,0x00,0x21, 0x6,0x20,0x11,0x00, 0x6,0x00,0x01,0x01, 0x6,0x11,0x10,0x00, 0x6,0x00,0x20,0x12, 0x6,0x00,0x20,0x11, 0x6,0x20,0x10,0x02, 0x6,0x02,0x01,0x20, 0x6,0x00,0x22,0x11, 0x6,0x00,0x10,0x10, 0x6,0x02,0x11,0x00, 0x6,0x00,0x21,0x10, 0x6,0x00,0x02,0x03, 0x6,0x20,0x10,0x01, 0x6,0x00,0x12,0x01, 0x4,0x11,0x00, 0x4,0x00,0x22, 0x4,0x20,0x00, 0x4,0x01,0x10, 0x4,0x02,0x20, 0x4,0x00,0x20, 0x4,0x02,0x00, 0x4,0x10,0x01, 0x4,0x00,0x11, 0x4,0x02,0x01, 0x4,0x02,0x21, 0x4,0x00,0x02, 0x4,0x20,0x02, 0x4,0x01,0x01, 0x4,0x10,0x10, 0x4,0x10,0x02, 0x4,0x22,0x00, 0x4,0x10,0x00, 0x4,0x01,0x00, 0x4,0x21,0x00, 0x4,0x12,0x00, 0x4,0x00,0x10, 0x4,0x20,0x12, 0x4,0x01,0x11, 0x4,0x00,0x01, 0x4,0x01,0x02, 0x4,0x11,0x02, 0x4,0x11,0x01, 0x4,0x10,0x20, 0x4,0x20,0x01, 0x4,0x22,0x11, 0x4,0x00,0x12, 0x4,0x20,0x10, 0x4,0x22,0x01, 0x4,0x01,0x20, 0x4,0x00,0x21, 0x4,0x10,0x11, 0x4,0x21,0x10, 0x4,0x10,0x22, 0x4,0x02,0x03, 0x4,0x12,0x01, 0x4,0x20,0x11, 0x4,0x11,0x10, 0x4,0x20,0x30, 0x4,0x11,0x20, 0x4,0x02,0x10, 0x4,0x22,0x10, 0x4,0x11,0x11, 0x4,0x30,0x20, 0x4,0x30,0x00, 0x4,0x01,0x22, 0x4,0x01,0x12, 0x4,0x02,0x11, 0x4,0x03,0x02, 0x4,0x03,0x00, 0x4,0x10,0x21, 0x4,0x12,0x20, 0x4,0x00,0x00, 0x4,0x12,0x21, 0x4,0x21,0x11, 0x4,0x02,0x22, 0x4,0x10,0x12, 0x4,0x31,0x00, 0x4,0x20,0x20, 0x4,0x00,0x03, 0x4,0x02,0x02, 0x4,0x22,0x20, 0x4,0x01,0x21, 0x4,0x21,0x02, 0x4,0x21,0x12, 0x4,0x11,0x22, 0x4,0x00,0x30, 0x4,0x12,0x11, 0x4,0x20,0x22, 0x4,0x31,0x20, 0x4,0x21,0x30, 0x4,0x22,0x02, 0x4,0x22,0x22, 0x4,0x20,0x31, 0x4,0x13,0x02, 0x4,0x03,0x10, 0x4,0x11,0x12, 0x4,0x00,0x13, 0x4,0x21,0x01, 0x4,0x12,0x03, 0x4,0x13,0x00, 0x4,0x13,0x10, 0x4,0x02,0x13, 0x4,0x30,0x01, 0x4,0x12,0x10, 0x4,0x22,0x13, 0x4,0x03,0x12, 0x4,0x31,0x01, 0x4,0x30,0x22, 0x4,0x00,0x31, 0x4,0x01,0x31, 0x4,0x02,0x23, 0x4,0x01,0x30, 0x4,0x11,0x21, 0x4,0x22,0x21, 0x4,0x01,0x13, 0x4,0x10,0x03, 0x4,0x22,0x03, 0x4,0x30,0x21, 0x4,0x21,0x31, 0x4,0x33,0x00, 0x4,0x13,0x12, 0x4,0x11,0x31, 0x4,0x30,0x02, 0x4,0x12,0x02, 0x4,0x11,0x13, 0x4,0x12,0x22, 0x4,0x20,0x32, 0x4,0x10,0x13, 0x4,0x22,0x31, 0x4,0x21,0x20, 0x4,0x01,0x33, 0x4,0x33,0x10, 0x4,0x20,0x13, 0x4,0x31,0x22, 0x4,0x13,0x30, 0x4,0x01,0x03, 0x4,0x11,0x33, 0x4,0x20,0x21, 0x4,0x13,0x31, 0x4,0x03,0x22, 0x4,0x31,0x02, 0x4,0x00,0x24, 0x2,0x00, 0x2,0x10, 0x2,0x20, 0x2,0x30, 0x2,0x40, 0x2,0x50, 0x2,0x60, 0x2,0x01, 0x2,0x11, 0x2,0x21, 0x2,0x31, 0x2,0x41, 0x2,0x51, 0x2,0x61, 0x2,0x02, 0x2,0x12, 0x2,0x22, 0x2,0x32, 0x2,0x42, 0x2,0x52, 0x2,0x62, 0x2,0x03, 0x2,0x13, 0x2,0x23, 0x2,0x33, 0x2,0x43, 0x2,0x53, 0x2,0x63, 0x2,0x04, 0x2,0x14, 0x2,0x24, 0x2,0x34, 0x2,0x44, 0x2,0x54, 0x2,0x64, 0x2,0x05, 0x2,0x15, 0x2,0x25, 0x2,0x35, 0x2,0x45, 0x2,0x55, 0x2,0x65, 0x2,0x06, 0x2,0x16, 0x2,0x26, 0x2,0x36, 0x2,0x46, 0x2,0x56, 0x2,0x66 }; static const uint8_t pc_tbl3[] = { 0x6,0x00,0x00,0x00, 0x6,0x00,0x00,0x00, 0x6,0x00,0x00,0x01, 0x6,0x00,0x00,0x10, 0x6,0x00,0x00,0x11, 0x6,0x00,0x01,0x00, 0x6,0x00,0x01,0x01, 0x6,0x00,0x01,0x10, 0x6,0x00,0x01,0x11, 0x6,0x00,0x10,0x00, 0x6,0x00,0x10,0x01, 0x6,0x00,0x10,0x10, 0x6,0x00,0x10,0x11, 0x6,0x00,0x11,0x00, 0x6,0x00,0x11,0x01, 0x6,0x00,0x11,0x10, 0x6,0x00,0x11,0x11, 0x6,0x01,0x00,0x00, 0x6,0x01,0x00,0x01, 0x6,0x01,0x00,0x10, 0x6,0x01,0x00,0x11, 0x6,0x01,0x01,0x00, 0x6,0x01,0x01,0x01, 0x6,0x01,0x01,0x10, 0x6,0x01,0x01,0x11, 0x6,0x01,0x10,0x00, 0x6,0x01,0x10,0x01, 0x6,0x01,0x10,0x10, 0x6,0x01,0x10,0x11, 0x6,0x01,0x11,0x00, 0x6,0x01,0x11,0x01, 0x6,0x01,0x11,0x10, 0x6,0x01,0x11,0x11, 0x6,0x10,0x00,0x00, 0x6,0x10,0x00,0x01, 0x6,0x10,0x00,0x10, 0x6,0x10,0x00,0x11, 0x6,0x10,0x01,0x00, 0x6,0x10,0x01,0x01, 0x6,0x10,0x01,0x10, 0x6,0x10,0x01,0x11, 0x6,0x10,0x10,0x00, 0x6,0x10,0x10,0x01, 0x6,0x10,0x10,0x10, 0x6,0x10,0x10,0x11, 0x6,0x10,0x11,0x00, 0x6,0x10,0x11,0x01, 0x6,0x10,0x11,0x10, 0x6,0x10,0x11,0x11, 0x6,0x11,0x00,0x00, 0x6,0x11,0x00,0x01, 0x6,0x11,0x00,0x10, 0x6,0x11,0x00,0x11, 0x6,0x11,0x01,0x00, 0x6,0x11,0x01,0x01, 0x6,0x11,0x01,0x10, 0x6,0x11,0x01,0x11, 0x6,0x11,0x10,0x00, 0x6,0x11,0x10,0x01, 0x6,0x11,0x10,0x10, 0x6,0x11,0x10,0x11, 0x6,0x11,0x11,0x00, 0x6,0x11,0x11,0x01, 0x6,0x11,0x11,0x10, 0x4,0x00,0x00, 0x4,0x00,0x01, 0x4,0x00,0x02, 0x4,0x00,0x03, 0x4,0x00,0x10, 0x4,0x00,0x11, 0x4,0x00,0x12, 0x4,0x00,0x13, 0x4,0x00,0x20, 0x4,0x00,0x21, 0x4,0x00,0x22, 0x4,0x00,0x23, 0x4,0x00,0x30, 0x4,0x00,0x31, 0x4,0x00,0x32, 0x4,0x00,0x33, 0x4,0x01,0x00, 0x4,0x01,0x01, 0x4,0x01,0x02, 0x4,0x01,0x03, 0x4,0x01,0x10, 0x4,0x01,0x11, 0x4,0x01,0x12, 0x4,0x01,0x13, 0x4,0x01,0x20, 0x4,0x01,0x21, 0x4,0x01,0x22, 0x4,0x01,0x23, 0x4,0x01,0x30, 0x4,0x01,0x31, 0x4,0x01,0x32, 0x4,0x01,0x33, 0x4,0x02,0x00, 0x4,0x02,0x01, 0x4,0x02,0x02, 0x4,0x02,0x03, 0x4,0x02,0x10, 0x4,0x02,0x11, 0x4,0x02,0x12, 0x4,0x02,0x13, 0x4,0x02,0x20, 0x4,0x02,0x21, 0x4,0x02,0x22, 0x4,0x02,0x23, 0x4,0x02,0x30, 0x4,0x02,0x31, 0x4,0x02,0x32, 0x4,0x02,0x33, 0x4,0x03,0x00, 0x4,0x03,0x01, 0x4,0x03,0x02, 0x4,0x03,0x03, 0x4,0x03,0x10, 0x4,0x03,0x11, 0x4,0x03,0x12, 0x4,0x03,0x13, 0x4,0x03,0x20, 0x4,0x03,0x21, 0x4,0x03,0x22, 0x4,0x03,0x23, 0x4,0x03,0x30, 0x4,0x03,0x31, 0x4,0x03,0x32, 0x4,0x03,0x33, 0x4,0x10,0x00, 0x4,0x10,0x01, 0x4,0x10,0x02, 0x4,0x10,0x03, 0x4,0x10,0x10, 0x4,0x10,0x11, 0x4,0x10,0x12, 0x4,0x10,0x13, 0x4,0x10,0x20, 0x4,0x10,0x21, 0x4,0x10,0x22, 0x4,0x10,0x23, 0x4,0x10,0x30, 0x4,0x10,0x31, 0x4,0x10,0x32, 0x4,0x10,0x33, 0x4,0x11,0x00, 0x4,0x11,0x01, 0x4,0x11,0x02, 0x4,0x11,0x03, 0x4,0x11,0x10, 0x4,0x11,0x11, 0x4,0x11,0x12, 0x4,0x11,0x13, 0x4,0x11,0x20, 0x4,0x11,0x21, 0x4,0x11,0x22, 0x4,0x11,0x23, 0x4,0x11,0x30, 0x4,0x11,0x31, 0x4,0x11,0x32, 0x4,0x11,0x33, 0x4,0x12,0x00, 0x4,0x12,0x01, 0x4,0x12,0x02, 0x4,0x12,0x03, 0x4,0x12,0x10, 0x4,0x12,0x11, 0x4,0x12,0x12, 0x4,0x12,0x13, 0x4,0x12,0x20, 0x4,0x12,0x21, 0x4,0x12,0x22, 0x4,0x12,0x23, 0x4,0x12,0x30, 0x4,0x12,0x31, 0x4,0x12,0x32, 0x4,0x12,0x33, 0x4,0x13,0x00, 0x4,0x13,0x01, 0x4,0x13,0x02, 0x4,0x13,0x03, 0x4,0x13,0x10, 0x4,0x13,0x11, 0x4,0x13,0x12, 0x4,0x13,0x13, 0x4,0x13,0x20, 0x4,0x13,0x21, 0x4,0x13,0x22, 0x4,0x13,0x23, 0x4,0x13,0x30, 0x4,0x13,0x31, 0x4,0x13,0x32, 0x4,0x13,0x33, 0x2,0x00, 0x2,0x10, 0x2,0x20, 0x2,0x30, 0x2,0x40, 0x2,0x50, 0x2,0x60, 0x2,0x70, 0x2,0x01, 0x2,0x11, 0x2,0x21, 0x2,0x31, 0x2,0x41, 0x2,0x51, 0x2,0x61, 0x2,0x71, 0x2,0x02, 0x2,0x12, 0x2,0x22, 0x2,0x32, 0x2,0x42, 0x2,0x52, 0x2,0x62, 0x2,0x72, 0x2,0x03, 0x2,0x13, 0x2,0x23, 0x2,0x33, 0x2,0x43, 0x2,0x53, 0x2,0x63, 0x2,0x73, 0x2,0x04, 0x2,0x14, 0x2,0x24, 0x2,0x34, 0x2,0x44, 0x2,0x54, 0x2,0x64, 0x2,0x74, 0x2,0x05, 0x2,0x15, 0x2,0x25, 0x2,0x35, 0x2,0x45, 0x2,0x55, 0x2,0x65, 0x2,0x75, 0x2,0x06, 0x2,0x16, 0x2,0x26, 0x2,0x36, 0x2,0x46, 0x2,0x56, 0x2,0x66, 0x2,0x76, 0x2,0x07, 0x2,0x17, 0x2,0x27, 0x2,0x37, 0x2,0x47, 0x2,0x57, 0x2,0x67, 0x2,0x77 }; static const uint8_t pc_tbl4[] = { 0x8,0x00,0x00,0x00,0x00, 0x8,0x00,0x00,0x00,0x00, 0x8,0x20,0x00,0x00,0x00, 0x8,0x00,0x00,0x00,0x01, 0x8,0x10,0x00,0x00,0x00, 0x8,0x00,0x00,0x00,0x02, 0x8,0x01,0x00,0x00,0x00, 0x8,0x00,0x00,0x00,0x10, 0x8,0x02,0x00,0x00,0x00, 0x6,0x00,0x00,0x00, 0x6,0x20,0x00,0x00, 0x6,0x00,0x00,0x01, 0x6,0x10,0x00,0x00, 0x6,0x00,0x00,0x02, 0x6,0x00,0x10,0x00, 0x6,0x00,0x20,0x00, 0x6,0x00,0x02,0x00, 0x6,0x00,0x01,0x00, 0x6,0x01,0x00,0x00, 0x6,0x00,0x00,0x20, 0x6,0x02,0x00,0x00, 0x6,0x00,0x00,0x10, 0x6,0x10,0x00,0x20, 0x6,0x01,0x00,0x02, 0x6,0x20,0x00,0x10, 0x6,0x02,0x00,0x01, 0x6,0x20,0x10,0x00, 0x6,0x00,0x12,0x00, 0x6,0x00,0x02,0x01, 0x6,0x02,0x01,0x00, 0x6,0x00,0x21,0x00, 0x6,0x00,0x01,0x02, 0x6,0x00,0x20,0x10, 0x6,0x00,0x00,0x21, 0x6,0x00,0x00,0x12, 0x6,0x00,0x01,0x20, 0x6,0x12,0x00,0x00, 0x6,0x00,0x10,0x20, 0x6,0x01,0x20,0x00, 0x6,0x02,0x10,0x00, 0x6,0x10,0x20,0x00, 0x6,0x01,0x02,0x00, 0x6,0x21,0x00,0x00, 0x6,0x00,0x02,0x10, 0x6,0x20,0x01,0x00, 0x6,0x00,0x22,0x00, 0x6,0x10,0x02,0x00, 0x6,0x00,0x10,0x02, 0x6,0x11,0x00,0x00, 0x6,0x00,0x11,0x00, 0x6,0x22,0x00,0x00, 0x6,0x20,0x00,0x02, 0x6,0x10,0x00,0x01, 0x6,0x00,0x20,0x01, 0x6,0x02,0x20,0x00, 0x6,0x01,0x10,0x00, 0x6,0x01,0x00,0x20, 0x6,0x00,0x20,0x02, 0x6,0x01,0x20,0x02, 0x6,0x10,0x01,0x00, 0x6,0x02,0x00,0x10, 0x6,0x00,0x10,0x01, 0x6,0x10,0x01,0x20, 0x6,0x20,0x02,0x10, 0x6,0x00,0x00,0x22, 0x6,0x10,0x00,0x02, 0x6,0x00,0x02,0x20, 0x6,0x20,0x02,0x00, 0x6,0x00,0x00,0x11, 0x6,0x02,0x10,0x01, 0x6,0x00,0x01,0x10, 0x6,0x00,0x02,0x11, 0x4,0x01,0x02, 0x4,0x02,0x01, 0x4,0x01,0x00, 0x4,0x10,0x20, 0x4,0x20,0x10, 0x4,0x20,0x00, 0x4,0x11,0x00, 0x4,0x02,0x00, 0x4,0x12,0x00, 0x4,0x00,0x21, 0x4,0x22,0x00, 0x4,0x00,0x12, 0x4,0x21,0x00, 0x4,0x02,0x11, 0x4,0x00,0x01, 0x4,0x10,0x02, 0x4,0x02,0x20, 0x4,0x20,0x11, 0x4,0x01,0x10, 0x4,0x21,0x10, 0x4,0x10,0x00, 0x4,0x10,0x22, 0x4,0x20,0x20, 0x4,0x00,0x22, 0x4,0x01,0x22, 0x4,0x20,0x01, 0x4,0x02,0x02, 0x4,0x00,0x20, 0x4,0x00,0x10, 0x4,0x00,0x11, 0x4,0x22,0x01, 0x4,0x11,0x20, 0x4,0x12,0x01, 0x4,0x12,0x20, 0x4,0x11,0x02, 0x4,0x10,0x10, 0x4,0x01,0x01, 0x4,0x02,0x21, 0x4,0x20,0x12, 0x4,0x01,0x12, 0x4,0x22,0x11, 0x4,0x21,0x12, 0x4,0x22,0x10, 0x4,0x21,0x02, 0x4,0x20,0x02, 0x4,0x10,0x01, 0x4,0x00,0x02, 0x4,0x10,0x21, 0x4,0x01,0x20, 0x4,0x11,0x22, 0x4,0x12,0x21, 0x4,0x22,0x20, 0x4,0x02,0x10, 0x4,0x02,0x22, 0x4,0x11,0x10, 0x4,0x22,0x02, 0x4,0x20,0x21, 0x4,0x01,0x11, 0x4,0x11,0x01, 0x4,0x10,0x12, 0x4,0x02,0x12, 0x4,0x20,0x22, 0x4,0x21,0x20, 0x4,0x01,0x21, 0x4,0x12,0x02, 0x4,0x21,0x11, 0x4,0x12,0x22, 0x4,0x12,0x10, 0x4,0x22,0x21, 0x4,0x10,0x11, 0x4,0x21,0x01, 0x4,0x11,0x12, 0x4,0x12,0x11, 0x4,0x66,0x66, 0x4,0x22,0x22, 0x4,0x11,0x21, 0x4,0x11,0x11, 0x4,0x21,0x22, 0x4,0x00,0x00, 0x4,0x22,0x12, 0x4,0x12,0x12, 0x4,0x21,0x21, 0x4,0x42,0x00, 0x4,0x00,0x04, 0x4,0x40,0x00, 0x4,0x30,0x00, 0x4,0x31,0x00, 0x4,0x00,0x03, 0x4,0x00,0x14, 0x4,0x00,0x13, 0x4,0x01,0x24, 0x4,0x20,0x13, 0x4,0x01,0x42, 0x4,0x14,0x20, 0x4,0x42,0x02, 0x4,0x13,0x00, 0x4,0x00,0x24, 0x4,0x31,0x20, 0x4,0x22,0x13, 0x4,0x11,0x24, 0x4,0x12,0x66, 0x4,0x30,0x01, 0x4,0x02,0x13, 0x4,0x12,0x42, 0x4,0x40,0x10, 0x4,0x40,0x02, 0x4,0x01,0x04, 0x4,0x24,0x00, 0x4,0x42,0x10, 0x4,0x21,0x13, 0x4,0x13,0x12, 0x4,0x31,0x21, 0x4,0x21,0x24, 0x4,0x00,0x40, 0x4,0x10,0x24, 0x4,0x10,0x42, 0x4,0x32,0x01, 0x4,0x11,0x42, 0x4,0x20,0x31, 0x4,0x12,0x40, 0x2,0x00, 0x2,0x10, 0x2,0x20, 0x2,0x30, 0x2,0x40, 0x2,0x50, 0x2,0x60, 0x2,0x70, 0x2,0x01, 0x2,0x11, 0x2,0x21, 0x2,0x31, 0x2,0x41, 0x2,0x51, 0x2,0x61, 0x2,0x71, 0x2,0x02, 0x2,0x12, 0x2,0x22, 0x2,0x32, 0x2,0x42, 0x2,0x52, 0x2,0x62, 0x2,0x72, 0x2,0x03, 0x2,0x13, 0x2,0x23, 0x2,0x33, 0x2,0x43, 0x2,0x53, 0x2,0x63, 0x2,0x73, 0x2,0x04, 0x2,0x14, 0x2,0x24, 0x2,0x34, 0x2,0x44, 0x2,0x54, 0x2,0x64, 0x2,0x74, 0x2,0x05, 0x2,0x15, 0x2,0x25, 0x2,0x35, 0x2,0x45, 0x2,0x55, 0x2,0x65, 0x2,0x75, 0x2,0x06, 0x2,0x16, 0x2,0x26, 0x2,0x36, 0x2,0x46, 0x2,0x56, 0x2,0x66, 0x2,0x76, 0x2,0x07, 0x2,0x17, 0x2,0x27, 0x2,0x37, 0x2,0x47, 0x2,0x57, 0x2,0x67, 0x2,0x77 }; static const uint8_t * const tables[] = { pc_tbl2, pc_tbl3, pc_tbl4 }; #endif /* AVCODEC_TRUEMOTION1DATA_H */
123linslouis-android-video-cutter
jni/libavcodec/truemotion1data.h
C
asf20
14,502
/* * AAC encoder * Copyright (C) 2008 Konstantin Shishkov * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * AAC encoder */ /*********************************** * TODOs: * add sane pulse detection * add temporal noise shaping ***********************************/ #include "avcodec.h" #include "put_bits.h" #include "dsputil.h" #include "mpeg4audio.h" #include "aac.h" #include "aactab.h" #include "aacenc.h" #include "psymodel.h" static const uint8_t swb_size_1024_96[] = { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 12, 12, 12, 12, 12, 16, 16, 24, 28, 36, 44, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 }; static const uint8_t swb_size_1024_64[] = { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 12, 12, 12, 16, 16, 16, 20, 24, 24, 28, 36, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 }; static const uint8_t swb_size_1024_48[] = { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 96 }; static const uint8_t swb_size_1024_32[] = { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 }; static const uint8_t swb_size_1024_24[] = { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 16, 16, 16, 20, 20, 24, 24, 28, 28, 32, 36, 36, 40, 44, 48, 52, 52, 64, 64, 64, 64, 64 }; static const uint8_t swb_size_1024_16[] = { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 20, 20, 20, 24, 24, 28, 28, 32, 36, 40, 40, 44, 48, 52, 56, 60, 64, 64, 64 }; static const uint8_t swb_size_1024_8[] = { 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 16, 16, 16, 20, 20, 20, 20, 24, 24, 24, 28, 28, 32, 36, 36, 40, 44, 48, 52, 56, 60, 64, 80 }; static const uint8_t *swb_size_1024[] = { swb_size_1024_96, swb_size_1024_96, swb_size_1024_64, swb_size_1024_48, swb_size_1024_48, swb_size_1024_32, swb_size_1024_24, swb_size_1024_24, swb_size_1024_16, swb_size_1024_16, swb_size_1024_16, swb_size_1024_8 }; static const uint8_t swb_size_128_96[] = { 4, 4, 4, 4, 4, 4, 8, 8, 8, 16, 28, 36 }; static const uint8_t swb_size_128_48[] = { 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 12, 16, 16, 16 }; static const uint8_t swb_size_128_24[] = { 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 16, 16, 20 }; static const uint8_t swb_size_128_16[] = { 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 12, 12, 16, 20, 20 }; static const uint8_t swb_size_128_8[] = { 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 12, 16, 20, 20 }; static const uint8_t *swb_size_128[] = { /* the last entry on the following row is swb_size_128_64 but is a duplicate of swb_size_128_96 */ swb_size_128_96, swb_size_128_96, swb_size_128_96, swb_size_128_48, swb_size_128_48, swb_size_128_48, swb_size_128_24, swb_size_128_24, swb_size_128_16, swb_size_128_16, swb_size_128_16, swb_size_128_8 }; /** default channel configurations */ static const uint8_t aac_chan_configs[6][5] = { {1, TYPE_SCE}, // 1 channel - single channel element {1, TYPE_CPE}, // 2 channels - channel pair {2, TYPE_SCE, TYPE_CPE}, // 3 channels - center + stereo {3, TYPE_SCE, TYPE_CPE, TYPE_SCE}, // 4 channels - front center + stereo + back center {3, TYPE_SCE, TYPE_CPE, TYPE_CPE}, // 5 channels - front center + stereo + back stereo {4, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_LFE}, // 6 channels - front center + stereo + back stereo + LFE }; /** * Make AAC audio config object. * @see 1.6.2.1 "Syntax - AudioSpecificConfig" */ static void put_audio_specific_config(AVCodecContext *avctx) { PutBitContext pb; AACEncContext *s = avctx->priv_data; init_put_bits(&pb, avctx->extradata, avctx->extradata_size*8); put_bits(&pb, 5, 2); //object type - AAC-LC put_bits(&pb, 4, s->samplerate_index); //sample rate index put_bits(&pb, 4, avctx->channels); //GASpecificConfig put_bits(&pb, 1, 0); //frame length - 1024 samples put_bits(&pb, 1, 0); //does not depend on core coder put_bits(&pb, 1, 0); //is not extension flush_put_bits(&pb); } static av_cold int aac_encode_init(AVCodecContext *avctx) { AACEncContext *s = avctx->priv_data; int i; const uint8_t *sizes[2]; int lengths[2]; avctx->frame_size = 1024; for (i = 0; i < 16; i++) if (avctx->sample_rate == ff_mpeg4audio_sample_rates[i]) break; if (i == 16) { av_log(avctx, AV_LOG_ERROR, "Unsupported sample rate %d\n", avctx->sample_rate); return -1; } if (avctx->channels > 6) { av_log(avctx, AV_LOG_ERROR, "Unsupported number of channels: %d\n", avctx->channels); return -1; } if (avctx->profile != FF_PROFILE_UNKNOWN && avctx->profile != FF_PROFILE_AAC_LOW) { av_log(avctx, AV_LOG_ERROR, "Unsupported profile %d\n", avctx->profile); return -1; } if (1024.0 * avctx->bit_rate / avctx->sample_rate > 6144 * avctx->channels) { av_log(avctx, AV_LOG_ERROR, "Too many bits per frame requested\n"); return -1; } s->samplerate_index = i; dsputil_init(&s->dsp, avctx); ff_mdct_init(&s->mdct1024, 11, 0, 1.0); ff_mdct_init(&s->mdct128, 8, 0, 1.0); // window init ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024); ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128); ff_init_ff_sine_windows(10); ff_init_ff_sine_windows(7); s->samples = av_malloc(2 * 1024 * avctx->channels * sizeof(s->samples[0])); s->cpe = av_mallocz(sizeof(ChannelElement) * aac_chan_configs[avctx->channels-1][0]); avctx->extradata = av_malloc(2); avctx->extradata_size = 2; put_audio_specific_config(avctx); sizes[0] = swb_size_1024[i]; sizes[1] = swb_size_128[i]; lengths[0] = ff_aac_num_swb_1024[i]; lengths[1] = ff_aac_num_swb_128[i]; ff_psy_init(&s->psy, avctx, 2, sizes, lengths); s->psypp = ff_psy_preprocess_init(avctx); s->coder = &ff_aac_coders[2]; s->lambda = avctx->global_quality ? avctx->global_quality : 120; ff_aac_tableinit(); if (avctx->channels > 5) av_log(avctx, AV_LOG_ERROR, "This encoder does not yet enforce the restrictions on LFEs. " "The output will most likely be an illegal bitstream.\n"); return 0; } static void apply_window_and_mdct(AVCodecContext *avctx, AACEncContext *s, SingleChannelElement *sce, short *audio, int channel) { int i, j, k; const float * lwindow = sce->ics.use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024; const float * swindow = sce->ics.use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128; const float * pwindow = sce->ics.use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128; if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) { memcpy(s->output, sce->saved, sizeof(float)*1024); if (sce->ics.window_sequence[0] == LONG_STOP_SEQUENCE) { memset(s->output, 0, sizeof(s->output[0]) * 448); for (i = 448; i < 576; i++) s->output[i] = sce->saved[i] * pwindow[i - 448]; for (i = 576; i < 704; i++) s->output[i] = sce->saved[i]; } if (sce->ics.window_sequence[0] != LONG_START_SEQUENCE) { for (i = 0, j = channel; i < 1024; i++, j += avctx->channels) { s->output[i+1024] = audio[j] * lwindow[1024 - i - 1]; sce->saved[i] = audio[j] * lwindow[i]; } } else { for (i = 0, j = channel; i < 448; i++, j += avctx->channels) s->output[i+1024] = audio[j]; for (; i < 576; i++, j += avctx->channels) s->output[i+1024] = audio[j] * swindow[576 - i - 1]; memset(s->output+1024+576, 0, sizeof(s->output[0]) * 448); for (i = 0, j = channel; i < 1024; i++, j += avctx->channels) sce->saved[i] = audio[j]; } ff_mdct_calc(&s->mdct1024, sce->coeffs, s->output); } else { for (k = 0; k < 1024; k += 128) { for (i = 448 + k; i < 448 + k + 256; i++) s->output[i - 448 - k] = (i < 1024) ? sce->saved[i] : audio[channel + (i-1024)*avctx->channels]; s->dsp.vector_fmul (s->output, k ? swindow : pwindow, 128); s->dsp.vector_fmul_reverse(s->output+128, s->output+128, swindow, 128); ff_mdct_calc(&s->mdct128, sce->coeffs + k, s->output); } for (i = 0, j = channel; i < 1024; i++, j += avctx->channels) sce->saved[i] = audio[j]; } } /** * Encode ics_info element. * @see Table 4.6 (syntax of ics_info) */ static void put_ics_info(AACEncContext *s, IndividualChannelStream *info) { int w; put_bits(&s->pb, 1, 0); // ics_reserved bit put_bits(&s->pb, 2, info->window_sequence[0]); put_bits(&s->pb, 1, info->use_kb_window[0]); if (info->window_sequence[0] != EIGHT_SHORT_SEQUENCE) { put_bits(&s->pb, 6, info->max_sfb); put_bits(&s->pb, 1, 0); // no prediction } else { put_bits(&s->pb, 4, info->max_sfb); for (w = 1; w < 8; w++) put_bits(&s->pb, 1, !info->group_len[w]); } } /** * Encode MS data. * @see 4.6.8.1 "Joint Coding - M/S Stereo" */ static void encode_ms_info(PutBitContext *pb, ChannelElement *cpe) { int i, w; put_bits(pb, 2, cpe->ms_mode); if (cpe->ms_mode == 1) for (w = 0; w < cpe->ch[0].ics.num_windows; w += cpe->ch[0].ics.group_len[w]) for (i = 0; i < cpe->ch[0].ics.max_sfb; i++) put_bits(pb, 1, cpe->ms_mask[w*16 + i]); } /** * Produce integer coefficients from scalefactors provided by the model. */ static void adjust_frame_information(AACEncContext *apc, ChannelElement *cpe, int chans) { int i, w, w2, g, ch; int start, sum, maxsfb, cmaxsfb; for (ch = 0; ch < chans; ch++) { IndividualChannelStream *ics = &cpe->ch[ch].ics; start = 0; maxsfb = 0; cpe->ch[ch].pulse.num_pulse = 0; for (w = 0; w < ics->num_windows*16; w += 16) { for (g = 0; g < ics->num_swb; g++) { sum = 0; //apply M/S if (!ch && cpe->ms_mask[w + g]) { for (i = 0; i < ics->swb_sizes[g]; i++) { cpe->ch[0].coeffs[start+i] = (cpe->ch[0].coeffs[start+i] + cpe->ch[1].coeffs[start+i]) / 2.0; cpe->ch[1].coeffs[start+i] = cpe->ch[0].coeffs[start+i] - cpe->ch[1].coeffs[start+i]; } } start += ics->swb_sizes[g]; } for (cmaxsfb = ics->num_swb; cmaxsfb > 0 && cpe->ch[ch].zeroes[w+cmaxsfb-1]; cmaxsfb--) ; maxsfb = FFMAX(maxsfb, cmaxsfb); } ics->max_sfb = maxsfb; //adjust zero bands for window groups for (w = 0; w < ics->num_windows; w += ics->group_len[w]) { for (g = 0; g < ics->max_sfb; g++) { i = 1; for (w2 = w; w2 < w + ics->group_len[w]; w2++) { if (!cpe->ch[ch].zeroes[w2*16 + g]) { i = 0; break; } } cpe->ch[ch].zeroes[w*16 + g] = i; } } } if (chans > 1 && cpe->common_window) { IndividualChannelStream *ics0 = &cpe->ch[0].ics; IndividualChannelStream *ics1 = &cpe->ch[1].ics; int msc = 0; ics0->max_sfb = FFMAX(ics0->max_sfb, ics1->max_sfb); ics1->max_sfb = ics0->max_sfb; for (w = 0; w < ics0->num_windows*16; w += 16) for (i = 0; i < ics0->max_sfb; i++) if (cpe->ms_mask[w+i]) msc++; if (msc == 0 || ics0->max_sfb == 0) cpe->ms_mode = 0; else cpe->ms_mode = msc < ics0->max_sfb ? 1 : 2; } } /** * Encode scalefactor band coding type. */ static void encode_band_info(AACEncContext *s, SingleChannelElement *sce) { int w; for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) s->coder->encode_window_bands_info(s, sce, w, sce->ics.group_len[w], s->lambda); } /** * Encode scalefactors. */ static void encode_scale_factors(AVCodecContext *avctx, AACEncContext *s, SingleChannelElement *sce) { int off = sce->sf_idx[0], diff; int i, w; for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { for (i = 0; i < sce->ics.max_sfb; i++) { if (!sce->zeroes[w*16 + i]) { diff = sce->sf_idx[w*16 + i] - off + SCALE_DIFF_ZERO; if (diff < 0 || diff > 120) av_log(avctx, AV_LOG_ERROR, "Scalefactor difference is too big to be coded\n"); off = sce->sf_idx[w*16 + i]; put_bits(&s->pb, ff_aac_scalefactor_bits[diff], ff_aac_scalefactor_code[diff]); } } } } /** * Encode pulse data. */ static void encode_pulses(AACEncContext *s, Pulse *pulse) { int i; put_bits(&s->pb, 1, !!pulse->num_pulse); if (!pulse->num_pulse) return; put_bits(&s->pb, 2, pulse->num_pulse - 1); put_bits(&s->pb, 6, pulse->start); for (i = 0; i < pulse->num_pulse; i++) { put_bits(&s->pb, 5, pulse->pos[i]); put_bits(&s->pb, 4, pulse->amp[i]); } } /** * Encode spectral coefficients processed by psychoacoustic model. */ static void encode_spectral_coeffs(AACEncContext *s, SingleChannelElement *sce) { int start, i, w, w2; for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { start = 0; for (i = 0; i < sce->ics.max_sfb; i++) { if (sce->zeroes[w*16 + i]) { start += sce->ics.swb_sizes[i]; continue; } for (w2 = w; w2 < w + sce->ics.group_len[w]; w2++) s->coder->quantize_and_encode_band(s, &s->pb, sce->coeffs + start + w2*128, sce->ics.swb_sizes[i], sce->sf_idx[w*16 + i], sce->band_type[w*16 + i], s->lambda); start += sce->ics.swb_sizes[i]; } } } /** * Encode one channel of audio data. */ static int encode_individual_channel(AVCodecContext *avctx, AACEncContext *s, SingleChannelElement *sce, int common_window) { put_bits(&s->pb, 8, sce->sf_idx[0]); if (!common_window) put_ics_info(s, &sce->ics); encode_band_info(s, sce); encode_scale_factors(avctx, s, sce); encode_pulses(s, &sce->pulse); put_bits(&s->pb, 1, 0); //tns put_bits(&s->pb, 1, 0); //ssr encode_spectral_coeffs(s, sce); return 0; } /** * Write some auxiliary information about the created AAC file. */ static void put_bitstream_info(AVCodecContext *avctx, AACEncContext *s, const char *name) { int i, namelen, padbits; namelen = strlen(name) + 2; put_bits(&s->pb, 3, TYPE_FIL); put_bits(&s->pb, 4, FFMIN(namelen, 15)); if (namelen >= 15) put_bits(&s->pb, 8, namelen - 16); put_bits(&s->pb, 4, 0); //extension type - filler padbits = 8 - (put_bits_count(&s->pb) & 7); align_put_bits(&s->pb); for (i = 0; i < namelen - 2; i++) put_bits(&s->pb, 8, name[i]); put_bits(&s->pb, 12 - padbits, 0); } static int aac_encode_frame(AVCodecContext *avctx, uint8_t *frame, int buf_size, void *data) { AACEncContext *s = avctx->priv_data; int16_t *samples = s->samples, *samples2, *la; ChannelElement *cpe; int i, j, chans, tag, start_ch; const uint8_t *chan_map = aac_chan_configs[avctx->channels-1]; int chan_el_counter[4]; FFPsyWindowInfo windows[avctx->channels]; if (s->last_frame) return 0; if (data) { if (!s->psypp) { memcpy(s->samples + 1024 * avctx->channels, data, 1024 * avctx->channels * sizeof(s->samples[0])); } else { start_ch = 0; samples2 = s->samples + 1024 * avctx->channels; for (i = 0; i < chan_map[0]; i++) { tag = chan_map[i+1]; chans = tag == TYPE_CPE ? 2 : 1; ff_psy_preprocess(s->psypp, (uint16_t*)data + start_ch, samples2 + start_ch, start_ch, chans); start_ch += chans; } } } if (!avctx->frame_number) { memcpy(s->samples, s->samples + 1024 * avctx->channels, 1024 * avctx->channels * sizeof(s->samples[0])); return 0; } start_ch = 0; for (i = 0; i < chan_map[0]; i++) { FFPsyWindowInfo* wi = windows + start_ch; tag = chan_map[i+1]; chans = tag == TYPE_CPE ? 2 : 1; cpe = &s->cpe[i]; samples2 = samples + start_ch; la = samples2 + 1024 * avctx->channels + start_ch; if (!data) la = NULL; for (j = 0; j < chans; j++) { IndividualChannelStream *ics = &cpe->ch[j].ics; int k; wi[j] = ff_psy_suggest_window(&s->psy, samples2, la, start_ch + j, ics->window_sequence[0]); ics->window_sequence[1] = ics->window_sequence[0]; ics->window_sequence[0] = wi[j].window_type[0]; ics->use_kb_window[1] = ics->use_kb_window[0]; ics->use_kb_window[0] = wi[j].window_shape; ics->num_windows = wi[j].num_windows; ics->swb_sizes = s->psy.bands [ics->num_windows == 8]; ics->num_swb = s->psy.num_bands[ics->num_windows == 8]; for (k = 0; k < ics->num_windows; k++) ics->group_len[k] = wi[j].grouping[k]; s->cur_channel = start_ch + j; apply_window_and_mdct(avctx, s, &cpe->ch[j], samples2, j); } start_ch += chans; } do { int frame_bits; init_put_bits(&s->pb, frame, buf_size*8); if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & CODEC_FLAG_BITEXACT)) put_bitstream_info(avctx, s, LIBAVCODEC_IDENT); start_ch = 0; memset(chan_el_counter, 0, sizeof(chan_el_counter)); for (i = 0; i < chan_map[0]; i++) { FFPsyWindowInfo* wi = windows + start_ch; tag = chan_map[i+1]; chans = tag == TYPE_CPE ? 2 : 1; cpe = &s->cpe[i]; for (j = 0; j < chans; j++) { s->cur_channel = start_ch + j; ff_psy_set_band_info(&s->psy, s->cur_channel, cpe->ch[j].coeffs, &wi[j]); s->coder->search_for_quantizers(avctx, s, &cpe->ch[j], s->lambda); } cpe->common_window = 0; if (chans > 1 && wi[0].window_type[0] == wi[1].window_type[0] && wi[0].window_shape == wi[1].window_shape) { cpe->common_window = 1; for (j = 0; j < wi[0].num_windows; j++) { if (wi[0].grouping[j] != wi[1].grouping[j]) { cpe->common_window = 0; break; } } } s->cur_channel = start_ch; if (cpe->common_window && s->coder->search_for_ms) s->coder->search_for_ms(s, cpe, s->lambda); adjust_frame_information(s, cpe, chans); put_bits(&s->pb, 3, tag); put_bits(&s->pb, 4, chan_el_counter[tag]++); if (chans == 2) { put_bits(&s->pb, 1, cpe->common_window); if (cpe->common_window) { put_ics_info(s, &cpe->ch[0].ics); encode_ms_info(&s->pb, cpe); } } for (j = 0; j < chans; j++) { s->cur_channel = start_ch + j; encode_individual_channel(avctx, s, &cpe->ch[j], cpe->common_window); } start_ch += chans; } frame_bits = put_bits_count(&s->pb); if (frame_bits <= 6144 * avctx->channels - 3) break; s->lambda *= avctx->bit_rate * 1024.0f / avctx->sample_rate / frame_bits; } while (1); put_bits(&s->pb, 3, TYPE_END); flush_put_bits(&s->pb); avctx->frame_bits = put_bits_count(&s->pb); // rate control stuff if (!(avctx->flags & CODEC_FLAG_QSCALE)) { float ratio = avctx->bit_rate * 1024.0f / avctx->sample_rate / avctx->frame_bits; s->lambda *= ratio; s->lambda = FFMIN(s->lambda, 65536.f); } if (!data) s->last_frame = 1; memcpy(s->samples, s->samples + 1024 * avctx->channels, 1024 * avctx->channels * sizeof(s->samples[0])); return put_bits_count(&s->pb)>>3; } static av_cold int aac_encode_end(AVCodecContext *avctx) { AACEncContext *s = avctx->priv_data; ff_mdct_end(&s->mdct1024); ff_mdct_end(&s->mdct128); ff_psy_end(&s->psy); ff_psy_preprocess_end(s->psypp); av_freep(&s->samples); av_freep(&s->cpe); return 0; } AVCodec aac_encoder = { "aac", AVMEDIA_TYPE_AUDIO, CODEC_ID_AAC, sizeof(AACEncContext), aac_encode_init, aac_encode_frame, aac_encode_end, .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL, .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("Advanced Audio Coding"), };
123linslouis-android-video-cutter
jni/libavcodec/aacenc.c
C
asf20
22,968
/* * VC-1 and WMV3 decoder * copyright (c) 2006 Konstantin Shishkov * (c) 2005 anonymous, Alex Beregszaszi, Michael Niedermayer * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * VC-1 tables. */ #include "avcodec.h" #include "vc1.h" #include "vc1data.h" /** Table for conversion between TTBLK and TTMB */ const int ff_vc1_ttblk_to_tt[3][8] = { { TT_8X4, TT_4X8, TT_8X8, TT_4X4, TT_8X4_TOP, TT_8X4_BOTTOM, TT_4X8_RIGHT, TT_4X8_LEFT }, { TT_8X8, TT_4X8_RIGHT, TT_4X8_LEFT, TT_4X4, TT_8X4, TT_4X8, TT_8X4_BOTTOM, TT_8X4_TOP }, { TT_8X8, TT_4X8, TT_4X4, TT_8X4_BOTTOM, TT_4X8_RIGHT, TT_4X8_LEFT, TT_8X4, TT_8X4_TOP } }; const int ff_vc1_ttfrm_to_tt[4] = { TT_8X8, TT_8X4, TT_4X8, TT_4X4 }; /** MV P mode - the 5th element is only used for mode 1 */ const uint8_t ff_vc1_mv_pmode_table[2][5] = { { MV_PMODE_1MV_HPEL_BILIN, MV_PMODE_1MV, MV_PMODE_1MV_HPEL, MV_PMODE_INTENSITY_COMP, MV_PMODE_MIXED_MV }, { MV_PMODE_1MV, MV_PMODE_MIXED_MV, MV_PMODE_1MV_HPEL, MV_PMODE_INTENSITY_COMP, MV_PMODE_1MV_HPEL_BILIN } }; const uint8_t ff_vc1_mv_pmode_table2[2][4] = { { MV_PMODE_1MV_HPEL_BILIN, MV_PMODE_1MV, MV_PMODE_1MV_HPEL, MV_PMODE_MIXED_MV }, { MV_PMODE_1MV, MV_PMODE_MIXED_MV, MV_PMODE_1MV_HPEL, MV_PMODE_1MV_HPEL_BILIN } }; const int ff_vc1_fps_nr[5] = { 24, 25, 30, 50, 60 }, ff_vc1_fps_dr[2] = { 1000, 1001 }; const uint8_t ff_vc1_pquant_table[3][32] = { { /* Implicit quantizer */ 0, 1, 2, 3, 4, 5, 6, 7, 8, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 29, 31 }, { /* Explicit quantizer, pquantizer uniform */ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 }, { /* Explicit quantizer, pquantizer non-uniform */ 0, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 29, 31 } }; /** @name VC-1 VLC tables and defines * @todo TODO move this into the context */ //@{ #define VC1_BFRACTION_VLC_BITS 7 VLC ff_vc1_bfraction_vlc; #define VC1_IMODE_VLC_BITS 4 VLC ff_vc1_imode_vlc; #define VC1_NORM2_VLC_BITS 3 VLC ff_vc1_norm2_vlc; #define VC1_NORM6_VLC_BITS 9 VLC ff_vc1_norm6_vlc; /* Could be optimized, one table only needs 8 bits */ #define VC1_TTMB_VLC_BITS 9 //12 VLC ff_vc1_ttmb_vlc[3]; #define VC1_MV_DIFF_VLC_BITS 9 //15 VLC ff_vc1_mv_diff_vlc[4]; #define VC1_CBPCY_P_VLC_BITS 9 //14 VLC ff_vc1_cbpcy_p_vlc[4]; #define VC1_4MV_BLOCK_PATTERN_VLC_BITS 6 VLC ff_vc1_4mv_block_pattern_vlc[4]; #define VC1_TTBLK_VLC_BITS 5 VLC ff_vc1_ttblk_vlc[3]; #define VC1_SUBBLKPAT_VLC_BITS 6 VLC ff_vc1_subblkpat_vlc[3]; VLC ff_vc1_ac_coeff_table[8]; //@} #if B_FRACTION_DEN==840 //original bfraction from vc9data.h, not conforming to standard /* bfraction is fractional, we scale to the GCD 3*5*7*8 = 840 */ const int16_t ff_vc1_bfraction_lut[23] = { 420 /*1/2*/, 280 /*1/3*/, 560 /*2/3*/, 210 /*1/4*/, 630 /*3/4*/, 168 /*1/5*/, 336 /*2/5*/, 504 /*3/5*/, 672 /*4/5*/, 140 /*1/6*/, 700 /*5/6*/, 120 /*1/7*/, 240 /*2/7*/, 360 /*3/7*/, 480 /*4/7*/, 600 /*5/7*/, 720 /*6/7*/, 105 /*1/8*/, 315 /*3/8*/, 525 /*5/8*/, 735 /*7/8*/, -1 /*inv.*/, 0 /*BI fm*/ }; #else /* pre-computed scales for all bfractions and base=256 */ const int16_t ff_vc1_bfraction_lut[23] = { 128 /*1/2*/, 85 /*1/3*/, 170 /*2/3*/, 64 /*1/4*/, 192 /*3/4*/, 51 /*1/5*/, 102 /*2/5*/, 153 /*3/5*/, 204 /*4/5*/, 43 /*1/6*/, 215 /*5/6*/, 37 /*1/7*/, 74 /*2/7*/, 111 /*3/7*/, 148 /*4/7*/, 185 /*5/7*/, 222 /*6/7*/, 32 /*1/8*/, 96 /*3/8*/, 160 /*5/8*/, 224 /*7/8*/, -1 /*inv.*/, 0 /*BI fm*/ }; #endif const uint8_t ff_vc1_bfraction_bits[23] = { 3, 3, 3, 3, 3, 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }; const uint8_t ff_vc1_bfraction_codes[23] = { 0, 1, 2, 3, 4, 5, 6, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127 }; //Same as H.264 const AVRational ff_vc1_pixel_aspect[16]={ {0, 1}, {1, 1}, {12, 11}, {10, 11}, {16, 11}, {40, 33}, {24, 11}, {20, 11}, {32, 11}, {80, 33}, {18, 11}, {15, 11}, {64, 33}, {160, 99}, {0, 1}, {0, 1} }; /* BitPlane IMODE - such a small table... */ const uint8_t ff_vc1_imode_codes[7] = { 0, 2, 1, 3, 1, 2, 3 }; const uint8_t ff_vc1_imode_bits[7] = { 4, 2, 3, 2, 4, 3, 3 }; /* Normal-2 imode */ const uint8_t ff_vc1_norm2_codes[4] = { 0, 4, 5, 3 }; const uint8_t ff_vc1_norm2_bits[4] = { 1, 3, 3, 2 }; const uint16_t ff_vc1_norm6_codes[64] = { 0x001, 0x002, 0x003, 0x000, 0x004, 0x001, 0x002, 0x047, 0x005, 0x003, 0x004, 0x04B, 0x005, 0x04D, 0x04E, 0x30E, 0x006, 0x006, 0x007, 0x053, 0x008, 0x055, 0x056, 0x30D, 0x009, 0x059, 0x05A, 0x30C, 0x05C, 0x30B, 0x30A, 0x037, 0x007, 0x00A, 0x00B, 0x043, 0x00C, 0x045, 0x046, 0x309, 0x00D, 0x049, 0x04A, 0x308, 0x04C, 0x307, 0x306, 0x036, 0x00E, 0x051, 0x052, 0x305, 0x054, 0x304, 0x303, 0x035, 0x058, 0x302, 0x301, 0x034, 0x300, 0x033, 0x032, 0x007, }; const uint8_t ff_vc1_norm6_bits[64] = { 1, 4, 4, 8, 4, 8, 8, 10, 4, 8, 8, 10, 8, 10, 10, 13, 4, 8, 8, 10, 8, 10, 10, 13, 8, 10, 10, 13, 10, 13, 13, 9, 4, 8, 8, 10, 8, 10, 10, 13, 8, 10, 10, 13, 10, 13, 13, 9, 8, 10, 10, 13, 10, 13, 13, 9, 10, 13, 13, 9, 13, 9, 9, 6, }; #if 0 /* Normal-6 imode */ const uint8_t ff_vc1_norm6_spec[64][5] = { { 0, 1, 1 }, { 1, 2, 4 }, { 2, 3, 4 }, { 3, 0, 8 }, { 4, 4, 4 }, { 5, 1, 8 }, { 6, 2, 8 }, { 7, 2, 5, 7, 5 }, { 8, 5, 4 }, { 9, 3, 8 }, {10, 4, 8 }, {11, 2, 5, 11, 5 }, {12, 5, 8 }, {13, 2, 5, 13, 5 }, {14, 2, 5, 14, 5 }, {15, 3, 5, 14, 8 }, {16, 6, 4 }, {17, 6, 8 }, {18, 7, 8 }, {19, 2, 5, 19, 5 }, {20, 8, 8 }, {21, 2, 5, 21, 5 }, {22, 2, 5, 22, 5 }, {23, 3, 5, 13, 8 }, {24, 9, 8 }, {25, 2, 5, 25, 5 }, {26, 2, 5, 26, 5 }, {27, 3, 5, 12, 8 }, {28, 2, 5, 28, 5 }, {29, 3, 5, 11, 8 }, {30, 3, 5, 10, 8 }, {31, 3, 5, 7, 4 }, {32, 7, 4 }, {33, 10, 8 }, {34, 11, 8 }, {35, 2, 5, 3, 5 }, {36, 12, 8 }, {37, 2, 5, 5, 5 }, {38, 2, 5, 6, 5 }, {39, 3, 5, 9, 8 }, {40, 13, 8 }, {41, 2, 5, 9, 5 }, {42, 2, 5, 10, 5 }, {43, 3, 5, 8, 8 }, {44, 2, 5, 12, 5 }, {45, 3, 5, 7, 8 }, {46, 3, 5, 6, 8 }, {47, 3, 5, 6, 4 }, {48, 14, 8 }, {49, 2, 5, 17, 5 }, {50, 2, 5, 18, 5 }, {51, 3, 5, 5, 8 }, {52, 2, 5, 20, 5 }, {53, 3, 5, 4, 8 }, {54, 3, 5, 3, 8 }, {55, 3, 5, 5, 4 }, {56, 2, 5, 24, 5 }, {57, 3, 5, 2, 8 }, {58, 3, 5, 1, 8 }, {59, 3, 5, 4, 4 }, {60, 3, 5, 0, 8 }, {61, 3, 5, 3, 4 }, {62, 3, 5, 2, 4 }, {63, 3, 5, 1, 1 }, }; #endif /* 4MV Block pattern VLC tables */ const uint8_t ff_vc1_4mv_block_pattern_codes[4][16] = { { 14, 58, 59, 25, 12, 26, 15, 15, 13, 24, 27, 0, 28, 1, 2, 2}, { 8, 18, 19, 4, 20, 5, 30, 11, 21, 31, 6, 12, 7, 13, 14, 0}, { 15, 6, 7, 2, 8, 3, 28, 9, 10, 29, 4, 11, 5, 12, 13, 0}, { 0, 11, 12, 4, 13, 5, 30, 16, 14, 31, 6, 17, 7, 18, 19, 10} }; const uint8_t ff_vc1_4mv_block_pattern_bits[4][16] = { { 5, 6, 6, 5, 5, 5, 5, 4, 5, 5, 5, 3, 5, 3, 3, 2}, { 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4, 4, 4, 4, 4, 2}, { 4, 4, 4, 4, 4, 4, 5, 4, 4, 5, 4, 4, 4, 4, 4, 3}, { 2, 4, 4, 4, 4, 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4} }; 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 }; /* P-Picture CBPCY VLC tables */ #if 1 // Looks like original tables are not conforming to standard at all. Are they used for old WMV? const uint16_t ff_vc1_cbpcy_p_codes[4][64] = { { 0, 6, 15, 13, 13, 11, 3, 13, 5, 8, 49, 10, 12, 114, 102, 119, 1, 54, 96, 8, 10, 111, 5, 15, 12, 10, 2, 12, 13, 115, 53, 63, 1, 7, 1, 7, 14, 12, 4, 14, 1, 9, 97, 11, 7, 58, 52, 62, 4, 103, 1, 9, 11, 56, 101, 118, 4, 110, 100, 30, 2, 5, 4, 3 }, { 0, 9, 1, 18, 5, 14, 237, 26, 3, 121, 3, 22, 13, 16, 6, 30, 2, 10, 1, 20, 12, 241, 5, 28, 16, 12, 3, 24, 28, 124, 239, 247, 1, 240, 1, 19, 18, 15, 4, 27, 1, 122, 2, 23, 1, 17, 7, 31, 1, 11, 2, 21, 19, 246, 238, 29, 17, 13, 236, 25, 58, 63, 8, 125 }, { 0, 201, 25, 231, 5, 221, 1, 3, 2, 414, 2, 241, 16, 225, 195, 492, 2, 412, 1, 240, 7, 224, 98, 245, 1, 220, 96, 5, 9, 230, 101, 247, 1, 102, 1, 415, 24, 3, 2, 244, 3, 54, 3, 484, 17, 114, 200, 493, 3, 413, 1, 4, 13, 113, 99, 485, 4, 111, 194, 243, 5, 29, 26, 31 }, { 0, 28, 12, 44, 3, 36, 20, 52, 2, 32, 16, 48, 8, 40, 24, 28, 1, 30, 14, 46, 6, 38, 22, 54, 3, 34, 18, 50, 10, 42, 26, 30, 1, 29, 13, 45, 5, 37, 21, 53, 2, 33, 17, 49, 9, 41, 25, 29, 1, 31, 15, 47, 7, 39, 23, 55, 4, 35, 19, 51, 11, 43, 27, 31 } }; const uint8_t ff_vc1_cbpcy_p_bits[4][64] = { { 13, 13, 7, 13, 7, 13, 13, 12, 6, 13, 7, 12, 6, 8, 8, 8, 5, 7, 8, 12, 6, 8, 13, 12, 7, 13, 13, 12, 6, 8, 7, 7, 6, 13, 8, 12, 7, 13, 13, 12, 7, 13, 8, 12, 5, 7, 7, 7, 6, 8, 13, 12, 6, 7, 8, 8, 5, 8, 8, 6, 3, 3, 3, 2 }, { 14, 13, 8, 13, 3, 13, 8, 13, 3, 7, 8, 13, 4, 13, 13, 13, 3, 13, 13, 13, 4, 8, 13, 13, 5, 13, 13, 13, 5, 7, 8, 8, 3, 8, 14, 13, 5, 13, 13, 13, 4, 7, 13, 13, 6, 13, 13, 13, 5, 13, 8, 13, 5, 8, 8, 13, 5, 13, 8, 13, 6, 6, 13, 7 }, { 13, 8, 6, 8, 4, 8, 13, 12, 4, 9, 8, 8, 5, 8, 8, 9, 5, 9, 10, 8, 4, 8, 7, 8, 6, 8, 7, 13, 4, 8, 7, 8, 5, 7, 8, 9, 6, 13, 13, 8, 4, 6, 8, 9, 5, 7, 8, 9, 5, 9, 9, 13, 5, 7, 7, 9, 4, 7, 8, 8, 3, 5, 5, 5 }, { 9, 9, 9, 9, 2, 9, 9, 9, 2, 9, 9, 9, 9, 9, 9, 8, 3, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8 } }; #else const uint16_t ff_vc1_cbpcy_p_codes[4][64] = { { 0, 1, 1, 4, 5, 1, 12, 4, 13, 14, 10, 11, 12, 7, 13, 2, 15, 1, 96, 1, 49, 97, 2, 100, 3, 4, 5, 101, 102, 52, 53, 4, 6, 7, 54, 103, 8, 9, 10, 110, 11, 12, 111, 56, 114, 58, 115, 5, 13, 7, 8, 9, 10, 11, 12, 30, 13, 14, 15, 118, 119, 62, 63, 3 }, { 0, 1, 2, 1, 3, 1, 16, 17, 5, 18, 12, 19, 13, 1, 28, 58, 1, 1, 1, 2, 3, 2, 3, 236, 237, 4, 5, 238, 6, 7, 239, 8, 9, 240, 10, 11, 121, 122, 12, 13, 14, 15, 241, 246, 16, 17, 124, 63, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 247, 125 }, { 0, 1, 2, 3, 2, 3, 1, 4, 5, 24, 7, 13, 16, 17, 9, 5, 25, 1, 1, 1, 2, 3, 96, 194, 1, 2, 98, 99, 195, 200, 101, 26, 201, 102, 412, 413, 414, 54, 220, 111, 221, 3, 224, 113, 225, 114, 230, 29, 231, 415, 240, 4, 241, 484, 5, 243, 3, 244, 245, 485, 492, 493, 247, 31 }, { 0, 1, 1, 1, 2, 2, 3, 4, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 28, 29, 30, 31 } }; const uint8_t ff_vc1_cbpcy_p_bits[4][64] = { { 13, 6, 5, 6, 6, 7, 7, 5, 7, 7, 6, 6, 6, 5, 6, 3, 7, 8, 8, 13, 7, 8, 13, 8, 13, 13, 13, 8, 8, 7, 7, 3, 13, 13, 7, 8, 13, 13, 13, 8, 13, 13, 8, 7, 8, 7, 8, 3, 13, 12, 12, 12, 12, 12, 12, 6, 12, 12, 12, 8, 8, 7, 7, 2 }, { 14, 3, 3, 5, 3, 4, 5, 5, 3, 5, 4, 5, 4, 6, 5, 6, 8, 14, 13, 8, 8, 13, 13, 8, 8, 13, 13, 8, 13, 13, 8, 13, 13, 8, 13, 13, 7, 7, 13, 13, 13, 13, 8, 8, 13, 13, 7, 6, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 8, 7 }, { 13, 5, 5, 5, 4, 4, 6, 4, 4, 6, 4, 5, 5, 5, 4, 3, 6, 8, 10, 9, 8, 8, 7, 8, 13, 13, 7, 7, 8, 8, 7, 5, 8, 7, 9, 9, 9, 6, 8, 7, 8, 13, 8, 7, 8, 7, 8, 5, 8, 9, 8, 13, 8, 9, 13, 8, 12, 8, 8, 9, 9, 9, 8, 5 }, { 9, 2, 3, 9, 2, 9, 9, 9, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8 } }; #endif /* MacroBlock Transform Type: 7.1.3.11, p89 * 8x8:B * 8x4:B:btm 8x4:B:top 8x4:B:both, * 4x8:B:right 4x8:B:left 4x8:B:both * 4x4:B 8x8:MB * 8x4:MB:btm 8x4:MB:top 8x4,MB,both * 4x8,MB,right 4x8,MB,left * 4x4,MB */ const uint16_t ff_vc1_ttmb_codes[3][16] = { { 0x0003, 0x002E, 0x005F, 0x0000, 0x0016, 0x0015, 0x0001, 0x0004, 0x0014, 0x02F1, 0x0179, 0x017B, 0x0BC0, 0x0BC1, 0x05E1, 0x017A }, { 0x0006, 0x0006, 0x0003, 0x0007, 0x000F, 0x000E, 0x0000, 0x0002, 0x0002, 0x0014, 0x0011, 0x000B, 0x0009, 0x0021, 0x0015, 0x0020 }, { 0x0006, 0x0000, 0x000E, 0x0005, 0x0002, 0x0003, 0x0003, 0x000F, 0x0002, 0x0081, 0x0021, 0x0009, 0x0101, 0x0041, 0x0011, 0x0100 } }; const uint8_t ff_vc1_ttmb_bits[3][16] = { { 2, 6, 7, 2, 5, 5, 2, 3, 5, 10, 9, 9, 12, 12, 11, 9 }, { 3, 4, 4, 4, 4, 4, 3, 3, 2, 7, 7, 6, 6, 8, 7, 8 }, { 3, 3, 4, 5, 3, 3, 4, 4, 2, 10, 8, 6, 11, 9, 7, 11 } }; /* TTBLK (Transform Type per Block) tables */ const uint8_t ff_vc1_ttblk_codes[3][8] = { { 0, 1, 3, 5, 16, 17, 18, 19}, { 3, 0, 1, 2, 3, 5, 8, 9}, { 1, 0, 1, 4, 6, 7, 10, 11} }; const uint8_t ff_vc1_ttblk_bits[3][8] = { { 2, 2, 2, 3, 5, 5, 5, 5}, { 2, 3, 3, 3, 3, 3, 4, 4}, { 2, 3, 3, 3, 3, 3, 4, 4} }; /* SUBBLKPAT tables, p93-94, reordered */ const uint8_t ff_vc1_subblkpat_codes[3][15] = { { 14, 12, 7, 11, 9, 26, 2, 10, 27, 8, 0, 6, 1, 15, 1}, { 14, 0, 8, 15, 10, 4, 23, 13, 5, 9, 25, 3, 24, 22, 1}, { 5, 6, 2, 2, 8, 0, 28, 3, 1, 3, 29, 1, 19, 18, 15} }; const uint8_t ff_vc1_subblkpat_bits[3][15] = { { 5, 5, 5, 5, 5, 6, 4, 5, 6, 5, 4, 5, 4, 5, 1}, { 4, 3, 4, 4, 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 2}, { 3, 3, 4, 3, 4, 5, 5, 3, 5, 4, 5, 4, 5, 5, 4} }; /* MV differential tables, p265 */ const uint16_t ff_vc1_mv_diff_codes[4][73] = { { 0, 2, 3, 8, 576, 3, 2, 6, 5, 577, 578, 7, 8, 9, 40, 19, 37, 82, 21, 22, 23, 579, 580, 166, 96, 167, 49, 194, 195, 581, 582, 583, 292, 293, 294, 13, 2, 7, 24, 50, 102, 295, 13, 7, 8, 18, 50, 103, 38, 20, 21, 22, 39, 204, 103, 23, 24, 25, 104, 410, 105, 106, 107, 108, 109, 220, 411, 442, 222, 443, 446, 447, 7 /* 73 elements */ }, { 0, 4, 5, 3, 4, 3, 4, 5, 20, 6, 21, 44, 45, 46, 3008, 95, 112, 113, 57, 3009, 3010, 116, 117, 3011, 118, 3012, 3013, 3014, 3015, 3016, 3017, 3018, 3019, 3020, 3021, 3022, 1, 4, 15, 160, 161, 41, 6, 11, 42, 162, 43, 119, 56, 57, 58, 163, 236, 237, 3023, 119, 120, 242, 122, 486, 1512, 487, 246, 494, 1513, 495, 1514, 1515, 1516, 1517, 1518, 1519, 31 /* 73 elements */ }, { 0, 512, 513, 514, 515, 2, 3, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 1, 5, 287, 288, 289, 290, 6, 7, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319 /* 73 elements */ }, { 0, 1, 1, 2, 3, 4, 1, 5, 4, 3, 5, 8, 6, 9, 10, 11, 12, 7, 104, 14, 105, 4, 10, 15, 11, 6, 14, 8, 106, 107, 108, 15, 109, 9, 55, 10, 1, 2, 1, 2, 3, 12, 6, 2, 6, 7, 28, 7, 15, 8, 5, 18, 29, 152, 77, 24, 25, 26, 39, 108, 13, 109, 55, 56, 57, 116, 11, 153, 234, 235, 118, 119, 15 /* 73 elements */ } }; const uint8_t ff_vc1_mv_diff_bits[4][73] = { { 6, 7, 7, 8, 14, 6, 5, 6, 7, 14, 14, 6, 6, 6, 8, 9, 10, 9, 7, 7, 7, 14, 14, 10, 9, 10, 8, 10, 10, 14, 14, 14, 13, 13, 13, 6, 3, 5, 6, 8, 9, 13, 5, 4, 4, 5, 7, 9, 6, 5, 5, 5, 6, 9, 8, 5, 5, 5, 7, 10, 7, 7, 7, 7, 7, 8, 10, 9, 8, 9, 9, 9, 3 /* 73 elements */ }, { 5, 7, 7, 6, 6, 5, 5, 6, 7, 5, 7, 8, 8, 8, 14, 9, 9, 9, 8, 14, 14, 9, 9, 14, 9, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 2, 3, 6, 8, 8, 6, 3, 4, 6, 8, 6, 9, 6, 6, 6, 8, 8, 8, 14, 7, 7, 8, 7, 9, 13, 9, 8, 9, 13, 9, 13, 13, 13, 13, 13, 13, 5 /* 73 elements */ }, { 3, 12, 12, 12, 12, 3, 4, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 1, 5, 11, 11, 11, 11, 4, 4, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11 /* 73 elements */ }, { 15, 11, 15, 15, 15, 15, 12, 15, 12, 11, 12, 12, 15, 12, 12, 12, 12, 15, 15, 12, 15, 10, 11, 12, 11, 10, 11, 10, 15, 15, 15, 11, 15, 10, 14, 10, 4, 4, 5, 7, 8, 9, 5, 3, 4, 5, 6, 8, 5, 4, 3, 5, 6, 8, 7, 5, 5, 5, 6, 7, 9, 7, 6, 6, 6, 7, 10, 8, 8, 8, 7, 7, 4 /* 73 elements */ } }; /* DC differentials low+hi-mo, p217 are the same as in msmpeg4data .h */ /* Table 232 */ const int8_t ff_vc1_simple_progressive_4x4_zz [16] = { 0, 8, 16, 1, 9, 24, 17, 2, 10, 18, 25, 3, 11, 26, 19, 27 }; const int8_t ff_vc1_adv_progressive_8x4_zz [32] = /* Table 233 */ { 0, 8, 1, 16, 2, 9, 10, 3, 24, 17, 4, 11, 18, 12, 5, 19, 25, 13, 20, 26, 27, 6, 21, 28, 14, 22, 29, 7, 30, 15, 23, 31 }; const int8_t ff_vc1_adv_progressive_4x8_zz [32] = /* Table 234 */ { 0, 1, 8, 2, 9, 16, 17, 24, 10, 32, 25, 18, 40, 3, 33, 26, 48, 11, 56, 41, 34, 49, 57, 42, 19, 50, 27, 58, 35, 43, 51, 59 }; const int8_t ff_vc1_adv_interlaced_8x8_zz [64] = /* Table 235 */ { 0, 8, 1, 16, 24, 9, 2, 32, 40, 48, 56, 17, 10, 3, 25, 18, 11, 4, 33, 41, 49, 57, 26, 34, 42, 50, 58, 19, 12, 5, 27, 20, 13, 6, 35, 28, 21, 14, 7, 15, 22, 29, 36, 43, 51, 59, 60, 52, 44, 37, 30, 23, 31, 38, 45, 53, 61, 62, 54, 46, 39, 47, 55, 63 }; const int8_t ff_vc1_adv_interlaced_8x4_zz [32] = /* Table 236 */ { 0, 8, 16, 24, 1, 9, 2, 17, 25, 10, 3, 18, 26, 4, 11, 19, 12, 5, 13, 20, 27, 6, 21, 28, 14, 22, 29, 7, 30, 15, 23, 31 }; const int8_t ff_vc1_adv_interlaced_4x8_zz [32] = /* Table 237 */ { 0, 1, 2, 8, 16, 9, 24, 17, 10, 3, 32, 40, 48, 56, 25, 18, 33, 26, 41, 34, 49, 57, 11, 42, 19, 50, 27, 58, 35, 43, 51, 59 }; const int8_t ff_vc1_adv_interlaced_4x4_zz [16] = /* Table 238 */ { 0, 8, 16, 24, 1, 9, 17, 2, 25, 10, 18, 3, 26, 11, 19, 27 }; /* DQScale as specified in 8.1.3.9 - almost identical to 0x40000/i */ const int32_t ff_vc1_dqscale[63] = { 0x40000, 0x20000, 0x15555, 0x10000, 0xCCCD, 0xAAAB, 0x9249, 0x8000, 0x71C7, 0x6666, 0x5D17, 0x5555, 0x4EC5, 0x4925, 0x4444, 0x4000, 0x3C3C, 0x38E4, 0x35E5, 0x3333, 0x30C3, 0x2E8C, 0x2C86, 0x2AAB, 0x28F6, 0x2762, 0x25ED, 0x2492, 0x234F, 0x2222, 0x2108, 0x2000, 0x1F08, 0x1E1E, 0x1D42, 0x1C72, 0x1BAD, 0x1AF3, 0x1A42, 0x199A, 0x18FA, 0x1862, 0x17D0, 0x1746, 0x16C1, 0x1643, 0x15CA, 0x1555, 0x14E6, 0x147B, 0x1414, 0x13B1, 0x1352, 0x12F7, 0x129E, 0x1249, 0x11F7, 0x11A8, 0x115B, 0x1111, 0x10C9, 0x1084, 0x1000 };
123linslouis-android-video-cutter
jni/libavcodec/vc1data.c
C
asf20
22,224
/* * MPEG Audio header decoder * Copyright (c) 2001, 2002 Fabrice Bellard * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * MPEG Audio header decoder. */ #ifndef AVCODEC_MPEGAUDIODECHEADER_H #define AVCODEC_MPEGAUDIODECHEADER_H #include "libavutil/common.h" #include "mpegaudio.h" /* header decoding. MUST check the header before because no consistency check is done there. Return 1 if free format found and that the frame size must be computed externally */ int ff_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header); #endif /* AVCODEC_MPEGAUDIODECHEADER_H */
123linslouis-android-video-cutter
jni/libavcodec/mpegaudiodecheader.h
C
asf20
1,314
/* * Spectral Band Replication definitions and structures * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl ) * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * Spectral Band Replication definitions and structures * @author Robert Swain ( rob opendot cl ) */ #ifndef AVCODEC_SBR_H #define AVCODEC_SBR_H #include <stdint.h> #include "fft.h" #include "aacps.h" /** * Spectral Band Replication header - spectrum parameters that invoke a reset if they differ from the previous header. */ typedef struct { uint8_t bs_start_freq; uint8_t bs_stop_freq; uint8_t bs_xover_band; /** * @defgroup bs_header_extra_1 Variables associated with bs_header_extra_1 * @{ */ uint8_t bs_freq_scale; uint8_t bs_alter_scale; uint8_t bs_noise_bands; /** @} */ } SpectrumParameters; #define SBR_SYNTHESIS_BUF_SIZE ((1280-128)*2) /** * Spectral Band Replication per channel data */ typedef struct { /** * @defgroup bitstream Main bitstream data variables * @{ */ unsigned bs_frame_class; unsigned bs_add_harmonic_flag; unsigned bs_num_env; uint8_t bs_freq_res[7]; unsigned bs_num_noise; uint8_t bs_df_env[5]; uint8_t bs_df_noise[2]; uint8_t bs_invf_mode[2][5]; uint8_t bs_add_harmonic[48]; unsigned bs_amp_res; /** @} */ /** * @defgroup state State variables * @{ */ DECLARE_ALIGNED(16, float, synthesis_filterbank_samples)[SBR_SYNTHESIS_BUF_SIZE]; DECLARE_ALIGNED(16, float, analysis_filterbank_samples) [1312]; int synthesis_filterbank_samples_offset; ///l_APrev and l_A int e_a[2]; ///Chirp factors float bw_array[5]; ///QMF values of the original signal float W[2][32][32][2]; ///QMF output of the HF adjustor float Y[2][38][64][2]; float g_temp[42][48]; float q_temp[42][48]; uint8_t s_indexmapped[8][48]; ///Envelope scalefactors float env_facs[6][48]; ///Noise scalefactors float noise_facs[3][5]; ///Envelope time borders uint8_t t_env[8]; ///Envelope time border of the last envelope of the previous frame uint8_t t_env_num_env_old; ///Noise time borders uint8_t t_q[3]; unsigned f_indexnoise; unsigned f_indexsine; /** @} */ } SBRData; /** * Spectral Band Replication */ typedef struct { int sample_rate; int start; int reset; SpectrumParameters spectrum_params; int bs_amp_res_header; /** * @defgroup bs_header_extra_2 variables associated with bs_header_extra_2 * @{ */ unsigned bs_limiter_bands; unsigned bs_limiter_gains; unsigned bs_interpol_freq; unsigned bs_smoothing_mode; /** @} */ unsigned bs_coupling; unsigned k[5]; ///< k0, k1, k2 ///kx', and kx respectively, kx is the first QMF subband where SBR is used. ///kx' is its value from the previous frame unsigned kx[2]; ///M' and M respectively, M is the number of QMF subbands that use SBR. unsigned m[2]; ///The number of frequency bands in f_master unsigned n_master; SBRData data[2]; PSContext ps; ///N_Low and N_High respectively, the number of frequency bands for low and high resolution unsigned n[2]; ///Number of noise floor bands unsigned n_q; ///Number of limiter bands unsigned n_lim; ///The master QMF frequency grouping uint16_t f_master[49]; ///Frequency borders for low resolution SBR uint16_t f_tablelow[25]; ///Frequency borders for high resolution SBR uint16_t f_tablehigh[49]; ///Frequency borders for noise floors uint16_t f_tablenoise[6]; ///Frequency borders for the limiter uint16_t f_tablelim[29]; unsigned num_patches; uint8_t patch_num_subbands[6]; uint8_t patch_start_subband[6]; ///QMF low frequency input to the HF generator float X_low[32][40][2]; ///QMF output of the HF generator float X_high[64][40][2]; ///QMF values of the reconstructed signal DECLARE_ALIGNED(16, float, X)[2][2][38][64]; ///Zeroth coefficient used to filter the subband signals float alpha0[64][2]; ///First coefficient used to filter the subband signals float alpha1[64][2]; ///Dequantized envelope scalefactors, remapped float e_origmapped[7][48]; ///Dequantized noise scalefactors, remapped float q_mapped[7][48]; ///Sinusoidal presence, remapped uint8_t s_mapped[7][48]; ///Estimated envelope float e_curr[7][48]; ///Amplitude adjusted noise scalefactors float q_m[7][48]; ///Sinusoidal levels float s_m[7][48]; float gain[7][48]; DECLARE_ALIGNED(16, float, qmf_filter_scratch)[5][64]; FFTContext mdct_ana; FFTContext mdct; } SpectralBandReplication; #endif /* AVCODEC_SBR_H */
123linslouis-android-video-cutter
jni/libavcodec/sbr.h
C
asf20
6,320
/* * AAC Spectral Band Replication function declarations * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl ) * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * AAC Spectral Band Replication function declarations * @author Robert Swain ( rob opendot cl ) */ #ifndef AVCODEC_AACSBR_H #define AVCODEC_AACSBR_H #include "get_bits.h" #include "aac.h" #include "sbr.h" /** Initialize SBR. */ av_cold void ff_aac_sbr_init(void); /** Initialize one SBR context. */ av_cold void ff_aac_sbr_ctx_init(SpectralBandReplication *sbr); /** Close one SBR context. */ av_cold void ff_aac_sbr_ctx_close(SpectralBandReplication *sbr); /** Decode one SBR element. */ int ff_decode_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, int crc, int cnt, int id_aac); /** Apply one SBR element to one AAC element. */ void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac, float* L, float *R); #endif /* AVCODEC_AACSBR_H */
123linslouis-android-video-cutter
jni/libavcodec/aacsbr.h
C
asf20
1,803
/* * XSUB subtitle decoder * Copyright (c) 2007 Reimar Döffinger * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avcodec.h" #include "get_bits.h" #include "bytestream.h" static av_cold int decode_init(AVCodecContext *avctx) { avctx->pix_fmt = PIX_FMT_PAL8; return 0; } static const uint8_t tc_offsets[9] = { 0, 1, 3, 4, 6, 7, 9, 10, 11 }; static const uint8_t tc_muls[9] = { 10, 6, 10, 6, 10, 10, 10, 10, 1 }; static int64_t parse_timecode(const uint8_t *buf, int64_t packet_time) { int i; int64_t ms = 0; if (buf[2] != ':' || buf[5] != ':' || buf[8] != '.') return AV_NOPTS_VALUE; for (i = 0; i < sizeof(tc_offsets); i++) { uint8_t c = buf[tc_offsets[i]] - '0'; if (c > 9) return AV_NOPTS_VALUE; ms = (ms + c) * tc_muls[i]; } return ms - packet_time; } static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; AVSubtitle *sub = data; const uint8_t *buf_end = buf + buf_size; uint8_t *bitmap; int w, h, x, y, rlelen, i; int64_t packet_time = 0; GetBitContext gb; memset(sub, 0, sizeof(*sub)); // check that at least header fits if (buf_size < 27 + 7 * 2 + 4 * 3) { av_log(avctx, AV_LOG_ERROR, "coded frame too small\n"); return -1; } // read start and end time if (buf[0] != '[' || buf[13] != '-' || buf[26] != ']') { av_log(avctx, AV_LOG_ERROR, "invalid time code\n"); return -1; } if (avpkt->pts != AV_NOPTS_VALUE) packet_time = av_rescale_q(avpkt->pts, AV_TIME_BASE_Q, (AVRational){1, 1000}); sub->start_display_time = parse_timecode(buf + 1, packet_time); sub->end_display_time = parse_timecode(buf + 14, packet_time); buf += 27; // read header w = bytestream_get_le16(&buf); h = bytestream_get_le16(&buf); if (avcodec_check_dimensions(avctx, w, h) < 0) return -1; x = bytestream_get_le16(&buf); y = bytestream_get_le16(&buf); // skip bottom right position, it gives no new information bytestream_get_le16(&buf); bytestream_get_le16(&buf); rlelen = bytestream_get_le16(&buf); // allocate sub and set values sub->rects = av_mallocz(sizeof(*sub->rects)); sub->rects[0] = av_mallocz(sizeof(*sub->rects[0])); sub->num_rects = 1; sub->rects[0]->x = x; sub->rects[0]->y = y; sub->rects[0]->w = w; sub->rects[0]->h = h; sub->rects[0]->type = SUBTITLE_BITMAP; sub->rects[0]->pict.linesize[0] = w; sub->rects[0]->pict.data[0] = av_malloc(w * h); sub->rects[0]->nb_colors = 4; sub->rects[0]->pict.data[1] = av_mallocz(AVPALETTE_SIZE); // read palette for (i = 0; i < sub->rects[0]->nb_colors; i++) ((uint32_t*)sub->rects[0]->pict.data[1])[i] = bytestream_get_be24(&buf); // make all except background (first entry) non-transparent for (i = 1; i < sub->rects[0]->nb_colors; i++) ((uint32_t*)sub->rects[0]->pict.data[1])[i] |= 0xff000000; // process RLE-compressed data rlelen = FFMIN(rlelen, buf_end - buf); init_get_bits(&gb, buf, rlelen * 8); bitmap = sub->rects[0]->pict.data[0]; for (y = 0; y < h; y++) { // interlaced: do odd lines if (y == (h + 1) / 2) bitmap = sub->rects[0]->pict.data[0] + w; for (x = 0; x < w; ) { int log2 = ff_log2_tab[show_bits(&gb, 8)]; int run = get_bits(&gb, 14 - 4 * (log2 >> 1)); int color = get_bits(&gb, 2); run = FFMIN(run, w - x); // run length 0 means till end of row if (!run) run = w - x; memset(bitmap, color, run); bitmap += run; x += run; } // interlaced, skip every second line bitmap += w; align_get_bits(&gb); } *data_size = 1; return buf_size; } AVCodec xsub_decoder = { "xsub", AVMEDIA_TYPE_SUBTITLE, CODEC_ID_XSUB, 0, decode_init, NULL, NULL, decode_frame, .long_name = NULL_IF_CONFIG_SMALL("XSUB"), };
123linslouis-android-video-cutter
jni/libavcodec/xsubdec.c
C
asf20
4,849
/* * Header file for hardcoded AAC cube-root table * * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef CBRT_TABLEGEN_H #define CBRT_TABLEGEN_H #include <stdint.h> #include <math.h> #if CONFIG_HARDCODED_TABLES #define cbrt_tableinit() #include "libavcodec/cbrt_tables.h" #else static uint32_t cbrt_tab[1 << 13]; static void cbrt_tableinit(void) { if (!cbrt_tab[(1<<13) - 1]) { int i; for (i = 0; i < 1<<13; i++) { union { float f; uint32_t i; } f; f.f = cbrtf(i) * i; cbrt_tab[i] = f.i; } } } #endif /* CONFIG_HARDCODED_TABLES */ #endif /* CBRT_TABLEGEN_H */
123linslouis-android-video-cutter
jni/libavcodec/cbrt_tablegen.h
C
asf20
1,465
/* * Intel Indeo 3 (IV31, IV32, etc.) video decoder for ffmpeg * written, produced, and directed by Alan Smithee * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AVCODEC_INDEO3DATA_H #define AVCODEC_INDEO3DATA_H #include <stdint.h> static const uint32_t correction[] = { 0x00000000, 0x00000202, 0xfffffdfe, 0x000002ff, 0xfffffd01, 0xffffff03, 0x000000fd, 0x00000404, 0xfffffbfc, 0x00000501, 0xfffffaff, 0x00000105, 0xfffffefb, 0x000003fc, 0xfffffc04, 0x000005fe, 0xfffffa02, 0xfffffe06, 0x000001fa, 0x00000904, 0xfffff6fc, 0x00000409, 0xfffffbf7, 0x00000909, 0xfffff6f7, 0x00000a01, 0xfffff5ff, 0x0000010a, 0xfffffef6, 0x000007fb, 0xfffff805, 0xfffffb08, 0x000004f8, 0x00000f09, 0xfffff0f7, 0x0000090f, 0xfffff6f1, 0x00000bfd, 0xfffff403, 0xfffffd0c, 0x000002f4, 0x00001004, 0xffffeffc, 0x00000410, 0xfffffbf0, 0x00001010, 0xffffeff0, 0x00001200, 0xffffee00, 0x00000012, 0xffffffee, 0x00000bf4, 0xfffff40c, 0x00000ff7, 0xfffff009, 0xfffff710, 0x000008f0, 0x00001b0b, 0xffffe4f5, 0x00000b1b, 0xfffff4e5, 0x00001c13, 0xffffe3ed, 0x0000131c, 0xffffece4, 0x000015fa, 0xffffea06, 0xfffffa16, 0x000005ea, 0x00001d04, 0xffffe2fc, 0x0000041d, 0xfffffbe3, 0x00001e1e, 0xffffe1e2, 0x000020fe, 0xffffdf02, 0xfffffe21, 0x000001df, 0x000016ee, 0xffffe912, 0xffffee17, 0x000011e9, 0x00001df1, 0xffffe20f, 0xfffff11e, 0x00000ee2, 0x00002e16, 0xffffd1ea, 0x0000162e, 0xffffe9d2, 0x00002f0d, 0xffffd0f3, 0x00000d2f, 0xfffff2d1, 0x00003123, 0xffffcedd, 0x00002331, 0xffffdccf, 0x000028f5, 0xffffd70b, 0xfffff529, 0x00000ad7, 0x00003304, 0xffffccfc, 0x00000433, 0xfffffbcd, 0x00003636, 0xffffc9ca, 0x000021de, 0xffffde22, 0x000029e3, 0xffffd61d, 0xffffe32a, 0x00001cd6, 0x00003bfa, 0xffffc406, 0xfffffa3c, 0x000005c4, 0x00004c1b, 0xffffb3e5, 0x00001b4c, 0xffffe4b4, 0x00004d2b, 0xffffb2d5, 0x00002b4d, 0xffffd4b3, 0x000036e8, 0xffffc918, 0xffffe837, 0x000017c9, 0x00004f0e, 0xffffb0f2, 0x00000e4f, 0xfffff1b1, 0x0000533f, 0xffffacc1, 0x00003f53, 0xffffc0ad, 0x000049ec, 0xffffb614, 0xffffec4a, 0x000013b6, 0x00005802, 0xffffa7fe, 0x00000258, 0xfffffda8, 0x00005d5d, 0xffffa2a3, 0x00003ccc, 0xffffc334, 0xffffcc3d, 0x000033c3, 0x00007834, 0xffff87cc, 0x00003478, 0xffffcb88, 0x00004ad3, 0xffffb52d, 0xffffd34b, 0x00002cb5, 0x00007d4b, 0xffff82b5, 0x00004b7d, 0xffffb483, 0x00007a21, 0xffff85df, 0x0000217a, 0xffffde86, 0x000066f3, 0xffff990d, 0xfffff367, 0x00000c99, 0x00005fd8, 0xffffa028, 0xffffd860, 0x000027a0, 0x00007ede, 0xffff8122, 0xffffde7f, 0x00002181, 0x000058a7, 0xffffa759, 0x000068b2, 0xffff974e, 0xffffb269, 0x00004d97, 0x00000c0c, 0xfffff3f4, 0x00001717, 0xffffe8e9, 0x00002a2a, 0xffffd5d6, 0x00004949, 0xffffb6b7, 0x00000000, 0x02020000, 0xfdfe0000, 0x02ff0000, 0xfd010000, 0xff030000, 0x00fd0000, 0x00000202, 0x02020202, 0xfdfe0202, 0x02ff0202, 0xfd010202, 0xff030202, 0x00fd0202, 0xfffffdfe, 0x0201fdfe, 0xfdfdfdfe, 0x02fefdfe, 0xfd00fdfe, 0xff02fdfe, 0x00fcfdfe, 0x000002ff, 0x020202ff, 0xfdfe02ff, 0x02ff02ff, 0xfd0102ff, 0xff0302ff, 0x00fd02ff, 0xfffffd01, 0x0201fd01, 0xfdfdfd01, 0x02fefd01, 0xfd00fd01, 0xff02fd01, 0x00fcfd01, 0xffffff03, 0x0201ff03, 0xfdfdff03, 0x02feff03, 0xfd00ff03, 0xff02ff03, 0x00fcff03, 0x000000fd, 0x020200fd, 0xfdfe00fd, 0x02ff00fd, 0xfd0100fd, 0xff0300fd, 0x00fd00fd, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000303, 0xfffffcfd, 0x000003ff, 0xfffffc01, 0xffffff04, 0x000000fc, 0x00000707, 0xfffff8f9, 0x00000802, 0xfffff7fe, 0x00000208, 0xfffffdf8, 0x000008fe, 0xfffff702, 0xfffffe09, 0x000001f7, 0x000005fa, 0xfffffa06, 0x00000d06, 0xfffff2fa, 0x0000060d, 0xfffff9f3, 0x00000d0d, 0xfffff2f3, 0x00000e01, 0xfffff1ff, 0x0000010e, 0xfffffef2, 0x00000bf8, 0xfffff408, 0xfffff80c, 0x000007f4, 0x0000170e, 0xffffe8f2, 0x00000e17, 0xfffff1e9, 0x000011fb, 0xffffee05, 0xfffffb12, 0x000004ee, 0x00001806, 0xffffe7fa, 0x00000618, 0xfffff9e8, 0x00001818, 0xffffe7e8, 0x00001aff, 0xffffe501, 0xffffff1b, 0x000000e5, 0x000010ef, 0xffffef11, 0x000016f3, 0xffffe90d, 0xfffff317, 0x00000ce9, 0x00002810, 0xffffd7f0, 0x00001028, 0xffffefd8, 0x0000291c, 0xffffd6e4, 0x00001c29, 0xffffe3d7, 0x000020f7, 0xffffdf09, 0xfffff721, 0x000008df, 0x00002b06, 0xffffd4fa, 0x0000062b, 0xfffff9d5, 0x00002e2e, 0xffffd1d2, 0x000031fc, 0xffffce04, 0xfffffc32, 0x000003ce, 0x000021e5, 0xffffde1b, 0xffffe522, 0x00001ade, 0x00002cea, 0xffffd316, 0xffffea2d, 0x000015d3, 0x00004522, 0xffffbade, 0x00002245, 0xffffddbb, 0x00004613, 0xffffb9ed, 0x00001346, 0xffffecba, 0x00004935, 0xffffb6cb, 0x00003549, 0xffffcab7, 0x00003def, 0xffffc211, 0xffffef3e, 0x000010c2, 0x00004d05, 0xffffb2fb, 0x0000054d, 0xfffffab3, 0x00005252, 0xffffadae, 0x000032cd, 0xffffcd33, 0x00003fd5, 0xffffc02b, 0xffffd540, 0x00002ac0, 0x000059f6, 0xffffa60a, 0xfffff65a, 0x000009a6, 0x00007229, 0xffff8dd7, 0x00002972, 0xffffd68e, 0x00007440, 0xffff8bc0, 0x00004074, 0xffffbf8c, 0x000051db, 0xffffae25, 0xffffdb52, 0x000024ae, 0x00007716, 0xffff88ea, 0x00001677, 0xffffe989, 0x00007c5f, 0xffff83a1, 0x00005f7c, 0xffffa084, 0x00006ee2, 0xffff911e, 0xffffe26f, 0x00001d91, 0x00005bb2, 0xffffa44e, 0xffffb25c, 0x00004da4, 0x000070bc, 0xffff8f44, 0xffffbc71, 0x0000438f, 0x00001212, 0xffffedee, 0x00002222, 0xffffddde, 0x00003f3f, 0xffffc0c1, 0x00006d6d, 0xffff9293, 0x00000000, 0x03030000, 0xfcfd0000, 0x03ff0000, 0xfc010000, 0xff040000, 0x00fc0000, 0x07070000, 0xf8f90000, 0x00000303, 0x03030303, 0xfcfd0303, 0x03ff0303, 0xfc010303, 0xff040303, 0x00fc0303, 0x07070303, 0xf8f90303, 0xfffffcfd, 0x0302fcfd, 0xfcfcfcfd, 0x03fefcfd, 0xfc00fcfd, 0xff03fcfd, 0x00fbfcfd, 0x0706fcfd, 0xf8f8fcfd, 0x000003ff, 0x030303ff, 0xfcfd03ff, 0x03ff03ff, 0xfc0103ff, 0xff0403ff, 0x00fc03ff, 0x070703ff, 0xf8f903ff, 0xfffffc01, 0x0302fc01, 0xfcfcfc01, 0x03fefc01, 0xfc00fc01, 0xff03fc01, 0x00fbfc01, 0x0706fc01, 0xf8f8fc01, 0xffffff04, 0x0302ff04, 0xfcfcff04, 0x03feff04, 0xfc00ff04, 0xff03ff04, 0x00fbff04, 0x0706ff04, 0xf8f8ff04, 0x000000fc, 0x030300fc, 0xfcfd00fc, 0x03ff00fc, 0xfc0100fc, 0xff0400fc, 0x00fc00fc, 0x070700fc, 0xf8f900fc, 0x00000707, 0x03030707, 0xfcfd0707, 0x03ff0707, 0xfc010707, 0xff040707, 0x00fc0707, 0x07070707, 0xf8f90707, 0xfffff8f9, 0x0302f8f9, 0xfcfcf8f9, 0x03fef8f9, 0xfc00f8f9, 0xff03f8f9, 0x00fbf8f9, 0x0706f8f9, 0xf8f8f8f9, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000404, 0xfffffbfc, 0x000004ff, 0xfffffb01, 0xffffff05, 0x000000fb, 0x00000a03, 0xfffff5fd, 0x0000030a, 0xfffffcf6, 0x00000909, 0xfffff6f7, 0x000006f9, 0xfffff907, 0x00000bfd, 0xfffff403, 0xfffffd0c, 0x000002f4, 0x00001108, 0xffffeef8, 0x00000811, 0xfffff7ef, 0x00001111, 0xffffeeef, 0x00001301, 0xffffecff, 0x00000113, 0xfffffeed, 0x00000ff5, 0xfffff00b, 0xfffff510, 0x00000af0, 0x000016fa, 0xffffe906, 0xfffffa17, 0x000005e9, 0x00001f12, 0xffffe0ee, 0x0000121f, 0xffffede1, 0x00002008, 0xffffdff8, 0x00000820, 0xfffff7e0, 0x00002121, 0xffffdedf, 0x000023ff, 0xffffdc01, 0xffffff24, 0x000000dc, 0x000016e9, 0xffffe917, 0x00001eef, 0xffffe111, 0xffffef1f, 0x000010e1, 0x00003615, 0xffffc9eb, 0x00001536, 0xffffeaca, 0x00003725, 0xffffc8db, 0x00002537, 0xffffdac9, 0x00002bf4, 0xffffd40c, 0xfffff42c, 0x00000bd4, 0x00003908, 0xffffc6f8, 0x00000839, 0xfffff7c7, 0x00003d3d, 0xffffc2c3, 0x000041fb, 0xffffbe05, 0xfffffb42, 0x000004be, 0x00002cdc, 0xffffd324, 0xffffdc2d, 0x000023d3, 0x00003be3, 0xffffc41d, 0xffffe33c, 0x00001cc4, 0x00005c2d, 0xffffa3d3, 0x00002d5c, 0xffffd2a4, 0x00005d19, 0xffffa2e7, 0x0000195d, 0xffffe6a3, 0x00006147, 0xffff9eb9, 0x00004761, 0xffffb89f, 0x000052ea, 0xffffad16, 0xffffea53, 0x000015ad, 0x00006607, 0xffff99f9, 0x00000766, 0xfffff89a, 0x00006d6d, 0xffff9293, 0x000043bc, 0xffffbc44, 0x000054c7, 0xffffab39, 0xffffc755, 0x000038ab, 0x000077f3, 0xffff880d, 0xfffff378, 0x00000c88, 0x00006dcf, 0xffff9231, 0xffffcf6e, 0x00003092, 0x00007a98, 0xffff8568, 0xffff987b, 0x00006785, 0x00001818, 0xffffe7e8, 0x00002e2e, 0xffffd1d2, 0x00005454, 0xffffabac, 0x00000000, 0x04040000, 0xfbfc0000, 0x04ff0000, 0xfb010000, 0xff050000, 0x00fb0000, 0x0a030000, 0xf5fd0000, 0x030a0000, 0x00000404, 0x04040404, 0xfbfc0404, 0x04ff0404, 0xfb010404, 0xff050404, 0x00fb0404, 0x0a030404, 0xf5fd0404, 0x030a0404, 0xfffffbfc, 0x0403fbfc, 0xfbfbfbfc, 0x04fefbfc, 0xfb00fbfc, 0xff04fbfc, 0x00fafbfc, 0x0a02fbfc, 0xf5fcfbfc, 0x0309fbfc, 0x000004ff, 0x040404ff, 0xfbfc04ff, 0x04ff04ff, 0xfb0104ff, 0xff0504ff, 0x00fb04ff, 0x0a0304ff, 0xf5fd04ff, 0x030a04ff, 0xfffffb01, 0x0403fb01, 0xfbfbfb01, 0x04fefb01, 0xfb00fb01, 0xff04fb01, 0x00fafb01, 0x0a02fb01, 0xf5fcfb01, 0x0309fb01, 0xffffff05, 0x0403ff05, 0xfbfbff05, 0x04feff05, 0xfb00ff05, 0xff04ff05, 0x00faff05, 0x0a02ff05, 0xf5fcff05, 0x0309ff05, 0x000000fb, 0x040400fb, 0xfbfc00fb, 0x04ff00fb, 0xfb0100fb, 0xff0500fb, 0x00fb00fb, 0x0a0300fb, 0xf5fd00fb, 0x030a00fb, 0x00000a03, 0x04040a03, 0xfbfc0a03, 0x04ff0a03, 0xfb010a03, 0xff050a03, 0x00fb0a03, 0x0a030a03, 0xf5fd0a03, 0x030a0a03, 0xfffff5fd, 0x0403f5fd, 0xfbfbf5fd, 0x04fef5fd, 0xfb00f5fd, 0xff04f5fd, 0x00faf5fd, 0x0a02f5fd, 0xf5fcf5fd, 0x0309f5fd, 0x0000030a, 0x0404030a, 0xfbfc030a, 0x04ff030a, 0xfb01030a, 0xff05030a, 0x00fb030a, 0x0a03030a, 0xf5fd030a, 0x030a030a, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000505, 0xfffffafb, 0x000006fe, 0xfffff902, 0xfffffe07, 0x000001f9, 0x00000b0b, 0xfffff4f5, 0x00000d03, 0xfffff2fd, 0x0000030d, 0xfffffcf3, 0x000008f7, 0xfffff709, 0x00000efc, 0xfffff104, 0xfffffc0f, 0x000003f1, 0x0000160b, 0xffffe9f5, 0x00000b16, 0xfffff4ea, 0x00001515, 0xffffeaeb, 0x00001802, 0xffffe7fe, 0x00000218, 0xfffffde8, 0x000013f2, 0xffffec0e, 0xfffff214, 0x00000dec, 0x00002617, 0xffffd9e9, 0x00001726, 0xffffe8da, 0x00001cf8, 0xffffe308, 0xfffff81d, 0x000007e3, 0x0000270b, 0xffffd8f5, 0x00000b27, 0xfffff4d9, 0x00002929, 0xffffd6d7, 0x00002cff, 0xffffd301, 0xffffff2d, 0x000000d3, 0x00001ce3, 0xffffe31d, 0x000026ea, 0xffffd916, 0xffffea27, 0x000015d9, 0x0000431b, 0xffffbce5, 0x00001b43, 0xffffe4bd, 0x0000452f, 0xffffbad1, 0x00002f45, 0xffffd0bb, 0x000037f1, 0xffffc80f, 0xfffff138, 0x00000ec8, 0x0000470b, 0xffffb8f5, 0x00000b47, 0xfffff4b9, 0x00004c4c, 0xffffb3b4, 0x000052fa, 0xffffad06, 0xfffffa53, 0x000005ad, 0x000038d3, 0xffffc72d, 0xffffd339, 0x00002cc7, 0x00004adc, 0xffffb524, 0xffffdc4b, 0x000023b5, 0x00007338, 0xffff8cc8, 0x00003873, 0xffffc78d, 0x0000751f, 0xffff8ae1, 0x00001f75, 0xffffe08b, 0x00007a58, 0xffff85a8, 0x0000587a, 0xffffa786, 0x000067e4, 0xffff981c, 0xffffe468, 0x00001b98, 0x000054ab, 0xffffab55, 0x000069b8, 0xffff9648, 0xffffb86a, 0x00004796, 0x00001e1e, 0xffffe1e2, 0x00003a3a, 0xffffc5c6, 0x00006969, 0xffff9697, 0x00000000, 0x05050000, 0xfafb0000, 0x06fe0000, 0xf9020000, 0xfe070000, 0x01f90000, 0x0b0b0000, 0xf4f50000, 0x0d030000, 0xf2fd0000, 0x00000505, 0x05050505, 0xfafb0505, 0x06fe0505, 0xf9020505, 0xfe070505, 0x01f90505, 0x0b0b0505, 0xf4f50505, 0x0d030505, 0xf2fd0505, 0xfffffafb, 0x0504fafb, 0xfafafafb, 0x06fdfafb, 0xf901fafb, 0xfe06fafb, 0x01f8fafb, 0x0b0afafb, 0xf4f4fafb, 0x0d02fafb, 0xf2fcfafb, 0x000006fe, 0x050506fe, 0xfafb06fe, 0x06fe06fe, 0xf90206fe, 0xfe0706fe, 0x01f906fe, 0x0b0b06fe, 0xf4f506fe, 0x0d0306fe, 0xf2fd06fe, 0xfffff902, 0x0504f902, 0xfafaf902, 0x06fdf902, 0xf901f902, 0xfe06f902, 0x01f8f902, 0x0b0af902, 0xf4f4f902, 0x0d02f902, 0xf2fcf902, 0xfffffe07, 0x0504fe07, 0xfafafe07, 0x06fdfe07, 0xf901fe07, 0xfe06fe07, 0x01f8fe07, 0x0b0afe07, 0xf4f4fe07, 0x0d02fe07, 0xf2fcfe07, 0x000001f9, 0x050501f9, 0xfafb01f9, 0x06fe01f9, 0xf90201f9, 0xfe0701f9, 0x01f901f9, 0x0b0b01f9, 0xf4f501f9, 0x0d0301f9, 0xf2fd01f9, 0x00000b0b, 0x05050b0b, 0xfafb0b0b, 0x06fe0b0b, 0xf9020b0b, 0xfe070b0b, 0x01f90b0b, 0x0b0b0b0b, 0xf4f50b0b, 0x0d030b0b, 0xf2fd0b0b, 0xfffff4f5, 0x0504f4f5, 0xfafaf4f5, 0x06fdf4f5, 0xf901f4f5, 0xfe06f4f5, 0x01f8f4f5, 0x0b0af4f5, 0xf4f4f4f5, 0x0d02f4f5, 0xf2fcf4f5, 0x00000d03, 0x05050d03, 0xfafb0d03, 0x06fe0d03, 0xf9020d03, 0xfe070d03, 0x01f90d03, 0x0b0b0d03, 0xf4f50d03, 0x0d030d03, 0xf2fd0d03, 0xfffff2fd, 0x0504f2fd, 0xfafaf2fd, 0x06fdf2fd, 0xf901f2fd, 0xfe06f2fd, 0x01f8f2fd, 0x0b0af2fd, 0xf4f4f2fd, 0x0d02f2fd, 0xf2fcf2fd, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000606, 0xfffff9fa, 0x000007fe, 0xfffff802, 0xfffffe08, 0x000001f8, 0x00000d0d, 0xfffff2f3, 0x00000f04, 0xfffff0fc, 0x0000040f, 0xfffffbf1, 0x00000af5, 0xfffff50b, 0x000011fb, 0xffffee05, 0xfffffb12, 0x000004ee, 0x00001a0d, 0xffffe5f3, 0x00000d1a, 0xfffff2e6, 0x00001a1a, 0xffffe5e6, 0x00001d02, 0xffffe2fe, 0x0000021d, 0xfffffde3, 0x000017f0, 0xffffe810, 0xfffff018, 0x00000fe8, 0x00002e1c, 0xffffd1e4, 0x00001c2e, 0xffffe3d2, 0x000022f7, 0xffffdd09, 0xfffff723, 0x000008dd, 0x00002f0d, 0xffffd0f3, 0x00000d2f, 0xfffff2d1, 0x00003131, 0xffffcecf, 0x000035ff, 0xffffca01, 0xffffff36, 0x000000ca, 0x000022dd, 0xffffdd23, 0x00002ee6, 0xffffd11a, 0xffffe62f, 0x000019d1, 0x00005120, 0xffffaee0, 0x00002051, 0xffffdfaf, 0x00005338, 0xffffacc8, 0x00003853, 0xffffc7ad, 0x000042ee, 0xffffbd12, 0xffffee43, 0x000011bd, 0x0000560d, 0xffffa9f3, 0x00000d56, 0xfffff2aa, 0x00005b5b, 0xffffa4a5, 0x000062f9, 0xffff9d07, 0xfffff963, 0x0000069d, 0x000043ca, 0xffffbc36, 0xffffca44, 0x000035bc, 0x000059d4, 0xffffa62c, 0xffffd45a, 0x00002ba6, 0x00007bdf, 0xffff8421, 0xffffdf7c, 0x00002084, 0x00006699, 0xffff9967, 0x00007eaa, 0xffff8156, 0xffffaa7f, 0x00005581, 0x00002525, 0xffffdadb, 0x00004545, 0xffffbabb, 0x00000000, 0x06060000, 0xf9fa0000, 0x07fe0000, 0xf8020000, 0xfe080000, 0x01f80000, 0x0d0d0000, 0xf2f30000, 0x0f040000, 0xf0fc0000, 0x040f0000, 0x00000606, 0x06060606, 0xf9fa0606, 0x07fe0606, 0xf8020606, 0xfe080606, 0x01f80606, 0x0d0d0606, 0xf2f30606, 0x0f040606, 0xf0fc0606, 0x040f0606, 0xfffff9fa, 0x0605f9fa, 0xf9f9f9fa, 0x07fdf9fa, 0xf801f9fa, 0xfe07f9fa, 0x01f7f9fa, 0x0d0cf9fa, 0xf2f2f9fa, 0x0f03f9fa, 0xf0fbf9fa, 0x040ef9fa, 0x000007fe, 0x060607fe, 0xf9fa07fe, 0x07fe07fe, 0xf80207fe, 0xfe0807fe, 0x01f807fe, 0x0d0d07fe, 0xf2f307fe, 0x0f0407fe, 0xf0fc07fe, 0x040f07fe, 0xfffff802, 0x0605f802, 0xf9f9f802, 0x07fdf802, 0xf801f802, 0xfe07f802, 0x01f7f802, 0x0d0cf802, 0xf2f2f802, 0x0f03f802, 0xf0fbf802, 0x040ef802, 0xfffffe08, 0x0605fe08, 0xf9f9fe08, 0x07fdfe08, 0xf801fe08, 0xfe07fe08, 0x01f7fe08, 0x0d0cfe08, 0xf2f2fe08, 0x0f03fe08, 0xf0fbfe08, 0x040efe08, 0x000001f8, 0x060601f8, 0xf9fa01f8, 0x07fe01f8, 0xf80201f8, 0xfe0801f8, 0x01f801f8, 0x0d0d01f8, 0xf2f301f8, 0x0f0401f8, 0xf0fc01f8, 0x040f01f8, 0x00000d0d, 0x06060d0d, 0xf9fa0d0d, 0x07fe0d0d, 0xf8020d0d, 0xfe080d0d, 0x01f80d0d, 0x0d0d0d0d, 0xf2f30d0d, 0x0f040d0d, 0xf0fc0d0d, 0x040f0d0d, 0xfffff2f3, 0x0605f2f3, 0xf9f9f2f3, 0x07fdf2f3, 0xf801f2f3, 0xfe07f2f3, 0x01f7f2f3, 0x0d0cf2f3, 0xf2f2f2f3, 0x0f03f2f3, 0xf0fbf2f3, 0x040ef2f3, 0x00000f04, 0x06060f04, 0xf9fa0f04, 0x07fe0f04, 0xf8020f04, 0xfe080f04, 0x01f80f04, 0x0d0d0f04, 0xf2f30f04, 0x0f040f04, 0xf0fc0f04, 0x040f0f04, 0xfffff0fc, 0x0605f0fc, 0xf9f9f0fc, 0x07fdf0fc, 0xf801f0fc, 0xfe07f0fc, 0x01f7f0fc, 0x0d0cf0fc, 0xf2f2f0fc, 0x0f03f0fc, 0xf0fbf0fc, 0x040ef0fc, 0x0000040f, 0x0606040f, 0xf9fa040f, 0x07fe040f, 0xf802040f, 0xfe08040f, 0x01f8040f, 0x0d0d040f, 0xf2f3040f, 0x0f04040f, 0xf0fc040f, 0x040f040f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000707, 0xfffff8f9, 0x000009fd, 0xfffff603, 0xfffffd0a, 0x000002f6, 0x00001010, 0xffffeff0, 0x00001205, 0xffffedfb, 0x00000512, 0xfffffaee, 0x00000cf3, 0xfffff30d, 0x000014fa, 0xffffeb06, 0xfffffa15, 0x000005eb, 0x00001e0f, 0xffffe1f1, 0x00000f1e, 0xfffff0e2, 0x00001e1e, 0xffffe1e2, 0x00002202, 0xffffddfe, 0x00000222, 0xfffffdde, 0x00001bed, 0xffffe413, 0xffffed1c, 0x000012e4, 0x00003620, 0xffffc9e0, 0x00002036, 0xffffdfca, 0x000028f5, 0xffffd70b, 0xfffff529, 0x00000ad7, 0x0000370f, 0xffffc8f1, 0x00000f37, 0xfffff0c9, 0x00003939, 0xffffc6c7, 0x00003eff, 0xffffc101, 0xffffff3f, 0x000000c1, 0x000027d8, 0xffffd828, 0x000036e2, 0xffffc91e, 0xffffe237, 0x00001dc9, 0x00005e25, 0xffffa1db, 0x0000255e, 0xffffdaa2, 0x00006041, 0xffff9fbf, 0x00004160, 0xffffbea0, 0x00004deb, 0xffffb215, 0xffffeb4e, 0x000014b2, 0x0000640f, 0xffff9bf1, 0x00000f64, 0xfffff09c, 0x00006a6a, 0xffff9596, 0x000073f8, 0xffff8c08, 0xfffff874, 0x0000078c, 0x00004ec1, 0xffffb13f, 0xffffc14f, 0x00003eb1, 0x000068cd, 0xffff9733, 0xffffcd69, 0x00003297, 0x00007788, 0xffff8878, 0x00002b2b, 0xffffd4d5, 0x00005050, 0xffffafb0, 0x00000000, 0x07070000, 0xf8f90000, 0x09fd0000, 0xf6030000, 0xfd0a0000, 0x02f60000, 0x10100000, 0xeff00000, 0x12050000, 0xedfb0000, 0x05120000, 0x00000707, 0x07070707, 0xf8f90707, 0x09fd0707, 0xf6030707, 0xfd0a0707, 0x02f60707, 0x10100707, 0xeff00707, 0x12050707, 0xedfb0707, 0x05120707, 0xfffff8f9, 0x0706f8f9, 0xf8f8f8f9, 0x09fcf8f9, 0xf602f8f9, 0xfd09f8f9, 0x02f5f8f9, 0x100ff8f9, 0xefeff8f9, 0x1204f8f9, 0xedfaf8f9, 0x0511f8f9, 0x000009fd, 0x070709fd, 0xf8f909fd, 0x09fd09fd, 0xf60309fd, 0xfd0a09fd, 0x02f609fd, 0x101009fd, 0xeff009fd, 0x120509fd, 0xedfb09fd, 0x051209fd, 0xfffff603, 0x0706f603, 0xf8f8f603, 0x09fcf603, 0xf602f603, 0xfd09f603, 0x02f5f603, 0x100ff603, 0xefeff603, 0x1204f603, 0xedfaf603, 0x0511f603, 0xfffffd0a, 0x0706fd0a, 0xf8f8fd0a, 0x09fcfd0a, 0xf602fd0a, 0xfd09fd0a, 0x02f5fd0a, 0x100ffd0a, 0xefeffd0a, 0x1204fd0a, 0xedfafd0a, 0x0511fd0a, 0x000002f6, 0x070702f6, 0xf8f902f6, 0x09fd02f6, 0xf60302f6, 0xfd0a02f6, 0x02f602f6, 0x101002f6, 0xeff002f6, 0x120502f6, 0xedfb02f6, 0x051202f6, 0x00001010, 0x07071010, 0xf8f91010, 0x09fd1010, 0xf6031010, 0xfd0a1010, 0x02f61010, 0x10101010, 0xeff01010, 0x12051010, 0xedfb1010, 0x05121010, 0xffffeff0, 0x0706eff0, 0xf8f8eff0, 0x09fceff0, 0xf602eff0, 0xfd09eff0, 0x02f5eff0, 0x100feff0, 0xefefeff0, 0x1204eff0, 0xedfaeff0, 0x0511eff0, 0x00001205, 0x07071205, 0xf8f91205, 0x09fd1205, 0xf6031205, 0xfd0a1205, 0x02f61205, 0x10101205, 0xeff01205, 0x12051205, 0xedfb1205, 0x05121205, 0xffffedfb, 0x0706edfb, 0xf8f8edfb, 0x09fcedfb, 0xf602edfb, 0xfd09edfb, 0x02f5edfb, 0x100fedfb, 0xefefedfb, 0x1204edfb, 0xedfaedfb, 0x0511edfb, 0x00000512, 0x07070512, 0xf8f90512, 0x09fd0512, 0xf6030512, 0xfd0a0512, 0x02f60512, 0x10100512, 0xeff00512, 0x12050512, 0xedfb0512, 0x05120512, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000808, 0xfffff7f8, 0x00000afd, 0xfffff503, 0xfffffd0b, 0x000002f5, 0x00001212, 0xffffedee, 0x00001405, 0xffffebfb, 0x00000514, 0xfffffaec, 0x00000ef1, 0xfffff10f, 0x000017f9, 0xffffe807, 0xfffff918, 0x000006e8, 0x00002311, 0xffffdcef, 0x00001123, 0xffffeedd, 0x00002222, 0xffffddde, 0x00002603, 0xffffd9fd, 0x00000326, 0xfffffcda, 0x00001fea, 0xffffe016, 0xffffea20, 0x000015e0, 0x00003d25, 0xffffc2db, 0x0000253d, 0xffffdac3, 0x00002ef3, 0xffffd10d, 0xfffff32f, 0x00000cd1, 0x00003f11, 0xffffc0ef, 0x0000113f, 0xffffeec1, 0x00004141, 0xffffbebf, 0x000047ff, 0xffffb801, 0xffffff48, 0x000000b8, 0x00002dd2, 0xffffd22e, 0x00003edd, 0xffffc123, 0xffffdd3f, 0x000022c1, 0x00006b2b, 0xffff94d5, 0x00002b6b, 0xffffd495, 0x00006e4b, 0xffff91b5, 0x00004b6e, 0xffffb492, 0x000058e8, 0xffffa718, 0xffffe859, 0x000017a7, 0x00007211, 0xffff8def, 0x00001172, 0xffffee8e, 0x00007979, 0xffff8687, 0x00005ab8, 0xffffa548, 0xffffb85b, 0x000047a5, 0x000077c6, 0xffff883a, 0xffffc678, 0x00003988, 0x00003131, 0xffffcecf, 0x00005c5c, 0xffffa3a4, 0x00000000, 0x08080000, 0xf7f80000, 0x0afd0000, 0xf5030000, 0xfd0b0000, 0x02f50000, 0x12120000, 0xedee0000, 0x14050000, 0xebfb0000, 0x05140000, 0x00000808, 0x08080808, 0xf7f80808, 0x0afd0808, 0xf5030808, 0xfd0b0808, 0x02f50808, 0x12120808, 0xedee0808, 0x14050808, 0xebfb0808, 0x05140808, 0xfffff7f8, 0x0807f7f8, 0xf7f7f7f8, 0x0afcf7f8, 0xf502f7f8, 0xfd0af7f8, 0x02f4f7f8, 0x1211f7f8, 0xededf7f8, 0x1404f7f8, 0xebfaf7f8, 0x0513f7f8, 0x00000afd, 0x08080afd, 0xf7f80afd, 0x0afd0afd, 0xf5030afd, 0xfd0b0afd, 0x02f50afd, 0x12120afd, 0xedee0afd, 0x14050afd, 0xebfb0afd, 0x05140afd, 0xfffff503, 0x0807f503, 0xf7f7f503, 0x0afcf503, 0xf502f503, 0xfd0af503, 0x02f4f503, 0x1211f503, 0xededf503, 0x1404f503, 0xebfaf503, 0x0513f503, 0xfffffd0b, 0x0807fd0b, 0xf7f7fd0b, 0x0afcfd0b, 0xf502fd0b, 0xfd0afd0b, 0x02f4fd0b, 0x1211fd0b, 0xededfd0b, 0x1404fd0b, 0xebfafd0b, 0x0513fd0b, 0x000002f5, 0x080802f5, 0xf7f802f5, 0x0afd02f5, 0xf50302f5, 0xfd0b02f5, 0x02f502f5, 0x121202f5, 0xedee02f5, 0x140502f5, 0xebfb02f5, 0x051402f5, 0x00001212, 0x08081212, 0xf7f81212, 0x0afd1212, 0xf5031212, 0xfd0b1212, 0x02f51212, 0x12121212, 0xedee1212, 0x14051212, 0xebfb1212, 0x05141212, 0xffffedee, 0x0807edee, 0xf7f7edee, 0x0afcedee, 0xf502edee, 0xfd0aedee, 0x02f4edee, 0x1211edee, 0xedededee, 0x1404edee, 0xebfaedee, 0x0513edee, 0x00001405, 0x08081405, 0xf7f81405, 0x0afd1405, 0xf5031405, 0xfd0b1405, 0x02f51405, 0x12121405, 0xedee1405, 0x14051405, 0xebfb1405, 0x05141405, 0xffffebfb, 0x0807ebfb, 0xf7f7ebfb, 0x0afcebfb, 0xf502ebfb, 0xfd0aebfb, 0x02f4ebfb, 0x1211ebfb, 0xededebfb, 0x1404ebfb, 0xebfaebfb, 0x0513ebfb, 0x00000514, 0x08080514, 0xf7f80514, 0x0afd0514, 0xf5030514, 0xfd0b0514, 0x02f50514, 0x12120514, 0xedee0514, 0x14050514, 0xebfb0514, 0x05140514, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000909, 0xfffff6f7, 0x00000bfd, 0xfffff403, 0xfffffd0c, 0x000002f4, 0x00001414, 0xffffebec, 0x00001706, 0xffffe8fa, 0x00000617, 0xfffff9e9, 0x000010ef, 0xffffef11, 0x00001af9, 0xffffe507, 0xfffff91b, 0x000006e5, 0x00002713, 0xffffd8ed, 0x00001327, 0xffffecd9, 0x00002727, 0xffffd8d9, 0x00002b03, 0xffffd4fd, 0x0000032b, 0xfffffcd5, 0x000023e8, 0xffffdc18, 0xffffe824, 0x000017dc, 0x0000452a, 0xffffbad6, 0x00002a45, 0xffffd5bb, 0x000034f2, 0xffffcb0e, 0xfffff235, 0x00000dcb, 0x00004713, 0xffffb8ed, 0x00001347, 0xffffecb9, 0x00004949, 0xffffb6b7, 0x00004ffe, 0xffffb002, 0xfffffe50, 0x000001b0, 0x000033cc, 0xffffcc34, 0x000045d9, 0xffffba27, 0xffffd946, 0x000026ba, 0x00007930, 0xffff86d0, 0x00003079, 0xffffcf87, 0x00007c54, 0xffff83ac, 0x0000547c, 0xffffab84, 0x000063e5, 0xffff9c1b, 0xffffe564, 0x00001a9c, 0x000065af, 0xffff9a51, 0xffffaf66, 0x0000509a, 0x00003737, 0xffffc8c9, 0x00006868, 0xffff9798, 0x00000000, 0x09090000, 0xf6f70000, 0x0bfd0000, 0xf4030000, 0xfd0c0000, 0x02f40000, 0x14140000, 0xebec0000, 0x17060000, 0xe8fa0000, 0x06170000, 0xf9e90000, 0x00000909, 0x09090909, 0xf6f70909, 0x0bfd0909, 0xf4030909, 0xfd0c0909, 0x02f40909, 0x14140909, 0xebec0909, 0x17060909, 0xe8fa0909, 0x06170909, 0xf9e90909, 0xfffff6f7, 0x0908f6f7, 0xf6f6f6f7, 0x0bfcf6f7, 0xf402f6f7, 0xfd0bf6f7, 0x02f3f6f7, 0x1413f6f7, 0xebebf6f7, 0x1705f6f7, 0xe8f9f6f7, 0x0616f6f7, 0xf9e8f6f7, 0x00000bfd, 0x09090bfd, 0xf6f70bfd, 0x0bfd0bfd, 0xf4030bfd, 0xfd0c0bfd, 0x02f40bfd, 0x14140bfd, 0xebec0bfd, 0x17060bfd, 0xe8fa0bfd, 0x06170bfd, 0xf9e90bfd, 0xfffff403, 0x0908f403, 0xf6f6f403, 0x0bfcf403, 0xf402f403, 0xfd0bf403, 0x02f3f403, 0x1413f403, 0xebebf403, 0x1705f403, 0xe8f9f403, 0x0616f403, 0xf9e8f403, 0xfffffd0c, 0x0908fd0c, 0xf6f6fd0c, 0x0bfcfd0c, 0xf402fd0c, 0xfd0bfd0c, 0x02f3fd0c, 0x1413fd0c, 0xebebfd0c, 0x1705fd0c, 0xe8f9fd0c, 0x0616fd0c, 0xf9e8fd0c, 0x000002f4, 0x090902f4, 0xf6f702f4, 0x0bfd02f4, 0xf40302f4, 0xfd0c02f4, 0x02f402f4, 0x141402f4, 0xebec02f4, 0x170602f4, 0xe8fa02f4, 0x061702f4, 0xf9e902f4, 0x00001414, 0x09091414, 0xf6f71414, 0x0bfd1414, 0xf4031414, 0xfd0c1414, 0x02f41414, 0x14141414, 0xebec1414, 0x17061414, 0xe8fa1414, 0x06171414, 0xf9e91414, 0xffffebec, 0x0908ebec, 0xf6f6ebec, 0x0bfcebec, 0xf402ebec, 0xfd0bebec, 0x02f3ebec, 0x1413ebec, 0xebebebec, 0x1705ebec, 0xe8f9ebec, 0x0616ebec, 0xf9e8ebec, 0x00001706, 0x09091706, 0xf6f71706, 0x0bfd1706, 0xf4031706, 0xfd0c1706, 0x02f41706, 0x14141706, 0xebec1706, 0x17061706, 0xe8fa1706, 0x06171706, 0xf9e91706, 0xffffe8fa, 0x0908e8fa, 0xf6f6e8fa, 0x0bfce8fa, 0xf402e8fa, 0xfd0be8fa, 0x02f3e8fa, 0x1413e8fa, 0xebebe8fa, 0x1705e8fa, 0xe8f9e8fa, 0x0616e8fa, 0xf9e8e8fa, 0x00000617, 0x09090617, 0xf6f70617, 0x0bfd0617, 0xf4030617, 0xfd0c0617, 0x02f40617, 0x14140617, 0xebec0617, 0x17060617, 0xe8fa0617, 0x06170617, 0xf9e90617, 0xfffff9e9, 0x0908f9e9, 0xf6f6f9e9, 0x0bfcf9e9, 0xf402f9e9, 0xfd0bf9e9, 0x02f3f9e9, 0x1413f9e9, 0xebebf9e9, 0x1705f9e9, 0xe8f9f9e9, 0x0616f9e9, 0xf9e8f9e9, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000202, 0xfffffdfe, 0x00000200, 0xfffffe00, 0x00000002, 0xfffffffe, 0x00000404, 0xfffffbfc, 0x00000400, 0xfffffc00, 0x00000004, 0xfffffffc, 0x000003fc, 0xfffffc04, 0x000005fe, 0xfffffa02, 0xfffffe06, 0x000001fa, 0x00000804, 0xfffff7fc, 0x00000408, 0xfffffbf8, 0x00000808, 0xfffff7f8, 0x00000a00, 0xfffff600, 0x0000000a, 0xfffffff6, 0x000007fc, 0xfffff804, 0xfffffc08, 0x000003f8, 0x00000e08, 0xfffff1f8, 0x0000080e, 0xfffff7f2, 0x00000bfe, 0xfffff402, 0xfffffe0c, 0x000001f4, 0x00001004, 0xffffeffc, 0x00000410, 0xfffffbf0, 0x00001010, 0xffffeff0, 0x00001200, 0xffffee00, 0x00000012, 0xffffffee, 0x00000bf4, 0xfffff40c, 0x00000ff8, 0xfffff008, 0xfffff810, 0x000007f0, 0x00001a0a, 0xffffe5f6, 0x00000a1a, 0xfffff5e6, 0x00001c12, 0xffffe3ee, 0x0000121c, 0xffffede4, 0x000015fa, 0xffffea06, 0xfffffa16, 0x000005ea, 0x00001c04, 0xffffe3fc, 0x0000041c, 0xfffffbe4, 0x00001e1e, 0xffffe1e2, 0x00001ffe, 0xffffe002, 0xfffffe20, 0x000001e0, 0x000015ee, 0xffffea12, 0xffffee16, 0x000011ea, 0x00001df2, 0xffffe20e, 0xfffff21e, 0x00000de2, 0x00002e16, 0xffffd1ea, 0x0000162e, 0xffffe9d2, 0x00002e0c, 0xffffd1f4, 0x00000c2e, 0xfffff3d2, 0x00003022, 0xffffcfde, 0x00002230, 0xffffddd0, 0x000027f6, 0xffffd80a, 0xfffff628, 0x000009d8, 0x00003204, 0xffffcdfc, 0x00000432, 0xfffffbce, 0x00003636, 0xffffc9ca, 0x000021de, 0xffffde22, 0x000029e4, 0xffffd61c, 0xffffe42a, 0x00001bd6, 0x00003bfa, 0xffffc406, 0xfffffa3c, 0x000005c4, 0x00004c1a, 0xffffb3e6, 0x00001a4c, 0xffffe5b4, 0x00004c2a, 0xffffb3d6, 0x00002a4c, 0xffffd5b4, 0x000035e8, 0xffffca18, 0xffffe836, 0x000017ca, 0x00004e0e, 0xffffb1f2, 0x00000e4e, 0xfffff1b2, 0x0000523e, 0xffffadc2, 0x00003e52, 0xffffc1ae, 0x000049ec, 0xffffb614, 0xffffec4a, 0x000013b6, 0x00005802, 0xffffa7fe, 0x00000258, 0xfffffda8, 0x00005c5c, 0xffffa3a4, 0x00003bcc, 0xffffc434, 0xffffcc3c, 0x000033c4, 0x00007634, 0xffff89cc, 0x00003476, 0xffffcb8a, 0x000049d4, 0xffffb62c, 0xffffd44a, 0x00002bb6, 0x0000764a, 0xffff89b6, 0x00004a76, 0xffffb58a, 0x00007620, 0xffff89e0, 0x00002076, 0xffffdf8a, 0x000065f4, 0xffff9a0c, 0xfffff466, 0x00000b9a, 0x00005fd8, 0xffffa028, 0xffffd860, 0x000027a0, 0x000075de, 0xffff8a22, 0xffffde76, 0x0000218a, 0x000057a8, 0xffffa858, 0x000067b2, 0xffff984e, 0xffffb268, 0x00004d98, 0x00000c0c, 0xfffff3f4, 0x00001616, 0xffffe9ea, 0x00002a2a, 0xffffd5d6, 0x00004848, 0xffffb7b8, 0x00000000, 0x02020000, 0xfdfe0000, 0x02000000, 0xfe000000, 0x00020000, 0xfffe0000, 0x00000202, 0x02020202, 0xfdfe0202, 0x02000202, 0xfe000202, 0x00020202, 0xfffe0202, 0xfffffdfe, 0x0201fdfe, 0xfdfdfdfe, 0x01fffdfe, 0xfdfffdfe, 0x0001fdfe, 0xfffdfdfe, 0x00000200, 0x02020200, 0xfdfe0200, 0x02000200, 0xfe000200, 0x00020200, 0xfffe0200, 0xfffffe00, 0x0201fe00, 0xfdfdfe00, 0x01fffe00, 0xfdfffe00, 0x0001fe00, 0xfffdfe00, 0x00000002, 0x02020002, 0xfdfe0002, 0x02000002, 0xfe000002, 0x00020002, 0xfffe0002, 0xfffffffe, 0x0201fffe, 0xfdfdfffe, 0x01fffffe, 0xfdfffffe, 0x0001fffe, 0xfffdfffe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000303, 0xfffffcfd, 0x00000300, 0xfffffd00, 0x00000003, 0xfffffffd, 0x00000606, 0xfffff9fa, 0x00000903, 0xfffff6fd, 0x00000309, 0xfffffcf7, 0x000008fd, 0xfffff703, 0xfffffd09, 0x000002f7, 0x000005fa, 0xfffffa06, 0x00000c06, 0xfffff3fa, 0x0000060c, 0xfffff9f4, 0x00000c0c, 0xfffff3f4, 0x00000f00, 0xfffff100, 0x0000000f, 0xfffffff1, 0x00000bf7, 0xfffff409, 0xfffff70c, 0x000008f4, 0x0000180f, 0xffffe7f1, 0x00000f18, 0xfffff0e8, 0x000011fa, 0xffffee06, 0xfffffa12, 0x000005ee, 0x00001806, 0xffffe7fa, 0x00000618, 0xfffff9e8, 0x00001818, 0xffffe7e8, 0x00001b00, 0xffffe500, 0x0000001b, 0xffffffe5, 0x000011ee, 0xffffee12, 0x000017f4, 0xffffe80c, 0xfffff418, 0x00000be8, 0x0000270f, 0xffffd8f1, 0x00000f27, 0xfffff0d9, 0x00002a1b, 0xffffd5e5, 0x00001b2a, 0xffffe4d6, 0x000020f7, 0xffffdf09, 0xfffff721, 0x000008df, 0x00002a06, 0xffffd5fa, 0x0000062a, 0xfffff9d6, 0x00002d2d, 0xffffd2d3, 0x000032fd, 0xffffcd03, 0xfffffd33, 0x000002cd, 0x000020e5, 0xffffdf1b, 0xffffe521, 0x00001adf, 0x00002ceb, 0xffffd315, 0xffffeb2d, 0x000014d3, 0x00004521, 0xffffbadf, 0x00002145, 0xffffdebb, 0x00004512, 0xffffbaee, 0x00001245, 0xffffedbb, 0x00004836, 0xffffb7ca, 0x00003648, 0xffffc9b8, 0x00003eee, 0xffffc112, 0xffffee3f, 0x000011c1, 0x00004e06, 0xffffb1fa, 0x0000064e, 0xfffff9b2, 0x00005151, 0xffffaeaf, 0x000032cd, 0xffffcd33, 0x00003ed6, 0xffffc12a, 0xffffd63f, 0x000029c1, 0x000059f7, 0xffffa609, 0xfffff75a, 0x000008a6, 0x0000722a, 0xffff8dd6, 0x00002a72, 0xffffd58e, 0x0000753f, 0xffff8ac1, 0x00003f75, 0xffffc08b, 0x000050dc, 0xffffaf24, 0xffffdc51, 0x000023af, 0x00007815, 0xffff87eb, 0x00001578, 0xffffea88, 0x00007b60, 0xffff84a0, 0x0000607b, 0xffff9f85, 0x00006ee2, 0xffff911e, 0xffffe26f, 0x00001d91, 0x00005cb2, 0xffffa34e, 0xffffb25d, 0x00004da3, 0x000071bb, 0xffff8e45, 0xffffbb72, 0x0000448e, 0x00001212, 0xffffedee, 0x00002121, 0xffffdedf, 0x00003f3f, 0xffffc0c1, 0x00006c6c, 0xffff9394, 0x00000000, 0x03030000, 0xfcfd0000, 0x03000000, 0xfd000000, 0x00030000, 0xfffd0000, 0x06060000, 0xf9fa0000, 0x00000303, 0x03030303, 0xfcfd0303, 0x03000303, 0xfd000303, 0x00030303, 0xfffd0303, 0x06060303, 0xf9fa0303, 0xfffffcfd, 0x0302fcfd, 0xfcfcfcfd, 0x02fffcfd, 0xfcfffcfd, 0x0002fcfd, 0xfffcfcfd, 0x0605fcfd, 0xf9f9fcfd, 0x00000300, 0x03030300, 0xfcfd0300, 0x03000300, 0xfd000300, 0x00030300, 0xfffd0300, 0x06060300, 0xf9fa0300, 0xfffffd00, 0x0302fd00, 0xfcfcfd00, 0x02fffd00, 0xfcfffd00, 0x0002fd00, 0xfffcfd00, 0x0605fd00, 0xf9f9fd00, 0x00000003, 0x03030003, 0xfcfd0003, 0x03000003, 0xfd000003, 0x00030003, 0xfffd0003, 0x06060003, 0xf9fa0003, 0xfffffffd, 0x0302fffd, 0xfcfcfffd, 0x02fffffd, 0xfcfffffd, 0x0002fffd, 0xfffcfffd, 0x0605fffd, 0xf9f9fffd, 0x00000606, 0x03030606, 0xfcfd0606, 0x03000606, 0xfd000606, 0x00030606, 0xfffd0606, 0x06060606, 0xf9fa0606, 0xfffff9fa, 0x0302f9fa, 0xfcfcf9fa, 0x02fff9fa, 0xfcfff9fa, 0x0002f9fa, 0xfffcf9fa, 0x0605f9fa, 0xf9f9f9fa, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000404, 0xfffffbfc, 0x00000400, 0xfffffc00, 0x00000004, 0xfffffffc, 0x00000804, 0xfffff7fc, 0x00000408, 0xfffffbf8, 0x00000808, 0xfffff7f8, 0x000007f8, 0xfffff808, 0x00000bfc, 0xfffff404, 0xfffffc0c, 0x000003f4, 0x00001008, 0xffffeff8, 0x00000810, 0xfffff7f0, 0x00001010, 0xffffeff0, 0x00001400, 0xffffec00, 0x00000014, 0xffffffec, 0x00000ff4, 0xfffff00c, 0xfffff410, 0x00000bf0, 0x000017fc, 0xffffe804, 0xfffffc18, 0x000003e8, 0x00002010, 0xffffdff0, 0x00001020, 0xffffefe0, 0x00002008, 0xffffdff8, 0x00000820, 0xfffff7e0, 0x00002020, 0xffffdfe0, 0x00002400, 0xffffdc00, 0x00000024, 0xffffffdc, 0x000017e8, 0xffffe818, 0x00001ff0, 0xffffe010, 0xfffff020, 0x00000fe0, 0x00003414, 0xffffcbec, 0x00001434, 0xffffebcc, 0x00003824, 0xffffc7dc, 0x00002438, 0xffffdbc8, 0x00002bf4, 0xffffd40c, 0xfffff42c, 0x00000bd4, 0x00003808, 0xffffc7f8, 0x00000838, 0xfffff7c8, 0x00003c3c, 0xffffc3c4, 0x00003ffc, 0xffffc004, 0xfffffc40, 0x000003c0, 0x00002bdc, 0xffffd424, 0xffffdc2c, 0x000023d4, 0x00003be4, 0xffffc41c, 0xffffe43c, 0x00001bc4, 0x00005c2c, 0xffffa3d4, 0x00002c5c, 0xffffd3a4, 0x00005c18, 0xffffa3e8, 0x0000185c, 0xffffe7a4, 0x00006048, 0xffff9fb8, 0x00004860, 0xffffb7a0, 0x000053ec, 0xffffac14, 0xffffec54, 0x000013ac, 0x00006408, 0xffff9bf8, 0x00000864, 0xfffff79c, 0x00006c6c, 0xffff9394, 0x000043bc, 0xffffbc44, 0x000053c8, 0xffffac38, 0xffffc854, 0x000037ac, 0x000077f4, 0xffff880c, 0xfffff478, 0x00000b88, 0x00006bd0, 0xffff9430, 0xffffd06c, 0x00002f94, 0x00007b98, 0xffff8468, 0xffff987c, 0x00006784, 0x00001818, 0xffffe7e8, 0x00002c2c, 0xffffd3d4, 0x00005454, 0xffffabac, 0x00000000, 0x04040000, 0xfbfc0000, 0x04000000, 0xfc000000, 0x00040000, 0xfffc0000, 0x08040000, 0xf7fc0000, 0x04080000, 0x00000404, 0x04040404, 0xfbfc0404, 0x04000404, 0xfc000404, 0x00040404, 0xfffc0404, 0x08040404, 0xf7fc0404, 0x04080404, 0xfffffbfc, 0x0403fbfc, 0xfbfbfbfc, 0x03fffbfc, 0xfbfffbfc, 0x0003fbfc, 0xfffbfbfc, 0x0803fbfc, 0xf7fbfbfc, 0x0407fbfc, 0x00000400, 0x04040400, 0xfbfc0400, 0x04000400, 0xfc000400, 0x00040400, 0xfffc0400, 0x08040400, 0xf7fc0400, 0x04080400, 0xfffffc00, 0x0403fc00, 0xfbfbfc00, 0x03fffc00, 0xfbfffc00, 0x0003fc00, 0xfffbfc00, 0x0803fc00, 0xf7fbfc00, 0x0407fc00, 0x00000004, 0x04040004, 0xfbfc0004, 0x04000004, 0xfc000004, 0x00040004, 0xfffc0004, 0x08040004, 0xf7fc0004, 0x04080004, 0xfffffffc, 0x0403fffc, 0xfbfbfffc, 0x03fffffc, 0xfbfffffc, 0x0003fffc, 0xfffbfffc, 0x0803fffc, 0xf7fbfffc, 0x0407fffc, 0x00000804, 0x04040804, 0xfbfc0804, 0x04000804, 0xfc000804, 0x00040804, 0xfffc0804, 0x08040804, 0xf7fc0804, 0x04080804, 0xfffff7fc, 0x0403f7fc, 0xfbfbf7fc, 0x03fff7fc, 0xfbfff7fc, 0x0003f7fc, 0xfffbf7fc, 0x0803f7fc, 0xf7fbf7fc, 0x0407f7fc, 0x00000408, 0x04040408, 0xfbfc0408, 0x04000408, 0xfc000408, 0x00040408, 0xfffc0408, 0x08040408, 0xf7fc0408, 0x04080408, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000505, 0xfffffafb, 0x00000500, 0xfffffb00, 0x00000005, 0xfffffffb, 0x00000a0a, 0xfffff5f6, 0x00000f05, 0xfffff0fb, 0x0000050f, 0xfffffaf1, 0x000009f6, 0xfffff60a, 0x00000efb, 0xfffff105, 0xfffffb0f, 0x000004f1, 0x0000140a, 0xffffebf6, 0x00000a14, 0xfffff5ec, 0x00001414, 0xffffebec, 0x00001900, 0xffffe700, 0x00000019, 0xffffffe7, 0x000013f1, 0xffffec0f, 0xfffff114, 0x00000eec, 0x00002819, 0xffffd7e7, 0x00001928, 0xffffe6d8, 0x00001df6, 0xffffe20a, 0xfffff61e, 0x000009e2, 0x0000280a, 0xffffd7f6, 0x00000a28, 0xfffff5d8, 0x00002828, 0xffffd7d8, 0x00002d00, 0xffffd300, 0x0000002d, 0xffffffd3, 0x00001de2, 0xffffe21e, 0x000027ec, 0xffffd814, 0xffffec28, 0x000013d8, 0x00004119, 0xffffbee7, 0x00001941, 0xffffe6bf, 0x0000462d, 0xffffb9d3, 0x00002d46, 0xffffd2ba, 0x000036f1, 0xffffc90f, 0xfffff137, 0x00000ec9, 0x0000460a, 0xffffb9f6, 0x00000a46, 0xfffff5ba, 0x00004b4b, 0xffffb4b5, 0x000054fb, 0xffffab05, 0xfffffb55, 0x000004ab, 0x000036d3, 0xffffc92d, 0xffffd337, 0x00002cc9, 0x00004add, 0xffffb523, 0xffffdd4b, 0x000022b5, 0x00007337, 0xffff8cc9, 0x00003773, 0xffffc88d, 0x0000731e, 0xffff8ce2, 0x00001e73, 0xffffe18d, 0x0000785a, 0xffff87a6, 0x00005a78, 0xffffa588, 0x000068e2, 0xffff971e, 0xffffe269, 0x00001d97, 0x000054ab, 0xffffab55, 0x000068ba, 0xffff9746, 0xffffba69, 0x00004597, 0x00001e1e, 0xffffe1e2, 0x00003c3c, 0xffffc3c4, 0x00006969, 0xffff9697, 0x00000000, 0x05050000, 0xfafb0000, 0x05000000, 0xfb000000, 0x00050000, 0xfffb0000, 0x0a0a0000, 0xf5f60000, 0x0f050000, 0xf0fb0000, 0x00000505, 0x05050505, 0xfafb0505, 0x05000505, 0xfb000505, 0x00050505, 0xfffb0505, 0x0a0a0505, 0xf5f60505, 0x0f050505, 0xf0fb0505, 0xfffffafb, 0x0504fafb, 0xfafafafb, 0x04fffafb, 0xfafffafb, 0x0004fafb, 0xfffafafb, 0x0a09fafb, 0xf5f5fafb, 0x0f04fafb, 0xf0fafafb, 0x00000500, 0x05050500, 0xfafb0500, 0x05000500, 0xfb000500, 0x00050500, 0xfffb0500, 0x0a0a0500, 0xf5f60500, 0x0f050500, 0xf0fb0500, 0xfffffb00, 0x0504fb00, 0xfafafb00, 0x04fffb00, 0xfafffb00, 0x0004fb00, 0xfffafb00, 0x0a09fb00, 0xf5f5fb00, 0x0f04fb00, 0xf0fafb00, 0x00000005, 0x05050005, 0xfafb0005, 0x05000005, 0xfb000005, 0x00050005, 0xfffb0005, 0x0a0a0005, 0xf5f60005, 0x0f050005, 0xf0fb0005, 0xfffffffb, 0x0504fffb, 0xfafafffb, 0x04fffffb, 0xfafffffb, 0x0004fffb, 0xfffafffb, 0x0a09fffb, 0xf5f5fffb, 0x0f04fffb, 0xf0fafffb, 0x00000a0a, 0x05050a0a, 0xfafb0a0a, 0x05000a0a, 0xfb000a0a, 0x00050a0a, 0xfffb0a0a, 0x0a0a0a0a, 0xf5f60a0a, 0x0f050a0a, 0xf0fb0a0a, 0xfffff5f6, 0x0504f5f6, 0xfafaf5f6, 0x04fff5f6, 0xfafff5f6, 0x0004f5f6, 0xfffaf5f6, 0x0a09f5f6, 0xf5f5f5f6, 0x0f04f5f6, 0xf0faf5f6, 0x00000f05, 0x05050f05, 0xfafb0f05, 0x05000f05, 0xfb000f05, 0x00050f05, 0xfffb0f05, 0x0a0a0f05, 0xf5f60f05, 0x0f050f05, 0xf0fb0f05, 0xfffff0fb, 0x0504f0fb, 0xfafaf0fb, 0x04fff0fb, 0xfafff0fb, 0x0004f0fb, 0xfffaf0fb, 0x0a09f0fb, 0xf5f5f0fb, 0x0f04f0fb, 0xf0faf0fb, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000606, 0xfffff9fa, 0x00000600, 0xfffffa00, 0x00000006, 0xfffffffa, 0x00000c0c, 0xfffff3f4, 0x00000c06, 0xfffff3fa, 0x0000060c, 0xfffff9f4, 0x00000bf4, 0xfffff40c, 0x000011fa, 0xffffee06, 0xfffffa12, 0x000005ee, 0x0000180c, 0xffffe7f4, 0x00000c18, 0xfffff3e8, 0x00001818, 0xffffe7e8, 0x00001e00, 0xffffe200, 0x0000001e, 0xffffffe2, 0x000017ee, 0xffffe812, 0xffffee18, 0x000011e8, 0x0000301e, 0xffffcfe2, 0x00001e30, 0xffffe1d0, 0x000023fa, 0xffffdc06, 0xfffffa24, 0x000005dc, 0x0000300c, 0xffffcff4, 0x00000c30, 0xfffff3d0, 0x00003030, 0xffffcfd0, 0x00003600, 0xffffca00, 0x00000036, 0xffffffca, 0x000023dc, 0xffffdc24, 0x00002fe8, 0xffffd018, 0xffffe830, 0x000017d0, 0x00004e1e, 0xffffb1e2, 0x00001e4e, 0xffffe1b2, 0x00005436, 0xffffabca, 0x00003654, 0xffffc9ac, 0x000041ee, 0xffffbe12, 0xffffee42, 0x000011be, 0x0000540c, 0xffffabf4, 0x00000c54, 0xfffff3ac, 0x00005a5a, 0xffffa5a6, 0x00005ffa, 0xffffa006, 0xfffffa60, 0x000005a0, 0x000041ca, 0xffffbe36, 0xffffca42, 0x000035be, 0x000059d6, 0xffffa62a, 0xffffd65a, 0x000029a6, 0x00007de2, 0xffff821e, 0xffffe27e, 0x00001d82, 0x0000659a, 0xffff9a66, 0x00007dac, 0xffff8254, 0xffffac7e, 0x00005382, 0x00002424, 0xffffdbdc, 0x00004242, 0xffffbdbe, 0x00000000, 0x06060000, 0xf9fa0000, 0x06000000, 0xfa000000, 0x00060000, 0xfffa0000, 0x0c0c0000, 0xf3f40000, 0x0c060000, 0xf3fa0000, 0x060c0000, 0x00000606, 0x06060606, 0xf9fa0606, 0x06000606, 0xfa000606, 0x00060606, 0xfffa0606, 0x0c0c0606, 0xf3f40606, 0x0c060606, 0xf3fa0606, 0x060c0606, 0xfffff9fa, 0x0605f9fa, 0xf9f9f9fa, 0x05fff9fa, 0xf9fff9fa, 0x0005f9fa, 0xfff9f9fa, 0x0c0bf9fa, 0xf3f3f9fa, 0x0c05f9fa, 0xf3f9f9fa, 0x060bf9fa, 0x00000600, 0x06060600, 0xf9fa0600, 0x06000600, 0xfa000600, 0x00060600, 0xfffa0600, 0x0c0c0600, 0xf3f40600, 0x0c060600, 0xf3fa0600, 0x060c0600, 0xfffffa00, 0x0605fa00, 0xf9f9fa00, 0x05fffa00, 0xf9fffa00, 0x0005fa00, 0xfff9fa00, 0x0c0bfa00, 0xf3f3fa00, 0x0c05fa00, 0xf3f9fa00, 0x060bfa00, 0x00000006, 0x06060006, 0xf9fa0006, 0x06000006, 0xfa000006, 0x00060006, 0xfffa0006, 0x0c0c0006, 0xf3f40006, 0x0c060006, 0xf3fa0006, 0x060c0006, 0xfffffffa, 0x0605fffa, 0xf9f9fffa, 0x05fffffa, 0xf9fffffa, 0x0005fffa, 0xfff9fffa, 0x0c0bfffa, 0xf3f3fffa, 0x0c05fffa, 0xf3f9fffa, 0x060bfffa, 0x00000c0c, 0x06060c0c, 0xf9fa0c0c, 0x06000c0c, 0xfa000c0c, 0x00060c0c, 0xfffa0c0c, 0x0c0c0c0c, 0xf3f40c0c, 0x0c060c0c, 0xf3fa0c0c, 0x060c0c0c, 0xfffff3f4, 0x0605f3f4, 0xf9f9f3f4, 0x05fff3f4, 0xf9fff3f4, 0x0005f3f4, 0xfff9f3f4, 0x0c0bf3f4, 0xf3f3f3f4, 0x0c05f3f4, 0xf3f9f3f4, 0x060bf3f4, 0x00000c06, 0x06060c06, 0xf9fa0c06, 0x06000c06, 0xfa000c06, 0x00060c06, 0xfffa0c06, 0x0c0c0c06, 0xf3f40c06, 0x0c060c06, 0xf3fa0c06, 0x060c0c06, 0xfffff3fa, 0x0605f3fa, 0xf9f9f3fa, 0x05fff3fa, 0xf9fff3fa, 0x0005f3fa, 0xfff9f3fa, 0x0c0bf3fa, 0xf3f3f3fa, 0x0c05f3fa, 0xf3f9f3fa, 0x060bf3fa, 0x0000060c, 0x0606060c, 0xf9fa060c, 0x0600060c, 0xfa00060c, 0x0006060c, 0xfffa060c, 0x0c0c060c, 0xf3f4060c, 0x0c06060c, 0xf3fa060c, 0x060c060c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000707, 0xfffff8f9, 0x00000700, 0xfffff900, 0x00000007, 0xfffffff9, 0x00000e0e, 0xfffff1f2, 0x00001507, 0xffffeaf9, 0x00000715, 0xfffff8eb, 0x00000df2, 0xfffff20e, 0x000014f9, 0xffffeb07, 0xfffff915, 0x000006eb, 0x00001c0e, 0xffffe3f2, 0x00000e1c, 0xfffff1e4, 0x00001c1c, 0xffffe3e4, 0x00002300, 0xffffdd00, 0x00000023, 0xffffffdd, 0x00001beb, 0xffffe415, 0xffffeb1c, 0x000014e4, 0x00003823, 0xffffc7dd, 0x00002338, 0xffffdcc8, 0x000029f2, 0xffffd60e, 0xfffff22a, 0x00000dd6, 0x0000380e, 0xffffc7f2, 0x00000e38, 0xfffff1c8, 0x00003838, 0xffffc7c8, 0x00003f00, 0xffffc100, 0x0000003f, 0xffffffc1, 0x000029d6, 0xffffd62a, 0x000037e4, 0xffffc81c, 0xffffe438, 0x00001bc8, 0x00005b23, 0xffffa4dd, 0x0000235b, 0xffffdca5, 0x0000623f, 0xffff9dc1, 0x00003f62, 0xffffc09e, 0x00004ceb, 0xffffb315, 0xffffeb4d, 0x000014b3, 0x0000620e, 0xffff9df2, 0x00000e62, 0xfffff19e, 0x00006969, 0xffff9697, 0x000076f9, 0xffff8907, 0xfffff977, 0x00000689, 0x00004cc1, 0xffffb33f, 0xffffc14d, 0x00003eb3, 0x000068cf, 0xffff9731, 0xffffcf69, 0x00003097, 0x00007689, 0xffff8977, 0x00002a2a, 0xffffd5d6, 0x00004d4d, 0xffffb2b3, 0x00000000, 0x07070000, 0xf8f90000, 0x07000000, 0xf9000000, 0x00070000, 0xfff90000, 0x0e0e0000, 0xf1f20000, 0x15070000, 0xeaf90000, 0x07150000, 0x00000707, 0x07070707, 0xf8f90707, 0x07000707, 0xf9000707, 0x00070707, 0xfff90707, 0x0e0e0707, 0xf1f20707, 0x15070707, 0xeaf90707, 0x07150707, 0xfffff8f9, 0x0706f8f9, 0xf8f8f8f9, 0x06fff8f9, 0xf8fff8f9, 0x0006f8f9, 0xfff8f8f9, 0x0e0df8f9, 0xf1f1f8f9, 0x1506f8f9, 0xeaf8f8f9, 0x0714f8f9, 0x00000700, 0x07070700, 0xf8f90700, 0x07000700, 0xf9000700, 0x00070700, 0xfff90700, 0x0e0e0700, 0xf1f20700, 0x15070700, 0xeaf90700, 0x07150700, 0xfffff900, 0x0706f900, 0xf8f8f900, 0x06fff900, 0xf8fff900, 0x0006f900, 0xfff8f900, 0x0e0df900, 0xf1f1f900, 0x1506f900, 0xeaf8f900, 0x0714f900, 0x00000007, 0x07070007, 0xf8f90007, 0x07000007, 0xf9000007, 0x00070007, 0xfff90007, 0x0e0e0007, 0xf1f20007, 0x15070007, 0xeaf90007, 0x07150007, 0xfffffff9, 0x0706fff9, 0xf8f8fff9, 0x06fffff9, 0xf8fffff9, 0x0006fff9, 0xfff8fff9, 0x0e0dfff9, 0xf1f1fff9, 0x1506fff9, 0xeaf8fff9, 0x0714fff9, 0x00000e0e, 0x07070e0e, 0xf8f90e0e, 0x07000e0e, 0xf9000e0e, 0x00070e0e, 0xfff90e0e, 0x0e0e0e0e, 0xf1f20e0e, 0x15070e0e, 0xeaf90e0e, 0x07150e0e, 0xfffff1f2, 0x0706f1f2, 0xf8f8f1f2, 0x06fff1f2, 0xf8fff1f2, 0x0006f1f2, 0xfff8f1f2, 0x0e0df1f2, 0xf1f1f1f2, 0x1506f1f2, 0xeaf8f1f2, 0x0714f1f2, 0x00001507, 0x07071507, 0xf8f91507, 0x07001507, 0xf9001507, 0x00071507, 0xfff91507, 0x0e0e1507, 0xf1f21507, 0x15071507, 0xeaf91507, 0x07151507, 0xffffeaf9, 0x0706eaf9, 0xf8f8eaf9, 0x06ffeaf9, 0xf8ffeaf9, 0x0006eaf9, 0xfff8eaf9, 0x0e0deaf9, 0xf1f1eaf9, 0x1506eaf9, 0xeaf8eaf9, 0x0714eaf9, 0x00000715, 0x07070715, 0xf8f90715, 0x07000715, 0xf9000715, 0x00070715, 0xfff90715, 0x0e0e0715, 0xf1f20715, 0x15070715, 0xeaf90715, 0x07150715, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000808, 0xfffff7f8, 0x00000800, 0xfffff800, 0x00000008, 0xfffffff8, 0x00001010, 0xffffeff0, 0x00001008, 0xffffeff8, 0x00000810, 0xfffff7f0, 0x00000ff0, 0xfffff010, 0x000017f8, 0xffffe808, 0xfffff818, 0x000007e8, 0x00002010, 0xffffdff0, 0x00001020, 0xffffefe0, 0x00002020, 0xffffdfe0, 0x00002800, 0xffffd800, 0x00000028, 0xffffffd8, 0x00001fe8, 0xffffe018, 0xffffe820, 0x000017e0, 0x00004028, 0xffffbfd8, 0x00002840, 0xffffd7c0, 0x00002ff0, 0xffffd010, 0xfffff030, 0x00000fd0, 0x00004010, 0xffffbff0, 0x00001040, 0xffffefc0, 0x00004040, 0xffffbfc0, 0x00004800, 0xffffb800, 0x00000048, 0xffffffb8, 0x00002fd0, 0xffffd030, 0x00003fe0, 0xffffc020, 0xffffe040, 0x00001fc0, 0x00006828, 0xffff97d8, 0x00002868, 0xffffd798, 0x00007048, 0xffff8fb8, 0x00004870, 0xffffb790, 0x000057e8, 0xffffa818, 0xffffe858, 0x000017a8, 0x00007010, 0xffff8ff0, 0x00001070, 0xffffef90, 0x00007878, 0xffff8788, 0x000057b8, 0xffffa848, 0xffffb858, 0x000047a8, 0x000077c8, 0xffff8838, 0xffffc878, 0x00003788, 0x00003030, 0xffffcfd0, 0x00005858, 0xffffa7a8, 0x00000000, 0x08080000, 0xf7f80000, 0x08000000, 0xf8000000, 0x00080000, 0xfff80000, 0x10100000, 0xeff00000, 0x10080000, 0xeff80000, 0x08100000, 0x00000808, 0x08080808, 0xf7f80808, 0x08000808, 0xf8000808, 0x00080808, 0xfff80808, 0x10100808, 0xeff00808, 0x10080808, 0xeff80808, 0x08100808, 0xfffff7f8, 0x0807f7f8, 0xf7f7f7f8, 0x07fff7f8, 0xf7fff7f8, 0x0007f7f8, 0xfff7f7f8, 0x100ff7f8, 0xefeff7f8, 0x1007f7f8, 0xeff7f7f8, 0x080ff7f8, 0x00000800, 0x08080800, 0xf7f80800, 0x08000800, 0xf8000800, 0x00080800, 0xfff80800, 0x10100800, 0xeff00800, 0x10080800, 0xeff80800, 0x08100800, 0xfffff800, 0x0807f800, 0xf7f7f800, 0x07fff800, 0xf7fff800, 0x0007f800, 0xfff7f800, 0x100ff800, 0xefeff800, 0x1007f800, 0xeff7f800, 0x080ff800, 0x00000008, 0x08080008, 0xf7f80008, 0x08000008, 0xf8000008, 0x00080008, 0xfff80008, 0x10100008, 0xeff00008, 0x10080008, 0xeff80008, 0x08100008, 0xfffffff8, 0x0807fff8, 0xf7f7fff8, 0x07fffff8, 0xf7fffff8, 0x0007fff8, 0xfff7fff8, 0x100ffff8, 0xefeffff8, 0x1007fff8, 0xeff7fff8, 0x080ffff8, 0x00001010, 0x08081010, 0xf7f81010, 0x08001010, 0xf8001010, 0x00081010, 0xfff81010, 0x10101010, 0xeff01010, 0x10081010, 0xeff81010, 0x08101010, 0xffffeff0, 0x0807eff0, 0xf7f7eff0, 0x07ffeff0, 0xf7ffeff0, 0x0007eff0, 0xfff7eff0, 0x100feff0, 0xefefeff0, 0x1007eff0, 0xeff7eff0, 0x080feff0, 0x00001008, 0x08081008, 0xf7f81008, 0x08001008, 0xf8001008, 0x00081008, 0xfff81008, 0x10101008, 0xeff01008, 0x10081008, 0xeff81008, 0x08101008, 0xffffeff8, 0x0807eff8, 0xf7f7eff8, 0x07ffeff8, 0xf7ffeff8, 0x0007eff8, 0xfff7eff8, 0x100feff8, 0xefefeff8, 0x1007eff8, 0xeff7eff8, 0x080feff8, 0x00000810, 0x08080810, 0xf7f80810, 0x08000810, 0xf8000810, 0x00080810, 0xfff80810, 0x10100810, 0xeff00810, 0x10080810, 0xeff80810, 0x08100810, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000909, 0xfffff6f7, 0x00000900, 0xfffff700, 0x00000009, 0xfffffff7, 0x00001212, 0xffffedee, 0x00001b09, 0xffffe4f7, 0x0000091b, 0xfffff6e5, 0x000011ee, 0xffffee12, 0x00001af7, 0xffffe509, 0xfffff71b, 0x000008e5, 0x00002412, 0xffffdbee, 0x00001224, 0xffffeddc, 0x00002424, 0xffffdbdc, 0x00002d00, 0xffffd300, 0x0000002d, 0xffffffd3, 0x000023e5, 0xffffdc1b, 0xffffe524, 0x00001adc, 0x0000482d, 0xffffb7d3, 0x00002d48, 0xffffd2b8, 0x000035ee, 0xffffca12, 0xffffee36, 0x000011ca, 0x00004812, 0xffffb7ee, 0x00001248, 0xffffedb8, 0x00004848, 0xffffb7b8, 0x00005100, 0xffffaf00, 0x00000051, 0xffffffaf, 0x000035ca, 0xffffca36, 0x000047dc, 0xffffb824, 0xffffdc48, 0x000023b8, 0x0000752d, 0xffff8ad3, 0x00002d75, 0xffffd28b, 0x00007e51, 0xffff81af, 0x0000517e, 0xffffae82, 0x000062e5, 0xffff9d1b, 0xffffe563, 0x00001a9d, 0x000062af, 0xffff9d51, 0xffffaf63, 0x0000509d, 0x00003636, 0xffffc9ca, 0x00006c6c, 0xffff9394, 0x00000000, 0x09090000, 0xf6f70000, 0x09000000, 0xf7000000, 0x00090000, 0xfff70000, 0x12120000, 0xedee0000, 0x1b090000, 0xe4f70000, 0x091b0000, 0xf6e50000, 0x00000909, 0x09090909, 0xf6f70909, 0x09000909, 0xf7000909, 0x00090909, 0xfff70909, 0x12120909, 0xedee0909, 0x1b090909, 0xe4f70909, 0x091b0909, 0xf6e50909, 0xfffff6f7, 0x0908f6f7, 0xf6f6f6f7, 0x08fff6f7, 0xf6fff6f7, 0x0008f6f7, 0xfff6f6f7, 0x1211f6f7, 0xededf6f7, 0x1b08f6f7, 0xe4f6f6f7, 0x091af6f7, 0xf6e4f6f7, 0x00000900, 0x09090900, 0xf6f70900, 0x09000900, 0xf7000900, 0x00090900, 0xfff70900, 0x12120900, 0xedee0900, 0x1b090900, 0xe4f70900, 0x091b0900, 0xf6e50900, 0xfffff700, 0x0908f700, 0xf6f6f700, 0x08fff700, 0xf6fff700, 0x0008f700, 0xfff6f700, 0x1211f700, 0xededf700, 0x1b08f700, 0xe4f6f700, 0x091af700, 0xf6e4f700, 0x00000009, 0x09090009, 0xf6f70009, 0x09000009, 0xf7000009, 0x00090009, 0xfff70009, 0x12120009, 0xedee0009, 0x1b090009, 0xe4f70009, 0x091b0009, 0xf6e50009, 0xfffffff7, 0x0908fff7, 0xf6f6fff7, 0x08fffff7, 0xf6fffff7, 0x0008fff7, 0xfff6fff7, 0x1211fff7, 0xededfff7, 0x1b08fff7, 0xe4f6fff7, 0x091afff7, 0xf6e4fff7, 0x00001212, 0x09091212, 0xf6f71212, 0x09001212, 0xf7001212, 0x00091212, 0xfff71212, 0x12121212, 0xedee1212, 0x1b091212, 0xe4f71212, 0x091b1212, 0xf6e51212, 0xffffedee, 0x0908edee, 0xf6f6edee, 0x08ffedee, 0xf6ffedee, 0x0008edee, 0xfff6edee, 0x1211edee, 0xedededee, 0x1b08edee, 0xe4f6edee, 0x091aedee, 0xf6e4edee, 0x00001b09, 0x09091b09, 0xf6f71b09, 0x09001b09, 0xf7001b09, 0x00091b09, 0xfff71b09, 0x12121b09, 0xedee1b09, 0x1b091b09, 0xe4f71b09, 0x091b1b09, 0xf6e51b09, 0xffffe4f7, 0x0908e4f7, 0xf6f6e4f7, 0x08ffe4f7, 0xf6ffe4f7, 0x0008e4f7, 0xfff6e4f7, 0x1211e4f7, 0xedede4f7, 0x1b08e4f7, 0xe4f6e4f7, 0x091ae4f7, 0xf6e4e4f7, 0x0000091b, 0x0909091b, 0xf6f7091b, 0x0900091b, 0xf700091b, 0x0009091b, 0xfff7091b, 0x1212091b, 0xedee091b, 0x1b09091b, 0xe4f7091b, 0x091b091b, 0xf6e5091b, 0xfffff6e5, 0x0908f6e5, 0xf6f6f6e5, 0x08fff6e5, 0xf6fff6e5, 0x0008f6e5, 0xfff6f6e5, 0x1211f6e5, 0xededf6e5, 0x1b08f6e5, 0xe4f6f6e5, 0x091af6e5, 0xf6e4f6e5, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000202, 0xfffffdfe, 0x00000300, 0xfffffd00, 0x00000003, 0xfffffffd, 0x00000606, 0xfffff9fa, 0x00000700, 0xfffff900, 0x00000007, 0xfffffff9, 0x000004fb, 0xfffffb05, 0xfffffb05, 0x000004fb, 0x00000b06, 0xfffff4fa, 0x0000060b, 0xfffff9f5, 0x00000800, 0xfffff800, 0x00000008, 0xfffffff8, 0x00000b0b, 0xfffff4f5, 0x00000c00, 0xfffff400, 0x0000000c, 0xfffffff4, 0x0000110c, 0xffffeef4, 0x00000c11, 0xfffff3ef, 0x00001111, 0xffffeeef, 0x00001206, 0xffffedfa, 0x00000612, 0xfffff9ee, 0x00000af8, 0xfffff508, 0xfffff80b, 0x000007f5, 0x00000f00, 0xfffff100, 0x0000000f, 0xfffffff1, 0x00001400, 0xffffec00, 0x00000014, 0xffffffec, 0x00001912, 0xffffe6ee, 0x00001219, 0xffffede7, 0x0000190b, 0xffffe6f5, 0x00000b19, 0xfffff4e7, 0x00001919, 0xffffe6e7, 0x00000df2, 0xfffff20e, 0xfffff20e, 0x00000df2, 0x00001a00, 0xffffe600, 0x0000001a, 0xffffffe6, 0x000011f5, 0xffffee0b, 0xfffff512, 0x00000aee, 0x000015f9, 0xffffea07, 0xfffff916, 0x000006ea, 0x0000221a, 0xffffdde6, 0x00001a22, 0xffffe5de, 0x00002212, 0xffffddee, 0x00001222, 0xffffedde, 0x00002222, 0xffffddde, 0x0000230b, 0xffffdcf5, 0x00000b23, 0xfffff4dd, 0x00001d00, 0xffffe300, 0x0000001d, 0xffffffe3, 0x000015ed, 0xffffea13, 0xffffed16, 0x000012ea, 0x000019f1, 0xffffe60f, 0xfffff11a, 0x00000ee6, 0x00002500, 0xffffdb00, 0x00000025, 0xffffffdb, 0x00002c1b, 0xffffd3e5, 0x00001b2c, 0xffffe4d4, 0x00002c24, 0xffffd3dc, 0x0000242c, 0xffffdbd4, 0x00002c12, 0xffffd3ee, 0x0000122c, 0xffffedd4, 0x000020f6, 0xffffdf0a, 0xfffff621, 0x000009df, 0x00002d2d, 0xffffd2d3, 0x00000000, 0x00000000, 0x00000202, 0xfffffdfe, 0x00000300, 0xfffffd00, 0x00000003, 0xfffffffd, 0x00000606, 0xfffff9fa, 0x00000700, 0xfffff900, 0x02020000, 0x02020202, 0x0201fdfe, 0x02020300, 0x0201fd00, 0x02020003, 0x0201fffd, 0x02020606, 0x0201f9fa, 0x02020700, 0x0201f900, 0xfdfe0000, 0xfdfe0202, 0xfdfdfdfe, 0xfdfe0300, 0xfdfdfd00, 0xfdfe0003, 0xfdfdfffd, 0xfdfe0606, 0xfdfdf9fa, 0xfdfe0700, 0xfdfdf900, 0x03000000, 0x03000202, 0x02fffdfe, 0x03000300, 0x02fffd00, 0x03000003, 0x02fffffd, 0x03000606, 0x02fff9fa, 0x03000700, 0x02fff900, 0xfd000000, 0xfd000202, 0xfcfffdfe, 0xfd000300, 0xfcfffd00, 0xfd000003, 0xfcfffffd, 0xfd000606, 0xfcfff9fa, 0xfd000700, 0xfcfff900, 0x00030000, 0x00030202, 0x0002fdfe, 0x00030300, 0x0002fd00, 0x00030003, 0x0002fffd, 0x00030606, 0x0002f9fa, 0x00030700, 0x0002f900, 0xfffd0000, 0xfffd0202, 0xfffcfdfe, 0xfffd0300, 0xfffcfd00, 0xfffd0003, 0xfffcfffd, 0xfffd0606, 0xfffcf9fa, 0xfffd0700, 0xfffcf900, 0x06060000, 0x06060202, 0x0605fdfe, 0x06060300, 0x0605fd00, 0x06060003, 0x0605fffd, 0x06060606, 0x0605f9fa, 0x06060700, 0x0605f900, 0xf9fa0000, 0xf9fa0202, 0xf9f9fdfe, 0xf9fa0300, 0xf9f9fd00, 0xf9fa0003, 0xf9f9fffd, 0xf9fa0606, 0xf9f9f9fa, 0xf9fa0700, 0xf9f9f900, 0x07000000, 0x07000202, 0x06fffdfe, 0x07000300, 0x06fffd00, 0x07000003, 0x06fffffd, 0x07000606, 0x06fff9fa, 0x07000700, 0x06fff900, 0xf9000000, 0xf9000202, 0xf8fffdfe, 0xf9000300, 0xf8fffd00, 0xf9000003, 0xf8fffffd, 0xf9000606, 0xf8fff9fa, 0xf9000700, 0xf8fff900, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000200, 0xfffffe00, 0x00000002, 0xfffffffe, 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000600, 0xfffffa00, 0x00000006, 0xfffffffa, 0x000003fc, 0xfffffc04, 0xfffffa0a, 0x000005f6, 0xfffff400, 0x00000c00, 0xfffff3fa, 0xfffff406, 0x00000bfa, 0x00000c06, 0xfffffff2, 0x0000000e, 0x00000c0c, 0xfffff3f4, 0xffffee00, 0x00001200, 0xfffff40e, 0x00000bf2, 0xfffff9ee, 0xfffffa12, 0x000005ee, 0x00000612, 0xffffedf6, 0xffffee0a, 0x000011f6, 0x0000120a, 0xffffffea, 0x00000016, 0xffffe800, 0x00001800, 0xfffff3ea, 0xfffff416, 0x00000bea, 0x00000c16, 0xffffe7f8, 0xffffe808, 0x000017f8, 0x00001808, 0xfffff9e6, 0xfffffa1a, 0x000005e6, 0x0000061a, 0xffffffe4, 0x0000001c, 0x00001414, 0xffffebec, 0xffffe5f2, 0x00001a0e, 0xfffff3e2, 0x00000c1e, 0xffffdff6, 0x0000200a, 0xffffdfee, 0x00002012, 0xffffe5e6, 0x00001a1a, 0xffffebde, 0x00001422, 0xfffff3da, 0x00000c26, 0xffffdfe0, 0x00002020, 0x00002020, 0xffffd7ea, 0xffffddde, 0x00002222, 0x00000000, 0x00000200, 0xfffffe00, 0x00000002, 0xfffffffe, 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000600, 0xfffffa00, 0x00000006, 0xfffffffa, 0x02000000, 0x02000200, 0x01fffe00, 0x02000002, 0x01fffffe, 0x02000202, 0x01fffdfe, 0x02000606, 0x01fff9fa, 0x02000600, 0x01fffa00, 0x02000006, 0x01fffffa, 0xfe000000, 0xfe000200, 0xfdfffe00, 0xfe000002, 0xfdfffffe, 0xfe000202, 0xfdfffdfe, 0xfe000606, 0xfdfff9fa, 0xfe000600, 0xfdfffa00, 0xfe000006, 0xfdfffffa, 0x00020000, 0x00020200, 0x0001fe00, 0x00020002, 0x0001fffe, 0x00020202, 0x0001fdfe, 0x00020606, 0x0001f9fa, 0x00020600, 0x0001fa00, 0x00020006, 0x0001fffa, 0xfffe0000, 0xfffe0200, 0xfffdfe00, 0xfffe0002, 0xfffdfffe, 0xfffe0202, 0xfffdfdfe, 0xfffe0606, 0xfffdf9fa, 0xfffe0600, 0xfffdfa00, 0xfffe0006, 0xfffdfffa, 0x02020000, 0x02020200, 0x0201fe00, 0x02020002, 0x0201fffe, 0x02020202, 0x0201fdfe, 0x02020606, 0x0201f9fa, 0x02020600, 0x0201fa00, 0x02020006, 0x0201fffa, 0xfdfe0000, 0xfdfe0200, 0xfdfdfe00, 0xfdfe0002, 0xfdfdfffe, 0xfdfe0202, 0xfdfdfdfe, 0xfdfe0606, 0xfdfdf9fa, 0xfdfe0600, 0xfdfdfa00, 0xfdfe0006, 0xfdfdfffa, 0x06060000, 0x06060200, 0x0605fe00, 0x06060002, 0x0605fffe, 0x06060202, 0x0605fdfe, 0x06060606, 0x0605f9fa, 0x06060600, 0x0605fa00, 0x06060006, 0x0605fffa, 0xf9fa0000, 0xf9fa0200, 0xf9f9fe00, 0xf9fa0002, 0xf9f9fffe, 0xf9fa0202, 0xf9f9fdfe, 0xf9fa0606, 0xf9f9f9fa, 0xf9fa0600, 0xf9f9fa00, 0xf9fa0006, 0xf9f9fffa, 0x06000000, 0x06000200, 0x05fffe00, 0x06000002, 0x05fffffe, 0x06000202, 0x05fffdfe, 0x06000606, 0x05fff9fa, 0x06000600, 0x05fffa00, 0x06000006, 0x05fffffa, 0xfa000000, 0xfa000200, 0xf9fffe00, 0xfa000002, 0xf9fffffe, 0xfa000202, 0xf9fffdfe, 0xfa000606, 0xf9fff9fa, 0xfa000600, 0xf9fffa00, 0xfa000006, 0xf9fffffa, 0x00060000, 0x00060200, 0x0005fe00, 0x00060002, 0x0005fffe, 0x00060202, 0x0005fdfe, 0x00060606, 0x0005f9fa, 0x00060600, 0x0005fa00, 0x00060006, 0x0005fffa, 0xfffa0000, 0xfffa0200, 0xfff9fe00, 0xfffa0002, 0xfff9fffe, 0xfffa0202, 0xfff9fdfe, 0xfffa0606, 0xfff9f9fa, 0xfffa0600, 0xfff9fa00, 0xfffa0006, 0xfff9fffa, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000200, 0xfffffe00, 0x00000002, 0xfffffffe, 0x00000404, 0xfffffbfc, 0x00000a0a, 0xfffff5f6, 0x00000a00, 0xfffff600, 0x0000000a, 0xfffffff6, 0x000005fa, 0xfffffa06, 0xfffff80e, 0x000007f2, 0xffffffee, 0x00000012, 0xfffff00a, 0x00000ff6, 0xffffe800, 0x00001800, 0xfffff7e8, 0xfffff818, 0x000007e8, 0x00000818, 0x00001212, 0xffffedee, 0xfffff014, 0x00000fec, 0xffffe5f2, 0xffffe60e, 0x000019f2, 0x00001a0e, 0xffffffe2, 0x0000001e, 0xffffde00, 0x00002200, 0xfffff7de, 0xfffff822, 0x000007de, 0x00000822, 0xffffede2, 0xffffee1e, 0x000011e2, 0x0000121e, 0xffffddf6, 0xffffde0a, 0x000021f6, 0x0000220a, 0xffffddec, 0x00002214, 0xffffffd8, 0x00000028, 0x00001e1e, 0xffffe1e2, 0xffffedd8, 0x00001228, 0xffffd400, 0x00002c00, 0xffffd3f0, 0x00002c10, 0xffffdbdc, 0xffffdbdc, 0x00002424, 0xffffd3e6, 0x00002c1a, 0xffffe5d2, 0x00001a2e, 0xffffedcc, 0x00001234, 0xffffc9ec, 0xffffd3d4, 0x00002c2c, 0xffffc9e0, 0xffffd1d2, 0xffffd1d2, 0x00002e2e, 0x00000000, 0x00000200, 0xfffffe00, 0x00000002, 0xfffffffe, 0x00000404, 0xfffffbfc, 0x00000a0a, 0xfffff5f6, 0x00000a00, 0xfffff600, 0x0000000a, 0xfffffff6, 0x02000000, 0x02000200, 0x01fffe00, 0x02000002, 0x01fffffe, 0x02000404, 0x01fffbfc, 0x02000a0a, 0x01fff5f6, 0x02000a00, 0x01fff600, 0x0200000a, 0x01fffff6, 0xfe000000, 0xfe000200, 0xfdfffe00, 0xfe000002, 0xfdfffffe, 0xfe000404, 0xfdfffbfc, 0xfe000a0a, 0xfdfff5f6, 0xfe000a00, 0xfdfff600, 0xfe00000a, 0xfdfffff6, 0x00020000, 0x00020200, 0x0001fe00, 0x00020002, 0x0001fffe, 0x00020404, 0x0001fbfc, 0x00020a0a, 0x0001f5f6, 0x00020a00, 0x0001f600, 0x0002000a, 0x0001fff6, 0xfffe0000, 0xfffe0200, 0xfffdfe00, 0xfffe0002, 0xfffdfffe, 0xfffe0404, 0xfffdfbfc, 0xfffe0a0a, 0xfffdf5f6, 0xfffe0a00, 0xfffdf600, 0xfffe000a, 0xfffdfff6, 0x04040000, 0x04040200, 0x0403fe00, 0x04040002, 0x0403fffe, 0x04040404, 0x0403fbfc, 0x04040a0a, 0x0403f5f6, 0x04040a00, 0x0403f600, 0x0404000a, 0x0403fff6, 0xfbfc0000, 0xfbfc0200, 0xfbfbfe00, 0xfbfc0002, 0xfbfbfffe, 0xfbfc0404, 0xfbfbfbfc, 0xfbfc0a0a, 0xfbfbf5f6, 0xfbfc0a00, 0xfbfbf600, 0xfbfc000a, 0xfbfbfff6, 0x0a0a0000, 0x0a0a0200, 0x0a09fe00, 0x0a0a0002, 0x0a09fffe, 0x0a0a0404, 0x0a09fbfc, 0x0a0a0a0a, 0x0a09f5f6, 0x0a0a0a00, 0x0a09f600, 0x0a0a000a, 0x0a09fff6, 0xf5f60000, 0xf5f60200, 0xf5f5fe00, 0xf5f60002, 0xf5f5fffe, 0xf5f60404, 0xf5f5fbfc, 0xf5f60a0a, 0xf5f5f5f6, 0xf5f60a00, 0xf5f5f600, 0xf5f6000a, 0xf5f5fff6, 0x0a000000, 0x0a000200, 0x09fffe00, 0x0a000002, 0x09fffffe, 0x0a000404, 0x09fffbfc, 0x0a000a0a, 0x09fff5f6, 0x0a000a00, 0x09fff600, 0x0a00000a, 0x09fffff6, 0xf6000000, 0xf6000200, 0xf5fffe00, 0xf6000002, 0xf5fffffe, 0xf6000404, 0xf5fffbfc, 0xf6000a0a, 0xf5fff5f6, 0xf6000a00, 0xf5fff600, 0xf600000a, 0xf5fffff6, 0x000a0000, 0x000a0200, 0x0009fe00, 0x000a0002, 0x0009fffe, 0x000a0404, 0x0009fbfc, 0x000a0a0a, 0x0009f5f6, 0x000a0a00, 0x0009f600, 0x000a000a, 0x0009fff6, 0xfff60000, 0xfff60200, 0xfff5fe00, 0xfff60002, 0xfff5fffe, 0xfff60404, 0xfff5fbfc, 0xfff60a0a, 0xfff5f5f6, 0xfff60a00, 0xfff5f600, 0xfff6000a, 0xfff5fff6, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000400, 0xfffffc00, 0x00000004, 0xfffffffc, 0x00000404, 0xfffffbfc, 0x00000c0c, 0xfffff3f4, 0x00000c00, 0xfffff400, 0x0000000c, 0xfffffff4, 0x000007f8, 0xfffff808, 0xfffff008, 0x00000ff8, 0xffffe800, 0x00001800, 0xfffff7e8, 0xfffff818, 0x000007e8, 0x00000818, 0xfffff014, 0x00000fec, 0xffffffe4, 0x0000001c, 0xffffe7f0, 0xffffe810, 0x000017f0, 0x00001810, 0xffffe000, 0x00002000, 0xffffefe4, 0xfffff01c, 0x00000fe4, 0x0000101c, 0xffffdff8, 0xffffe008, 0xfffff7e0, 0xfffff820, 0x000007e0, 0x00000820, 0x00001ff8, 0x00002008, 0x00001818, 0xffffe7e8, 0xffffe818, 0x000017e8, 0xffffdfec, 0x00002014, 0xffffffd8, 0x00000028, 0xffffefd8, 0x00001028, 0xffffd400, 0xffffd400, 0xffffffd4, 0x0000002c, 0x00002c00, 0x00002c00, 0xffffdfe0, 0x00002020, 0xffffd3f0, 0x00002c10, 0xffffd3e8, 0xffffe7d4, 0x0000182c, 0x00002c18, 0xffffefd0, 0x00001030, 0xffffdbdc, 0xffffdbdc, 0x00002424, 0x00002424, 0xffffcbec, 0x00002828, 0xffffd7d8, 0xffffcbe0, 0x00000000, 0x00000400, 0xfffffc00, 0x00000004, 0xfffffffc, 0x00000404, 0xfffffbfc, 0x00000c0c, 0xfffff3f4, 0x00000c00, 0xfffff400, 0x0000000c, 0xfffffff4, 0x04000000, 0x04000400, 0x03fffc00, 0x04000004, 0x03fffffc, 0x04000404, 0x03fffbfc, 0x04000c0c, 0x03fff3f4, 0x04000c00, 0x03fff400, 0x0400000c, 0x03fffff4, 0xfc000000, 0xfc000400, 0xfbfffc00, 0xfc000004, 0xfbfffffc, 0xfc000404, 0xfbfffbfc, 0xfc000c0c, 0xfbfff3f4, 0xfc000c00, 0xfbfff400, 0xfc00000c, 0xfbfffff4, 0x00040000, 0x00040400, 0x0003fc00, 0x00040004, 0x0003fffc, 0x00040404, 0x0003fbfc, 0x00040c0c, 0x0003f3f4, 0x00040c00, 0x0003f400, 0x0004000c, 0x0003fff4, 0xfffc0000, 0xfffc0400, 0xfffbfc00, 0xfffc0004, 0xfffbfffc, 0xfffc0404, 0xfffbfbfc, 0xfffc0c0c, 0xfffbf3f4, 0xfffc0c00, 0xfffbf400, 0xfffc000c, 0xfffbfff4, 0x04040000, 0x04040400, 0x0403fc00, 0x04040004, 0x0403fffc, 0x04040404, 0x0403fbfc, 0x04040c0c, 0x0403f3f4, 0x04040c00, 0x0403f400, 0x0404000c, 0x0403fff4, 0xfbfc0000, 0xfbfc0400, 0xfbfbfc00, 0xfbfc0004, 0xfbfbfffc, 0xfbfc0404, 0xfbfbfbfc, 0xfbfc0c0c, 0xfbfbf3f4, 0xfbfc0c00, 0xfbfbf400, 0xfbfc000c, 0xfbfbfff4, 0x0c0c0000, 0x0c0c0400, 0x0c0bfc00, 0x0c0c0004, 0x0c0bfffc, 0x0c0c0404, 0x0c0bfbfc, 0x0c0c0c0c, 0x0c0bf3f4, 0x0c0c0c00, 0x0c0bf400, 0x0c0c000c, 0x0c0bfff4, 0xf3f40000, 0xf3f40400, 0xf3f3fc00, 0xf3f40004, 0xf3f3fffc, 0xf3f40404, 0xf3f3fbfc, 0xf3f40c0c, 0xf3f3f3f4, 0xf3f40c00, 0xf3f3f400, 0xf3f4000c, 0xf3f3fff4, 0x0c000000, 0x0c000400, 0x0bfffc00, 0x0c000004, 0x0bfffffc, 0x0c000404, 0x0bfffbfc, 0x0c000c0c, 0x0bfff3f4, 0x0c000c00, 0x0bfff400, 0x0c00000c, 0x0bfffff4, 0xf4000000, 0xf4000400, 0xf3fffc00, 0xf4000004, 0xf3fffffc, 0xf4000404, 0xf3fffbfc, 0xf4000c0c, 0xf3fff3f4, 0xf4000c00, 0xf3fff400, 0xf400000c, 0xf3fffff4, 0x000c0000, 0x000c0400, 0x000bfc00, 0x000c0004, 0x000bfffc, 0x000c0404, 0x000bfbfc, 0x000c0c0c, 0x000bf3f4, 0x000c0c00, 0x000bf400, 0x000c000c, 0x000bfff4, 0xfff40000, 0xfff40400, 0xfff3fc00, 0xfff40004, 0xfff3fffc, 0xfff40404, 0xfff3fbfc, 0xfff40c0c, 0xfff3f3f4, 0xfff40c00, 0xfff3f400, 0xfff4000c, 0xfff3fff4, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000c0c, 0xfffff3f4, 0x00001414, 0xffffebec, 0x00002020, 0xffffdfe0, 0x00002e2e, 0xffffd1d2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000c0c, 0xfffff3f4, 0x00001414, 0xffffebec, 0x00002020, 0xffffdfe0, 0x00002e2e, 0xffffd1d2, 0x02020000, 0x02020202, 0x0201fdfe, 0x02020606, 0x0201f9fa, 0x02020c0c, 0x0201f3f4, 0x02021414, 0x0201ebec, 0x02022020, 0x0201dfe0, 0x02022e2e, 0x0201d1d2, 0xfdfe0000, 0xfdfe0202, 0xfdfdfdfe, 0xfdfe0606, 0xfdfdf9fa, 0xfdfe0c0c, 0xfdfdf3f4, 0xfdfe1414, 0xfdfdebec, 0xfdfe2020, 0xfdfddfe0, 0xfdfe2e2e, 0xfdfdd1d2, 0x06060000, 0x06060202, 0x0605fdfe, 0x06060606, 0x0605f9fa, 0x06060c0c, 0x0605f3f4, 0x06061414, 0x0605ebec, 0x06062020, 0x0605dfe0, 0x06062e2e, 0x0605d1d2, 0xf9fa0000, 0xf9fa0202, 0xf9f9fdfe, 0xf9fa0606, 0xf9f9f9fa, 0xf9fa0c0c, 0xf9f9f3f4, 0xf9fa1414, 0xf9f9ebec, 0xf9fa2020, 0xf9f9dfe0, 0xf9fa2e2e, 0xf9f9d1d2, 0x0c0c0000, 0x0c0c0202, 0x0c0bfdfe, 0x0c0c0606, 0x0c0bf9fa, 0x0c0c0c0c, 0x0c0bf3f4, 0x0c0c1414, 0x0c0bebec, 0x0c0c2020, 0x0c0bdfe0, 0x0c0c2e2e, 0x0c0bd1d2, 0xf3f40000, 0xf3f40202, 0xf3f3fdfe, 0xf3f40606, 0xf3f3f9fa, 0xf3f40c0c, 0xf3f3f3f4, 0xf3f41414, 0xf3f3ebec, 0xf3f42020, 0xf3f3dfe0, 0xf3f42e2e, 0xf3f3d1d2, 0x14140000, 0x14140202, 0x1413fdfe, 0x14140606, 0x1413f9fa, 0x14140c0c, 0x1413f3f4, 0x14141414, 0x1413ebec, 0x14142020, 0x1413dfe0, 0x14142e2e, 0x1413d1d2, 0xebec0000, 0xebec0202, 0xebebfdfe, 0xebec0606, 0xebebf9fa, 0xebec0c0c, 0xebebf3f4, 0xebec1414, 0xebebebec, 0xebec2020, 0xebebdfe0, 0xebec2e2e, 0xebebd1d2, 0x20200000, 0x20200202, 0x201ffdfe, 0x20200606, 0x201ff9fa, 0x20200c0c, 0x201ff3f4, 0x20201414, 0x201febec, 0x20202020, 0x201fdfe0, 0x20202e2e, 0x201fd1d2, 0xdfe00000, 0xdfe00202, 0xdfdffdfe, 0xdfe00606, 0xdfdff9fa, 0xdfe00c0c, 0xdfdff3f4, 0xdfe01414, 0xdfdfebec, 0xdfe02020, 0xdfdfdfe0, 0xdfe02e2e, 0xdfdfd1d2, 0x2e2e0000, 0x2e2e0202, 0x2e2dfdfe, 0x2e2e0606, 0x2e2df9fa, 0x2e2e0c0c, 0x2e2df3f4, 0x2e2e1414, 0x2e2debec, 0x2e2e2020, 0x2e2ddfe0, 0x2e2e2e2e, 0x2e2dd1d2, 0xd1d20000, 0xd1d20202, 0xd1d1fdfe, 0xd1d20606, 0xd1d1f9fa, 0xd1d20c0c, 0xd1d1f3f4, 0xd1d21414, 0xd1d1ebec, 0xd1d22020, 0xd1d1dfe0, 0xd1d22e2e, 0xd1d1d1d2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000c0c, 0xfffff3f4, 0x00001414, 0xffffebec, 0x00002020, 0xffffdfe0, 0x00002e2e, 0xffffd1d2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000c0c, 0xfffff3f4, 0x00001414, 0xffffebec, 0x00002020, 0xffffdfe0, 0x00002e2e, 0xffffd1d2, 0x02020000, 0x02020202, 0x0201fdfe, 0x02020606, 0x0201f9fa, 0x02020c0c, 0x0201f3f4, 0x02021414, 0x0201ebec, 0x02022020, 0x0201dfe0, 0x02022e2e, 0x0201d1d2, 0xfdfe0000, 0xfdfe0202, 0xfdfdfdfe, 0xfdfe0606, 0xfdfdf9fa, 0xfdfe0c0c, 0xfdfdf3f4, 0xfdfe1414, 0xfdfdebec, 0xfdfe2020, 0xfdfddfe0, 0xfdfe2e2e, 0xfdfdd1d2, 0x06060000, 0x06060202, 0x0605fdfe, 0x06060606, 0x0605f9fa, 0x06060c0c, 0x0605f3f4, 0x06061414, 0x0605ebec, 0x06062020, 0x0605dfe0, 0x06062e2e, 0x0605d1d2, 0xf9fa0000, 0xf9fa0202, 0xf9f9fdfe, 0xf9fa0606, 0xf9f9f9fa, 0xf9fa0c0c, 0xf9f9f3f4, 0xf9fa1414, 0xf9f9ebec, 0xf9fa2020, 0xf9f9dfe0, 0xf9fa2e2e, 0xf9f9d1d2, 0x0c0c0000, 0x0c0c0202, 0x0c0bfdfe, 0x0c0c0606, 0x0c0bf9fa, 0x0c0c0c0c, 0x0c0bf3f4, 0x0c0c1414, 0x0c0bebec, 0x0c0c2020, 0x0c0bdfe0, 0x0c0c2e2e, 0x0c0bd1d2, 0xf3f40000, 0xf3f40202, 0xf3f3fdfe, 0xf3f40606, 0xf3f3f9fa, 0xf3f40c0c, 0xf3f3f3f4, 0xf3f41414, 0xf3f3ebec, 0xf3f42020, 0xf3f3dfe0, 0xf3f42e2e, 0xf3f3d1d2, 0x14140000, 0x14140202, 0x1413fdfe, 0x14140606, 0x1413f9fa, 0x14140c0c, 0x1413f3f4, 0x14141414, 0x1413ebec, 0x14142020, 0x1413dfe0, 0x14142e2e, 0x1413d1d2, 0xebec0000, 0xebec0202, 0xebebfdfe, 0xebec0606, 0xebebf9fa, 0xebec0c0c, 0xebebf3f4, 0xebec1414, 0xebebebec, 0xebec2020, 0xebebdfe0, 0xebec2e2e, 0xebebd1d2, 0x20200000, 0x20200202, 0x201ffdfe, 0x20200606, 0x201ff9fa, 0x20200c0c, 0x201ff3f4, 0x20201414, 0x201febec, 0x20202020, 0x201fdfe0, 0x20202e2e, 0x201fd1d2, 0xdfe00000, 0xdfe00202, 0xdfdffdfe, 0xdfe00606, 0xdfdff9fa, 0xdfe00c0c, 0xdfdff3f4, 0xdfe01414, 0xdfdfebec, 0xdfe02020, 0xdfdfdfe0, 0xdfe02e2e, 0xdfdfd1d2, 0x2e2e0000, 0x2e2e0202, 0x2e2dfdfe, 0x2e2e0606, 0x2e2df9fa, 0x2e2e0c0c, 0x2e2df3f4, 0x2e2e1414, 0x2e2debec, 0x2e2e2020, 0x2e2ddfe0, 0x2e2e2e2e, 0x2e2dd1d2, 0xd1d20000, 0xd1d20202, 0xd1d1fdfe, 0xd1d20606, 0xd1d1f9fa, 0xd1d20c0c, 0xd1d1f3f4, 0xd1d21414, 0xd1d1ebec, 0xd1d22020, 0xd1d1dfe0, 0xd1d22e2e, 0xd1d1d1d2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000c0c, 0xfffff3f4, 0x00001414, 0xffffebec, 0x00002020, 0xffffdfe0, 0x00002e2e, 0xffffd1d2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000c0c, 0xfffff3f4, 0x00001414, 0xffffebec, 0x00002020, 0xffffdfe0, 0x00002e2e, 0xffffd1d2, 0x02020000, 0x02020202, 0x0201fdfe, 0x02020606, 0x0201f9fa, 0x02020c0c, 0x0201f3f4, 0x02021414, 0x0201ebec, 0x02022020, 0x0201dfe0, 0x02022e2e, 0x0201d1d2, 0xfdfe0000, 0xfdfe0202, 0xfdfdfdfe, 0xfdfe0606, 0xfdfdf9fa, 0xfdfe0c0c, 0xfdfdf3f4, 0xfdfe1414, 0xfdfdebec, 0xfdfe2020, 0xfdfddfe0, 0xfdfe2e2e, 0xfdfdd1d2, 0x06060000, 0x06060202, 0x0605fdfe, 0x06060606, 0x0605f9fa, 0x06060c0c, 0x0605f3f4, 0x06061414, 0x0605ebec, 0x06062020, 0x0605dfe0, 0x06062e2e, 0x0605d1d2, 0xf9fa0000, 0xf9fa0202, 0xf9f9fdfe, 0xf9fa0606, 0xf9f9f9fa, 0xf9fa0c0c, 0xf9f9f3f4, 0xf9fa1414, 0xf9f9ebec, 0xf9fa2020, 0xf9f9dfe0, 0xf9fa2e2e, 0xf9f9d1d2, 0x0c0c0000, 0x0c0c0202, 0x0c0bfdfe, 0x0c0c0606, 0x0c0bf9fa, 0x0c0c0c0c, 0x0c0bf3f4, 0x0c0c1414, 0x0c0bebec, 0x0c0c2020, 0x0c0bdfe0, 0x0c0c2e2e, 0x0c0bd1d2, 0xf3f40000, 0xf3f40202, 0xf3f3fdfe, 0xf3f40606, 0xf3f3f9fa, 0xf3f40c0c, 0xf3f3f3f4, 0xf3f41414, 0xf3f3ebec, 0xf3f42020, 0xf3f3dfe0, 0xf3f42e2e, 0xf3f3d1d2, 0x14140000, 0x14140202, 0x1413fdfe, 0x14140606, 0x1413f9fa, 0x14140c0c, 0x1413f3f4, 0x14141414, 0x1413ebec, 0x14142020, 0x1413dfe0, 0x14142e2e, 0x1413d1d2, 0xebec0000, 0xebec0202, 0xebebfdfe, 0xebec0606, 0xebebf9fa, 0xebec0c0c, 0xebebf3f4, 0xebec1414, 0xebebebec, 0xebec2020, 0xebebdfe0, 0xebec2e2e, 0xebebd1d2, 0x20200000, 0x20200202, 0x201ffdfe, 0x20200606, 0x201ff9fa, 0x20200c0c, 0x201ff3f4, 0x20201414, 0x201febec, 0x20202020, 0x201fdfe0, 0x20202e2e, 0x201fd1d2, 0xdfe00000, 0xdfe00202, 0xdfdffdfe, 0xdfe00606, 0xdfdff9fa, 0xdfe00c0c, 0xdfdff3f4, 0xdfe01414, 0xdfdfebec, 0xdfe02020, 0xdfdfdfe0, 0xdfe02e2e, 0xdfdfd1d2, 0x2e2e0000, 0x2e2e0202, 0x2e2dfdfe, 0x2e2e0606, 0x2e2df9fa, 0x2e2e0c0c, 0x2e2df3f4, 0x2e2e1414, 0x2e2debec, 0x2e2e2020, 0x2e2ddfe0, 0x2e2e2e2e, 0x2e2dd1d2, 0xd1d20000, 0xd1d20202, 0xd1d1fdfe, 0xd1d20606, 0xd1d1f9fa, 0xd1d20c0c, 0xd1d1f3f4, 0xd1d21414, 0xd1d1ebec, 0xd1d22020, 0xd1d1dfe0, 0xd1d22e2e, 0xd1d1d1d2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000c0c, 0xfffff3f4, 0x00001414, 0xffffebec, 0x00002020, 0xffffdfe0, 0x00002e2e, 0xffffd1d2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000c0c, 0xfffff3f4, 0x00001414, 0xffffebec, 0x00002020, 0xffffdfe0, 0x00002e2e, 0xffffd1d2, 0x02020000, 0x02020202, 0x0201fdfe, 0x02020606, 0x0201f9fa, 0x02020c0c, 0x0201f3f4, 0x02021414, 0x0201ebec, 0x02022020, 0x0201dfe0, 0x02022e2e, 0x0201d1d2, 0xfdfe0000, 0xfdfe0202, 0xfdfdfdfe, 0xfdfe0606, 0xfdfdf9fa, 0xfdfe0c0c, 0xfdfdf3f4, 0xfdfe1414, 0xfdfdebec, 0xfdfe2020, 0xfdfddfe0, 0xfdfe2e2e, 0xfdfdd1d2, 0x06060000, 0x06060202, 0x0605fdfe, 0x06060606, 0x0605f9fa, 0x06060c0c, 0x0605f3f4, 0x06061414, 0x0605ebec, 0x06062020, 0x0605dfe0, 0x06062e2e, 0x0605d1d2, 0xf9fa0000, 0xf9fa0202, 0xf9f9fdfe, 0xf9fa0606, 0xf9f9f9fa, 0xf9fa0c0c, 0xf9f9f3f4, 0xf9fa1414, 0xf9f9ebec, 0xf9fa2020, 0xf9f9dfe0, 0xf9fa2e2e, 0xf9f9d1d2, 0x0c0c0000, 0x0c0c0202, 0x0c0bfdfe, 0x0c0c0606, 0x0c0bf9fa, 0x0c0c0c0c, 0x0c0bf3f4, 0x0c0c1414, 0x0c0bebec, 0x0c0c2020, 0x0c0bdfe0, 0x0c0c2e2e, 0x0c0bd1d2, 0xf3f40000, 0xf3f40202, 0xf3f3fdfe, 0xf3f40606, 0xf3f3f9fa, 0xf3f40c0c, 0xf3f3f3f4, 0xf3f41414, 0xf3f3ebec, 0xf3f42020, 0xf3f3dfe0, 0xf3f42e2e, 0xf3f3d1d2, 0x14140000, 0x14140202, 0x1413fdfe, 0x14140606, 0x1413f9fa, 0x14140c0c, 0x1413f3f4, 0x14141414, 0x1413ebec, 0x14142020, 0x1413dfe0, 0x14142e2e, 0x1413d1d2, 0xebec0000, 0xebec0202, 0xebebfdfe, 0xebec0606, 0xebebf9fa, 0xebec0c0c, 0xebebf3f4, 0xebec1414, 0xebebebec, 0xebec2020, 0xebebdfe0, 0xebec2e2e, 0xebebd1d2, 0x20200000, 0x20200202, 0x201ffdfe, 0x20200606, 0x201ff9fa, 0x20200c0c, 0x201ff3f4, 0x20201414, 0x201febec, 0x20202020, 0x201fdfe0, 0x20202e2e, 0x201fd1d2, 0xdfe00000, 0xdfe00202, 0xdfdffdfe, 0xdfe00606, 0xdfdff9fa, 0xdfe00c0c, 0xdfdff3f4, 0xdfe01414, 0xdfdfebec, 0xdfe02020, 0xdfdfdfe0, 0xdfe02e2e, 0xdfdfd1d2, 0x2e2e0000, 0x2e2e0202, 0x2e2dfdfe, 0x2e2e0606, 0x2e2df9fa, 0x2e2e0c0c, 0x2e2df3f4, 0x2e2e1414, 0x2e2debec, 0x2e2e2020, 0x2e2ddfe0, 0x2e2e2e2e, 0x2e2dd1d2, 0xd1d20000, 0xd1d20202, 0xd1d1fdfe, 0xd1d20606, 0xd1d1f9fa, 0xd1d20c0c, 0xd1d1f3f4, 0xd1d21414, 0xd1d1ebec, 0xd1d22020, 0xd1d1dfe0, 0xd1d22e2e, 0xd1d1d1d2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }; static const uint32_t correctionloworder[] = { 0x00000000, 0x02020202, 0xfdfdfdfe, 0x0302feff, 0xfcfd0101, 0xfeff0303, 0x0100fcfd, 0x04040404, 0xfbfbfbfc, 0x05050101, 0xfafafeff, 0x01010505, 0xfefefafb, 0x0403fbfc, 0xfbfc0404, 0x0605fdfe, 0xf9fa0202, 0xfdfe0606, 0x0201f9fa, 0x09090404, 0xf6f6fbfc, 0x04040909, 0xfbfbf6f7, 0x09090909, 0xf6f6f6f7, 0x0a0a0101, 0xf5f5feff, 0x01010a0a, 0xfefef5f6, 0x0807fafb, 0xf7f80505, 0xfafb0808, 0x0504f7f8, 0x0f0f0909, 0xf0f0f6f7, 0x09090f0f, 0xf6f6f0f1, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x10100404, 0xefeffbfc, 0x04041010, 0xfbfbeff0, 0x10101010, 0xefefeff0, 0x12120000, 0xedee0000, 0x00001212, 0xffffedee, 0x0c0bf3f4, 0xf3f40c0c, 0x100ff6f7, 0xeff00909, 0xf6f71010, 0x0908eff0, 0x1b1b0b0b, 0xe4e4f4f5, 0x0b0b1b1b, 0xf4f4e4e5, 0x1c1c1313, 0xe3e3eced, 0x13131c1c, 0xecece3e4, 0x1615f9fa, 0xe9ea0606, 0xf9fa1616, 0x0605e9ea, 0x1d1d0404, 0xe2e2fbfc, 0x04041d1d, 0xfbfbe2e3, 0x1e1e1e1e, 0xe1e1e1e2, 0x2120fdfe, 0xdedf0202, 0xfdfe2121, 0x0201dedf, 0x1716edee, 0xe8e91212, 0xedee1717, 0x1211e8e9, 0x1e1df0f1, 0xe1e20f0f, 0xf0f11e1e, 0x0f0ee1e2, 0x2e2e1616, 0xd1d1e9ea, 0x16162e2e, 0xe9e9d1d2, 0x2f2f0d0d, 0xd0d0f2f3, 0x0d0d2f2f, 0xf2f2d0d1, 0x31312323, 0xcecedcdd, 0x23233131, 0xdcdccecf, 0x2928f4f5, 0xd6d70b0b, 0xf4f52929, 0x0b0ad6d7, 0x33330404, 0xccccfbfc, 0x04043333, 0xfbfbcccd, 0x36363636, 0xc9c9c9ca, 0x2221ddde, 0xddde2222, 0x2a29e2e3, 0xd5d61d1d, 0xe2e32a2a, 0x1d1cd5d6, 0x3c3bf9fa, 0xc3c40606, 0xf9fa3c3c, 0x0605c3c4, 0x4c4c1b1b, 0xb3b3e4e5, 0x1b1b4c4c, 0xe4e4b3b4, 0x4d4d2b2b, 0xb2b2d4d5, 0x2b2b4d4d, 0xd4d4b2b3, 0x3736e7e8, 0xc8c91818, 0xe7e83737, 0x1817c8c9, 0x4f4f0e0e, 0xb0b0f1f2, 0x0e0e4f4f, 0xf1f1b0b1, 0x53533f3f, 0xacacc0c1, 0x3f3f5353, 0xc0c0acad, 0x4a49ebec, 0xb5b61414, 0xebec4a4a, 0x1413b5b6, 0x58580202, 0xa7a7fdfe, 0x02025858, 0xfdfda7a8, 0x5d5d5d5d, 0xa2a2a2a3, 0x3d3ccbcc, 0xc2c33434, 0xcbcc3d3d, 0x3433c2c3, 0x78783434, 0x8787cbcc, 0x34347878, 0xcbcb8788, 0x4b4ad2d3, 0xb4b52d2d, 0xd2d34b4b, 0x2d2cb4b5, 0x7d7d4b4b, 0x8282b4b5, 0x4b4b7d7d, 0xb4b48283, 0x7a7a2121, 0x8585dedf, 0x21217a7a, 0xdede8586, 0x6766f2f3, 0x98990d0d, 0xf2f36767, 0x0d0c9899, 0x605fd7d8, 0x9fa02828, 0xd7d86060, 0x28279fa0, 0x7f7eddde, 0x80812222, 0xddde7f7f, 0x22218081, 0x5958a6a7, 0xa6a75959, 0x6968b1b2, 0x96974e4e, 0xb1b26969, 0x4e4d9697, 0x0c0c0c0c, 0xf3f3f3f4, 0x17171717, 0xe8e8e8e9, 0x2a2a2a2a, 0xd5d5d5d6, 0x49494949, 0xb6b6b6b7, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0x0302feff, 0x0302feff, 0x0302feff, 0x0302feff, 0x0302feff, 0x0302feff, 0x0302feff, 0xfcfd0101, 0xfcfd0101, 0xfcfd0101, 0xfcfd0101, 0xfcfd0101, 0xfcfd0101, 0xfcfd0101, 0xfeff0303, 0xfeff0303, 0xfeff0303, 0xfeff0303, 0xfeff0303, 0xfeff0303, 0xfeff0303, 0x0100fcfd, 0x0100fcfd, 0x0100fcfd, 0x0100fcfd, 0x0100fcfd, 0x0100fcfd, 0x0100fcfd, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, 0xfeff0404, 0x0100fbfc, 0x07070707, 0xf8f8f8f9, 0x08080202, 0xf7f7fdfe, 0x02020808, 0xfdfdf7f8, 0x0908fdfe, 0xf6f70202, 0xfdfe0909, 0x0201f6f7, 0x0605f9fa, 0xf9fa0606, 0x0d0d0606, 0xf2f2f9fa, 0x06060d0d, 0xf9f9f2f3, 0x0d0d0d0d, 0xf2f2f2f3, 0x0e0e0101, 0xf1f1feff, 0x01010e0e, 0xfefef1f2, 0x0c0bf7f8, 0xf3f40808, 0xf7f80c0c, 0x0807f3f4, 0x17170e0e, 0xe8e8f1f2, 0x0e0e1717, 0xf1f1e8e9, 0x1211fafb, 0xedee0505, 0xfafb1212, 0x0504edee, 0x18180606, 0xe7e7f9fa, 0x06061818, 0xf9f9e7e8, 0x18181818, 0xe7e7e7e8, 0x1b1afeff, 0xe4e50101, 0xfeff1b1b, 0x0100e4e5, 0x1110eeef, 0xeeef1111, 0x1716f2f3, 0xe8e90d0d, 0xf2f31717, 0x0d0ce8e9, 0x28281010, 0xd7d7eff0, 0x10102828, 0xefefd7d8, 0x29291c1c, 0xd6d6e3e4, 0x1c1c2929, 0xe3e3d6d7, 0x2120f6f7, 0xdedf0909, 0xf6f72121, 0x0908dedf, 0x2b2b0606, 0xd4d4f9fa, 0x06062b2b, 0xf9f9d4d5, 0x2e2e2e2e, 0xd1d1d1d2, 0x3231fbfc, 0xcdce0404, 0xfbfc3232, 0x0403cdce, 0x2221e4e5, 0xddde1b1b, 0xe4e52222, 0x1b1addde, 0x2d2ce9ea, 0xd2d31616, 0xe9ea2d2d, 0x1615d2d3, 0x45452222, 0xbabaddde, 0x22224545, 0xddddbabb, 0x46461313, 0xb9b9eced, 0x13134646, 0xececb9ba, 0x49493535, 0xb6b6cacb, 0x35354949, 0xcacab6b7, 0x3e3deeef, 0xc1c21111, 0xeeef3e3e, 0x1110c1c2, 0x4d4d0505, 0xb2b2fafb, 0x05054d4d, 0xfafab2b3, 0x52525252, 0xadadadae, 0x3332cccd, 0xcccd3333, 0x403fd4d5, 0xbfc02b2b, 0xd4d54040, 0x2b2abfc0, 0x5a59f5f6, 0xa5a60a0a, 0xf5f65a5a, 0x0a09a5a6, 0x72722929, 0x8d8dd6d7, 0x29297272, 0xd6d68d8e, 0x74744040, 0x8b8bbfc0, 0x40407474, 0xbfbf8b8c, 0x5251dadb, 0xadae2525, 0xdadb5252, 0x2524adae, 0x77771616, 0x8888e9ea, 0x16167777, 0xe9e98889, 0x7c7c5f5f, 0x8383a0a1, 0x5f5f7c7c, 0xa0a08384, 0x6f6ee1e2, 0x90911e1e, 0xe1e26f6f, 0x1e1d9091, 0x5c5bb1b2, 0xa3a44e4e, 0xb1b25c5c, 0x4e4da3a4, 0x7170bbbc, 0x8e8f4444, 0xbbbc7171, 0x44438e8f, 0x12121212, 0xedededee, 0x22222222, 0xddddddde, 0x3f3f3f3f, 0xc0c0c0c1, 0x6d6d6d6d, 0x92929293, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0x0403feff, 0x0403feff, 0x0403feff, 0x0403feff, 0x0403feff, 0x0403feff, 0x0403feff, 0x0403feff, 0x0403feff, 0xfbfc0101, 0xfbfc0101, 0xfbfc0101, 0xfbfc0101, 0xfbfc0101, 0xfbfc0101, 0xfbfc0101, 0xfbfc0101, 0xfbfc0101, 0xfeff0404, 0xfeff0404, 0xfeff0404, 0xfeff0404, 0xfeff0404, 0xfeff0404, 0xfeff0404, 0xfeff0404, 0xfeff0404, 0x0100fbfc, 0x0100fbfc, 0x0100fbfc, 0x0100fbfc, 0x0100fbfc, 0x0100fbfc, 0x0100fbfc, 0x0100fbfc, 0x0100fbfc, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, 0x03030a0a, 0xfcfcf5f6, 0x09090909, 0xf6f6f6f7, 0x0706f8f9, 0xf8f90707, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x11110808, 0xeeeef7f8, 0x08081111, 0xf7f7eeef, 0x11111111, 0xeeeeeeef, 0x13130101, 0xececfeff, 0x01011313, 0xfefeeced, 0x100ff4f5, 0xeff00b0b, 0xf4f51010, 0x0b0aeff0, 0x1716f9fa, 0xe8e90606, 0xf9fa1717, 0x0605e8e9, 0x1f1f1212, 0xe0e0edee, 0x12121f1f, 0xedede0e1, 0x20200808, 0xdfdff7f8, 0x08082020, 0xf7f7dfe0, 0x21212121, 0xdedededf, 0x2423feff, 0xdbdc0101, 0xfeff2424, 0x0100dbdc, 0x1716e8e9, 0xe8e91717, 0x1f1eeeef, 0xe0e11111, 0xeeef1f1f, 0x1110e0e1, 0x36361515, 0xc9c9eaeb, 0x15153636, 0xeaeac9ca, 0x37372525, 0xc8c8dadb, 0x25253737, 0xdadac8c9, 0x2c2bf3f4, 0xd3d40c0c, 0xf3f42c2c, 0x0c0bd3d4, 0x39390808, 0xc6c6f7f8, 0x08083939, 0xf7f7c6c7, 0x3d3d3d3d, 0xc2c2c2c3, 0x4241fafb, 0xbdbe0505, 0xfafb4242, 0x0504bdbe, 0x2d2cdbdc, 0xd2d32424, 0xdbdc2d2d, 0x2423d2d3, 0x3c3be2e3, 0xc3c41d1d, 0xe2e33c3c, 0x1d1cc3c4, 0x5c5c2d2d, 0xa3a3d2d3, 0x2d2d5c5c, 0xd2d2a3a4, 0x5d5d1919, 0xa2a2e6e7, 0x19195d5d, 0xe6e6a2a3, 0x61614747, 0x9e9eb8b9, 0x47476161, 0xb8b89e9f, 0x5352e9ea, 0xacad1616, 0xe9ea5353, 0x1615acad, 0x66660707, 0x9999f8f9, 0x07076666, 0xf8f8999a, 0x6d6d6d6d, 0x92929293, 0x4443bbbc, 0xbbbc4444, 0x5554c6c7, 0xaaab3939, 0xc6c75555, 0x3938aaab, 0x7877f2f3, 0x87880d0d, 0xf2f37878, 0x0d0c8788, 0x6e6dcecf, 0x91923131, 0xcecf6e6e, 0x31309192, 0x7b7a9798, 0x84856868, 0x97987b7b, 0x68678485, 0x18181818, 0xe7e7e7e8, 0x2e2e2e2e, 0xd1d1d1d2, 0x54545454, 0xabababac, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0x0504feff, 0x0504feff, 0x0504feff, 0x0504feff, 0x0504feff, 0x0504feff, 0x0504feff, 0x0504feff, 0x0504feff, 0x0504feff, 0xfafb0101, 0xfafb0101, 0xfafb0101, 0xfafb0101, 0xfafb0101, 0xfafb0101, 0xfafb0101, 0xfafb0101, 0xfafb0101, 0xfafb0101, 0xfeff0505, 0xfeff0505, 0xfeff0505, 0xfeff0505, 0xfeff0505, 0xfeff0505, 0xfeff0505, 0xfeff0505, 0xfeff0505, 0xfeff0505, 0x0100fafb, 0x0100fafb, 0x0100fafb, 0x0100fafb, 0x0100fafb, 0x0100fafb, 0x0100fafb, 0x0100fafb, 0x0100fafb, 0x0100fafb, 0x0a0a0303, 0x0a0a0303, 0x0a0a0303, 0x0a0a0303, 0x0a0a0303, 0x0a0a0303, 0x0a0a0303, 0x0a0a0303, 0x0a0a0303, 0x0a0a0303, 0xf5f5fcfd, 0xf5f5fcfd, 0xf5f5fcfd, 0xf5f5fcfd, 0xf5f5fcfd, 0xf5f5fcfd, 0xf5f5fcfd, 0xf5f5fcfd, 0xf5f5fcfd, 0xf5f5fcfd, 0x03030a0a, 0x03030a0a, 0x03030a0a, 0x03030a0a, 0x03030a0a, 0x03030a0a, 0x03030a0a, 0x03030a0a, 0x03030a0a, 0x03030a0a, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x03030d0d, 0xfcfcf2f3, 0x0908f6f7, 0xf6f70909, 0x0f0efbfc, 0xf0f10404, 0xfbfc0f0f, 0x0403f0f1, 0x16160b0b, 0xe9e9f4f5, 0x0b0b1616, 0xf4f4e9ea, 0x15151515, 0xeaeaeaeb, 0x18180202, 0xe7e7fdfe, 0x02021818, 0xfdfde7e8, 0x1413f1f2, 0xebec0e0e, 0xf1f21414, 0x0e0debec, 0x26261717, 0xd9d9e8e9, 0x17172626, 0xe8e8d9da, 0x1d1cf7f8, 0xe2e30808, 0xf7f81d1d, 0x0807e2e3, 0x27270b0b, 0xd8d8f4f5, 0x0b0b2727, 0xf4f4d8d9, 0x29292929, 0xd6d6d6d7, 0x2d2cfeff, 0xd2d30101, 0xfeff2d2d, 0x0100d2d3, 0x1d1ce2e3, 0xe2e31d1d, 0x2726e9ea, 0xd8d91616, 0xe9ea2727, 0x1615d8d9, 0x43431b1b, 0xbcbce4e5, 0x1b1b4343, 0xe4e4bcbd, 0x45452f2f, 0xbabad0d1, 0x2f2f4545, 0xd0d0babb, 0x3837f0f1, 0xc7c80f0f, 0xf0f13838, 0x0f0ec7c8, 0x47470b0b, 0xb8b8f4f5, 0x0b0b4747, 0xf4f4b8b9, 0x4c4c4c4c, 0xb3b3b3b4, 0x5352f9fa, 0xacad0606, 0xf9fa5353, 0x0605acad, 0x3938d2d3, 0xc6c72d2d, 0xd2d33939, 0x2d2cc6c7, 0x4b4adbdc, 0xb4b52424, 0xdbdc4b4b, 0x2423b4b5, 0x73733838, 0x8c8cc7c8, 0x38387373, 0xc7c78c8d, 0x75751f1f, 0x8a8ae0e1, 0x1f1f7575, 0xe0e08a8b, 0x7a7a5858, 0x8585a7a8, 0x58587a7a, 0xa7a78586, 0x6867e3e4, 0x97981c1c, 0xe3e46868, 0x1c1b9798, 0x5554aaab, 0xaaab5555, 0x6a69b7b8, 0x95964848, 0xb7b86a6a, 0x48479596, 0x1e1e1e1e, 0xe1e1e1e2, 0x3a3a3a3a, 0xc5c5c5c6, 0x69696969, 0x96969697, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0x0706fdfe, 0x0706fdfe, 0x0706fdfe, 0x0706fdfe, 0x0706fdfe, 0x0706fdfe, 0x0706fdfe, 0x0706fdfe, 0x0706fdfe, 0x0706fdfe, 0x0706fdfe, 0xf8f90202, 0xf8f90202, 0xf8f90202, 0xf8f90202, 0xf8f90202, 0xf8f90202, 0xf8f90202, 0xf8f90202, 0xf8f90202, 0xf8f90202, 0xf8f90202, 0xfdfe0707, 0xfdfe0707, 0xfdfe0707, 0xfdfe0707, 0xfdfe0707, 0xfdfe0707, 0xfdfe0707, 0xfdfe0707, 0xfdfe0707, 0xfdfe0707, 0xfdfe0707, 0x0201f8f9, 0x0201f8f9, 0x0201f8f9, 0x0201f8f9, 0x0201f8f9, 0x0201f8f9, 0x0201f8f9, 0x0201f8f9, 0x0201f8f9, 0x0201f8f9, 0x0201f8f9, 0x0b0b0b0b, 0x0b0b0b0b, 0x0b0b0b0b, 0x0b0b0b0b, 0x0b0b0b0b, 0x0b0b0b0b, 0x0b0b0b0b, 0x0b0b0b0b, 0x0b0b0b0b, 0x0b0b0b0b, 0x0b0b0b0b, 0xf4f4f4f5, 0xf4f4f4f5, 0xf4f4f4f5, 0xf4f4f4f5, 0xf4f4f4f5, 0xf4f4f4f5, 0xf4f4f4f5, 0xf4f4f4f5, 0xf4f4f4f5, 0xf4f4f4f5, 0xf4f4f4f5, 0x0d0d0303, 0x0d0d0303, 0x0d0d0303, 0x0d0d0303, 0x0d0d0303, 0x0d0d0303, 0x0d0d0303, 0x0d0d0303, 0x0d0d0303, 0x0d0d0303, 0x0d0d0303, 0xf2f2fcfd, 0xf2f2fcfd, 0xf2f2fcfd, 0xf2f2fcfd, 0xf2f2fcfd, 0xf2f2fcfd, 0xf2f2fcfd, 0xf2f2fcfd, 0xf2f2fcfd, 0xf2f2fcfd, 0xf2f2fcfd, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0xfbfbf0f1, 0x0b0af4f5, 0xf4f50b0b, 0x1211fafb, 0xedee0505, 0xfafb1212, 0x0504edee, 0x1a1a0d0d, 0xe5e5f2f3, 0x0d0d1a1a, 0xf2f2e5e6, 0x1a1a1a1a, 0xe5e5e5e6, 0x1d1d0202, 0xe2e2fdfe, 0x02021d1d, 0xfdfde2e3, 0x1817eff0, 0xe7e81010, 0xeff01818, 0x100fe7e8, 0x2e2e1c1c, 0xd1d1e3e4, 0x1c1c2e2e, 0xe3e3d1d2, 0x2322f6f7, 0xdcdd0909, 0xf6f72323, 0x0908dcdd, 0x2f2f0d0d, 0xd0d0f2f3, 0x0d0d2f2f, 0xf2f2d0d1, 0x31313131, 0xcecececf, 0x3635feff, 0xc9ca0101, 0xfeff3636, 0x0100c9ca, 0x2322dcdd, 0xdcdd2323, 0x2f2ee5e6, 0xd0d11a1a, 0xe5e62f2f, 0x1a19d0d1, 0x51512020, 0xaeaedfe0, 0x20205151, 0xdfdfaeaf, 0x53533838, 0xacacc7c8, 0x38385353, 0xc7c7acad, 0x4342edee, 0xbcbd1212, 0xedee4343, 0x1211bcbd, 0x56560d0d, 0xa9a9f2f3, 0x0d0d5656, 0xf2f2a9aa, 0x5b5b5b5b, 0xa4a4a4a5, 0x6362f8f9, 0x9c9d0707, 0xf8f96363, 0x07069c9d, 0x4443c9ca, 0xbbbc3636, 0xc9ca4444, 0x3635bbbc, 0x5a59d3d4, 0xa5a62c2c, 0xd3d45a5a, 0x2c2ba5a6, 0x7c7bdedf, 0x83842121, 0xdedf7c7c, 0x21208384, 0x67669899, 0x98996767, 0x7f7ea9aa, 0x80815656, 0xa9aa7f7f, 0x56558081, 0x25252525, 0xdadadadb, 0x45454545, 0xbabababb, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, 0xf7f80202, 0xf7f80202, 0xf7f80202, 0xf7f80202, 0xf7f80202, 0xf7f80202, 0xf7f80202, 0xf7f80202, 0xf7f80202, 0xf7f80202, 0xf7f80202, 0xf7f80202, 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, 0x0201f7f8, 0x0201f7f8, 0x0201f7f8, 0x0201f7f8, 0x0201f7f8, 0x0201f7f8, 0x0201f7f8, 0x0201f7f8, 0x0201f7f8, 0x0201f7f8, 0x0201f7f8, 0x0201f7f8, 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, 0xf2f2f2f3, 0xf2f2f2f3, 0xf2f2f2f3, 0xf2f2f2f3, 0xf2f2f2f3, 0xf2f2f2f3, 0xf2f2f2f3, 0xf2f2f2f3, 0xf2f2f2f3, 0xf2f2f2f3, 0xf2f2f2f3, 0xf2f2f2f3, 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, 0xf0f0fbfc, 0xf0f0fbfc, 0xf0f0fbfc, 0xf0f0fbfc, 0xf0f0fbfc, 0xf0f0fbfc, 0xf0f0fbfc, 0xf0f0fbfc, 0xf0f0fbfc, 0xf0f0fbfc, 0xf0f0fbfc, 0xf0f0fbfc, 0x04040f0f, 0x04040f0f, 0x04040f0f, 0x04040f0f, 0x04040f0f, 0x04040f0f, 0x04040f0f, 0x04040f0f, 0x04040f0f, 0x04040f0f, 0x04040f0f, 0x04040f0f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0xfafaedee, 0x0d0cf2f3, 0xf2f30d0d, 0x1514f9fa, 0xeaeb0606, 0xf9fa1515, 0x0605eaeb, 0x1e1e0f0f, 0xe1e1f0f1, 0x0f0f1e1e, 0xf0f0e1e2, 0x1e1e1e1e, 0xe1e1e1e2, 0x22220202, 0xddddfdfe, 0x02022222, 0xfdfdddde, 0x1c1beced, 0xe3e41313, 0xeced1c1c, 0x1312e3e4, 0x36362020, 0xc9c9dfe0, 0x20203636, 0xdfdfc9ca, 0x2928f4f5, 0xd6d70b0b, 0xf4f52929, 0x0b0ad6d7, 0x37370f0f, 0xc8c8f0f1, 0x0f0f3737, 0xf0f0c8c9, 0x39393939, 0xc6c6c6c7, 0x3f3efeff, 0xc0c10101, 0xfeff3f3f, 0x0100c0c1, 0x2827d7d8, 0xd7d82828, 0x3736e1e2, 0xc8c91e1e, 0xe1e23737, 0x1e1dc8c9, 0x5e5e2525, 0xa1a1dadb, 0x25255e5e, 0xdadaa1a2, 0x60604141, 0x9f9fbebf, 0x41416060, 0xbebe9fa0, 0x4e4deaeb, 0xb1b21515, 0xeaeb4e4e, 0x1514b1b2, 0x64640f0f, 0x9b9bf0f1, 0x0f0f6464, 0xf0f09b9c, 0x6a6a6a6a, 0x95959596, 0x7473f7f8, 0x8b8c0808, 0xf7f87474, 0x08078b8c, 0x4f4ec0c1, 0xb0b13f3f, 0xc0c14f4f, 0x3f3eb0b1, 0x6968cccd, 0x96973333, 0xcccd6969, 0x33329697, 0x78778788, 0x87887878, 0x2b2b2b2b, 0xd4d4d4d5, 0x50505050, 0xafafafb0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, 0xf5f60303, 0xf5f60303, 0xf5f60303, 0xf5f60303, 0xf5f60303, 0xf5f60303, 0xf5f60303, 0xf5f60303, 0xf5f60303, 0xf5f60303, 0xf5f60303, 0xf5f60303, 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, 0x0302f5f6, 0x0302f5f6, 0x0302f5f6, 0x0302f5f6, 0x0302f5f6, 0x0302f5f6, 0x0302f5f6, 0x0302f5f6, 0x0302f5f6, 0x0302f5f6, 0x0302f5f6, 0x0302f5f6, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0x12120505, 0x12120505, 0x12120505, 0x12120505, 0x12120505, 0x12120505, 0x12120505, 0x12120505, 0x12120505, 0x12120505, 0x12120505, 0x12120505, 0xededfafb, 0xededfafb, 0xededfafb, 0xededfafb, 0xededfafb, 0xededfafb, 0xededfafb, 0xededfafb, 0xededfafb, 0xededfafb, 0xededfafb, 0xededfafb, 0x05051212, 0x05051212, 0x05051212, 0x05051212, 0x05051212, 0x05051212, 0x05051212, 0x05051212, 0x05051212, 0x05051212, 0x05051212, 0x05051212, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0xfafaebec, 0x0f0ef0f1, 0xf0f10f0f, 0x1817f8f9, 0xe7e80707, 0xf8f91818, 0x0706e7e8, 0x23231111, 0xdcdceeef, 0x11112323, 0xeeeedcdd, 0x22222222, 0xddddddde, 0x26260303, 0xd9d9fcfd, 0x03032626, 0xfcfcd9da, 0x201fe9ea, 0xdfe01616, 0xe9ea2020, 0x1615dfe0, 0x3d3d2525, 0xc2c2dadb, 0x25253d3d, 0xdadac2c3, 0x2f2ef2f3, 0xd0d10d0d, 0xf2f32f2f, 0x0d0cd0d1, 0x3f3f1111, 0xc0c0eeef, 0x11113f3f, 0xeeeec0c1, 0x41414141, 0xbebebebf, 0x4847feff, 0xb7b80101, 0xfeff4848, 0x0100b7b8, 0x2e2dd1d2, 0xd1d22e2e, 0x3f3edcdd, 0xc0c12323, 0xdcdd3f3f, 0x2322c0c1, 0x6b6b2b2b, 0x9494d4d5, 0x2b2b6b6b, 0xd4d49495, 0x6e6e4b4b, 0x9191b4b5, 0x4b4b6e6e, 0xb4b49192, 0x5958e7e8, 0xa6a71818, 0xe7e85959, 0x1817a6a7, 0x72721111, 0x8d8deeef, 0x11117272, 0xeeee8d8e, 0x79797979, 0x86868687, 0x5b5ab7b8, 0xa4a54848, 0xb7b85b5b, 0x4847a4a5, 0x7877c5c6, 0x87883a3a, 0xc5c67878, 0x3a398788, 0x31313131, 0xcecececf, 0x5c5c5c5c, 0xa3a3a3a4, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, 0xf4f50303, 0xf4f50303, 0xf4f50303, 0xf4f50303, 0xf4f50303, 0xf4f50303, 0xf4f50303, 0xf4f50303, 0xf4f50303, 0xf4f50303, 0xf4f50303, 0xf4f50303, 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, 0x0302f4f5, 0x0302f4f5, 0x0302f4f5, 0x0302f4f5, 0x0302f4f5, 0x0302f4f5, 0x0302f4f5, 0x0302f4f5, 0x0302f4f5, 0x0302f4f5, 0x0302f4f5, 0x0302f4f5, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0x14140505, 0x14140505, 0x14140505, 0x14140505, 0x14140505, 0x14140505, 0x14140505, 0x14140505, 0x14140505, 0x14140505, 0x14140505, 0x14140505, 0xebebfafb, 0xebebfafb, 0xebebfafb, 0xebebfafb, 0xebebfafb, 0xebebfafb, 0xebebfafb, 0xebebfafb, 0xebebfafb, 0xebebfafb, 0xebebfafb, 0xebebfafb, 0x05051414, 0x05051414, 0x05051414, 0x05051414, 0x05051414, 0x05051414, 0x05051414, 0x05051414, 0x05051414, 0x05051414, 0x05051414, 0x05051414, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x1110eeef, 0xeeef1111, 0x1b1af8f9, 0xe4e50707, 0xf8f91b1b, 0x0706e4e5, 0x27271313, 0xd8d8eced, 0x13132727, 0xececd8d9, 0x27272727, 0xd8d8d8d9, 0x2b2b0303, 0xd4d4fcfd, 0x03032b2b, 0xfcfcd4d5, 0x2423e7e8, 0xdbdc1818, 0xe7e82424, 0x1817dbdc, 0x45452a2a, 0xbabad5d6, 0x2a2a4545, 0xd5d5babb, 0x3534f1f2, 0xcacb0e0e, 0xf1f23535, 0x0e0dcacb, 0x47471313, 0xb8b8eced, 0x13134747, 0xececb8b9, 0x49494949, 0xb6b6b6b7, 0x504ffdfe, 0xafb00202, 0xfdfe5050, 0x0201afb0, 0x3433cbcc, 0xcbcc3434, 0x4645d8d9, 0xb9ba2727, 0xd8d94646, 0x2726b9ba, 0x79793030, 0x8686cfd0, 0x30307979, 0xcfcf8687, 0x7c7c5454, 0x8383abac, 0x54547c7c, 0xabab8384, 0x6463e4e5, 0x9b9c1b1b, 0xe4e56464, 0x1b1a9b9c, 0x6665aeaf, 0x999a5151, 0xaeaf6666, 0x5150999a, 0x37373737, 0xc8c8c8c9, 0x68686868, 0x97979798, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xfcfd0c0c, 0xfcfd0c0c, 0xfcfd0c0c, 0xfcfd0c0c, 0xfcfd0c0c, 0xfcfd0c0c, 0xfcfd0c0c, 0xfcfd0c0c, 0xfcfd0c0c, 0xfcfd0c0c, 0xfcfd0c0c, 0xfcfd0c0c, 0xfcfd0c0c, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0x17170606, 0x17170606, 0x17170606, 0x17170606, 0x17170606, 0x17170606, 0x17170606, 0x17170606, 0x17170606, 0x17170606, 0x17170606, 0x17170606, 0x17170606, 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, 0x06061717, 0x06061717, 0x06061717, 0x06061717, 0x06061717, 0x06061717, 0x06061717, 0x06061717, 0x06061717, 0x06061717, 0x06061717, 0x06061717, 0x06061717, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x0403fbfc, 0xfbfc0404, 0x0605fdfe, 0xf9fa0202, 0xfdfe0606, 0x0201f9fa, 0x08080404, 0xf7f7fbfc, 0x04040808, 0xfbfbf7f8, 0x08080808, 0xf7f7f7f8, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x0807fbfc, 0xf7f80404, 0xfbfc0808, 0x0403f7f8, 0x0e0e0808, 0xf1f1f7f8, 0x08080e0e, 0xf7f7f1f2, 0x0c0bfdfe, 0xf3f40202, 0xfdfe0c0c, 0x0201f3f4, 0x10100404, 0xefeffbfc, 0x04041010, 0xfbfbeff0, 0x10101010, 0xefefeff0, 0x12120000, 0xedee0000, 0x00001212, 0xffffedee, 0x0c0bf3f4, 0xf3f40c0c, 0x100ff7f8, 0xeff00808, 0xf7f81010, 0x0807eff0, 0x1a1a0a0a, 0xe5e5f5f6, 0x0a0a1a1a, 0xf5f5e5e6, 0x1c1c1212, 0xe3e3edee, 0x12121c1c, 0xedede3e4, 0x1615f9fa, 0xe9ea0606, 0xf9fa1616, 0x0605e9ea, 0x1c1c0404, 0xe3e3fbfc, 0x04041c1c, 0xfbfbe3e4, 0x1e1e1e1e, 0xe1e1e1e2, 0x201ffdfe, 0xdfe00202, 0xfdfe2020, 0x0201dfe0, 0x1615edee, 0xe9ea1212, 0xedee1616, 0x1211e9ea, 0x1e1df1f2, 0xe1e20e0e, 0xf1f21e1e, 0x0e0de1e2, 0x2e2e1616, 0xd1d1e9ea, 0x16162e2e, 0xe9e9d1d2, 0x2e2e0c0c, 0xd1d1f3f4, 0x0c0c2e2e, 0xf3f3d1d2, 0x30302222, 0xcfcfddde, 0x22223030, 0xddddcfd0, 0x2827f5f6, 0xd7d80a0a, 0xf5f62828, 0x0a09d7d8, 0x32320404, 0xcdcdfbfc, 0x04043232, 0xfbfbcdce, 0x36363636, 0xc9c9c9ca, 0x2221ddde, 0xddde2222, 0x2a29e3e4, 0xd5d61c1c, 0xe3e42a2a, 0x1c1bd5d6, 0x3c3bf9fa, 0xc3c40606, 0xf9fa3c3c, 0x0605c3c4, 0x4c4c1a1a, 0xb3b3e5e6, 0x1a1a4c4c, 0xe5e5b3b4, 0x4c4c2a2a, 0xb3b3d5d6, 0x2a2a4c4c, 0xd5d5b3b4, 0x3635e7e8, 0xc9ca1818, 0xe7e83636, 0x1817c9ca, 0x4e4e0e0e, 0xb1b1f1f2, 0x0e0e4e4e, 0xf1f1b1b2, 0x52523e3e, 0xadadc1c2, 0x3e3e5252, 0xc1c1adae, 0x4a49ebec, 0xb5b61414, 0xebec4a4a, 0x1413b5b6, 0x58580202, 0xa7a7fdfe, 0x02025858, 0xfdfda7a8, 0x5c5c5c5c, 0xa3a3a3a4, 0x3c3bcbcc, 0xc3c43434, 0xcbcc3c3c, 0x3433c3c4, 0x76763434, 0x8989cbcc, 0x34347676, 0xcbcb898a, 0x4a49d3d4, 0xb5b62c2c, 0xd3d44a4a, 0x2c2bb5b6, 0x76764a4a, 0x8989b5b6, 0x4a4a7676, 0xb5b5898a, 0x76762020, 0x8989dfe0, 0x20207676, 0xdfdf898a, 0x6665f3f4, 0x999a0c0c, 0xf3f46666, 0x0c0b999a, 0x605fd7d8, 0x9fa02828, 0xd7d86060, 0x28279fa0, 0x7675ddde, 0x898a2222, 0xddde7676, 0x2221898a, 0x5857a7a8, 0xa7a85858, 0x6867b1b2, 0x97984e4e, 0xb1b26868, 0x4e4d9798, 0x0c0c0c0c, 0xf3f3f3f4, 0x16161616, 0xe9e9e9ea, 0x2a2a2a2a, 0xd5d5d5d6, 0x48484848, 0xb7b7b7b8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x09090303, 0xf6f6fcfd, 0x03030909, 0xfcfcf6f7, 0x0908fcfd, 0xf6f70303, 0xfcfd0909, 0x0302f6f7, 0x0605f9fa, 0xf9fa0606, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0xf9f9f3f4, 0x0c0c0c0c, 0xf3f3f3f4, 0x0f0f0000, 0xf0f10000, 0x00000f0f, 0xfffff0f1, 0x0c0bf6f7, 0xf3f40909, 0xf6f70c0c, 0x0908f3f4, 0x18180f0f, 0xe7e7f0f1, 0x0f0f1818, 0xf0f0e7e8, 0x1211f9fa, 0xedee0606, 0xf9fa1212, 0x0605edee, 0x18180606, 0xe7e7f9fa, 0x06061818, 0xf9f9e7e8, 0x18181818, 0xe7e7e7e8, 0x1b1b0000, 0xe4e50000, 0x00001b1b, 0xffffe4e5, 0x1211edee, 0xedee1212, 0x1817f3f4, 0xe7e80c0c, 0xf3f41818, 0x0c0be7e8, 0x27270f0f, 0xd8d8f0f1, 0x0f0f2727, 0xf0f0d8d9, 0x2a2a1b1b, 0xd5d5e4e5, 0x1b1b2a2a, 0xe4e4d5d6, 0x2120f6f7, 0xdedf0909, 0xf6f72121, 0x0908dedf, 0x2a2a0606, 0xd5d5f9fa, 0x06062a2a, 0xf9f9d5d6, 0x2d2d2d2d, 0xd2d2d2d3, 0x3332fcfd, 0xcccd0303, 0xfcfd3333, 0x0302cccd, 0x2120e4e5, 0xdedf1b1b, 0xe4e52121, 0x1b1adedf, 0x2d2ceaeb, 0xd2d31515, 0xeaeb2d2d, 0x1514d2d3, 0x45452121, 0xbabadedf, 0x21214545, 0xdedebabb, 0x45451212, 0xbabaedee, 0x12124545, 0xededbabb, 0x48483636, 0xb7b7c9ca, 0x36364848, 0xc9c9b7b8, 0x3f3eedee, 0xc0c11212, 0xedee3f3f, 0x1211c0c1, 0x4e4e0606, 0xb1b1f9fa, 0x06064e4e, 0xf9f9b1b2, 0x51515151, 0xaeaeaeaf, 0x3332cccd, 0xcccd3333, 0x3f3ed5d6, 0xc0c12a2a, 0xd5d63f3f, 0x2a29c0c1, 0x5a59f6f7, 0xa5a60909, 0xf6f75a5a, 0x0908a5a6, 0x72722a2a, 0x8d8dd5d6, 0x2a2a7272, 0xd5d58d8e, 0x75753f3f, 0x8a8ac0c1, 0x3f3f7575, 0xc0c08a8b, 0x5150dbdc, 0xaeaf2424, 0xdbdc5151, 0x2423aeaf, 0x78781515, 0x8787eaeb, 0x15157878, 0xeaea8788, 0x7b7b6060, 0x84849fa0, 0x60607b7b, 0x9f9f8485, 0x6f6ee1e2, 0x90911e1e, 0xe1e26f6f, 0x1e1d9091, 0x5d5cb1b2, 0xa2a34e4e, 0xb1b25d5d, 0x4e4da2a3, 0x7271babb, 0x8d8e4545, 0xbabb7272, 0x45448d8e, 0x12121212, 0xedededee, 0x21212121, 0xdedededf, 0x3f3f3f3f, 0xc0c0c0c1, 0x6c6c6c6c, 0x93939394, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, 0x04040808, 0xfbfbf7f8, 0x08080808, 0xf7f7f7f8, 0x0807f7f8, 0xf7f80808, 0x0c0bfbfc, 0xf3f40404, 0xfbfc0c0c, 0x0403f3f4, 0x10100808, 0xefeff7f8, 0x08081010, 0xf7f7eff0, 0x10101010, 0xefefeff0, 0x14140000, 0xebec0000, 0x00001414, 0xffffebec, 0x100ff3f4, 0xeff00c0c, 0xf3f41010, 0x0c0beff0, 0x1817fbfc, 0xe7e80404, 0xfbfc1818, 0x0403e7e8, 0x20201010, 0xdfdfeff0, 0x10102020, 0xefefdfe0, 0x20200808, 0xdfdff7f8, 0x08082020, 0xf7f7dfe0, 0x20202020, 0xdfdfdfe0, 0x24240000, 0xdbdc0000, 0x00002424, 0xffffdbdc, 0x1817e7e8, 0xe7e81818, 0x201feff0, 0xdfe01010, 0xeff02020, 0x100fdfe0, 0x34341414, 0xcbcbebec, 0x14143434, 0xebebcbcc, 0x38382424, 0xc7c7dbdc, 0x24243838, 0xdbdbc7c8, 0x2c2bf3f4, 0xd3d40c0c, 0xf3f42c2c, 0x0c0bd3d4, 0x38380808, 0xc7c7f7f8, 0x08083838, 0xf7f7c7c8, 0x3c3c3c3c, 0xc3c3c3c4, 0x403ffbfc, 0xbfc00404, 0xfbfc4040, 0x0403bfc0, 0x2c2bdbdc, 0xd3d42424, 0xdbdc2c2c, 0x2423d3d4, 0x3c3be3e4, 0xc3c41c1c, 0xe3e43c3c, 0x1c1bc3c4, 0x5c5c2c2c, 0xa3a3d3d4, 0x2c2c5c5c, 0xd3d3a3a4, 0x5c5c1818, 0xa3a3e7e8, 0x18185c5c, 0xe7e7a3a4, 0x60604848, 0x9f9fb7b8, 0x48486060, 0xb7b79fa0, 0x5453ebec, 0xabac1414, 0xebec5454, 0x1413abac, 0x64640808, 0x9b9bf7f8, 0x08086464, 0xf7f79b9c, 0x6c6c6c6c, 0x93939394, 0x4443bbbc, 0xbbbc4444, 0x5453c7c8, 0xabac3838, 0xc7c85454, 0x3837abac, 0x7877f3f4, 0x87880c0c, 0xf3f47878, 0x0c0b8788, 0x6c6bcfd0, 0x93943030, 0xcfd06c6c, 0x302f9394, 0x7c7b9798, 0x83846868, 0x97987c7c, 0x68678384, 0x18181818, 0xe7e7e7e8, 0x2c2c2c2c, 0xd3d3d3d4, 0x54545454, 0xabababac, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0x08080404, 0x08080404, 0x08080404, 0x08080404, 0x08080404, 0x08080404, 0x08080404, 0x08080404, 0x08080404, 0x08080404, 0xf7f7fbfc, 0xf7f7fbfc, 0xf7f7fbfc, 0xf7f7fbfc, 0xf7f7fbfc, 0xf7f7fbfc, 0xf7f7fbfc, 0xf7f7fbfc, 0xf7f7fbfc, 0xf7f7fbfc, 0x04040808, 0x04040808, 0x04040808, 0x04040808, 0x04040808, 0x04040808, 0x04040808, 0x04040808, 0x04040808, 0x04040808, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x05050f0f, 0xfafaf0f1, 0x0a09f5f6, 0xf5f60a0a, 0x0f0efafb, 0xf0f10505, 0xfafb0f0f, 0x0504f0f1, 0x14140a0a, 0xebebf5f6, 0x0a0a1414, 0xf5f5ebec, 0x14141414, 0xebebebec, 0x19190000, 0xe6e70000, 0x00001919, 0xffffe6e7, 0x1413f0f1, 0xebec0f0f, 0xf0f11414, 0x0f0eebec, 0x28281919, 0xd7d7e6e7, 0x19192828, 0xe6e6d7d8, 0x1e1df5f6, 0xe1e20a0a, 0xf5f61e1e, 0x0a09e1e2, 0x28280a0a, 0xd7d7f5f6, 0x0a0a2828, 0xf5f5d7d8, 0x28282828, 0xd7d7d7d8, 0x2d2d0000, 0xd2d30000, 0x00002d2d, 0xffffd2d3, 0x1e1de1e2, 0xe1e21e1e, 0x2827ebec, 0xd7d81414, 0xebec2828, 0x1413d7d8, 0x41411919, 0xbebee6e7, 0x19194141, 0xe6e6bebf, 0x46462d2d, 0xb9b9d2d3, 0x2d2d4646, 0xd2d2b9ba, 0x3736f0f1, 0xc8c90f0f, 0xf0f13737, 0x0f0ec8c9, 0x46460a0a, 0xb9b9f5f6, 0x0a0a4646, 0xf5f5b9ba, 0x4b4b4b4b, 0xb4b4b4b5, 0x5554fafb, 0xaaab0505, 0xfafb5555, 0x0504aaab, 0x3736d2d3, 0xc8c92d2d, 0xd2d33737, 0x2d2cc8c9, 0x4b4adcdd, 0xb4b52323, 0xdcdd4b4b, 0x2322b4b5, 0x73733737, 0x8c8cc8c9, 0x37377373, 0xc8c88c8d, 0x73731e1e, 0x8c8ce1e2, 0x1e1e7373, 0xe1e18c8d, 0x78785a5a, 0x8787a5a6, 0x5a5a7878, 0xa5a58788, 0x6968e1e2, 0x96971e1e, 0xe1e26969, 0x1e1d9697, 0x5554aaab, 0xaaab5555, 0x6968b9ba, 0x96974646, 0xb9ba6969, 0x46459697, 0x1e1e1e1e, 0xe1e1e1e2, 0x3c3c3c3c, 0xc3c3c3c4, 0x69696969, 0x96969697, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0x05050000, 0x05050000, 0x05050000, 0x05050000, 0x05050000, 0x05050000, 0x05050000, 0x05050000, 0x05050000, 0x05050000, 0x05050000, 0xfafb0000, 0xfafb0000, 0xfafb0000, 0xfafb0000, 0xfafb0000, 0xfafb0000, 0xfafb0000, 0xfafb0000, 0xfafb0000, 0xfafb0000, 0xfafb0000, 0x00000505, 0x00000505, 0x00000505, 0x00000505, 0x00000505, 0x00000505, 0x00000505, 0x00000505, 0x00000505, 0x00000505, 0x00000505, 0xfffffafb, 0xfffffafb, 0xfffffafb, 0xfffffafb, 0xfffffafb, 0xfffffafb, 0xfffffafb, 0xfffffafb, 0xfffffafb, 0xfffffafb, 0xfffffafb, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0x0f0f0505, 0x0f0f0505, 0x0f0f0505, 0x0f0f0505, 0x0f0f0505, 0x0f0f0505, 0x0f0f0505, 0x0f0f0505, 0x0f0f0505, 0x0f0f0505, 0x0f0f0505, 0xf0f0fafb, 0xf0f0fafb, 0xf0f0fafb, 0xf0f0fafb, 0xf0f0fafb, 0xf0f0fafb, 0xf0f0fafb, 0xf0f0fafb, 0xf0f0fafb, 0xf0f0fafb, 0xf0f0fafb, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0xf9f9f3f4, 0x0c0bf3f4, 0xf3f40c0c, 0x1211f9fa, 0xedee0606, 0xf9fa1212, 0x0605edee, 0x18180c0c, 0xe7e7f3f4, 0x0c0c1818, 0xf3f3e7e8, 0x18181818, 0xe7e7e7e8, 0x1e1e0000, 0xe1e20000, 0x00001e1e, 0xffffe1e2, 0x1817edee, 0xe7e81212, 0xedee1818, 0x1211e7e8, 0x30301e1e, 0xcfcfe1e2, 0x1e1e3030, 0xe1e1cfd0, 0x2423f9fa, 0xdbdc0606, 0xf9fa2424, 0x0605dbdc, 0x30300c0c, 0xcfcff3f4, 0x0c0c3030, 0xf3f3cfd0, 0x30303030, 0xcfcfcfd0, 0x36360000, 0xc9ca0000, 0x00003636, 0xffffc9ca, 0x2423dbdc, 0xdbdc2424, 0x302fe7e8, 0xcfd01818, 0xe7e83030, 0x1817cfd0, 0x4e4e1e1e, 0xb1b1e1e2, 0x1e1e4e4e, 0xe1e1b1b2, 0x54543636, 0xababc9ca, 0x36365454, 0xc9c9abac, 0x4241edee, 0xbdbe1212, 0xedee4242, 0x1211bdbe, 0x54540c0c, 0xababf3f4, 0x0c0c5454, 0xf3f3abac, 0x5a5a5a5a, 0xa5a5a5a6, 0x605ff9fa, 0x9fa00606, 0xf9fa6060, 0x06059fa0, 0x4241c9ca, 0xbdbe3636, 0xc9ca4242, 0x3635bdbe, 0x5a59d5d6, 0xa5a62a2a, 0xd5d65a5a, 0x2a29a5a6, 0x7e7de1e2, 0x81821e1e, 0xe1e27e7e, 0x1e1d8182, 0x6665999a, 0x999a6666, 0x7e7dabac, 0x81825454, 0xabac7e7e, 0x54538182, 0x24242424, 0xdbdbdbdc, 0x42424242, 0xbdbdbdbe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, 0xf3f3f9fa, 0xf3f3f9fa, 0xf3f3f9fa, 0xf3f3f9fa, 0xf3f3f9fa, 0xf3f3f9fa, 0xf3f3f9fa, 0xf3f3f9fa, 0xf3f3f9fa, 0xf3f3f9fa, 0xf3f3f9fa, 0xf3f3f9fa, 0x06060c0c, 0x06060c0c, 0x06060c0c, 0x06060c0c, 0x06060c0c, 0x06060c0c, 0x06060c0c, 0x06060c0c, 0x06060c0c, 0x06060c0c, 0x06060c0c, 0x06060c0c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0xf8f8eaeb, 0x0e0df1f2, 0xf1f20e0e, 0x1514f8f9, 0xeaeb0707, 0xf8f91515, 0x0706eaeb, 0x1c1c0e0e, 0xe3e3f1f2, 0x0e0e1c1c, 0xf1f1e3e4, 0x1c1c1c1c, 0xe3e3e3e4, 0x23230000, 0xdcdd0000, 0x00002323, 0xffffdcdd, 0x1c1beaeb, 0xe3e41515, 0xeaeb1c1c, 0x1514e3e4, 0x38382323, 0xc7c7dcdd, 0x23233838, 0xdcdcc7c8, 0x2a29f1f2, 0xd5d60e0e, 0xf1f22a2a, 0x0e0dd5d6, 0x38380e0e, 0xc7c7f1f2, 0x0e0e3838, 0xf1f1c7c8, 0x38383838, 0xc7c7c7c8, 0x3f3f0000, 0xc0c10000, 0x00003f3f, 0xffffc0c1, 0x2a29d5d6, 0xd5d62a2a, 0x3837e3e4, 0xc7c81c1c, 0xe3e43838, 0x1c1bc7c8, 0x5b5b2323, 0xa4a4dcdd, 0x23235b5b, 0xdcdca4a5, 0x62623f3f, 0x9d9dc0c1, 0x3f3f6262, 0xc0c09d9e, 0x4d4ceaeb, 0xb2b31515, 0xeaeb4d4d, 0x1514b2b3, 0x62620e0e, 0x9d9df1f2, 0x0e0e6262, 0xf1f19d9e, 0x69696969, 0x96969697, 0x7776f8f9, 0x88890707, 0xf8f97777, 0x07068889, 0x4d4cc0c1, 0xb2b33f3f, 0xc0c14d4d, 0x3f3eb2b3, 0x6968cecf, 0x96973131, 0xcecf6969, 0x31309697, 0x77768889, 0x88897777, 0x2a2a2a2a, 0xd5d5d5d6, 0x4d4d4d4d, 0xb2b2b2b3, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0x00000707, 0x00000707, 0x00000707, 0x00000707, 0x00000707, 0x00000707, 0x00000707, 0x00000707, 0x00000707, 0x00000707, 0x00000707, 0x00000707, 0xfffff8f9, 0xfffff8f9, 0xfffff8f9, 0xfffff8f9, 0xfffff8f9, 0xfffff8f9, 0xfffff8f9, 0xfffff8f9, 0xfffff8f9, 0xfffff8f9, 0xfffff8f9, 0xfffff8f9, 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, 0xf1f1f1f2, 0xf1f1f1f2, 0xf1f1f1f2, 0xf1f1f1f2, 0xf1f1f1f2, 0xf1f1f1f2, 0xf1f1f1f2, 0xf1f1f1f2, 0xf1f1f1f2, 0xf1f1f1f2, 0xf1f1f1f2, 0xf1f1f1f2, 0x15150707, 0x15150707, 0x15150707, 0x15150707, 0x15150707, 0x15150707, 0x15150707, 0x15150707, 0x15150707, 0x15150707, 0x15150707, 0x15150707, 0xeaeaf8f9, 0xeaeaf8f9, 0xeaeaf8f9, 0xeaeaf8f9, 0xeaeaf8f9, 0xeaeaf8f9, 0xeaeaf8f9, 0xeaeaf8f9, 0xeaeaf8f9, 0xeaeaf8f9, 0xeaeaf8f9, 0xeaeaf8f9, 0x07071515, 0x07071515, 0x07071515, 0x07071515, 0x07071515, 0x07071515, 0x07071515, 0x07071515, 0x07071515, 0x07071515, 0x07071515, 0x07071515, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0xf7f7eff0, 0x100feff0, 0xeff01010, 0x1817f7f8, 0xe7e80808, 0xf7f81818, 0x0807e7e8, 0x20201010, 0xdfdfeff0, 0x10102020, 0xefefdfe0, 0x20202020, 0xdfdfdfe0, 0x28280000, 0xd7d80000, 0x00002828, 0xffffd7d8, 0x201fe7e8, 0xdfe01818, 0xe7e82020, 0x1817dfe0, 0x40402828, 0xbfbfd7d8, 0x28284040, 0xd7d7bfc0, 0x302feff0, 0xcfd01010, 0xeff03030, 0x100fcfd0, 0x40401010, 0xbfbfeff0, 0x10104040, 0xefefbfc0, 0x40404040, 0xbfbfbfc0, 0x48480000, 0xb7b80000, 0x00004848, 0xffffb7b8, 0x302fcfd0, 0xcfd03030, 0x403fdfe0, 0xbfc02020, 0xdfe04040, 0x201fbfc0, 0x68682828, 0x9797d7d8, 0x28286868, 0xd7d79798, 0x70704848, 0x8f8fb7b8, 0x48487070, 0xb7b78f90, 0x5857e7e8, 0xa7a81818, 0xe7e85858, 0x1817a7a8, 0x70701010, 0x8f8feff0, 0x10107070, 0xefef8f90, 0x78787878, 0x87878788, 0x5857b7b8, 0xa7a84848, 0xb7b85858, 0x4847a7a8, 0x7877c7c8, 0x87883838, 0xc7c87878, 0x38378788, 0x30303030, 0xcfcfcfd0, 0x58585858, 0xa7a7a7a8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0x08080000, 0x08080000, 0x08080000, 0x08080000, 0x08080000, 0x08080000, 0x08080000, 0x08080000, 0x08080000, 0x08080000, 0x08080000, 0x08080000, 0xf7f80000, 0xf7f80000, 0xf7f80000, 0xf7f80000, 0xf7f80000, 0xf7f80000, 0xf7f80000, 0xf7f80000, 0xf7f80000, 0xf7f80000, 0xf7f80000, 0xf7f80000, 0x00000808, 0x00000808, 0x00000808, 0x00000808, 0x00000808, 0x00000808, 0x00000808, 0x00000808, 0x00000808, 0x00000808, 0x00000808, 0x00000808, 0xfffff7f8, 0xfffff7f8, 0xfffff7f8, 0xfffff7f8, 0xfffff7f8, 0xfffff7f8, 0xfffff7f8, 0xfffff7f8, 0xfffff7f8, 0xfffff7f8, 0xfffff7f8, 0xfffff7f8, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0x10100808, 0x10100808, 0x10100808, 0x10100808, 0x10100808, 0x10100808, 0x10100808, 0x10100808, 0x10100808, 0x10100808, 0x10100808, 0x10100808, 0xefeff7f8, 0xefeff7f8, 0xefeff7f8, 0xefeff7f8, 0xefeff7f8, 0xefeff7f8, 0xefeff7f8, 0xefeff7f8, 0xefeff7f8, 0xefeff7f8, 0xefeff7f8, 0xefeff7f8, 0x08081010, 0x08081010, 0x08081010, 0x08081010, 0x08081010, 0x08081010, 0x08081010, 0x08081010, 0x08081010, 0x08081010, 0x08081010, 0x08081010, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x1211edee, 0xedee1212, 0x1b1af6f7, 0xe4e50909, 0xf6f71b1b, 0x0908e4e5, 0x24241212, 0xdbdbedee, 0x12122424, 0xededdbdc, 0x24242424, 0xdbdbdbdc, 0x2d2d0000, 0xd2d30000, 0x00002d2d, 0xffffd2d3, 0x2423e4e5, 0xdbdc1b1b, 0xe4e52424, 0x1b1adbdc, 0x48482d2d, 0xb7b7d2d3, 0x2d2d4848, 0xd2d2b7b8, 0x3635edee, 0xc9ca1212, 0xedee3636, 0x1211c9ca, 0x48481212, 0xb7b7edee, 0x12124848, 0xededb7b8, 0x48484848, 0xb7b7b7b8, 0x51510000, 0xaeaf0000, 0x00005151, 0xffffaeaf, 0x3635c9ca, 0xc9ca3636, 0x4847dbdc, 0xb7b82424, 0xdbdc4848, 0x2423b7b8, 0x75752d2d, 0x8a8ad2d3, 0x2d2d7575, 0xd2d28a8b, 0x7e7e5151, 0x8181aeaf, 0x51517e7e, 0xaeae8182, 0x6362e4e5, 0x9c9d1b1b, 0xe4e56363, 0x1b1a9c9d, 0x6362aeaf, 0x9c9d5151, 0xaeaf6363, 0x51509c9d, 0x36363636, 0xc9c9c9ca, 0x6c6c6c6c, 0x93939394, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0x09090000, 0x09090000, 0x09090000, 0x09090000, 0x09090000, 0x09090000, 0x09090000, 0x09090000, 0x09090000, 0x09090000, 0x09090000, 0x09090000, 0x09090000, 0xf6f70000, 0xf6f70000, 0xf6f70000, 0xf6f70000, 0xf6f70000, 0xf6f70000, 0xf6f70000, 0xf6f70000, 0xf6f70000, 0xf6f70000, 0xf6f70000, 0xf6f70000, 0xf6f70000, 0x00000909, 0x00000909, 0x00000909, 0x00000909, 0x00000909, 0x00000909, 0x00000909, 0x00000909, 0x00000909, 0x00000909, 0x00000909, 0x00000909, 0x00000909, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, 0x09091b1b, 0x09091b1b, 0x09091b1b, 0x09091b1b, 0x09091b1b, 0x09091b1b, 0x09091b1b, 0x09091b1b, 0x09091b1b, 0x09091b1b, 0x09091b1b, 0x09091b1b, 0x09091b1b, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0504fafb, 0xfafb0505, 0xfafb0505, 0x0504fafb, 0x0b0b0606, 0xf4f4f9fa, 0x06060b0b, 0xf9f9f4f5, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x0b0b0b0b, 0xf4f4f4f5, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x11110c0c, 0xeeeef3f4, 0x0c0c1111, 0xf3f3eeef, 0x11111111, 0xeeeeeeef, 0x12120606, 0xededf9fa, 0x06061212, 0xf9f9edee, 0x0b0af7f8, 0xf4f50808, 0xf7f80b0b, 0x0807f4f5, 0x0f0f0000, 0xf0f10000, 0x00000f0f, 0xfffff0f1, 0x14140000, 0xebec0000, 0x00001414, 0xffffebec, 0x19191212, 0xe6e6edee, 0x12121919, 0xedede6e7, 0x19190b0b, 0xe6e6f4f5, 0x0b0b1919, 0xf4f4e6e7, 0x19191919, 0xe6e6e6e7, 0x0e0df1f2, 0xf1f20e0e, 0xf1f20e0e, 0x0e0df1f2, 0x1a1a0000, 0xe5e60000, 0x00001a1a, 0xffffe5e6, 0x1211f4f5, 0xedee0b0b, 0xf4f51212, 0x0b0aedee, 0x1615f8f9, 0xe9ea0707, 0xf8f91616, 0x0706e9ea, 0x22221a1a, 0xdddde5e6, 0x1a1a2222, 0xe5e5ddde, 0x22221212, 0xddddedee, 0x12122222, 0xededddde, 0x22222222, 0xddddddde, 0x23230b0b, 0xdcdcf4f5, 0x0b0b2323, 0xf4f4dcdd, 0x1d1d0000, 0xe2e30000, 0x00001d1d, 0xffffe2e3, 0x1615eced, 0xe9ea1313, 0xeced1616, 0x1312e9ea, 0x1a19f0f1, 0xe5e60f0f, 0xf0f11a1a, 0x0f0ee5e6, 0x25250000, 0xdadb0000, 0x00002525, 0xffffdadb, 0x2c2c1b1b, 0xd3d3e4e5, 0x1b1b2c2c, 0xe4e4d3d4, 0x2c2c2424, 0xd3d3dbdc, 0x24242c2c, 0xdbdbd3d4, 0x2c2c1212, 0xd3d3edee, 0x12122c2c, 0xededd3d4, 0x2120f5f6, 0xdedf0a0a, 0xf5f62121, 0x0a09dedf, 0x2d2d2d2d, 0xd2d2d2d3, 0x00000000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0403fbfc, 0xfbfc0404, 0xf9fa0a0a, 0x0605f5f6, 0xf3f40000, 0x0c0c0000, 0xf3f3f9fa, 0xf3f40606, 0x0c0bf9fa, 0x0c0c0606, 0xfffff1f2, 0x00000e0e, 0x0c0c0c0c, 0xf3f3f3f4, 0xedee0000, 0x12120000, 0xf3f40e0e, 0x0c0bf1f2, 0xf9f9edee, 0xf9fa1212, 0x0605edee, 0x06061212, 0xededf5f6, 0xedee0a0a, 0x1211f5f6, 0x12120a0a, 0xffffe9ea, 0x00001616, 0xe7e80000, 0x18180000, 0xf3f3e9ea, 0xf3f41616, 0x0c0be9ea, 0x0c0c1616, 0xe7e7f7f8, 0xe7e80808, 0x1817f7f8, 0x18180808, 0xf9f9e5e6, 0xf9fa1a1a, 0x0605e5e6, 0x06061a1a, 0xffffe3e4, 0x00001c1c, 0x14141414, 0xebebebec, 0xe5e5f1f2, 0x1a1a0e0e, 0xf3f3e1e2, 0x0c0c1e1e, 0xdfdff5f6, 0x20200a0a, 0xdfdfedee, 0x20201212, 0xe5e5e5e6, 0x1a1a1a1a, 0xebebddde, 0x14142222, 0xf3f3d9da, 0x0c0c2626, 0xdfdfdfe0, 0x20202020, 0x20202020, 0xd7d7e9ea, 0xddddddde, 0x22222222, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x0605f9fa, 0xf9fa0606, 0xf7f80e0e, 0x0807f1f2, 0xffffedee, 0x00001212, 0xeff00a0a, 0x100ff5f6, 0xe7e80000, 0x18180000, 0xf7f7e7e8, 0xf7f81818, 0x0807e7e8, 0x08081818, 0x12121212, 0xedededee, 0xeff01414, 0x100febec, 0xe5e5f1f2, 0xe5e60e0e, 0x1a19f1f2, 0x1a1a0e0e, 0xffffe1e2, 0x00001e1e, 0xddde0000, 0x22220000, 0xf7f7ddde, 0xf7f82222, 0x0807ddde, 0x08082222, 0xedede1e2, 0xedee1e1e, 0x1211e1e2, 0x12121e1e, 0xddddf5f6, 0xddde0a0a, 0x2221f5f6, 0x22220a0a, 0xddddebec, 0x22221414, 0xffffd7d8, 0x00002828, 0x1e1e1e1e, 0xe1e1e1e2, 0xededd7d8, 0x12122828, 0xd3d40000, 0x2c2c0000, 0xd3d3eff0, 0x2c2c1010, 0xdbdbdbdc, 0xdbdbdbdc, 0x24242424, 0xd3d3e5e6, 0x2c2c1a1a, 0xe5e5d1d2, 0x1a1a2e2e, 0xededcbcc, 0x12123434, 0xc9c9ebec, 0xd3d3d3d4, 0x2c2c2c2c, 0xc9c9dfe0, 0xd1d1d1d2, 0xd1d1d1d2, 0x2e2e2e2e, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x0807f7f8, 0xf7f80808, 0xeff00808, 0x100ff7f8, 0xe7e80000, 0x18180000, 0xf7f7e7e8, 0xf7f81818, 0x0807e7e8, 0x08081818, 0xeff01414, 0x100febec, 0xffffe3e4, 0x00001c1c, 0xe7e7eff0, 0xe7e81010, 0x1817eff0, 0x18181010, 0xdfe00000, 0x20200000, 0xefefe3e4, 0xeff01c1c, 0x100fe3e4, 0x10101c1c, 0xdfdff7f8, 0xdfe00808, 0xf7f7dfe0, 0xf7f82020, 0x0807dfe0, 0x08082020, 0x201ff7f8, 0x20200808, 0x18181818, 0xe7e7e7e8, 0xe7e81818, 0x1817e7e8, 0xdfdfebec, 0x20201414, 0xffffd7d8, 0x00002828, 0xefefd7d8, 0x10102828, 0xd3d40000, 0xd3d40000, 0xffffd3d4, 0x00002c2c, 0x2c2c0000, 0x2c2c0000, 0xdfdfdfe0, 0x20202020, 0xd3d3eff0, 0x2c2c1010, 0xd3d3e7e8, 0xe7e7d3d4, 0x18182c2c, 0x2c2c1818, 0xefefcfd0, 0x10103030, 0xdbdbdbdc, 0xdbdbdbdc, 0x24242424, 0x24242424, 0xcbcbebec, 0x28282828, 0xd7d7d7d8, 0xcbcbdfe0, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }; static const uint32_t correctionhighorder[] = { 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x0302feff, 0xfcfd0101, 0xfeff0303, 0x0100fcfd, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x0302feff, 0xfcfd0101, 0xfeff0303, 0x0100fcfd, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x0302feff, 0xfcfd0101, 0xfeff0303, 0x0100fcfd, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x0302feff, 0xfcfd0101, 0xfeff0303, 0x0100fcfd, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x0302feff, 0xfcfd0101, 0xfeff0303, 0x0100fcfd, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x0302feff, 0xfcfd0101, 0xfeff0303, 0x0100fcfd, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x0302feff, 0xfcfd0101, 0xfeff0303, 0x0100fcfd, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, 0xfeff0404, 0x0100fbfc, 0x07070707, 0xf8f8f8f9, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, 0xfeff0404, 0x0100fbfc, 0x07070707, 0xf8f8f8f9, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, 0xfeff0404, 0x0100fbfc, 0x07070707, 0xf8f8f8f9, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, 0xfeff0404, 0x0100fbfc, 0x07070707, 0xf8f8f8f9, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, 0xfeff0404, 0x0100fbfc, 0x07070707, 0xf8f8f8f9, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, 0xfeff0404, 0x0100fbfc, 0x07070707, 0xf8f8f8f9, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, 0xfeff0404, 0x0100fbfc, 0x07070707, 0xf8f8f8f9, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, 0xfeff0404, 0x0100fbfc, 0x07070707, 0xf8f8f8f9, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, 0xfeff0404, 0x0100fbfc, 0x07070707, 0xf8f8f8f9, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, 0x03030a0a, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, 0x03030a0a, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, 0x03030a0a, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, 0x03030a0a, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, 0x03030a0a, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, 0x03030a0a, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, 0x03030a0a, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, 0x03030a0a, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, 0x03030a0a, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, 0x03030a0a, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, 0x04040808, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, 0x04040808, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, 0x04040808, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, 0x04040808, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, 0x04040808, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, 0x04040808, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, 0x04040808, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, 0x04040808, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, 0x04040808, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, 0x04040808, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, 0xf5f60000, 0xf5f60000, 0xf5f60000, 0xf5f60000, 0xf5f60000, 0xf5f60000, 0xf5f60000, 0xf5f60000, 0xf5f60000, 0xf5f60000, 0xf5f60000, 0xf5f60000, 0xf5f60000, 0x00000a0a, 0x00000a0a, 0x00000a0a, 0x00000a0a, 0x00000a0a, 0x00000a0a, 0x00000a0a, 0x00000a0a, 0x00000a0a, 0x00000a0a, 0x00000a0a, 0x00000a0a, 0x00000a0a, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, 0xf3f40000, 0xf3f40000, 0xf3f40000, 0xf3f40000, 0xf3f40000, 0xf3f40000, 0xf3f40000, 0xf3f40000, 0xf3f40000, 0xf3f40000, 0xf3f40000, 0xf3f40000, 0xf3f40000, 0x00000c0c, 0x00000c0c, 0x00000c0c, 0x00000c0c, 0x00000c0c, 0x00000c0c, 0x00000c0c, 0x00000c0c, 0x00000c0c, 0x00000c0c, 0x00000c0c, 0x00000c0c, 0x00000c0c, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }; #endif /* AVCODEC_INDEO3DATA_H */
123linslouis-android-video-cutter
jni/libavcodec/indeo3data.h
C
asf20
240,754
/* * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avcodec.h" static int dump_extradata(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int keyframe){ int cmd= args ? *args : 0; /* cast to avoid warning about discarding qualifiers */ if(avctx->extradata){ if( (keyframe && (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER) && cmd=='a') ||(keyframe && (cmd=='k' || !cmd)) ||(cmd=='e') /*||(? && (s->flags & PARSER_FLAG_DUMP_EXTRADATA_AT_BEGIN)*/){ int size= buf_size + avctx->extradata_size; *poutbuf_size= size; *poutbuf= av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); memcpy(*poutbuf, avctx->extradata, avctx->extradata_size); memcpy((*poutbuf) + avctx->extradata_size, buf, buf_size + FF_INPUT_BUFFER_PADDING_SIZE); return 1; } } return 0; } AVBitStreamFilter dump_extradata_bsf={ "dump_extra", 0, dump_extradata, };
123linslouis-android-video-cutter
jni/libavcodec/dump_extradata_bsf.c
C
asf20
1,898
/* * Bink video decoder * Copyright (C) 2009 Kostya Shishkov * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AVCODEC_BINKDATA_H #define AVCODEC_BINKDATA_H #include <stdint.h> /** Bink DCT and residue 8x8 block scan order */ static const uint8_t bink_scan[64] = { 0, 1, 8, 9, 2, 3, 10, 11, 4, 5, 12, 13, 6, 7, 14, 15, 20, 21, 28, 29, 22, 23, 30, 31, 16, 17, 24, 25, 32, 33, 40, 41, 34, 35, 42, 43, 48, 49, 56, 57, 50, 51, 58, 59, 18, 19, 26, 27, 36, 37, 44, 45, 38, 39, 46, 47, 52, 53, 60, 61, 54, 55, 62, 63 }; static const uint8_t bink_tree_bits[16][16] = { { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, }, { 0x00, 0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F, }, { 0x00, 0x02, 0x01, 0x09, 0x05, 0x15, 0x0D, 0x1D, 0x03, 0x13, 0x0B, 0x1B, 0x07, 0x17, 0x0F, 0x1F, }, { 0x00, 0x02, 0x06, 0x01, 0x09, 0x05, 0x0D, 0x1D, 0x03, 0x13, 0x0B, 0x1B, 0x07, 0x17, 0x0F, 0x1F, }, { 0x00, 0x04, 0x02, 0x06, 0x01, 0x09, 0x05, 0x0D, 0x03, 0x13, 0x0B, 0x1B, 0x07, 0x17, 0x0F, 0x1F, }, { 0x00, 0x04, 0x02, 0x0A, 0x06, 0x0E, 0x01, 0x09, 0x05, 0x0D, 0x03, 0x0B, 0x07, 0x17, 0x0F, 0x1F, }, { 0x00, 0x02, 0x0A, 0x06, 0x0E, 0x01, 0x09, 0x05, 0x0D, 0x03, 0x0B, 0x1B, 0x07, 0x17, 0x0F, 0x1F, }, { 0x00, 0x01, 0x05, 0x03, 0x13, 0x0B, 0x1B, 0x3B, 0x07, 0x27, 0x17, 0x37, 0x0F, 0x2F, 0x1F, 0x3F, }, { 0x00, 0x01, 0x03, 0x13, 0x0B, 0x2B, 0x1B, 0x3B, 0x07, 0x27, 0x17, 0x37, 0x0F, 0x2F, 0x1F, 0x3F, }, { 0x00, 0x01, 0x05, 0x0D, 0x03, 0x13, 0x0B, 0x1B, 0x07, 0x27, 0x17, 0x37, 0x0F, 0x2F, 0x1F, 0x3F, }, { 0x00, 0x02, 0x01, 0x05, 0x0D, 0x03, 0x13, 0x0B, 0x1B, 0x07, 0x17, 0x37, 0x0F, 0x2F, 0x1F, 0x3F, }, { 0x00, 0x01, 0x09, 0x05, 0x0D, 0x03, 0x13, 0x0B, 0x1B, 0x07, 0x17, 0x37, 0x0F, 0x2F, 0x1F, 0x3F, }, { 0x00, 0x02, 0x01, 0x03, 0x13, 0x0B, 0x1B, 0x3B, 0x07, 0x27, 0x17, 0x37, 0x0F, 0x2F, 0x1F, 0x3F, }, { 0x00, 0x01, 0x05, 0x03, 0x07, 0x27, 0x17, 0x37, 0x0F, 0x4F, 0x2F, 0x6F, 0x1F, 0x5F, 0x3F, 0x7F, }, { 0x00, 0x01, 0x05, 0x03, 0x07, 0x17, 0x37, 0x77, 0x0F, 0x4F, 0x2F, 0x6F, 0x1F, 0x5F, 0x3F, 0x7F, }, { 0x00, 0x02, 0x01, 0x05, 0x03, 0x07, 0x27, 0x17, 0x37, 0x0F, 0x2F, 0x6F, 0x1F, 0x5F, 0x3F, 0x7F, }, }; static const uint8_t bink_tree_lens[16][16] = { { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }, { 1, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 }, { 2, 2, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 }, { 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 }, { 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5 }, { 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5 }, { 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5 }, { 1, 3, 3, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, { 1, 2, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, { 1, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6 }, { 2, 2, 3, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6 }, { 1, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6 }, { 2, 2, 2, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, { 1, 3, 3, 3, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7 }, { 1, 3, 3, 3, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 2, 2, 3, 3, 3, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7 }, }; static const uint8_t bink_patterns[16][64] = { { 0x00, 0x08, 0x10, 0x18, 0x20, 0x28, 0x30, 0x38, 0x39, 0x31, 0x29, 0x21, 0x19, 0x11, 0x09, 0x01, 0x02, 0x0A, 0x12, 0x1A, 0x22, 0x2A, 0x32, 0x3A, 0x3B, 0x33, 0x2B, 0x23, 0x1B, 0x13, 0x0B, 0x03, 0x04, 0x0C, 0x14, 0x1C, 0x24, 0x2C, 0x34, 0x3C, 0x3D, 0x35, 0x2D, 0x25, 0x1D, 0x15, 0x0D, 0x05, 0x06, 0x0E, 0x16, 0x1E, 0x26, 0x2E, 0x36, 0x3E, 0x3F, 0x37, 0x2F, 0x27, 0x1F, 0x17, 0x0F, 0x07, }, { 0x3B, 0x3A, 0x39, 0x38, 0x30, 0x31, 0x32, 0x33, 0x2B, 0x2A, 0x29, 0x28, 0x20, 0x21, 0x22, 0x23, 0x1B, 0x1A, 0x19, 0x18, 0x10, 0x11, 0x12, 0x13, 0x0B, 0x0A, 0x09, 0x08, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x0F, 0x0E, 0x0D, 0x0C, 0x14, 0x15, 0x16, 0x17, 0x1F, 0x1E, 0x1D, 0x1C, 0x24, 0x25, 0x26, 0x27, 0x2F, 0x2E, 0x2D, 0x2C, 0x34, 0x35, 0x36, 0x37, 0x3F, 0x3E, 0x3D, 0x3C, }, { 0x19, 0x11, 0x12, 0x1A, 0x1B, 0x13, 0x0B, 0x03, 0x02, 0x0A, 0x09, 0x01, 0x00, 0x08, 0x10, 0x18, 0x20, 0x28, 0x30, 0x38, 0x39, 0x31, 0x29, 0x2A, 0x32, 0x3A, 0x3B, 0x33, 0x2B, 0x23, 0x22, 0x21, 0x1D, 0x15, 0x16, 0x1E, 0x1F, 0x17, 0x0F, 0x07, 0x06, 0x0E, 0x0D, 0x05, 0x04, 0x0C, 0x14, 0x1C, 0x24, 0x2C, 0x34, 0x3C, 0x3D, 0x35, 0x2D, 0x2E, 0x36, 0x3E, 0x3F, 0x37, 0x2F, 0x27, 0x26, 0x25, }, { 0x03, 0x0B, 0x02, 0x0A, 0x01, 0x09, 0x00, 0x08, 0x10, 0x18, 0x11, 0x19, 0x12, 0x1A, 0x13, 0x1B, 0x23, 0x2B, 0x22, 0x2A, 0x21, 0x29, 0x20, 0x28, 0x30, 0x38, 0x31, 0x39, 0x32, 0x3A, 0x33, 0x3B, 0x3C, 0x34, 0x3D, 0x35, 0x3E, 0x36, 0x3F, 0x37, 0x2F, 0x27, 0x2E, 0x26, 0x2D, 0x25, 0x2C, 0x24, 0x1C, 0x14, 0x1D, 0x15, 0x1E, 0x16, 0x1F, 0x17, 0x0F, 0x07, 0x0E, 0x06, 0x0D, 0x05, 0x0C, 0x04, }, { 0x18, 0x19, 0x10, 0x11, 0x08, 0x09, 0x00, 0x01, 0x02, 0x03, 0x0A, 0x0B, 0x12, 0x13, 0x1A, 0x1B, 0x1C, 0x1D, 0x14, 0x15, 0x0C, 0x0D, 0x04, 0x05, 0x06, 0x07, 0x0E, 0x0F, 0x16, 0x17, 0x1E, 0x1F, 0x27, 0x26, 0x2F, 0x2E, 0x37, 0x36, 0x3F, 0x3E, 0x3D, 0x3C, 0x35, 0x34, 0x2D, 0x2C, 0x25, 0x24, 0x23, 0x22, 0x2B, 0x2A, 0x33, 0x32, 0x3B, 0x3A, 0x39, 0x38, 0x31, 0x30, 0x29, 0x28, 0x21, 0x20, }, { 0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B, 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B, 0x20, 0x21, 0x22, 0x23, 0x28, 0x29, 0x2A, 0x2B, 0x30, 0x31, 0x32, 0x33, 0x38, 0x39, 0x3A, 0x3B, 0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F, 0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F, 0x24, 0x25, 0x26, 0x27, 0x2C, 0x2D, 0x2E, 0x2F, 0x34, 0x35, 0x36, 0x37, 0x3C, 0x3D, 0x3E, 0x3F, }, { 0x06, 0x07, 0x0F, 0x0E, 0x0D, 0x05, 0x0C, 0x04, 0x03, 0x0B, 0x02, 0x0A, 0x09, 0x01, 0x00, 0x08, 0x10, 0x18, 0x11, 0x19, 0x12, 0x1A, 0x13, 0x1B, 0x14, 0x1C, 0x15, 0x1D, 0x16, 0x1E, 0x17, 0x1F, 0x27, 0x2F, 0x26, 0x2E, 0x25, 0x2D, 0x24, 0x2C, 0x23, 0x2B, 0x22, 0x2A, 0x21, 0x29, 0x20, 0x28, 0x31, 0x30, 0x38, 0x39, 0x3A, 0x32, 0x3B, 0x33, 0x3C, 0x34, 0x3D, 0x35, 0x36, 0x37, 0x3F, 0x3E, }, { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x1F, 0x1E, 0x1D, 0x1C, 0x1B, 0x1A, 0x19, 0x18, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x2F, 0x2E, 0x2D, 0x2C, 0x2B, 0x2A, 0x29, 0x28, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38, }, { 0x00, 0x08, 0x09, 0x01, 0x02, 0x03, 0x0B, 0x0A, 0x12, 0x13, 0x1B, 0x1A, 0x19, 0x11, 0x10, 0x18, 0x20, 0x28, 0x29, 0x21, 0x22, 0x23, 0x2B, 0x2A, 0x32, 0x31, 0x30, 0x38, 0x39, 0x3A, 0x3B, 0x33, 0x34, 0x3C, 0x3D, 0x3E, 0x3F, 0x37, 0x36, 0x35, 0x2D, 0x2C, 0x24, 0x25, 0x26, 0x2E, 0x2F, 0x27, 0x1F, 0x17, 0x16, 0x1E, 0x1D, 0x1C, 0x14, 0x15, 0x0D, 0x0C, 0x04, 0x05, 0x06, 0x0E, 0x0F, 0x07, }, { 0x18, 0x19, 0x10, 0x11, 0x08, 0x09, 0x00, 0x01, 0x02, 0x03, 0x0A, 0x0B, 0x12, 0x13, 0x1A, 0x1B, 0x1C, 0x1D, 0x14, 0x15, 0x0C, 0x0D, 0x04, 0x05, 0x06, 0x07, 0x0E, 0x0F, 0x16, 0x17, 0x1E, 0x1F, 0x26, 0x27, 0x2E, 0x2F, 0x36, 0x37, 0x3E, 0x3F, 0x3C, 0x3D, 0x34, 0x35, 0x2C, 0x2D, 0x24, 0x25, 0x22, 0x23, 0x2A, 0x2B, 0x32, 0x33, 0x3A, 0x3B, 0x38, 0x39, 0x30, 0x31, 0x28, 0x29, 0x20, 0x21, }, { 0x00, 0x08, 0x01, 0x09, 0x02, 0x0A, 0x03, 0x0B, 0x13, 0x1B, 0x12, 0x1A, 0x11, 0x19, 0x10, 0x18, 0x20, 0x28, 0x21, 0x29, 0x22, 0x2A, 0x23, 0x2B, 0x33, 0x3B, 0x32, 0x3A, 0x31, 0x39, 0x30, 0x38, 0x3C, 0x34, 0x3D, 0x35, 0x3E, 0x36, 0x3F, 0x37, 0x2F, 0x27, 0x2E, 0x26, 0x2D, 0x25, 0x2C, 0x24, 0x1F, 0x17, 0x1E, 0x16, 0x1D, 0x15, 0x1C, 0x14, 0x0C, 0x04, 0x0D, 0x05, 0x0E, 0x06, 0x0F, 0x07, }, { 0x00, 0x08, 0x10, 0x18, 0x19, 0x1A, 0x1B, 0x13, 0x0B, 0x03, 0x02, 0x01, 0x09, 0x11, 0x12, 0x0A, 0x04, 0x0C, 0x14, 0x1C, 0x1D, 0x1E, 0x1F, 0x17, 0x0F, 0x07, 0x06, 0x05, 0x0D, 0x15, 0x16, 0x0E, 0x24, 0x2C, 0x34, 0x3C, 0x3D, 0x3E, 0x3F, 0x37, 0x2F, 0x27, 0x26, 0x25, 0x2D, 0x35, 0x36, 0x2E, 0x20, 0x28, 0x30, 0x38, 0x39, 0x3A, 0x3B, 0x33, 0x2B, 0x23, 0x22, 0x21, 0x29, 0x31, 0x32, 0x2A, }, { 0x00, 0x08, 0x09, 0x01, 0x02, 0x03, 0x0B, 0x0A, 0x13, 0x1B, 0x1A, 0x12, 0x11, 0x10, 0x18, 0x19, 0x21, 0x20, 0x28, 0x29, 0x2A, 0x22, 0x23, 0x2B, 0x33, 0x3B, 0x3A, 0x32, 0x31, 0x39, 0x38, 0x30, 0x34, 0x3C, 0x3D, 0x35, 0x36, 0x3E, 0x3F, 0x37, 0x2F, 0x27, 0x26, 0x2E, 0x2D, 0x2C, 0x24, 0x25, 0x1D, 0x1C, 0x14, 0x15, 0x16, 0x1E, 0x1F, 0x17, 0x0E, 0x0F, 0x07, 0x06, 0x05, 0x0D, 0x0C, 0x04, }, { 0x18, 0x10, 0x08, 0x00, 0x01, 0x02, 0x03, 0x0B, 0x13, 0x1B, 0x1A, 0x19, 0x11, 0x0A, 0x09, 0x12, 0x1C, 0x14, 0x0C, 0x04, 0x05, 0x06, 0x07, 0x0F, 0x17, 0x1F, 0x1E, 0x1D, 0x15, 0x0E, 0x0D, 0x16, 0x3C, 0x34, 0x2C, 0x24, 0x25, 0x26, 0x27, 0x2F, 0x37, 0x3F, 0x3E, 0x3D, 0x35, 0x2E, 0x2D, 0x36, 0x38, 0x30, 0x28, 0x20, 0x21, 0x22, 0x23, 0x2B, 0x33, 0x3B, 0x3A, 0x39, 0x31, 0x2A, 0x29, 0x32, }, { 0x00, 0x08, 0x09, 0x01, 0x02, 0x0A, 0x12, 0x11, 0x10, 0x18, 0x19, 0x1A, 0x1B, 0x13, 0x0B, 0x03, 0x07, 0x06, 0x0E, 0x0F, 0x17, 0x16, 0x15, 0x0D, 0x05, 0x04, 0x0C, 0x14, 0x1C, 0x1D, 0x1E, 0x1F, 0x3F, 0x3E, 0x36, 0x37, 0x2F, 0x2E, 0x2D, 0x35, 0x3D, 0x3C, 0x34, 0x2C, 0x24, 0x25, 0x26, 0x27, 0x38, 0x30, 0x31, 0x39, 0x3A, 0x32, 0x2A, 0x29, 0x28, 0x20, 0x21, 0x22, 0x23, 0x2B, 0x33, 0x3B, }, { 0x00, 0x01, 0x08, 0x09, 0x10, 0x11, 0x18, 0x19, 0x20, 0x21, 0x28, 0x29, 0x30, 0x31, 0x38, 0x39, 0x3A, 0x3B, 0x32, 0x33, 0x2A, 0x2B, 0x22, 0x23, 0x1A, 0x1B, 0x12, 0x13, 0x0A, 0x0B, 0x02, 0x03, 0x04, 0x05, 0x0C, 0x0D, 0x14, 0x15, 0x1C, 0x1D, 0x24, 0x25, 0x2C, 0x2D, 0x34, 0x35, 0x3C, 0x3D, 0x3E, 0x3F, 0x36, 0x37, 0x2E, 0x2F, 0x26, 0x27, 0x1E, 0x1F, 0x16, 0x17, 0x0E, 0x0F, 0x06, 0x07, } }; static const uint32_t bink_intra_quant[16][64] = { { 0x010000, 0x016315, 0x01E83D, 0x02A535, 0x014E7B, 0x016577, 0x02F1E6, 0x02724C, 0x010000, 0x00EEDA, 0x024102, 0x017F9B, 0x00BE80, 0x00611E, 0x01083C, 0x00A552, 0x021F88, 0x01DC53, 0x027FAD, 0x01F697, 0x014819, 0x00A743, 0x015A31, 0x009688, 0x02346F, 0x030EE5, 0x01FBFA, 0x02C096, 0x01D000, 0x028396, 0x019247, 0x01F9AA, 0x02346F, 0x01FBFA, 0x01DC53, 0x0231B8, 0x012F12, 0x01E06C, 0x00CB10, 0x0119A8, 0x01C48C, 0x019748, 0x014E86, 0x0122AF, 0x02C628, 0x027F20, 0x0297B5, 0x023F32, 0x025000, 0x01AB6B, 0x01D122, 0x0159B3, 0x012669, 0x008D43, 0x00EE1F, 0x0075ED, 0x01490C, 0x010288, 0x00F735, 0x00EF51, 0x00E0F1, 0x0072AD, 0x00A4D8, 0x006517, }, { 0x015555, 0x01D971, 0x028AFC, 0x0386F1, 0x01BDF9, 0x01DC9F, 0x03ED33, 0x034311, 0x015555, 0x013E78, 0x030158, 0x01FF7A, 0x00FE00, 0x00817D, 0x01604F, 0x00DC6D, 0x02D4B5, 0x027B19, 0x0354E7, 0x029E1F, 0x01B577, 0x00DF04, 0x01CD96, 0x00C8B6, 0x02F095, 0x0413DC, 0x02A54E, 0x03AB73, 0x026AAB, 0x035A1E, 0x02185E, 0x02A238, 0x02F095, 0x02A54E, 0x027B19, 0x02ECF5, 0x019418, 0x028090, 0x010EC0, 0x01778A, 0x025B66, 0x021F0B, 0x01BE09, 0x018394, 0x03B2E0, 0x03542A, 0x0374F1, 0x02FEEE, 0x031555, 0x0239E4, 0x026C2D, 0x01CCEE, 0x01888C, 0x00BC59, 0x013D7E, 0x009D3C, 0x01B6BB, 0x0158B5, 0x01499C, 0x013F17, 0x012BEC, 0x0098E6, 0x00DBCB, 0x0086C9, }, { 0x01AAAB, 0x024FCE, 0x032DBB, 0x0468AD, 0x022D78, 0x0253C7, 0x04E87F, 0x0413D5, 0x01AAAB, 0x018E16, 0x03C1AE, 0x027F58, 0x013D80, 0x00A1DC, 0x01B863, 0x011388, 0x0389E2, 0x0319DF, 0x042A21, 0x0345A7, 0x0222D4, 0x0116C5, 0x0240FC, 0x00FAE3, 0x03ACBA, 0x0518D3, 0x034EA1, 0x04964F, 0x030555, 0x0430A5, 0x029E76, 0x034AC5, 0x03ACBA, 0x034EA1, 0x0319DF, 0x03A833, 0x01F91E, 0x0320B4, 0x015270, 0x01D56D, 0x02F23F, 0x02A6CE, 0x022D8B, 0x01E479, 0x049F98, 0x042935, 0x04522D, 0x03BEA9, 0x03DAAB, 0x02C85D, 0x030738, 0x02402A, 0x01EAAF, 0x00EB6F, 0x018CDE, 0x00C48A, 0x022469, 0x01AEE2, 0x019C02, 0x018EDD, 0x0176E7, 0x00BF20, 0x0112BE, 0x00A87B, }, { 0x020000, 0x02C62A, 0x03D07A, 0x054A69, 0x029CF6, 0x02CAEF, 0x05E3CC, 0x04E499, 0x020000, 0x01DDB4, 0x048204, 0x02FF36, 0x017D01, 0x00C23C, 0x021077, 0x014AA3, 0x043F0F, 0x03B8A6, 0x04FF5A, 0x03ED2E, 0x029032, 0x014E86, 0x02B461, 0x012D11, 0x0468DF, 0x061DCA, 0x03F7F5, 0x05812C, 0x03A000, 0x05072C, 0x03248D, 0x03F353, 0x0468DF, 0x03F7F5, 0x03B8A6, 0x046370, 0x025E24, 0x03C0D8, 0x019620, 0x02334F, 0x038919, 0x032E91, 0x029D0D, 0x02455E, 0x058C50, 0x04FE3F, 0x052F69, 0x047E65, 0x04A000, 0x0356D6, 0x03A243, 0x02B365, 0x024CD2, 0x011A85, 0x01DC3E, 0x00EBD9, 0x029218, 0x020510, 0x01EE69, 0x01DEA2, 0x01C1E2, 0x00E559, 0x0149B0, 0x00CA2D, }, { 0x02AAAB, 0x03B2E3, 0x0515F8, 0x070DE2, 0x037BF2, 0x03B93E, 0x07DA65, 0x068621, 0x02AAAB, 0x027CF0, 0x0602B1, 0x03FEF3, 0x01FC01, 0x0102FA, 0x02C09F, 0x01B8DA, 0x05A96A, 0x04F632, 0x06A9CE, 0x053C3E, 0x036AED, 0x01BE09, 0x039B2D, 0x01916B, 0x05E129, 0x0827B8, 0x054A9C, 0x0756E5, 0x04D555, 0x06B43B, 0x0430BC, 0x05446F, 0x05E129, 0x054A9C, 0x04F632, 0x05D9EB, 0x032830, 0x050121, 0x021D80, 0x02EF14, 0x04B6CC, 0x043E16, 0x037C11, 0x030728, 0x0765C0, 0x06A855, 0x06E9E2, 0x05FDDB, 0x062AAB, 0x0473C8, 0x04D85A, 0x0399DC, 0x031118, 0x0178B2, 0x027AFD, 0x013A77, 0x036D76, 0x02B16A, 0x029337, 0x027E2E, 0x0257D8, 0x0131CC, 0x01B796, 0x010D91, }, { 0x038000, 0x04DACA, 0x06ACD5, 0x094238, 0x0492AE, 0x04E322, 0x0A4EA5, 0x08900C, 0x038000, 0x0343FB, 0x07E388, 0x053E9F, 0x029AC1, 0x0153E8, 0x039CD0, 0x02429E, 0x076E5B, 0x068322, 0x08BEDE, 0x06DF11, 0x047C57, 0x02496B, 0x04BBAB, 0x020EDD, 0x07B786, 0x0AB421, 0x06F1ED, 0x09A20D, 0x065800, 0x08CC8E, 0x057FF7, 0x06E9D2, 0x07B786, 0x06F1ED, 0x068322, 0x07AE04, 0x0424BF, 0x06917B, 0x02C6B8, 0x03D9CB, 0x062FEB, 0x05917D, 0x0492D7, 0x03F964, 0x09B58C, 0x08BCEF, 0x0912F8, 0x07DD30, 0x081800, 0x05D7F7, 0x065BF6, 0x04B9F1, 0x040670, 0x01EE69, 0x03416C, 0x019CBC, 0x047FAA, 0x0388DC, 0x036138, 0x03459C, 0x03134C, 0x01915C, 0x0240F5, 0x0161CF, }, { 0x040000, 0x058C54, 0x07A0F4, 0x0A94D3, 0x0539EC, 0x0595DD, 0x0BC798, 0x09C932, 0x040000, 0x03BB68, 0x090409, 0x05FE6D, 0x02FA01, 0x018477, 0x0420EE, 0x029547, 0x087E1F, 0x07714C, 0x09FEB5, 0x07DA5D, 0x052064, 0x029D0D, 0x0568C3, 0x025A21, 0x08D1BE, 0x0C3B94, 0x07EFEA, 0x0B0258, 0x074000, 0x0A0E59, 0x06491A, 0x07E6A7, 0x08D1BE, 0x07EFEA, 0x07714C, 0x08C6E0, 0x04BC48, 0x0781B1, 0x032C3F, 0x04669F, 0x071232, 0x065D22, 0x053A1A, 0x048ABC, 0x0B18A0, 0x09FC7F, 0x0A5ED3, 0x08FCC9, 0x094000, 0x06ADAC, 0x074487, 0x0566CA, 0x0499A5, 0x02350B, 0x03B87B, 0x01D7B3, 0x052430, 0x040A20, 0x03DCD3, 0x03BD45, 0x0383C5, 0x01CAB3, 0x029361, 0x01945A, }, { 0x050000, 0x06EF69, 0x098931, 0x0D3A07, 0x068867, 0x06FB55, 0x0EB97E, 0x0C3B7E, 0x050000, 0x04AA42, 0x0B450B, 0x077E08, 0x03B881, 0x01E595, 0x05292A, 0x033A99, 0x0A9DA7, 0x094D9F, 0x0C7E62, 0x09D0F4, 0x06687D, 0x034450, 0x06C2F4, 0x02F0AA, 0x0B062D, 0x0F4A78, 0x09EBE4, 0x0DC2EE, 0x091000, 0x0C91EF, 0x07DB61, 0x09E050, 0x0B062D, 0x09EBE4, 0x094D9F, 0x0AF898, 0x05EB59, 0x09621D, 0x03F74F, 0x058046, 0x08D6BE, 0x07F46A, 0x0688A0, 0x05AD6B, 0x0DDEC8, 0x0C7B9F, 0x0CF687, 0x0B3BFB, 0x0B9000, 0x085917, 0x0915A8, 0x06C07D, 0x05C00E, 0x02C24D, 0x04A69A, 0x024D9F, 0x066D3C, 0x050CA7, 0x04D407, 0x04AC96, 0x0464B6, 0x023D5F, 0x033839, 0x01F971, }, { 0x060000, 0x08527E, 0x0B716E, 0x0FDF3C, 0x07D6E1, 0x0860CC, 0x11AB63, 0x0EADCB, 0x060000, 0x05991C, 0x0D860D, 0x08FDA3, 0x047702, 0x0246B3, 0x063165, 0x03DFEA, 0x0CBD2E, 0x0B29F1, 0x0EFE0F, 0x0BC78B, 0x07B096, 0x03EB93, 0x081D24, 0x038732, 0x0D3A9C, 0x12595D, 0x0BE7DF, 0x108384, 0x0AE000, 0x0F1585, 0x096DA8, 0x0BD9FA, 0x0D3A9C, 0x0BE7DF, 0x0B29F1, 0x0D2A50, 0x071A6B, 0x0B4289, 0x04C25F, 0x0699EE, 0x0A9B4A, 0x098BB2, 0x07D727, 0x06D01A, 0x10A4F0, 0x0EFABE, 0x0F8E3C, 0x0D7B2E, 0x0DE000, 0x0A0482, 0x0AE6CA, 0x081A2F, 0x06E677, 0x034F90, 0x0594B9, 0x02C38C, 0x07B649, 0x060F2F, 0x05CB3C, 0x059BE7, 0x0545A7, 0x02B00C, 0x03DD11, 0x025E87, }, { 0x080000, 0x0B18A8, 0x0F41E8, 0x1529A5, 0x0A73D7, 0x0B2BBB, 0x178F2F, 0x139264, 0x080000, 0x0776CF, 0x120812, 0x0BFCD9, 0x05F402, 0x0308EF, 0x0841DC, 0x052A8E, 0x10FC3E, 0x0EE297, 0x13FD69, 0x0FB4B9, 0x0A40C8, 0x053A1A, 0x0AD186, 0x04B442, 0x11A37B, 0x187727, 0x0FDFD4, 0x1604B0, 0x0E8000, 0x141CB1, 0x0C9235, 0x0FCD4D, 0x11A37B, 0x0FDFD4, 0x0EE297, 0x118DC0, 0x09788F, 0x0F0362, 0x06587F, 0x08CD3D, 0x0E2463, 0x0CBA43, 0x0A7434, 0x091577, 0x163140, 0x13F8FE, 0x14BDA5, 0x11F992, 0x128000, 0x0D5B58, 0x0E890D, 0x0ACD94, 0x093349, 0x046A15, 0x0770F7, 0x03AF65, 0x0A4861, 0x08143F, 0x07B9A6, 0x077A89, 0x070789, 0x039565, 0x0526C2, 0x0328B4, }, { 0x0C0000, 0x10A4FD, 0x16E2DB, 0x1FBE78, 0x0FADC3, 0x10C198, 0x2356C7, 0x1D5B96, 0x0C0000, 0x0B3237, 0x1B0C1A, 0x11FB46, 0x08EE03, 0x048D66, 0x0C62CA, 0x07BFD5, 0x197A5D, 0x1653E3, 0x1DFC1E, 0x178F16, 0x0F612C, 0x07D727, 0x103A49, 0x070E64, 0x1A7539, 0x24B2BB, 0x17CFBD, 0x210709, 0x15C000, 0x1E2B0A, 0x12DB4F, 0x17B3F4, 0x1A7539, 0x17CFBD, 0x1653E3, 0x1A54A0, 0x0E34D7, 0x168513, 0x0984BE, 0x0D33DC, 0x153695, 0x131765, 0x0FAE4E, 0x0DA033, 0x2149E1, 0x1DF57D, 0x1F1C78, 0x1AF65B, 0x1BC000, 0x140904, 0x15CD94, 0x10345E, 0x0DCCEE, 0x069F20, 0x0B2972, 0x058718, 0x0F6C91, 0x0C1E5E, 0x0B9678, 0x0B37CE, 0x0A8B4E, 0x056018, 0x07BA22, 0x04BD0E, }, { 0x110000, 0x179466, 0x206C0C, 0x2CF87F, 0x16362A, 0x17BCED, 0x321044, 0x299714, 0x110000, 0x0FDC79, 0x265125, 0x19794E, 0x0CA685, 0x0672FB, 0x118BF4, 0x0AFA6D, 0x241804, 0x1FA181, 0x2A7A80, 0x21600A, 0x15C9A9, 0x0B1B77, 0x16FD3C, 0x09FF0D, 0x257B66, 0x33FD33, 0x21BBA2, 0x2EC9F7, 0x1ED000, 0x2ABCF9, 0x1AB6B0, 0x219444, 0x257B66, 0x21BBA2, 0x1FA181, 0x254D38, 0x142030, 0x1FE730, 0x0D7C0E, 0x12B423, 0x1E0D52, 0x1B0BCF, 0x1636EE, 0x134D9E, 0x2F28A9, 0x2A711B, 0x2C12FF, 0x263256, 0x275000, 0x1C621B, 0x1EE33C, 0x16F4DB, 0x138CFB, 0x09616E, 0x0FD00C, 0x07D4B7, 0x15D9CE, 0x112B06, 0x106A80, 0x0FE464, 0x0EF004, 0x079D77, 0x0AF25B, 0x06B67F, }, { 0x160000, 0x1E83CF, 0x29F53D, 0x3A3286, 0x1CBE90, 0x1EB842, 0x40C9C2, 0x35D293, 0x160000, 0x1486BA, 0x319630, 0x20F756, 0x105F06, 0x085891, 0x16B51E, 0x0E3506, 0x2EB5AA, 0x28EF20, 0x36F8E1, 0x2B30FE, 0x1C3225, 0x0E5FC7, 0x1DC030, 0x0CEFB7, 0x308193, 0x4347AC, 0x2BA786, 0x3C8CE5, 0x27E000, 0x374EE7, 0x229212, 0x2B7494, 0x308193, 0x2BA786, 0x28EF20, 0x3045D0, 0x1A0B89, 0x29494D, 0x11735D, 0x183469, 0x26E410, 0x230039, 0x1CBF8F, 0x18FB09, 0x3D0771, 0x36ECBA, 0x390986, 0x316E52, 0x32E000, 0x24BB33, 0x27F8E4, 0x1DB557, 0x194D09, 0x0C23BB, 0x1476A6, 0x0A2256, 0x1C470A, 0x1637AD, 0x153E87, 0x1490FA, 0x1354B9, 0x09DAD6, 0x0E2A94, 0x08AFF0, }, { 0x1C0000, 0x26D64D, 0x3566AA, 0x4A11C2, 0x249572, 0x27190E, 0x527525, 0x44805E, 0x1C0000, 0x1A1FD6, 0x3F1C3E, 0x29F4F9, 0x14D607, 0x0A9F44, 0x1CE683, 0x1214F0, 0x3B72D9, 0x341911, 0x45F6F0, 0x36F889, 0x23E2BB, 0x124B5B, 0x25DD54, 0x1076E9, 0x3DBC30, 0x55A109, 0x378F64, 0x4D1069, 0x32C000, 0x46646C, 0x2BFFB9, 0x374E8E, 0x3DBC30, 0x378F64, 0x341911, 0x3D7020, 0x2125F5, 0x348BD6, 0x1635BC, 0x1ECE57, 0x317F5B, 0x2C8BEB, 0x2496B6, 0x1FCB22, 0x4DAC61, 0x45E778, 0x4897C2, 0x3EE97F, 0x40C000, 0x2EBFB5, 0x32DFAE, 0x25CF86, 0x203380, 0x0F734B, 0x1A0B5F, 0x0CE5E2, 0x23FD53, 0x1C46DC, 0x1B09C4, 0x1A2CE1, 0x189A60, 0x0C8AE2, 0x1207A5, 0x0B0E77, }, { 0x220000, 0x2F28CC, 0x40D818, 0x59F0FE, 0x2C6C53, 0x2F79DA, 0x642089, 0x532E29, 0x220000, 0x1FB8F1, 0x4CA24B, 0x32F29C, 0x194D09, 0x0CE5F7, 0x2317E8, 0x15F4DB, 0x483007, 0x3F4303, 0x54F4FF, 0x42C014, 0x2B9351, 0x1636EE, 0x2DFA79, 0x13FE1A, 0x4AF6CC, 0x67FA67, 0x437743, 0x5D93EE, 0x3DA000, 0x5579F1, 0x356D61, 0x432888, 0x4AF6CC, 0x437743, 0x3F4303, 0x4A9A70, 0x284060, 0x3FCE60, 0x1AF81B, 0x256845, 0x3C1AA5, 0x36179D, 0x2C6DDD, 0x269B3C, 0x5E5152, 0x54E237, 0x5825FE, 0x4C64AD, 0x4EA000, 0x38C437, 0x3DC678, 0x2DE9B5, 0x2719F7, 0x12C2DB, 0x1FA018, 0x0FA96E, 0x2BB39B, 0x22560C, 0x20D500, 0x1FC8C8, 0x1DE007, 0x0F3AEE, 0x15E4B7, 0x0D6CFE, }, { 0x2C0000, 0x3D079E, 0x53EA79, 0x74650C, 0x397D20, 0x3D7083, 0x819383, 0x6BA525, 0x2C0000, 0x290D75, 0x632C61, 0x41EEAC, 0x20BE0C, 0x10B121, 0x2D6A3B, 0x1C6A0C, 0x5D6B54, 0x51DE40, 0x6DF1C2, 0x5661FB, 0x38644B, 0x1CBF8F, 0x3B8060, 0x19DF6D, 0x610326, 0x868F57, 0x574F0B, 0x7919CA, 0x4FC000, 0x6E9DCE, 0x452423, 0x56E928, 0x610326, 0x574F0B, 0x51DE40, 0x608BA0, 0x341713, 0x52929A, 0x22E6BA, 0x3068D2, 0x4DC821, 0x460071, 0x397F1E, 0x31F611, 0x7A0EE2, 0x6DD974, 0x72130C, 0x62DCA3, 0x65C000, 0x497665, 0x4FF1C9, 0x3B6AAE, 0x329A12, 0x184776, 0x28ED4D, 0x1444AC, 0x388E14, 0x2C6F5A, 0x2A7D0F, 0x2921F4, 0x26A973, 0x13B5AD, 0x1C5528, 0x115FDF, }, }; static const uint32_t bink_inter_quant[16][64] = { { 0x010000, 0x017946, 0x01A5A9, 0x0248DC, 0x016363, 0x0152A7, 0x0243EC, 0x0209EA, 0x012000, 0x00E248, 0x01BBDA, 0x015CBC, 0x00A486, 0x0053E0, 0x00F036, 0x008095, 0x01B701, 0x016959, 0x01B0B9, 0x0153FD, 0x00F8E7, 0x007EE4, 0x00EA30, 0x007763, 0x01B701, 0x0260EB, 0x019DE9, 0x023E1B, 0x017000, 0x01FE6E, 0x012DB5, 0x01A27B, 0x01E0D1, 0x01B0B9, 0x018A33, 0x01718D, 0x00D87A, 0x014449, 0x007B9A, 0x00AB71, 0x013178, 0x0112EA, 0x00AD08, 0x009BB9, 0x023D97, 0x020437, 0x021CCC, 0x01E6B4, 0x018000, 0x012DB5, 0x0146D9, 0x0100CE, 0x00CFD2, 0x006E5C, 0x00B0E4, 0x005A2D, 0x00E9CC, 0x00B7B1, 0x00846F, 0x006B85, 0x008337, 0x0042E5, 0x004A10, 0x002831, }, { 0x015555, 0x01F708, 0x023237, 0x030BD0, 0x01D9D9, 0x01C389, 0x03053B, 0x02B7E3, 0x018000, 0x012DB5, 0x024FCE, 0x01D0FA, 0x00DB5D, 0x006FD5, 0x014048, 0x00AB71, 0x024957, 0x01E1CC, 0x0240F7, 0x01C551, 0x014BDE, 0x00A92F, 0x013840, 0x009F2F, 0x024957, 0x032BE4, 0x0227E1, 0x02FD7A, 0x01EAAB, 0x02A893, 0x019247, 0x022DF9, 0x028116, 0x0240F7, 0x020D99, 0x01ECBC, 0x0120A3, 0x01B061, 0x00A4CE, 0x00E497, 0x01974B, 0x016E8E, 0x00E6B5, 0x00CFA2, 0x02FCC9, 0x02B04A, 0x02D110, 0x0288F1, 0x020000, 0x019247, 0x01B3CC, 0x015668, 0x011518, 0x009325, 0x00EBDA, 0x00783D, 0x0137BB, 0x00F4ED, 0x00B093, 0x008F5C, 0x00AEF4, 0x005931, 0x0062BF, 0x003597, }, { 0x01AAAB, 0x0274CB, 0x02BEC4, 0x03CEC4, 0x02504F, 0x02346C, 0x03C689, 0x0365DC, 0x01E000, 0x017922, 0x02E3C1, 0x024539, 0x011235, 0x008BCA, 0x01905A, 0x00D64D, 0x02DBAD, 0x025A40, 0x02D134, 0x0236A5, 0x019ED6, 0x00D37B, 0x018650, 0x00C6FB, 0x02DBAD, 0x03F6DD, 0x02B1D9, 0x03BCD8, 0x026555, 0x0352B8, 0x01F6D8, 0x02B977, 0x03215C, 0x02D134, 0x029100, 0x0267EB, 0x0168CC, 0x021C7A, 0x00CE01, 0x011DBD, 0x01FD1E, 0x01CA31, 0x012062, 0x01038A, 0x03BBFB, 0x035C5C, 0x038554, 0x032B2D, 0x028000, 0x01F6D8, 0x0220C0, 0x01AC02, 0x015A5E, 0x00B7EF, 0x0126D1, 0x00964C, 0x0185A9, 0x013228, 0x00DCB8, 0x00B333, 0x00DAB2, 0x006F7D, 0x007B6F, 0x0042FC, }, { 0x020000, 0x02F28D, 0x034B52, 0x0491B8, 0x02C6C5, 0x02A54E, 0x0487D8, 0x0413D5, 0x024000, 0x01C48F, 0x0377B5, 0x02B977, 0x01490C, 0x00A7BF, 0x01E06C, 0x01012A, 0x036E03, 0x02D2B3, 0x036172, 0x02A7FA, 0x01F1CE, 0x00FDC7, 0x01D460, 0x00EEC7, 0x036E03, 0x04C1D6, 0x033BD1, 0x047C37, 0x02E000, 0x03FCDD, 0x025B6A, 0x0344F5, 0x03C1A1, 0x036172, 0x031466, 0x02E31B, 0x01B0F5, 0x028892, 0x00F735, 0x0156E2, 0x0262F1, 0x0225D5, 0x015A10, 0x013772, 0x047B2D, 0x04086E, 0x043998, 0x03CD69, 0x030000, 0x025B6A, 0x028DB3, 0x02019B, 0x019FA3, 0x00DCB8, 0x0161C7, 0x00B45B, 0x01D398, 0x016F63, 0x0108DD, 0x00D70A, 0x01066F, 0x0085C9, 0x00941F, 0x005062, }, { 0x02AAAB, 0x03EE11, 0x04646D, 0x0617A0, 0x03B3B2, 0x038713, 0x060A75, 0x056FC6, 0x030000, 0x025B6A, 0x049F9B, 0x03A1F4, 0x01B6BB, 0x00DFAA, 0x028090, 0x0156E2, 0x0492AE, 0x03C399, 0x0481ED, 0x038AA2, 0x0297BD, 0x01525F, 0x027080, 0x013E5E, 0x0492AE, 0x0657C8, 0x044FC1, 0x05FAF4, 0x03D555, 0x055126, 0x03248D, 0x045BF2, 0x05022D, 0x0481ED, 0x041B33, 0x03D979, 0x024147, 0x0360C3, 0x01499C, 0x01C92E, 0x032E96, 0x02DD1C, 0x01CD6A, 0x019F43, 0x05F991, 0x056093, 0x05A220, 0x0511E1, 0x040000, 0x03248D, 0x036799, 0x02ACCF, 0x022A2F, 0x01264B, 0x01D7B5, 0x00F079, 0x026F75, 0x01E9D9, 0x016127, 0x011EB8, 0x015DE9, 0x00B262, 0x00C57F, 0x006B2D, }, { 0x038000, 0x052876, 0x05C3CF, 0x07FF02, 0x04DBD9, 0x04A148, 0x07EDBA, 0x0722B4, 0x03F000, 0x0317FB, 0x06117C, 0x04C491, 0x023FD5, 0x01258F, 0x0348BD, 0x01C209, 0x060085, 0x04F0B9, 0x05EA87, 0x04A5F5, 0x036728, 0x01BC1C, 0x0333A8, 0x01A1DB, 0x060085, 0x085336, 0x05A8AE, 0x07D960, 0x050800, 0x06FA82, 0x041FF9, 0x05B8AE, 0x0692DA, 0x05EA87, 0x0563B2, 0x050D6E, 0x02F5AD, 0x046F00, 0x01B09C, 0x02580C, 0x042D25, 0x03C235, 0x025D9B, 0x022108, 0x07D78F, 0x070EC1, 0x0764CA, 0x06A777, 0x054000, 0x041FF9, 0x0477F9, 0x0382D0, 0x02D75E, 0x018242, 0x026B1D, 0x013B9F, 0x03324A, 0x0282ED, 0x01CF83, 0x017851, 0x01CB42, 0x00EA21, 0x010336, 0x008CAC, }, { 0x040000, 0x05E519, 0x0696A4, 0x092370, 0x058D8A, 0x054A9C, 0x090FB0, 0x0827AA, 0x048000, 0x03891F, 0x06EF69, 0x0572EE, 0x029218, 0x014F7E, 0x03C0D8, 0x020254, 0x06DC05, 0x05A565, 0x06C2E4, 0x054FF3, 0x03E39B, 0x01FB8E, 0x03A8C0, 0x01DD8D, 0x06DC05, 0x0983AC, 0x0677A2, 0x08F86E, 0x05C000, 0x07F9B9, 0x04B6D4, 0x0689EB, 0x078343, 0x06C2E4, 0x0628CC, 0x05C635, 0x0361EA, 0x051124, 0x01EE69, 0x02ADC5, 0x04C5E1, 0x044BAA, 0x02B41F, 0x026EE5, 0x08F65A, 0x0810DD, 0x087330, 0x079AD1, 0x060000, 0x04B6D4, 0x051B65, 0x040337, 0x033F47, 0x01B970, 0x02C38F, 0x0168B6, 0x03A730, 0x02DEC6, 0x0211BA, 0x01AE14, 0x020CDD, 0x010B93, 0x01283E, 0x00A0C4, }, { 0x050000, 0x075E60, 0x083C4D, 0x0B6C4C, 0x06F0ED, 0x069D43, 0x0B539C, 0x0A3194, 0x05A000, 0x046B67, 0x08AB44, 0x06CFAA, 0x03369E, 0x01A35E, 0x04B10F, 0x0282E8, 0x089307, 0x070EBF, 0x08739C, 0x06A3F0, 0x04DC82, 0x027A72, 0x0492F0, 0x0254F0, 0x089307, 0x0BE497, 0x08158B, 0x0B3689, 0x073000, 0x09F827, 0x05E489, 0x082C66, 0x096413, 0x08739C, 0x07B2FF, 0x0737C2, 0x043A64, 0x06556D, 0x026A04, 0x035936, 0x05F75A, 0x055E94, 0x036127, 0x030A9E, 0x0B33F1, 0x0A1514, 0x0A8FFC, 0x098186, 0x078000, 0x05E489, 0x06623F, 0x050405, 0x040F19, 0x0227CC, 0x037473, 0x01C2E3, 0x0490FC, 0x039677, 0x029629, 0x021999, 0x029015, 0x014E78, 0x01724E, 0x00C8F5, }, { 0x060000, 0x08D7A6, 0x09E1F6, 0x0DB528, 0x085450, 0x07EFEA, 0x0D9788, 0x0C3B7E, 0x06C000, 0x054DAE, 0x0A671E, 0x082C66, 0x03DB24, 0x01F73E, 0x05A145, 0x03037D, 0x0A4A08, 0x087818, 0x0A2455, 0x07F7ED, 0x05D569, 0x02F955, 0x057D20, 0x02CC54, 0x0A4A08, 0x0E4582, 0x09B373, 0x0D74A5, 0x08A000, 0x0BF696, 0x07123E, 0x09CEE0, 0x0B44E4, 0x0A2455, 0x093D32, 0x08A950, 0x0512DF, 0x0799B6, 0x02E59E, 0x0404A7, 0x0728D2, 0x06717F, 0x040E2F, 0x03A657, 0x0D7187, 0x0C194B, 0x0CACC8, 0x0B683A, 0x090000, 0x07123E, 0x07A918, 0x0604D2, 0x04DEEA, 0x029629, 0x042556, 0x021D11, 0x057AC8, 0x044E28, 0x031A97, 0x02851E, 0x03134C, 0x01915C, 0x01BC5D, 0x00F126, }, { 0x080000, 0x0BCA33, 0x0D2D48, 0x1246E0, 0x0B1B15, 0x0A9538, 0x121F5F, 0x104F53, 0x090000, 0x07123E, 0x0DDED2, 0x0AE5DD, 0x052430, 0x029EFD, 0x0781B1, 0x0404A7, 0x0DB80B, 0x0B4ACB, 0x0D85C7, 0x0A9FE7, 0x07C736, 0x03F71D, 0x075180, 0x03BB1A, 0x0DB80B, 0x130757, 0x0CEF44, 0x11F0DC, 0x0B8000, 0x0FF372, 0x096DA8, 0x0D13D6, 0x0F0686, 0x0D85C7, 0x0C5198, 0x0B8C6A, 0x06C3D4, 0x0A2248, 0x03DCD3, 0x055B8A, 0x098BC3, 0x089754, 0x05683E, 0x04DDC9, 0x11ECB4, 0x1021B9, 0x10E661, 0x0F35A3, 0x0C0000, 0x096DA8, 0x0A36CB, 0x08066E, 0x067E8E, 0x0372E1, 0x05871E, 0x02D16B, 0x074E60, 0x05BD8B, 0x042374, 0x035C28, 0x0419BB, 0x021726, 0x02507C, 0x014188, }, { 0x0C0000, 0x11AF4C, 0x13C3EC, 0x1B6A50, 0x10A89F, 0x0FDFD4, 0x1B2F0F, 0x1876FD, 0x0D8000, 0x0A9B5D, 0x14CE3C, 0x1058CB, 0x07B649, 0x03EE7B, 0x0B4289, 0x0606FB, 0x149410, 0x10F030, 0x1448AB, 0x0FEFDA, 0x0BAAD2, 0x05F2AB, 0x0AFA40, 0x0598A7, 0x149410, 0x1C8B03, 0x1366E6, 0x1AE949, 0x114000, 0x17ED2B, 0x0E247C, 0x139DC1, 0x1689C8, 0x1448AB, 0x127A63, 0x11529F, 0x0A25BE, 0x0F336D, 0x05CB3C, 0x08094E, 0x0E51A4, 0x0CE2FE, 0x081C5D, 0x074CAE, 0x1AE30E, 0x183296, 0x195991, 0x16D074, 0x120000, 0x0E247C, 0x0F5230, 0x0C09A5, 0x09BDD5, 0x052C51, 0x084AAC, 0x043A21, 0x0AF590, 0x089C51, 0x06352E, 0x050A3B, 0x062698, 0x0322B9, 0x0378BA, 0x01E24D, }, { 0x110000, 0x190DAC, 0x1C0039, 0x26D69C, 0x17998C, 0x167D16, 0x2682AB, 0x22A891, 0x132000, 0x0F06C3, 0x1D797F, 0x172876, 0x0AECE7, 0x0591D9, 0x0FF398, 0x0889E3, 0x1D2717, 0x17FEEF, 0x1CBC47, 0x1693CA, 0x108754, 0x086D1D, 0x0F8D30, 0x07ED98, 0x1D2717, 0x286F9A, 0x1B7C71, 0x261FD3, 0x187000, 0x21E552, 0x140904, 0x1BCA27, 0x1FEDDC, 0x1CBC47, 0x1A2D62, 0x188A62, 0x0E6022, 0x1588DA, 0x083540, 0x0B6284, 0x1448FE, 0x124192, 0x0B7D84, 0x0A574B, 0x2616FF, 0x2247AA, 0x23E98D, 0x2051FA, 0x198000, 0x140904, 0x15B46F, 0x110DAA, 0x0DCCEE, 0x07541E, 0x0BBF1F, 0x05FD04, 0x0F868B, 0x0C32C8, 0x08CB57, 0x0723D4, 0x08B6AD, 0x047130, 0x04EB08, 0x02AB42, }, { 0x160000, 0x206C0C, 0x243C86, 0x3242E8, 0x1E8A79, 0x1D1A59, 0x31D646, 0x2CDA25, 0x18C000, 0x13722A, 0x2624C3, 0x1DF820, 0x0E2385, 0x073537, 0x14A4A7, 0x0B0CCC, 0x25BA1D, 0x1F0DAE, 0x252FE4, 0x1D37BB, 0x1563D6, 0x0AE78E, 0x142021, 0x0A4288, 0x25BA1D, 0x345430, 0x2391FB, 0x31565C, 0x1FA000, 0x2BDD7A, 0x19ED8D, 0x23F68C, 0x2951EF, 0x252FE4, 0x21E061, 0x1FC224, 0x129A87, 0x1BDE47, 0x0A9F44, 0x0EBBBA, 0x1A4058, 0x17A026, 0x0EDEAB, 0x0D61E9, 0x314AEF, 0x2C5CBE, 0x2E798A, 0x29D380, 0x210000, 0x19ED8D, 0x1C16AE, 0x1611AE, 0x11DC06, 0x097BEA, 0x0F3391, 0x07BFE7, 0x141787, 0x0FC93E, 0x0B617F, 0x093D6D, 0x0B46C1, 0x05BFA8, 0x065D55, 0x037437, }, { 0x1C0000, 0x2943B2, 0x2E1E7C, 0x3FF810, 0x26DEC9, 0x250A43, 0x3F6DCE, 0x3915A3, 0x1F8000, 0x18BFD8, 0x308BE1, 0x262485, 0x11FEA9, 0x092C75, 0x1A45EB, 0x0E1049, 0x300425, 0x2785C6, 0x2F5439, 0x252FA8, 0x1B393F, 0x0DE0E4, 0x199D41, 0x0D0EDC, 0x300425, 0x4299B2, 0x2D456E, 0x3ECB00, 0x284000, 0x37D40F, 0x20FFCB, 0x2DC56D, 0x3496D3, 0x2F5439, 0x2B1D93, 0x286B74, 0x17AD66, 0x2377FE, 0x0D84E2, 0x12C062, 0x21692A, 0x1E11A5, 0x12ECDA, 0x110840, 0x3EBC76, 0x387608, 0x3B2652, 0x353BBA, 0x2A0000, 0x20FFCB, 0x23BFC6, 0x1C1681, 0x16BAF1, 0x0C1213, 0x1358E8, 0x09DCF8, 0x19924F, 0x141767, 0x0E7C16, 0x0BC28A, 0x0E5A0D, 0x075104, 0x0819B2, 0x04655D, }, { 0x220000, 0x321B58, 0x380072, 0x4DAD38, 0x2F3318, 0x2CFA2D, 0x4D0556, 0x455122, 0x264000, 0x1E0D86, 0x3AF2FE, 0x2E50EB, 0x15D9CE, 0x0B23B2, 0x1FE730, 0x1113C7, 0x3A4E2D, 0x2FFDDF, 0x39788E, 0x2D2795, 0x210EA8, 0x10DA39, 0x1F1A61, 0x0FDB2F, 0x3A4E2D, 0x50DF33, 0x36F8E1, 0x4C3FA5, 0x30E000, 0x43CAA5, 0x281209, 0x37944D, 0x3FDBB7, 0x39788E, 0x345AC4, 0x3114C3, 0x1CC044, 0x2B11B4, 0x106A80, 0x16C509, 0x2891FC, 0x248324, 0x16FB08, 0x14AE97, 0x4C2DFD, 0x448F54, 0x47D31B, 0x40A3F5, 0x330000, 0x281209, 0x2B68DF, 0x221B53, 0x1B99DB, 0x0EA83B, 0x177E3E, 0x0BFA09, 0x1F0D17, 0x18658F, 0x1196AE, 0x0E47A8, 0x116D5A, 0x08E260, 0x09D60F, 0x055684, }, { 0x2C0000, 0x40D818, 0x48790C, 0x6485D0, 0x3D14F2, 0x3A34B2, 0x63AC8D, 0x59B44A, 0x318000, 0x26E454, 0x4C4986, 0x3BF03F, 0x1C470A, 0x0E6A6E, 0x29494D, 0x161998, 0x4B743A, 0x3E1B5C, 0x4A5FC7, 0x3A6F75, 0x2AC7AC, 0x15CF1D, 0x284041, 0x148510, 0x4B743A, 0x68A861, 0x4723F6, 0x62ACB8, 0x3F4000, 0x57BAF3, 0x33DB1A, 0x47ED19, 0x52A3DE, 0x4A5FC7, 0x43C0C2, 0x3F8448, 0x25350D, 0x37BC8E, 0x153E87, 0x1D7775, 0x3480B0, 0x2F404C, 0x1DBD56, 0x1AC3D2, 0x6295DE, 0x58B97B, 0x5CF313, 0x53A701, 0x420000, 0x33DB1A, 0x382D5C, 0x2C235D, 0x23B80D, 0x12F7D4, 0x1E6723, 0x0F7FCF, 0x282F0E, 0x1F927D, 0x16C2FF, 0x127AD9, 0x168D83, 0x0B7F50, 0x0CBAAA, 0x06E86E, }, }; #endif /* AVCODEC_BINKDATA_H */
123linslouis-android-video-cutter
jni/libavcodec/binkdata.h
C
asf20
32,746
/* * DVD subtitle decoding for ffmpeg * Copyright (c) 2005 Fabrice Bellard * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avcodec.h" #include "get_bits.h" #include "colorspace.h" #include "dsputil.h" //#define DEBUG static void yuv_a_to_rgba(const uint8_t *ycbcr, const uint8_t *alpha, uint32_t *rgba, int num_values) { uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; uint8_t r, g, b; int i, y, cb, cr; int r_add, g_add, b_add; for (i = num_values; i > 0; i--) { y = *ycbcr++; cb = *ycbcr++; cr = *ycbcr++; YUV_TO_RGB1_CCIR(cb, cr); YUV_TO_RGB2_CCIR(r, g, b, y); *rgba++ = (*alpha++ << 24) | (r << 16) | (g << 8) | b; } } static int decode_run_2bit(GetBitContext *gb, int *color) { unsigned int v, t; v = 0; for (t = 1; v < t && t <= 0x40; t <<= 2) v = (v << 4) | get_bits(gb, 4); *color = v & 3; if (v < 4) { /* Code for fill rest of line */ return INT_MAX; } return v >> 2; } static int decode_run_8bit(GetBitContext *gb, int *color) { int len; int has_run = get_bits1(gb); if (get_bits1(gb)) *color = get_bits(gb, 8); else *color = get_bits(gb, 2); if (has_run) { if (get_bits1(gb)) { len = get_bits(gb, 7); if (len == 0) len = INT_MAX; else len += 9; } else len = get_bits(gb, 3) + 2; } else len = 1; return len; } static int decode_rle(uint8_t *bitmap, int linesize, int w, int h, const uint8_t *buf, int start, int buf_size, int is_8bit) { GetBitContext gb; int bit_len; int x, y, len, color; uint8_t *d; bit_len = (buf_size - start) * 8; init_get_bits(&gb, buf + start, bit_len); x = 0; y = 0; d = bitmap; for(;;) { if (get_bits_count(&gb) > bit_len) return -1; if (is_8bit) len = decode_run_8bit(&gb, &color); else len = decode_run_2bit(&gb, &color); len = FFMIN(len, w - x); memset(d + x, color, len); x += len; if (x >= w) { y++; if (y >= h) break; d += linesize; x = 0; /* byte align */ align_get_bits(&gb); } } return 0; } static void guess_palette(uint32_t *rgba_palette, uint8_t *colormap, uint8_t *alpha, uint32_t subtitle_color) { uint8_t color_used[16]; int nb_opaque_colors, i, level, j, r, g, b; for(i = 0; i < 4; i++) rgba_palette[i] = 0; memset(color_used, 0, 16); nb_opaque_colors = 0; for(i = 0; i < 4; i++) { if (alpha[i] != 0 && !color_used[colormap[i]]) { color_used[colormap[i]] = 1; nb_opaque_colors++; } } if (nb_opaque_colors == 0) return; j = nb_opaque_colors; memset(color_used, 0, 16); for(i = 0; i < 4; i++) { if (alpha[i] != 0) { if (!color_used[colormap[i]]) { level = (0xff * j) / nb_opaque_colors; r = (((subtitle_color >> 16) & 0xff) * level) >> 8; g = (((subtitle_color >> 8) & 0xff) * level) >> 8; b = (((subtitle_color >> 0) & 0xff) * level) >> 8; rgba_palette[i] = b | (g << 8) | (r << 16) | ((alpha[i] * 17) << 24); color_used[colormap[i]] = (i + 1); j--; } else { rgba_palette[i] = (rgba_palette[color_used[colormap[i]] - 1] & 0x00ffffff) | ((alpha[i] * 17) << 24); } } } } #define READ_OFFSET(a) (big_offsets ? AV_RB32(a) : AV_RB16(a)) static int decode_dvd_subtitles(AVSubtitle *sub_header, const uint8_t *buf, int buf_size) { int cmd_pos, pos, cmd, x1, y1, x2, y2, offset1, offset2, next_cmd_pos; int big_offsets, offset_size, is_8bit = 0; const uint8_t *yuv_palette = 0; uint8_t colormap[4], alpha[256]; int date; int i; int is_menu = 0; if (buf_size < 10) return -1; memset(sub_header, 0, sizeof(*sub_header)); if (AV_RB16(buf) == 0) { /* HD subpicture with 4-byte offsets */ big_offsets = 1; offset_size = 4; cmd_pos = 6; } else { big_offsets = 0; offset_size = 2; cmd_pos = 2; } cmd_pos = READ_OFFSET(buf + cmd_pos); while (cmd_pos > 0 && cmd_pos < buf_size - 2 - offset_size) { date = AV_RB16(buf + cmd_pos); next_cmd_pos = READ_OFFSET(buf + cmd_pos + 2); dprintf(NULL, "cmd_pos=0x%04x next=0x%04x date=%d\n", cmd_pos, next_cmd_pos, date); pos = cmd_pos + 2 + offset_size; offset1 = -1; offset2 = -1; x1 = y1 = x2 = y2 = 0; while (pos < buf_size) { cmd = buf[pos++]; dprintf(NULL, "cmd=%02x\n", cmd); switch(cmd) { case 0x00: /* menu subpicture */ is_menu = 1; break; case 0x01: /* set start date */ sub_header->start_display_time = (date << 10) / 90; break; case 0x02: /* set end date */ sub_header->end_display_time = (date << 10) / 90; break; case 0x03: /* set colormap */ if ((buf_size - pos) < 2) goto fail; colormap[3] = buf[pos] >> 4; colormap[2] = buf[pos] & 0x0f; colormap[1] = buf[pos + 1] >> 4; colormap[0] = buf[pos + 1] & 0x0f; pos += 2; break; case 0x04: /* set alpha */ if ((buf_size - pos) < 2) goto fail; alpha[3] = buf[pos] >> 4; alpha[2] = buf[pos] & 0x0f; alpha[1] = buf[pos + 1] >> 4; alpha[0] = buf[pos + 1] & 0x0f; pos += 2; dprintf(NULL, "alpha=%x%x%x%x\n", alpha[0],alpha[1],alpha[2],alpha[3]); break; case 0x05: case 0x85: if ((buf_size - pos) < 6) goto fail; x1 = (buf[pos] << 4) | (buf[pos + 1] >> 4); x2 = ((buf[pos + 1] & 0x0f) << 8) | buf[pos + 2]; y1 = (buf[pos + 3] << 4) | (buf[pos + 4] >> 4); y2 = ((buf[pos + 4] & 0x0f) << 8) | buf[pos + 5]; if (cmd & 0x80) is_8bit = 1; dprintf(NULL, "x1=%d x2=%d y1=%d y2=%d\n", x1, x2, y1, y2); pos += 6; break; case 0x06: if ((buf_size - pos) < 4) goto fail; offset1 = AV_RB16(buf + pos); offset2 = AV_RB16(buf + pos + 2); dprintf(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2); pos += 4; break; case 0x86: if ((buf_size - pos) < 8) goto fail; offset1 = AV_RB32(buf + pos); offset2 = AV_RB32(buf + pos + 4); dprintf(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2); pos += 8; break; case 0x83: /* HD set palette */ if ((buf_size - pos) < 768) goto fail; yuv_palette = buf + pos; pos += 768; break; case 0x84: /* HD set contrast (alpha) */ if ((buf_size - pos) < 256) goto fail; for (i = 0; i < 256; i++) alpha[i] = 0xFF - buf[pos+i]; pos += 256; break; case 0xff: goto the_end; default: dprintf(NULL, "unrecognised subpicture command 0x%x\n", cmd); goto the_end; } } the_end: if (offset1 >= 0) { int w, h; uint8_t *bitmap; /* decode the bitmap */ w = x2 - x1 + 1; if (w < 0) w = 0; h = y2 - y1; if (h < 0) h = 0; if (w > 0 && h > 0) { if (sub_header->rects != NULL) { for (i = 0; i < sub_header->num_rects; i++) { av_freep(&sub_header->rects[i]->pict.data[0]); av_freep(&sub_header->rects[i]->pict.data[1]); av_freep(&sub_header->rects[i]); } av_freep(&sub_header->rects); sub_header->num_rects = 0; } bitmap = av_malloc(w * h); sub_header->rects = av_mallocz(sizeof(*sub_header->rects)); sub_header->rects[0] = av_mallocz(sizeof(AVSubtitleRect)); sub_header->num_rects = 1; sub_header->rects[0]->pict.data[0] = bitmap; decode_rle(bitmap, w * 2, w, (h + 1) / 2, buf, offset1, buf_size, is_8bit); decode_rle(bitmap + w, w * 2, w, h / 2, buf, offset2, buf_size, is_8bit); sub_header->rects[0]->pict.data[1] = av_mallocz(AVPALETTE_SIZE); if (is_8bit) { if (yuv_palette == 0) goto fail; sub_header->rects[0]->nb_colors = 256; yuv_a_to_rgba(yuv_palette, alpha, (uint32_t*)sub_header->rects[0]->pict.data[1], 256); } else { sub_header->rects[0]->nb_colors = 4; guess_palette((uint32_t*)sub_header->rects[0]->pict.data[1], colormap, alpha, 0xffff00); } sub_header->rects[0]->x = x1; sub_header->rects[0]->y = y1; sub_header->rects[0]->w = w; sub_header->rects[0]->h = h; sub_header->rects[0]->type = SUBTITLE_BITMAP; sub_header->rects[0]->pict.linesize[0] = w; } } if (next_cmd_pos == cmd_pos) break; cmd_pos = next_cmd_pos; } if (sub_header->num_rects > 0) return is_menu; fail: if (sub_header->rects != NULL) { for (i = 0; i < sub_header->num_rects; i++) { av_freep(&sub_header->rects[i]->pict.data[0]); av_freep(&sub_header->rects[i]->pict.data[1]); av_freep(&sub_header->rects[i]); } av_freep(&sub_header->rects); sub_header->num_rects = 0; } return -1; } static int is_transp(const uint8_t *buf, int pitch, int n, const uint8_t *transp_color) { int i; for(i = 0; i < n; i++) { if (!transp_color[*buf]) return 0; buf += pitch; } return 1; } /* return 0 if empty rectangle, 1 if non empty */ static int find_smallest_bounding_rectangle(AVSubtitle *s) { uint8_t transp_color[256]; int y1, y2, x1, x2, y, w, h, i; uint8_t *bitmap; if (s->num_rects == 0 || s->rects == NULL || s->rects[0]->w <= 0 || s->rects[0]->h <= 0) return 0; memset(transp_color, 0, 256); for(i = 0; i < s->rects[0]->nb_colors; i++) { if ((((uint32_t*)s->rects[0]->pict.data[1])[i] >> 24) == 0) transp_color[i] = 1; } y1 = 0; while (y1 < s->rects[0]->h && is_transp(s->rects[0]->pict.data[0] + y1 * s->rects[0]->pict.linesize[0], 1, s->rects[0]->w, transp_color)) y1++; if (y1 == s->rects[0]->h) { av_freep(&s->rects[0]->pict.data[0]); s->rects[0]->w = s->rects[0]->h = 0; return 0; } y2 = s->rects[0]->h - 1; while (y2 > 0 && is_transp(s->rects[0]->pict.data[0] + y2 * s->rects[0]->pict.linesize[0], 1, s->rects[0]->w, transp_color)) y2--; x1 = 0; while (x1 < (s->rects[0]->w - 1) && is_transp(s->rects[0]->pict.data[0] + x1, s->rects[0]->pict.linesize[0], s->rects[0]->h, transp_color)) x1++; x2 = s->rects[0]->w - 1; while (x2 > 0 && is_transp(s->rects[0]->pict.data[0] + x2, s->rects[0]->pict.linesize[0], s->rects[0]->h, transp_color)) x2--; w = x2 - x1 + 1; h = y2 - y1 + 1; bitmap = av_malloc(w * h); if (!bitmap) return 1; for(y = 0; y < h; y++) { memcpy(bitmap + w * y, s->rects[0]->pict.data[0] + x1 + (y1 + y) * s->rects[0]->pict.linesize[0], w); } av_freep(&s->rects[0]->pict.data[0]); s->rects[0]->pict.data[0] = bitmap; s->rects[0]->pict.linesize[0] = w; s->rects[0]->w = w; s->rects[0]->h = h; s->rects[0]->x += x1; s->rects[0]->y += y1; return 1; } #ifdef DEBUG #undef fprintf #undef perror #undef exit static void ppm_save(const char *filename, uint8_t *bitmap, int w, int h, uint32_t *rgba_palette) { int x, y, v; FILE *f; f = fopen(filename, "w"); if (!f) { perror(filename); exit(1); } fprintf(f, "P6\n" "%d %d\n" "%d\n", w, h, 255); for(y = 0; y < h; y++) { for(x = 0; x < w; x++) { v = rgba_palette[bitmap[y * w + x]]; putc((v >> 16) & 0xff, f); putc((v >> 8) & 0xff, f); putc((v >> 0) & 0xff, f); } } fclose(f); } #endif static int dvdsub_decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; AVSubtitle *sub = (void *)data; int is_menu; is_menu = decode_dvd_subtitles(sub, buf, buf_size); if (is_menu < 0) { no_subtitle: *data_size = 0; return buf_size; } if (!is_menu && find_smallest_bounding_rectangle(sub) == 0) goto no_subtitle; #if defined(DEBUG) dprintf(NULL, "start=%d ms end =%d ms\n", sub->start_display_time, sub->end_display_time); ppm_save("/tmp/a.ppm", sub->rects[0]->pict.data[0], sub->rects[0]->w, sub->rects[0]->h, sub->rects[0]->pict.data[1]); #endif *data_size = 1; return buf_size; } AVCodec dvdsub_decoder = { "dvdsub", AVMEDIA_TYPE_SUBTITLE, CODEC_ID_DVD_SUBTITLE, 0, NULL, NULL, NULL, dvdsub_decode, .long_name = NULL_IF_CONFIG_SMALL("DVD subtitles"), };
123linslouis-android-video-cutter
jni/libavcodec/dvdsubdec.c
C
asf20
15,607
/* * jrevdct.c * * This file is part of the Independent JPEG Group's software. * * The authors make NO WARRANTY or representation, either express or implied, * with respect to this software, its quality, accuracy, merchantability, or * fitness for a particular purpose. This software is provided "AS IS", and * you, its user, assume the entire risk as to its quality and accuracy. * * This software is copyright (C) 1991, 1992, Thomas G. Lane. * All Rights Reserved except as specified below. * * Permission is hereby granted to use, copy, modify, and distribute this * software (or portions thereof) for any purpose, without fee, subject to * these conditions: * (1) If any part of the source code for this software is distributed, then * this README file must be included, with this copyright and no-warranty * notice unaltered; and any additions, deletions, or changes to the original * files must be clearly indicated in accompanying documentation. * (2) If only executable code is distributed, then the accompanying * documentation must state that "this software is based in part on the work * of the Independent JPEG Group". * (3) Permission for use of this software is granted only if the user accepts * full responsibility for any undesirable consequences; the authors accept * NO LIABILITY for damages of any kind. * * These conditions apply to any software derived from or based on the IJG * code, not just to the unmodified library. If you use our work, you ought * to acknowledge us. * * Permission is NOT granted for the use of any IJG author's name or company * name in advertising or publicity relating to this software or products * derived from it. This software may be referred to only as "the Independent * JPEG Group's software". * * We specifically permit and encourage the use of this software as the basis * of commercial products, provided that all warranty or liability claims are * assumed by the product vendor. * * This file contains the basic inverse-DCT transformation subroutine. * * This implementation is based on an algorithm described in * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. * The primary algorithm described there uses 11 multiplies and 29 adds. * We use their alternate method with 12 multiplies and 32 adds. * The advantage of this method is that no data path contains more than one * multiplication; this allows a very simple and accurate implementation in * scaled fixed-point arithmetic, with a minimal number of shifts. * * I've made lots of modifications to attempt to take advantage of the * sparse nature of the DCT matrices we're getting. Although the logic * is cumbersome, it's straightforward and the resulting code is much * faster. * * A better way to do this would be to pass in the DCT block as a sparse * matrix, perhaps with the difference cases encoded. */ /** * @file * Independent JPEG Group's LLM idct. */ #include "libavutil/common.h" #include "dsputil.h" #define EIGHT_BIT_SAMPLES #define DCTSIZE 8 #define DCTSIZE2 64 #define GLOBAL #define RIGHT_SHIFT(x, n) ((x) >> (n)) typedef DCTELEM DCTBLOCK[DCTSIZE2]; #define CONST_BITS 13 /* * This routine is specialized to the case DCTSIZE = 8. */ #if DCTSIZE != 8 Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ #endif /* * A 2-D IDCT can be done by 1-D IDCT on each row followed by 1-D IDCT * on each column. Direct algorithms are also available, but they are * much more complex and seem not to be any faster when reduced to code. * * The poop on this scaling stuff is as follows: * * Each 1-D IDCT step produces outputs which are a factor of sqrt(N) * larger than the true IDCT outputs. The final outputs are therefore * a factor of N larger than desired; since N=8 this can be cured by * a simple right shift at the end of the algorithm. The advantage of * this arrangement is that we save two multiplications per 1-D IDCT, * because the y0 and y4 inputs need not be divided by sqrt(N). * * We have to do addition and subtraction of the integer inputs, which * is no problem, and multiplication by fractional constants, which is * a problem to do in integer arithmetic. We multiply all the constants * by CONST_SCALE and convert them to integer constants (thus retaining * CONST_BITS bits of precision in the constants). After doing a * multiplication we have to divide the product by CONST_SCALE, with proper * rounding, to produce the correct output. This division can be done * cheaply as a right shift of CONST_BITS bits. We postpone shifting * as long as possible so that partial sums can be added together with * full fractional precision. * * The outputs of the first pass are scaled up by PASS1_BITS bits so that * they are represented to better-than-integral precision. These outputs * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word * with the recommended scaling. (To scale up 12-bit sample data further, an * intermediate int32 array would be needed.) * * To avoid overflow of the 32-bit intermediate results in pass 2, we must * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis * shows that the values given below are the most effective. */ #ifdef EIGHT_BIT_SAMPLES #define PASS1_BITS 2 #else #define PASS1_BITS 1 /* lose a little precision to avoid overflow */ #endif #define ONE ((int32_t) 1) #define CONST_SCALE (ONE << CONST_BITS) /* Convert a positive real constant to an integer scaled by CONST_SCALE. * IMPORTANT: if your compiler doesn't do this arithmetic at compile time, * you will pay a significant penalty in run time. In that case, figure * the correct integer constant values and insert them by hand. */ /* Actually FIX is no longer used, we precomputed them all */ #define FIX(x) ((int32_t) ((x) * CONST_SCALE + 0.5)) /* Descale and correctly round an int32_t value that's scaled by N bits. * We assume RIGHT_SHIFT rounds towards minus infinity, so adding * the fudge factor is correct for either sign of X. */ #define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n) /* Multiply an int32_t variable by an int32_t constant to yield an int32_t result. * For 8-bit samples with the recommended scaling, all the variable * and constant values involved are no more than 16 bits wide, so a * 16x16->32 bit multiply can be used instead of a full 32x32 multiply; * this provides a useful speedup on many machines. * There is no way to specify a 16x16->32 multiply in portable C, but * some C compilers will do the right thing if you provide the correct * combination of casts. * NB: for 12-bit samples, a full 32-bit multiplication will be needed. */ #ifdef EIGHT_BIT_SAMPLES #ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */ #define MULTIPLY(var,const) (((int16_t) (var)) * ((int16_t) (const))) #endif #ifdef SHORTxLCONST_32 /* known to work with Microsoft C 6.0 */ #define MULTIPLY(var,const) (((int16_t) (var)) * ((int32_t) (const))) #endif #endif #ifndef MULTIPLY /* default definition */ #define MULTIPLY(var,const) ((var) * (const)) #endif /* Unlike our decoder where we approximate the FIXes, we need to use exact ones here or successive P-frames will drift too much with Reference frame coding */ #define FIX_0_211164243 1730 #define FIX_0_275899380 2260 #define FIX_0_298631336 2446 #define FIX_0_390180644 3196 #define FIX_0_509795579 4176 #define FIX_0_541196100 4433 #define FIX_0_601344887 4926 #define FIX_0_765366865 6270 #define FIX_0_785694958 6436 #define FIX_0_899976223 7373 #define FIX_1_061594337 8697 #define FIX_1_111140466 9102 #define FIX_1_175875602 9633 #define FIX_1_306562965 10703 #define FIX_1_387039845 11363 #define FIX_1_451774981 11893 #define FIX_1_501321110 12299 #define FIX_1_662939225 13623 #define FIX_1_847759065 15137 #define FIX_1_961570560 16069 #define FIX_2_053119869 16819 #define FIX_2_172734803 17799 #define FIX_2_562915447 20995 #define FIX_3_072711026 25172 /* * Perform the inverse DCT on one block of coefficients. */ void j_rev_dct(DCTBLOCK data) { int32_t tmp0, tmp1, tmp2, tmp3; int32_t tmp10, tmp11, tmp12, tmp13; int32_t z1, z2, z3, z4, z5; int32_t d0, d1, d2, d3, d4, d5, d6, d7; register DCTELEM *dataptr; int rowctr; /* Pass 1: process rows. */ /* Note results are scaled up by sqrt(8) compared to a true IDCT; */ /* furthermore, we scale the results by 2**PASS1_BITS. */ dataptr = data; for (rowctr = DCTSIZE-1; rowctr >= 0; rowctr--) { /* Due to quantization, we will usually find that many of the input * coefficients are zero, especially the AC terms. We can exploit this * by short-circuiting the IDCT calculation for any row in which all * the AC terms are zero. In that case each output is equal to the * DC coefficient (with scale factor as needed). * With typical images and quantization tables, half or more of the * row DCT calculations can be simplified this way. */ register int *idataptr = (int*)dataptr; /* WARNING: we do the same permutation as MMX idct to simplify the video core */ d0 = dataptr[0]; d2 = dataptr[1]; d4 = dataptr[2]; d6 = dataptr[3]; d1 = dataptr[4]; d3 = dataptr[5]; d5 = dataptr[6]; d7 = dataptr[7]; if ((d1 | d2 | d3 | d4 | d5 | d6 | d7) == 0) { /* AC terms all zero */ if (d0) { /* Compute a 32 bit value to assign. */ DCTELEM dcval = (DCTELEM) (d0 << PASS1_BITS); register int v = (dcval & 0xffff) | ((dcval << 16) & 0xffff0000); idataptr[0] = v; idataptr[1] = v; idataptr[2] = v; idataptr[3] = v; } dataptr += DCTSIZE; /* advance pointer to next row */ continue; } /* Even part: reverse the even part of the forward DCT. */ /* The rotator is sqrt(2)*c(-6). */ { if (d6) { if (d2) { /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */ z1 = MULTIPLY(d2 + d6, FIX_0_541196100); tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065); tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865); tmp0 = (d0 + d4) << CONST_BITS; tmp1 = (d0 - d4) << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp1 + tmp2; tmp12 = tmp1 - tmp2; } else { /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */ tmp2 = MULTIPLY(-d6, FIX_1_306562965); tmp3 = MULTIPLY(d6, FIX_0_541196100); tmp0 = (d0 + d4) << CONST_BITS; tmp1 = (d0 - d4) << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp1 + tmp2; tmp12 = tmp1 - tmp2; } } else { if (d2) { /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */ tmp2 = MULTIPLY(d2, FIX_0_541196100); tmp3 = MULTIPLY(d2, FIX_1_306562965); tmp0 = (d0 + d4) << CONST_BITS; tmp1 = (d0 - d4) << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp1 + tmp2; tmp12 = tmp1 - tmp2; } else { /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */ tmp10 = tmp13 = (d0 + d4) << CONST_BITS; tmp11 = tmp12 = (d0 - d4) << CONST_BITS; } } /* Odd part per figure 8; the matrix is unitary and hence its * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. */ if (d7) { if (d5) { if (d3) { if (d1) { /* d1 != 0, d3 != 0, d5 != 0, d7 != 0 */ z1 = d7 + d1; z2 = d5 + d3; z3 = d7 + d3; z4 = d5 + d1; z5 = MULTIPLY(z3 + z4, FIX_1_175875602); tmp0 = MULTIPLY(d7, FIX_0_298631336); tmp1 = MULTIPLY(d5, FIX_2_053119869); tmp2 = MULTIPLY(d3, FIX_3_072711026); tmp3 = MULTIPLY(d1, FIX_1_501321110); z1 = MULTIPLY(-z1, FIX_0_899976223); z2 = MULTIPLY(-z2, FIX_2_562915447); z3 = MULTIPLY(-z3, FIX_1_961570560); z4 = MULTIPLY(-z4, FIX_0_390180644); z3 += z5; z4 += z5; tmp0 += z1 + z3; tmp1 += z2 + z4; tmp2 += z2 + z3; tmp3 += z1 + z4; } else { /* d1 == 0, d3 != 0, d5 != 0, d7 != 0 */ z2 = d5 + d3; z3 = d7 + d3; z5 = MULTIPLY(z3 + d5, FIX_1_175875602); tmp0 = MULTIPLY(d7, FIX_0_298631336); tmp1 = MULTIPLY(d5, FIX_2_053119869); tmp2 = MULTIPLY(d3, FIX_3_072711026); z1 = MULTIPLY(-d7, FIX_0_899976223); z2 = MULTIPLY(-z2, FIX_2_562915447); z3 = MULTIPLY(-z3, FIX_1_961570560); z4 = MULTIPLY(-d5, FIX_0_390180644); z3 += z5; z4 += z5; tmp0 += z1 + z3; tmp1 += z2 + z4; tmp2 += z2 + z3; tmp3 = z1 + z4; } } else { if (d1) { /* d1 != 0, d3 == 0, d5 != 0, d7 != 0 */ z1 = d7 + d1; z4 = d5 + d1; z5 = MULTIPLY(d7 + z4, FIX_1_175875602); tmp0 = MULTIPLY(d7, FIX_0_298631336); tmp1 = MULTIPLY(d5, FIX_2_053119869); tmp3 = MULTIPLY(d1, FIX_1_501321110); z1 = MULTIPLY(-z1, FIX_0_899976223); z2 = MULTIPLY(-d5, FIX_2_562915447); z3 = MULTIPLY(-d7, FIX_1_961570560); z4 = MULTIPLY(-z4, FIX_0_390180644); z3 += z5; z4 += z5; tmp0 += z1 + z3; tmp1 += z2 + z4; tmp2 = z2 + z3; tmp3 += z1 + z4; } else { /* d1 == 0, d3 == 0, d5 != 0, d7 != 0 */ tmp0 = MULTIPLY(-d7, FIX_0_601344887); z1 = MULTIPLY(-d7, FIX_0_899976223); z3 = MULTIPLY(-d7, FIX_1_961570560); tmp1 = MULTIPLY(-d5, FIX_0_509795579); z2 = MULTIPLY(-d5, FIX_2_562915447); z4 = MULTIPLY(-d5, FIX_0_390180644); z5 = MULTIPLY(d5 + d7, FIX_1_175875602); z3 += z5; z4 += z5; tmp0 += z3; tmp1 += z4; tmp2 = z2 + z3; tmp3 = z1 + z4; } } } else { if (d3) { if (d1) { /* d1 != 0, d3 != 0, d5 == 0, d7 != 0 */ z1 = d7 + d1; z3 = d7 + d3; z5 = MULTIPLY(z3 + d1, FIX_1_175875602); tmp0 = MULTIPLY(d7, FIX_0_298631336); tmp2 = MULTIPLY(d3, FIX_3_072711026); tmp3 = MULTIPLY(d1, FIX_1_501321110); z1 = MULTIPLY(-z1, FIX_0_899976223); z2 = MULTIPLY(-d3, FIX_2_562915447); z3 = MULTIPLY(-z3, FIX_1_961570560); z4 = MULTIPLY(-d1, FIX_0_390180644); z3 += z5; z4 += z5; tmp0 += z1 + z3; tmp1 = z2 + z4; tmp2 += z2 + z3; tmp3 += z1 + z4; } else { /* d1 == 0, d3 != 0, d5 == 0, d7 != 0 */ z3 = d7 + d3; tmp0 = MULTIPLY(-d7, FIX_0_601344887); z1 = MULTIPLY(-d7, FIX_0_899976223); tmp2 = MULTIPLY(d3, FIX_0_509795579); z2 = MULTIPLY(-d3, FIX_2_562915447); z5 = MULTIPLY(z3, FIX_1_175875602); z3 = MULTIPLY(-z3, FIX_0_785694958); tmp0 += z3; tmp1 = z2 + z5; tmp2 += z3; tmp3 = z1 + z5; } } else { if (d1) { /* d1 != 0, d3 == 0, d5 == 0, d7 != 0 */ z1 = d7 + d1; z5 = MULTIPLY(z1, FIX_1_175875602); z1 = MULTIPLY(z1, FIX_0_275899380); z3 = MULTIPLY(-d7, FIX_1_961570560); tmp0 = MULTIPLY(-d7, FIX_1_662939225); z4 = MULTIPLY(-d1, FIX_0_390180644); tmp3 = MULTIPLY(d1, FIX_1_111140466); tmp0 += z1; tmp1 = z4 + z5; tmp2 = z3 + z5; tmp3 += z1; } else { /* d1 == 0, d3 == 0, d5 == 0, d7 != 0 */ tmp0 = MULTIPLY(-d7, FIX_1_387039845); tmp1 = MULTIPLY(d7, FIX_1_175875602); tmp2 = MULTIPLY(-d7, FIX_0_785694958); tmp3 = MULTIPLY(d7, FIX_0_275899380); } } } } else { if (d5) { if (d3) { if (d1) { /* d1 != 0, d3 != 0, d5 != 0, d7 == 0 */ z2 = d5 + d3; z4 = d5 + d1; z5 = MULTIPLY(d3 + z4, FIX_1_175875602); tmp1 = MULTIPLY(d5, FIX_2_053119869); tmp2 = MULTIPLY(d3, FIX_3_072711026); tmp3 = MULTIPLY(d1, FIX_1_501321110); z1 = MULTIPLY(-d1, FIX_0_899976223); z2 = MULTIPLY(-z2, FIX_2_562915447); z3 = MULTIPLY(-d3, FIX_1_961570560); z4 = MULTIPLY(-z4, FIX_0_390180644); z3 += z5; z4 += z5; tmp0 = z1 + z3; tmp1 += z2 + z4; tmp2 += z2 + z3; tmp3 += z1 + z4; } else { /* d1 == 0, d3 != 0, d5 != 0, d7 == 0 */ z2 = d5 + d3; z5 = MULTIPLY(z2, FIX_1_175875602); tmp1 = MULTIPLY(d5, FIX_1_662939225); z4 = MULTIPLY(-d5, FIX_0_390180644); z2 = MULTIPLY(-z2, FIX_1_387039845); tmp2 = MULTIPLY(d3, FIX_1_111140466); z3 = MULTIPLY(-d3, FIX_1_961570560); tmp0 = z3 + z5; tmp1 += z2; tmp2 += z2; tmp3 = z4 + z5; } } else { if (d1) { /* d1 != 0, d3 == 0, d5 != 0, d7 == 0 */ z4 = d5 + d1; z5 = MULTIPLY(z4, FIX_1_175875602); z1 = MULTIPLY(-d1, FIX_0_899976223); tmp3 = MULTIPLY(d1, FIX_0_601344887); tmp1 = MULTIPLY(-d5, FIX_0_509795579); z2 = MULTIPLY(-d5, FIX_2_562915447); z4 = MULTIPLY(z4, FIX_0_785694958); tmp0 = z1 + z5; tmp1 += z4; tmp2 = z2 + z5; tmp3 += z4; } else { /* d1 == 0, d3 == 0, d5 != 0, d7 == 0 */ tmp0 = MULTIPLY(d5, FIX_1_175875602); tmp1 = MULTIPLY(d5, FIX_0_275899380); tmp2 = MULTIPLY(-d5, FIX_1_387039845); tmp3 = MULTIPLY(d5, FIX_0_785694958); } } } else { if (d3) { if (d1) { /* d1 != 0, d3 != 0, d5 == 0, d7 == 0 */ z5 = d1 + d3; tmp3 = MULTIPLY(d1, FIX_0_211164243); tmp2 = MULTIPLY(-d3, FIX_1_451774981); z1 = MULTIPLY(d1, FIX_1_061594337); z2 = MULTIPLY(-d3, FIX_2_172734803); z4 = MULTIPLY(z5, FIX_0_785694958); z5 = MULTIPLY(z5, FIX_1_175875602); tmp0 = z1 - z4; tmp1 = z2 + z4; tmp2 += z5; tmp3 += z5; } else { /* d1 == 0, d3 != 0, d5 == 0, d7 == 0 */ tmp0 = MULTIPLY(-d3, FIX_0_785694958); tmp1 = MULTIPLY(-d3, FIX_1_387039845); tmp2 = MULTIPLY(-d3, FIX_0_275899380); tmp3 = MULTIPLY(d3, FIX_1_175875602); } } else { if (d1) { /* d1 != 0, d3 == 0, d5 == 0, d7 == 0 */ tmp0 = MULTIPLY(d1, FIX_0_275899380); tmp1 = MULTIPLY(d1, FIX_0_785694958); tmp2 = MULTIPLY(d1, FIX_1_175875602); tmp3 = MULTIPLY(d1, FIX_1_387039845); } else { /* d1 == 0, d3 == 0, d5 == 0, d7 == 0 */ tmp0 = tmp1 = tmp2 = tmp3 = 0; } } } } } /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ dataptr[0] = (DCTELEM) DESCALE(tmp10 + tmp3, CONST_BITS-PASS1_BITS); dataptr[7] = (DCTELEM) DESCALE(tmp10 - tmp3, CONST_BITS-PASS1_BITS); dataptr[1] = (DCTELEM) DESCALE(tmp11 + tmp2, CONST_BITS-PASS1_BITS); dataptr[6] = (DCTELEM) DESCALE(tmp11 - tmp2, CONST_BITS-PASS1_BITS); dataptr[2] = (DCTELEM) DESCALE(tmp12 + tmp1, CONST_BITS-PASS1_BITS); dataptr[5] = (DCTELEM) DESCALE(tmp12 - tmp1, CONST_BITS-PASS1_BITS); dataptr[3] = (DCTELEM) DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS); dataptr[4] = (DCTELEM) DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS); dataptr += DCTSIZE; /* advance pointer to next row */ } /* Pass 2: process columns. */ /* Note that we must descale the results by a factor of 8 == 2**3, */ /* and also undo the PASS1_BITS scaling. */ dataptr = data; for (rowctr = DCTSIZE-1; rowctr >= 0; rowctr--) { /* Columns of zeroes can be exploited in the same way as we did with rows. * However, the row calculation has created many nonzero AC terms, so the * simplification applies less often (typically 5% to 10% of the time). * On machines with very fast multiplication, it's possible that the * test takes more time than it's worth. In that case this section * may be commented out. */ d0 = dataptr[DCTSIZE*0]; d1 = dataptr[DCTSIZE*1]; d2 = dataptr[DCTSIZE*2]; d3 = dataptr[DCTSIZE*3]; d4 = dataptr[DCTSIZE*4]; d5 = dataptr[DCTSIZE*5]; d6 = dataptr[DCTSIZE*6]; d7 = dataptr[DCTSIZE*7]; /* Even part: reverse the even part of the forward DCT. */ /* The rotator is sqrt(2)*c(-6). */ if (d6) { if (d2) { /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */ z1 = MULTIPLY(d2 + d6, FIX_0_541196100); tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065); tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865); tmp0 = (d0 + d4) << CONST_BITS; tmp1 = (d0 - d4) << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp1 + tmp2; tmp12 = tmp1 - tmp2; } else { /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */ tmp2 = MULTIPLY(-d6, FIX_1_306562965); tmp3 = MULTIPLY(d6, FIX_0_541196100); tmp0 = (d0 + d4) << CONST_BITS; tmp1 = (d0 - d4) << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp1 + tmp2; tmp12 = tmp1 - tmp2; } } else { if (d2) { /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */ tmp2 = MULTIPLY(d2, FIX_0_541196100); tmp3 = MULTIPLY(d2, FIX_1_306562965); tmp0 = (d0 + d4) << CONST_BITS; tmp1 = (d0 - d4) << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp1 + tmp2; tmp12 = tmp1 - tmp2; } else { /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */ tmp10 = tmp13 = (d0 + d4) << CONST_BITS; tmp11 = tmp12 = (d0 - d4) << CONST_BITS; } } /* Odd part per figure 8; the matrix is unitary and hence its * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. */ if (d7) { if (d5) { if (d3) { if (d1) { /* d1 != 0, d3 != 0, d5 != 0, d7 != 0 */ z1 = d7 + d1; z2 = d5 + d3; z3 = d7 + d3; z4 = d5 + d1; z5 = MULTIPLY(z3 + z4, FIX_1_175875602); tmp0 = MULTIPLY(d7, FIX_0_298631336); tmp1 = MULTIPLY(d5, FIX_2_053119869); tmp2 = MULTIPLY(d3, FIX_3_072711026); tmp3 = MULTIPLY(d1, FIX_1_501321110); z1 = MULTIPLY(-z1, FIX_0_899976223); z2 = MULTIPLY(-z2, FIX_2_562915447); z3 = MULTIPLY(-z3, FIX_1_961570560); z4 = MULTIPLY(-z4, FIX_0_390180644); z3 += z5; z4 += z5; tmp0 += z1 + z3; tmp1 += z2 + z4; tmp2 += z2 + z3; tmp3 += z1 + z4; } else { /* d1 == 0, d3 != 0, d5 != 0, d7 != 0 */ z2 = d5 + d3; z3 = d7 + d3; z5 = MULTIPLY(z3 + d5, FIX_1_175875602); tmp0 = MULTIPLY(d7, FIX_0_298631336); tmp1 = MULTIPLY(d5, FIX_2_053119869); tmp2 = MULTIPLY(d3, FIX_3_072711026); z1 = MULTIPLY(-d7, FIX_0_899976223); z2 = MULTIPLY(-z2, FIX_2_562915447); z3 = MULTIPLY(-z3, FIX_1_961570560); z4 = MULTIPLY(-d5, FIX_0_390180644); z3 += z5; z4 += z5; tmp0 += z1 + z3; tmp1 += z2 + z4; tmp2 += z2 + z3; tmp3 = z1 + z4; } } else { if (d1) { /* d1 != 0, d3 == 0, d5 != 0, d7 != 0 */ z1 = d7 + d1; z3 = d7; z4 = d5 + d1; z5 = MULTIPLY(z3 + z4, FIX_1_175875602); tmp0 = MULTIPLY(d7, FIX_0_298631336); tmp1 = MULTIPLY(d5, FIX_2_053119869); tmp3 = MULTIPLY(d1, FIX_1_501321110); z1 = MULTIPLY(-z1, FIX_0_899976223); z2 = MULTIPLY(-d5, FIX_2_562915447); z3 = MULTIPLY(-d7, FIX_1_961570560); z4 = MULTIPLY(-z4, FIX_0_390180644); z3 += z5; z4 += z5; tmp0 += z1 + z3; tmp1 += z2 + z4; tmp2 = z2 + z3; tmp3 += z1 + z4; } else { /* d1 == 0, d3 == 0, d5 != 0, d7 != 0 */ tmp0 = MULTIPLY(-d7, FIX_0_601344887); z1 = MULTIPLY(-d7, FIX_0_899976223); z3 = MULTIPLY(-d7, FIX_1_961570560); tmp1 = MULTIPLY(-d5, FIX_0_509795579); z2 = MULTIPLY(-d5, FIX_2_562915447); z4 = MULTIPLY(-d5, FIX_0_390180644); z5 = MULTIPLY(d5 + d7, FIX_1_175875602); z3 += z5; z4 += z5; tmp0 += z3; tmp1 += z4; tmp2 = z2 + z3; tmp3 = z1 + z4; } } } else { if (d3) { if (d1) { /* d1 != 0, d3 != 0, d5 == 0, d7 != 0 */ z1 = d7 + d1; z3 = d7 + d3; z5 = MULTIPLY(z3 + d1, FIX_1_175875602); tmp0 = MULTIPLY(d7, FIX_0_298631336); tmp2 = MULTIPLY(d3, FIX_3_072711026); tmp3 = MULTIPLY(d1, FIX_1_501321110); z1 = MULTIPLY(-z1, FIX_0_899976223); z2 = MULTIPLY(-d3, FIX_2_562915447); z3 = MULTIPLY(-z3, FIX_1_961570560); z4 = MULTIPLY(-d1, FIX_0_390180644); z3 += z5; z4 += z5; tmp0 += z1 + z3; tmp1 = z2 + z4; tmp2 += z2 + z3; tmp3 += z1 + z4; } else { /* d1 == 0, d3 != 0, d5 == 0, d7 != 0 */ z3 = d7 + d3; tmp0 = MULTIPLY(-d7, FIX_0_601344887); z1 = MULTIPLY(-d7, FIX_0_899976223); tmp2 = MULTIPLY(d3, FIX_0_509795579); z2 = MULTIPLY(-d3, FIX_2_562915447); z5 = MULTIPLY(z3, FIX_1_175875602); z3 = MULTIPLY(-z3, FIX_0_785694958); tmp0 += z3; tmp1 = z2 + z5; tmp2 += z3; tmp3 = z1 + z5; } } else { if (d1) { /* d1 != 0, d3 == 0, d5 == 0, d7 != 0 */ z1 = d7 + d1; z5 = MULTIPLY(z1, FIX_1_175875602); z1 = MULTIPLY(z1, FIX_0_275899380); z3 = MULTIPLY(-d7, FIX_1_961570560); tmp0 = MULTIPLY(-d7, FIX_1_662939225); z4 = MULTIPLY(-d1, FIX_0_390180644); tmp3 = MULTIPLY(d1, FIX_1_111140466); tmp0 += z1; tmp1 = z4 + z5; tmp2 = z3 + z5; tmp3 += z1; } else { /* d1 == 0, d3 == 0, d5 == 0, d7 != 0 */ tmp0 = MULTIPLY(-d7, FIX_1_387039845); tmp1 = MULTIPLY(d7, FIX_1_175875602); tmp2 = MULTIPLY(-d7, FIX_0_785694958); tmp3 = MULTIPLY(d7, FIX_0_275899380); } } } } else { if (d5) { if (d3) { if (d1) { /* d1 != 0, d3 != 0, d5 != 0, d7 == 0 */ z2 = d5 + d3; z4 = d5 + d1; z5 = MULTIPLY(d3 + z4, FIX_1_175875602); tmp1 = MULTIPLY(d5, FIX_2_053119869); tmp2 = MULTIPLY(d3, FIX_3_072711026); tmp3 = MULTIPLY(d1, FIX_1_501321110); z1 = MULTIPLY(-d1, FIX_0_899976223); z2 = MULTIPLY(-z2, FIX_2_562915447); z3 = MULTIPLY(-d3, FIX_1_961570560); z4 = MULTIPLY(-z4, FIX_0_390180644); z3 += z5; z4 += z5; tmp0 = z1 + z3; tmp1 += z2 + z4; tmp2 += z2 + z3; tmp3 += z1 + z4; } else { /* d1 == 0, d3 != 0, d5 != 0, d7 == 0 */ z2 = d5 + d3; z5 = MULTIPLY(z2, FIX_1_175875602); tmp1 = MULTIPLY(d5, FIX_1_662939225); z4 = MULTIPLY(-d5, FIX_0_390180644); z2 = MULTIPLY(-z2, FIX_1_387039845); tmp2 = MULTIPLY(d3, FIX_1_111140466); z3 = MULTIPLY(-d3, FIX_1_961570560); tmp0 = z3 + z5; tmp1 += z2; tmp2 += z2; tmp3 = z4 + z5; } } else { if (d1) { /* d1 != 0, d3 == 0, d5 != 0, d7 == 0 */ z4 = d5 + d1; z5 = MULTIPLY(z4, FIX_1_175875602); z1 = MULTIPLY(-d1, FIX_0_899976223); tmp3 = MULTIPLY(d1, FIX_0_601344887); tmp1 = MULTIPLY(-d5, FIX_0_509795579); z2 = MULTIPLY(-d5, FIX_2_562915447); z4 = MULTIPLY(z4, FIX_0_785694958); tmp0 = z1 + z5; tmp1 += z4; tmp2 = z2 + z5; tmp3 += z4; } else { /* d1 == 0, d3 == 0, d5 != 0, d7 == 0 */ tmp0 = MULTIPLY(d5, FIX_1_175875602); tmp1 = MULTIPLY(d5, FIX_0_275899380); tmp2 = MULTIPLY(-d5, FIX_1_387039845); tmp3 = MULTIPLY(d5, FIX_0_785694958); } } } else { if (d3) { if (d1) { /* d1 != 0, d3 != 0, d5 == 0, d7 == 0 */ z5 = d1 + d3; tmp3 = MULTIPLY(d1, FIX_0_211164243); tmp2 = MULTIPLY(-d3, FIX_1_451774981); z1 = MULTIPLY(d1, FIX_1_061594337); z2 = MULTIPLY(-d3, FIX_2_172734803); z4 = MULTIPLY(z5, FIX_0_785694958); z5 = MULTIPLY(z5, FIX_1_175875602); tmp0 = z1 - z4; tmp1 = z2 + z4; tmp2 += z5; tmp3 += z5; } else { /* d1 == 0, d3 != 0, d5 == 0, d7 == 0 */ tmp0 = MULTIPLY(-d3, FIX_0_785694958); tmp1 = MULTIPLY(-d3, FIX_1_387039845); tmp2 = MULTIPLY(-d3, FIX_0_275899380); tmp3 = MULTIPLY(d3, FIX_1_175875602); } } else { if (d1) { /* d1 != 0, d3 == 0, d5 == 0, d7 == 0 */ tmp0 = MULTIPLY(d1, FIX_0_275899380); tmp1 = MULTIPLY(d1, FIX_0_785694958); tmp2 = MULTIPLY(d1, FIX_1_175875602); tmp3 = MULTIPLY(d1, FIX_1_387039845); } else { /* d1 == 0, d3 == 0, d5 == 0, d7 == 0 */ tmp0 = tmp1 = tmp2 = tmp3 = 0; } } } } /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp3, CONST_BITS+PASS1_BITS+3); dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp10 - tmp3, CONST_BITS+PASS1_BITS+3); dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp11 + tmp2, CONST_BITS+PASS1_BITS+3); dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(tmp11 - tmp2, CONST_BITS+PASS1_BITS+3); dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(tmp12 + tmp1, CONST_BITS+PASS1_BITS+3); dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp12 - tmp1, CONST_BITS+PASS1_BITS+3); dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp13 + tmp0, CONST_BITS+PASS1_BITS+3); dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp13 - tmp0, CONST_BITS+PASS1_BITS+3); dataptr++; /* advance pointer to next column */ } } #undef DCTSIZE #define DCTSIZE 4 #define DCTSTRIDE 8 void j_rev_dct4(DCTBLOCK data) { int32_t tmp0, tmp1, tmp2, tmp3; int32_t tmp10, tmp11, tmp12, tmp13; int32_t z1; int32_t d0, d2, d4, d6; register DCTELEM *dataptr; int rowctr; /* Pass 1: process rows. */ /* Note results are scaled up by sqrt(8) compared to a true IDCT; */ /* furthermore, we scale the results by 2**PASS1_BITS. */ data[0] += 4; dataptr = data; for (rowctr = DCTSIZE-1; rowctr >= 0; rowctr--) { /* Due to quantization, we will usually find that many of the input * coefficients are zero, especially the AC terms. We can exploit this * by short-circuiting the IDCT calculation for any row in which all * the AC terms are zero. In that case each output is equal to the * DC coefficient (with scale factor as needed). * With typical images and quantization tables, half or more of the * row DCT calculations can be simplified this way. */ register int *idataptr = (int*)dataptr; d0 = dataptr[0]; d2 = dataptr[1]; d4 = dataptr[2]; d6 = dataptr[3]; if ((d2 | d4 | d6) == 0) { /* AC terms all zero */ if (d0) { /* Compute a 32 bit value to assign. */ DCTELEM dcval = (DCTELEM) (d0 << PASS1_BITS); register int v = (dcval & 0xffff) | ((dcval << 16) & 0xffff0000); idataptr[0] = v; idataptr[1] = v; } dataptr += DCTSTRIDE; /* advance pointer to next row */ continue; } /* Even part: reverse the even part of the forward DCT. */ /* The rotator is sqrt(2)*c(-6). */ if (d6) { if (d2) { /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */ z1 = MULTIPLY(d2 + d6, FIX_0_541196100); tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065); tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865); tmp0 = (d0 + d4) << CONST_BITS; tmp1 = (d0 - d4) << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp1 + tmp2; tmp12 = tmp1 - tmp2; } else { /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */ tmp2 = MULTIPLY(-d6, FIX_1_306562965); tmp3 = MULTIPLY(d6, FIX_0_541196100); tmp0 = (d0 + d4) << CONST_BITS; tmp1 = (d0 - d4) << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp1 + tmp2; tmp12 = tmp1 - tmp2; } } else { if (d2) { /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */ tmp2 = MULTIPLY(d2, FIX_0_541196100); tmp3 = MULTIPLY(d2, FIX_1_306562965); tmp0 = (d0 + d4) << CONST_BITS; tmp1 = (d0 - d4) << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp1 + tmp2; tmp12 = tmp1 - tmp2; } else { /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */ tmp10 = tmp13 = (d0 + d4) << CONST_BITS; tmp11 = tmp12 = (d0 - d4) << CONST_BITS; } } /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ dataptr[0] = (DCTELEM) DESCALE(tmp10, CONST_BITS-PASS1_BITS); dataptr[1] = (DCTELEM) DESCALE(tmp11, CONST_BITS-PASS1_BITS); dataptr[2] = (DCTELEM) DESCALE(tmp12, CONST_BITS-PASS1_BITS); dataptr[3] = (DCTELEM) DESCALE(tmp13, CONST_BITS-PASS1_BITS); dataptr += DCTSTRIDE; /* advance pointer to next row */ } /* Pass 2: process columns. */ /* Note that we must descale the results by a factor of 8 == 2**3, */ /* and also undo the PASS1_BITS scaling. */ dataptr = data; for (rowctr = DCTSIZE-1; rowctr >= 0; rowctr--) { /* Columns of zeroes can be exploited in the same way as we did with rows. * However, the row calculation has created many nonzero AC terms, so the * simplification applies less often (typically 5% to 10% of the time). * On machines with very fast multiplication, it's possible that the * test takes more time than it's worth. In that case this section * may be commented out. */ d0 = dataptr[DCTSTRIDE*0]; d2 = dataptr[DCTSTRIDE*1]; d4 = dataptr[DCTSTRIDE*2]; d6 = dataptr[DCTSTRIDE*3]; /* Even part: reverse the even part of the forward DCT. */ /* The rotator is sqrt(2)*c(-6). */ if (d6) { if (d2) { /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */ z1 = MULTIPLY(d2 + d6, FIX_0_541196100); tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065); tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865); tmp0 = (d0 + d4) << CONST_BITS; tmp1 = (d0 - d4) << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp1 + tmp2; tmp12 = tmp1 - tmp2; } else { /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */ tmp2 = MULTIPLY(-d6, FIX_1_306562965); tmp3 = MULTIPLY(d6, FIX_0_541196100); tmp0 = (d0 + d4) << CONST_BITS; tmp1 = (d0 - d4) << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp1 + tmp2; tmp12 = tmp1 - tmp2; } } else { if (d2) { /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */ tmp2 = MULTIPLY(d2, FIX_0_541196100); tmp3 = MULTIPLY(d2, FIX_1_306562965); tmp0 = (d0 + d4) << CONST_BITS; tmp1 = (d0 - d4) << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp1 + tmp2; tmp12 = tmp1 - tmp2; } else { /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */ tmp10 = tmp13 = (d0 + d4) << CONST_BITS; tmp11 = tmp12 = (d0 - d4) << CONST_BITS; } } /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ dataptr[DCTSTRIDE*0] = tmp10 >> (CONST_BITS+PASS1_BITS+3); dataptr[DCTSTRIDE*1] = tmp11 >> (CONST_BITS+PASS1_BITS+3); dataptr[DCTSTRIDE*2] = tmp12 >> (CONST_BITS+PASS1_BITS+3); dataptr[DCTSTRIDE*3] = tmp13 >> (CONST_BITS+PASS1_BITS+3); dataptr++; /* advance pointer to next column */ } } void j_rev_dct2(DCTBLOCK data){ int d00, d01, d10, d11; data[0] += 4; d00 = data[0+0*DCTSTRIDE] + data[1+0*DCTSTRIDE]; d01 = data[0+0*DCTSTRIDE] - data[1+0*DCTSTRIDE]; d10 = data[0+1*DCTSTRIDE] + data[1+1*DCTSTRIDE]; d11 = data[0+1*DCTSTRIDE] - data[1+1*DCTSTRIDE]; data[0+0*DCTSTRIDE]= (d00 + d10)>>3; data[1+0*DCTSTRIDE]= (d01 + d11)>>3; data[0+1*DCTSTRIDE]= (d00 - d10)>>3; data[1+1*DCTSTRIDE]= (d01 - d11)>>3; } void j_rev_dct1(DCTBLOCK data){ data[0] = (data[0] + 4)>>3; } #undef FIX #undef CONST_BITS
123linslouis-android-video-cutter
jni/libavcodec/jrevdct.c
C
asf20
43,830
/* * H.26L/H.264/AVC/JVT/14496-10/... motion vector predicion * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * H.264 / AVC / MPEG4 part10 motion vector predicion. * @author Michael Niedermayer <michaelni@gmx.at> */ #ifndef AVCODEC_H264_MVPRED_H #define AVCODEC_H264_MVPRED_H #include "internal.h" #include "avcodec.h" #include "h264.h" //#undef NDEBUG #include <assert.h> static inline int fetch_diagonal_mv(H264Context *h, const int16_t **C, int i, int list, int part_width){ const int topright_ref= h->ref_cache[list][ i - 8 + part_width ]; MpegEncContext *s = &h->s; /* there is no consistent mapping of mvs to neighboring locations that will * make mbaff happy, so we can't move all this logic to fill_caches */ if(FRAME_MBAFF){ #define SET_DIAG_MV(MV_OP, REF_OP, XY, Y4)\ const int xy = XY, y4 = Y4;\ const int mb_type = mb_types[xy+(y4>>2)*s->mb_stride];\ if(!USES_LIST(mb_type,list))\ return LIST_NOT_USED;\ mv = s->current_picture_ptr->motion_val[list][h->mb2b_xy[xy]+3 + y4*h->b_stride];\ h->mv_cache[list][scan8[0]-2][0] = mv[0];\ h->mv_cache[list][scan8[0]-2][1] = mv[1] MV_OP;\ return s->current_picture_ptr->ref_index[list][4*xy+1 + (y4&~1)] REF_OP; if(topright_ref == PART_NOT_AVAILABLE && i >= scan8[0]+8 && (i&7)==4 && h->ref_cache[list][scan8[0]-1] != PART_NOT_AVAILABLE){ const uint32_t *mb_types = s->current_picture_ptr->mb_type; const int16_t *mv; AV_ZERO32(h->mv_cache[list][scan8[0]-2]); *C = h->mv_cache[list][scan8[0]-2]; if(!MB_FIELD && IS_INTERLACED(h->left_type[0])){ SET_DIAG_MV(*2, >>1, h->left_mb_xy[0]+s->mb_stride, (s->mb_y&1)*2+(i>>5)); assert(h->left_mb_xy[0] == h->left_mb_xy[1]); } if(MB_FIELD && !IS_INTERLACED(h->left_type[0])){ // left shift will turn LIST_NOT_USED into PART_NOT_AVAILABLE, but that's OK. SET_DIAG_MV(/2, <<1, h->left_mb_xy[i>=36], ((i>>2))&3); } } #undef SET_DIAG_MV } if(topright_ref != PART_NOT_AVAILABLE){ *C= h->mv_cache[list][ i - 8 + part_width ]; return topright_ref; }else{ tprintf(s->avctx, "topright MV not available\n"); *C= h->mv_cache[list][ i - 8 - 1 ]; return h->ref_cache[list][ i - 8 - 1 ]; } } /** * gets the predicted MV. * @param n the block index * @param part_width the width of the partition (4, 8,16) -> (1, 2, 4) * @param mx the x component of the predicted motion vector * @param my the y component of the predicted motion vector */ static inline void pred_motion(H264Context * const h, int n, int part_width, int list, int ref, int * const mx, int * const my){ const int index8= scan8[n]; const int top_ref= h->ref_cache[list][ index8 - 8 ]; const int left_ref= h->ref_cache[list][ index8 - 1 ]; const int16_t * const A= h->mv_cache[list][ index8 - 1 ]; const int16_t * const B= h->mv_cache[list][ index8 - 8 ]; const int16_t * C; int diagonal_ref, match_count; assert(part_width==1 || part_width==2 || part_width==4); /* mv_cache B . . A T T T T U . . L . . , . U . . L . . . . U . . L . . , . . . . L . . . . */ diagonal_ref= fetch_diagonal_mv(h, &C, index8, list, part_width); match_count= (diagonal_ref==ref) + (top_ref==ref) + (left_ref==ref); tprintf(h->s.avctx, "pred_motion match_count=%d\n", match_count); if(match_count > 1){ //most common *mx= mid_pred(A[0], B[0], C[0]); *my= mid_pred(A[1], B[1], C[1]); }else if(match_count==1){ if(left_ref==ref){ *mx= A[0]; *my= A[1]; }else if(top_ref==ref){ *mx= B[0]; *my= B[1]; }else{ *mx= C[0]; *my= C[1]; } }else{ if(top_ref == PART_NOT_AVAILABLE && diagonal_ref == PART_NOT_AVAILABLE && left_ref != PART_NOT_AVAILABLE){ *mx= A[0]; *my= A[1]; }else{ *mx= mid_pred(A[0], B[0], C[0]); *my= mid_pred(A[1], B[1], C[1]); } } tprintf(h->s.avctx, "pred_motion (%2d %2d %2d) (%2d %2d %2d) (%2d %2d %2d) -> (%2d %2d %2d) at %2d %2d %d list %d\n", top_ref, B[0], B[1], diagonal_ref, C[0], C[1], left_ref, A[0], A[1], ref, *mx, *my, h->s.mb_x, h->s.mb_y, n, list); } /** * gets the directionally predicted 16x8 MV. * @param n the block index * @param mx the x component of the predicted motion vector * @param my the y component of the predicted motion vector */ static inline void pred_16x8_motion(H264Context * const h, int n, int list, int ref, int * const mx, int * const my){ if(n==0){ const int top_ref= h->ref_cache[list][ scan8[0] - 8 ]; const int16_t * const B= h->mv_cache[list][ scan8[0] - 8 ]; tprintf(h->s.avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n", top_ref, B[0], B[1], h->s.mb_x, h->s.mb_y, n, list); if(top_ref == ref){ *mx= B[0]; *my= B[1]; return; } }else{ const int left_ref= h->ref_cache[list][ scan8[8] - 1 ]; const int16_t * const A= h->mv_cache[list][ scan8[8] - 1 ]; tprintf(h->s.avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n", left_ref, A[0], A[1], h->s.mb_x, h->s.mb_y, n, list); if(left_ref == ref){ *mx= A[0]; *my= A[1]; return; } } //RARE pred_motion(h, n, 4, list, ref, mx, my); } /** * gets the directionally predicted 8x16 MV. * @param n the block index * @param mx the x component of the predicted motion vector * @param my the y component of the predicted motion vector */ static inline void pred_8x16_motion(H264Context * const h, int n, int list, int ref, int * const mx, int * const my){ if(n==0){ const int left_ref= h->ref_cache[list][ scan8[0] - 1 ]; const int16_t * const A= h->mv_cache[list][ scan8[0] - 1 ]; tprintf(h->s.avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n", left_ref, A[0], A[1], h->s.mb_x, h->s.mb_y, n, list); if(left_ref == ref){ *mx= A[0]; *my= A[1]; return; } }else{ const int16_t * C; int diagonal_ref; diagonal_ref= fetch_diagonal_mv(h, &C, scan8[4], list, 2); tprintf(h->s.avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n", diagonal_ref, C[0], C[1], h->s.mb_x, h->s.mb_y, n, list); if(diagonal_ref == ref){ *mx= C[0]; *my= C[1]; return; } } //RARE pred_motion(h, n, 2, list, ref, mx, my); } static inline void pred_pskip_motion(H264Context * const h, int * const mx, int * const my){ const int top_ref = h->ref_cache[0][ scan8[0] - 8 ]; const int left_ref= h->ref_cache[0][ scan8[0] - 1 ]; tprintf(h->s.avctx, "pred_pskip: (%d) (%d) at %2d %2d\n", top_ref, left_ref, h->s.mb_x, h->s.mb_y); if(top_ref == PART_NOT_AVAILABLE || left_ref == PART_NOT_AVAILABLE || !( top_ref | AV_RN32A(h->mv_cache[0][ scan8[0] - 8 ])) || !(left_ref | AV_RN32A(h->mv_cache[0][ scan8[0] - 1 ]))){ *mx = *my = 0; return; } pred_motion(h, 0, 4, 0, 0, mx, my); return; } #endif /* AVCODEC_H264_MVPRED_H */
123linslouis-android-video-cutter
jni/libavcodec/h264_mvpred.h
C
asf20
8,317
/* * AVOptions * Copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * AVOptions * @author Michael Niedermayer <michaelni@gmx.at> */ #include "avcodec.h" #include "opt.h" #include "eval.h" //FIXME order them and do a bin search const AVOption *av_find_opt(void *v, const char *name, const char *unit, int mask, int flags){ AVClass *c= *(AVClass**)v; //FIXME silly way of storing AVClass const AVOption *o= c->option; for(;o && o->name; o++){ if(!strcmp(o->name, name) && (!unit || (o->unit && !strcmp(o->unit, unit))) && (o->flags & mask) == flags ) return o; } return NULL; } const AVOption *av_next_option(void *obj, const AVOption *last){ if(last && last[1].name) return ++last; else if(last) return NULL; 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){ const AVOption *o= av_find_opt(obj, name, NULL, 0, 0); void *dst; if(o_out) *o_out= o; if(!o || o->offset<=0) return AVERROR(ENOENT); 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); return AVERROR(ERANGE); } dst= ((uint8_t*)obj) + o->offset; switch(o->type){ case FF_OPT_TYPE_FLAGS: case FF_OPT_TYPE_INT: *(int *)dst= llrint(num/den)*intnum; break; case FF_OPT_TYPE_INT64: *(int64_t *)dst= llrint(num/den)*intnum; break; case FF_OPT_TYPE_FLOAT: *(float *)dst= num*intnum/den; break; case FF_OPT_TYPE_DOUBLE:*(double *)dst= num*intnum/den; break; case FF_OPT_TYPE_RATIONAL: if((int)num == num) *(AVRational*)dst= (AVRational){num*intnum, den}; else *(AVRational*)dst= av_d2q(num*intnum/den, 1<<24); break; default: return AVERROR(EINVAL); } 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[]={ M_PI, M_E, FF_QP2LAMBDA, 0 }; static const char * const const_names[]={ "PI", "E", "QP2LAMBDA", 0 }; static int hexchar2int(char c) { if (c >= '0' && c <= '9') return c - '0'; if (c >= 'a' && c <= 'f') return c - 'a' + 10; if (c >= 'A' && c <= 'F') return c - 'A' + 10; return -1; } int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out){ int ret; const AVOption *o= av_find_opt(obj, name, NULL, 0, 0); if (o_out) *o_out = o; if(!o) return AVERROR(ENOENT); if(!val || o->offset<=0) return AVERROR(EINVAL); if(o->type == FF_OPT_TYPE_BINARY){ uint8_t **dst = (uint8_t **)(((uint8_t*)obj) + o->offset); 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; } if(o->type != FF_OPT_TYPE_STRING){ int notfirst=0; for(;;){ int i; char buf[256]; int cmd=0; double d; const char *error = NULL; 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; d = ff_parse_and_eval_expr(buf, const_values, const_names, NULL, NULL, NULL, NULL, NULL, &error); if(isnan(d)) { const AVOption *o_named= av_find_opt(obj, buf, o->unit, 0, 0); if(o_named && o_named->type == FF_OPT_TYPE_CONST) d= o_named->default_val; else if(!strcmp(buf, "default")) d= o->default_val; 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 { if (error) av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\": %s\n", val, error); return AVERROR(EINVAL); } } 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; } return AVERROR(EINVAL); } if(alloc){ av_free(*(void**)(((uint8_t*)obj) + o->offset)); val= av_strdup(val); } memcpy(((uint8_t*)obj) + o->offset, &val, sizeof(val)); return 0; } #if LIBAVCODEC_VERSION_MAJOR < 53 const AVOption *av_set_string2(void *obj, const char *name, const char *val, int alloc){ const AVOption *o; if (av_set_string3(obj, name, val, alloc, &o) < 0) return NULL; return o; } const AVOption *av_set_string(void *obj, const char *name, const char *val){ const AVOption *o; if (av_set_string3(obj, name, val, 0, &o) < 0) return NULL; return o; } #endif const AVOption *av_set_double(void *obj, const char *name, double n){ return av_set_number(obj, name, n, 1, 1); } const AVOption *av_set_q(void *obj, const char *name, AVRational n){ return av_set_number(obj, name, n.num, n.den, 1); } const AVOption *av_set_int(void *obj, const char *name, int64_t n){ return av_set_number(obj, name, 1, 1, n); } /** * * @param buf a buffer which is used for returning non string values as strings, can be NULL * @param buf_len allocated length in bytes of buf */ const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len){ const AVOption *o= av_find_opt(obj, name, NULL, 0, 0); void *dst; uint8_t *bin; int len, i; if(!o || o->offset<=0) return NULL; if(o->type != FF_OPT_TYPE_STRING && (!buf || !buf_len)) return NULL; dst= ((uint8_t*)obj) + o->offset; if(o_out) *o_out= o; switch(o->type){ case FF_OPT_TYPE_FLAGS: snprintf(buf, buf_len, "0x%08X",*(int *)dst);break; case FF_OPT_TYPE_INT: snprintf(buf, buf_len, "%d" , *(int *)dst);break; case FF_OPT_TYPE_INT64: snprintf(buf, buf_len, "%"PRId64, *(int64_t*)dst);break; case FF_OPT_TYPE_FLOAT: snprintf(buf, buf_len, "%f" , *(float *)dst);break; case FF_OPT_TYPE_DOUBLE: snprintf(buf, buf_len, "%f" , *(double *)dst);break; case FF_OPT_TYPE_RATIONAL: snprintf(buf, buf_len, "%d/%d", ((AVRational*)dst)->num, ((AVRational*)dst)->den);break; case FF_OPT_TYPE_STRING: return *(void**)dst; case FF_OPT_TYPE_BINARY: len = *(int*)(((uint8_t *)dst) + sizeof(uint8_t *)); if(len >= (buf_len + 1)/2) return NULL; bin = *(uint8_t**)dst; for(i = 0; i < len; i++) snprintf(buf + i*2, 3, "%02X", bin[i]); break; default: return NULL; } return buf; } static int av_get_number(void *obj, const char *name, const AVOption **o_out, double *num, int *den, int64_t *intnum){ const AVOption *o= av_find_opt(obj, name, NULL, 0, 0); void *dst; if(!o || o->offset<=0) goto error; dst= ((uint8_t*)obj) + o->offset; if(o_out) *o_out= o; switch(o->type){ case FF_OPT_TYPE_FLAGS: *intnum= *(unsigned int*)dst;return 0; case FF_OPT_TYPE_INT: *intnum= *(int *)dst;return 0; case FF_OPT_TYPE_INT64: *intnum= *(int64_t*)dst;return 0; case FF_OPT_TYPE_FLOAT: *num= *(float *)dst;return 0; case FF_OPT_TYPE_DOUBLE: *num= *(double *)dst;return 0; case FF_OPT_TYPE_RATIONAL: *intnum= ((AVRational*)dst)->num; *den = ((AVRational*)dst)->den; return 0; } error: *den=*intnum=0; return -1; } double av_get_double(void *obj, const char *name, const AVOption **o_out){ int64_t intnum=1; double num=1; int den=1; av_get_number(obj, name, o_out, &num, &den, &intnum); return num*intnum/den; } AVRational av_get_q(void *obj, const char *name, const AVOption **o_out){ int64_t intnum=1; double num=1; int den=1; av_get_number(obj, name, o_out, &num, &den, &intnum); if(num == 1.0 && (int)intnum == intnum) return (AVRational){intnum, den}; else return av_d2q(num*intnum/den, 1<<24); } int64_t av_get_int(void *obj, const char *name, const AVOption **o_out){ int64_t intnum=1; double num=1; int den=1; av_get_number(obj, name, o_out, &num, &den, &intnum); return num*intnum/den; } static void opt_list(void *obj, void *av_log_obj, const char *unit) { const AVOption *opt=NULL; while((opt= av_next_option(obj, opt))){ if(!(opt->flags & (AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM))) continue; /* Don't print CONST's on level one. * Don't print anything but CONST's on level two. * Only print items from the requested unit. */ if (!unit && opt->type==FF_OPT_TYPE_CONST) continue; else if (unit && opt->type!=FF_OPT_TYPE_CONST) continue; else if (unit && opt->type==FF_OPT_TYPE_CONST && strcmp(unit, opt->unit)) continue; else if (unit && opt->type == FF_OPT_TYPE_CONST) av_log(av_log_obj, AV_LOG_INFO, " %-15s ", opt->name); else av_log(av_log_obj, AV_LOG_INFO, "-%-17s ", opt->name); switch( opt->type ) { case FF_OPT_TYPE_FLAGS: av_log( av_log_obj, AV_LOG_INFO, "%-7s ", "<flags>" ); break; case FF_OPT_TYPE_INT: av_log( av_log_obj, AV_LOG_INFO, "%-7s ", "<int>" ); break; case FF_OPT_TYPE_INT64: av_log( av_log_obj, AV_LOG_INFO, "%-7s ", "<int64>" ); break; case FF_OPT_TYPE_DOUBLE: av_log( av_log_obj, AV_LOG_INFO, "%-7s ", "<double>" ); break; case FF_OPT_TYPE_FLOAT: av_log( av_log_obj, AV_LOG_INFO, "%-7s ", "<float>" ); break; case FF_OPT_TYPE_STRING: av_log( av_log_obj, AV_LOG_INFO, "%-7s ", "<string>" ); break; case FF_OPT_TYPE_RATIONAL: av_log( av_log_obj, AV_LOG_INFO, "%-7s ", "<rational>" ); break; case FF_OPT_TYPE_BINARY: av_log( av_log_obj, AV_LOG_INFO, "%-7s ", "<binary>" ); break; case FF_OPT_TYPE_CONST: default: av_log( av_log_obj, AV_LOG_INFO, "%-7s ", "" ); break; } av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_ENCODING_PARAM) ? 'E' : '.'); av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_DECODING_PARAM) ? 'D' : '.'); av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_VIDEO_PARAM ) ? 'V' : '.'); av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_AUDIO_PARAM ) ? 'A' : '.'); av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_SUBTITLE_PARAM) ? 'S' : '.'); if(opt->help) av_log(av_log_obj, AV_LOG_INFO, " %s", opt->help); av_log(av_log_obj, AV_LOG_INFO, "\n"); if (opt->unit && opt->type != FF_OPT_TYPE_CONST) { opt_list(obj, av_log_obj, opt->unit); } } } int av_opt_show(void *obj, void *av_log_obj){ if(!obj) return -1; av_log(av_log_obj, AV_LOG_INFO, "%s AVOptions:\n", (*(AVClass**)obj)->class_name); opt_list(obj, av_log_obj, NULL); return 0; } /** Set the values of the AVCodecContext or AVFormatContext structure. * They are set to the defaults specified in the according AVOption options * array default_val field. * * @param s AVCodecContext or AVFormatContext for which the defaults will be set */ void av_opt_set_defaults2(void *s, int mask, int flags) { const AVOption *opt = NULL; while ((opt = av_next_option(s, opt)) != NULL) { if((opt->flags & mask) != flags) continue; switch(opt->type) { case FF_OPT_TYPE_CONST: /* Nothing to be done here */ break; case FF_OPT_TYPE_FLAGS: case FF_OPT_TYPE_INT: { int val; val = opt->default_val; av_set_int(s, opt->name, val); } break; case FF_OPT_TYPE_INT64: if((double)(opt->default_val+0.6) == opt->default_val) av_log(s, AV_LOG_DEBUG, "loss of precision in default of %s\n", opt->name); av_set_int(s, opt->name, opt->default_val); break; case FF_OPT_TYPE_FLOAT: { double val; val = opt->default_val; av_set_double(s, opt->name, val); } break; case FF_OPT_TYPE_RATIONAL: { AVRational val; val = av_d2q(opt->default_val, INT_MAX); av_set_q(s, opt->name, val); } break; case FF_OPT_TYPE_STRING: case FF_OPT_TYPE_BINARY: /* Cannot set default for string as default_val is of type * double */ break; default: av_log(s, AV_LOG_DEBUG, "AVOption type %d of option %s not implemented yet\n", opt->type, opt->name); } } } void av_opt_set_defaults(void *s){ av_opt_set_defaults2(s, 0, 0); }
123linslouis-android-video-cutter
jni/libavcodec/opt.c
C
asf20
15,491
/* * Header file for hardcoded PCM tables * * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PCM_TABLEGEN_H #define PCM_TABLEGEN_H #include <stdint.h> #include "../libavutil/attributes.h" /* from g711.c by SUN microsystems (unrestricted use) */ #define SIGN_BIT (0x80) /* Sign bit for a A-law byte. */ #define QUANT_MASK (0xf) /* Quantization field mask. */ #define NSEGS (8) /* Number of A-law segments. */ #define SEG_SHIFT (4) /* Left shift for segment number. */ #define SEG_MASK (0x70) /* Segment field mask. */ #define BIAS (0x84) /* Bias for linear code. */ /* * alaw2linear() - Convert an A-law value to 16-bit linear PCM * */ static av_cold int alaw2linear(unsigned char a_val) { int t; int seg; a_val ^= 0x55; t = a_val & QUANT_MASK; seg = ((unsigned)a_val & SEG_MASK) >> SEG_SHIFT; if(seg) t= (t + t + 1 + 32) << (seg + 2); else t= (t + t + 1 ) << 3; return (a_val & SIGN_BIT) ? t : -t; } static av_cold int ulaw2linear(unsigned char u_val) { int t; /* Complement to obtain normal u-law value. */ u_val = ~u_val; /* * Extract and bias the quantization bits. Then * shift up by the segment number and subtract out the bias. */ t = ((u_val & QUANT_MASK) << 3) + BIAS; t <<= ((unsigned)u_val & SEG_MASK) >> SEG_SHIFT; return (u_val & SIGN_BIT) ? (BIAS - t) : (t - BIAS); } #if CONFIG_HARDCODED_TABLES #define pcm_alaw_tableinit() #define pcm_ulaw_tableinit() #include "libavcodec/pcm_tables.h" #else /* 16384 entries per table */ static uint8_t linear_to_alaw[16384]; static uint8_t linear_to_ulaw[16384]; static av_cold void build_xlaw_table(uint8_t *linear_to_xlaw, int (*xlaw2linear)(unsigned char), int mask) { int i, j, v, v1, v2; j = 0; for(i=0;i<128;i++) { if (i != 127) { v1 = xlaw2linear(i ^ mask); v2 = xlaw2linear((i + 1) ^ mask); v = (v1 + v2 + 4) >> 3; } else { v = 8192; } for(;j<v;j++) { linear_to_xlaw[8192 + j] = (i ^ mask); if (j > 0) linear_to_xlaw[8192 - j] = (i ^ (mask ^ 0x80)); } } linear_to_xlaw[0] = linear_to_xlaw[1]; } static void pcm_alaw_tableinit(void) { build_xlaw_table(linear_to_alaw, alaw2linear, 0xd5); } static void pcm_ulaw_tableinit(void) { build_xlaw_table(linear_to_ulaw, ulaw2linear, 0xff); } #endif /* CONFIG_HARDCODED_TABLES */ #endif /* PCM_TABLEGEN_H */
123linslouis-android-video-cutter
jni/libavcodec/pcm_tablegen.h
C
asf20
3,519
/** * @file * Vorbis I decoder * @author Denes Balatoni ( dbalatoni programozo hu ) * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #undef V_DEBUG //#define V_DEBUG //#define AV_DEBUG(...) av_log(NULL, AV_LOG_INFO, __VA_ARGS__) #include <math.h> #define ALT_BITSTREAM_READER_LE #include "avcodec.h" #include "get_bits.h" #include "dsputil.h" #include "fft.h" #include "vorbis.h" #include "xiph.h" #define V_NB_BITS 8 #define V_NB_BITS2 11 #define V_MAX_VLCS (1 << 16) #define V_MAX_PARTITIONS (1 << 20) #ifndef V_DEBUG #define AV_DEBUG(...) #endif #undef NDEBUG #include <assert.h> typedef struct { uint_fast8_t dimensions; uint_fast8_t lookup_type; uint_fast8_t maxdepth; VLC vlc; float *codevectors; unsigned int nb_bits; } vorbis_codebook; typedef union vorbis_floor_u vorbis_floor_data; typedef struct vorbis_floor0_s vorbis_floor0; typedef struct vorbis_floor1_s vorbis_floor1; struct vorbis_context_s; typedef uint_fast8_t (* vorbis_floor_decode_func) (struct vorbis_context_s *, vorbis_floor_data *, float *); typedef struct { uint_fast8_t floor_type; vorbis_floor_decode_func decode; union vorbis_floor_u { struct vorbis_floor0_s { uint_fast8_t order; uint_fast16_t rate; uint_fast16_t bark_map_size; int_fast32_t *map[2]; uint_fast32_t map_size[2]; uint_fast8_t amplitude_bits; uint_fast8_t amplitude_offset; uint_fast8_t num_books; uint_fast8_t *book_list; float *lsp; } t0; struct vorbis_floor1_s { uint_fast8_t partitions; uint_fast8_t maximum_class; uint_fast8_t partition_class[32]; uint_fast8_t class_dimensions[16]; uint_fast8_t class_subclasses[16]; uint_fast8_t class_masterbook[16]; int_fast16_t subclass_books[16][8]; uint_fast8_t multiplier; uint_fast16_t x_list_dim; vorbis_floor1_entry *list; } t1; } data; } vorbis_floor; typedef struct { uint_fast16_t type; uint_fast32_t begin; uint_fast32_t end; uint_fast32_t partition_size; uint_fast8_t classifications; uint_fast8_t classbook; int_fast16_t books[64][8]; uint_fast8_t maxpass; } vorbis_residue; typedef struct { uint_fast8_t submaps; uint_fast16_t coupling_steps; uint_fast8_t *magnitude; uint_fast8_t *angle; uint_fast8_t *mux; uint_fast8_t submap_floor[16]; uint_fast8_t submap_residue[16]; } vorbis_mapping; typedef struct { uint_fast8_t blockflag; uint_fast16_t windowtype; uint_fast16_t transformtype; uint_fast8_t mapping; } vorbis_mode; typedef struct vorbis_context_s { AVCodecContext *avccontext; GetBitContext gb; DSPContext dsp; FFTContext mdct[2]; uint_fast8_t first_frame; uint_fast32_t version; uint_fast8_t audio_channels; uint_fast32_t audio_samplerate; uint_fast32_t bitrate_maximum; uint_fast32_t bitrate_nominal; uint_fast32_t bitrate_minimum; uint_fast32_t blocksize[2]; const float *win[2]; uint_fast16_t codebook_count; vorbis_codebook *codebooks; uint_fast8_t floor_count; vorbis_floor *floors; uint_fast8_t residue_count; vorbis_residue *residues; uint_fast8_t mapping_count; vorbis_mapping *mappings; uint_fast8_t mode_count; vorbis_mode *modes; uint_fast8_t mode_number; // mode number for the current packet uint_fast8_t previous_window; float *channel_residues; float *channel_floors; float *saved; uint_fast32_t add_bias; // for float->int conversion uint_fast32_t exp_bias; } vorbis_context; /* Helper functions */ #define BARK(x) \ (13.1f * atan(0.00074f * (x)) + 2.24f * atan(1.85e-8f * (x) * (x)) + 1e-4f * (x)) static const char idx_err_str[] = "Index value %d out of range (0 - %d) for %s at %s:%i\n"; #define VALIDATE_INDEX(idx, limit) \ if (idx >= limit) {\ av_log(vc->avccontext, AV_LOG_ERROR,\ idx_err_str,\ (int)(idx), (int)(limit - 1), #idx, __FILE__, __LINE__);\ return -1;\ } #define GET_VALIDATED_INDEX(idx, bits, limit) \ {\ idx = get_bits(gb, bits);\ VALIDATE_INDEX(idx, limit)\ } static float vorbisfloat2float(uint_fast32_t val) { double mant = val & 0x1fffff; long exp = (val & 0x7fe00000L) >> 21; if (val & 0x80000000) mant = -mant; return ldexp(mant, exp - 20 - 768); } // Free all allocated memory ----------------------------------------- static void vorbis_free(vorbis_context *vc) { int_fast16_t i; av_freep(&vc->channel_residues); av_freep(&vc->channel_floors); av_freep(&vc->saved); av_freep(&vc->residues); av_freep(&vc->modes); ff_mdct_end(&vc->mdct[0]); ff_mdct_end(&vc->mdct[1]); for (i = 0; i < vc->codebook_count; ++i) { av_free(vc->codebooks[i].codevectors); free_vlc(&vc->codebooks[i].vlc); } av_freep(&vc->codebooks); for (i = 0; i < vc->floor_count; ++i) { if (vc->floors[i].floor_type == 0) { av_free(vc->floors[i].data.t0.map[0]); av_free(vc->floors[i].data.t0.map[1]); av_free(vc->floors[i].data.t0.book_list); av_free(vc->floors[i].data.t0.lsp); } else { av_free(vc->floors[i].data.t1.list); } } av_freep(&vc->floors); for (i = 0; i < vc->mapping_count; ++i) { av_free(vc->mappings[i].magnitude); av_free(vc->mappings[i].angle); av_free(vc->mappings[i].mux); } av_freep(&vc->mappings); } // Parse setup header ------------------------------------------------- // Process codebooks part static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc) { uint_fast16_t cb; uint8_t *tmp_vlc_bits; uint32_t *tmp_vlc_codes; GetBitContext *gb = &vc->gb; vc->codebook_count = get_bits(gb, 8) + 1; AV_DEBUG(" Codebooks: %d \n", vc->codebook_count); vc->codebooks = av_mallocz(vc->codebook_count * sizeof(vorbis_codebook)); tmp_vlc_bits = av_mallocz(V_MAX_VLCS * sizeof(uint8_t)); tmp_vlc_codes = av_mallocz(V_MAX_VLCS * sizeof(uint32_t)); for (cb = 0; cb < vc->codebook_count; ++cb) { vorbis_codebook *codebook_setup = &vc->codebooks[cb]; uint_fast8_t ordered; uint_fast32_t t, used_entries = 0; uint_fast32_t entries; AV_DEBUG(" %d. Codebook \n", cb); if (get_bits(gb, 24) != 0x564342) { av_log(vc->avccontext, AV_LOG_ERROR, " %"PRIdFAST16". Codebook setup data corrupt. \n", cb); goto error; } codebook_setup->dimensions=get_bits(gb, 16); if (codebook_setup->dimensions > 16 || codebook_setup->dimensions == 0) { av_log(vc->avccontext, AV_LOG_ERROR, " %"PRIdFAST16". Codebook's dimension is invalid (%d). \n", cb, codebook_setup->dimensions); goto error; } entries = get_bits(gb, 24); if (entries > V_MAX_VLCS) { av_log(vc->avccontext, AV_LOG_ERROR, " %"PRIdFAST16". Codebook has too many entries (%"PRIdFAST32"). \n", cb, entries); goto error; } ordered = get_bits1(gb); AV_DEBUG(" codebook_dimensions %d, codebook_entries %d \n", codebook_setup->dimensions, entries); if (!ordered) { uint_fast16_t ce; uint_fast8_t flag; uint_fast8_t sparse = get_bits1(gb); AV_DEBUG(" not ordered \n"); if (sparse) { AV_DEBUG(" sparse \n"); used_entries = 0; for (ce = 0; ce < entries; ++ce) { flag = get_bits1(gb); if (flag) { tmp_vlc_bits[ce] = get_bits(gb, 5) + 1; ++used_entries; } else tmp_vlc_bits[ce] = 0; } } else { AV_DEBUG(" not sparse \n"); used_entries = entries; for (ce = 0; ce < entries; ++ce) tmp_vlc_bits[ce] = get_bits(gb, 5) + 1; } } else { uint_fast16_t current_entry = 0; uint_fast8_t current_length = get_bits(gb, 5)+1; AV_DEBUG(" ordered, current length: %d \n", current_length); //FIXME used_entries = entries; for (; current_entry < used_entries && current_length <= 32; ++current_length) { uint_fast16_t i, number; AV_DEBUG(" number bits: %d ", ilog(entries - current_entry)); number = get_bits(gb, ilog(entries - current_entry)); AV_DEBUG(" number: %d \n", number); for (i = current_entry; i < number+current_entry; ++i) if (i < used_entries) tmp_vlc_bits[i] = current_length; current_entry+=number; } if (current_entry>used_entries) { av_log(vc->avccontext, AV_LOG_ERROR, " More codelengths than codes in codebook. \n"); goto error; } } codebook_setup->lookup_type = get_bits(gb, 4); AV_DEBUG(" lookup type: %d : %s \n", codebook_setup->lookup_type, codebook_setup->lookup_type ? "vq" : "no lookup"); // If the codebook is used for (inverse) VQ, calculate codevectors. if (codebook_setup->lookup_type == 1) { uint_fast16_t i, j, k; uint_fast16_t codebook_lookup_values = ff_vorbis_nth_root(entries, codebook_setup->dimensions); uint_fast16_t codebook_multiplicands[codebook_lookup_values]; float codebook_minimum_value = vorbisfloat2float(get_bits_long(gb, 32)); float codebook_delta_value = vorbisfloat2float(get_bits_long(gb, 32)); uint_fast8_t codebook_value_bits = get_bits(gb, 4)+1; uint_fast8_t codebook_sequence_p = get_bits1(gb); AV_DEBUG(" We expect %d numbers for building the codevectors. \n", codebook_lookup_values); AV_DEBUG(" delta %f minmum %f \n", codebook_delta_value, codebook_minimum_value); for (i = 0; i < codebook_lookup_values; ++i) { codebook_multiplicands[i] = get_bits(gb, codebook_value_bits); AV_DEBUG(" multiplicands*delta+minmum : %e \n", (float)codebook_multiplicands[i]*codebook_delta_value+codebook_minimum_value); AV_DEBUG(" multiplicand %d \n", codebook_multiplicands[i]); } // Weed out unused vlcs and build codevector vector codebook_setup->codevectors = used_entries ? av_mallocz(used_entries*codebook_setup->dimensions * sizeof(float)) : NULL; for (j = 0, i = 0; i < entries; ++i) { uint_fast8_t dim = codebook_setup->dimensions; if (tmp_vlc_bits[i]) { float last = 0.0; uint_fast32_t lookup_offset = i; #ifdef V_DEBUG av_log(vc->avccontext, AV_LOG_INFO, "Lookup offset %d ,", i); #endif for (k = 0; k < dim; ++k) { uint_fast32_t multiplicand_offset = lookup_offset % codebook_lookup_values; codebook_setup->codevectors[j * dim + k] = codebook_multiplicands[multiplicand_offset] * codebook_delta_value + codebook_minimum_value + last; if (codebook_sequence_p) last = codebook_setup->codevectors[j * dim + k]; lookup_offset/=codebook_lookup_values; } tmp_vlc_bits[j] = tmp_vlc_bits[i]; #ifdef V_DEBUG av_log(vc->avccontext, AV_LOG_INFO, "real lookup offset %d, vector: ", j); for (k = 0; k < dim; ++k) av_log(vc->avccontext, AV_LOG_INFO, " %f ", codebook_setup->codevectors[j * dim + k]); av_log(vc->avccontext, AV_LOG_INFO, "\n"); #endif ++j; } } if (j != used_entries) { av_log(vc->avccontext, AV_LOG_ERROR, "Bug in codevector vector building code. \n"); goto error; } entries = used_entries; } else if (codebook_setup->lookup_type >= 2) { av_log(vc->avccontext, AV_LOG_ERROR, "Codebook lookup type not supported. \n"); goto error; } // Initialize VLC table if (ff_vorbis_len2vlc(tmp_vlc_bits, tmp_vlc_codes, entries)) { av_log(vc->avccontext, AV_LOG_ERROR, " Invalid code lengths while generating vlcs. \n"); goto error; } codebook_setup->maxdepth = 0; for (t = 0; t < entries; ++t) if (tmp_vlc_bits[t] >= codebook_setup->maxdepth) codebook_setup->maxdepth = tmp_vlc_bits[t]; if (codebook_setup->maxdepth > 3 * V_NB_BITS) codebook_setup->nb_bits = V_NB_BITS2; else codebook_setup->nb_bits = V_NB_BITS; codebook_setup->maxdepth = (codebook_setup->maxdepth+codebook_setup->nb_bits - 1) / codebook_setup->nb_bits; if (init_vlc(&codebook_setup->vlc, codebook_setup->nb_bits, entries, tmp_vlc_bits, sizeof(*tmp_vlc_bits), sizeof(*tmp_vlc_bits), tmp_vlc_codes, sizeof(*tmp_vlc_codes), sizeof(*tmp_vlc_codes), INIT_VLC_LE)) { av_log(vc->avccontext, AV_LOG_ERROR, " Error generating vlc tables. \n"); goto error; } } av_free(tmp_vlc_bits); av_free(tmp_vlc_codes); return 0; // Error: error: av_free(tmp_vlc_bits); av_free(tmp_vlc_codes); return -1; } // Process time domain transforms part (unused in Vorbis I) static int vorbis_parse_setup_hdr_tdtransforms(vorbis_context *vc) { GetBitContext *gb = &vc->gb; uint_fast8_t i; uint_fast8_t vorbis_time_count = get_bits(gb, 6) + 1; for (i = 0; i < vorbis_time_count; ++i) { uint_fast16_t vorbis_tdtransform = get_bits(gb, 16); AV_DEBUG(" Vorbis time domain transform %d: %d \n", vorbis_time_count, vorbis_tdtransform); if (vorbis_tdtransform) { av_log(vc->avccontext, AV_LOG_ERROR, "Vorbis time domain transform data nonzero. \n"); return -1; } } return 0; } // Process floors part static uint_fast8_t vorbis_floor0_decode(vorbis_context *vc, vorbis_floor_data *vfu, float *vec); static void create_map(vorbis_context *vc, uint_fast8_t floor_number); static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc, vorbis_floor_data *vfu, float *vec); static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) { GetBitContext *gb = &vc->gb; uint_fast16_t i,j,k; vc->floor_count = get_bits(gb, 6) + 1; vc->floors = av_mallocz(vc->floor_count * sizeof(vorbis_floor)); for (i = 0; i < vc->floor_count; ++i) { vorbis_floor *floor_setup = &vc->floors[i]; floor_setup->floor_type = get_bits(gb, 16); AV_DEBUG(" %d. floor type %d \n", i, floor_setup->floor_type); if (floor_setup->floor_type == 1) { uint_fast8_t maximum_class = 0; uint_fast8_t rangebits; uint_fast16_t floor1_values = 2; floor_setup->decode = vorbis_floor1_decode; floor_setup->data.t1.partitions = get_bits(gb, 5); AV_DEBUG(" %d.floor: %d partitions \n", i, floor_setup->data.t1.partitions); for (j = 0; j < floor_setup->data.t1.partitions; ++j) { floor_setup->data.t1.partition_class[j] = get_bits(gb, 4); if (floor_setup->data.t1.partition_class[j] > maximum_class) maximum_class = floor_setup->data.t1.partition_class[j]; AV_DEBUG(" %d. floor %d partition class %d \n", i, j, floor_setup->data.t1.partition_class[j]); } AV_DEBUG(" maximum class %d \n", maximum_class); floor_setup->data.t1.maximum_class = maximum_class; for (j = 0; j <= maximum_class; ++j) { floor_setup->data.t1.class_dimensions[j] = get_bits(gb, 3) + 1; floor_setup->data.t1.class_subclasses[j] = get_bits(gb, 2); AV_DEBUG(" %d floor %d class dim: %d subclasses %d \n", i, j, floor_setup->data.t1.class_dimensions[j], floor_setup->data.t1.class_subclasses[j]); if (floor_setup->data.t1.class_subclasses[j]) { GET_VALIDATED_INDEX(floor_setup->data.t1.class_masterbook[j], 8, vc->codebook_count) AV_DEBUG(" masterbook: %d \n", floor_setup->data.t1.class_masterbook[j]); } for (k = 0; k < (1 << floor_setup->data.t1.class_subclasses[j]); ++k) { int16_t bits = get_bits(gb, 8) - 1; if (bits != -1) VALIDATE_INDEX(bits, vc->codebook_count) floor_setup->data.t1.subclass_books[j][k] = bits; AV_DEBUG(" book %d. : %d \n", k, floor_setup->data.t1.subclass_books[j][k]); } } floor_setup->data.t1.multiplier = get_bits(gb, 2) + 1; floor_setup->data.t1.x_list_dim = 2; for (j = 0; j < floor_setup->data.t1.partitions; ++j) floor_setup->data.t1.x_list_dim+=floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]]; floor_setup->data.t1.list = av_mallocz(floor_setup->data.t1.x_list_dim * sizeof(vorbis_floor1_entry)); rangebits = get_bits(gb, 4); floor_setup->data.t1.list[0].x = 0; floor_setup->data.t1.list[1].x = (1 << rangebits); for (j = 0; j < floor_setup->data.t1.partitions; ++j) { for (k = 0; k < floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]]; ++k, ++floor1_values) { floor_setup->data.t1.list[floor1_values].x = get_bits(gb, rangebits); AV_DEBUG(" %d. floor1 Y coord. %d \n", floor1_values, floor_setup->data.t1.list[floor1_values].x); } } // Precalculate order of x coordinates - needed for decode ff_vorbis_ready_floor1_list(floor_setup->data.t1.list, floor_setup->data.t1.x_list_dim); } else if (floor_setup->floor_type == 0) { uint_fast8_t max_codebook_dim = 0; floor_setup->decode = vorbis_floor0_decode; floor_setup->data.t0.order = get_bits(gb, 8); floor_setup->data.t0.rate = get_bits(gb, 16); floor_setup->data.t0.bark_map_size = get_bits(gb, 16); floor_setup->data.t0.amplitude_bits = get_bits(gb, 6); /* zero would result in a div by zero later * * 2^0 - 1 == 0 */ if (floor_setup->data.t0.amplitude_bits == 0) { av_log(vc->avccontext, AV_LOG_ERROR, "Floor 0 amplitude bits is 0.\n"); return -1; } floor_setup->data.t0.amplitude_offset = get_bits(gb, 8); floor_setup->data.t0.num_books = get_bits(gb, 4) + 1; /* allocate mem for booklist */ floor_setup->data.t0.book_list = av_malloc(floor_setup->data.t0.num_books); if (!floor_setup->data.t0.book_list) return -1; /* read book indexes */ { int idx; uint_fast8_t book_idx; for (idx = 0; idx < floor_setup->data.t0.num_books; ++idx) { GET_VALIDATED_INDEX(floor_setup->data.t0.book_list[idx], 8, vc->codebook_count) if (vc->codebooks[book_idx].dimensions > max_codebook_dim) max_codebook_dim = vc->codebooks[book_idx].dimensions; } } create_map(vc, i); /* allocate mem for lsp coefficients */ { /* codebook dim is for padding if codebook dim doesn't * * divide order+1 then we need to read more data */ floor_setup->data.t0.lsp = av_malloc((floor_setup->data.t0.order+1 + max_codebook_dim) * sizeof(float)); if (!floor_setup->data.t0.lsp) return -1; } #ifdef V_DEBUG /* debug output parsed headers */ AV_DEBUG("floor0 order: %u\n", floor_setup->data.t0.order); AV_DEBUG("floor0 rate: %u\n", floor_setup->data.t0.rate); AV_DEBUG("floor0 bark map size: %u\n", floor_setup->data.t0.bark_map_size); AV_DEBUG("floor0 amplitude bits: %u\n", floor_setup->data.t0.amplitude_bits); AV_DEBUG("floor0 amplitude offset: %u\n", floor_setup->data.t0.amplitude_offset); AV_DEBUG("floor0 number of books: %u\n", floor_setup->data.t0.num_books); AV_DEBUG("floor0 book list pointer: %p\n", floor_setup->data.t0.book_list); { int idx; for (idx = 0; idx < floor_setup->data.t0.num_books; ++idx) { AV_DEBUG(" Book %d: %u\n", idx+1, floor_setup->data.t0.book_list[idx]); } } #endif } else { av_log(vc->avccontext, AV_LOG_ERROR, "Invalid floor type!\n"); return -1; } } return 0; } // Process residues part static int vorbis_parse_setup_hdr_residues(vorbis_context *vc) { GetBitContext *gb = &vc->gb; uint_fast8_t i, j, k; vc->residue_count = get_bits(gb, 6)+1; vc->residues = av_mallocz(vc->residue_count * sizeof(vorbis_residue)); AV_DEBUG(" There are %d residues. \n", vc->residue_count); for (i = 0; i < vc->residue_count; ++i) { vorbis_residue *res_setup = &vc->residues[i]; uint_fast8_t cascade[64]; uint_fast8_t high_bits; uint_fast8_t low_bits; res_setup->type = get_bits(gb, 16); AV_DEBUG(" %d. residue type %d \n", i, res_setup->type); res_setup->begin = get_bits(gb, 24); res_setup->end = get_bits(gb, 24); res_setup->partition_size = get_bits(gb, 24) + 1; /* Validations to prevent a buffer overflow later. */ if (res_setup->begin>res_setup->end || res_setup->end>vc->blocksize[1] / (res_setup->type == 2 ? 1 : 2) || (res_setup->end-res_setup->begin) / res_setup->partition_size > V_MAX_PARTITIONS) { av_log(vc->avccontext, AV_LOG_ERROR, "partition out of bounds: type, begin, end, size, blocksize: %"PRIdFAST16", %"PRIdFAST32", %"PRIdFAST32", %"PRIdFAST32", %"PRIdFAST32"\n", res_setup->type, res_setup->begin, res_setup->end, res_setup->partition_size, vc->blocksize[1] / 2); return -1; } res_setup->classifications = get_bits(gb, 6) + 1; GET_VALIDATED_INDEX(res_setup->classbook, 8, vc->codebook_count) AV_DEBUG(" begin %d end %d part.size %d classif.s %d classbook %d \n", res_setup->begin, res_setup->end, res_setup->partition_size, res_setup->classifications, res_setup->classbook); for (j = 0; j < res_setup->classifications; ++j) { high_bits = 0; low_bits = get_bits(gb, 3); if (get_bits1(gb)) high_bits = get_bits(gb, 5); cascade[j] = (high_bits << 3) + low_bits; AV_DEBUG(" %d class casscade depth: %d \n", j, ilog(cascade[j])); } res_setup->maxpass = 0; for (j = 0; j < res_setup->classifications; ++j) { for (k = 0; k < 8; ++k) { if (cascade[j]&(1 << k)) { GET_VALIDATED_INDEX(res_setup->books[j][k], 8, vc->codebook_count) AV_DEBUG(" %d class casscade depth %d book: %d \n", j, k, res_setup->books[j][k]); if (k>res_setup->maxpass) res_setup->maxpass = k; } else { res_setup->books[j][k] = -1; } } } } return 0; } // Process mappings part static int vorbis_parse_setup_hdr_mappings(vorbis_context *vc) { GetBitContext *gb = &vc->gb; uint_fast8_t i, j; vc->mapping_count = get_bits(gb, 6)+1; vc->mappings = av_mallocz(vc->mapping_count * sizeof(vorbis_mapping)); AV_DEBUG(" There are %d mappings. \n", vc->mapping_count); for (i = 0; i < vc->mapping_count; ++i) { vorbis_mapping *mapping_setup = &vc->mappings[i]; if (get_bits(gb, 16)) { av_log(vc->avccontext, AV_LOG_ERROR, "Other mappings than type 0 are not compliant with the Vorbis I specification. \n"); return -1; } if (get_bits1(gb)) { mapping_setup->submaps = get_bits(gb, 4) + 1; } else { mapping_setup->submaps = 1; } if (get_bits1(gb)) { mapping_setup->coupling_steps = get_bits(gb, 8) + 1; mapping_setup->magnitude = av_mallocz(mapping_setup->coupling_steps * sizeof(uint_fast8_t)); mapping_setup->angle = av_mallocz(mapping_setup->coupling_steps * sizeof(uint_fast8_t)); for (j = 0; j < mapping_setup->coupling_steps; ++j) { GET_VALIDATED_INDEX(mapping_setup->magnitude[j], ilog(vc->audio_channels - 1), vc->audio_channels) GET_VALIDATED_INDEX(mapping_setup->angle[j], ilog(vc->audio_channels - 1), vc->audio_channels) } } else { mapping_setup->coupling_steps = 0; } AV_DEBUG(" %d mapping coupling steps: %d \n", i, mapping_setup->coupling_steps); if (get_bits(gb, 2)) { av_log(vc->avccontext, AV_LOG_ERROR, "%d. mapping setup data invalid. \n", i); return -1; // following spec. } if (mapping_setup->submaps>1) { mapping_setup->mux = av_mallocz(vc->audio_channels * sizeof(uint_fast8_t)); for (j = 0; j < vc->audio_channels; ++j) mapping_setup->mux[j] = get_bits(gb, 4); } for (j = 0; j < mapping_setup->submaps; ++j) { skip_bits(gb, 8); // FIXME check? GET_VALIDATED_INDEX(mapping_setup->submap_floor[j], 8, vc->floor_count) GET_VALIDATED_INDEX(mapping_setup->submap_residue[j], 8, vc->residue_count) AV_DEBUG(" %d mapping %d submap : floor %d, residue %d \n", i, j, mapping_setup->submap_floor[j], mapping_setup->submap_residue[j]); } } return 0; } // Process modes part static void create_map(vorbis_context *vc, uint_fast8_t floor_number) { vorbis_floor *floors = vc->floors; vorbis_floor0 *vf; int idx; int_fast8_t blockflag; int_fast32_t *map; int_fast32_t n; //TODO: could theoretically be smaller? for (blockflag = 0; blockflag < 2; ++blockflag) { n = vc->blocksize[blockflag] / 2; floors[floor_number].data.t0.map[blockflag] = av_malloc((n+1) * sizeof(int_fast32_t)); // n + sentinel map = floors[floor_number].data.t0.map[blockflag]; vf = &floors[floor_number].data.t0; for (idx = 0; idx < n; ++idx) { map[idx] = floor(BARK((vf->rate * idx) / (2.0f * n)) * ((vf->bark_map_size) / BARK(vf->rate / 2.0f))); if (vf->bark_map_size-1 < map[idx]) map[idx] = vf->bark_map_size - 1; } map[n] = -1; vf->map_size[blockflag] = n; } # ifdef V_DEBUG for (idx = 0; idx <= n; ++idx) { AV_DEBUG("floor0 map: map at pos %d is %d\n", idx, map[idx]); } # endif } static int vorbis_parse_setup_hdr_modes(vorbis_context *vc) { GetBitContext *gb = &vc->gb; uint_fast8_t i; vc->mode_count = get_bits(gb, 6) + 1; vc->modes = av_mallocz(vc->mode_count * sizeof(vorbis_mode)); AV_DEBUG(" There are %d modes.\n", vc->mode_count); for (i = 0; i < vc->mode_count; ++i) { vorbis_mode *mode_setup = &vc->modes[i]; mode_setup->blockflag = get_bits1(gb); mode_setup->windowtype = get_bits(gb, 16); //FIXME check mode_setup->transformtype = get_bits(gb, 16); //FIXME check GET_VALIDATED_INDEX(mode_setup->mapping, 8, vc->mapping_count); AV_DEBUG(" %d mode: blockflag %d, windowtype %d, transformtype %d, mapping %d \n", i, mode_setup->blockflag, mode_setup->windowtype, mode_setup->transformtype, mode_setup->mapping); } return 0; } // Process the whole setup header using the functions above static int vorbis_parse_setup_hdr(vorbis_context *vc) { GetBitContext *gb = &vc->gb; if ((get_bits(gb, 8) != 'v') || (get_bits(gb, 8) != 'o') || (get_bits(gb, 8) != 'r') || (get_bits(gb, 8) != 'b') || (get_bits(gb, 8) != 'i') || (get_bits(gb, 8) != 's')) { av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis setup header packet corrupt (no vorbis signature). \n"); return -1; } if (vorbis_parse_setup_hdr_codebooks(vc)) { av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis setup header packet corrupt (codebooks). \n"); return -2; } if (vorbis_parse_setup_hdr_tdtransforms(vc)) { av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis setup header packet corrupt (time domain transforms). \n"); return -3; } if (vorbis_parse_setup_hdr_floors(vc)) { av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis setup header packet corrupt (floors). \n"); return -4; } if (vorbis_parse_setup_hdr_residues(vc)) { av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis setup header packet corrupt (residues). \n"); return -5; } if (vorbis_parse_setup_hdr_mappings(vc)) { av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis setup header packet corrupt (mappings). \n"); return -6; } if (vorbis_parse_setup_hdr_modes(vc)) { av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis setup header packet corrupt (modes). \n"); return -7; } if (!get_bits1(gb)) { av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis setup header packet corrupt (framing flag). \n"); return -8; // framing flag bit unset error } return 0; } // Process the identification header static int vorbis_parse_id_hdr(vorbis_context *vc) { GetBitContext *gb = &vc->gb; uint_fast8_t bl0, bl1; if ((get_bits(gb, 8) != 'v') || (get_bits(gb, 8) != 'o') || (get_bits(gb, 8) != 'r') || (get_bits(gb, 8) != 'b') || (get_bits(gb, 8) != 'i') || (get_bits(gb, 8) != 's')) { av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis id header packet corrupt (no vorbis signature). \n"); return -1; } vc->version = get_bits_long(gb, 32); //FIXME check 0 vc->audio_channels = get_bits(gb, 8); if (vc->audio_channels <= 0) { av_log(vc->avccontext, AV_LOG_ERROR, "Invalid number of channels\n"); return -1; } vc->audio_samplerate = get_bits_long(gb, 32); if (vc->audio_samplerate <= 0) { av_log(vc->avccontext, AV_LOG_ERROR, "Invalid samplerate\n"); return -1; } vc->bitrate_maximum = get_bits_long(gb, 32); vc->bitrate_nominal = get_bits_long(gb, 32); vc->bitrate_minimum = get_bits_long(gb, 32); bl0 = get_bits(gb, 4); bl1 = get_bits(gb, 4); vc->blocksize[0] = (1 << bl0); vc->blocksize[1] = (1 << bl1); if (bl0 > 13 || bl0 < 6 || bl1 > 13 || bl1 < 6 || bl1 < bl0) { av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis id header packet corrupt (illegal blocksize). \n"); return -3; } // output format int16 if (vc->blocksize[1] / 2 * vc->audio_channels * 2 > AVCODEC_MAX_AUDIO_FRAME_SIZE) { av_log(vc->avccontext, AV_LOG_ERROR, "Vorbis channel count makes " "output packets too large.\n"); return -4; } vc->win[0] = ff_vorbis_vwin[bl0 - 6]; vc->win[1] = ff_vorbis_vwin[bl1 - 6]; if ((get_bits1(gb)) == 0) { av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis id header packet corrupt (framing flag not set). \n"); return -2; } vc->channel_residues = av_malloc((vc->blocksize[1] / 2) * vc->audio_channels * sizeof(float)); vc->channel_floors = av_malloc((vc->blocksize[1] / 2) * vc->audio_channels * sizeof(float)); vc->saved = av_mallocz((vc->blocksize[1] / 4) * vc->audio_channels * sizeof(float)); vc->previous_window = 0; ff_mdct_init(&vc->mdct[0], bl0, 1, vc->exp_bias ? -(1 << 15) : -1.0); ff_mdct_init(&vc->mdct[1], bl1, 1, vc->exp_bias ? -(1 << 15) : -1.0); AV_DEBUG(" vorbis version %d \n audio_channels %d \n audio_samplerate %d \n bitrate_max %d \n bitrate_nom %d \n bitrate_min %d \n blk_0 %d blk_1 %d \n ", vc->version, vc->audio_channels, vc->audio_samplerate, vc->bitrate_maximum, vc->bitrate_nominal, vc->bitrate_minimum, vc->blocksize[0], vc->blocksize[1]); /* BLK = vc->blocksize[0]; for (i = 0; i < BLK / 2; ++i) { vc->win[0][i] = sin(0.5*3.14159265358*(sin(((float)i + 0.5) / (float)BLK*3.14159265358))*(sin(((float)i + 0.5) / (float)BLK*3.14159265358))); } */ return 0; } // Process the extradata using the functions above (identification header, setup header) static av_cold int vorbis_decode_init(AVCodecContext *avccontext) { vorbis_context *vc = avccontext->priv_data ; uint8_t *headers = avccontext->extradata; int headers_len = avccontext->extradata_size; uint8_t *header_start[3]; int header_len[3]; GetBitContext *gb = &(vc->gb); int hdr_type; vc->avccontext = avccontext; dsputil_init(&vc->dsp, avccontext); if (vc->dsp.float_to_int16_interleave == ff_float_to_int16_interleave_c) { vc->add_bias = 385; vc->exp_bias = 0; } else { vc->add_bias = 0; vc->exp_bias = 15 << 23; } if (!headers_len) { av_log(avccontext, AV_LOG_ERROR, "Extradata missing.\n"); return -1; } if (ff_split_xiph_headers(headers, headers_len, 30, header_start, header_len) < 0) { av_log(avccontext, AV_LOG_ERROR, "Extradata corrupt.\n"); return -1; } init_get_bits(gb, header_start[0], header_len[0]*8); hdr_type = get_bits(gb, 8); if (hdr_type != 1) { av_log(avccontext, AV_LOG_ERROR, "First header is not the id header.\n"); return -1; } if (vorbis_parse_id_hdr(vc)) { av_log(avccontext, AV_LOG_ERROR, "Id header corrupt.\n"); vorbis_free(vc); return -1; } init_get_bits(gb, header_start[2], header_len[2]*8); hdr_type = get_bits(gb, 8); if (hdr_type != 5) { av_log(avccontext, AV_LOG_ERROR, "Third header is not the setup header.\n"); vorbis_free(vc); return -1; } if (vorbis_parse_setup_hdr(vc)) { av_log(avccontext, AV_LOG_ERROR, "Setup header corrupt.\n"); vorbis_free(vc); return -1; } if (vc->audio_channels > 8) avccontext->channel_layout = 0; else avccontext->channel_layout = ff_vorbis_channel_layouts[vc->audio_channels - 1]; avccontext->channels = vc->audio_channels; avccontext->sample_rate = vc->audio_samplerate; avccontext->frame_size = FFMIN(vc->blocksize[0], vc->blocksize[1]) >> 2; avccontext->sample_fmt = SAMPLE_FMT_S16; return 0 ; } // Decode audiopackets ------------------------------------------------- // Read and decode floor static uint_fast8_t vorbis_floor0_decode(vorbis_context *vc, vorbis_floor_data *vfu, float *vec) { vorbis_floor0 *vf = &vfu->t0; float *lsp = vf->lsp; uint_fast32_t amplitude; uint_fast32_t book_idx; uint_fast8_t blockflag = vc->modes[vc->mode_number].blockflag; amplitude = get_bits(&vc->gb, vf->amplitude_bits); if (amplitude > 0) { float last = 0; uint_fast16_t lsp_len = 0; uint_fast16_t idx; vorbis_codebook codebook; book_idx = get_bits(&vc->gb, ilog(vf->num_books)); if (book_idx >= vf->num_books) { av_log(vc->avccontext, AV_LOG_ERROR, "floor0 dec: booknumber too high!\n"); book_idx = 0; //FIXME: look above } AV_DEBUG("floor0 dec: booknumber: %u\n", book_idx); codebook = vc->codebooks[vf->book_list[book_idx]]; while (lsp_len<vf->order) { int vec_off; AV_DEBUG("floor0 dec: book dimension: %d\n", codebook.dimensions); AV_DEBUG("floor0 dec: maximum depth: %d\n", codebook.maxdepth); /* read temp vector */ vec_off = get_vlc2(&vc->gb, codebook.vlc.table, codebook.nb_bits, codebook.maxdepth) * codebook.dimensions; AV_DEBUG("floor0 dec: vector offset: %d\n", vec_off); /* copy each vector component and add last to it */ for (idx = 0; idx < codebook.dimensions; ++idx) lsp[lsp_len+idx] = codebook.codevectors[vec_off+idx] + last; last = lsp[lsp_len+idx-1]; /* set last to last vector component */ lsp_len += codebook.dimensions; } #ifdef V_DEBUG /* DEBUG: output lsp coeffs */ { int idx; for (idx = 0; idx < lsp_len; ++idx) AV_DEBUG("floor0 dec: coeff at %d is %f\n", idx, lsp[idx]); } #endif /* synthesize floor output vector */ { int i; int order = vf->order; float wstep = M_PI / vf->bark_map_size; for (i = 0; i < order; i++) lsp[i] = 2.0f * cos(lsp[i]); AV_DEBUG("floor0 synth: map_size = %d; m = %d; wstep = %f\n", vf->map_size, order, wstep); i = 0; while (i < vf->map_size[blockflag]) { int j, iter_cond = vf->map[blockflag][i]; float p = 0.5f; float q = 0.5f; float two_cos_w = 2.0f * cos(wstep * iter_cond); // needed all times /* similar part for the q and p products */ for (j = 0; j + 1 < order; j += 2) { q *= lsp[j] - two_cos_w; p *= lsp[j + 1] - two_cos_w; } if (j == order) { // even order p *= p * (2.0f - two_cos_w); q *= q * (2.0f + two_cos_w); } else { // odd order q *= two_cos_w-lsp[j]; // one more time for q /* final step and square */ p *= p * (4.f - two_cos_w * two_cos_w); q *= q; } /* calculate linear floor value */ { q = exp((((amplitude*vf->amplitude_offset) / (((1 << vf->amplitude_bits) - 1) * sqrt(p + q))) - vf->amplitude_offset) * .11512925f); } /* fill vector */ do { vec[i] = q; ++i; } while (vf->map[blockflag][i] == iter_cond); } } } else { /* this channel is unused */ return 1; } AV_DEBUG(" Floor0 decoded\n"); return 0; } static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc, vorbis_floor_data *vfu, float *vec) { vorbis_floor1 *vf = &vfu->t1; GetBitContext *gb = &vc->gb; uint_fast16_t range_v[4] = { 256, 128, 86, 64 }; uint_fast16_t range = range_v[vf->multiplier-1]; uint_fast16_t floor1_Y[vf->x_list_dim]; uint_fast16_t floor1_Y_final[vf->x_list_dim]; int floor1_flag[vf->x_list_dim]; uint_fast8_t class_; uint_fast8_t cdim; uint_fast8_t cbits; uint_fast8_t csub; uint_fast8_t cval; int_fast16_t book; uint_fast16_t offset; uint_fast16_t i,j; /*u*/int_fast16_t adx, ady, off, predicted; // WTF ? dy/adx = (unsigned)dy/adx ? int_fast16_t dy, err; if (!get_bits1(gb)) // silence return 1; // Read values (or differences) for the floor's points floor1_Y[0] = get_bits(gb, ilog(range - 1)); floor1_Y[1] = get_bits(gb, ilog(range - 1)); AV_DEBUG("floor 0 Y %d floor 1 Y %d \n", floor1_Y[0], floor1_Y[1]); offset = 2; for (i = 0; i < vf->partitions; ++i) { class_ = vf->partition_class[i]; cdim = vf->class_dimensions[class_]; cbits = vf->class_subclasses[class_]; csub = (1 << cbits) - 1; cval = 0; AV_DEBUG("Cbits %d \n", cbits); if (cbits) // this reads all subclasses for this partition's class cval = get_vlc2(gb, vc->codebooks[vf->class_masterbook[class_]].vlc.table, vc->codebooks[vf->class_masterbook[class_]].nb_bits, 3); for (j = 0; j < cdim; ++j) { book = vf->subclass_books[class_][cval & csub]; AV_DEBUG("book %d Cbits %d cval %d bits:%d \n", book, cbits, cval, get_bits_count(gb)); cval = cval >> cbits; if (book > -1) { floor1_Y[offset+j] = get_vlc2(gb, vc->codebooks[book].vlc.table, vc->codebooks[book].nb_bits, 3); } else { floor1_Y[offset+j] = 0; } AV_DEBUG(" floor(%d) = %d \n", vf->list[offset+j].x, floor1_Y[offset+j]); } offset+=cdim; } // Amplitude calculation from the differences floor1_flag[0] = 1; floor1_flag[1] = 1; floor1_Y_final[0] = floor1_Y[0]; floor1_Y_final[1] = floor1_Y[1]; for (i = 2; i < vf->x_list_dim; ++i) { uint_fast16_t val, highroom, lowroom, room; uint_fast16_t high_neigh_offs; uint_fast16_t low_neigh_offs; low_neigh_offs = vf->list[i].low; high_neigh_offs = vf->list[i].high; dy = floor1_Y_final[high_neigh_offs] - floor1_Y_final[low_neigh_offs]; // render_point begin adx = vf->list[high_neigh_offs].x - vf->list[low_neigh_offs].x; ady = FFABS(dy); err = ady * (vf->list[i].x - vf->list[low_neigh_offs].x); off = (int16_t)err / (int16_t)adx; if (dy < 0) { predicted = floor1_Y_final[low_neigh_offs] - off; } else { predicted = floor1_Y_final[low_neigh_offs] + off; } // render_point end val = floor1_Y[i]; highroom = range-predicted; lowroom = predicted; if (highroom < lowroom) { room = highroom * 2; } else { room = lowroom * 2; // SPEC mispelling } if (val) { floor1_flag[low_neigh_offs] = 1; floor1_flag[high_neigh_offs] = 1; floor1_flag[i] = 1; if (val >= room) { if (highroom > lowroom) { floor1_Y_final[i] = val - lowroom + predicted; } else { floor1_Y_final[i] = predicted - val + highroom - 1; } } else { if (val & 1) { floor1_Y_final[i] = predicted - (val + 1) / 2; } else { floor1_Y_final[i] = predicted + val / 2; } } } else { floor1_flag[i] = 0; floor1_Y_final[i] = predicted; } AV_DEBUG(" Decoded floor(%d) = %d / val %d \n", vf->list[i].x, floor1_Y_final[i], val); } // Curve synth - connect the calculated dots and convert from dB scale FIXME optimize ? ff_vorbis_floor1_render_list(vf->list, vf->x_list_dim, floor1_Y_final, floor1_flag, vf->multiplier, vec, vf->list[1].x); AV_DEBUG(" Floor decoded\n"); return 0; } // Read and decode residue static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, vorbis_residue *vr, uint_fast8_t ch, uint_fast8_t *do_not_decode, float *vec, uint_fast16_t vlen, int vr_type) { GetBitContext *gb = &vc->gb; uint_fast8_t c_p_c = vc->codebooks[vr->classbook].dimensions; uint_fast16_t n_to_read = vr->end-vr->begin; uint_fast16_t ptns_to_read = n_to_read/vr->partition_size; uint_fast8_t classifs[ptns_to_read*vc->audio_channels]; uint_fast8_t pass; uint_fast8_t ch_used; uint_fast8_t i,j,l; uint_fast16_t k; if (vr_type == 2) { for (j = 1; j < ch; ++j) do_not_decode[0] &= do_not_decode[j]; // FIXME - clobbering input if (do_not_decode[0]) return 0; ch_used = 1; } else { ch_used = ch; } AV_DEBUG(" residue type 0/1/2 decode begin, ch: %d cpc %d \n", ch, c_p_c); for (pass = 0; pass <= vr->maxpass; ++pass) { // FIXME OPTIMIZE? uint_fast16_t voffset; uint_fast16_t partition_count; uint_fast16_t j_times_ptns_to_read; voffset = vr->begin; for (partition_count = 0; partition_count < ptns_to_read;) { // SPEC error if (!pass) { uint_fast32_t inverse_class = ff_inverse[vr->classifications]; for (j_times_ptns_to_read = 0, j = 0; j < ch_used; ++j) { if (!do_not_decode[j]) { uint_fast32_t temp = get_vlc2(gb, vc->codebooks[vr->classbook].vlc.table, vc->codebooks[vr->classbook].nb_bits, 3); AV_DEBUG("Classword: %d \n", temp); assert(vr->classifications > 1 && temp <= 65536); //needed for inverse[] for (i = 0; i < c_p_c; ++i) { uint_fast32_t temp2; temp2 = (((uint_fast64_t)temp) * inverse_class) >> 32; if (partition_count + c_p_c - 1 - i < ptns_to_read) classifs[j_times_ptns_to_read + partition_count + c_p_c - 1 - i] = temp - temp2 * vr->classifications; temp = temp2; } } j_times_ptns_to_read += ptns_to_read; } } for (i = 0; (i < c_p_c) && (partition_count < ptns_to_read); ++i) { for (j_times_ptns_to_read = 0, j = 0; j < ch_used; ++j) { uint_fast16_t voffs; if (!do_not_decode[j]) { uint_fast8_t vqclass = classifs[j_times_ptns_to_read+partition_count]; int_fast16_t vqbook = vr->books[vqclass][pass]; if (vqbook >= 0 && vc->codebooks[vqbook].codevectors) { uint_fast16_t coffs; unsigned dim = vc->codebooks[vqbook].dimensions; // not uint_fast8_t: 64bit is slower here on amd64 uint_fast16_t step = dim == 1 ? vr->partition_size : FASTDIV(vr->partition_size, dim); vorbis_codebook codebook = vc->codebooks[vqbook]; if (vr_type == 0) { voffs = voffset+j*vlen; for (k = 0; k < step; ++k) { coffs = get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * dim; for (l = 0; l < dim; ++l) vec[voffs + k + l * step] += codebook.codevectors[coffs + l]; // FPMATH } } else if (vr_type == 1) { voffs = voffset + j * vlen; for (k = 0; k < step; ++k) { coffs = get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * dim; for (l = 0; l < dim; ++l, ++voffs) { vec[voffs]+=codebook.codevectors[coffs+l]; // FPMATH AV_DEBUG(" pass %d offs: %d curr: %f change: %f cv offs.: %d \n", pass, voffs, vec[voffs], codebook.codevectors[coffs+l], coffs); } } } else if (vr_type == 2 && ch == 2 && (voffset & 1) == 0 && (dim & 1) == 0) { // most frequent case optimized voffs = voffset >> 1; if (dim == 2) { for (k = 0; k < step; ++k) { coffs = get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * 2; vec[voffs + k ] += codebook.codevectors[coffs ]; // FPMATH vec[voffs + k + vlen] += codebook.codevectors[coffs + 1]; // FPMATH } } else if (dim == 4) { for (k = 0; k < step; ++k, voffs += 2) { coffs = get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * 4; vec[voffs ] += codebook.codevectors[coffs ]; // FPMATH vec[voffs + 1 ] += codebook.codevectors[coffs + 2]; // FPMATH vec[voffs + vlen ] += codebook.codevectors[coffs + 1]; // FPMATH vec[voffs + vlen + 1] += codebook.codevectors[coffs + 3]; // FPMATH } } else for (k = 0; k < step; ++k) { coffs = get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * dim; for (l = 0; l < dim; l += 2, voffs++) { vec[voffs ] += codebook.codevectors[coffs + l ]; // FPMATH vec[voffs + vlen] += codebook.codevectors[coffs + l + 1]; // FPMATH AV_DEBUG(" pass %d offs: %d curr: %f change: %f cv offs.: %d+%d \n", pass, voffset / ch + (voffs % ch) * vlen, vec[voffset / ch + (voffs % ch) * vlen], codebook.codevectors[coffs + l], coffs, l); } } } else if (vr_type == 2) { voffs = voffset; for (k = 0; k < step; ++k) { coffs = get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * dim; for (l = 0; l < dim; ++l, ++voffs) { vec[voffs / ch + (voffs % ch) * vlen] += codebook.codevectors[coffs + l]; // FPMATH FIXME use if and counter instead of / and % AV_DEBUG(" pass %d offs: %d curr: %f change: %f cv offs.: %d+%d \n", pass, voffset / ch + (voffs % ch) * vlen, vec[voffset / ch + (voffs % ch) * vlen], codebook.codevectors[coffs + l], coffs, l); } } } } } j_times_ptns_to_read += ptns_to_read; } ++partition_count; voffset += vr->partition_size; } } } return 0; } static inline int vorbis_residue_decode(vorbis_context *vc, vorbis_residue *vr, uint_fast8_t ch, uint_fast8_t *do_not_decode, float *vec, uint_fast16_t vlen) { if (vr->type == 2) return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 2); else if (vr->type == 1) return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 1); else if (vr->type == 0) return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 0); else { av_log(vc->avccontext, AV_LOG_ERROR, " Invalid residue type while residue decode?! \n"); return -1; } } void vorbis_inverse_coupling(float *mag, float *ang, int blocksize) { int i; for (i = 0; i < blocksize; i++) { if (mag[i] > 0.0) { if (ang[i] > 0.0) { ang[i] = mag[i] - ang[i]; } else { float temp = ang[i]; ang[i] = mag[i]; mag[i] += temp; } } else { if (ang[i] > 0.0) { ang[i] += mag[i]; } else { float temp = ang[i]; ang[i] = mag[i]; mag[i] -= temp; } } } } static void copy_normalize(float *dst, float *src, int len, int exp_bias, float add_bias) { int i; if (exp_bias) { memcpy(dst, src, len * sizeof(float)); } else { for (i = 0; i < len; i++) dst[i] = src[i] + add_bias; } } // Decode the audio packet using the functions above static int vorbis_parse_audio_packet(vorbis_context *vc) { GetBitContext *gb = &vc->gb; uint_fast8_t previous_window = vc->previous_window; uint_fast8_t mode_number; uint_fast8_t blockflag; uint_fast16_t blocksize; int_fast32_t i,j; uint_fast8_t no_residue[vc->audio_channels]; uint_fast8_t do_not_decode[vc->audio_channels]; vorbis_mapping *mapping; float *ch_res_ptr = vc->channel_residues; float *ch_floor_ptr = vc->channel_floors; uint_fast8_t res_chan[vc->audio_channels]; uint_fast8_t res_num = 0; int_fast16_t retlen = 0; float fadd_bias = vc->add_bias; if (get_bits1(gb)) { av_log(vc->avccontext, AV_LOG_ERROR, "Not a Vorbis I audio packet.\n"); return -1; // packet type not audio } if (vc->mode_count == 1) { mode_number = 0; } else { GET_VALIDATED_INDEX(mode_number, ilog(vc->mode_count-1), vc->mode_count) } vc->mode_number = mode_number; mapping = &vc->mappings[vc->modes[mode_number].mapping]; AV_DEBUG(" Mode number: %d , mapping: %d , blocktype %d \n", mode_number, vc->modes[mode_number].mapping, vc->modes[mode_number].blockflag); blockflag = vc->modes[mode_number].blockflag; blocksize = vc->blocksize[blockflag]; if (blockflag) skip_bits(gb, 2); // previous_window, next_window memset(ch_res_ptr, 0, sizeof(float) * vc->audio_channels * blocksize / 2); //FIXME can this be removed ? memset(ch_floor_ptr, 0, sizeof(float) * vc->audio_channels * blocksize / 2); //FIXME can this be removed ? // Decode floor for (i = 0; i < vc->audio_channels; ++i) { vorbis_floor *floor; if (mapping->submaps > 1) { floor = &vc->floors[mapping->submap_floor[mapping->mux[i]]]; } else { floor = &vc->floors[mapping->submap_floor[0]]; } no_residue[i] = floor->decode(vc, &floor->data, ch_floor_ptr); ch_floor_ptr += blocksize / 2; } // Nonzero vector propagate for (i = mapping->coupling_steps - 1; i >= 0; --i) { if (!(no_residue[mapping->magnitude[i]] & no_residue[mapping->angle[i]])) { no_residue[mapping->magnitude[i]] = 0; no_residue[mapping->angle[i]] = 0; } } // Decode residue for (i = 0; i < mapping->submaps; ++i) { vorbis_residue *residue; uint_fast8_t ch = 0; for (j = 0; j < vc->audio_channels; ++j) { if ((mapping->submaps == 1) || (i == mapping->mux[j])) { res_chan[j] = res_num; if (no_residue[j]) { do_not_decode[ch] = 1; } else { do_not_decode[ch] = 0; } ++ch; ++res_num; } } residue = &vc->residues[mapping->submap_residue[i]]; vorbis_residue_decode(vc, residue, ch, do_not_decode, ch_res_ptr, blocksize/2); ch_res_ptr += ch * blocksize / 2; } // Inverse coupling for (i = mapping->coupling_steps - 1; i >= 0; --i) { //warning: i has to be signed float *mag, *ang; mag = vc->channel_residues+res_chan[mapping->magnitude[i]] * blocksize / 2; ang = vc->channel_residues+res_chan[mapping->angle[i]] * blocksize / 2; vc->dsp.vorbis_inverse_coupling(mag, ang, blocksize / 2); } // Dotproduct, MDCT for (j = vc->audio_channels-1;j >= 0; j--) { ch_floor_ptr = vc->channel_floors + j * blocksize / 2; ch_res_ptr = vc->channel_residues + res_chan[j] * blocksize / 2; vc->dsp.vector_fmul(ch_floor_ptr, ch_res_ptr, blocksize / 2); ff_imdct_half(&vc->mdct[blockflag], ch_res_ptr, ch_floor_ptr); } // Overlap/add, save data for next overlapping FPMATH retlen = (blocksize + vc->blocksize[previous_window]) / 4; for (j = 0; j < vc->audio_channels; j++) { uint_fast16_t bs0 = vc->blocksize[0]; uint_fast16_t bs1 = vc->blocksize[1]; float *residue = vc->channel_residues + res_chan[j] * blocksize / 2; float *saved = vc->saved + j * bs1 / 4; float *ret = vc->channel_floors + j * retlen; float *buf = residue; const float *win = vc->win[blockflag & previous_window]; if (blockflag == previous_window) { vc->dsp.vector_fmul_window(ret, saved, buf, win, fadd_bias, blocksize / 4); } else if (blockflag > previous_window) { vc->dsp.vector_fmul_window(ret, saved, buf, win, fadd_bias, bs0 / 4); copy_normalize(ret+bs0/2, buf+bs0/4, (bs1-bs0)/4, vc->exp_bias, fadd_bias); } else { copy_normalize(ret, saved, (bs1 - bs0) / 4, vc->exp_bias, fadd_bias); vc->dsp.vector_fmul_window(ret + (bs1 - bs0) / 4, saved + (bs1 - bs0) / 4, buf, win, fadd_bias, bs0 / 4); } memcpy(saved, buf + blocksize / 4, blocksize / 4 * sizeof(float)); } vc->previous_window = blockflag; return retlen; } // Return the decoded audio packet through the standard api static int vorbis_decode_frame(AVCodecContext *avccontext, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; vorbis_context *vc = avccontext->priv_data ; GetBitContext *gb = &(vc->gb); const float *channel_ptrs[vc->audio_channels]; int i; int_fast16_t len; if (!buf_size) return 0; AV_DEBUG("packet length %d \n", buf_size); init_get_bits(gb, buf, buf_size*8); len = vorbis_parse_audio_packet(vc); if (len <= 0) { *data_size = 0; return buf_size; } if (!vc->first_frame) { vc->first_frame = 1; *data_size = 0; return buf_size ; } AV_DEBUG("parsed %d bytes %d bits, returned %d samples (*ch*bits) \n", get_bits_count(gb)/8, get_bits_count(gb)%8, len); if (vc->audio_channels > 8) { for (i = 0; i < vc->audio_channels; i++) channel_ptrs[i] = vc->channel_floors + i * len; } else { for (i = 0; i < vc->audio_channels; i++) channel_ptrs[i] = vc->channel_floors + len * ff_vorbis_channel_layout_offsets[vc->audio_channels - 1][i]; } vc->dsp.float_to_int16_interleave(data, channel_ptrs, len, vc->audio_channels); *data_size = len * 2 * vc->audio_channels; return buf_size ; } // Close decoder static av_cold int vorbis_decode_close(AVCodecContext *avccontext) { vorbis_context *vc = avccontext->priv_data; vorbis_free(vc); return 0 ; } AVCodec vorbis_decoder = { "vorbis", AVMEDIA_TYPE_AUDIO, CODEC_ID_VORBIS, sizeof(vorbis_context), vorbis_decode_init, NULL, vorbis_decode_close, vorbis_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("Vorbis"), .channel_layouts = ff_vorbis_channel_layouts, };
123linslouis-android-video-cutter
jni/libavcodec/vorbis_dec.c
C
asf20
61,745
/* * MJPEG encoder * Copyright (c) 2000, 2001 Fabrice Bellard * Copyright (c) 2003 Alex Beregszaszi * Copyright (c) 2003-2004 Michael Niedermayer * * Support for external huffman table, various fixes (AVID workaround), * aspecting, new decode_frame mechanism and apple mjpeg-b support * by Alex Beregszaszi * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * MJPEG encoder. */ #ifndef AVCODEC_MJPEGENC_H #define AVCODEC_MJPEGENC_H #include "dsputil.h" #include "mpegvideo.h" typedef struct MJpegContext { uint8_t huff_size_dc_luminance[12]; //FIXME use array [3] instead of lumi / chrom, for easier addressing uint16_t huff_code_dc_luminance[12]; uint8_t huff_size_dc_chrominance[12]; uint16_t huff_code_dc_chrominance[12]; uint8_t huff_size_ac_luminance[256]; uint16_t huff_code_ac_luminance[256]; uint8_t huff_size_ac_chrominance[256]; uint16_t huff_code_ac_chrominance[256]; } MJpegContext; int ff_mjpeg_encode_init(MpegEncContext *s); void ff_mjpeg_encode_close(MpegEncContext *s); void ff_mjpeg_encode_picture_header(MpegEncContext *s); void ff_mjpeg_encode_picture_trailer(MpegEncContext *s); void ff_mjpeg_encode_stuffing(PutBitContext *pbc); void ff_mjpeg_encode_dc(MpegEncContext *s, int val, uint8_t *huff_size, uint16_t *huff_code); void ff_mjpeg_encode_mb(MpegEncContext *s, DCTELEM block[6][64]); #endif /* AVCODEC_MJPEGENC_H */
123linslouis-android-video-cutter
jni/libavcodec/mjpegenc.h
C
asf20
2,175
/* * MPEG Audio common code * Copyright (c) 2001, 2002 Fabrice Bellard * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * MPEG Audio common code. */ #include "mpegaudio.h" /* bitrate is in kb/s */ int ff_mpa_l2_select_table(int bitrate, int nb_channels, int freq, int lsf) { int ch_bitrate, table; ch_bitrate = bitrate / nb_channels; if (!lsf) { if ((freq == 48000 && ch_bitrate >= 56) || (ch_bitrate >= 56 && ch_bitrate <= 80)) table = 0; else if (freq != 48000 && ch_bitrate >= 96) table = 1; else if (freq != 32000 && ch_bitrate <= 48) table = 2; else table = 3; } else { table = 4; } return table; }
123linslouis-android-video-cutter
jni/libavcodec/mpegaudio.c
C
asf20
1,464
/* * Delphine Software International CIN Audio/Video Decoders * Copyright (c) 2006 Gregory Montoir (cyx@users.sourceforge.net) * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * Delphine Software International CIN audio/video decoders */ #include "avcodec.h" #include "bytestream.h" typedef enum CinVideoBitmapIndex { CIN_CUR_BMP = 0, /* current */ CIN_PRE_BMP = 1, /* previous */ CIN_INT_BMP = 2 /* intermediate */ } CinVideoBitmapIndex; typedef struct CinVideoContext { AVCodecContext *avctx; AVFrame frame; unsigned int bitmap_size; uint32_t palette[256]; uint8_t *bitmap_table[3]; } CinVideoContext; typedef struct CinAudioContext { AVCodecContext *avctx; int initial_decode_frame; int delta; } CinAudioContext; /* table defining a geometric sequence with multiplier = 32767 ^ (1 / 128) */ static const int16_t cinaudio_delta16_table[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -30210, -27853, -25680, -23677, -21829, -20126, -18556, -17108, -15774, -14543, -13408, -12362, -11398, -10508, -9689, -8933, -8236, -7593, -7001, -6455, -5951, -5487, -5059, -4664, -4300, -3964, -3655, -3370, -3107, -2865, -2641, -2435, -2245, -2070, -1908, -1759, -1622, -1495, -1379, -1271, -1172, -1080, -996, -918, -847, -781, -720, -663, -612, -564, -520, -479, -442, -407, -376, -346, -319, -294, -271, -250, -230, -212, -196, -181, -166, -153, -141, -130, -120, -111, -102, -94, -87, -80, -74, -68, -62, -58, -53, -49, -45, -41, -38, -35, -32, -30, -27, -25, -23, -21, -20, -18, -17, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 20, 21, 23, 25, 27, 30, 32, 35, 38, 41, 45, 49, 53, 58, 62, 68, 74, 80, 87, 94, 102, 111, 120, 130, 141, 153, 166, 181, 196, 212, 230, 250, 271, 294, 319, 346, 376, 407, 442, 479, 520, 564, 612, 663, 720, 781, 847, 918, 996, 1080, 1172, 1271, 1379, 1495, 1622, 1759, 1908, 2070, 2245, 2435, 2641, 2865, 3107, 3370, 3655, 3964, 4300, 4664, 5059, 5487, 5951, 6455, 7001, 7593, 8236, 8933, 9689, 10508, 11398, 12362, 13408, 14543, 15774, 17108, 18556, 20126, 21829, 23677, 25680, 27853, 30210, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static av_cold int cinvideo_decode_init(AVCodecContext *avctx) { CinVideoContext *cin = avctx->priv_data; unsigned int i; cin->avctx = avctx; avctx->pix_fmt = PIX_FMT_PAL8; cin->frame.data[0] = NULL; cin->bitmap_size = avctx->width * avctx->height; for (i = 0; i < 3; ++i) { cin->bitmap_table[i] = av_mallocz(cin->bitmap_size); if (!cin->bitmap_table[i]) av_log(avctx, AV_LOG_ERROR, "Can't allocate bitmap buffers.\n"); } return 0; } static void cin_apply_delta_data(const unsigned char *src, unsigned char *dst, int size) { while (size--) *dst++ += *src++; } static int cin_decode_huffman(const unsigned char *src, int src_size, unsigned char *dst, int dst_size) { int b, huff_code = 0; unsigned char huff_code_table[15]; unsigned char *dst_cur = dst; unsigned char *dst_end = dst + dst_size; const unsigned char *src_end = src + src_size; memcpy(huff_code_table, src, 15); src += 15; src_size -= 15; while (src < src_end) { huff_code = *src++; if ((huff_code >> 4) == 15) { b = huff_code << 4; huff_code = *src++; *dst_cur++ = b | (huff_code >> 4); } else *dst_cur++ = huff_code_table[huff_code >> 4]; if (dst_cur >= dst_end) break; huff_code &= 15; if (huff_code == 15) { *dst_cur++ = *src++; } else *dst_cur++ = huff_code_table[huff_code]; if (dst_cur >= dst_end) break; } return dst_cur - dst; } static void cin_decode_lzss(const unsigned char *src, int src_size, unsigned char *dst, int dst_size) { uint16_t cmd; int i, sz, offset, code; unsigned char *dst_end = dst + dst_size; const unsigned char *src_end = src + src_size; while (src < src_end && dst < dst_end) { code = *src++; for (i = 0; i < 8 && src < src_end && dst < dst_end; ++i) { if (code & (1 << i)) { *dst++ = *src++; } else { cmd = AV_RL16(src); src += 2; offset = cmd >> 4; sz = (cmd & 0xF) + 2; /* don't use memcpy/memmove here as the decoding routine (ab)uses */ /* buffer overlappings to repeat bytes in the destination */ sz = FFMIN(sz, dst_end - dst); while (sz--) { *dst = *(dst - offset - 1); ++dst; } } } } } static void cin_decode_rle(const unsigned char *src, int src_size, unsigned char *dst, int dst_size) { int len, code; unsigned char *dst_end = dst + dst_size; const unsigned char *src_end = src + src_size; while (src < src_end && dst < dst_end) { code = *src++; if (code & 0x80) { len = code - 0x7F; memset(dst, *src++, FFMIN(len, dst_end - dst)); } else { len = code + 1; memcpy(dst, src, FFMIN(len, dst_end - dst)); src += len; } dst += len; } } static int cinvideo_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; CinVideoContext *cin = avctx->priv_data; int i, y, palette_type, palette_colors_count, bitmap_frame_type, bitmap_frame_size; cin->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; if (avctx->reget_buffer(avctx, &cin->frame)) { av_log(cin->avctx, AV_LOG_ERROR, "delphinecinvideo: reget_buffer() failed to allocate a frame\n"); return -1; } palette_type = buf[0]; palette_colors_count = AV_RL16(buf+1); bitmap_frame_type = buf[3]; buf += 4; bitmap_frame_size = buf_size - 4; /* handle palette */ if (palette_type == 0) { for (i = 0; i < palette_colors_count; ++i) { cin->palette[i] = bytestream_get_le24(&buf); bitmap_frame_size -= 3; } } else { for (i = 0; i < palette_colors_count; ++i) { cin->palette[buf[0]] = AV_RL24(buf+1); buf += 4; bitmap_frame_size -= 4; } } memcpy(cin->frame.data[1], cin->palette, sizeof(cin->palette)); cin->frame.palette_has_changed = 1; /* note: the decoding routines below assumes that surface.width = surface.pitch */ switch (bitmap_frame_type) { case 9: cin_decode_rle(buf, bitmap_frame_size, cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size); break; case 34: cin_decode_rle(buf, bitmap_frame_size, cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size); cin_apply_delta_data(cin->bitmap_table[CIN_PRE_BMP], cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size); break; case 35: cin_decode_huffman(buf, bitmap_frame_size, cin->bitmap_table[CIN_INT_BMP], cin->bitmap_size); cin_decode_rle(cin->bitmap_table[CIN_INT_BMP], bitmap_frame_size, cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size); break; case 36: bitmap_frame_size = cin_decode_huffman(buf, bitmap_frame_size, cin->bitmap_table[CIN_INT_BMP], cin->bitmap_size); cin_decode_rle(cin->bitmap_table[CIN_INT_BMP], bitmap_frame_size, cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size); cin_apply_delta_data(cin->bitmap_table[CIN_PRE_BMP], cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size); break; case 37: cin_decode_huffman(buf, bitmap_frame_size, cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size); break; case 38: cin_decode_lzss(buf, bitmap_frame_size, cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size); break; case 39: cin_decode_lzss(buf, bitmap_frame_size, cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size); cin_apply_delta_data(cin->bitmap_table[CIN_PRE_BMP], cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size); break; } for (y = 0; y < cin->avctx->height; ++y) memcpy(cin->frame.data[0] + (cin->avctx->height - 1 - y) * cin->frame.linesize[0], cin->bitmap_table[CIN_CUR_BMP] + y * cin->avctx->width, cin->avctx->width); FFSWAP(uint8_t *, cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_table[CIN_PRE_BMP]); *data_size = sizeof(AVFrame); *(AVFrame *)data = cin->frame; return buf_size; } static av_cold int cinvideo_decode_end(AVCodecContext *avctx) { CinVideoContext *cin = avctx->priv_data; int i; if (cin->frame.data[0]) avctx->release_buffer(avctx, &cin->frame); for (i = 0; i < 3; ++i) av_free(cin->bitmap_table[i]); return 0; } static av_cold int cinaudio_decode_init(AVCodecContext *avctx) { CinAudioContext *cin = avctx->priv_data; cin->avctx = avctx; cin->initial_decode_frame = 1; cin->delta = 0; avctx->sample_fmt = SAMPLE_FMT_S16; return 0; } static int cinaudio_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; CinAudioContext *cin = avctx->priv_data; const uint8_t *src = buf; int16_t *samples = (int16_t *)data; buf_size = FFMIN(buf_size, *data_size/2); if (cin->initial_decode_frame) { cin->initial_decode_frame = 0; cin->delta = (int16_t)AV_RL16(src); src += 2; *samples++ = cin->delta; buf_size -= 2; } while (buf_size > 0) { cin->delta += cinaudio_delta16_table[*src++]; cin->delta = av_clip_int16(cin->delta); *samples++ = cin->delta; --buf_size; } *data_size = (uint8_t *)samples - (uint8_t *)data; return src - buf; } AVCodec dsicinvideo_decoder = { "dsicinvideo", AVMEDIA_TYPE_VIDEO, CODEC_ID_DSICINVIDEO, sizeof(CinVideoContext), cinvideo_decode_init, NULL, cinvideo_decode_end, cinvideo_decode_frame, CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Delphine Software International CIN video"), }; AVCodec dsicinaudio_decoder = { "dsicinaudio", AVMEDIA_TYPE_AUDIO, CODEC_ID_DSICINAUDIO, sizeof(CinAudioContext), cinaudio_decode_init, NULL, NULL, cinaudio_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("Delphine Software International CIN audio"), };
123linslouis-android-video-cutter
jni/libavcodec/dsicinav.c
C
asf20
12,430
/* * H261 parser * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * Copyright (c) 2004 Maarten Daniels * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * h261codec. */ #include "parser.h" static int h261_find_frame_end(ParseContext *pc, AVCodecContext* avctx, const uint8_t *buf, int buf_size){ int vop_found, i, j; uint32_t state; vop_found= pc->frame_start_found; state= pc->state; for(i=0; i<buf_size && !vop_found; i++){ state= (state<<8) | buf[i]; for(j=0; j<8; j++){ if(((state>>j)&0xFFFFF0) == 0x000100){ vop_found=1; break; } } } if(vop_found){ for(; i<buf_size; i++){ state= (state<<8) | buf[i]; for(j=0; j<8; j++){ if(((state>>j)&0xFFFFF0) == 0x000100){ pc->frame_start_found=0; pc->state= (state>>(3*8))+0xFF00; return i-2; } } } } pc->frame_start_found= vop_found; pc->state= state; return END_NOT_FOUND; } static int h261_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size) { ParseContext *pc = s->priv_data; int next; next= h261_find_frame_end(pc,avctx, buf, buf_size); if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { *poutbuf = NULL; *poutbuf_size = 0; return buf_size; } *poutbuf = buf; *poutbuf_size = buf_size; return next; } AVCodecParser h261_parser = { { CODEC_ID_H261 }, sizeof(ParseContext), NULL, h261_parse, ff_parse_close, };
123linslouis-android-video-cutter
jni/libavcodec/h261_parser.c
C
asf20
2,507
/* * Assorted DPCM codecs * Copyright (c) 2003 The ffmpeg Project * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file: dpcm.c * Assorted DPCM (differential pulse code modulation) audio codecs * by Mike Melanson (melanson@pcisys.net) * Xan DPCM decoder by Mario Brito (mbrito@student.dei.uc.pt) * for more information on the specific data formats, visit: * http://www.pcisys.net/~melanson/codecs/simpleaudio.html * SOL DPCMs implemented by Konstantin Shishkov * * Note about using the Xan DPCM decoder: Xan DPCM is used in AVI files * found in the Wing Commander IV computer game. These AVI files contain * WAVEFORMAT headers which report the audio format as 0x01: raw PCM. * Clearly incorrect. To detect Xan DPCM, you will probably have to * special-case your AVI demuxer to use Xan DPCM if the file uses 'Xxan' * (Xan video) for its video codec. Alternately, such AVI files also contain * the fourcc 'Axan' in the 'auds' chunk of the AVI header. */ #include "libavutil/intreadwrite.h" #include "avcodec.h" typedef struct DPCMContext { int channels; short roq_square_array[256]; long sample[2];//for SOL_DPCM const int *sol_table;//for SOL_DPCM } DPCMContext; #define SE_16BIT(x) if (x & 0x8000) x -= 0x10000; static const int interplay_delta_table[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 47, 51, 56, 61, 66, 72, 79, 86, 94, 102, 112, 122, 133, 145, 158, 173, 189, 206, 225, 245, 267, 292, 318, 348, 379, 414, 452, 493, 538, 587, 640, 699, 763, 832, 908, 991, 1081, 1180, 1288, 1405, 1534, 1673, 1826, 1993, 2175, 2373, 2590, 2826, 3084, 3365, 3672, 4008, 4373, 4772, 5208, 5683, 6202, 6767, 7385, 8059, 8794, 9597, 10472, 11428, 12471, 13609, 14851, 16206, 17685, 19298, 21060, 22981, 25078, 27367, 29864, 32589, -29973, -26728, -23186, -19322, -15105, -10503, -5481, -1, 1, 1, 5481, 10503, 15105, 19322, 23186, 26728, 29973, -32589, -29864, -27367, -25078, -22981, -21060, -19298, -17685, -16206, -14851, -13609, -12471, -11428, -10472, -9597, -8794, -8059, -7385, -6767, -6202, -5683, -5208, -4772, -4373, -4008, -3672, -3365, -3084, -2826, -2590, -2373, -2175, -1993, -1826, -1673, -1534, -1405, -1288, -1180, -1081, -991, -908, -832, -763, -699, -640, -587, -538, -493, -452, -414, -379, -348, -318, -292, -267, -245, -225, -206, -189, -173, -158, -145, -133, -122, -112, -102, -94, -86, -79, -72, -66, -61, -56, -51, -47, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1 }; static const int sol_table_old[16] = { 0x0, 0x1, 0x2 , 0x3, 0x6, 0xA, 0xF, 0x15, -0x15, -0xF, -0xA, -0x6, -0x3, -0x2, -0x1, 0x0}; static const int sol_table_new[16] = { 0x0, 0x1, 0x2, 0x3, 0x6, 0xA, 0xF, 0x15, 0x0, -0x1, -0x2, -0x3, -0x6, -0xA, -0xF, -0x15}; static const int sol_table_16[128] = { 0x000, 0x008, 0x010, 0x020, 0x030, 0x040, 0x050, 0x060, 0x070, 0x080, 0x090, 0x0A0, 0x0B0, 0x0C0, 0x0D0, 0x0E0, 0x0F0, 0x100, 0x110, 0x120, 0x130, 0x140, 0x150, 0x160, 0x170, 0x180, 0x190, 0x1A0, 0x1B0, 0x1C0, 0x1D0, 0x1E0, 0x1F0, 0x200, 0x208, 0x210, 0x218, 0x220, 0x228, 0x230, 0x238, 0x240, 0x248, 0x250, 0x258, 0x260, 0x268, 0x270, 0x278, 0x280, 0x288, 0x290, 0x298, 0x2A0, 0x2A8, 0x2B0, 0x2B8, 0x2C0, 0x2C8, 0x2D0, 0x2D8, 0x2E0, 0x2E8, 0x2F0, 0x2F8, 0x300, 0x308, 0x310, 0x318, 0x320, 0x328, 0x330, 0x338, 0x340, 0x348, 0x350, 0x358, 0x360, 0x368, 0x370, 0x378, 0x380, 0x388, 0x390, 0x398, 0x3A0, 0x3A8, 0x3B0, 0x3B8, 0x3C0, 0x3C8, 0x3D0, 0x3D8, 0x3E0, 0x3E8, 0x3F0, 0x3F8, 0x400, 0x440, 0x480, 0x4C0, 0x500, 0x540, 0x580, 0x5C0, 0x600, 0x640, 0x680, 0x6C0, 0x700, 0x740, 0x780, 0x7C0, 0x800, 0x900, 0xA00, 0xB00, 0xC00, 0xD00, 0xE00, 0xF00, 0x1000, 0x1400, 0x1800, 0x1C00, 0x2000, 0x3000, 0x4000 }; static av_cold int dpcm_decode_init(AVCodecContext *avctx) { DPCMContext *s = avctx->priv_data; int i; short square; s->channels = avctx->channels; s->sample[0] = s->sample[1] = 0; switch(avctx->codec->id) { case CODEC_ID_ROQ_DPCM: /* initialize square table */ for (i = 0; i < 128; i++) { square = i * i; s->roq_square_array[i] = square; s->roq_square_array[i + 128] = -square; } break; case CODEC_ID_SOL_DPCM: switch(avctx->codec_tag){ case 1: s->sol_table=sol_table_old; s->sample[0] = s->sample[1] = 0x80; break; case 2: s->sol_table=sol_table_new; s->sample[0] = s->sample[1] = 0x80; break; case 3: s->sol_table=sol_table_16; break; default: av_log(avctx, AV_LOG_ERROR, "Unknown SOL subcodec\n"); return -1; } break; default: break; } avctx->sample_fmt = SAMPLE_FMT_S16; return 0; } static int dpcm_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; DPCMContext *s = avctx->priv_data; int in, out = 0; int predictor[2]; int channel_number = 0; short *output_samples = data; int shift[2]; unsigned char byte; short diff; if (!buf_size) return 0; // almost every DPCM variant expands one byte of data into two if(*data_size/2 < buf_size) return -1; switch(avctx->codec->id) { case CODEC_ID_ROQ_DPCM: if (s->channels == 1) predictor[0] = AV_RL16(&buf[6]); else { predictor[0] = buf[7] << 8; predictor[1] = buf[6] << 8; } SE_16BIT(predictor[0]); SE_16BIT(predictor[1]); /* decode the samples */ for (in = 8, out = 0; in < buf_size; in++, out++) { predictor[channel_number] += s->roq_square_array[buf[in]]; predictor[channel_number] = av_clip_int16(predictor[channel_number]); output_samples[out] = predictor[channel_number]; /* toggle channel */ channel_number ^= s->channels - 1; } break; case CODEC_ID_INTERPLAY_DPCM: in = 6; /* skip over the stream mask and stream length */ predictor[0] = AV_RL16(&buf[in]); in += 2; SE_16BIT(predictor[0]) output_samples[out++] = predictor[0]; if (s->channels == 2) { predictor[1] = AV_RL16(&buf[in]); in += 2; SE_16BIT(predictor[1]) output_samples[out++] = predictor[1]; } while (in < buf_size) { predictor[channel_number] += interplay_delta_table[buf[in++]]; predictor[channel_number] = av_clip_int16(predictor[channel_number]); output_samples[out++] = predictor[channel_number]; /* toggle channel */ channel_number ^= s->channels - 1; } break; case CODEC_ID_XAN_DPCM: in = 0; shift[0] = shift[1] = 4; predictor[0] = AV_RL16(&buf[in]); in += 2; SE_16BIT(predictor[0]); if (s->channels == 2) { predictor[1] = AV_RL16(&buf[in]); in += 2; SE_16BIT(predictor[1]); } while (in < buf_size) { byte = buf[in++]; diff = (byte & 0xFC) << 8; if ((byte & 0x03) == 3) shift[channel_number]++; else shift[channel_number] -= (2 * (byte & 3)); /* saturate the shifter to a lower limit of 0 */ if (shift[channel_number] < 0) shift[channel_number] = 0; diff >>= shift[channel_number]; predictor[channel_number] += diff; predictor[channel_number] = av_clip_int16(predictor[channel_number]); output_samples[out++] = predictor[channel_number]; /* toggle channel */ channel_number ^= s->channels - 1; } break; case CODEC_ID_SOL_DPCM: in = 0; if (avctx->codec_tag != 3) { if(*data_size/4 < buf_size) return -1; while (in < buf_size) { int n1, n2; n1 = (buf[in] >> 4) & 0xF; n2 = buf[in++] & 0xF; s->sample[0] += s->sol_table[n1]; if (s->sample[0] < 0) s->sample[0] = 0; if (s->sample[0] > 255) s->sample[0] = 255; output_samples[out++] = (s->sample[0] - 128) << 8; s->sample[s->channels - 1] += s->sol_table[n2]; if (s->sample[s->channels - 1] < 0) s->sample[s->channels - 1] = 0; if (s->sample[s->channels - 1] > 255) s->sample[s->channels - 1] = 255; output_samples[out++] = (s->sample[s->channels - 1] - 128) << 8; } } else { while (in < buf_size) { int n; n = buf[in++]; if (n & 0x80) s->sample[channel_number] -= s->sol_table[n & 0x7F]; else s->sample[channel_number] += s->sol_table[n & 0x7F]; s->sample[channel_number] = av_clip_int16(s->sample[channel_number]); output_samples[out++] = s->sample[channel_number]; /* toggle channel */ channel_number ^= s->channels - 1; } } break; } *data_size = out * sizeof(short); return buf_size; } #define DPCM_DECODER(id, name, long_name_) \ AVCodec name ## _decoder = { \ #name, \ AVMEDIA_TYPE_AUDIO, \ id, \ sizeof(DPCMContext), \ dpcm_decode_init, \ NULL, \ NULL, \ dpcm_decode_frame, \ .long_name = NULL_IF_CONFIG_SMALL(long_name_), \ }; DPCM_DECODER(CODEC_ID_INTERPLAY_DPCM, interplay_dpcm, "DPCM Interplay"); DPCM_DECODER(CODEC_ID_ROQ_DPCM, roq_dpcm, "DPCM id RoQ"); DPCM_DECODER(CODEC_ID_SOL_DPCM, sol_dpcm, "DPCM Sol"); DPCM_DECODER(CODEC_ID_XAN_DPCM, xan_dpcm, "DPCM Xan");
123linslouis-android-video-cutter
jni/libavcodec/dpcm.c
C
asf20
12,011
/* * Microsoft RLE decoder * Copyright (C) 2008 Konstantin Shishkov * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AVCODEC_MSRLEDEC_H #define AVCODEC_MSRLEDEC_H #include "avcodec.h" /** * Decodes stream in MS RLE format into frame. * * @param avctx codec context * @param pic destination frame * @param depth bit depth * @param data input stream * @param data_size input size */ int ff_msrle_decode(AVCodecContext *avctx, AVPicture *pic, int depth, const uint8_t* data, int data_size); #endif /* AVCODEC_MSRLEDEC_H */
123linslouis-android-video-cutter
jni/libavcodec/msrledec.h
C
asf20
1,296
/* * JPEG-LS decoder * Copyright (c) 2003 Michael Niedermayer * Copyright (c) 2006 Konstantin Shishkov * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * JPEG-LS decoder. */ #ifndef AVCODEC_JPEGLSDEC_H #define AVCODEC_JPEGLSDEC_H #include "mjpeg.h" #include "mjpegdec.h" /** * Decode LSE block with initialization parameters */ int ff_jpegls_decode_lse(MJpegDecodeContext *s); int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transform, int ilv); #endif /* AVCODEC_JPEGLSDEC_H */
123linslouis-android-video-cutter
jni/libavcodec/jpeglsdec.h
C
asf20
1,243
/* * DXVA2 HW acceleration * * copyright (c) 2010 Laurent Aimar * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AVCODEC_DXVA_INTERNAL_H #define AVCODEC_DXVA_INTERNAL_H #include "dxva2.h" #include "avcodec.h" #include "mpegvideo.h" void *ff_dxva2_get_surface(const Picture *picture); unsigned ff_dxva2_get_surface_index(const struct dxva_context *, const Picture *picture); int ff_dxva2_commit_buffer(AVCodecContext *, struct dxva_context *, DXVA2_DecodeBufferDesc *, unsigned type, const void *data, unsigned size, unsigned mb_count); int ff_dxva2_common_end_frame(AVCodecContext *, MpegEncContext *, const void *pp, unsigned pp_size, const void *qm, unsigned qm_size, int (*commit_bs_si)(AVCodecContext *, DXVA2_DecodeBufferDesc *bs, DXVA2_DecodeBufferDesc *slice)); #endif /* AVCODEC_DXVA_INTERNAL_H */
123linslouis-android-video-cutter
jni/libavcodec/dxva2_internal.h
C
asf20
1,846
/* * Electronic Arts TGV Video Decoder * Copyright (c) 2007-2008 Peter Ross * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * Electronic Arts TGV Video Decoder * by Peter Ross (pross@xvid.org) * * Technical details here: * http://wiki.multimedia.cx/index.php?title=Electronic_Arts_TGV */ #include "avcodec.h" #define ALT_BITSTREAM_READER_LE #include "get_bits.h" #include "libavutil/lzo.h" #define EA_PREAMBLE_SIZE 8 #define kVGT_TAG MKTAG('k', 'V', 'G', 'T') typedef struct TgvContext { AVCodecContext *avctx; AVFrame frame; AVFrame last_frame; int width,height; unsigned int palette[AVPALETTE_COUNT]; int (*mv_codebook)[2]; unsigned char (*block_codebook)[16]; int num_mvs; ///< current length of mv_codebook int num_blocks_packed; ///< current length of block_codebook } TgvContext; static av_cold int tgv_decode_init(AVCodecContext *avctx){ TgvContext *s = avctx->priv_data; s->avctx = avctx; avctx->time_base = (AVRational){1, 15}; avctx->pix_fmt = PIX_FMT_PAL8; return 0; } /** * Unpack buffer * @return 0 on success, -1 on critical buffer underflow */ static int unpack(const uint8_t *src, const uint8_t *src_end, unsigned char *dst, int width, int height) { unsigned char *dst_end = dst + width*height; int size, size1, size2, av_uninit(offset), run; unsigned char *dst_start = dst; if (src[0] & 0x01) src += 5; else src += 2; if (src+3>src_end) return -1; size = AV_RB24(src); src += 3; while(size>0 && src<src_end) { /* determine size1 and size2 */ size1 = (src[0] & 3); if ( src[0] & 0x80 ) { // 1 if (src[0] & 0x40 ) { // 11 if ( src[0] & 0x20 ) { // 111 if ( src[0] < 0xFC ) // !(111111) size1 = (((src[0] & 31) + 1) << 2); src++; size2 = 0; } else { // 110 offset = ((src[0] & 0x10) << 12) + AV_RB16(&src[1]) + 1; size2 = ((src[0] & 0xC) << 6) + src[3] + 5; src += 4; } } else { // 10 size1 = ( ( src[1] & 0xC0) >> 6 ); offset = (AV_RB16(&src[1]) & 0x3FFF) + 1; size2 = (src[0] & 0x3F) + 4; src += 3; } } else { // 0 offset = ((src[0] & 0x60) << 3) + src[1] + 1; size2 = ((src[0] & 0x1C) >> 2) + 3; src += 2; } /* fetch strip from src */ if (size1>src_end-src) break; if (size1>0) { size -= size1; run = FFMIN(size1, dst_end-dst); memcpy(dst, src, run); dst += run; src += run; } if (size2>0) { if (dst-dst_start<offset) return 0; size -= size2; run = FFMIN(size2, dst_end-dst); av_memcpy_backptr(dst, offset, run); dst += run; } } return 0; } /** * Decode inter-frame * @return 0 on success, -1 on critical buffer underflow */ static int tgv_decode_inter(TgvContext * s, const uint8_t *buf, const uint8_t *buf_end){ unsigned char *frame0_end = s->last_frame.data[0] + s->avctx->width*s->last_frame.linesize[0]; int num_mvs; int num_blocks_raw; int num_blocks_packed; int vector_bits; int i,j,x,y; GetBitContext gb; int mvbits; const unsigned char *blocks_raw; if(buf+12>buf_end) return -1; num_mvs = AV_RL16(&buf[0]); num_blocks_raw = AV_RL16(&buf[2]); num_blocks_packed = AV_RL16(&buf[4]); vector_bits = AV_RL16(&buf[6]); buf += 12; /* allocate codebook buffers as neccessary */ if (num_mvs > s->num_mvs) { s->mv_codebook = av_realloc(s->mv_codebook, num_mvs*2*sizeof(int)); s->num_mvs = num_mvs; } if (num_blocks_packed > s->num_blocks_packed) { s->block_codebook = av_realloc(s->block_codebook, num_blocks_packed*16*sizeof(unsigned char)); s->num_blocks_packed = num_blocks_packed; } /* read motion vectors */ mvbits = (num_mvs*2*10+31) & ~31; if (buf+(mvbits>>3)+16*num_blocks_raw+8*num_blocks_packed>buf_end) return -1; init_get_bits(&gb, buf, mvbits); for (i=0; i<num_mvs; i++) { s->mv_codebook[i][0] = get_sbits(&gb, 10); s->mv_codebook[i][1] = get_sbits(&gb, 10); } buf += mvbits>>3; /* note ptr to uncompressed blocks */ blocks_raw = buf; buf += num_blocks_raw*16; /* read compressed blocks */ init_get_bits(&gb, buf, (buf_end-buf)<<3); for (i=0; i<num_blocks_packed; i++) { int tmp[4]; for(j=0; j<4; j++) tmp[j] = get_bits(&gb, 8); for(j=0; j<16; j++) s->block_codebook[i][15-j] = tmp[get_bits(&gb, 2)]; } if (get_bits_left(&gb) < vector_bits * (s->avctx->height/4) * (s->avctx->width/4)) return -1; /* read vectors and build frame */ for(y=0; y<s->avctx->height/4; y++) for(x=0; x<s->avctx->width/4; x++) { unsigned int vector = get_bits(&gb, vector_bits); const unsigned char *src; int src_stride; if (vector < num_mvs) { src = s->last_frame.data[0] + (y*4 + s->mv_codebook[vector][1])*s->last_frame.linesize[0] + x*4 + s->mv_codebook[vector][0]; src_stride = s->last_frame.linesize[0]; if (src+3*src_stride+3>=frame0_end) continue; }else{ int offset = vector - num_mvs; if (offset<num_blocks_raw) src = blocks_raw + 16*offset; else if (offset-num_blocks_raw<num_blocks_packed) src = s->block_codebook[offset-num_blocks_raw]; else continue; src_stride = 4; } for(j=0; j<4; j++) for(i=0; i<4; i++) s->frame.data[0][ (y*4+j)*s->frame.linesize[0] + (x*4+i) ] = src[j*src_stride + i]; } return 0; } /** release AVFrame buffers if allocated */ static void cond_release_buffer(AVFrame *pic) { if (pic->data[0]) { av_freep(&pic->data[0]); av_free(pic->data[1]); } } static int tgv_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; TgvContext *s = avctx->priv_data; const uint8_t *buf_end = buf + buf_size; int chunk_type; chunk_type = AV_RL32(&buf[0]); buf += EA_PREAMBLE_SIZE; if (chunk_type==kVGT_TAG) { int pal_count, i; if(buf+12>buf_end) { av_log(avctx, AV_LOG_WARNING, "truncated header\n"); return -1; } s->width = AV_RL16(&buf[0]); s->height = AV_RL16(&buf[2]); if (s->avctx->width!=s->width || s->avctx->height!=s->height) { avcodec_set_dimensions(s->avctx, s->width, s->height); cond_release_buffer(&s->frame); cond_release_buffer(&s->last_frame); } pal_count = AV_RL16(&buf[6]); buf += 12; for(i=0; i<pal_count && i<AVPALETTE_COUNT && buf+2<buf_end; i++) { s->palette[i] = AV_RB24(buf); buf += 3; } } if (avcodec_check_dimensions(avctx, s->width, s->height)) return -1; /* shuffle */ FFSWAP(AVFrame, s->frame, s->last_frame); if (!s->frame.data[0]) { s->frame.reference = 1; s->frame.buffer_hints = FF_BUFFER_HINTS_VALID; s->frame.linesize[0] = s->width; /* allocate additional 12 bytes to accomodate av_memcpy_backptr() OUTBUF_PADDED optimisation */ s->frame.data[0] = av_malloc(s->width*s->height + 12); if (!s->frame.data[0]) return AVERROR(ENOMEM); s->frame.data[1] = av_malloc(AVPALETTE_SIZE); if (!s->frame.data[1]) { av_freep(&s->frame.data[0]); return AVERROR(ENOMEM); } } memcpy(s->frame.data[1], s->palette, AVPALETTE_SIZE); if(chunk_type==kVGT_TAG) { s->frame.key_frame = 1; s->frame.pict_type = FF_I_TYPE; if (unpack(buf, buf_end, s->frame.data[0], s->avctx->width, s->avctx->height)<0) { av_log(avctx, AV_LOG_WARNING, "truncated intra frame\n"); return -1; } }else{ if (!s->last_frame.data[0]) { av_log(avctx, AV_LOG_WARNING, "inter frame without corresponding intra frame\n"); return buf_size; } s->frame.key_frame = 0; s->frame.pict_type = FF_P_TYPE; if (tgv_decode_inter(s, buf, buf_end)<0) { av_log(avctx, AV_LOG_WARNING, "truncated inter frame\n"); return -1; } } *data_size = sizeof(AVFrame); *(AVFrame*)data = s->frame; return buf_size; } static av_cold int tgv_decode_end(AVCodecContext *avctx) { TgvContext *s = avctx->priv_data; cond_release_buffer(&s->frame); cond_release_buffer(&s->last_frame); av_free(s->mv_codebook); av_free(s->block_codebook); return 0; } AVCodec eatgv_decoder = { "eatgv", AVMEDIA_TYPE_VIDEO, CODEC_ID_TGV, sizeof(TgvContext), tgv_decode_init, NULL, tgv_decode_end, tgv_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("Electronic Arts TGV video"), };
123linslouis-android-video-cutter
jni/libavcodec/eatgv.c
C
asf20
10,279
/* * H.264/MPEG-4 Part 10 (Base profile) encoder. * * DSP functions * * Copyright (c) 2006 Expertisecentrum Digitale Media, UHasselt * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * H.264 encoder related DSP utils * */ #include "dsputil.h" #define H264_DCT_PART1(X) \ a = block[0][X]+block[3][X]; \ c = block[0][X]-block[3][X]; \ b = block[1][X]+block[2][X]; \ d = block[1][X]-block[2][X]; \ pieces[0][X] = a+b; \ pieces[2][X] = a-b; \ pieces[1][X] = (c<<1)+d; \ pieces[3][X] = c-(d<<1); #define H264_DCT_PART2(X) \ a = pieces[X][0]+pieces[X][3]; \ c = pieces[X][0]-pieces[X][3]; \ b = pieces[X][1]+pieces[X][2]; \ d = pieces[X][1]-pieces[X][2]; \ block[0][X] = a+b; \ block[2][X] = a-b; \ block[1][X] = (c<<1)+d; \ block[3][X] = c-(d<<1); /** * Transform the provided matrix using the H.264 modified DCT. * @note * we'll always work with transposed input blocks, to avoid having to make a * distinction between C and mmx implementations. * * @param block transposed input block */ static void h264_dct_c(DCTELEM block[4][4]) { DCTELEM pieces[4][4]; DCTELEM a, b, c, d; H264_DCT_PART1(0); H264_DCT_PART1(1); H264_DCT_PART1(2); H264_DCT_PART1(3); H264_DCT_PART2(0); H264_DCT_PART2(1); H264_DCT_PART2(2); H264_DCT_PART2(3); } av_cold void ff_h264dspenc_init(DSPContext* c, AVCodecContext *avctx) { c->h264_dct = h264_dct_c; }
123linslouis-android-video-cutter
jni/libavcodec/h264dspenc.c
C
asf20
2,231
/* * DSP functions for Indeo Video Interactive codecs (Indeo4 and Indeo5) * * Copyright (c) 2009 Maxim Poliakovski * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * DSP functions (inverse transforms, motion compensation, wavelet recompostions) * for Indeo Video Interactive codecs. */ #include "avcodec.h" #include "dsputil.h" #include "dwt.h" #include "ivi_common.h" #include "ivi_dsp.h" void ff_ivi_recompose53(const IVIPlaneDesc *plane, uint8_t *dst, const int dst_pitch, const int num_bands) { int x, y, indx; int32_t p0, p1, p2, p3, tmp0, tmp1, tmp2; int32_t b0_1, b0_2, b1_1, b1_2, b1_3, b2_1, b2_2, b2_3, b2_4, b2_5, b2_6; int32_t b3_1, b3_2, b3_3, b3_4, b3_5, b3_6, b3_7, b3_8, b3_9; int32_t pitch, back_pitch; const IDWTELEM *b0_ptr, *b1_ptr, *b2_ptr, *b3_ptr; /* all bands should have the same pitch */ pitch = plane->bands[0].pitch; /* pixels at the position "y-1" will be set to pixels at the "y" for the 1st iteration */ back_pitch = 0; /* get pointers to the wavelet bands */ b0_ptr = plane->bands[0].buf; b1_ptr = plane->bands[1].buf; b2_ptr = plane->bands[2].buf; b3_ptr = plane->bands[3].buf; for (y = 0; y < plane->height; y += 2) { /* load storage variables with values */ if (num_bands > 0) { b0_1 = b0_ptr[0]; b0_2 = b0_ptr[pitch]; } if (num_bands > 1) { b1_1 = b1_ptr[back_pitch]; b1_2 = b1_ptr[0]; b1_3 = b1_1 - b1_2*6 + b1_ptr[pitch]; } if (num_bands > 2) { b2_2 = b2_ptr[0]; // b2[x, y ] b2_3 = b2_2; // b2[x+1,y ] = b2[x,y] b2_5 = b2_ptr[pitch]; // b2[x ,y+1] b2_6 = b2_5; // b2[x+1,y+1] = b2[x,y+1] } if (num_bands > 3) { b3_2 = b3_ptr[back_pitch]; // b3[x ,y-1] b3_3 = b3_2; // b3[x+1,y-1] = b3[x ,y-1] b3_5 = b3_ptr[0]; // b3[x ,y ] b3_6 = b3_5; // b3[x+1,y ] = b3[x ,y ] b3_8 = b3_2 - b3_5*6 + b3_ptr[pitch]; b3_9 = b3_8; } for (x = 0, indx = 0; x < plane->width; x+=2, indx++) { /* some values calculated in the previous iterations can */ /* be reused in the next ones, so do appropriate copying */ b2_1 = b2_2; // b2[x-1,y ] = b2[x, y ] b2_2 = b2_3; // b2[x ,y ] = b2[x+1,y ] b2_4 = b2_5; // b2[x-1,y+1] = b2[x ,y+1] b2_5 = b2_6; // b2[x ,y+1] = b2[x+1,y+1] b3_1 = b3_2; // b3[x-1,y-1] = b3[x ,y-1] b3_2 = b3_3; // b3[x ,y-1] = b3[x+1,y-1] b3_4 = b3_5; // b3[x-1,y ] = b3[x ,y ] b3_5 = b3_6; // b3[x ,y ] = b3[x+1,y ] b3_7 = b3_8; // vert_HPF(x-1) b3_8 = b3_9; // vert_HPF(x ) p0 = p1 = p2 = p3 = 0; /* process the LL-band by applying LPF both vertically and horizontally */ if (num_bands > 0) { tmp0 = b0_1; tmp2 = b0_2; b0_1 = b0_ptr[indx+1]; b0_2 = b0_ptr[pitch+indx+1]; tmp1 = tmp0 + b0_1; p0 = tmp0 << 4; p1 = tmp1 << 3; p2 = (tmp0 + tmp2) << 3; p3 = (tmp1 + tmp2 + b0_2) << 2; } /* process the HL-band by applying HPF vertically and LPF horizontally */ if (num_bands > 1) { tmp0 = b1_2; tmp1 = b1_1; b1_2 = b1_ptr[indx+1]; b1_1 = b1_ptr[back_pitch+indx+1]; tmp2 = tmp1 - tmp0*6 + b1_3; b1_3 = b1_1 - b1_2*6 + b1_ptr[pitch+indx+1]; p0 += (tmp0 + tmp1) << 3; p1 += (tmp0 + tmp1 + b1_1 + b1_2) << 2; p2 += tmp2 << 2; p3 += (tmp2 + b1_3) << 1; } /* process the LH-band by applying LPF vertically and HPF horizontally */ if (num_bands > 2) { b2_3 = b2_ptr[indx+1]; b2_6 = b2_ptr[pitch+indx+1]; tmp0 = b2_1 + b2_2; tmp1 = b2_1 - b2_2*6 + b2_3; p0 += tmp0 << 3; p1 += tmp1 << 2; p2 += (tmp0 + b2_4 + b2_5) << 2; p3 += (tmp1 + b2_4 - b2_5*6 + b2_6) << 1; } /* process the HH-band by applying HPF both vertically and horizontally */ if (num_bands > 3) { b3_6 = b3_ptr[indx+1]; // b3[x+1,y ] b3_3 = b3_ptr[back_pitch+indx+1]; // b3[x+1,y-1] tmp0 = b3_1 + b3_4; tmp1 = b3_2 + b3_5; tmp2 = b3_3 + b3_6; b3_9 = b3_3 - b3_6*6 + b3_ptr[pitch+indx+1]; p0 += (tmp0 + tmp1) << 2; p1 += (tmp0 - tmp1*6 + tmp2) << 1; p2 += (b3_7 + b3_8) << 1; p3 += b3_7 - b3_8*6 + b3_9; } /* output four pixels */ dst[x] = av_clip_uint8((p0 >> 6) + 128); dst[x+1] = av_clip_uint8((p1 >> 6) + 128); dst[dst_pitch+x] = av_clip_uint8((p2 >> 6) + 128); dst[dst_pitch+x+1] = av_clip_uint8((p3 >> 6) + 128); }// for x dst += dst_pitch << 1; back_pitch = -pitch; b0_ptr += pitch; b1_ptr += pitch; b2_ptr += pitch; b3_ptr += pitch; } } /** butterfly operation for the inverse slant transform */ #define IVI_SLANT_BFLY(s1, s2, o1, o2, t) \ t = s1 - s2;\ o1 = s1 + s2;\ o2 = t;\ /** This is a reflection a,b = 1/2, 5/4 for the inverse slant transform */ #define IVI_IREFLECT(s1, s2, o1, o2, t) \ t = ((s1 + s2*2 + 2) >> 2) + s1;\ o2 = ((s1*2 - s2 + 2) >> 2) - s2;\ o1 = t;\ /** This is a reflection a,b = 1/2, 7/8 for the inverse slant transform */ #define IVI_SLANT_PART4(s1, s2, o1, o2, t) \ t = s2 + ((s1*4 - s2 + 4) >> 3);\ o2 = s1 + ((-s1 - s2*4 + 4) >> 3);\ o1 = t;\ /** inverse slant8 transform */ #define IVI_INV_SLANT8(s1, s4, s8, s5, s2, s6, s3, s7,\ d1, d2, d3, d4, d5, d6, d7, d8,\ t0, t1, t2, t3, t4, t5, t6, t7, t8) {\ IVI_SLANT_PART4(s4, s5, t4, t5, t0);\ \ IVI_SLANT_BFLY(s1, t5, t1, t5, t0); IVI_SLANT_BFLY(s2, s6, t2, t6, t0);\ IVI_SLANT_BFLY(s7, s3, t7, t3, t0); IVI_SLANT_BFLY(t4, s8, t4, t8, t0);\ \ IVI_SLANT_BFLY(t1, t2, t1, t2, t0); IVI_IREFLECT (t4, t3, t4, t3, t0);\ IVI_SLANT_BFLY(t5, t6, t5, t6, t0); IVI_IREFLECT (t8, t7, t8, t7, t0);\ IVI_SLANT_BFLY(t1, t4, t1, t4, t0); IVI_SLANT_BFLY(t2, t3, t2, t3, t0);\ IVI_SLANT_BFLY(t5, t8, t5, t8, t0); IVI_SLANT_BFLY(t6, t7, t6, t7, t0);\ d1 = COMPENSATE(t1);\ d2 = COMPENSATE(t2);\ d3 = COMPENSATE(t3);\ d4 = COMPENSATE(t4);\ d5 = COMPENSATE(t5);\ d6 = COMPENSATE(t6);\ d7 = COMPENSATE(t7);\ d8 = COMPENSATE(t8);} /** inverse slant4 transform */ #define IVI_INV_SLANT4(s1, s4, s2, s3, d1, d2, d3, d4, t0, t1, t2, t3, t4) {\ IVI_SLANT_BFLY(s1, s2, t1, t2, t0); IVI_IREFLECT (s4, s3, t4, t3, t0);\ \ IVI_SLANT_BFLY(t1, t4, t1, t4, t0); IVI_SLANT_BFLY(t2, t3, t2, t3, t0);\ d1 = COMPENSATE(t1);\ d2 = COMPENSATE(t2);\ d3 = COMPENSATE(t3);\ d4 = COMPENSATE(t4);} void ff_ivi_inverse_slant_8x8(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags) { int i; const int32_t *src; int32_t *dst; int tmp[64]; int t0, t1, t2, t3, t4, t5, t6, t7, t8; #define COMPENSATE(x) (x) src = in; dst = tmp; for (i = 0; i < 8; i++) { if (flags[i]) { IVI_INV_SLANT8(src[0], src[8], src[16], src[24], src[32], src[40], src[48], src[56], dst[0], dst[8], dst[16], dst[24], dst[32], dst[40], dst[48], dst[56], t0, t1, t2, t3, t4, t5, t6, t7, t8); } else dst[0] = dst[8] = dst[16] = dst[24] = dst[32] = dst[40] = dst[48] = dst[56] = 0; src++; dst++; } #undef COMPENSATE #define COMPENSATE(x) ((x + 1)>>1) src = tmp; for (i = 0; i < 8; i++) { if (!src[0] && !src[1] && !src[2] && !src[3] && !src[4] && !src[5] && !src[6] && !src[7]) { memset(out, 0, 8*sizeof(out[0])); } else { IVI_INV_SLANT8(src[0], src[1], src[2], src[3], src[4], src[5], src[6], src[7], out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7], t0, t1, t2, t3, t4, t5, t6, t7, t8); } src += 8; out += pitch; } #undef COMPENSATE } void ff_ivi_inverse_slant_4x4(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags) { int i; const int32_t *src; int32_t *dst; int tmp[16]; int t0, t1, t2, t3, t4; #define COMPENSATE(x) (x) src = in; dst = tmp; for (i = 0; i < 4; i++) { if (flags[i]) { IVI_INV_SLANT4(src[0], src[4], src[8], src[12], dst[0], dst[4], dst[8], dst[12], t0, t1, t2, t3, t4); } else dst[0] = dst[4] = dst[8] = dst[12] = 0; src++; dst++; } #undef COMPENSATE #define COMPENSATE(x) ((x + 1)>>1) src = tmp; for (i = 0; i < 4; i++) { if (!src[0] && !src[1] && !src[2] && !src[3]) { out[0] = out[1] = out[2] = out[3] = 0; } else { IVI_INV_SLANT4(src[0], src[1], src[2], src[3], out[0], out[1], out[2], out[3], t0, t1, t2, t3, t4); } src += 4; out += pitch; } #undef COMPENSATE } void ff_ivi_dc_slant_2d(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size) { int x, y; int16_t dc_coeff; dc_coeff = (*in + 1) >> 1; for (y = 0; y < blk_size; out += pitch, y++) { for (x = 0; x < blk_size; x++) out[x] = dc_coeff; } } void ff_ivi_row_slant8(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags) { int i; int t0, t1, t2, t3, t4, t5, t6, t7, t8; #define COMPENSATE(x) ((x + 1)>>1) for (i = 0; i < 8; i++) { if (!in[0] && !in[1] && !in[2] && !in[3] && !in[4] && !in[5] && !in[6] && !in[7]) { memset(out, 0, 8*sizeof(out[0])); } else { IVI_INV_SLANT8( in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7], out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7], t0, t1, t2, t3, t4, t5, t6, t7, t8); } in += 8; out += pitch; } #undef COMPENSATE } void ff_ivi_dc_row_slant(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size) { int x, y; int16_t dc_coeff; dc_coeff = (*in + 1) >> 1; for (x = 0; x < blk_size; x++) out[x] = dc_coeff; out += pitch; for (y = 1; y < blk_size; out += pitch, y++) { for (x = 0; x < blk_size; x++) out[x] = 0; } } void ff_ivi_col_slant8(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags) { int i, row2, row4, row8; int t0, t1, t2, t3, t4, t5, t6, t7, t8; row2 = pitch << 1; row4 = pitch << 2; row8 = pitch << 3; #define COMPENSATE(x) ((x + 1)>>1) for (i = 0; i < 8; i++) { if (flags[i]) { IVI_INV_SLANT8(in[0], in[8], in[16], in[24], in[32], in[40], in[48], in[56], out[0], out[pitch], out[row2], out[row2 + pitch], out[row4], out[row4 + pitch], out[row4 + row2], out[row8 - pitch], t0, t1, t2, t3, t4, t5, t6, t7, t8); } else { out[0] = out[pitch] = out[row2] = out[row2 + pitch] = out[row4] = out[row4 + pitch] = out[row4 + row2] = out[row8 - pitch] = 0; } in++; out++; } #undef COMPENSATE } void ff_ivi_dc_col_slant(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size) { int x, y; int16_t dc_coeff; dc_coeff = (*in + 1) >> 1; for (y = 0; y < blk_size; out += pitch, y++) { out[0] = dc_coeff; for (x = 1; x < blk_size; x++) out[x] = 0; } } void ff_ivi_put_pixels_8x8(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags) { int x, y; for (y = 0; y < 8; out += pitch, in += 8, y++) for (x = 0; x < 8; x++) out[x] = in[x]; } void ff_ivi_put_dc_pixel_8x8(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size) { int y; out[0] = in[0]; memset(out + 1, 0, 7*sizeof(out[0])); out += pitch; for (y = 1; y < 8; out += pitch, y++) memset(out, 0, 8*sizeof(out[0])); } #define IVI_MC_TEMPLATE(size, suffix, OP) \ void ff_ivi_mc_ ## size ##x## size ## suffix (int16_t *buf, const int16_t *ref_buf, \ uint32_t pitch, int mc_type) \ { \ int i, j; \ const int16_t *wptr; \ \ switch (mc_type) { \ case 0: /* fullpel (no interpolation) */ \ for (i = 0; i < size; i++, buf += pitch, ref_buf += pitch) { \ for (j = 0; j < size; j++) {\ OP(buf[j], ref_buf[j]); \ } \ } \ break; \ case 1: /* horizontal halfpel interpolation */ \ for (i = 0; i < size; i++, buf += pitch, ref_buf += pitch) \ for (j = 0; j < size; j++) \ OP(buf[j], (ref_buf[j] + ref_buf[j+1]) >> 1); \ break; \ case 2: /* vertical halfpel interpolation */ \ wptr = ref_buf + pitch; \ for (i = 0; i < size; i++, buf += pitch, wptr += pitch, ref_buf += pitch) \ for (j = 0; j < size; j++) \ OP(buf[j], (ref_buf[j] + wptr[j]) >> 1); \ break; \ case 3: /* vertical and horizontal halfpel interpolation */ \ wptr = ref_buf + pitch; \ for (i = 0; i < size; i++, buf += pitch, wptr += pitch, ref_buf += pitch) \ for (j = 0; j < size; j++) \ OP(buf[j], (ref_buf[j] + ref_buf[j+1] + wptr[j] + wptr[j+1]) >> 2); \ break; \ } \ } \ #define OP_PUT(a, b) (a) = (b) #define OP_ADD(a, b) (a) += (b) IVI_MC_TEMPLATE(8, _no_delta, OP_PUT); IVI_MC_TEMPLATE(8, _delta, OP_ADD); IVI_MC_TEMPLATE(4, _no_delta, OP_PUT); IVI_MC_TEMPLATE(4, _delta, OP_ADD);
123linslouis-android-video-cutter
jni/libavcodec/ivi_dsp.c
C
asf20
15,366
/* * V210 decoder * * Copyright (C) 2009 Michael Niedermayer <michaelni@gmx.at> * Copyright (c) 2009 Baptiste Coudurier <baptiste dot coudurier at gmail dot com> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avcodec.h" #include "libavutil/bswap.h" static av_cold int decode_init(AVCodecContext *avctx) { if (avctx->width & 1) { av_log(avctx, AV_LOG_ERROR, "v210 needs even width\n"); return -1; } avctx->pix_fmt = PIX_FMT_YUV422P16; avctx->bits_per_raw_sample = 10; avctx->coded_frame = avcodec_alloc_frame(); return 0; } static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { int h, w; AVFrame *pic = avctx->coded_frame; const uint8_t *psrc = avpkt->data; uint16_t *y, *u, *v; int aligned_width = ((avctx->width + 47) / 48) * 48; int stride = aligned_width * 8 / 3; if (pic->data[0]) avctx->release_buffer(avctx, pic); if (avpkt->size < stride * avctx->height) { av_log(avctx, AV_LOG_ERROR, "packet too small\n"); return -1; } pic->reference = 0; if (avctx->get_buffer(avctx, pic) < 0) return -1; y = (uint16_t*)pic->data[0]; u = (uint16_t*)pic->data[1]; v = (uint16_t*)pic->data[2]; pic->pict_type = FF_I_TYPE; pic->key_frame = 1; #define READ_PIXELS(a, b, c) \ do { \ val = le2me_32(*src++); \ *a++ = val << 6; \ *b++ = (val >> 4) & 0xFFC0; \ *c++ = (val >> 14) & 0xFFC0; \ } while (0) for (h = 0; h < avctx->height; h++) { const uint32_t *src = (const uint32_t*)psrc; uint32_t val; for (w = 0; w < avctx->width - 5; w += 6) { READ_PIXELS(u, y, v); READ_PIXELS(y, u, y); READ_PIXELS(v, y, u); READ_PIXELS(y, v, y); } if (w < avctx->width - 1) { READ_PIXELS(u, y, v); val = le2me_32(*src++); *y++ = val << 6; } if (w < avctx->width - 3) { *u++ = (val >> 4) & 0xFFC0; *y++ = (val >> 14) & 0xFFC0; val = le2me_32(*src++); *v++ = val << 6; *y++ = (val >> 4) & 0xFFC0; } psrc += stride; y += pic->linesize[0] / 2 - avctx->width; u += pic->linesize[1] / 2 - avctx->width / 2; v += pic->linesize[2] / 2 - avctx->width / 2; } *data_size = sizeof(AVFrame); *(AVFrame*)data = *avctx->coded_frame; return avpkt->size; } static av_cold int decode_close(AVCodecContext *avctx) { AVFrame *pic = avctx->coded_frame; if (pic->data[0]) avctx->release_buffer(avctx, pic); av_freep(&avctx->coded_frame); return 0; } AVCodec v210_decoder = { "v210", AVMEDIA_TYPE_VIDEO, CODEC_ID_V210, 0, decode_init, NULL, decode_close, decode_frame, CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:2:2 10-bit"), };
123linslouis-android-video-cutter
jni/libavcodec/v210dec.c
C
asf20
3,795
/* * audio resampling * Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * audio resampling * @author Michael Niedermayer <michaelni@gmx.at> */ #include "avcodec.h" #include "dsputil.h" #ifndef CONFIG_RESAMPLE_HP #define FILTER_SHIFT 15 #define FELEM int16_t #define FELEM2 int32_t #define FELEML int64_t #define FELEM_MAX INT16_MAX #define FELEM_MIN INT16_MIN #define WINDOW_TYPE 9 #elif !defined(CONFIG_RESAMPLE_AUDIOPHILE_KIDDY_MODE) #define FILTER_SHIFT 30 #define FELEM int32_t #define FELEM2 int64_t #define FELEML int64_t #define FELEM_MAX INT32_MAX #define FELEM_MIN INT32_MIN #define WINDOW_TYPE 12 #else #define FILTER_SHIFT 0 #define FELEM double #define FELEM2 double #define FELEML double #define WINDOW_TYPE 24 #endif typedef struct AVResampleContext{ const AVClass *av_class; FELEM *filter_bank; int filter_length; int ideal_dst_incr; int dst_incr; int index; int frac; int src_incr; int compensation_distance; int phase_shift; int phase_mask; int linear; }AVResampleContext; /** * 0th order modified bessel function of the first kind. */ static double bessel(double x){ double v=1; double lastv=0; double t=1; int i; x= x*x/4; for(i=1; v != lastv; i++){ lastv=v; t *= x/(i*i); v += t; } return v; } /** * builds a polyphase filterbank. * @param factor resampling factor * @param scale wanted sum of coefficients for each filter * @param type 0->cubic, 1->blackman nuttall windowed sinc, 2..16->kaiser windowed sinc beta=2..16 */ static void build_filter(FELEM *filter, double factor, int tap_count, int phase_count, int scale, int type){ int ph, i; double x, y, w, tab[tap_count]; const int center= (tap_count-1)/2; /* if upsampling, only need to interpolate, no filter */ if (factor > 1.0) factor = 1.0; for(ph=0;ph<phase_count;ph++) { double norm = 0; for(i=0;i<tap_count;i++) { x = M_PI * ((double)(i - center) - (double)ph / phase_count) * factor; if (x == 0) y = 1.0; else y = sin(x) / x; switch(type){ case 0:{ const float d= -0.5; //first order derivative = -0.5 x = fabs(((double)(i - center) - (double)ph / phase_count) * factor); if(x<1.0) y= 1 - 3*x*x + 2*x*x*x + d*( -x*x + x*x*x); else y= d*(-4 + 8*x - 5*x*x + x*x*x); break;} case 1: w = 2.0*x / (factor*tap_count) + M_PI; y *= 0.3635819 - 0.4891775 * cos(w) + 0.1365995 * cos(2*w) - 0.0106411 * cos(3*w); break; default: w = 2.0*x / (factor*tap_count*M_PI); y *= bessel(type*sqrt(FFMAX(1-w*w, 0))); break; } tab[i] = y; norm += y; } /* normalize so that an uniform color remains the same */ for(i=0;i<tap_count;i++) { #ifdef CONFIG_RESAMPLE_AUDIOPHILE_KIDDY_MODE filter[ph * tap_count + i] = tab[i] / norm; #else filter[ph * tap_count + i] = av_clip(lrintf(tab[i] * scale / norm), FELEM_MIN, FELEM_MAX); #endif } } #if 0 { #define LEN 1024 int j,k; double sine[LEN + tap_count]; double filtered[LEN]; double maxff=-2, minff=2, maxsf=-2, minsf=2; for(i=0; i<LEN; i++){ double ss=0, sf=0, ff=0; for(j=0; j<LEN+tap_count; j++) sine[j]= cos(i*j*M_PI/LEN); for(j=0; j<LEN; j++){ double sum=0; ph=0; for(k=0; k<tap_count; k++) sum += filter[ph * tap_count + k] * sine[k+j]; filtered[j]= sum / (1<<FILTER_SHIFT); ss+= sine[j + center] * sine[j + center]; ff+= filtered[j] * filtered[j]; sf+= sine[j + center] * filtered[j]; } ss= sqrt(2*ss/LEN); ff= sqrt(2*ff/LEN); sf= 2*sf/LEN; maxff= FFMAX(maxff, ff); minff= FFMIN(minff, ff); maxsf= FFMAX(maxsf, sf); minsf= FFMIN(minsf, sf); if(i%11==0){ av_log(NULL, AV_LOG_ERROR, "i:%4d ss:%f ff:%13.6e-%13.6e sf:%13.6e-%13.6e\n", i, ss, maxff, minff, maxsf, minsf); minff=minsf= 2; maxff=maxsf= -2; } } } #endif } AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_size, int phase_shift, int linear, double cutoff){ AVResampleContext *c= av_mallocz(sizeof(AVResampleContext)); double factor= FFMIN(out_rate * cutoff / in_rate, 1.0); int phase_count= 1<<phase_shift; c->phase_shift= phase_shift; c->phase_mask= phase_count-1; c->linear= linear; c->filter_length= FFMAX((int)ceil(filter_size/factor), 1); c->filter_bank= av_mallocz(c->filter_length*(phase_count+1)*sizeof(FELEM)); build_filter(c->filter_bank, factor, c->filter_length, phase_count, 1<<FILTER_SHIFT, WINDOW_TYPE); memcpy(&c->filter_bank[c->filter_length*phase_count+1], c->filter_bank, (c->filter_length-1)*sizeof(FELEM)); c->filter_bank[c->filter_length*phase_count]= c->filter_bank[c->filter_length - 1]; c->src_incr= out_rate; c->ideal_dst_incr= c->dst_incr= in_rate * phase_count; c->index= -phase_count*((c->filter_length-1)/2); return c; } void av_resample_close(AVResampleContext *c){ av_freep(&c->filter_bank); av_freep(&c); } void av_resample_compensate(AVResampleContext *c, int sample_delta, int compensation_distance){ // sample_delta += (c->ideal_dst_incr - c->dst_incr)*(int64_t)c->compensation_distance / c->ideal_dst_incr; c->compensation_distance= compensation_distance; c->dst_incr = c->ideal_dst_incr - c->ideal_dst_incr * (int64_t)sample_delta / compensation_distance; } int av_resample(AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx){ int dst_index, i; int index= c->index; int frac= c->frac; int dst_incr_frac= c->dst_incr % c->src_incr; int dst_incr= c->dst_incr / c->src_incr; int compensation_distance= c->compensation_distance; if(compensation_distance == 0 && c->filter_length == 1 && c->phase_shift==0){ int64_t index2= ((int64_t)index)<<32; int64_t incr= (1LL<<32) * c->dst_incr / c->src_incr; dst_size= FFMIN(dst_size, (src_size-1-index) * (int64_t)c->src_incr / c->dst_incr); for(dst_index=0; dst_index < dst_size; dst_index++){ dst[dst_index] = src[index2>>32]; index2 += incr; } frac += dst_index * dst_incr_frac; index += dst_index * dst_incr; index += frac / c->src_incr; frac %= c->src_incr; }else{ for(dst_index=0; dst_index < dst_size; dst_index++){ FELEM *filter= c->filter_bank + c->filter_length*(index & c->phase_mask); int sample_index= index >> c->phase_shift; FELEM2 val=0; if(sample_index < 0){ for(i=0; i<c->filter_length; i++) val += src[FFABS(sample_index + i) % src_size] * filter[i]; }else if(sample_index + c->filter_length > src_size){ break; }else if(c->linear){ FELEM2 v2=0; for(i=0; i<c->filter_length; i++){ val += src[sample_index + i] * (FELEM2)filter[i]; v2 += src[sample_index + i] * (FELEM2)filter[i + c->filter_length]; } val+=(v2-val)*(FELEML)frac / c->src_incr; }else{ for(i=0; i<c->filter_length; i++){ val += src[sample_index + i] * (FELEM2)filter[i]; } } #ifdef CONFIG_RESAMPLE_AUDIOPHILE_KIDDY_MODE dst[dst_index] = av_clip_int16(lrintf(val)); #else val = (val + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT; dst[dst_index] = (unsigned)(val + 32768) > 65535 ? (val>>31) ^ 32767 : val; #endif frac += dst_incr_frac; index += dst_incr; if(frac >= c->src_incr){ frac -= c->src_incr; index++; } if(dst_index + 1 == compensation_distance){ compensation_distance= 0; dst_incr_frac= c->ideal_dst_incr % c->src_incr; dst_incr= c->ideal_dst_incr / c->src_incr; } } } *consumed= FFMAX(index, 0) >> c->phase_shift; if(index>=0) index &= c->phase_mask; if(compensation_distance){ compensation_distance -= dst_index; assert(compensation_distance > 0); } if(update_ctx){ c->frac= frac; c->index= index; c->dst_incr= dst_incr_frac + c->src_incr*dst_incr; c->compensation_distance= compensation_distance; } #if 0 if(update_ctx && !c->compensation_distance){ #undef rand av_resample_compensate(c, rand() % (8000*2) - 8000, 8000*2); av_log(NULL, AV_LOG_DEBUG, "%d %d %d\n", c->dst_incr, c->ideal_dst_incr, c->compensation_distance); } #endif return dst_index; }
123linslouis-android-video-cutter
jni/libavcodec/resample2.c
C
asf20
9,925
/* * CGA ROM data * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AVCODEC_CGA_DATA_H #define AVCODEC_CGA_DATA_H #include <stdint.h> extern const uint8_t ff_cga_font[2048]; extern const uint32_t ff_cga_palette[16]; #endif
123linslouis-android-video-cutter
jni/libavcodec/cga_data.h
C
asf20
949
/* * RV30/40 decoder common data * Copyright (c) 2007 Mike Melanson, Konstantin Shishkov * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * RV30/40 decoder common data */ #include "avcodec.h" #include "dsputil.h" #include "mpegvideo.h" #include "golomb.h" #include "mathops.h" #include "rectangle.h" #include "rv34vlc.h" #include "rv34data.h" #include "rv34.h" //#define DEBUG static inline void ZERO8x2(void* dst, int stride) { fill_rectangle(dst, 1, 2, stride, 0, 4); fill_rectangle(((uint8_t*)(dst))+4, 1, 2, stride, 0, 4); } /** translation of RV30/40 macroblock types to lavc ones */ static const int rv34_mb_type_to_lavc[12] = { MB_TYPE_INTRA, MB_TYPE_INTRA16x16 | MB_TYPE_SEPARATE_DC, MB_TYPE_16x16 | MB_TYPE_L0, MB_TYPE_8x8 | MB_TYPE_L0, MB_TYPE_16x16 | MB_TYPE_L0, MB_TYPE_16x16 | MB_TYPE_L1, MB_TYPE_SKIP, MB_TYPE_DIRECT2 | MB_TYPE_16x16, MB_TYPE_16x8 | MB_TYPE_L0, MB_TYPE_8x16 | MB_TYPE_L0, MB_TYPE_16x16 | MB_TYPE_L0L1, MB_TYPE_16x16 | MB_TYPE_L0 | MB_TYPE_SEPARATE_DC }; static RV34VLC intra_vlcs[NUM_INTRA_TABLES], inter_vlcs[NUM_INTER_TABLES]; /** * @defgroup vlc RV30/40 VLC generating functions * @{ */ static const int table_offs[] = { 0, 1818, 3622, 4144, 4698, 5234, 5804, 5868, 5900, 5932, 5996, 6252, 6316, 6348, 6380, 7674, 8944, 10274, 11668, 12250, 14060, 15846, 16372, 16962, 17512, 18148, 18180, 18212, 18244, 18308, 18564, 18628, 18660, 18692, 20036, 21314, 22648, 23968, 24614, 26384, 28190, 28736, 29366, 29938, 30608, 30640, 30672, 30704, 30768, 31024, 31088, 31120, 31184, 32570, 33898, 35236, 36644, 37286, 39020, 40802, 41368, 42052, 42692, 43348, 43380, 43412, 43444, 43476, 43604, 43668, 43700, 43732, 45100, 46430, 47778, 49160, 49802, 51550, 53340, 53972, 54648, 55348, 55994, 56122, 56154, 56186, 56218, 56346, 56410, 56442, 56474, 57878, 59290, 60636, 62036, 62682, 64460, 64524, 64588, 64716, 64844, 66076, 67466, 67978, 68542, 69064, 69648, 70296, 72010, 72074, 72138, 72202, 72330, 73572, 74936, 75454, 76030, 76566, 77176, 77822, 79582, 79646, 79678, 79742, 79870, 81180, 82536, 83064, 83672, 84242, 84934, 85576, 87384, 87448, 87480, 87544, 87672, 88982, 90340, 90902, 91598, 92182, 92846, 93488, 95246, 95278, 95310, 95374, 95502, 96878, 98266, 98848, 99542, 100234, 100884, 101524, 103320, 103352, 103384, 103416, 103480, 104874, 106222, 106910, 107584, 108258, 108902, 109544, 111366, 111398, 111430, 111462, 111494, 112878, 114320, 114988, 115660, 116310, 116950, 117592 }; static VLC_TYPE table_data[117592][2]; /** * Generate VLC from codeword lengths. * @param bits codeword lengths (zeroes are accepted) * @param size length of input data * @param vlc output VLC * @param insyms symbols for input codes (NULL for default ones) * @param num VLC table number (for static initialization) */ static void rv34_gen_vlc(const uint8_t *bits, int size, VLC *vlc, const uint8_t *insyms, const int num) { int i; int counts[17] = {0}, codes[17]; uint16_t cw[size], syms[size]; uint8_t bits2[size]; int maxbits = 0, realsize = 0; for(i = 0; i < size; i++){ if(bits[i]){ bits2[realsize] = bits[i]; syms[realsize] = insyms ? insyms[i] : i; realsize++; maxbits = FFMAX(maxbits, bits[i]); counts[bits[i]]++; } } codes[0] = 0; for(i = 0; i < 16; i++) codes[i+1] = (codes[i] + counts[i]) << 1; for(i = 0; i < realsize; i++) cw[i] = codes[bits2[i]]++; vlc->table = &table_data[table_offs[num]]; vlc->table_allocated = table_offs[num + 1] - table_offs[num]; init_vlc_sparse(vlc, FFMIN(maxbits, 9), realsize, bits2, 1, 1, cw, 2, 2, syms, 2, 2, INIT_VLC_USE_NEW_STATIC); } /** * Initialize all tables. */ static av_cold void rv34_init_tables(void) { int i, j, k; for(i = 0; i < NUM_INTRA_TABLES; i++){ for(j = 0; j < 2; j++){ rv34_gen_vlc(rv34_table_intra_cbppat [i][j], CBPPAT_VLC_SIZE, &intra_vlcs[i].cbppattern[j], NULL, 19*i + 0 + j); rv34_gen_vlc(rv34_table_intra_secondpat[i][j], OTHERBLK_VLC_SIZE, &intra_vlcs[i].second_pattern[j], NULL, 19*i + 2 + j); rv34_gen_vlc(rv34_table_intra_thirdpat [i][j], OTHERBLK_VLC_SIZE, &intra_vlcs[i].third_pattern[j], NULL, 19*i + 4 + j); for(k = 0; k < 4; k++){ rv34_gen_vlc(rv34_table_intra_cbp[i][j+k*2], CBP_VLC_SIZE, &intra_vlcs[i].cbp[j][k], rv34_cbp_code, 19*i + 6 + j*4 + k); } } for(j = 0; j < 4; j++){ rv34_gen_vlc(rv34_table_intra_firstpat[i][j], FIRSTBLK_VLC_SIZE, &intra_vlcs[i].first_pattern[j], NULL, 19*i + 14 + j); } rv34_gen_vlc(rv34_intra_coeff[i], COEFF_VLC_SIZE, &intra_vlcs[i].coefficient, NULL, 19*i + 18); } for(i = 0; i < NUM_INTER_TABLES; i++){ rv34_gen_vlc(rv34_inter_cbppat[i], CBPPAT_VLC_SIZE, &inter_vlcs[i].cbppattern[0], NULL, i*12 + 95); for(j = 0; j < 4; j++){ rv34_gen_vlc(rv34_inter_cbp[i][j], CBP_VLC_SIZE, &inter_vlcs[i].cbp[0][j], rv34_cbp_code, i*12 + 96 + j); } for(j = 0; j < 2; j++){ rv34_gen_vlc(rv34_table_inter_firstpat [i][j], FIRSTBLK_VLC_SIZE, &inter_vlcs[i].first_pattern[j], NULL, i*12 + 100 + j); rv34_gen_vlc(rv34_table_inter_secondpat[i][j], OTHERBLK_VLC_SIZE, &inter_vlcs[i].second_pattern[j], NULL, i*12 + 102 + j); rv34_gen_vlc(rv34_table_inter_thirdpat [i][j], OTHERBLK_VLC_SIZE, &inter_vlcs[i].third_pattern[j], NULL, i*12 + 104 + j); } rv34_gen_vlc(rv34_inter_coeff[i], COEFF_VLC_SIZE, &inter_vlcs[i].coefficient, NULL, i*12 + 106); } } /** @} */ // vlc group /** * @defgroup transform RV30/40 inverse transform functions * @{ */ static av_always_inline void rv34_row_transform(int temp[16], DCTELEM *block) { int i; for(i=0; i<4; i++){ const int z0= 13*(block[i+8*0] + block[i+8*2]); const int z1= 13*(block[i+8*0] - block[i+8*2]); const int z2= 7* block[i+8*1] - 17*block[i+8*3]; const int z3= 17* block[i+8*1] + 7*block[i+8*3]; temp[4*i+0]= z0+z3; temp[4*i+1]= z1+z2; temp[4*i+2]= z1-z2; temp[4*i+3]= z0-z3; } } /** * Real Video 3.0/4.0 inverse transform * Code is almost the same as in SVQ3, only scaling is different. */ static void rv34_inv_transform(DCTELEM *block){ int temp[16]; int i; rv34_row_transform(temp, block); for(i=0; i<4; i++){ const int z0= 13*(temp[4*0+i] + temp[4*2+i]) + 0x200; const int z1= 13*(temp[4*0+i] - temp[4*2+i]) + 0x200; const int z2= 7* temp[4*1+i] - 17*temp[4*3+i]; const int z3= 17* temp[4*1+i] + 7*temp[4*3+i]; block[i*8+0]= (z0 + z3)>>10; block[i*8+1]= (z1 + z2)>>10; block[i*8+2]= (z1 - z2)>>10; block[i*8+3]= (z0 - z3)>>10; } } /** * RealVideo 3.0/4.0 inverse transform for DC block * * Code is almost the same as rv34_inv_transform() * but final coefficients are multiplied by 1.5 and have no rounding. */ static void rv34_inv_transform_noround(DCTELEM *block){ int temp[16]; int i; rv34_row_transform(temp, block); for(i=0; i<4; i++){ const int z0= 13*(temp[4*0+i] + temp[4*2+i]); const int z1= 13*(temp[4*0+i] - temp[4*2+i]); const int z2= 7* temp[4*1+i] - 17*temp[4*3+i]; const int z3= 17* temp[4*1+i] + 7*temp[4*3+i]; block[i*8+0]= ((z0 + z3)*3)>>11; block[i*8+1]= ((z1 + z2)*3)>>11; block[i*8+2]= ((z1 - z2)*3)>>11; block[i*8+3]= ((z0 - z3)*3)>>11; } } /** @} */ // transform /** * @defgroup block RV30/40 4x4 block decoding functions * @{ */ /** * Decode coded block pattern. */ static int rv34_decode_cbp(GetBitContext *gb, RV34VLC *vlc, int table) { int pattern, code, cbp=0; int ones; static const int cbp_masks[3] = {0x100000, 0x010000, 0x110000}; static const int shifts[4] = { 0, 2, 8, 10 }; const int *curshift = shifts; int i, t, mask; code = get_vlc2(gb, vlc->cbppattern[table].table, 9, 2); pattern = code & 0xF; code >>= 4; ones = rv34_count_ones[pattern]; for(mask = 8; mask; mask >>= 1, curshift++){ if(pattern & mask) cbp |= get_vlc2(gb, vlc->cbp[table][ones].table, vlc->cbp[table][ones].bits, 1) << curshift[0]; } for(i = 0; i < 4; i++){ t = modulo_three_table[code][i]; if(t == 1) cbp |= cbp_masks[get_bits1(gb)] << i; if(t == 2) cbp |= cbp_masks[2] << i; } return cbp; } /** * Get one coefficient value from the bistream and store it. */ static inline void decode_coeff(DCTELEM *dst, int coef, int esc, GetBitContext *gb, VLC* vlc) { if(coef){ if(coef == esc){ coef = get_vlc2(gb, vlc->table, 9, 2); if(coef > 23){ coef -= 23; coef = 22 + ((1 << coef) | get_bits(gb, coef)); } coef += esc; } if(get_bits1(gb)) coef = -coef; *dst = coef; } } /** * Decode 2x2 subblock of coefficients. */ static inline void decode_subblock(DCTELEM *dst, int code, const int is_block2, GetBitContext *gb, VLC *vlc) { int coeffs[4]; coeffs[0] = modulo_three_table[code][0]; coeffs[1] = modulo_three_table[code][1]; coeffs[2] = modulo_three_table[code][2]; coeffs[3] = modulo_three_table[code][3]; decode_coeff(dst , coeffs[0], 3, gb, vlc); if(is_block2){ decode_coeff(dst+8, coeffs[1], 2, gb, vlc); decode_coeff(dst+1, coeffs[2], 2, gb, vlc); }else{ decode_coeff(dst+1, coeffs[1], 2, gb, vlc); decode_coeff(dst+8, coeffs[2], 2, gb, vlc); } decode_coeff(dst+9, coeffs[3], 2, gb, vlc); } /** * Decode coefficients for 4x4 block. * * This is done by filling 2x2 subblocks with decoded coefficients * in this order (the same for subblocks and subblock coefficients): * o--o * / * / * o--o */ static inline void rv34_decode_block(DCTELEM *dst, GetBitContext *gb, RV34VLC *rvlc, int fc, int sc) { int code, pattern; code = get_vlc2(gb, rvlc->first_pattern[fc].table, 9, 2); pattern = code & 0x7; code >>= 3; decode_subblock(dst, code, 0, gb, &rvlc->coefficient); if(pattern & 4){ code = get_vlc2(gb, rvlc->second_pattern[sc].table, 9, 2); decode_subblock(dst + 2, code, 0, gb, &rvlc->coefficient); } if(pattern & 2){ // Looks like coefficients 1 and 2 are swapped for this block code = get_vlc2(gb, rvlc->second_pattern[sc].table, 9, 2); decode_subblock(dst + 8*2, code, 1, gb, &rvlc->coefficient); } if(pattern & 1){ code = get_vlc2(gb, rvlc->third_pattern[sc].table, 9, 2); decode_subblock(dst + 8*2+2, code, 0, gb, &rvlc->coefficient); } } /** * Dequantize ordinary 4x4 block. * @todo optimize */ static inline void rv34_dequant4x4(DCTELEM *block, int Qdc, int Q) { int i, j; block[0] = (block[0] * Qdc + 8) >> 4; for(i = 0; i < 4; i++) for(j = !i; j < 4; j++) block[j + i*8] = (block[j + i*8] * Q + 8) >> 4; } /** * Dequantize 4x4 block of DC values for 16x16 macroblock. * @todo optimize */ static inline void rv34_dequant4x4_16x16(DCTELEM *block, int Qdc, int Q) { int i; for(i = 0; i < 3; i++) block[rv34_dezigzag[i]] = (block[rv34_dezigzag[i]] * Qdc + 8) >> 4; for(; i < 16; i++) block[rv34_dezigzag[i]] = (block[rv34_dezigzag[i]] * Q + 8) >> 4; } /** @} */ //block functions /** * @defgroup bitstream RV30/40 bitstream parsing * @{ */ /** * Decode starting slice position. * @todo Maybe replace with ff_h263_decode_mba() ? */ int ff_rv34_get_start_offset(GetBitContext *gb, int mb_size) { int i; for(i = 0; i < 5; i++) if(rv34_mb_max_sizes[i] >= mb_size - 1) break; return rv34_mb_bits_sizes[i]; } /** * Select VLC set for decoding from current quantizer, modifier and frame type. */ static inline RV34VLC* choose_vlc_set(int quant, int mod, int type) { if(mod == 2 && quant < 19) quant += 10; else if(mod && quant < 26) quant += 5; return type ? &inter_vlcs[rv34_quant_to_vlc_set[1][av_clip(quant, 0, 30)]] : &intra_vlcs[rv34_quant_to_vlc_set[0][av_clip(quant, 0, 30)]]; } /** * Decode quantizer difference and return modified quantizer. */ static inline int rv34_decode_dquant(GetBitContext *gb, int quant) { if(get_bits1(gb)) return rv34_dquant_tab[get_bits1(gb)][quant]; else return get_bits(gb, 5); } /** @} */ //bitstream functions /** * @defgroup mv motion vector related code (prediction, reconstruction, motion compensation) * @{ */ /** macroblock partition width in 8x8 blocks */ static const uint8_t part_sizes_w[RV34_MB_TYPES] = { 2, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2 }; /** macroblock partition height in 8x8 blocks */ static const uint8_t part_sizes_h[RV34_MB_TYPES] = { 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2 }; /** availability index for subblocks */ static const uint8_t avail_indexes[4] = { 6, 7, 10, 11 }; /** * motion vector prediction * * Motion prediction performed for the block by using median prediction of * motion vectors from the left, top and right top blocks but in corner cases * some other vectors may be used instead. */ static void rv34_pred_mv(RV34DecContext *r, int block_type, int subblock_no, int dmv_no) { MpegEncContext *s = &r->s; int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride; int A[2] = {0}, B[2], C[2]; int i, j; int mx, my; int avail_index = avail_indexes[subblock_no]; int c_off = part_sizes_w[block_type]; mv_pos += (subblock_no & 1) + (subblock_no >> 1)*s->b8_stride; if(subblock_no == 3) c_off = -1; if(r->avail_cache[avail_index - 1]){ A[0] = s->current_picture_ptr->motion_val[0][mv_pos-1][0]; A[1] = s->current_picture_ptr->motion_val[0][mv_pos-1][1]; } if(r->avail_cache[avail_index - 4]){ B[0] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride][0]; B[1] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride][1]; }else{ B[0] = A[0]; B[1] = A[1]; } if(!r->avail_cache[avail_index - 4 + c_off]){ if(r->avail_cache[avail_index - 4] && (r->avail_cache[avail_index - 1] || r->rv30)){ C[0] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride-1][0]; C[1] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride-1][1]; }else{ C[0] = A[0]; C[1] = A[1]; } }else{ C[0] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride+c_off][0]; C[1] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride+c_off][1]; } mx = mid_pred(A[0], B[0], C[0]); my = mid_pred(A[1], B[1], C[1]); mx += r->dmv[dmv_no][0]; my += r->dmv[dmv_no][1]; for(j = 0; j < part_sizes_h[block_type]; j++){ for(i = 0; i < part_sizes_w[block_type]; i++){ s->current_picture_ptr->motion_val[0][mv_pos + i + j*s->b8_stride][0] = mx; s->current_picture_ptr->motion_val[0][mv_pos + i + j*s->b8_stride][1] = my; } } } #define GET_PTS_DIFF(a, b) ((a - b + 8192) & 0x1FFF) /** * Calculate motion vector component that should be added for direct blocks. */ static int calc_add_mv(RV34DecContext *r, int dir, int val) { int refdist = GET_PTS_DIFF(r->next_pts, r->last_pts); int dist = dir ? -GET_PTS_DIFF(r->next_pts, r->cur_pts) : GET_PTS_DIFF(r->cur_pts, r->last_pts); int mul; if(!refdist) return 0; mul = (dist << 14) / refdist; return (val * mul + 0x2000) >> 14; } /** * Predict motion vector for B-frame macroblock. */ static inline void rv34_pred_b_vector(int A[2], int B[2], int C[2], int A_avail, int B_avail, int C_avail, int *mx, int *my) { if(A_avail + B_avail + C_avail != 3){ *mx = A[0] + B[0] + C[0]; *my = A[1] + B[1] + C[1]; if(A_avail + B_avail + C_avail == 2){ *mx /= 2; *my /= 2; } }else{ *mx = mid_pred(A[0], B[0], C[0]); *my = mid_pred(A[1], B[1], C[1]); } } /** * motion vector prediction for B-frames */ static void rv34_pred_mv_b(RV34DecContext *r, int block_type, int dir) { MpegEncContext *s = &r->s; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride; int A[2], B[2], C[2]; int has_A = 0, has_B = 0, has_C = 0; int mx, my; int i, j; Picture *cur_pic = s->current_picture_ptr; const int mask = dir ? MB_TYPE_L1 : MB_TYPE_L0; int type = cur_pic->mb_type[mb_pos]; memset(A, 0, sizeof(A)); memset(B, 0, sizeof(B)); memset(C, 0, sizeof(C)); if((r->avail_cache[6-1] & type) & mask){ A[0] = cur_pic->motion_val[dir][mv_pos - 1][0]; A[1] = cur_pic->motion_val[dir][mv_pos - 1][1]; has_A = 1; } if((r->avail_cache[6-4] & type) & mask){ B[0] = cur_pic->motion_val[dir][mv_pos - s->b8_stride][0]; B[1] = cur_pic->motion_val[dir][mv_pos - s->b8_stride][1]; has_B = 1; } if(r->avail_cache[6-4] && (r->avail_cache[6-2] & type) & mask){ C[0] = cur_pic->motion_val[dir][mv_pos - s->b8_stride + 2][0]; C[1] = cur_pic->motion_val[dir][mv_pos - s->b8_stride + 2][1]; has_C = 1; }else if((s->mb_x+1) == s->mb_width && (r->avail_cache[6-5] & type) & mask){ C[0] = cur_pic->motion_val[dir][mv_pos - s->b8_stride - 1][0]; C[1] = cur_pic->motion_val[dir][mv_pos - s->b8_stride - 1][1]; has_C = 1; } rv34_pred_b_vector(A, B, C, has_A, has_B, has_C, &mx, &my); mx += r->dmv[dir][0]; my += r->dmv[dir][1]; for(j = 0; j < 2; j++){ for(i = 0; i < 2; i++){ cur_pic->motion_val[dir][mv_pos + i + j*s->b8_stride][0] = mx; cur_pic->motion_val[dir][mv_pos + i + j*s->b8_stride][1] = my; } } if(block_type == RV34_MB_B_BACKWARD || block_type == RV34_MB_B_FORWARD){ ZERO8x2(cur_pic->motion_val[!dir][mv_pos], s->b8_stride); } } /** * motion vector prediction - RV3 version */ static void rv34_pred_mv_rv3(RV34DecContext *r, int block_type, int dir) { MpegEncContext *s = &r->s; int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride; int A[2] = {0}, B[2], C[2]; int i, j, k; int mx, my; int avail_index = avail_indexes[0]; if(r->avail_cache[avail_index - 1]){ A[0] = s->current_picture_ptr->motion_val[0][mv_pos-1][0]; A[1] = s->current_picture_ptr->motion_val[0][mv_pos-1][1]; } if(r->avail_cache[avail_index - 4]){ B[0] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride][0]; B[1] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride][1]; }else{ B[0] = A[0]; B[1] = A[1]; } if(!r->avail_cache[avail_index - 4 + 2]){ if(r->avail_cache[avail_index - 4] && (r->avail_cache[avail_index - 1])){ C[0] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride-1][0]; C[1] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride-1][1]; }else{ C[0] = A[0]; C[1] = A[1]; } }else{ C[0] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride+2][0]; C[1] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride+2][1]; } mx = mid_pred(A[0], B[0], C[0]); my = mid_pred(A[1], B[1], C[1]); mx += r->dmv[0][0]; my += r->dmv[0][1]; for(j = 0; j < 2; j++){ for(i = 0; i < 2; i++){ for(k = 0; k < 2; k++){ s->current_picture_ptr->motion_val[k][mv_pos + i + j*s->b8_stride][0] = mx; s->current_picture_ptr->motion_val[k][mv_pos + i + j*s->b8_stride][1] = my; } } } } static const int chroma_coeffs[3] = { 0, 3, 5 }; /** * generic motion compensation function * * @param r decoder context * @param block_type type of the current block * @param xoff horizontal offset from the start of the current block * @param yoff vertical offset from the start of the current block * @param mv_off offset to the motion vector information * @param width width of the current partition in 8x8 blocks * @param height height of the current partition in 8x8 blocks * @param dir motion compensation direction (i.e. from the last or the next reference frame) * @param thirdpel motion vectors are specified in 1/3 of pixel * @param qpel_mc a set of functions used to perform luma motion compensation * @param chroma_mc a set of functions used to perform chroma motion compensation */ static inline void rv34_mc(RV34DecContext *r, const int block_type, const int xoff, const int yoff, int mv_off, const int width, const int height, int dir, const int thirdpel, qpel_mc_func (*qpel_mc)[16], h264_chroma_mc_func (*chroma_mc)) { MpegEncContext *s = &r->s; uint8_t *Y, *U, *V, *srcY, *srcU, *srcV; int dxy, mx, my, umx, umy, lx, ly, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y; int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride + mv_off; int is16x16 = 1; if(thirdpel){ int chroma_mx, chroma_my; mx = (s->current_picture_ptr->motion_val[dir][mv_pos][0] + (3 << 24)) / 3 - (1 << 24); my = (s->current_picture_ptr->motion_val[dir][mv_pos][1] + (3 << 24)) / 3 - (1 << 24); lx = (s->current_picture_ptr->motion_val[dir][mv_pos][0] + (3 << 24)) % 3; ly = (s->current_picture_ptr->motion_val[dir][mv_pos][1] + (3 << 24)) % 3; chroma_mx = (s->current_picture_ptr->motion_val[dir][mv_pos][0] + 1) >> 1; chroma_my = (s->current_picture_ptr->motion_val[dir][mv_pos][1] + 1) >> 1; umx = (chroma_mx + (3 << 24)) / 3 - (1 << 24); umy = (chroma_my + (3 << 24)) / 3 - (1 << 24); uvmx = chroma_coeffs[(chroma_mx + (3 << 24)) % 3]; uvmy = chroma_coeffs[(chroma_my + (3 << 24)) % 3]; }else{ int cx, cy; mx = s->current_picture_ptr->motion_val[dir][mv_pos][0] >> 2; my = s->current_picture_ptr->motion_val[dir][mv_pos][1] >> 2; lx = s->current_picture_ptr->motion_val[dir][mv_pos][0] & 3; ly = s->current_picture_ptr->motion_val[dir][mv_pos][1] & 3; cx = s->current_picture_ptr->motion_val[dir][mv_pos][0] / 2; cy = s->current_picture_ptr->motion_val[dir][mv_pos][1] / 2; umx = cx >> 2; umy = cy >> 2; uvmx = (cx & 3) << 1; uvmy = (cy & 3) << 1; //due to some flaw RV40 uses the same MC compensation routine for H2V2 and H3V3 if(uvmx == 6 && uvmy == 6) uvmx = uvmy = 4; } dxy = ly*4 + lx; srcY = dir ? s->next_picture_ptr->data[0] : s->last_picture_ptr->data[0]; srcU = dir ? s->next_picture_ptr->data[1] : s->last_picture_ptr->data[1]; srcV = dir ? s->next_picture_ptr->data[2] : s->last_picture_ptr->data[2]; src_x = s->mb_x * 16 + xoff + mx; src_y = s->mb_y * 16 + yoff + my; uvsrc_x = s->mb_x * 8 + (xoff >> 1) + umx; uvsrc_y = s->mb_y * 8 + (yoff >> 1) + umy; srcY += src_y * s->linesize + src_x; srcU += uvsrc_y * s->uvlinesize + uvsrc_x; srcV += uvsrc_y * s->uvlinesize + uvsrc_x; if( (unsigned)(src_x - !!lx*2) > s->h_edge_pos - !!lx*2 - (width <<3) - 4 || (unsigned)(src_y - !!ly*2) > s->v_edge_pos - !!ly*2 - (height<<3) - 4){ uint8_t *uvbuf= s->edge_emu_buffer + 22 * s->linesize; srcY -= 2 + 2*s->linesize; ff_emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize, (width<<3)+6, (height<<3)+6, src_x - 2, src_y - 2, s->h_edge_pos, s->v_edge_pos); srcY = s->edge_emu_buffer + 2 + 2*s->linesize; ff_emulated_edge_mc(uvbuf , srcU, s->uvlinesize, (width<<2)+1, (height<<2)+1, uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1); ff_emulated_edge_mc(uvbuf + 16, srcV, s->uvlinesize, (width<<2)+1, (height<<2)+1, uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1); srcU = uvbuf; srcV = uvbuf + 16; } Y = s->dest[0] + xoff + yoff *s->linesize; U = s->dest[1] + (xoff>>1) + (yoff>>1)*s->uvlinesize; V = s->dest[2] + (xoff>>1) + (yoff>>1)*s->uvlinesize; if(block_type == RV34_MB_P_16x8){ qpel_mc[1][dxy](Y, srcY, s->linesize); Y += 8; srcY += 8; }else if(block_type == RV34_MB_P_8x16){ qpel_mc[1][dxy](Y, srcY, s->linesize); Y += 8 * s->linesize; srcY += 8 * s->linesize; } is16x16 = (block_type != RV34_MB_P_8x8) && (block_type != RV34_MB_P_16x8) && (block_type != RV34_MB_P_8x16); qpel_mc[!is16x16][dxy](Y, srcY, s->linesize); chroma_mc[2-width] (U, srcU, s->uvlinesize, height*4, uvmx, uvmy); chroma_mc[2-width] (V, srcV, s->uvlinesize, height*4, uvmx, uvmy); } static void rv34_mc_1mv(RV34DecContext *r, const int block_type, const int xoff, const int yoff, int mv_off, const int width, const int height, int dir) { rv34_mc(r, block_type, xoff, yoff, mv_off, width, height, dir, r->rv30, r->rv30 ? r->s.dsp.put_rv30_tpel_pixels_tab : r->s.dsp.put_rv40_qpel_pixels_tab, r->rv30 ? r->s.dsp.put_h264_chroma_pixels_tab : r->s.dsp.put_rv40_chroma_pixels_tab); } static void rv34_mc_2mv(RV34DecContext *r, const int block_type) { rv34_mc(r, block_type, 0, 0, 0, 2, 2, 0, r->rv30, r->rv30 ? r->s.dsp.put_rv30_tpel_pixels_tab : r->s.dsp.put_rv40_qpel_pixels_tab, r->rv30 ? r->s.dsp.put_h264_chroma_pixels_tab : r->s.dsp.put_rv40_chroma_pixels_tab); rv34_mc(r, block_type, 0, 0, 0, 2, 2, 1, r->rv30, r->rv30 ? r->s.dsp.avg_rv30_tpel_pixels_tab : r->s.dsp.avg_rv40_qpel_pixels_tab, r->rv30 ? r->s.dsp.avg_h264_chroma_pixels_tab : r->s.dsp.avg_rv40_chroma_pixels_tab); } static void rv34_mc_2mv_skip(RV34DecContext *r) { int i, j; for(j = 0; j < 2; j++) for(i = 0; i < 2; i++){ rv34_mc(r, RV34_MB_P_8x8, i*8, j*8, i+j*r->s.b8_stride, 1, 1, 0, r->rv30, r->rv30 ? r->s.dsp.put_rv30_tpel_pixels_tab : r->s.dsp.put_rv40_qpel_pixels_tab, r->rv30 ? r->s.dsp.put_h264_chroma_pixels_tab : r->s.dsp.put_rv40_chroma_pixels_tab); rv34_mc(r, RV34_MB_P_8x8, i*8, j*8, i+j*r->s.b8_stride, 1, 1, 1, r->rv30, r->rv30 ? r->s.dsp.avg_rv30_tpel_pixels_tab : r->s.dsp.avg_rv40_qpel_pixels_tab, r->rv30 ? r->s.dsp.avg_h264_chroma_pixels_tab : r->s.dsp.avg_rv40_chroma_pixels_tab); } } /** number of motion vectors in each macroblock type */ static const int num_mvs[RV34_MB_TYPES] = { 0, 0, 1, 4, 1, 1, 0, 0, 2, 2, 2, 1 }; /** * Decode motion vector differences * and perform motion vector reconstruction and motion compensation. */ static int rv34_decode_mv(RV34DecContext *r, int block_type) { MpegEncContext *s = &r->s; GetBitContext *gb = &s->gb; int i, j, k, l; int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride; int next_bt; memset(r->dmv, 0, sizeof(r->dmv)); for(i = 0; i < num_mvs[block_type]; i++){ r->dmv[i][0] = svq3_get_se_golomb(gb); r->dmv[i][1] = svq3_get_se_golomb(gb); } switch(block_type){ case RV34_MB_TYPE_INTRA: case RV34_MB_TYPE_INTRA16x16: ZERO8x2(s->current_picture_ptr->motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride); return 0; case RV34_MB_SKIP: if(s->pict_type == FF_P_TYPE){ ZERO8x2(s->current_picture_ptr->motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride); rv34_mc_1mv (r, block_type, 0, 0, 0, 2, 2, 0); break; } case RV34_MB_B_DIRECT: //surprisingly, it uses motion scheme from next reference frame next_bt = s->next_picture_ptr->mb_type[s->mb_x + s->mb_y * s->mb_stride]; if(IS_INTRA(next_bt) || IS_SKIP(next_bt)){ ZERO8x2(s->current_picture_ptr->motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride); ZERO8x2(s->current_picture_ptr->motion_val[1][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride); }else for(j = 0; j < 2; j++) for(i = 0; i < 2; i++) for(k = 0; k < 2; k++) for(l = 0; l < 2; l++) s->current_picture_ptr->motion_val[l][mv_pos + i + j*s->b8_stride][k] = calc_add_mv(r, l, s->next_picture_ptr->motion_val[0][mv_pos + i + j*s->b8_stride][k]); if(!(IS_16X8(next_bt) || IS_8X16(next_bt) || IS_8X8(next_bt))) //we can use whole macroblock MC rv34_mc_2mv(r, block_type); else rv34_mc_2mv_skip(r); ZERO8x2(s->current_picture_ptr->motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride); break; case RV34_MB_P_16x16: case RV34_MB_P_MIX16x16: rv34_pred_mv(r, block_type, 0, 0); rv34_mc_1mv (r, block_type, 0, 0, 0, 2, 2, 0); break; case RV34_MB_B_FORWARD: case RV34_MB_B_BACKWARD: r->dmv[1][0] = r->dmv[0][0]; r->dmv[1][1] = r->dmv[0][1]; if(r->rv30) rv34_pred_mv_rv3(r, block_type, block_type == RV34_MB_B_BACKWARD); else rv34_pred_mv_b (r, block_type, block_type == RV34_MB_B_BACKWARD); rv34_mc_1mv (r, block_type, 0, 0, 0, 2, 2, block_type == RV34_MB_B_BACKWARD); break; case RV34_MB_P_16x8: case RV34_MB_P_8x16: rv34_pred_mv(r, block_type, 0, 0); rv34_pred_mv(r, block_type, 1 + (block_type == RV34_MB_P_16x8), 1); if(block_type == RV34_MB_P_16x8){ rv34_mc_1mv(r, block_type, 0, 0, 0, 2, 1, 0); rv34_mc_1mv(r, block_type, 0, 8, s->b8_stride, 2, 1, 0); } if(block_type == RV34_MB_P_8x16){ rv34_mc_1mv(r, block_type, 0, 0, 0, 1, 2, 0); rv34_mc_1mv(r, block_type, 8, 0, 1, 1, 2, 0); } break; case RV34_MB_B_BIDIR: rv34_pred_mv_b (r, block_type, 0); rv34_pred_mv_b (r, block_type, 1); rv34_mc_2mv (r, block_type); break; case RV34_MB_P_8x8: for(i=0;i< 4;i++){ rv34_pred_mv(r, block_type, i, i); rv34_mc_1mv (r, block_type, (i&1)<<3, (i&2)<<2, (i&1)+(i>>1)*s->b8_stride, 1, 1, 0); } break; } return 0; } /** @} */ // mv group /** * @defgroup recons Macroblock reconstruction functions * @{ */ /** mapping of RV30/40 intra prediction types to standard H.264 types */ static const int ittrans[9] = { DC_PRED, VERT_PRED, HOR_PRED, DIAG_DOWN_RIGHT_PRED, DIAG_DOWN_LEFT_PRED, VERT_RIGHT_PRED, VERT_LEFT_PRED, HOR_UP_PRED, HOR_DOWN_PRED, }; /** mapping of RV30/40 intra 16x16 prediction types to standard H.264 types */ static const int ittrans16[4] = { DC_PRED8x8, VERT_PRED8x8, HOR_PRED8x8, PLANE_PRED8x8, }; /** * Perform 4x4 intra prediction. */ static void rv34_pred_4x4_block(RV34DecContext *r, uint8_t *dst, int stride, int itype, int up, int left, int down, int right) { uint8_t *prev = dst - stride + 4; uint32_t topleft; if(!up && !left) itype = DC_128_PRED; else if(!up){ if(itype == VERT_PRED) itype = HOR_PRED; if(itype == DC_PRED) itype = LEFT_DC_PRED; }else if(!left){ if(itype == HOR_PRED) itype = VERT_PRED; if(itype == DC_PRED) itype = TOP_DC_PRED; if(itype == DIAG_DOWN_LEFT_PRED) itype = DIAG_DOWN_LEFT_PRED_RV40_NODOWN; } if(!down){ if(itype == DIAG_DOWN_LEFT_PRED) itype = DIAG_DOWN_LEFT_PRED_RV40_NODOWN; if(itype == HOR_UP_PRED) itype = HOR_UP_PRED_RV40_NODOWN; if(itype == VERT_LEFT_PRED) itype = VERT_LEFT_PRED_RV40_NODOWN; } if(!right && up){ topleft = dst[-stride + 3] * 0x01010101; prev = (uint8_t*)&topleft; } r->h.pred4x4[itype](dst, prev, stride); } /** add_pixels_clamped for 4x4 block */ static void rv34_add_4x4_block(uint8_t *dst, int stride, DCTELEM block[64], int off) { int x, y; for(y = 0; y < 4; y++) for(x = 0; x < 4; x++) dst[x + y*stride] = av_clip_uint8(dst[x + y*stride] + block[off + x+y*8]); } static inline int adjust_pred16(int itype, int up, int left) { if(!up && !left) itype = DC_128_PRED8x8; else if(!up){ if(itype == PLANE_PRED8x8)itype = HOR_PRED8x8; if(itype == VERT_PRED8x8) itype = HOR_PRED8x8; if(itype == DC_PRED8x8) itype = LEFT_DC_PRED8x8; }else if(!left){ if(itype == PLANE_PRED8x8)itype = VERT_PRED8x8; if(itype == HOR_PRED8x8) itype = VERT_PRED8x8; if(itype == DC_PRED8x8) itype = TOP_DC_PRED8x8; } return itype; } static void rv34_output_macroblock(RV34DecContext *r, int8_t *intra_types, int cbp, int is16) { MpegEncContext *s = &r->s; DSPContext *dsp = &s->dsp; int i, j; uint8_t *Y, *U, *V; int itype; int avail[6*8] = {0}; int idx; // Set neighbour information. if(r->avail_cache[1]) avail[0] = 1; if(r->avail_cache[2]) avail[1] = avail[2] = 1; if(r->avail_cache[3]) avail[3] = avail[4] = 1; if(r->avail_cache[4]) avail[5] = 1; if(r->avail_cache[5]) avail[8] = avail[16] = 1; if(r->avail_cache[9]) avail[24] = avail[32] = 1; Y = s->dest[0]; U = s->dest[1]; V = s->dest[2]; if(!is16){ for(j = 0; j < 4; j++){ idx = 9 + j*8; for(i = 0; i < 4; i++, cbp >>= 1, Y += 4, idx++){ rv34_pred_4x4_block(r, Y, s->linesize, ittrans[intra_types[i]], avail[idx-8], avail[idx-1], avail[idx+7], avail[idx-7]); avail[idx] = 1; if(cbp & 1) rv34_add_4x4_block(Y, s->linesize, s->block[(i>>1)+(j&2)], (i&1)*4+(j&1)*32); } Y += s->linesize * 4 - 4*4; intra_types += r->intra_types_stride; } intra_types -= r->intra_types_stride * 4; fill_rectangle(r->avail_cache + 6, 2, 2, 4, 0, 4); for(j = 0; j < 2; j++){ idx = 6 + j*4; for(i = 0; i < 2; i++, cbp >>= 1, idx++){ rv34_pred_4x4_block(r, U + i*4 + j*4*s->uvlinesize, s->uvlinesize, ittrans[intra_types[i*2+j*2*r->intra_types_stride]], r->avail_cache[idx-4], r->avail_cache[idx-1], !i && !j, r->avail_cache[idx-3]); rv34_pred_4x4_block(r, V + i*4 + j*4*s->uvlinesize, s->uvlinesize, ittrans[intra_types[i*2+j*2*r->intra_types_stride]], r->avail_cache[idx-4], r->avail_cache[idx-1], !i && !j, r->avail_cache[idx-3]); r->avail_cache[idx] = 1; if(cbp & 0x01) rv34_add_4x4_block(U + i*4 + j*4*s->uvlinesize, s->uvlinesize, s->block[4], i*4+j*32); if(cbp & 0x10) rv34_add_4x4_block(V + i*4 + j*4*s->uvlinesize, s->uvlinesize, s->block[5], i*4+j*32); } } }else{ itype = ittrans16[intra_types[0]]; itype = adjust_pred16(itype, r->avail_cache[6-4], r->avail_cache[6-1]); r->h.pred16x16[itype](Y, s->linesize); dsp->add_pixels_clamped(s->block[0], Y, s->linesize); dsp->add_pixels_clamped(s->block[1], Y + 8, s->linesize); Y += s->linesize * 8; dsp->add_pixels_clamped(s->block[2], Y, s->linesize); dsp->add_pixels_clamped(s->block[3], Y + 8, s->linesize); itype = ittrans16[intra_types[0]]; if(itype == PLANE_PRED8x8) itype = DC_PRED8x8; itype = adjust_pred16(itype, r->avail_cache[6-4], r->avail_cache[6-1]); r->h.pred8x8[itype](U, s->uvlinesize); dsp->add_pixels_clamped(s->block[4], U, s->uvlinesize); r->h.pred8x8[itype](V, s->uvlinesize); dsp->add_pixels_clamped(s->block[5], V, s->uvlinesize); } } /** @} */ // recons group /** * @addtogroup bitstream * Decode macroblock header and return CBP in case of success, -1 otherwise. */ static int rv34_decode_mb_header(RV34DecContext *r, int8_t *intra_types) { MpegEncContext *s = &r->s; GetBitContext *gb = &s->gb; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; int i, t; if(!r->si.type){ r->is16 = get_bits1(gb); if(!r->is16 && !r->rv30){ if(!get_bits1(gb)) av_log(s->avctx, AV_LOG_ERROR, "Need DQUANT\n"); } s->current_picture_ptr->mb_type[mb_pos] = r->is16 ? MB_TYPE_INTRA16x16 : MB_TYPE_INTRA; r->block_type = r->is16 ? RV34_MB_TYPE_INTRA16x16 : RV34_MB_TYPE_INTRA; }else{ r->block_type = r->decode_mb_info(r); if(r->block_type == -1) return -1; s->current_picture_ptr->mb_type[mb_pos] = rv34_mb_type_to_lavc[r->block_type]; r->mb_type[mb_pos] = r->block_type; if(r->block_type == RV34_MB_SKIP){ if(s->pict_type == FF_P_TYPE) r->mb_type[mb_pos] = RV34_MB_P_16x16; if(s->pict_type == FF_B_TYPE) r->mb_type[mb_pos] = RV34_MB_B_DIRECT; } r->is16 = !!IS_INTRA16x16(s->current_picture_ptr->mb_type[mb_pos]); rv34_decode_mv(r, r->block_type); if(r->block_type == RV34_MB_SKIP){ fill_rectangle(intra_types, 4, 4, r->intra_types_stride, 0, sizeof(intra_types[0])); return 0; } r->chroma_vlc = 1; r->luma_vlc = 0; } if(IS_INTRA(s->current_picture_ptr->mb_type[mb_pos])){ if(r->is16){ t = get_bits(gb, 2); fill_rectangle(intra_types, 4, 4, r->intra_types_stride, t, sizeof(intra_types[0])); r->luma_vlc = 2; }else{ if(r->decode_intra_types(r, gb, intra_types) < 0) return -1; r->luma_vlc = 1; } r->chroma_vlc = 0; r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 0); }else{ for(i = 0; i < 16; i++) intra_types[(i & 3) + (i>>2) * r->intra_types_stride] = 0; r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 1); if(r->mb_type[mb_pos] == RV34_MB_P_MIX16x16){ r->is16 = 1; r->chroma_vlc = 1; r->luma_vlc = 2; r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 0); } } return rv34_decode_cbp(gb, r->cur_vlcs, r->is16); } /** * @addtogroup recons * @{ */ /** * mask for retrieving all bits in coded block pattern * corresponding to one 8x8 block */ #define LUMA_CBP_BLOCK_MASK 0x33 #define U_CBP_MASK 0x0F0000 #define V_CBP_MASK 0xF00000 static void rv34_apply_differences(RV34DecContext *r, int cbp) { static const int shifts[4] = { 0, 2, 8, 10 }; MpegEncContext *s = &r->s; int i; for(i = 0; i < 4; i++) if((cbp & (LUMA_CBP_BLOCK_MASK << shifts[i])) || r->block_type == RV34_MB_P_MIX16x16) s->dsp.add_pixels_clamped(s->block[i], s->dest[0] + (i & 1)*8 + (i&2)*4*s->linesize, s->linesize); if(cbp & U_CBP_MASK) s->dsp.add_pixels_clamped(s->block[4], s->dest[1], s->uvlinesize); if(cbp & V_CBP_MASK) s->dsp.add_pixels_clamped(s->block[5], s->dest[2], s->uvlinesize); } static int is_mv_diff_gt_3(int16_t (*motion_val)[2], int step) { int d; d = motion_val[0][0] - motion_val[-step][0]; if(d < -3 || d > 3) return 1; d = motion_val[0][1] - motion_val[-step][1]; if(d < -3 || d > 3) return 1; return 0; } static int rv34_set_deblock_coef(RV34DecContext *r) { MpegEncContext *s = &r->s; int hmvmask = 0, vmvmask = 0, i, j; int midx = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride; int16_t (*motion_val)[2] = s->current_picture_ptr->motion_val[0][midx]; for(j = 0; j < 16; j += 8){ for(i = 0; i < 2; i++){ if(is_mv_diff_gt_3(motion_val + i, 1)) vmvmask |= 0x11 << (j + i*2); if((j || s->mb_y) && is_mv_diff_gt_3(motion_val + i, s->b8_stride)) hmvmask |= 0x03 << (j + i*2); } motion_val += s->b8_stride; } if(s->first_slice_line) hmvmask &= ~0x000F; if(!s->mb_x) vmvmask &= ~0x1111; if(r->rv30){ //RV30 marks both subblocks on the edge for filtering vmvmask |= (vmvmask & 0x4444) >> 1; hmvmask |= (hmvmask & 0x0F00) >> 4; if(s->mb_x) r->deblock_coefs[s->mb_x - 1 + s->mb_y*s->mb_stride] |= (vmvmask & 0x1111) << 3; if(!s->first_slice_line) r->deblock_coefs[s->mb_x + (s->mb_y - 1)*s->mb_stride] |= (hmvmask & 0xF) << 12; } return hmvmask | vmvmask; } static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types) { MpegEncContext *s = &r->s; GetBitContext *gb = &s->gb; int cbp, cbp2; int i, blknum, blkoff; DCTELEM block16[64]; int luma_dc_quant; int dist; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; // Calculate which neighbours are available. Maybe it's worth optimizing too. memset(r->avail_cache, 0, sizeof(r->avail_cache)); fill_rectangle(r->avail_cache + 6, 2, 2, 4, 1, 4); dist = (s->mb_x - s->resync_mb_x) + (s->mb_y - s->resync_mb_y) * s->mb_width; if(s->mb_x && dist) r->avail_cache[5] = r->avail_cache[9] = s->current_picture_ptr->mb_type[mb_pos - 1]; if(dist >= s->mb_width) r->avail_cache[2] = r->avail_cache[3] = s->current_picture_ptr->mb_type[mb_pos - s->mb_stride]; if(((s->mb_x+1) < s->mb_width) && dist >= s->mb_width - 1) r->avail_cache[4] = s->current_picture_ptr->mb_type[mb_pos - s->mb_stride + 1]; if(s->mb_x && dist > s->mb_width) r->avail_cache[1] = s->current_picture_ptr->mb_type[mb_pos - s->mb_stride - 1]; s->qscale = r->si.quant; cbp = cbp2 = rv34_decode_mb_header(r, intra_types); r->cbp_luma [mb_pos] = cbp; r->cbp_chroma[mb_pos] = cbp >> 16; if(s->pict_type == FF_I_TYPE) r->deblock_coefs[mb_pos] = 0xFFFF; else r->deblock_coefs[mb_pos] = rv34_set_deblock_coef(r) | r->cbp_luma[mb_pos]; s->current_picture_ptr->qscale_table[mb_pos] = s->qscale; if(cbp == -1) return -1; luma_dc_quant = r->block_type == RV34_MB_P_MIX16x16 ? r->luma_dc_quant_p[s->qscale] : r->luma_dc_quant_i[s->qscale]; if(r->is16){ memset(block16, 0, sizeof(block16)); rv34_decode_block(block16, gb, r->cur_vlcs, 3, 0); rv34_dequant4x4_16x16(block16, rv34_qscale_tab[luma_dc_quant],rv34_qscale_tab[s->qscale]); rv34_inv_transform_noround(block16); } for(i = 0; i < 16; i++, cbp >>= 1){ if(!r->is16 && !(cbp & 1)) continue; blknum = ((i & 2) >> 1) + ((i & 8) >> 2); blkoff = ((i & 1) << 2) + ((i & 4) << 3); if(cbp & 1) rv34_decode_block(s->block[blknum] + blkoff, gb, r->cur_vlcs, r->luma_vlc, 0); rv34_dequant4x4(s->block[blknum] + blkoff, rv34_qscale_tab[s->qscale],rv34_qscale_tab[s->qscale]); if(r->is16) //FIXME: optimize s->block[blknum][blkoff] = block16[(i & 3) | ((i & 0xC) << 1)]; rv34_inv_transform(s->block[blknum] + blkoff); } if(r->block_type == RV34_MB_P_MIX16x16) r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 1); for(; i < 24; i++, cbp >>= 1){ if(!(cbp & 1)) continue; blknum = ((i & 4) >> 2) + 4; blkoff = ((i & 1) << 2) + ((i & 2) << 4); rv34_decode_block(s->block[blknum] + blkoff, gb, r->cur_vlcs, r->chroma_vlc, 1); rv34_dequant4x4(s->block[blknum] + blkoff, rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]],rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]]); rv34_inv_transform(s->block[blknum] + blkoff); } if(IS_INTRA(s->current_picture_ptr->mb_type[mb_pos])) rv34_output_macroblock(r, intra_types, cbp2, r->is16); else rv34_apply_differences(r, cbp2); return 0; } static int check_slice_end(RV34DecContext *r, MpegEncContext *s) { int bits; if(s->mb_y >= s->mb_height) return 1; if(!s->mb_num_left) return 1; if(r->s.mb_skip_run > 1) return 0; bits = r->bits - get_bits_count(&s->gb); if(bits < 0 || (bits < 8 && !show_bits(&s->gb, bits))) return 1; return 0; } static inline int slice_compare(SliceInfo *si1, SliceInfo *si2) { return si1->type != si2->type || si1->start >= si2->start || si1->width != si2->width || si1->height != si2->height|| si1->pts != si2->pts; } static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int buf_size) { MpegEncContext *s = &r->s; GetBitContext *gb = &s->gb; int mb_pos; int res; init_get_bits(&r->s.gb, buf, buf_size*8); res = r->parse_slice_header(r, gb, &r->si); if(res < 0){ av_log(s->avctx, AV_LOG_ERROR, "Incorrect or unknown slice header\n"); return -1; } if ((s->mb_x == 0 && s->mb_y == 0) || s->current_picture_ptr==NULL) { if(s->width != r->si.width || s->height != r->si.height){ av_log(s->avctx, AV_LOG_DEBUG, "Changing dimensions to %dx%d\n", r->si.width,r->si.height); MPV_common_end(s); s->width = r->si.width; s->height = r->si.height; avcodec_set_dimensions(s->avctx, s->width, s->height); if(MPV_common_init(s) < 0) return -1; r->intra_types_stride = s->mb_width*4 + 4; r->intra_types_hist = av_realloc(r->intra_types_hist, r->intra_types_stride * 4 * 2 * sizeof(*r->intra_types_hist)); r->intra_types = r->intra_types_hist + r->intra_types_stride * 4; r->mb_type = av_realloc(r->mb_type, r->s.mb_stride * r->s.mb_height * sizeof(*r->mb_type)); r->cbp_luma = av_realloc(r->cbp_luma, r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_luma)); r->cbp_chroma = av_realloc(r->cbp_chroma, r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_chroma)); r->deblock_coefs = av_realloc(r->deblock_coefs, r->s.mb_stride * r->s.mb_height * sizeof(*r->deblock_coefs)); } s->pict_type = r->si.type ? r->si.type : FF_I_TYPE; if(MPV_frame_start(s, s->avctx) < 0) return -1; ff_er_frame_start(s); r->cur_pts = r->si.pts; if(s->pict_type != FF_B_TYPE){ r->last_pts = r->next_pts; r->next_pts = r->cur_pts; } s->mb_x = s->mb_y = 0; } r->si.end = end; s->qscale = r->si.quant; r->bits = buf_size*8; s->mb_num_left = r->si.end - r->si.start; r->s.mb_skip_run = 0; mb_pos = s->mb_x + s->mb_y * s->mb_width; if(r->si.start != mb_pos){ av_log(s->avctx, AV_LOG_ERROR, "Slice indicates MB offset %d, got %d\n", r->si.start, mb_pos); s->mb_x = r->si.start % s->mb_width; s->mb_y = r->si.start / s->mb_width; } memset(r->intra_types_hist, -1, r->intra_types_stride * 4 * 2 * sizeof(*r->intra_types_hist)); s->first_slice_line = 1; s->resync_mb_x= s->mb_x; s->resync_mb_y= s->mb_y; ff_init_block_index(s); while(!check_slice_end(r, s)) { ff_update_block_index(s); s->dsp.clear_blocks(s->block[0]); if(rv34_decode_macroblock(r, r->intra_types + s->mb_x * 4 + 4) < 0){ ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_ERROR|DC_ERROR|MV_ERROR); return -1; } if (++s->mb_x == s->mb_width) { s->mb_x = 0; s->mb_y++; ff_init_block_index(s); memmove(r->intra_types_hist, r->intra_types, r->intra_types_stride * 4 * sizeof(*r->intra_types_hist)); memset(r->intra_types, -1, r->intra_types_stride * 4 * sizeof(*r->intra_types_hist)); if(r->loop_filter && s->mb_y >= 2) r->loop_filter(r, s->mb_y - 2); } if(s->mb_x == s->resync_mb_x) s->first_slice_line=0; s->mb_num_left--; } ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END); return s->mb_y == s->mb_height; } /** @} */ // recons group end /** * Initialize decoder. */ av_cold int ff_rv34_decode_init(AVCodecContext *avctx) { RV34DecContext *r = avctx->priv_data; MpegEncContext *s = &r->s; MPV_decode_defaults(s); s->avctx= avctx; s->out_format = FMT_H263; s->codec_id= avctx->codec_id; s->width = avctx->width; s->height = avctx->height; r->s.avctx = avctx; avctx->flags |= CODEC_FLAG_EMU_EDGE; r->s.flags |= CODEC_FLAG_EMU_EDGE; avctx->pix_fmt = PIX_FMT_YUV420P; avctx->has_b_frames = 1; s->low_delay = 0; if (MPV_common_init(s) < 0) return -1; ff_h264_pred_init(&r->h, CODEC_ID_RV40); r->intra_types_stride = 4*s->mb_stride + 4; r->intra_types_hist = av_malloc(r->intra_types_stride * 4 * 2 * sizeof(*r->intra_types_hist)); r->intra_types = r->intra_types_hist + r->intra_types_stride * 4; r->mb_type = av_mallocz(r->s.mb_stride * r->s.mb_height * sizeof(*r->mb_type)); r->cbp_luma = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_luma)); r->cbp_chroma = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_chroma)); r->deblock_coefs = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->deblock_coefs)); if(!intra_vlcs[0].cbppattern[0].bits) rv34_init_tables(); return 0; } static int get_slice_offset(AVCodecContext *avctx, const uint8_t *buf, int n) { if(avctx->slice_count) return avctx->slice_offset[n]; else return AV_RL32(buf + n*8 - 4) == 1 ? AV_RL32(buf + n*8) : AV_RB32(buf + n*8); } int ff_rv34_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; RV34DecContext *r = avctx->priv_data; MpegEncContext *s = &r->s; AVFrame *pict = data; SliceInfo si; int i; int slice_count; const uint8_t *slices_hdr = NULL; int last = 0; /* no supplementary picture */ if (buf_size == 0) { /* special case for last picture */ if (s->low_delay==0 && s->next_picture_ptr) { *pict= *(AVFrame*)s->next_picture_ptr; s->next_picture_ptr= NULL; *data_size = sizeof(AVFrame); } return 0; } if(!avctx->slice_count){ slice_count = (*buf++) + 1; slices_hdr = buf + 4; buf += 8 * slice_count; }else slice_count = avctx->slice_count; //parse first slice header to check whether this frame can be decoded if(get_slice_offset(avctx, slices_hdr, 0) > buf_size){ av_log(avctx, AV_LOG_ERROR, "Slice offset is greater than frame size\n"); return -1; } init_get_bits(&s->gb, buf+get_slice_offset(avctx, slices_hdr, 0), buf_size-get_slice_offset(avctx, slices_hdr, 0)); if(r->parse_slice_header(r, &r->s.gb, &si) < 0 || si.start){ av_log(avctx, AV_LOG_ERROR, "First slice header is incorrect\n"); return -1; } if((!s->last_picture_ptr || !s->last_picture_ptr->data[0]) && si.type == FF_B_TYPE) return -1; /* skip b frames if we are in a hurry */ if(avctx->hurry_up && si.type==FF_B_TYPE) return buf_size; if( (avctx->skip_frame >= AVDISCARD_NONREF && si.type==FF_B_TYPE) || (avctx->skip_frame >= AVDISCARD_NONKEY && si.type!=FF_I_TYPE) || avctx->skip_frame >= AVDISCARD_ALL) return buf_size; /* skip everything if we are in a hurry>=5 */ if(avctx->hurry_up>=5) return buf_size; for(i=0; i<slice_count; i++){ int offset= get_slice_offset(avctx, slices_hdr, i); int size; if(i+1 == slice_count) size= buf_size - offset; else size= get_slice_offset(avctx, slices_hdr, i+1) - offset; if(offset > buf_size){ av_log(avctx, AV_LOG_ERROR, "Slice offset is greater than frame size\n"); break; } r->si.end = s->mb_width * s->mb_height; if(i+1 < slice_count){ init_get_bits(&s->gb, buf+get_slice_offset(avctx, slices_hdr, i+1), (buf_size-get_slice_offset(avctx, slices_hdr, i+1))*8); if(r->parse_slice_header(r, &r->s.gb, &si) < 0){ if(i+2 < slice_count) size = get_slice_offset(avctx, slices_hdr, i+2) - offset; else size = buf_size - offset; }else r->si.end = si.start; } last = rv34_decode_slice(r, r->si.end, buf + offset, size); s->mb_num_left = r->s.mb_x + r->s.mb_y*r->s.mb_width - r->si.start; if(last) break; } if(last){ if(r->loop_filter) r->loop_filter(r, s->mb_height - 1); ff_er_frame_end(s); MPV_frame_end(s); if (s->pict_type == FF_B_TYPE || s->low_delay) { *pict= *(AVFrame*)s->current_picture_ptr; } else if (s->last_picture_ptr != NULL) { *pict= *(AVFrame*)s->last_picture_ptr; } if(s->last_picture_ptr || s->low_delay){ *data_size = sizeof(AVFrame); ff_print_debug_info(s, pict); } s->current_picture_ptr= NULL; //so we can detect if frame_end wasnt called (find some nicer solution...) } return buf_size; } av_cold int ff_rv34_decode_end(AVCodecContext *avctx) { RV34DecContext *r = avctx->priv_data; MPV_common_end(&r->s); av_freep(&r->intra_types_hist); r->intra_types = NULL; av_freep(&r->mb_type); av_freep(&r->cbp_luma); av_freep(&r->cbp_chroma); av_freep(&r->deblock_coefs); return 0; }
123linslouis-android-video-cutter
jni/libavcodec/rv34.c
C
asf20
55,432
/* * MPEG1/2 tables * copyright (c) 2000,2001 Fabrice Bellard * copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * MPEG1/2 tables. */ #include "mpeg12data.h" const uint16_t ff_mpeg1_default_intra_matrix[64] = { 8, 16, 19, 22, 26, 27, 29, 34, 16, 16, 22, 24, 27, 29, 34, 37, 19, 22, 26, 27, 29, 34, 34, 38, 22, 22, 26, 27, 29, 34, 37, 40, 22, 26, 27, 29, 32, 35, 40, 48, 26, 27, 29, 32, 35, 40, 48, 58, 26, 27, 29, 34, 38, 46, 56, 69, 27, 29, 35, 38, 46, 56, 69, 83 }; const uint16_t ff_mpeg1_default_non_intra_matrix[64] = { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, }; const uint16_t ff_mpeg12_vlc_dc_lum_code[12] = { 0x4, 0x0, 0x1, 0x5, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe, 0x1ff, }; const unsigned char ff_mpeg12_vlc_dc_lum_bits[12] = { 3, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 9, }; const uint16_t ff_mpeg12_vlc_dc_chroma_code[12] = { 0x0, 0x1, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe, 0x3fe, 0x3ff, }; const unsigned char ff_mpeg12_vlc_dc_chroma_bits[12] = { 2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, }; static const uint16_t mpeg1_vlc[113][2] = { { 0x3, 2 }, { 0x4, 4 }, { 0x5, 5 }, { 0x6, 7 }, { 0x26, 8 }, { 0x21, 8 }, { 0xa, 10 }, { 0x1d, 12 }, { 0x18, 12 }, { 0x13, 12 }, { 0x10, 12 }, { 0x1a, 13 }, { 0x19, 13 }, { 0x18, 13 }, { 0x17, 13 }, { 0x1f, 14 }, { 0x1e, 14 }, { 0x1d, 14 }, { 0x1c, 14 }, { 0x1b, 14 }, { 0x1a, 14 }, { 0x19, 14 }, { 0x18, 14 }, { 0x17, 14 }, { 0x16, 14 }, { 0x15, 14 }, { 0x14, 14 }, { 0x13, 14 }, { 0x12, 14 }, { 0x11, 14 }, { 0x10, 14 }, { 0x18, 15 }, { 0x17, 15 }, { 0x16, 15 }, { 0x15, 15 }, { 0x14, 15 }, { 0x13, 15 }, { 0x12, 15 }, { 0x11, 15 }, { 0x10, 15 }, { 0x3, 3 }, { 0x6, 6 }, { 0x25, 8 }, { 0xc, 10 }, { 0x1b, 12 }, { 0x16, 13 }, { 0x15, 13 }, { 0x1f, 15 }, { 0x1e, 15 }, { 0x1d, 15 }, { 0x1c, 15 }, { 0x1b, 15 }, { 0x1a, 15 }, { 0x19, 15 }, { 0x13, 16 }, { 0x12, 16 }, { 0x11, 16 }, { 0x10, 16 }, { 0x5, 4 }, { 0x4, 7 }, { 0xb, 10 }, { 0x14, 12 }, { 0x14, 13 }, { 0x7, 5 }, { 0x24, 8 }, { 0x1c, 12 }, { 0x13, 13 }, { 0x6, 5 }, { 0xf, 10 }, { 0x12, 12 }, { 0x7, 6 }, { 0x9, 10 }, { 0x12, 13 }, { 0x5, 6 }, { 0x1e, 12 }, { 0x14, 16 }, { 0x4, 6 }, { 0x15, 12 }, { 0x7, 7 }, { 0x11, 12 }, { 0x5, 7 }, { 0x11, 13 }, { 0x27, 8 }, { 0x10, 13 }, { 0x23, 8 }, { 0x1a, 16 }, { 0x22, 8 }, { 0x19, 16 }, { 0x20, 8 }, { 0x18, 16 }, { 0xe, 10 }, { 0x17, 16 }, { 0xd, 10 }, { 0x16, 16 }, { 0x8, 10 }, { 0x15, 16 }, { 0x1f, 12 }, { 0x1a, 12 }, { 0x19, 12 }, { 0x17, 12 }, { 0x16, 12 }, { 0x1f, 13 }, { 0x1e, 13 }, { 0x1d, 13 }, { 0x1c, 13 }, { 0x1b, 13 }, { 0x1f, 16 }, { 0x1e, 16 }, { 0x1d, 16 }, { 0x1c, 16 }, { 0x1b, 16 }, { 0x1, 6 }, /* escape */ { 0x2, 2 }, /* EOB */ }; static const uint16_t mpeg2_vlc[113][2] = { {0x02, 2}, {0x06, 3}, {0x07, 4}, {0x1c, 5}, {0x1d, 5}, {0x05, 6}, {0x04, 6}, {0x7b, 7}, {0x7c, 7}, {0x23, 8}, {0x22, 8}, {0xfa, 8}, {0xfb, 8}, {0xfe, 8}, {0xff, 8}, {0x1f,14}, {0x1e,14}, {0x1d,14}, {0x1c,14}, {0x1b,14}, {0x1a,14}, {0x19,14}, {0x18,14}, {0x17,14}, {0x16,14}, {0x15,14}, {0x14,14}, {0x13,14}, {0x12,14}, {0x11,14}, {0x10,14}, {0x18,15}, {0x17,15}, {0x16,15}, {0x15,15}, {0x14,15}, {0x13,15}, {0x12,15}, {0x11,15}, {0x10,15}, {0x02, 3}, {0x06, 5}, {0x79, 7}, {0x27, 8}, {0x20, 8}, {0x16,13}, {0x15,13}, {0x1f,15}, {0x1e,15}, {0x1d,15}, {0x1c,15}, {0x1b,15}, {0x1a,15}, {0x19,15}, {0x13,16}, {0x12,16}, {0x11,16}, {0x10,16}, {0x05, 5}, {0x07, 7}, {0xfc, 8}, {0x0c,10}, {0x14,13}, {0x07, 5}, {0x26, 8}, {0x1c,12}, {0x13,13}, {0x06, 6}, {0xfd, 8}, {0x12,12}, {0x07, 6}, {0x04, 9}, {0x12,13}, {0x06, 7}, {0x1e,12}, {0x14,16}, {0x04, 7}, {0x15,12}, {0x05, 7}, {0x11,12}, {0x78, 7}, {0x11,13}, {0x7a, 7}, {0x10,13}, {0x21, 8}, {0x1a,16}, {0x25, 8}, {0x19,16}, {0x24, 8}, {0x18,16}, {0x05, 9}, {0x17,16}, {0x07, 9}, {0x16,16}, {0x0d,10}, {0x15,16}, {0x1f,12}, {0x1a,12}, {0x19,12}, {0x17,12}, {0x16,12}, {0x1f,13}, {0x1e,13}, {0x1d,13}, {0x1c,13}, {0x1b,13}, {0x1f,16}, {0x1e,16}, {0x1d,16}, {0x1c,16}, {0x1b,16}, {0x01,6}, /* escape */ {0x06,4}, /* EOB */ }; static const int8_t mpeg1_level[111] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 1, 2, 3, 4, 5, 1, 2, 3, 4, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; static const int8_t mpeg1_run[111] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, }; RLTable ff_rl_mpeg1 = { 111, 111, mpeg1_vlc, mpeg1_run, mpeg1_level, }; RLTable ff_rl_mpeg2 = { 111, 111, mpeg2_vlc, mpeg1_run, mpeg1_level, }; const uint8_t ff_mpeg12_mbAddrIncrTable[36][2] = { {0x1, 1}, {0x3, 3}, {0x2, 3}, {0x3, 4}, {0x2, 4}, {0x3, 5}, {0x2, 5}, {0x7, 7}, {0x6, 7}, {0xb, 8}, {0xa, 8}, {0x9, 8}, {0x8, 8}, {0x7, 8}, {0x6, 8}, {0x17, 10}, {0x16, 10}, {0x15, 10}, {0x14, 10}, {0x13, 10}, {0x12, 10}, {0x23, 11}, {0x22, 11}, {0x21, 11}, {0x20, 11}, {0x1f, 11}, {0x1e, 11}, {0x1d, 11}, {0x1c, 11}, {0x1b, 11}, {0x1a, 11}, {0x19, 11}, {0x18, 11}, {0x8, 11}, /* escape */ {0xf, 11}, /* stuffing */ {0x0, 8}, /* end (and 15 more 0 bits should follow) */ }; const uint8_t ff_mpeg12_mbPatTable[64][2] = { {0x1, 9}, {0xb, 5}, {0x9, 5}, {0xd, 6}, {0xd, 4}, {0x17, 7}, {0x13, 7}, {0x1f, 8}, {0xc, 4}, {0x16, 7}, {0x12, 7}, {0x1e, 8}, {0x13, 5}, {0x1b, 8}, {0x17, 8}, {0x13, 8}, {0xb, 4}, {0x15, 7}, {0x11, 7}, {0x1d, 8}, {0x11, 5}, {0x19, 8}, {0x15, 8}, {0x11, 8}, {0xf, 6}, {0xf, 8}, {0xd, 8}, {0x3, 9}, {0xf, 5}, {0xb, 8}, {0x7, 8}, {0x7, 9}, {0xa, 4}, {0x14, 7}, {0x10, 7}, {0x1c, 8}, {0xe, 6}, {0xe, 8}, {0xc, 8}, {0x2, 9}, {0x10, 5}, {0x18, 8}, {0x14, 8}, {0x10, 8}, {0xe, 5}, {0xa, 8}, {0x6, 8}, {0x6, 9}, {0x12, 5}, {0x1a, 8}, {0x16, 8}, {0x12, 8}, {0xd, 5}, {0x9, 8}, {0x5, 8}, {0x5, 9}, {0xc, 5}, {0x8, 8}, {0x4, 8}, {0x4, 9}, {0x7, 3}, {0xa, 5}, {0x8, 5}, {0xc, 6} }; const uint8_t ff_mpeg12_mbMotionVectorTable[17][2] = { { 0x1, 1 }, { 0x1, 2 }, { 0x1, 3 }, { 0x1, 4 }, { 0x3, 6 }, { 0x5, 7 }, { 0x4, 7 }, { 0x3, 7 }, { 0xb, 9 }, { 0xa, 9 }, { 0x9, 9 }, { 0x11, 10 }, { 0x10, 10 }, { 0xf, 10 }, { 0xe, 10 }, { 0xd, 10 }, { 0xc, 10 }, }; const AVRational ff_frame_rate_tab[] = { { 0, 0}, {24000, 1001}, { 24, 1}, { 25, 1}, {30000, 1001}, { 30, 1}, { 50, 1}, {60000, 1001}, { 60, 1}, // Xing's 15fps: (9) { 15, 1}, // libmpeg3's "Unofficial economy rates": (10-13) { 5, 1}, { 10, 1}, { 12, 1}, { 15, 1}, { 0, 0}, }; const float ff_mpeg1_aspect[16]={ 0.0000, 1.0000, 0.6735, 0.7031, 0.7615, 0.8055, 0.8437, 0.8935, 0.9157, 0.9815, 1.0255, 1.0695, 1.0950, 1.1575, 1.2015, }; const AVRational ff_mpeg2_aspect[16]={ {0,1}, {1,1}, {4,3}, {16,9}, {221,100}, {0,1}, {0,1}, {0,1}, {0,1}, {0,1}, {0,1}, {0,1}, {0,1}, {0,1}, {0,1}, {0,1}, };
123linslouis-android-video-cutter
jni/libavcodec/mpeg12data.c
C
asf20
9,092
/* * FLAC data header * Copyright (c) 2003 Alex Beregszaszi * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AVCODEC_FLACDATA_H #define AVCODEC_FLACDATA_H #include "internal.h" extern const int ff_flac_sample_rate_table[16]; extern const int16_t ff_flac_blocksize_table[16]; #endif /* AVCODEC_FLACDATA_H */
123linslouis-android-video-cutter
jni/libavcodec/flacdata.h
C
asf20
1,036
/* * Copyright (c) 2003 The FFmpeg Project * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* * How to use this decoder: * SVQ3 data is transported within Apple Quicktime files. Quicktime files * have stsd atoms to describe media trak properties. A stsd atom for a * video trak contains 1 or more ImageDescription atoms. These atoms begin * with the 4-byte length of the atom followed by the codec fourcc. Some * decoders need information in this atom to operate correctly. Such * is the case with SVQ3. In order to get the best use out of this decoder, * the calling app must make the SVQ3 ImageDescription atom available * via the AVCodecContext's extradata[_size] field: * * AVCodecContext.extradata = pointer to ImageDescription, first characters * are expected to be 'S', 'V', 'Q', and '3', NOT the 4-byte atom length * AVCodecContext.extradata_size = size of ImageDescription atom memory * buffer (which will be the same as the ImageDescription atom size field * from the QT file, minus 4 bytes since the length is missing) * * You will know you have these parameters passed correctly when the decoder * correctly decodes this file: * http://samples.mplayerhq.hu/V-codecs/SVQ3/Vertical400kbit.sorenson3.mov */ #include "internal.h" #include "dsputil.h" #include "avcodec.h" #include "mpegvideo.h" #include "h264.h" #include "h264data.h" //FIXME FIXME FIXME #include "h264_mvpred.h" #include "golomb.h" #include "rectangle.h" #include "vdpau_internal.h" #if CONFIG_ZLIB #include <zlib.h> #endif #include "svq1.h" /** * @file * svq3 decoder. */ #define FULLPEL_MODE 1 #define HALFPEL_MODE 2 #define THIRDPEL_MODE 3 #define PREDICT_MODE 4 /* dual scan (from some older h264 draft) o-->o-->o o | /| o o o / o | / | |/ | o o o o / o-->o-->o-->o */ static const uint8_t svq3_scan[16] = { 0+0*4, 1+0*4, 2+0*4, 2+1*4, 2+2*4, 3+0*4, 3+1*4, 3+2*4, 0+1*4, 0+2*4, 1+1*4, 1+2*4, 0+3*4, 1+3*4, 2+3*4, 3+3*4, }; static const uint8_t svq3_pred_0[25][2] = { { 0, 0 }, { 1, 0 }, { 0, 1 }, { 0, 2 }, { 1, 1 }, { 2, 0 }, { 3, 0 }, { 2, 1 }, { 1, 2 }, { 0, 3 }, { 0, 4 }, { 1, 3 }, { 2, 2 }, { 3, 1 }, { 4, 0 }, { 4, 1 }, { 3, 2 }, { 2, 3 }, { 1, 4 }, { 2, 4 }, { 3, 3 }, { 4, 2 }, { 4, 3 }, { 3, 4 }, { 4, 4 } }; static const int8_t svq3_pred_1[6][6][5] = { { { 2,-1,-1,-1,-1 }, { 2, 1,-1,-1,-1 }, { 1, 2,-1,-1,-1 }, { 2, 1,-1,-1,-1 }, { 1, 2,-1,-1,-1 }, { 1, 2,-1,-1,-1 } }, { { 0, 2,-1,-1,-1 }, { 0, 2, 1, 4, 3 }, { 0, 1, 2, 4, 3 }, { 0, 2, 1, 4, 3 }, { 2, 0, 1, 3, 4 }, { 0, 4, 2, 1, 3 } }, { { 2, 0,-1,-1,-1 }, { 2, 1, 0, 4, 3 }, { 1, 2, 4, 0, 3 }, { 2, 1, 0, 4, 3 }, { 2, 1, 4, 3, 0 }, { 1, 2, 4, 0, 3 } }, { { 2, 0,-1,-1,-1 }, { 2, 0, 1, 4, 3 }, { 1, 2, 0, 4, 3 }, { 2, 1, 0, 4, 3 }, { 2, 1, 3, 4, 0 }, { 2, 4, 1, 0, 3 } }, { { 0, 2,-1,-1,-1 }, { 0, 2, 1, 3, 4 }, { 1, 2, 3, 0, 4 }, { 2, 0, 1, 3, 4 }, { 2, 1, 3, 0, 4 }, { 2, 0, 4, 3, 1 } }, { { 0, 2,-1,-1,-1 }, { 0, 2, 4, 1, 3 }, { 1, 4, 2, 0, 3 }, { 4, 2, 0, 1, 3 }, { 2, 0, 1, 4, 3 }, { 4, 2, 1, 0, 3 } }, }; static const struct { uint8_t run; uint8_t level; } svq3_dct_tables[2][16] = { { { 0, 0 }, { 0, 1 }, { 1, 1 }, { 2, 1 }, { 0, 2 }, { 3, 1 }, { 4, 1 }, { 5, 1 }, { 0, 3 }, { 1, 2 }, { 2, 2 }, { 6, 1 }, { 7, 1 }, { 8, 1 }, { 9, 1 }, { 0, 4 } }, { { 0, 0 }, { 0, 1 }, { 1, 1 }, { 0, 2 }, { 2, 1 }, { 0, 3 }, { 0, 4 }, { 0, 5 }, { 3, 1 }, { 4, 1 }, { 1, 2 }, { 1, 3 }, { 0, 6 }, { 0, 7 }, { 0, 8 }, { 0, 9 } } }; static const uint32_t svq3_dequant_coeff[32] = { 3881, 4351, 4890, 5481, 6154, 6914, 7761, 8718, 9781, 10987, 12339, 13828, 15523, 17435, 19561, 21873, 24552, 27656, 30847, 34870, 38807, 43747, 49103, 54683, 61694, 68745, 77615, 89113,100253,109366,126635,141533 }; void ff_svq3_luma_dc_dequant_idct_c(DCTELEM *block, int qp) { const int qmul = svq3_dequant_coeff[qp]; #define stride 16 int i; int temp[16]; static const int x_offset[4] = {0, 1*stride, 4* stride, 5*stride}; static const int y_offset[4] = {0, 2*stride, 8* stride, 10*stride}; for (i = 0; i < 4; i++){ const int offset = y_offset[i]; const int z0 = 13*(block[offset+stride*0] + block[offset+stride*4]); const int z1 = 13*(block[offset+stride*0] - block[offset+stride*4]); const int z2 = 7* block[offset+stride*1] - 17*block[offset+stride*5]; const int z3 = 17* block[offset+stride*1] + 7*block[offset+stride*5]; temp[4*i+0] = z0+z3; temp[4*i+1] = z1+z2; temp[4*i+2] = z1-z2; temp[4*i+3] = z0-z3; } for (i = 0; i < 4; i++){ const int offset = x_offset[i]; const int z0 = 13*(temp[4*0+i] + temp[4*2+i]); const int z1 = 13*(temp[4*0+i] - temp[4*2+i]); const int z2 = 7* temp[4*1+i] - 17*temp[4*3+i]; const int z3 = 17* temp[4*1+i] + 7*temp[4*3+i]; block[stride*0 +offset] = ((z0 + z3)*qmul + 0x80000) >> 20; block[stride*2 +offset] = ((z1 + z2)*qmul + 0x80000) >> 20; block[stride*8 +offset] = ((z1 - z2)*qmul + 0x80000) >> 20; block[stride*10+offset] = ((z0 - z3)*qmul + 0x80000) >> 20; } } #undef stride void ff_svq3_add_idct_c(uint8_t *dst, DCTELEM *block, int stride, int qp, int dc) { const int qmul = svq3_dequant_coeff[qp]; int i; uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; if (dc) { dc = 13*13*((dc == 1) ? 1538*block[0] : ((qmul*(block[0] >> 3)) / 2)); block[0] = 0; } for (i = 0; i < 4; i++) { const int z0 = 13*(block[0 + 4*i] + block[2 + 4*i]); const int z1 = 13*(block[0 + 4*i] - block[2 + 4*i]); const int z2 = 7* block[1 + 4*i] - 17*block[3 + 4*i]; const int z3 = 17* block[1 + 4*i] + 7*block[3 + 4*i]; block[0 + 4*i] = z0 + z3; block[1 + 4*i] = z1 + z2; block[2 + 4*i] = z1 - z2; block[3 + 4*i] = z0 - z3; } for (i = 0; i < 4; i++) { const int z0 = 13*(block[i + 4*0] + block[i + 4*2]); const int z1 = 13*(block[i + 4*0] - block[i + 4*2]); const int z2 = 7* block[i + 4*1] - 17*block[i + 4*3]; const int z3 = 17* block[i + 4*1] + 7*block[i + 4*3]; const int rr = (dc + 0x80000); dst[i + stride*0] = cm[ dst[i + stride*0] + (((z0 + z3)*qmul + rr) >> 20) ]; dst[i + stride*1] = cm[ dst[i + stride*1] + (((z1 + z2)*qmul + rr) >> 20) ]; dst[i + stride*2] = cm[ dst[i + stride*2] + (((z1 - z2)*qmul + rr) >> 20) ]; dst[i + stride*3] = cm[ dst[i + stride*3] + (((z0 - z3)*qmul + rr) >> 20) ]; } } static inline int svq3_decode_block(GetBitContext *gb, DCTELEM *block, int index, const int type) { static const uint8_t *const scan_patterns[4] = { luma_dc_zigzag_scan, zigzag_scan, svq3_scan, chroma_dc_scan }; int run, level, sign, vlc, limit; const int intra = (3 * type) >> 2; const uint8_t *const scan = scan_patterns[type]; for (limit = (16 >> intra); index < 16; index = limit, limit += 8) { for (; (vlc = svq3_get_ue_golomb(gb)) != 0; index++) { if (vlc == INVALID_VLC) return -1; sign = (vlc & 0x1) - 1; vlc = (vlc + 1) >> 1; if (type == 3) { if (vlc < 3) { run = 0; level = vlc; } else if (vlc < 4) { run = 1; level = 1; } else { run = (vlc & 0x3); level = ((vlc + 9) >> 2) - run; } } else { if (vlc < 16) { run = svq3_dct_tables[intra][vlc].run; level = svq3_dct_tables[intra][vlc].level; } else if (intra) { run = (vlc & 0x7); level = (vlc >> 3) + ((run == 0) ? 8 : ((run < 2) ? 2 : ((run < 5) ? 0 : -1))); } else { run = (vlc & 0xF); level = (vlc >> 4) + ((run == 0) ? 4 : ((run < 3) ? 2 : ((run < 10) ? 1 : 0))); } } if ((index += run) >= limit) return -1; block[scan[index]] = (level ^ sign) - sign; } if (type != 2) { break; } } return 0; } static inline void svq3_mc_dir_part(MpegEncContext *s, int x, int y, int width, int height, int mx, int my, int dxy, int thirdpel, int dir, int avg) { const Picture *pic = (dir == 0) ? &s->last_picture : &s->next_picture; uint8_t *src, *dest; int i, emu = 0; int blocksize = 2 - (width>>3); //16->0, 8->1, 4->2 mx += x; my += y; if (mx < 0 || mx >= (s->h_edge_pos - width - 1) || my < 0 || my >= (s->v_edge_pos - height - 1)) { if ((s->flags & CODEC_FLAG_EMU_EDGE)) { emu = 1; } mx = av_clip (mx, -16, (s->h_edge_pos - width + 15)); my = av_clip (my, -16, (s->v_edge_pos - height + 15)); } /* form component predictions */ dest = s->current_picture.data[0] + x + y*s->linesize; src = pic->data[0] + mx + my*s->linesize; if (emu) { ff_emulated_edge_mc(s->edge_emu_buffer, src, s->linesize, (width + 1), (height + 1), mx, my, s->h_edge_pos, s->v_edge_pos); src = s->edge_emu_buffer; } if (thirdpel) (avg ? s->dsp.avg_tpel_pixels_tab : s->dsp.put_tpel_pixels_tab)[dxy](dest, src, s->linesize, width, height); else (avg ? s->dsp.avg_pixels_tab : s->dsp.put_pixels_tab)[blocksize][dxy](dest, src, s->linesize, height); if (!(s->flags & CODEC_FLAG_GRAY)) { mx = (mx + (mx < (int) x)) >> 1; my = (my + (my < (int) y)) >> 1; width = (width >> 1); height = (height >> 1); blocksize++; for (i = 1; i < 3; i++) { dest = s->current_picture.data[i] + (x >> 1) + (y >> 1)*s->uvlinesize; src = pic->data[i] + mx + my*s->uvlinesize; if (emu) { ff_emulated_edge_mc(s->edge_emu_buffer, src, s->uvlinesize, (width + 1), (height + 1), mx, my, (s->h_edge_pos >> 1), (s->v_edge_pos >> 1)); src = s->edge_emu_buffer; } if (thirdpel) (avg ? s->dsp.avg_tpel_pixels_tab : s->dsp.put_tpel_pixels_tab)[dxy](dest, src, s->uvlinesize, width, height); else (avg ? s->dsp.avg_pixels_tab : s->dsp.put_pixels_tab)[blocksize][dxy](dest, src, s->uvlinesize, height); } } } static inline int svq3_mc_dir(H264Context *h, int size, int mode, int dir, int avg) { int i, j, k, mx, my, dx, dy, x, y; MpegEncContext *const s = (MpegEncContext *) h; const int part_width = ((size & 5) == 4) ? 4 : 16 >> (size & 1); const int part_height = 16 >> ((unsigned) (size + 1) / 3); const int extra_width = (mode == PREDICT_MODE) ? -16*6 : 0; const int h_edge_pos = 6*(s->h_edge_pos - part_width ) - extra_width; const int v_edge_pos = 6*(s->v_edge_pos - part_height) - extra_width; for (i = 0; i < 16; i += part_height) { for (j = 0; j < 16; j += part_width) { const int b_xy = (4*s->mb_x + (j >> 2)) + (4*s->mb_y + (i >> 2))*h->b_stride; int dxy; x = 16*s->mb_x + j; y = 16*s->mb_y + i; k = ((j >> 2) & 1) + ((i >> 1) & 2) + ((j >> 1) & 4) + (i & 8); if (mode != PREDICT_MODE) { pred_motion(h, k, (part_width >> 2), dir, 1, &mx, &my); } else { mx = s->next_picture.motion_val[0][b_xy][0]<<1; my = s->next_picture.motion_val[0][b_xy][1]<<1; if (dir == 0) { mx = ((mx * h->frame_num_offset) / h->prev_frame_num_offset + 1) >> 1; my = ((my * h->frame_num_offset) / h->prev_frame_num_offset + 1) >> 1; } else { mx = ((mx * (h->frame_num_offset - h->prev_frame_num_offset)) / h->prev_frame_num_offset + 1) >> 1; my = ((my * (h->frame_num_offset - h->prev_frame_num_offset)) / h->prev_frame_num_offset + 1) >> 1; } } /* clip motion vector prediction to frame border */ mx = av_clip(mx, extra_width - 6*x, h_edge_pos - 6*x); my = av_clip(my, extra_width - 6*y, v_edge_pos - 6*y); /* get (optional) motion vector differential */ if (mode == PREDICT_MODE) { dx = dy = 0; } else { dy = svq3_get_se_golomb(&s->gb); dx = svq3_get_se_golomb(&s->gb); if (dx == INVALID_VLC || dy == INVALID_VLC) { av_log(h->s.avctx, AV_LOG_ERROR, "invalid MV vlc\n"); return -1; } } /* compute motion vector */ if (mode == THIRDPEL_MODE) { int fx, fy; mx = ((mx + 1)>>1) + dx; my = ((my + 1)>>1) + dy; fx = ((unsigned)(mx + 0x3000))/3 - 0x1000; fy = ((unsigned)(my + 0x3000))/3 - 0x1000; dxy = (mx - 3*fx) + 4*(my - 3*fy); svq3_mc_dir_part(s, x, y, part_width, part_height, fx, fy, dxy, 1, dir, avg); mx += mx; my += my; } else if (mode == HALFPEL_MODE || mode == PREDICT_MODE) { mx = ((unsigned)(mx + 1 + 0x3000))/3 + dx - 0x1000; my = ((unsigned)(my + 1 + 0x3000))/3 + dy - 0x1000; dxy = (mx&1) + 2*(my&1); svq3_mc_dir_part(s, x, y, part_width, part_height, mx>>1, my>>1, dxy, 0, dir, avg); mx *= 3; my *= 3; } else { mx = ((unsigned)(mx + 3 + 0x6000))/6 + dx - 0x1000; my = ((unsigned)(my + 3 + 0x6000))/6 + dy - 0x1000; svq3_mc_dir_part(s, x, y, part_width, part_height, mx, my, 0, 0, dir, avg); mx *= 6; my *= 6; } /* update mv_cache */ if (mode != PREDICT_MODE) { int32_t mv = pack16to32(mx,my); if (part_height == 8 && i < 8) { *(int32_t *) h->mv_cache[dir][scan8[k] + 1*8] = mv; if (part_width == 8 && j < 8) { *(int32_t *) h->mv_cache[dir][scan8[k] + 1 + 1*8] = mv; } } if (part_width == 8 && j < 8) { *(int32_t *) h->mv_cache[dir][scan8[k] + 1] = mv; } if (part_width == 4 || part_height == 4) { *(int32_t *) h->mv_cache[dir][scan8[k]] = mv; } } /* write back motion vectors */ fill_rectangle(s->current_picture.motion_val[dir][b_xy], part_width>>2, part_height>>2, h->b_stride, pack16to32(mx,my), 4); } } return 0; } static int svq3_decode_mb(H264Context *h, unsigned int mb_type) { int i, j, k, m, dir, mode; int cbp = 0; uint32_t vlc; int8_t *top, *left; MpegEncContext *const s = (MpegEncContext *) h; const int mb_xy = h->mb_xy; const int b_xy = 4*s->mb_x + 4*s->mb_y*h->b_stride; h->top_samples_available = (s->mb_y == 0) ? 0x33FF : 0xFFFF; h->left_samples_available = (s->mb_x == 0) ? 0x5F5F : 0xFFFF; h->topright_samples_available = 0xFFFF; if (mb_type == 0) { /* SKIP */ if (s->pict_type == FF_P_TYPE || s->next_picture.mb_type[mb_xy] == -1) { svq3_mc_dir_part(s, 16*s->mb_x, 16*s->mb_y, 16, 16, 0, 0, 0, 0, 0, 0); if (s->pict_type == FF_B_TYPE) { svq3_mc_dir_part(s, 16*s->mb_x, 16*s->mb_y, 16, 16, 0, 0, 0, 0, 1, 1); } mb_type = MB_TYPE_SKIP; } else { mb_type = FFMIN(s->next_picture.mb_type[mb_xy], 6); if (svq3_mc_dir(h, mb_type, PREDICT_MODE, 0, 0) < 0) return -1; if (svq3_mc_dir(h, mb_type, PREDICT_MODE, 1, 1) < 0) return -1; mb_type = MB_TYPE_16x16; } } else if (mb_type < 8) { /* INTER */ if (h->thirdpel_flag && h->halfpel_flag == !get_bits1 (&s->gb)) { mode = THIRDPEL_MODE; } else if (h->halfpel_flag && h->thirdpel_flag == !get_bits1 (&s->gb)) { mode = HALFPEL_MODE; } else { mode = FULLPEL_MODE; } /* fill caches */ /* note ref_cache should contain here: ???????? ???11111 N??11111 N??11111 N??11111 */ for (m = 0; m < 2; m++) { if (s->mb_x > 0 && h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1]+6] != -1) { for (i = 0; i < 4; i++) { *(uint32_t *) h->mv_cache[m][scan8[0] - 1 + i*8] = *(uint32_t *) s->current_picture.motion_val[m][b_xy - 1 + i*h->b_stride]; } } else { for (i = 0; i < 4; i++) { *(uint32_t *) h->mv_cache[m][scan8[0] - 1 + i*8] = 0; } } if (s->mb_y > 0) { memcpy(h->mv_cache[m][scan8[0] - 1*8], s->current_picture.motion_val[m][b_xy - h->b_stride], 4*2*sizeof(int16_t)); memset(&h->ref_cache[m][scan8[0] - 1*8], (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]] == -1) ? PART_NOT_AVAILABLE : 1, 4); if (s->mb_x < (s->mb_width - 1)) { *(uint32_t *) h->mv_cache[m][scan8[0] + 4 - 1*8] = *(uint32_t *) s->current_picture.motion_val[m][b_xy - h->b_stride + 4]; h->ref_cache[m][scan8[0] + 4 - 1*8] = (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride + 1]+6] == -1 || h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride ] ] == -1) ? PART_NOT_AVAILABLE : 1; }else h->ref_cache[m][scan8[0] + 4 - 1*8] = PART_NOT_AVAILABLE; if (s->mb_x > 0) { *(uint32_t *) h->mv_cache[m][scan8[0] - 1 - 1*8] = *(uint32_t *) s->current_picture.motion_val[m][b_xy - h->b_stride - 1]; h->ref_cache[m][scan8[0] - 1 - 1*8] = (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride - 1]+3] == -1) ? PART_NOT_AVAILABLE : 1; }else h->ref_cache[m][scan8[0] - 1 - 1*8] = PART_NOT_AVAILABLE; }else memset(&h->ref_cache[m][scan8[0] - 1*8 - 1], PART_NOT_AVAILABLE, 8); if (s->pict_type != FF_B_TYPE) break; } /* decode motion vector(s) and form prediction(s) */ if (s->pict_type == FF_P_TYPE) { if (svq3_mc_dir(h, (mb_type - 1), mode, 0, 0) < 0) return -1; } else { /* FF_B_TYPE */ if (mb_type != 2) { if (svq3_mc_dir(h, 0, mode, 0, 0) < 0) return -1; } else { for (i = 0; i < 4; i++) { memset(s->current_picture.motion_val[0][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t)); } } if (mb_type != 1) { if (svq3_mc_dir(h, 0, mode, 1, (mb_type == 3)) < 0) return -1; } else { for (i = 0; i < 4; i++) { memset(s->current_picture.motion_val[1][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t)); } } } mb_type = MB_TYPE_16x16; } else if (mb_type == 8 || mb_type == 33) { /* INTRA4x4 */ memset(h->intra4x4_pred_mode_cache, -1, 8*5*sizeof(int8_t)); if (mb_type == 8) { if (s->mb_x > 0) { for (i = 0; i < 4; i++) { h->intra4x4_pred_mode_cache[scan8[0] - 1 + i*8] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1]+6-i]; } if (h->intra4x4_pred_mode_cache[scan8[0] - 1] == -1) { h->left_samples_available = 0x5F5F; } } if (s->mb_y > 0) { h->intra4x4_pred_mode_cache[4+8*0] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]+0]; h->intra4x4_pred_mode_cache[5+8*0] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]+1]; h->intra4x4_pred_mode_cache[6+8*0] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]+2]; h->intra4x4_pred_mode_cache[7+8*0] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]+3]; if (h->intra4x4_pred_mode_cache[4+8*0] == -1) { h->top_samples_available = 0x33FF; } } /* decode prediction codes for luma blocks */ for (i = 0; i < 16; i+=2) { vlc = svq3_get_ue_golomb(&s->gb); if (vlc >= 25){ av_log(h->s.avctx, AV_LOG_ERROR, "luma prediction:%d\n", vlc); return -1; } left = &h->intra4x4_pred_mode_cache[scan8[i] - 1]; top = &h->intra4x4_pred_mode_cache[scan8[i] - 8]; left[1] = svq3_pred_1[top[0] + 1][left[0] + 1][svq3_pred_0[vlc][0]]; left[2] = svq3_pred_1[top[1] + 1][left[1] + 1][svq3_pred_0[vlc][1]]; if (left[1] == -1 || left[2] == -1){ av_log(h->s.avctx, AV_LOG_ERROR, "weird prediction\n"); return -1; } } } else { /* mb_type == 33, DC_128_PRED block type */ for (i = 0; i < 4; i++) { memset(&h->intra4x4_pred_mode_cache[scan8[0] + 8*i], DC_PRED, 4); } } ff_h264_write_back_intra_pred_mode(h); if (mb_type == 8) { ff_h264_check_intra4x4_pred_mode(h); h->top_samples_available = (s->mb_y == 0) ? 0x33FF : 0xFFFF; h->left_samples_available = (s->mb_x == 0) ? 0x5F5F : 0xFFFF; } else { for (i = 0; i < 4; i++) { memset(&h->intra4x4_pred_mode_cache[scan8[0] + 8*i], DC_128_PRED, 4); } h->top_samples_available = 0x33FF; h->left_samples_available = 0x5F5F; } mb_type = MB_TYPE_INTRA4x4; } else { /* INTRA16x16 */ dir = i_mb_type_info[mb_type - 8].pred_mode; dir = (dir >> 1) ^ 3*(dir & 1) ^ 1; if ((h->intra16x16_pred_mode = ff_h264_check_intra_pred_mode(h, dir)) == -1){ av_log(h->s.avctx, AV_LOG_ERROR, "check_intra_pred_mode = -1\n"); return -1; } cbp = i_mb_type_info[mb_type - 8].cbp; mb_type = MB_TYPE_INTRA16x16; } if (!IS_INTER(mb_type) && s->pict_type != FF_I_TYPE) { for (i = 0; i < 4; i++) { memset(s->current_picture.motion_val[0][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t)); } if (s->pict_type == FF_B_TYPE) { for (i = 0; i < 4; i++) { memset(s->current_picture.motion_val[1][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t)); } } } if (!IS_INTRA4x4(mb_type)) { memset(h->intra4x4_pred_mode+h->mb2br_xy[mb_xy], DC_PRED, 8); } if (!IS_SKIP(mb_type) || s->pict_type == FF_B_TYPE) { memset(h->non_zero_count_cache + 8, 0, 4*9*sizeof(uint8_t)); s->dsp.clear_blocks(h->mb); } if (!IS_INTRA16x16(mb_type) && (!IS_SKIP(mb_type) || s->pict_type == FF_B_TYPE)) { if ((vlc = svq3_get_ue_golomb(&s->gb)) >= 48){ av_log(h->s.avctx, AV_LOG_ERROR, "cbp_vlc=%d\n", vlc); return -1; } cbp = IS_INTRA(mb_type) ? golomb_to_intra4x4_cbp[vlc] : golomb_to_inter_cbp[vlc]; } if (IS_INTRA16x16(mb_type) || (s->pict_type != FF_I_TYPE && s->adaptive_quant && cbp)) { s->qscale += svq3_get_se_golomb(&s->gb); if (s->qscale > 31){ av_log(h->s.avctx, AV_LOG_ERROR, "qscale:%d\n", s->qscale); return -1; } } if (IS_INTRA16x16(mb_type)) { if (svq3_decode_block(&s->gb, h->mb, 0, 0)){ av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding intra luma dc\n"); return -1; } } if (cbp) { const int index = IS_INTRA16x16(mb_type) ? 1 : 0; const int type = ((s->qscale < 24 && IS_INTRA4x4(mb_type)) ? 2 : 1); for (i = 0; i < 4; i++) { if ((cbp & (1 << i))) { for (j = 0; j < 4; j++) { k = index ? ((j&1) + 2*(i&1) + 2*(j&2) + 4*(i&2)) : (4*i + j); h->non_zero_count_cache[ scan8[k] ] = 1; if (svq3_decode_block(&s->gb, &h->mb[16*k], index, type)){ av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding block\n"); return -1; } } } } if ((cbp & 0x30)) { for (i = 0; i < 2; ++i) { if (svq3_decode_block(&s->gb, &h->mb[16*(16 + 4*i)], 0, 3)){ av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding chroma dc block\n"); return -1; } } if ((cbp & 0x20)) { for (i = 0; i < 8; i++) { h->non_zero_count_cache[ scan8[16+i] ] = 1; if (svq3_decode_block(&s->gb, &h->mb[16*(16 + i)], 1, 1)){ av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding chroma ac block\n"); return -1; } } } } } h->cbp= cbp; s->current_picture.mb_type[mb_xy] = mb_type; if (IS_INTRA(mb_type)) { h->chroma_pred_mode = ff_h264_check_intra_pred_mode(h, DC_PRED8x8); } return 0; } static int svq3_decode_slice_header(H264Context *h) { MpegEncContext *const s = (MpegEncContext *) h; const int mb_xy = h->mb_xy; int i, header; header = get_bits(&s->gb, 8); if (((header & 0x9F) != 1 && (header & 0x9F) != 2) || (header & 0x60) == 0) { /* TODO: what? */ av_log(h->s.avctx, AV_LOG_ERROR, "unsupported slice header (%02X)\n", header); return -1; } else { int length = (header >> 5) & 3; h->next_slice_index = get_bits_count(&s->gb) + 8*show_bits(&s->gb, 8*length) + 8*length; if (h->next_slice_index > s->gb.size_in_bits) { av_log(h->s.avctx, AV_LOG_ERROR, "slice after bitstream end\n"); return -1; } s->gb.size_in_bits = h->next_slice_index - 8*(length - 1); skip_bits(&s->gb, 8); if (h->svq3_watermark_key) { uint32_t header = AV_RL32(&s->gb.buffer[(get_bits_count(&s->gb)>>3)+1]); AV_WL32(&s->gb.buffer[(get_bits_count(&s->gb)>>3)+1], header ^ h->svq3_watermark_key); } if (length > 0) { memcpy((uint8_t *) &s->gb.buffer[get_bits_count(&s->gb) >> 3], &s->gb.buffer[s->gb.size_in_bits >> 3], (length - 1)); } skip_bits_long(&s->gb, 0); } if ((i = svq3_get_ue_golomb(&s->gb)) == INVALID_VLC || i >= 3){ av_log(h->s.avctx, AV_LOG_ERROR, "illegal slice type %d \n", i); return -1; } h->slice_type = golomb_to_pict_type[i]; if ((header & 0x9F) == 2) { i = (s->mb_num < 64) ? 6 : (1 + av_log2 (s->mb_num - 1)); s->mb_skip_run = get_bits(&s->gb, i) - (s->mb_x + (s->mb_y * s->mb_width)); } else { skip_bits1(&s->gb); s->mb_skip_run = 0; } h->slice_num = get_bits(&s->gb, 8); s->qscale = get_bits(&s->gb, 5); s->adaptive_quant = get_bits1(&s->gb); /* unknown fields */ skip_bits1(&s->gb); if (h->unknown_svq3_flag) { skip_bits1(&s->gb); } skip_bits1(&s->gb); skip_bits(&s->gb, 2); while (get_bits1(&s->gb)) { skip_bits(&s->gb, 8); } /* reset intra predictors and invalidate motion vector references */ if (s->mb_x > 0) { memset(h->intra4x4_pred_mode+h->mb2br_xy[mb_xy - 1 ]+3, -1, 4*sizeof(int8_t)); memset(h->intra4x4_pred_mode+h->mb2br_xy[mb_xy - s->mb_x] , -1, 8*sizeof(int8_t)*s->mb_x); } if (s->mb_y > 0) { memset(h->intra4x4_pred_mode+h->mb2br_xy[mb_xy - s->mb_stride], -1, 8*sizeof(int8_t)*(s->mb_width - s->mb_x)); if (s->mb_x > 0) { h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride - 1]+3] = -1; } } return 0; } static av_cold int svq3_decode_init(AVCodecContext *avctx) { MpegEncContext *const s = avctx->priv_data; H264Context *const h = avctx->priv_data; int m; unsigned char *extradata; unsigned int size; if(avctx->thread_count > 1){ av_log(avctx, AV_LOG_ERROR, "SVQ3 does not support multithreaded decoding, patch welcome! (check latest SVN too)\n"); return -1; } if (ff_h264_decode_init(avctx) < 0) return -1; s->flags = avctx->flags; s->flags2 = avctx->flags2; s->unrestricted_mv = 1; h->is_complex=1; avctx->pix_fmt = avctx->codec->pix_fmts[0]; if (!s->context_initialized) { s->width = avctx->width; s->height = avctx->height; h->halfpel_flag = 1; h->thirdpel_flag = 1; h->unknown_svq3_flag = 0; h->chroma_qp[0] = h->chroma_qp[1] = 4; if (MPV_common_init(s) < 0) return -1; h->b_stride = 4*s->mb_width; ff_h264_alloc_tables(h); /* prowl for the "SEQH" marker in the extradata */ extradata = (unsigned char *)avctx->extradata; for (m = 0; m < avctx->extradata_size; m++) { if (!memcmp(extradata, "SEQH", 4)) break; extradata++; } /* if a match was found, parse the extra data */ if (extradata && !memcmp(extradata, "SEQH", 4)) { GetBitContext gb; int frame_size_code; size = AV_RB32(&extradata[4]); init_get_bits(&gb, extradata + 8, size*8); /* 'frame size code' and optional 'width, height' */ frame_size_code = get_bits(&gb, 3); switch (frame_size_code) { case 0: avctx->width = 160; avctx->height = 120; break; case 1: avctx->width = 128; avctx->height = 96; break; case 2: avctx->width = 176; avctx->height = 144; break; case 3: avctx->width = 352; avctx->height = 288; break; case 4: avctx->width = 704; avctx->height = 576; break; case 5: avctx->width = 240; avctx->height = 180; break; case 6: avctx->width = 320; avctx->height = 240; break; case 7: avctx->width = get_bits(&gb, 12); avctx->height = get_bits(&gb, 12); break; } h->halfpel_flag = get_bits1(&gb); h->thirdpel_flag = get_bits1(&gb); /* unknown fields */ skip_bits1(&gb); skip_bits1(&gb); skip_bits1(&gb); skip_bits1(&gb); s->low_delay = get_bits1(&gb); /* unknown field */ skip_bits1(&gb); while (get_bits1(&gb)) { skip_bits(&gb, 8); } h->unknown_svq3_flag = get_bits1(&gb); avctx->has_b_frames = !s->low_delay; if (h->unknown_svq3_flag) { #if CONFIG_ZLIB unsigned watermark_width = svq3_get_ue_golomb(&gb); unsigned watermark_height = svq3_get_ue_golomb(&gb); int u1 = svq3_get_ue_golomb(&gb); int u2 = get_bits(&gb, 8); int u3 = get_bits(&gb, 2); int u4 = svq3_get_ue_golomb(&gb); unsigned buf_len = watermark_width*watermark_height*4; int offset = (get_bits_count(&gb)+7)>>3; uint8_t *buf; if ((uint64_t)watermark_width*4 > UINT_MAX/watermark_height) return -1; buf = av_malloc(buf_len); av_log(avctx, AV_LOG_DEBUG, "watermark size: %dx%d\n", watermark_width, watermark_height); av_log(avctx, AV_LOG_DEBUG, "u1: %x u2: %x u3: %x compressed data size: %d offset: %d\n", u1, u2, u3, u4, offset); if (uncompress(buf, (uLong*)&buf_len, extradata + 8 + offset, size - offset) != Z_OK) { av_log(avctx, AV_LOG_ERROR, "could not uncompress watermark logo\n"); av_free(buf); return -1; } h->svq3_watermark_key = ff_svq1_packet_checksum(buf, buf_len, 0); h->svq3_watermark_key = h->svq3_watermark_key << 16 | h->svq3_watermark_key; av_log(avctx, AV_LOG_DEBUG, "watermark key %#x\n", h->svq3_watermark_key); av_free(buf); #else av_log(avctx, AV_LOG_ERROR, "this svq3 file contains watermark which need zlib support compiled in\n"); return -1; #endif } } } return 0; } static int svq3_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; MpegEncContext *const s = avctx->priv_data; H264Context *const h = avctx->priv_data; int m, mb_type; /* special case for last picture */ if (buf_size == 0) { if (s->next_picture_ptr && !s->low_delay) { *(AVFrame *) data = *(AVFrame *) &s->next_picture; s->next_picture_ptr = NULL; *data_size = sizeof(AVFrame); } return 0; } init_get_bits (&s->gb, buf, 8*buf_size); s->mb_x = s->mb_y = h->mb_xy = 0; if (svq3_decode_slice_header(h)) return -1; s->pict_type = h->slice_type; s->picture_number = h->slice_num; if (avctx->debug&FF_DEBUG_PICT_INFO){ av_log(h->s.avctx, AV_LOG_DEBUG, "%c hpel:%d, tpel:%d aqp:%d qp:%d, slice_num:%02X\n", av_get_pict_type_char(s->pict_type), h->halfpel_flag, h->thirdpel_flag, s->adaptive_quant, s->qscale, h->slice_num); } /* for hurry_up == 5 */ s->current_picture.pict_type = s->pict_type; s->current_picture.key_frame = (s->pict_type == FF_I_TYPE); /* Skip B-frames if we do not have reference frames. */ if (s->last_picture_ptr == NULL && s->pict_type == FF_B_TYPE) return 0; /* Skip B-frames if we are in a hurry. */ if (avctx->hurry_up && s->pict_type == FF_B_TYPE) return 0; /* Skip everything if we are in a hurry >= 5. */ if (avctx->hurry_up >= 5) return 0; if ( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == FF_B_TYPE) ||(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != FF_I_TYPE) || avctx->skip_frame >= AVDISCARD_ALL) return 0; if (s->next_p_frame_damaged) { if (s->pict_type == FF_B_TYPE) return 0; else s->next_p_frame_damaged = 0; } if (ff_h264_frame_start(h) < 0) return -1; if (s->pict_type == FF_B_TYPE) { h->frame_num_offset = (h->slice_num - h->prev_frame_num); if (h->frame_num_offset < 0) { h->frame_num_offset += 256; } if (h->frame_num_offset == 0 || h->frame_num_offset >= h->prev_frame_num_offset) { av_log(h->s.avctx, AV_LOG_ERROR, "error in B-frame picture id\n"); return -1; } } else { h->prev_frame_num = h->frame_num; h->frame_num = h->slice_num; h->prev_frame_num_offset = (h->frame_num - h->prev_frame_num); if (h->prev_frame_num_offset < 0) { h->prev_frame_num_offset += 256; } } for (m = 0; m < 2; m++){ int i; for (i = 0; i < 4; i++){ int j; for (j = -1; j < 4; j++) h->ref_cache[m][scan8[0] + 8*i + j]= 1; if (i < 3) h->ref_cache[m][scan8[0] + 8*i + j]= PART_NOT_AVAILABLE; } } for (s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) { for (s->mb_x = 0; s->mb_x < s->mb_width; s->mb_x++) { h->mb_xy = s->mb_x + s->mb_y*s->mb_stride; if ( (get_bits_count(&s->gb) + 7) >= s->gb.size_in_bits && ((get_bits_count(&s->gb) & 7) == 0 || show_bits(&s->gb, (-get_bits_count(&s->gb) & 7)) == 0)) { skip_bits(&s->gb, h->next_slice_index - get_bits_count(&s->gb)); s->gb.size_in_bits = 8*buf_size; if (svq3_decode_slice_header(h)) return -1; /* TODO: support s->mb_skip_run */ } mb_type = svq3_get_ue_golomb(&s->gb); if (s->pict_type == FF_I_TYPE) { mb_type += 8; } else if (s->pict_type == FF_B_TYPE && mb_type >= 4) { mb_type += 4; } if (mb_type > 33 || svq3_decode_mb(h, mb_type)) { av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d\n", s->mb_x, s->mb_y); return -1; } if (mb_type != 0) { ff_h264_hl_decode_mb (h); } if (s->pict_type != FF_B_TYPE && !s->low_delay) { s->current_picture.mb_type[s->mb_x + s->mb_y*s->mb_stride] = (s->pict_type == FF_P_TYPE && mb_type < 8) ? (mb_type - 1) : -1; } } ff_draw_horiz_band(s, 16*s->mb_y, 16); } MPV_frame_end(s); if (s->pict_type == FF_B_TYPE || s->low_delay) { *(AVFrame *) data = *(AVFrame *) &s->current_picture; } else { *(AVFrame *) data = *(AVFrame *) &s->last_picture; } /* Do not output the last pic after seeking. */ if (s->last_picture_ptr || s->low_delay) { *data_size = sizeof(AVFrame); } return buf_size; } AVCodec svq3_decoder = { "svq3", AVMEDIA_TYPE_VIDEO, CODEC_ID_SVQ3, sizeof(H264Context), svq3_decode_init, NULL, ff_h264_decode_end, svq3_decode_frame, CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_DELAY, .long_name = NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 3 / Sorenson Video 3 / SVQ3"), .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUVJ420P, PIX_FMT_NONE}, };
123linslouis-android-video-cutter
jni/libavcodec/svq3.c
C
asf20
39,627
/* * MJPEG encoder and decoder * Copyright (c) 2000, 2001 Fabrice Bellard * Copyright (c) 2003 Alex Beregszaszi * Copyright (c) 2003-2004 Michael Niedermayer * * Support for external huffman table, various fixes (AVID workaround), * aspecting, new decode_frame mechanism and apple mjpeg-b support * by Alex Beregszaszi * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * MJPEG encoder and decoder. */ #include "mjpeg.h" #if 0 /* These are the sample quantization tables given in JPEG spec section K.1. * The spec says that the values given produce "good" quality, and * when divided by 2, "very good" quality. */ const unsigned char std_luminance_quant_tbl[64] = { 16, 11, 10, 16, 24, 40, 51, 61, 12, 12, 14, 19, 26, 58, 60, 55, 14, 13, 16, 24, 40, 57, 69, 56, 14, 17, 22, 29, 51, 87, 80, 62, 18, 22, 37, 56, 68, 109, 103, 77, 24, 35, 55, 64, 81, 104, 113, 92, 49, 64, 78, 87, 103, 121, 120, 101, 72, 92, 95, 98, 112, 100, 103, 99 }; const unsigned char std_chrominance_quant_tbl[64] = { 17, 18, 24, 47, 99, 99, 99, 99, 18, 21, 26, 66, 99, 99, 99, 99, 24, 26, 56, 99, 99, 99, 99, 99, 47, 66, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99 }; #endif /* Set up the standard Huffman tables (cf. JPEG standard section K.3) */ /* IMPORTANT: these are only valid for 8-bit data precision! */ const uint8_t ff_mjpeg_bits_dc_luminance[17] = { /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }; const uint8_t ff_mjpeg_val_dc[12] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; const uint8_t ff_mjpeg_bits_dc_chrominance[17] = { /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; const uint8_t ff_mjpeg_bits_ac_luminance[17] = { /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d }; const uint8_t ff_mjpeg_val_ac_luminance[] = { 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa }; const uint8_t ff_mjpeg_bits_ac_chrominance[17] = { /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 }; const uint8_t ff_mjpeg_val_ac_chrominance[] = { 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa }; /* isn't this function nicer than the one in the libjpeg ? */ void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code, const uint8_t *bits_table, const uint8_t *val_table) { int i, j, k,nb, code, sym; code = 0; k = 0; for(i=1;i<=16;i++) { nb = bits_table[i]; for(j=0;j<nb;j++) { sym = val_table[k++]; huff_size[sym] = i; huff_code[sym] = code; code++; } code <<= 1; } }
123linslouis-android-video-cutter
jni/libavcodec/mjpeg.c
C
asf20
5,564
/* * Musepack decoder core * Copyright (c) 2006 Konstantin Shishkov * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * Musepack decoder core * MPEG Audio Layer 1/2 -like codec with frames of 1152 samples * divided into 32 subbands. */ #include "avcodec.h" #include "get_bits.h" #include "dsputil.h" #include "mpegaudio.h" #include "mpc.h" #include "mpcdata.h" void ff_mpc_init(void) { ff_mpa_synth_init(ff_mpa_synth_window); } /** * Process decoded Musepack data and produce PCM */ static void mpc_synth(MPCContext *c, int16_t *out) { int dither_state = 0; int i, ch; OUT_INT samples[MPA_MAX_CHANNELS * MPA_FRAME_SIZE], *samples_ptr; for(ch = 0; ch < 2; ch++){ samples_ptr = samples + ch; for(i = 0; i < SAMPLES_PER_BAND; i++) { ff_mpa_synth_filter(c->synth_buf[ch], &(c->synth_buf_offset[ch]), ff_mpa_synth_window, &dither_state, samples_ptr, 2, c->sb_samples[ch][i]); samples_ptr += 64; } } for(i = 0; i < MPC_FRAME_SIZE*2; i++) *out++=samples[i]; } void ff_mpc_dequantize_and_synth(MPCContext * c, int maxband, void *data) { int i, j, ch; Band *bands = c->bands; int off; float mul; /* dequantize */ memset(c->sb_samples, 0, sizeof(c->sb_samples)); off = 0; for(i = 0; i <= maxband; i++, off += SAMPLES_PER_BAND){ for(ch = 0; ch < 2; ch++){ if(bands[i].res[ch]){ j = 0; mul = mpc_CC[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][0]]; for(; j < 12; j++) c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off]; mul = mpc_CC[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][1]]; for(; j < 24; j++) c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off]; mul = mpc_CC[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][2]]; for(; j < 36; j++) c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off]; } } if(bands[i].msf){ int t1, t2; for(j = 0; j < SAMPLES_PER_BAND; j++){ t1 = c->sb_samples[0][j][i]; t2 = c->sb_samples[1][j][i]; c->sb_samples[0][j][i] = t1 + t2; c->sb_samples[1][j][i] = t1 - t2; } } } mpc_synth(c, data); }
123linslouis-android-video-cutter
jni/libavcodec/mpc.c
C
asf20
3,204
/* * Chinese AVS video (AVS1-P2, JiZhun profile) decoder. * * DSP functions * * Copyright (c) 2006 Stefan Gehrer <stefan.gehrer@gmx.de> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <stdio.h> #include "dsputil.h" /***************************************************************************** * * in-loop deblocking filter * ****************************************************************************/ #define P2 p0_p[-3*stride] #define P1 p0_p[-2*stride] #define P0 p0_p[-1*stride] #define Q0 p0_p[ 0*stride] #define Q1 p0_p[ 1*stride] #define Q2 p0_p[ 2*stride] static inline void loop_filter_l2(uint8_t *p0_p,int stride,int alpha, int beta) { int p0 = P0; int q0 = Q0; if(abs(p0-q0)<alpha && abs(P1-p0)<beta && abs(Q1-q0)<beta) { int s = p0 + q0 + 2; alpha = (alpha>>2) + 2; if(abs(P2-p0) < beta && abs(p0-q0) < alpha) { P0 = (P1 + p0 + s) >> 2; P1 = (2*P1 + s) >> 2; } else P0 = (2*P1 + s) >> 2; if(abs(Q2-q0) < beta && abs(q0-p0) < alpha) { Q0 = (Q1 + q0 + s) >> 2; Q1 = (2*Q1 + s) >> 2; } else Q0 = (2*Q1 + s) >> 2; } } static inline void loop_filter_l1(uint8_t *p0_p, int stride, int alpha, int beta, int tc) { int p0 = P0; int q0 = Q0; if(abs(p0-q0)<alpha && abs(P1-p0)<beta && abs(Q1-q0)<beta) { int delta = av_clip(((q0-p0)*3+P1-Q1+4)>>3,-tc, tc); P0 = av_clip_uint8(p0+delta); Q0 = av_clip_uint8(q0-delta); if(abs(P2-p0)<beta) { delta = av_clip(((P0-P1)*3+P2-Q0+4)>>3, -tc, tc); P1 = av_clip_uint8(P1+delta); } if(abs(Q2-q0)<beta) { delta = av_clip(((Q1-Q0)*3+P0-Q2+4)>>3, -tc, tc); Q1 = av_clip_uint8(Q1-delta); } } } static inline void loop_filter_c2(uint8_t *p0_p,int stride,int alpha, int beta) { int p0 = P0; int q0 = Q0; if(abs(p0-q0)<alpha && abs(P1-p0)<beta && abs(Q1-q0)<beta) { int s = p0 + q0 + 2; alpha = (alpha>>2) + 2; if(abs(P2-p0) < beta && abs(p0-q0) < alpha) { P0 = (P1 + p0 + s) >> 2; } else P0 = (2*P1 + s) >> 2; if(abs(Q2-q0) < beta && abs(q0-p0) < alpha) { Q0 = (Q1 + q0 + s) >> 2; } else Q0 = (2*Q1 + s) >> 2; } } static inline void loop_filter_c1(uint8_t *p0_p,int stride,int alpha, int beta, int tc) { if(abs(P0-Q0)<alpha && abs(P1-P0)<beta && abs(Q1-Q0)<beta) { int delta = av_clip(((Q0-P0)*3+P1-Q1+4)>>3, -tc, tc); P0 = av_clip_uint8(P0+delta); Q0 = av_clip_uint8(Q0-delta); } } #undef P0 #undef P1 #undef P2 #undef Q0 #undef Q1 #undef Q2 static void cavs_filter_lv_c(uint8_t *d, int stride, int alpha, int beta, int tc, int bs1, int bs2) { int i; if(bs1==2) for(i=0;i<16;i++) loop_filter_l2(d + i*stride,1,alpha,beta); else { if(bs1) for(i=0;i<8;i++) loop_filter_l1(d + i*stride,1,alpha,beta,tc); if (bs2) for(i=8;i<16;i++) loop_filter_l1(d + i*stride,1,alpha,beta,tc); } } static void cavs_filter_lh_c(uint8_t *d, int stride, int alpha, int beta, int tc, int bs1, int bs2) { int i; if(bs1==2) for(i=0;i<16;i++) loop_filter_l2(d + i,stride,alpha,beta); else { if(bs1) for(i=0;i<8;i++) loop_filter_l1(d + i,stride,alpha,beta,tc); if (bs2) for(i=8;i<16;i++) loop_filter_l1(d + i,stride,alpha,beta,tc); } } static void cavs_filter_cv_c(uint8_t *d, int stride, int alpha, int beta, int tc, int bs1, int bs2) { int i; if(bs1==2) for(i=0;i<8;i++) loop_filter_c2(d + i*stride,1,alpha,beta); else { if(bs1) for(i=0;i<4;i++) loop_filter_c1(d + i*stride,1,alpha,beta,tc); if (bs2) for(i=4;i<8;i++) loop_filter_c1(d + i*stride,1,alpha,beta,tc); } } static void cavs_filter_ch_c(uint8_t *d, int stride, int alpha, int beta, int tc, int bs1, int bs2) { int i; if(bs1==2) for(i=0;i<8;i++) loop_filter_c2(d + i,stride,alpha,beta); else { if(bs1) for(i=0;i<4;i++) loop_filter_c1(d + i,stride,alpha,beta,tc); if (bs2) for(i=4;i<8;i++) loop_filter_c1(d + i,stride,alpha,beta,tc); } } /***************************************************************************** * * inverse transform * ****************************************************************************/ static void cavs_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride) { int i; DCTELEM (*src)[8] = (DCTELEM(*)[8])block; uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; src[0][0] += 8; for( i = 0; i < 8; i++ ) { const int a0 = 3*src[i][1] - (src[i][7]<<1); const int a1 = 3*src[i][3] + (src[i][5]<<1); const int a2 = (src[i][3]<<1) - 3*src[i][5]; const int a3 = (src[i][1]<<1) + 3*src[i][7]; const int b4 = ((a0 + a1 + a3)<<1) + a1; const int b5 = ((a0 - a1 + a2)<<1) + a0; const int b6 = ((a3 - a2 - a1)<<1) + a3; const int b7 = ((a0 - a2 - a3)<<1) - a2; const int a7 = (src[i][2]<<2) - 10*src[i][6]; const int a6 = (src[i][6]<<2) + 10*src[i][2]; const int a5 = ((src[i][0] - src[i][4]) << 3) + 4; const int a4 = ((src[i][0] + src[i][4]) << 3) + 4; const int b0 = a4 + a6; const int b1 = a5 + a7; const int b2 = a5 - a7; const int b3 = a4 - a6; src[i][0] = (b0 + b4) >> 3; src[i][1] = (b1 + b5) >> 3; src[i][2] = (b2 + b6) >> 3; src[i][3] = (b3 + b7) >> 3; src[i][4] = (b3 - b7) >> 3; src[i][5] = (b2 - b6) >> 3; src[i][6] = (b1 - b5) >> 3; src[i][7] = (b0 - b4) >> 3; } for( i = 0; i < 8; i++ ) { const int a0 = 3*src[1][i] - (src[7][i]<<1); const int a1 = 3*src[3][i] + (src[5][i]<<1); const int a2 = (src[3][i]<<1) - 3*src[5][i]; const int a3 = (src[1][i]<<1) + 3*src[7][i]; const int b4 = ((a0 + a1 + a3)<<1) + a1; const int b5 = ((a0 - a1 + a2)<<1) + a0; const int b6 = ((a3 - a2 - a1)<<1) + a3; const int b7 = ((a0 - a2 - a3)<<1) - a2; const int a7 = (src[2][i]<<2) - 10*src[6][i]; const int a6 = (src[6][i]<<2) + 10*src[2][i]; const int a5 = (src[0][i] - src[4][i]) << 3; const int a4 = (src[0][i] + src[4][i]) << 3; const int b0 = a4 + a6; const int b1 = a5 + a7; const int b2 = a5 - a7; const int b3 = a4 - a6; dst[i + 0*stride] = cm[ dst[i + 0*stride] + ((b0 + b4) >> 7)]; dst[i + 1*stride] = cm[ dst[i + 1*stride] + ((b1 + b5) >> 7)]; dst[i + 2*stride] = cm[ dst[i + 2*stride] + ((b2 + b6) >> 7)]; dst[i + 3*stride] = cm[ dst[i + 3*stride] + ((b3 + b7) >> 7)]; dst[i + 4*stride] = cm[ dst[i + 4*stride] + ((b3 - b7) >> 7)]; dst[i + 5*stride] = cm[ dst[i + 5*stride] + ((b2 - b6) >> 7)]; dst[i + 6*stride] = cm[ dst[i + 6*stride] + ((b1 - b5) >> 7)]; dst[i + 7*stride] = cm[ dst[i + 7*stride] + ((b0 - b4) >> 7)]; } } /***************************************************************************** * * motion compensation * ****************************************************************************/ #define CAVS_SUBPIX(OPNAME, OP, NAME, A, B, C, D, E, F) \ static void OPNAME ## cavs_filt8_h_ ## NAME(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ const int h=8;\ uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\ int i;\ for(i=0; i<h; i++)\ {\ OP(dst[0], A*src[-2] + B*src[-1] + C*src[0] + D*src[1] + E*src[2] + F*src[3]);\ OP(dst[1], A*src[-1] + B*src[ 0] + C*src[1] + D*src[2] + E*src[3] + F*src[4]);\ OP(dst[2], A*src[ 0] + B*src[ 1] + C*src[2] + D*src[3] + E*src[4] + F*src[5]);\ OP(dst[3], A*src[ 1] + B*src[ 2] + C*src[3] + D*src[4] + E*src[5] + F*src[6]);\ OP(dst[4], A*src[ 2] + B*src[ 3] + C*src[4] + D*src[5] + E*src[6] + F*src[7]);\ OP(dst[5], A*src[ 3] + B*src[ 4] + C*src[5] + D*src[6] + E*src[7] + F*src[8]);\ OP(dst[6], A*src[ 4] + B*src[ 5] + C*src[6] + D*src[7] + E*src[8] + F*src[9]);\ OP(dst[7], A*src[ 5] + B*src[ 6] + C*src[7] + D*src[8] + E*src[9] + F*src[10]);\ dst+=dstStride;\ src+=srcStride;\ }\ }\ \ static void OPNAME ## cavs_filt8_v_ ## NAME(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ const int w=8;\ uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\ int i;\ for(i=0; i<w; i++)\ {\ const int srcB= src[-2*srcStride];\ const int srcA= src[-1*srcStride];\ const int src0= src[0 *srcStride];\ const int src1= src[1 *srcStride];\ const int src2= src[2 *srcStride];\ const int src3= src[3 *srcStride];\ const int src4= src[4 *srcStride];\ const int src5= src[5 *srcStride];\ const int src6= src[6 *srcStride];\ const int src7= src[7 *srcStride];\ const int src8= src[8 *srcStride];\ const int src9= src[9 *srcStride];\ const int src10= src[10 *srcStride];\ OP(dst[0*dstStride], A*srcB + B*srcA + C*src0 + D*src1 + E*src2 + F*src3);\ OP(dst[1*dstStride], A*srcA + B*src0 + C*src1 + D*src2 + E*src3 + F*src4);\ OP(dst[2*dstStride], A*src0 + B*src1 + C*src2 + D*src3 + E*src4 + F*src5);\ OP(dst[3*dstStride], A*src1 + B*src2 + C*src3 + D*src4 + E*src5 + F*src6);\ OP(dst[4*dstStride], A*src2 + B*src3 + C*src4 + D*src5 + E*src6 + F*src7);\ OP(dst[5*dstStride], A*src3 + B*src4 + C*src5 + D*src6 + E*src7 + F*src8);\ OP(dst[6*dstStride], A*src4 + B*src5 + C*src6 + D*src7 + E*src8 + F*src9);\ OP(dst[7*dstStride], A*src5 + B*src6 + C*src7 + D*src8 + E*src9 + F*src10);\ dst++;\ src++;\ }\ }\ \ static void OPNAME ## cavs_filt16_v_ ## NAME(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ OPNAME ## cavs_filt8_v_ ## NAME(dst , src , dstStride, srcStride);\ OPNAME ## cavs_filt8_v_ ## NAME(dst+8, src+8, dstStride, srcStride);\ src += 8*srcStride;\ dst += 8*dstStride;\ OPNAME ## cavs_filt8_v_ ## NAME(dst , src , dstStride, srcStride);\ OPNAME ## cavs_filt8_v_ ## NAME(dst+8, src+8, dstStride, srcStride);\ }\ \ static void OPNAME ## cavs_filt16_h_ ## NAME(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ OPNAME ## cavs_filt8_h_ ## NAME(dst , src , dstStride, srcStride);\ OPNAME ## cavs_filt8_h_ ## NAME(dst+8, src+8, dstStride, srcStride);\ src += 8*srcStride;\ dst += 8*dstStride;\ OPNAME ## cavs_filt8_h_ ## NAME(dst , src , dstStride, srcStride);\ OPNAME ## cavs_filt8_h_ ## NAME(dst+8, src+8, dstStride, srcStride);\ }\ #define CAVS_SUBPIX_HV(OPNAME, OP, NAME, AH, BH, CH, DH, EH, FH, AV, BV, CV, DV, EV, FV, FULL) \ static void OPNAME ## cavs_filt8_hv_ ## NAME(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int srcStride){\ int16_t temp[8*(8+5)];\ int16_t *tmp = temp;\ const int h=8;\ const int w=8;\ uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\ int i;\ src1 -= 2*srcStride;\ for(i=0; i<h+5; i++)\ {\ tmp[0]= AH*src1[-2] + BH*src1[-1] + CH*src1[0] + DH*src1[1] + EH*src1[2] + FH*src1[3];\ tmp[1]= AH*src1[-1] + BH*src1[ 0] + CH*src1[1] + DH*src1[2] + EH*src1[3] + FH*src1[4];\ tmp[2]= AH*src1[ 0] + BH*src1[ 1] + CH*src1[2] + DH*src1[3] + EH*src1[4] + FH*src1[5];\ tmp[3]= AH*src1[ 1] + BH*src1[ 2] + CH*src1[3] + DH*src1[4] + EH*src1[5] + FH*src1[6];\ tmp[4]= AH*src1[ 2] + BH*src1[ 3] + CH*src1[4] + DH*src1[5] + EH*src1[6] + FH*src1[7];\ tmp[5]= AH*src1[ 3] + BH*src1[ 4] + CH*src1[5] + DH*src1[6] + EH*src1[7] + FH*src1[8];\ tmp[6]= AH*src1[ 4] + BH*src1[ 5] + CH*src1[6] + DH*src1[7] + EH*src1[8] + FH*src1[9];\ tmp[7]= AH*src1[ 5] + BH*src1[ 6] + CH*src1[7] + DH*src1[8] + EH*src1[9] + FH*src1[10];\ tmp+=8;\ src1+=srcStride;\ }\ if(FULL) {\ tmp = temp+8*2; \ for(i=0; i<w; i++) \ { \ const int tmpB= tmp[-2*8]; \ const int tmpA= tmp[-1*8]; \ const int tmp0= tmp[0 *8]; \ const int tmp1= tmp[1 *8]; \ const int tmp2= tmp[2 *8]; \ const int tmp3= tmp[3 *8]; \ const int tmp4= tmp[4 *8]; \ const int tmp5= tmp[5 *8]; \ const int tmp6= tmp[6 *8]; \ const int tmp7= tmp[7 *8]; \ const int tmp8= tmp[8 *8]; \ const int tmp9= tmp[9 *8]; \ const int tmp10=tmp[10*8]; \ OP(dst[0*dstStride], AV*tmpB + BV*tmpA + CV*tmp0 + DV*tmp1 + EV*tmp2 + FV*tmp3 + 64*src2[0*srcStride]); \ OP(dst[1*dstStride], AV*tmpA + BV*tmp0 + CV*tmp1 + DV*tmp2 + EV*tmp3 + FV*tmp4 + 64*src2[1*srcStride]); \ OP(dst[2*dstStride], AV*tmp0 + BV*tmp1 + CV*tmp2 + DV*tmp3 + EV*tmp4 + FV*tmp5 + 64*src2[2*srcStride]); \ OP(dst[3*dstStride], AV*tmp1 + BV*tmp2 + CV*tmp3 + DV*tmp4 + EV*tmp5 + FV*tmp6 + 64*src2[3*srcStride]); \ OP(dst[4*dstStride], AV*tmp2 + BV*tmp3 + CV*tmp4 + DV*tmp5 + EV*tmp6 + FV*tmp7 + 64*src2[4*srcStride]); \ OP(dst[5*dstStride], AV*tmp3 + BV*tmp4 + CV*tmp5 + DV*tmp6 + EV*tmp7 + FV*tmp8 + 64*src2[5*srcStride]); \ OP(dst[6*dstStride], AV*tmp4 + BV*tmp5 + CV*tmp6 + DV*tmp7 + EV*tmp8 + FV*tmp9 + 64*src2[6*srcStride]); \ OP(dst[7*dstStride], AV*tmp5 + BV*tmp6 + CV*tmp7 + DV*tmp8 + EV*tmp9 + FV*tmp10 + 64*src2[7*srcStride]); \ dst++; \ tmp++; \ src2++; \ } \ } else {\ tmp = temp+8*2; \ for(i=0; i<w; i++) \ { \ const int tmpB= tmp[-2*8]; \ const int tmpA= tmp[-1*8]; \ const int tmp0= tmp[0 *8]; \ const int tmp1= tmp[1 *8]; \ const int tmp2= tmp[2 *8]; \ const int tmp3= tmp[3 *8]; \ const int tmp4= tmp[4 *8]; \ const int tmp5= tmp[5 *8]; \ const int tmp6= tmp[6 *8]; \ const int tmp7= tmp[7 *8]; \ const int tmp8= tmp[8 *8]; \ const int tmp9= tmp[9 *8]; \ const int tmp10=tmp[10*8]; \ OP(dst[0*dstStride], AV*tmpB + BV*tmpA + CV*tmp0 + DV*tmp1 + EV*tmp2 + FV*tmp3); \ OP(dst[1*dstStride], AV*tmpA + BV*tmp0 + CV*tmp1 + DV*tmp2 + EV*tmp3 + FV*tmp4); \ OP(dst[2*dstStride], AV*tmp0 + BV*tmp1 + CV*tmp2 + DV*tmp3 + EV*tmp4 + FV*tmp5); \ OP(dst[3*dstStride], AV*tmp1 + BV*tmp2 + CV*tmp3 + DV*tmp4 + EV*tmp5 + FV*tmp6); \ OP(dst[4*dstStride], AV*tmp2 + BV*tmp3 + CV*tmp4 + DV*tmp5 + EV*tmp6 + FV*tmp7); \ OP(dst[5*dstStride], AV*tmp3 + BV*tmp4 + CV*tmp5 + DV*tmp6 + EV*tmp7 + FV*tmp8); \ OP(dst[6*dstStride], AV*tmp4 + BV*tmp5 + CV*tmp6 + DV*tmp7 + EV*tmp8 + FV*tmp9); \ OP(dst[7*dstStride], AV*tmp5 + BV*tmp6 + CV*tmp7 + DV*tmp8 + EV*tmp9 + FV*tmp10); \ dst++; \ tmp++; \ } \ }\ }\ \ static void OPNAME ## cavs_filt16_hv_ ## NAME(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int srcStride){ \ OPNAME ## cavs_filt8_hv_ ## NAME(dst , src1, src2 , dstStride, srcStride); \ OPNAME ## cavs_filt8_hv_ ## NAME(dst+8, src1+8, src2+8, dstStride, srcStride); \ src1 += 8*srcStride;\ src2 += 8*srcStride;\ dst += 8*dstStride;\ OPNAME ## cavs_filt8_hv_ ## NAME(dst , src1, src2 , dstStride, srcStride); \ OPNAME ## cavs_filt8_hv_ ## NAME(dst+8, src1+8, src2+8, dstStride, srcStride); \ }\ #define CAVS_MC(OPNAME, SIZE) \ static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc10_c(uint8_t *dst, uint8_t *src, int stride){\ OPNAME ## cavs_filt ## SIZE ## _h_qpel_l(dst, src, stride, stride);\ }\ \ static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc20_c(uint8_t *dst, uint8_t *src, int stride){\ OPNAME ## cavs_filt ## SIZE ## _h_hpel(dst, src, stride, stride);\ }\ \ static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc30_c(uint8_t *dst, uint8_t *src, int stride){\ OPNAME ## cavs_filt ## SIZE ## _h_qpel_r(dst, src, stride, stride);\ }\ \ static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc01_c(uint8_t *dst, uint8_t *src, int stride){\ OPNAME ## cavs_filt ## SIZE ## _v_qpel_l(dst, src, stride, stride);\ }\ \ static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc02_c(uint8_t *dst, uint8_t *src, int stride){\ OPNAME ## cavs_filt ## SIZE ## _v_hpel(dst, src, stride, stride);\ }\ \ static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc03_c(uint8_t *dst, uint8_t *src, int stride){\ OPNAME ## cavs_filt ## SIZE ## _v_qpel_r(dst, src, stride, stride);\ }\ \ static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc22_c(uint8_t *dst, uint8_t *src, int stride){\ OPNAME ## cavs_filt ## SIZE ## _hv_jj(dst, src, NULL, stride, stride); \ }\ \ static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc11_c(uint8_t *dst, uint8_t *src, int stride){\ OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src, stride, stride); \ }\ \ static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc13_c(uint8_t *dst, uint8_t *src, int stride){\ OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+stride, stride, stride); \ }\ \ static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc31_c(uint8_t *dst, uint8_t *src, int stride){\ OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+1, stride, stride); \ }\ \ static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc33_c(uint8_t *dst, uint8_t *src, int stride){\ OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+stride+1,stride, stride); \ }\ \ static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc21_c(uint8_t *dst, uint8_t *src, int stride){\ OPNAME ## cavs_filt ## SIZE ## _hv_ff(dst, src, src+stride+1,stride, stride); \ }\ \ static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc12_c(uint8_t *dst, uint8_t *src, int stride){\ OPNAME ## cavs_filt ## SIZE ## _hv_ii(dst, src, src+stride+1,stride, stride); \ }\ \ static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc32_c(uint8_t *dst, uint8_t *src, int stride){\ OPNAME ## cavs_filt ## SIZE ## _hv_kk(dst, src, src+stride+1,stride, stride); \ }\ \ static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc23_c(uint8_t *dst, uint8_t *src, int stride){\ OPNAME ## cavs_filt ## SIZE ## _hv_qq(dst, src, src+stride+1,stride, stride); \ }\ #define op_put1(a, b) a = cm[((b)+4)>>3] #define op_put2(a, b) a = cm[((b)+64)>>7] #define op_put3(a, b) a = cm[((b)+32)>>6] #define op_put4(a, b) a = cm[((b)+512)>>10] #define op_avg1(a, b) a = ((a)+cm[((b)+4)>>3] +1)>>1 #define op_avg2(a, b) a = ((a)+cm[((b)+64)>>7] +1)>>1 #define op_avg3(a, b) a = ((a)+cm[((b)+32)>>6] +1)>>1 #define op_avg4(a, b) a = ((a)+cm[((b)+512)>>10]+1)>>1 CAVS_SUBPIX(put_ , op_put1, hpel, 0, -1, 5, 5, -1, 0) CAVS_SUBPIX(put_ , op_put2, qpel_l, -1, -2, 96, 42, -7, 0) CAVS_SUBPIX(put_ , op_put2, qpel_r, 0, -7, 42, 96, -2, -1) CAVS_SUBPIX_HV(put_, op_put3, jj, 0, -1, 5, 5, -1, 0, 0, -1, 5, 5, -1, 0, 0) CAVS_SUBPIX_HV(put_, op_put4, ff, 0, -1, 5, 5, -1, 0, -1, -2, 96, 42, -7, 0, 0) CAVS_SUBPIX_HV(put_, op_put4, ii, -1, -2, 96, 42, -7, 0, 0, -1, 5, 5, -1, 0, 0) CAVS_SUBPIX_HV(put_, op_put4, kk, 0, -7, 42, 96, -2, -1, 0, -1, 5, 5, -1, 0, 0) CAVS_SUBPIX_HV(put_, op_put4, qq, 0, -1, 5, 5, -1, 0, 0, -7, 42, 96, -2,-1, 0) CAVS_SUBPIX_HV(put_, op_put2, egpr, 0, -1, 5, 5, -1, 0, 0, -1, 5, 5, -1, 0, 1) CAVS_SUBPIX(avg_ , op_avg1, hpel, 0, -1, 5, 5, -1, 0) CAVS_SUBPIX(avg_ , op_avg2, qpel_l, -1, -2, 96, 42, -7, 0) CAVS_SUBPIX(avg_ , op_avg2, qpel_r, 0, -7, 42, 96, -2, -1) CAVS_SUBPIX_HV(avg_, op_avg3, jj, 0, -1, 5, 5, -1, 0, 0, -1, 5, 5, -1, 0, 0) CAVS_SUBPIX_HV(avg_, op_avg4, ff, 0, -1, 5, 5, -1, 0, -1, -2, 96, 42, -7, 0, 0) CAVS_SUBPIX_HV(avg_, op_avg4, ii, -1, -2, 96, 42, -7, 0, 0, -1, 5, 5, -1, 0, 0) CAVS_SUBPIX_HV(avg_, op_avg4, kk, 0, -7, 42, 96, -2, -1, 0, -1, 5, 5, -1, 0, 0) CAVS_SUBPIX_HV(avg_, op_avg4, qq, 0, -1, 5, 5, -1, 0, 0, -7, 42, 96, -2,-1, 0) CAVS_SUBPIX_HV(avg_, op_avg2, egpr, 0, -1, 5, 5, -1, 0, 0, -1, 5, 5, -1, 0, 1) CAVS_MC(put_, 8) CAVS_MC(put_, 16) CAVS_MC(avg_, 8) CAVS_MC(avg_, 16) av_cold void ff_cavsdsp_init(DSPContext* c, AVCodecContext *avctx) { #define dspfunc(PFX, IDX, NUM) \ c->PFX ## _pixels_tab[IDX][ 0] = ff_ ## PFX ## NUM ## _mc00_c; \ c->PFX ## _pixels_tab[IDX][ 1] = ff_ ## PFX ## NUM ## _mc10_c; \ c->PFX ## _pixels_tab[IDX][ 2] = ff_ ## PFX ## NUM ## _mc20_c; \ c->PFX ## _pixels_tab[IDX][ 3] = ff_ ## PFX ## NUM ## _mc30_c; \ c->PFX ## _pixels_tab[IDX][ 4] = ff_ ## PFX ## NUM ## _mc01_c; \ c->PFX ## _pixels_tab[IDX][ 5] = ff_ ## PFX ## NUM ## _mc11_c; \ c->PFX ## _pixels_tab[IDX][ 6] = ff_ ## PFX ## NUM ## _mc21_c; \ c->PFX ## _pixels_tab[IDX][ 7] = ff_ ## PFX ## NUM ## _mc31_c; \ c->PFX ## _pixels_tab[IDX][ 8] = ff_ ## PFX ## NUM ## _mc02_c; \ c->PFX ## _pixels_tab[IDX][ 9] = ff_ ## PFX ## NUM ## _mc12_c; \ c->PFX ## _pixels_tab[IDX][10] = ff_ ## PFX ## NUM ## _mc22_c; \ c->PFX ## _pixels_tab[IDX][11] = ff_ ## PFX ## NUM ## _mc32_c; \ c->PFX ## _pixels_tab[IDX][12] = ff_ ## PFX ## NUM ## _mc03_c; \ c->PFX ## _pixels_tab[IDX][13] = ff_ ## PFX ## NUM ## _mc13_c; \ c->PFX ## _pixels_tab[IDX][14] = ff_ ## PFX ## NUM ## _mc23_c; \ c->PFX ## _pixels_tab[IDX][15] = ff_ ## PFX ## NUM ## _mc33_c dspfunc(put_cavs_qpel, 0, 16); dspfunc(put_cavs_qpel, 1, 8); dspfunc(avg_cavs_qpel, 0, 16); dspfunc(avg_cavs_qpel, 1, 8); c->cavs_filter_lv = cavs_filter_lv_c; c->cavs_filter_lh = cavs_filter_lh_c; c->cavs_filter_cv = cavs_filter_cv_c; c->cavs_filter_ch = cavs_filter_ch_c; c->cavs_idct8_add = cavs_idct8_add_c; }
123linslouis-android-video-cutter
jni/libavcodec/cavsdsp.c
C
asf20
23,496
/* * H.26L/H.264/AVC/JVT/14496-10/... direct mb/block decoding * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * H.264 / AVC / MPEG4 part10 direct mb/block decoding. * @author Michael Niedermayer <michaelni@gmx.at> */ #include "internal.h" #include "dsputil.h" #include "avcodec.h" #include "mpegvideo.h" #include "h264.h" #include "rectangle.h" //#undef NDEBUG #include <assert.h> static int get_scale_factor(H264Context * const h, int poc, int poc1, int i){ int poc0 = h->ref_list[0][i].poc; int td = av_clip(poc1 - poc0, -128, 127); if(td == 0 || h->ref_list[0][i].long_ref){ return 256; }else{ int tb = av_clip(poc - poc0, -128, 127); int tx = (16384 + (FFABS(td) >> 1)) / td; return av_clip((tb*tx + 32) >> 6, -1024, 1023); } } void ff_h264_direct_dist_scale_factor(H264Context * const h){ MpegEncContext * const s = &h->s; const int poc = h->s.current_picture_ptr->field_poc[ s->picture_structure == PICT_BOTTOM_FIELD ]; const int poc1 = h->ref_list[1][0].poc; int i, field; for(field=0; field<2; field++){ const int poc = h->s.current_picture_ptr->field_poc[field]; const int poc1 = h->ref_list[1][0].field_poc[field]; for(i=0; i < 2*h->ref_count[0]; i++) h->dist_scale_factor_field[field][i^field] = get_scale_factor(h, poc, poc1, i+16); } for(i=0; i<h->ref_count[0]; i++){ h->dist_scale_factor[i] = get_scale_factor(h, poc, poc1, i); } } static void fill_colmap(H264Context *h, int map[2][16+32], int list, int field, int colfield, int mbafi){ MpegEncContext * const s = &h->s; Picture * const ref1 = &h->ref_list[1][0]; int j, old_ref, rfield; int start= mbafi ? 16 : 0; int end = mbafi ? 16+2*h->ref_count[0] : h->ref_count[0]; int interl= mbafi || s->picture_structure != PICT_FRAME; /* bogus; fills in for missing frames */ memset(map[list], 0, sizeof(map[list])); for(rfield=0; rfield<2; rfield++){ for(old_ref=0; old_ref<ref1->ref_count[colfield][list]; old_ref++){ int poc = ref1->ref_poc[colfield][list][old_ref]; if (!interl) poc |= 3; else if( interl && (poc&3) == 3) //FIXME store all MBAFF references so this isnt needed poc= (poc&~3) + rfield + 1; for(j=start; j<end; j++){ if(4*h->ref_list[0][j].frame_num + (h->ref_list[0][j].reference&3) == poc){ int cur_ref= mbafi ? (j-16)^field : j; map[list][2*old_ref + (rfield^field) + 16] = cur_ref; if(rfield == field || !interl) map[list][old_ref] = cur_ref; break; } } } } } void ff_h264_direct_ref_list_init(H264Context * const h){ MpegEncContext * const s = &h->s; Picture * const ref1 = &h->ref_list[1][0]; Picture * const cur = s->current_picture_ptr; int list, j, field; int sidx= (s->picture_structure&1)^1; int ref1sidx= (ref1->reference&1)^1; for(list=0; list<2; list++){ cur->ref_count[sidx][list] = h->ref_count[list]; for(j=0; j<h->ref_count[list]; j++) cur->ref_poc[sidx][list][j] = 4*h->ref_list[list][j].frame_num + (h->ref_list[list][j].reference&3); } if(s->picture_structure == PICT_FRAME){ memcpy(cur->ref_count[1], cur->ref_count[0], sizeof(cur->ref_count[0])); memcpy(cur->ref_poc [1], cur->ref_poc [0], sizeof(cur->ref_poc [0])); } cur->mbaff= FRAME_MBAFF; h->col_fieldoff= 0; if(s->picture_structure == PICT_FRAME){ int cur_poc = s->current_picture_ptr->poc; int *col_poc = h->ref_list[1]->field_poc; h->col_parity= (FFABS(col_poc[0] - cur_poc) >= FFABS(col_poc[1] - cur_poc)); ref1sidx=sidx= h->col_parity; }else if(!(s->picture_structure & h->ref_list[1][0].reference) && !h->ref_list[1][0].mbaff){ // FL -> FL & differ parity h->col_fieldoff= s->mb_stride*(2*(h->ref_list[1][0].reference) - 3); } if(cur->pict_type != FF_B_TYPE || h->direct_spatial_mv_pred) return; for(list=0; list<2; list++){ fill_colmap(h, h->map_col_to_list0, list, sidx, ref1sidx, 0); if(FRAME_MBAFF) for(field=0; field<2; field++) fill_colmap(h, h->map_col_to_list0_field[field], list, field, field, 1); } } static void pred_spatial_direct_motion(H264Context * const h, int *mb_type){ MpegEncContext * const s = &h->s; int b8_stride = 2; int b4_stride = h->b_stride; int mb_xy = h->mb_xy; int mb_type_col[2]; const int16_t (*l1mv0)[2], (*l1mv1)[2]; const int8_t *l1ref0, *l1ref1; const int is_b8x8 = IS_8X8(*mb_type); unsigned int sub_mb_type= MB_TYPE_L0L1; int i8, i4; int ref[2]; int mv[2]; int list; assert(h->ref_list[1][0].reference&3); #define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16|MB_TYPE_INTRA4x4|MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM) /* ref = min(neighbors) */ for(list=0; list<2; list++){ int left_ref = h->ref_cache[list][scan8[0] - 1]; int top_ref = h->ref_cache[list][scan8[0] - 8]; int refc = h->ref_cache[list][scan8[0] - 8 + 4]; const int16_t *C= h->mv_cache[list][ scan8[0] - 8 + 4]; if(refc == PART_NOT_AVAILABLE){ refc = h->ref_cache[list][scan8[0] - 8 - 1]; C = h-> mv_cache[list][scan8[0] - 8 - 1]; } ref[list] = FFMIN3((unsigned)left_ref, (unsigned)top_ref, (unsigned)refc); if(ref[list] >= 0){ //this is just pred_motion() but with the cases removed that cannot happen for direct blocks const int16_t * const A= h->mv_cache[list][ scan8[0] - 1 ]; const int16_t * const B= h->mv_cache[list][ scan8[0] - 8 ]; int match_count= (left_ref==ref[list]) + (top_ref==ref[list]) + (refc==ref[list]); if(match_count > 1){ //most common mv[list]= pack16to32(mid_pred(A[0], B[0], C[0]), mid_pred(A[1], B[1], C[1]) ); }else { assert(match_count==1); if(left_ref==ref[list]){ mv[list]= AV_RN32A(A); }else if(top_ref==ref[list]){ mv[list]= AV_RN32A(B); }else{ mv[list]= AV_RN32A(C); } } }else{ int mask= ~(MB_TYPE_L0 << (2*list)); mv[list] = 0; ref[list] = -1; if(!is_b8x8) *mb_type &= mask; sub_mb_type &= mask; } } if(ref[0] < 0 && ref[1] < 0){ ref[0] = ref[1] = 0; if(!is_b8x8) *mb_type |= MB_TYPE_L0L1; sub_mb_type |= MB_TYPE_L0L1; } if(!(is_b8x8|mv[0]|mv[1])){ fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, (uint8_t)ref[0], 1); fill_rectangle(&h->ref_cache[1][scan8[0]], 4, 4, 8, (uint8_t)ref[1], 1); fill_rectangle(&h->mv_cache[0][scan8[0]], 4, 4, 8, 0, 4); fill_rectangle(&h->mv_cache[1][scan8[0]], 4, 4, 8, 0, 4); *mb_type= (*mb_type & ~(MB_TYPE_8x8|MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_P1L0|MB_TYPE_P1L1))|MB_TYPE_16x16|MB_TYPE_DIRECT2; return; } if(IS_INTERLACED(h->ref_list[1][0].mb_type[mb_xy])){ // AFL/AFR/FR/FL -> AFL/FL if(!IS_INTERLACED(*mb_type)){ // AFR/FR -> AFL/FL mb_xy= s->mb_x + ((s->mb_y&~1) + h->col_parity)*s->mb_stride; b8_stride = 0; }else{ mb_xy += h->col_fieldoff; // non zero for FL -> FL & differ parity } goto single_col; }else{ // AFL/AFR/FR/FL -> AFR/FR if(IS_INTERLACED(*mb_type)){ // AFL /FL -> AFR/FR mb_xy= s->mb_x + (s->mb_y&~1)*s->mb_stride; mb_type_col[0] = h->ref_list[1][0].mb_type[mb_xy]; mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy + s->mb_stride]; b8_stride = 2+4*s->mb_stride; b4_stride *= 6; sub_mb_type |= MB_TYPE_16x16|MB_TYPE_DIRECT2; /* B_SUB_8x8 */ if( (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA) && (mb_type_col[1] & MB_TYPE_16x16_OR_INTRA) && !is_b8x8){ *mb_type |= MB_TYPE_16x8 |MB_TYPE_DIRECT2; /* B_16x8 */ }else{ *mb_type |= MB_TYPE_8x8; } }else{ // AFR/FR -> AFR/FR single_col: mb_type_col[0] = mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy]; sub_mb_type |= MB_TYPE_16x16|MB_TYPE_DIRECT2; /* B_SUB_8x8 */ if(!is_b8x8 && (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)){ *mb_type |= MB_TYPE_16x16|MB_TYPE_DIRECT2; /* B_16x16 */ }else if(!is_b8x8 && (mb_type_col[0] & (MB_TYPE_16x8|MB_TYPE_8x16))){ *mb_type |= MB_TYPE_DIRECT2 | (mb_type_col[0] & (MB_TYPE_16x8|MB_TYPE_8x16)); }else{ if(!h->sps.direct_8x8_inference_flag){ /* FIXME save sub mb types from previous frames (or derive from MVs) * so we know exactly what block size to use */ sub_mb_type += (MB_TYPE_8x8-MB_TYPE_16x16); /* B_SUB_4x4 */ } *mb_type |= MB_TYPE_8x8; } } } l1mv0 = &h->ref_list[1][0].motion_val[0][h->mb2b_xy [mb_xy]]; l1mv1 = &h->ref_list[1][0].motion_val[1][h->mb2b_xy [mb_xy]]; l1ref0 = &h->ref_list[1][0].ref_index [0][4*mb_xy]; l1ref1 = &h->ref_list[1][0].ref_index [1][4*mb_xy]; if(!b8_stride){ if(s->mb_y&1){ l1ref0 += 2; l1ref1 += 2; l1mv0 += 2*b4_stride; l1mv1 += 2*b4_stride; } } if(IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col[0])){ int n=0; for(i8=0; i8<4; i8++){ int x8 = i8&1; int y8 = i8>>1; int xy8 = x8+y8*b8_stride; int xy4 = 3*x8+y8*b4_stride; int a,b; if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8])) continue; h->sub_mb_type[i8] = sub_mb_type; fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[0], 1); fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[1], 1); if(!IS_INTRA(mb_type_col[y8]) && !h->ref_list[1][0].long_ref && ( (l1ref0[xy8] == 0 && FFABS(l1mv0[xy4][0]) <= 1 && FFABS(l1mv0[xy4][1]) <= 1) || (l1ref0[xy8] < 0 && l1ref1[xy8] == 0 && FFABS(l1mv1[xy4][0]) <= 1 && FFABS(l1mv1[xy4][1]) <= 1))){ a=b=0; if(ref[0] > 0) a= mv[0]; if(ref[1] > 0) b= mv[1]; n++; }else{ a= mv[0]; b= mv[1]; } fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, a, 4); fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, b, 4); } if(!is_b8x8 && !(n&3)) *mb_type= (*mb_type & ~(MB_TYPE_8x8|MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_P1L0|MB_TYPE_P1L1))|MB_TYPE_16x16|MB_TYPE_DIRECT2; }else if(IS_16X16(*mb_type)){ int a,b; fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, (uint8_t)ref[0], 1); fill_rectangle(&h->ref_cache[1][scan8[0]], 4, 4, 8, (uint8_t)ref[1], 1); if(!IS_INTRA(mb_type_col[0]) && !h->ref_list[1][0].long_ref && ( (l1ref0[0] == 0 && FFABS(l1mv0[0][0]) <= 1 && FFABS(l1mv0[0][1]) <= 1) || (l1ref0[0] < 0 && l1ref1[0] == 0 && FFABS(l1mv1[0][0]) <= 1 && FFABS(l1mv1[0][1]) <= 1 && h->x264_build>33U))){ a=b=0; if(ref[0] > 0) a= mv[0]; if(ref[1] > 0) b= mv[1]; }else{ a= mv[0]; b= mv[1]; } fill_rectangle(&h->mv_cache[0][scan8[0]], 4, 4, 8, a, 4); fill_rectangle(&h->mv_cache[1][scan8[0]], 4, 4, 8, b, 4); }else{ int n=0; for(i8=0; i8<4; i8++){ const int x8 = i8&1; const int y8 = i8>>1; if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8])) continue; h->sub_mb_type[i8] = sub_mb_type; fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, mv[0], 4); fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, mv[1], 4); fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[0], 1); fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[1], 1); assert(b8_stride==2); /* col_zero_flag */ if(!IS_INTRA(mb_type_col[0]) && !h->ref_list[1][0].long_ref && ( l1ref0[i8] == 0 || (l1ref0[i8] < 0 && l1ref1[i8] == 0 && h->x264_build>33U))){ const int16_t (*l1mv)[2]= l1ref0[i8] == 0 ? l1mv0 : l1mv1; if(IS_SUB_8X8(sub_mb_type)){ const int16_t *mv_col = l1mv[x8*3 + y8*3*b4_stride]; if(FFABS(mv_col[0]) <= 1 && FFABS(mv_col[1]) <= 1){ if(ref[0] == 0) fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, 0, 4); if(ref[1] == 0) fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, 0, 4); n+=4; } }else{ int m=0; for(i4=0; i4<4; i4++){ const int16_t *mv_col = l1mv[x8*2 + (i4&1) + (y8*2 + (i4>>1))*b4_stride]; if(FFABS(mv_col[0]) <= 1 && FFABS(mv_col[1]) <= 1){ if(ref[0] == 0) AV_ZERO32(h->mv_cache[0][scan8[i8*4+i4]]); if(ref[1] == 0) AV_ZERO32(h->mv_cache[1][scan8[i8*4+i4]]); m++; } } if(!(m&3)) h->sub_mb_type[i8]+= MB_TYPE_16x16 - MB_TYPE_8x8; n+=m; } } } if(!is_b8x8 && !(n&15)) *mb_type= (*mb_type & ~(MB_TYPE_8x8|MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_P1L0|MB_TYPE_P1L1))|MB_TYPE_16x16|MB_TYPE_DIRECT2; } } static void pred_temp_direct_motion(H264Context * const h, int *mb_type){ MpegEncContext * const s = &h->s; int b8_stride = 2; int b4_stride = h->b_stride; int mb_xy = h->mb_xy; int mb_type_col[2]; const int16_t (*l1mv0)[2], (*l1mv1)[2]; const int8_t *l1ref0, *l1ref1; const int is_b8x8 = IS_8X8(*mb_type); unsigned int sub_mb_type; int i8, i4; assert(h->ref_list[1][0].reference&3); if(IS_INTERLACED(h->ref_list[1][0].mb_type[mb_xy])){ // AFL/AFR/FR/FL -> AFL/FL if(!IS_INTERLACED(*mb_type)){ // AFR/FR -> AFL/FL mb_xy= s->mb_x + ((s->mb_y&~1) + h->col_parity)*s->mb_stride; b8_stride = 0; }else{ mb_xy += h->col_fieldoff; // non zero for FL -> FL & differ parity } goto single_col; }else{ // AFL/AFR/FR/FL -> AFR/FR if(IS_INTERLACED(*mb_type)){ // AFL /FL -> AFR/FR mb_xy= s->mb_x + (s->mb_y&~1)*s->mb_stride; mb_type_col[0] = h->ref_list[1][0].mb_type[mb_xy]; mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy + s->mb_stride]; b8_stride = 2+4*s->mb_stride; b4_stride *= 6; sub_mb_type = MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2; /* B_SUB_8x8 */ if( (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA) && (mb_type_col[1] & MB_TYPE_16x16_OR_INTRA) && !is_b8x8){ *mb_type |= MB_TYPE_16x8 |MB_TYPE_L0L1|MB_TYPE_DIRECT2; /* B_16x8 */ }else{ *mb_type |= MB_TYPE_8x8|MB_TYPE_L0L1; } }else{ // AFR/FR -> AFR/FR single_col: mb_type_col[0] = mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy]; sub_mb_type = MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2; /* B_SUB_8x8 */ if(!is_b8x8 && (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)){ *mb_type |= MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2; /* B_16x16 */ }else if(!is_b8x8 && (mb_type_col[0] & (MB_TYPE_16x8|MB_TYPE_8x16))){ *mb_type |= MB_TYPE_L0L1|MB_TYPE_DIRECT2 | (mb_type_col[0] & (MB_TYPE_16x8|MB_TYPE_8x16)); }else{ if(!h->sps.direct_8x8_inference_flag){ /* FIXME save sub mb types from previous frames (or derive from MVs) * so we know exactly what block size to use */ sub_mb_type = MB_TYPE_8x8|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2; /* B_SUB_4x4 */ } *mb_type |= MB_TYPE_8x8|MB_TYPE_L0L1; } } } l1mv0 = &h->ref_list[1][0].motion_val[0][h->mb2b_xy [mb_xy]]; l1mv1 = &h->ref_list[1][0].motion_val[1][h->mb2b_xy [mb_xy]]; l1ref0 = &h->ref_list[1][0].ref_index [0][4*mb_xy]; l1ref1 = &h->ref_list[1][0].ref_index [1][4*mb_xy]; if(!b8_stride){ if(s->mb_y&1){ l1ref0 += 2; l1ref1 += 2; l1mv0 += 2*b4_stride; l1mv1 += 2*b4_stride; } } { const int *map_col_to_list0[2] = {h->map_col_to_list0[0], h->map_col_to_list0[1]}; const int *dist_scale_factor = h->dist_scale_factor; int ref_offset; if(FRAME_MBAFF && IS_INTERLACED(*mb_type)){ map_col_to_list0[0] = h->map_col_to_list0_field[s->mb_y&1][0]; map_col_to_list0[1] = h->map_col_to_list0_field[s->mb_y&1][1]; dist_scale_factor =h->dist_scale_factor_field[s->mb_y&1]; } ref_offset = (h->ref_list[1][0].mbaff<<4) & (mb_type_col[0]>>3); //if(h->ref_list[1][0].mbaff && IS_INTERLACED(mb_type_col[0])) ref_offset=16 else 0 if(IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col[0])){ int y_shift = 2*!IS_INTERLACED(*mb_type); assert(h->sps.direct_8x8_inference_flag); for(i8=0; i8<4; i8++){ const int x8 = i8&1; const int y8 = i8>>1; int ref0, scale; const int16_t (*l1mv)[2]= l1mv0; if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8])) continue; h->sub_mb_type[i8] = sub_mb_type; fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, 0, 1); if(IS_INTRA(mb_type_col[y8])){ fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, 0, 1); fill_rectangle(&h-> mv_cache[0][scan8[i8*4]], 2, 2, 8, 0, 4); fill_rectangle(&h-> mv_cache[1][scan8[i8*4]], 2, 2, 8, 0, 4); continue; } ref0 = l1ref0[x8 + y8*b8_stride]; if(ref0 >= 0) ref0 = map_col_to_list0[0][ref0 + ref_offset]; else{ ref0 = map_col_to_list0[1][l1ref1[x8 + y8*b8_stride] + ref_offset]; l1mv= l1mv1; } scale = dist_scale_factor[ref0]; fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, ref0, 1); { const int16_t *mv_col = l1mv[x8*3 + y8*b4_stride]; int my_col = (mv_col[1]<<y_shift)/2; int mx = (scale * mv_col[0] + 128) >> 8; int my = (scale * my_col + 128) >> 8; fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, pack16to32(mx,my), 4); fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, pack16to32(mx-mv_col[0],my-my_col), 4); } } return; } /* one-to-one mv scaling */ if(IS_16X16(*mb_type)){ int ref, mv0, mv1; fill_rectangle(&h->ref_cache[1][scan8[0]], 4, 4, 8, 0, 1); if(IS_INTRA(mb_type_col[0])){ ref=mv0=mv1=0; }else{ const int ref0 = l1ref0[0] >= 0 ? map_col_to_list0[0][l1ref0[0] + ref_offset] : map_col_to_list0[1][l1ref1[0] + ref_offset]; const int scale = dist_scale_factor[ref0]; const int16_t *mv_col = l1ref0[0] >= 0 ? l1mv0[0] : l1mv1[0]; int mv_l0[2]; mv_l0[0] = (scale * mv_col[0] + 128) >> 8; mv_l0[1] = (scale * mv_col[1] + 128) >> 8; ref= ref0; mv0= pack16to32(mv_l0[0],mv_l0[1]); mv1= pack16to32(mv_l0[0]-mv_col[0],mv_l0[1]-mv_col[1]); } fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1); fill_rectangle(&h-> mv_cache[0][scan8[0]], 4, 4, 8, mv0, 4); fill_rectangle(&h-> mv_cache[1][scan8[0]], 4, 4, 8, mv1, 4); }else{ for(i8=0; i8<4; i8++){ const int x8 = i8&1; const int y8 = i8>>1; int ref0, scale; const int16_t (*l1mv)[2]= l1mv0; if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8])) continue; h->sub_mb_type[i8] = sub_mb_type; fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, 0, 1); if(IS_INTRA(mb_type_col[0])){ fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, 0, 1); fill_rectangle(&h-> mv_cache[0][scan8[i8*4]], 2, 2, 8, 0, 4); fill_rectangle(&h-> mv_cache[1][scan8[i8*4]], 2, 2, 8, 0, 4); continue; } assert(b8_stride == 2); ref0 = l1ref0[i8]; if(ref0 >= 0) ref0 = map_col_to_list0[0][ref0 + ref_offset]; else{ ref0 = map_col_to_list0[1][l1ref1[i8] + ref_offset]; l1mv= l1mv1; } scale = dist_scale_factor[ref0]; fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, ref0, 1); if(IS_SUB_8X8(sub_mb_type)){ const int16_t *mv_col = l1mv[x8*3 + y8*3*b4_stride]; int mx = (scale * mv_col[0] + 128) >> 8; int my = (scale * mv_col[1] + 128) >> 8; fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, pack16to32(mx,my), 4); fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, pack16to32(mx-mv_col[0],my-mv_col[1]), 4); }else for(i4=0; i4<4; i4++){ const int16_t *mv_col = l1mv[x8*2 + (i4&1) + (y8*2 + (i4>>1))*b4_stride]; int16_t *mv_l0 = h->mv_cache[0][scan8[i8*4+i4]]; mv_l0[0] = (scale * mv_col[0] + 128) >> 8; mv_l0[1] = (scale * mv_col[1] + 128) >> 8; AV_WN32A(h->mv_cache[1][scan8[i8*4+i4]], pack16to32(mv_l0[0]-mv_col[0],mv_l0[1]-mv_col[1])); } } } } } void ff_h264_pred_direct_motion(H264Context * const h, int *mb_type){ if(h->direct_spatial_mv_pred){ pred_spatial_direct_motion(h, mb_type); }else{ pred_temp_direct_motion(h, mb_type); } }
123linslouis-android-video-cutter
jni/libavcodec/h264_direct.c
C
asf20
25,094
NAME = avcodec FFLIBS = avutil HEADERS = avcodec.h avfft.h dxva2.h opt.h vaapi.h vdpau.h xvmc.h OBJS = allcodecs.o \ audioconvert.o \ avpacket.o \ bitstream.o \ bitstream_filter.o \ dsputil.o \ eval.o \ faanidct.o \ imgconvert.o \ jrevdct.o \ opt.o \ options.o \ parser.o \ raw.o \ resample.o \ resample2.o \ simple_idct.o \ utils.o \ # parts needed for many different codecs OBJS-$(CONFIG_AANDCT) += aandcttab.o OBJS-$(CONFIG_ENCODERS) += faandct.o jfdctfst.o jfdctint.o OBJS-$(CONFIG_DCT) += dct.o OBJS-$(CONFIG_DWT) += dwt.o OBJS-$(CONFIG_DXVA2) += dxva2.o FFT-OBJS-$(CONFIG_HARDCODED_TABLES) += cos_tables.o OBJS-$(CONFIG_FFT) += avfft.o fft.o $(FFT-OBJS-yes) OBJS-$(CONFIG_GOLOMB) += golomb.o OBJS-$(CONFIG_H264DSP) += h264dsp.o h264idct.o h264pred.o OBJS-$(CONFIG_LPC) += lpc.o OBJS-$(CONFIG_LSP) += lsp.o OBJS-$(CONFIG_MDCT) += mdct.o RDFT-OBJS-$(CONFIG_HARDCODED_TABLES) += sin_tables.o OBJS-$(CONFIG_RDFT) += rdft.o $(RDFT-OBJS-yes) OBJS-$(CONFIG_VAAPI) += vaapi.o OBJS-$(CONFIG_VDPAU) += vdpau.o # decoders/encoders/hardware accelerators OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps.o OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o \ aacpsy.o aactab.o \ psymodel.o iirfilter.o \ mpeg4audio.o OBJS-$(CONFIG_AASC_DECODER) += aasc.o msrledec.o OBJS-$(CONFIG_AC3_DECODER) += ac3dec.o ac3dec_data.o ac3.o OBJS-$(CONFIG_AC3_ENCODER) += ac3enc.o ac3tab.o ac3.o OBJS-$(CONFIG_ALAC_DECODER) += alac.o OBJS-$(CONFIG_ALAC_ENCODER) += alacenc.o OBJS-$(CONFIG_ALS_DECODER) += alsdec.o bgmc.o mpeg4audio.o OBJS-$(CONFIG_AMRNB_DECODER) += amrnbdec.o celp_filters.o \ celp_math.o acelp_filters.o \ acelp_vectors.o \ acelp_pitch_delay.o OBJS-$(CONFIG_AMV_DECODER) += sp5xdec.o mjpegdec.o mjpeg.o OBJS-$(CONFIG_ANM_DECODER) += anm.o OBJS-$(CONFIG_APE_DECODER) += apedec.o OBJS-$(CONFIG_ASV1_DECODER) += asv1.o mpeg12data.o OBJS-$(CONFIG_ASV1_ENCODER) += asv1.o mpeg12data.o OBJS-$(CONFIG_ASV2_DECODER) += asv1.o mpeg12data.o OBJS-$(CONFIG_ASV2_ENCODER) += asv1.o mpeg12data.o OBJS-$(CONFIG_ATRAC1_DECODER) += atrac1.o atrac.o OBJS-$(CONFIG_ATRAC3_DECODER) += atrac3.o atrac.o OBJS-$(CONFIG_AURA_DECODER) += cyuv.o OBJS-$(CONFIG_AURA2_DECODER) += aura.o OBJS-$(CONFIG_AVS_DECODER) += avs.o OBJS-$(CONFIG_BETHSOFTVID_DECODER) += bethsoftvideo.o OBJS-$(CONFIG_BFI_DECODER) += bfi.o OBJS-$(CONFIG_BINK_DECODER) += bink.o binkidct.o OBJS-$(CONFIG_BINKAUDIO_DCT_DECODER) += binkaudio.o wma.o OBJS-$(CONFIG_BINKAUDIO_RDFT_DECODER) += binkaudio.o wma.o OBJS-$(CONFIG_BMP_DECODER) += bmp.o msrledec.o OBJS-$(CONFIG_BMP_ENCODER) += bmpenc.o OBJS-$(CONFIG_C93_DECODER) += c93.o OBJS-$(CONFIG_CAVS_DECODER) += cavs.o cavsdec.o cavsdsp.o \ mpeg12data.o mpegvideo.o OBJS-$(CONFIG_CDGRAPHICS_DECODER) += cdgraphics.o OBJS-$(CONFIG_CINEPAK_DECODER) += cinepak.o OBJS-$(CONFIG_CLJR_DECODER) += cljr.o OBJS-$(CONFIG_CLJR_ENCODER) += cljr.o OBJS-$(CONFIG_COOK_DECODER) += cook.o OBJS-$(CONFIG_CSCD_DECODER) += cscd.o OBJS-$(CONFIG_CYUV_DECODER) += cyuv.o OBJS-$(CONFIG_DCA_DECODER) += dca.o synth_filter.o dcadsp.o OBJS-$(CONFIG_DNXHD_DECODER) += dnxhddec.o dnxhddata.o OBJS-$(CONFIG_DNXHD_ENCODER) += dnxhdenc.o dnxhddata.o \ mpegvideo_enc.o motion_est.o \ ratecontrol.o mpeg12data.o \ mpegvideo.o OBJS-$(CONFIG_DPX_DECODER) += dpx.o OBJS-$(CONFIG_DSICINAUDIO_DECODER) += dsicinav.o OBJS-$(CONFIG_DSICINVIDEO_DECODER) += dsicinav.o OBJS-$(CONFIG_DVBSUB_DECODER) += dvbsubdec.o OBJS-$(CONFIG_DVBSUB_ENCODER) += dvbsub.o OBJS-$(CONFIG_DVDSUB_DECODER) += dvdsubdec.o OBJS-$(CONFIG_DVDSUB_ENCODER) += dvdsubenc.o OBJS-$(CONFIG_DVVIDEO_DECODER) += dv.o dvdata.o OBJS-$(CONFIG_DVVIDEO_ENCODER) += dv.o dvdata.o OBJS-$(CONFIG_DXA_DECODER) += dxa.o OBJS-$(CONFIG_EAC3_DECODER) += eac3dec.o eac3dec_data.o OBJS-$(CONFIG_EACMV_DECODER) += eacmv.o OBJS-$(CONFIG_EAMAD_DECODER) += eamad.o eaidct.o mpeg12.o \ mpeg12data.o mpegvideo.o \ error_resilience.o OBJS-$(CONFIG_EATGQ_DECODER) += eatgq.o eaidct.o OBJS-$(CONFIG_EATGV_DECODER) += eatgv.o OBJS-$(CONFIG_EATQI_DECODER) += eatqi.o eaidct.o mpeg12.o \ mpeg12data.o mpegvideo.o \ error_resilience.o OBJS-$(CONFIG_EIGHTBPS_DECODER) += 8bps.o OBJS-$(CONFIG_EIGHTSVX_EXP_DECODER) += 8svx.o OBJS-$(CONFIG_EIGHTSVX_FIB_DECODER) += 8svx.o OBJS-$(CONFIG_ESCAPE124_DECODER) += escape124.o OBJS-$(CONFIG_FFV1_DECODER) += ffv1.o rangecoder.o OBJS-$(CONFIG_FFV1_ENCODER) += ffv1.o rangecoder.o OBJS-$(CONFIG_FFVHUFF_DECODER) += huffyuv.o OBJS-$(CONFIG_FFVHUFF_ENCODER) += huffyuv.o OBJS-$(CONFIG_FLAC_DECODER) += flacdec.o flacdata.o flac.o OBJS-$(CONFIG_FLAC_ENCODER) += flacenc.o flacdata.o flac.o OBJS-$(CONFIG_FLASHSV_DECODER) += flashsv.o OBJS-$(CONFIG_FLASHSV_ENCODER) += flashsvenc.o OBJS-$(CONFIG_FLIC_DECODER) += flicvideo.o OBJS-$(CONFIG_FOURXM_DECODER) += 4xm.o OBJS-$(CONFIG_FRAPS_DECODER) += fraps.o huffman.o OBJS-$(CONFIG_FRWU_DECODER) += frwu.o OBJS-$(CONFIG_GIF_DECODER) += gifdec.o lzw.o OBJS-$(CONFIG_GIF_ENCODER) += gif.o lzwenc.o OBJS-$(CONFIG_H261_DECODER) += h261dec.o h261.o \ mpegvideo.o error_resilience.o OBJS-$(CONFIG_H261_ENCODER) += h261enc.o h261.o \ mpegvideo_enc.o motion_est.o \ ratecontrol.o mpeg12data.o \ mpegvideo.o OBJS-$(CONFIG_H263_DECODER) += h263dec.o h263.o ituh263dec.o \ mpeg4video.o mpeg4videodec.o flvdec.o\ intelh263dec.o mpegvideo.o \ error_resilience.o OBJS-$(CONFIG_H263_VAAPI_HWACCEL) += vaapi_mpeg4.o OBJS-$(CONFIG_H263_ENCODER) += mpegvideo_enc.o mpeg4video.o \ mpeg4videoenc.o motion_est.o \ ratecontrol.o h263.o ituh263enc.o \ flvenc.o mpeg12data.o \ mpegvideo.o error_resilience.o OBJS-$(CONFIG_H264_DECODER) += h264.o \ h264_loopfilter.o h264_direct.o \ cabac.o h264_sei.o h264_ps.o \ h264_refs.o h264_cavlc.o h264_cabac.o\ mpegvideo.o error_resilience.o OBJS-$(CONFIG_H264_DXVA2_HWACCEL) += dxva2_h264.o OBJS-$(CONFIG_H264_ENCODER) += h264enc.o h264dspenc.o OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o OBJS-$(CONFIG_HUFFYUV_DECODER) += huffyuv.o OBJS-$(CONFIG_HUFFYUV_ENCODER) += huffyuv.o OBJS-$(CONFIG_IDCIN_DECODER) += idcinvideo.o OBJS-$(CONFIG_IFF_BYTERUN1_DECODER) += iff.o OBJS-$(CONFIG_IFF_ILBM_DECODER) += iff.o OBJS-$(CONFIG_IMC_DECODER) += imc.o OBJS-$(CONFIG_INDEO2_DECODER) += indeo2.o OBJS-$(CONFIG_INDEO3_DECODER) += indeo3.o OBJS-$(CONFIG_INDEO5_DECODER) += indeo5.o ivi_common.o ivi_dsp.o OBJS-$(CONFIG_INTERPLAY_DPCM_DECODER) += dpcm.o OBJS-$(CONFIG_INTERPLAY_VIDEO_DECODER) += interplayvideo.o OBJS-$(CONFIG_JPEGLS_DECODER) += jpeglsdec.o jpegls.o \ mjpegdec.o mjpeg.o OBJS-$(CONFIG_JPEGLS_ENCODER) += jpeglsenc.o jpegls.o OBJS-$(CONFIG_KGV1_DECODER) += kgv1dec.o OBJS-$(CONFIG_KMVC_DECODER) += kmvc.o OBJS-$(CONFIG_LJPEG_ENCODER) += ljpegenc.o mjpegenc.o mjpeg.o \ mpegvideo_enc.o motion_est.o \ ratecontrol.o mpeg12data.o \ mpegvideo.o OBJS-$(CONFIG_LOCO_DECODER) += loco.o OBJS-$(CONFIG_MACE3_DECODER) += mace.o OBJS-$(CONFIG_MACE6_DECODER) += mace.o OBJS-$(CONFIG_MDEC_DECODER) += mdec.o mpeg12.o mpeg12data.o \ mpegvideo.o error_resilience.o OBJS-$(CONFIG_MIMIC_DECODER) += mimic.o OBJS-$(CONFIG_MJPEG_DECODER) += mjpegdec.o mjpeg.o OBJS-$(CONFIG_MJPEG_ENCODER) += mjpegenc.o mjpeg.o \ mpegvideo_enc.o motion_est.o \ ratecontrol.o mpeg12data.o \ mpegvideo.o OBJS-$(CONFIG_MJPEGB_DECODER) += mjpegbdec.o mjpegdec.o mjpeg.o OBJS-$(CONFIG_MLP_DECODER) += mlpdec.o mlpdsp.o OBJS-$(CONFIG_MMVIDEO_DECODER) += mmvideo.o OBJS-$(CONFIG_MOTIONPIXELS_DECODER) += motionpixels.o OBJS-$(CONFIG_MP1_DECODER) += mpegaudiodec.o mpegaudiodecheader.o \ mpegaudio.o mpegaudiodata.o OBJS-$(CONFIG_MP2_DECODER) += mpegaudiodec.o mpegaudiodecheader.o \ mpegaudio.o mpegaudiodata.o OBJS-$(CONFIG_MP2_ENCODER) += mpegaudioenc.o mpegaudio.o \ mpegaudiodata.o OBJS-$(CONFIG_MP3ADU_DECODER) += mpegaudiodec.o mpegaudiodecheader.o \ mpegaudio.o mpegaudiodata.o OBJS-$(CONFIG_MP3ON4_DECODER) += mpegaudiodec.o mpegaudiodecheader.o \ mpegaudio.o mpegaudiodata.o \ mpeg4audio.o OBJS-$(CONFIG_MP3_DECODER) += mpegaudiodec.o mpegaudiodecheader.o \ mpegaudio.o mpegaudiodata.o OBJS-$(CONFIG_MPC7_DECODER) += mpc7.o mpc.o mpegaudiodec.o \ mpegaudiodecheader.o mpegaudio.o \ mpegaudiodata.o OBJS-$(CONFIG_MPC8_DECODER) += mpc8.o mpc.o mpegaudiodec.o \ mpegaudiodecheader.o mpegaudio.o \ mpegaudiodata.o OBJS-$(CONFIG_MPEGVIDEO_DECODER) += mpeg12.o mpeg12data.o \ mpegvideo.o error_resilience.o OBJS-$(CONFIG_MPEG_XVMC_DECODER) += mpegvideo_xvmc.o OBJS-$(CONFIG_MPEG1VIDEO_DECODER) += mpeg12.o mpeg12data.o \ mpegvideo.o error_resilience.o OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o mpegvideo_enc.o \ motion_est.o ratecontrol.o \ mpeg12.o mpeg12data.o \ mpegvideo.o error_resilience.o OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL) += vaapi_mpeg2.o OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12.o mpeg12data.o \ mpegvideo.o error_resilience.o OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpegvideo_enc.o \ motion_est.o ratecontrol.o \ mpeg12.o mpeg12data.o \ mpegvideo.o error_resilience.o OBJS-$(CONFIG_MPEG4_VAAPI_HWACCEL) += vaapi_mpeg4.o OBJS-$(CONFIG_MSMPEG4V1_DECODER) += msmpeg4.o msmpeg4data.o OBJS-$(CONFIG_MSMPEG4V1_ENCODER) += msmpeg4.o msmpeg4data.o h263dec.o \ h263.o ituh263dec.o mpeg4videodec.o OBJS-$(CONFIG_MSMPEG4V2_DECODER) += msmpeg4.o msmpeg4data.o h263dec.o \ h263.o ituh263dec.o mpeg4videodec.o OBJS-$(CONFIG_MSMPEG4V2_ENCODER) += msmpeg4.o msmpeg4data.o h263dec.o \ h263.o ituh263dec.o mpeg4videodec.o OBJS-$(CONFIG_MSMPEG4V3_DECODER) += msmpeg4.o msmpeg4data.o h263dec.o \ h263.o ituh263dec.o mpeg4videodec.o OBJS-$(CONFIG_MSMPEG4V3_ENCODER) += msmpeg4.o msmpeg4data.o h263dec.o \ h263.o ituh263dec.o mpeg4videodec.o OBJS-$(CONFIG_MSRLE_DECODER) += msrle.o msrledec.o OBJS-$(CONFIG_MSVIDEO1_DECODER) += msvideo1.o OBJS-$(CONFIG_MSZH_DECODER) += lcldec.o OBJS-$(CONFIG_NELLYMOSER_DECODER) += nellymoserdec.o nellymoser.o OBJS-$(CONFIG_NELLYMOSER_ENCODER) += nellymoserenc.o nellymoser.o OBJS-$(CONFIG_NUV_DECODER) += nuv.o rtjpeg.o OBJS-$(CONFIG_PAM_DECODER) += pnmdec.o pnm.o OBJS-$(CONFIG_PAM_ENCODER) += pamenc.o pnm.o OBJS-$(CONFIG_PBM_DECODER) += pnmdec.o pnm.o OBJS-$(CONFIG_PBM_ENCODER) += pnmenc.o pnm.o OBJS-$(CONFIG_PCX_DECODER) += pcx.o OBJS-$(CONFIG_PCX_ENCODER) += pcxenc.o OBJS-$(CONFIG_PGM_DECODER) += pnmdec.o pnm.o OBJS-$(CONFIG_PGM_ENCODER) += pnmenc.o pnm.o OBJS-$(CONFIG_PGMYUV_DECODER) += pnmdec.o pnm.o OBJS-$(CONFIG_PGMYUV_ENCODER) += pnmenc.o pnm.o OBJS-$(CONFIG_PGSSUB_DECODER) += pgssubdec.o OBJS-$(CONFIG_PNG_DECODER) += png.o pngdec.o OBJS-$(CONFIG_PNG_ENCODER) += png.o pngenc.o OBJS-$(CONFIG_PPM_DECODER) += pnmdec.o pnm.o OBJS-$(CONFIG_PPM_ENCODER) += pnmenc.o pnm.o OBJS-$(CONFIG_PTX_DECODER) += ptx.o OBJS-$(CONFIG_QCELP_DECODER) += qcelpdec.o celp_math.o \ celp_filters.o acelp_vectors.o \ acelp_filters.o OBJS-$(CONFIG_QDM2_DECODER) += qdm2.o mpegaudiodec.o \ mpegaudiodecheader.o mpegaudio.o \ mpegaudiodata.o OBJS-$(CONFIG_QDRAW_DECODER) += qdrw.o OBJS-$(CONFIG_QPEG_DECODER) += qpeg.o OBJS-$(CONFIG_QTRLE_DECODER) += qtrle.o OBJS-$(CONFIG_QTRLE_ENCODER) += qtrleenc.o OBJS-$(CONFIG_R210_DECODER) += r210dec.o OBJS-$(CONFIG_RA_144_DECODER) += ra144.o celp_filters.o OBJS-$(CONFIG_RA_288_DECODER) += ra288.o celp_math.o celp_filters.o OBJS-$(CONFIG_RAWVIDEO_DECODER) += rawdec.o OBJS-$(CONFIG_RAWVIDEO_ENCODER) += rawenc.o OBJS-$(CONFIG_RL2_DECODER) += rl2.o OBJS-$(CONFIG_ROQ_DECODER) += roqvideodec.o roqvideo.o OBJS-$(CONFIG_ROQ_ENCODER) += roqvideoenc.o roqvideo.o elbg.o OBJS-$(CONFIG_ROQ_DPCM_DECODER) += dpcm.o OBJS-$(CONFIG_ROQ_DPCM_ENCODER) += roqaudioenc.o OBJS-$(CONFIG_RPZA_DECODER) += rpza.o OBJS-$(CONFIG_RV10_DECODER) += rv10.o OBJS-$(CONFIG_RV10_ENCODER) += rv10enc.o OBJS-$(CONFIG_RV20_DECODER) += rv10.o OBJS-$(CONFIG_RV20_ENCODER) += rv20enc.o OBJS-$(CONFIG_RV30_DECODER) += rv30.o rv34.o rv30dsp.o \ mpegvideo.o error_resilience.o OBJS-$(CONFIG_RV40_DECODER) += rv40.o rv34.o rv40dsp.o \ mpegvideo.o error_resilience.o OBJS-$(CONFIG_SGI_DECODER) += sgidec.o OBJS-$(CONFIG_SGI_ENCODER) += sgienc.o rle.o OBJS-$(CONFIG_SHORTEN_DECODER) += shorten.o OBJS-$(CONFIG_SIPR_DECODER) += sipr.o acelp_pitch_delay.o \ celp_math.o acelp_vectors.o \ acelp_filters.o celp_filters.o \ sipr16k.o OBJS-$(CONFIG_SMACKAUD_DECODER) += smacker.o OBJS-$(CONFIG_SMACKER_DECODER) += smacker.o OBJS-$(CONFIG_SMC_DECODER) += smc.o OBJS-$(CONFIG_SNOW_DECODER) += snow.o rangecoder.o OBJS-$(CONFIG_SNOW_ENCODER) += snow.o rangecoder.o motion_est.o \ ratecontrol.o h263.o \ mpegvideo.o error_resilience.o \ ituh263enc.o mpegvideo_enc.o \ mpeg12data.o OBJS-$(CONFIG_SOL_DPCM_DECODER) += dpcm.o OBJS-$(CONFIG_SONIC_DECODER) += sonic.o OBJS-$(CONFIG_SONIC_ENCODER) += sonic.o OBJS-$(CONFIG_SONIC_LS_ENCODER) += sonic.o OBJS-$(CONFIG_SP5X_DECODER) += sp5xdec.o mjpegdec.o mjpeg.o OBJS-$(CONFIG_SUNRAST_DECODER) += sunrast.o OBJS-$(CONFIG_SVQ1_DECODER) += svq1dec.o svq1.o h263.o \ mpegvideo.o error_resilience.o OBJS-$(CONFIG_SVQ1_ENCODER) += svq1enc.o svq1.o \ motion_est.o h263.o \ mpegvideo.o error_resilience.o \ ituh263enc.o mpegvideo_enc.o \ ratecontrol.o mpeg12data.o OBJS-$(CONFIG_SVQ3_DECODER) += h264.o svq3.o \ h264_loopfilter.o h264_direct.o \ h264_sei.o h264_ps.o h264_refs.o \ h264_cavlc.o h264_cabac.o cabac.o \ mpegvideo.o error_resilience.o \ svq1dec.o svq1.o h263.o OBJS-$(CONFIG_TARGA_DECODER) += targa.o OBJS-$(CONFIG_TARGA_ENCODER) += targaenc.o rle.o OBJS-$(CONFIG_THEORA_DECODER) += xiph.o OBJS-$(CONFIG_THP_DECODER) += mjpegdec.o mjpeg.o OBJS-$(CONFIG_TIERTEXSEQVIDEO_DECODER) += tiertexseqv.o OBJS-$(CONFIG_TIFF_DECODER) += tiff.o lzw.o faxcompr.o OBJS-$(CONFIG_TIFF_ENCODER) += tiffenc.o rle.o lzwenc.o OBJS-$(CONFIG_TMV_DECODER) += tmv.o cga_data.o OBJS-$(CONFIG_TRUEMOTION1_DECODER) += truemotion1.o OBJS-$(CONFIG_TRUEMOTION2_DECODER) += truemotion2.o OBJS-$(CONFIG_TRUESPEECH_DECODER) += truespeech.o OBJS-$(CONFIG_TSCC_DECODER) += tscc.o msrledec.o OBJS-$(CONFIG_TTA_DECODER) += tta.o OBJS-$(CONFIG_TWINVQ_DECODER) += twinvq.o celp_math.o OBJS-$(CONFIG_TXD_DECODER) += txd.o s3tc.o OBJS-$(CONFIG_ULTI_DECODER) += ulti.o OBJS-$(CONFIG_V210_DECODER) += v210dec.o OBJS-$(CONFIG_V210_ENCODER) += v210enc.o OBJS-$(CONFIG_V210X_DECODER) += v210x.o OBJS-$(CONFIG_VB_DECODER) += vb.o OBJS-$(CONFIG_VC1_DECODER) += vc1dec.o vc1.o vc1data.o vc1dsp.o \ msmpeg4.o msmpeg4data.o \ intrax8.o intrax8dsp.o OBJS-$(CONFIG_VC1_DXVA2_HWACCEL) += dxva2_vc1.o OBJS-$(CONFIG_VC1_VAAPI_HWACCEL) += vaapi_vc1.o OBJS-$(CONFIG_VCR1_DECODER) += vcr1.o OBJS-$(CONFIG_VCR1_ENCODER) += vcr1.o OBJS-$(CONFIG_VMDAUDIO_DECODER) += vmdav.o OBJS-$(CONFIG_VMDVIDEO_DECODER) += vmdav.o OBJS-$(CONFIG_VMNC_DECODER) += vmnc.o OBJS-$(CONFIG_VORBIS_DECODER) += vorbis_dec.o vorbis.o \ vorbis_data.o xiph.o OBJS-$(CONFIG_VORBIS_ENCODER) += vorbis_enc.o vorbis.o \ vorbis_data.o OBJS-$(CONFIG_VP3_DECODER) += vp3.o vp3dsp.o OBJS-$(CONFIG_VP5_DECODER) += vp5.o vp56.o vp56data.o vp56dsp.o \ vp3dsp.o OBJS-$(CONFIG_VP6_DECODER) += vp6.o vp56.o vp56data.o vp56dsp.o \ vp3dsp.o vp6dsp.o huffman.o OBJS-$(CONFIG_VQA_DECODER) += vqavideo.o OBJS-$(CONFIG_WAVPACK_DECODER) += wavpack.o OBJS-$(CONFIG_WMAPRO_DECODER) += wmaprodec.o wma.o OBJS-$(CONFIG_WMAV1_DECODER) += wmadec.o wma.o aactab.o OBJS-$(CONFIG_WMAV1_ENCODER) += wmaenc.o wma.o aactab.o OBJS-$(CONFIG_WMAV2_DECODER) += wmadec.o wma.o aactab.o OBJS-$(CONFIG_WMAV2_ENCODER) += wmaenc.o wma.o aactab.o OBJS-$(CONFIG_WMAVOICE_DECODER) += wmavoice.o \ celp_math.o celp_filters.o \ acelp_vectors.o acelp_filters.o OBJS-$(CONFIG_WMV1_DECODER) += msmpeg4.o msmpeg4data.o OBJS-$(CONFIG_WMV2_DECODER) += wmv2dec.o wmv2.o \ msmpeg4.o msmpeg4data.o \ intrax8.o intrax8dsp.o OBJS-$(CONFIG_WMV2_ENCODER) += wmv2enc.o wmv2.o \ msmpeg4.o msmpeg4data.o \ mpeg4videodec.o ituh263dec.o h263dec.o OBJS-$(CONFIG_WNV1_DECODER) += wnv1.o OBJS-$(CONFIG_WS_SND1_DECODER) += ws-snd1.o OBJS-$(CONFIG_XAN_DPCM_DECODER) += dpcm.o OBJS-$(CONFIG_XAN_WC3_DECODER) += xan.o OBJS-$(CONFIG_XAN_WC4_DECODER) += xan.o OBJS-$(CONFIG_XL_DECODER) += xl.o OBJS-$(CONFIG_XSUB_DECODER) += xsubdec.o OBJS-$(CONFIG_XSUB_ENCODER) += xsubenc.o OBJS-$(CONFIG_YOP_DECODER) += yop.o OBJS-$(CONFIG_ZLIB_DECODER) += lcldec.o OBJS-$(CONFIG_ZLIB_ENCODER) += lclenc.o OBJS-$(CONFIG_ZMBV_DECODER) += zmbv.o OBJS-$(CONFIG_ZMBV_ENCODER) += zmbvenc.o # (AD)PCM decoders/encoders OBJS-$(CONFIG_PCM_ALAW_DECODER) += pcm.o OBJS-$(CONFIG_PCM_ALAW_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_BLURAY_DECODER) += pcm-mpeg.o OBJS-$(CONFIG_PCM_DVD_DECODER) += pcm.o OBJS-$(CONFIG_PCM_DVD_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_F32BE_DECODER) += pcm.o OBJS-$(CONFIG_PCM_F32BE_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_F32LE_DECODER) += pcm.o OBJS-$(CONFIG_PCM_F32LE_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_F64BE_DECODER) += pcm.o OBJS-$(CONFIG_PCM_F64BE_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_F64LE_DECODER) += pcm.o OBJS-$(CONFIG_PCM_F64LE_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_MULAW_DECODER) += pcm.o OBJS-$(CONFIG_PCM_MULAW_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_S8_DECODER) += pcm.o OBJS-$(CONFIG_PCM_S8_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_S16BE_DECODER) += pcm.o OBJS-$(CONFIG_PCM_S16BE_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_S16LE_DECODER) += pcm.o OBJS-$(CONFIG_PCM_S16LE_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_S16LE_PLANAR_DECODER) += pcm.o OBJS-$(CONFIG_PCM_S24BE_DECODER) += pcm.o OBJS-$(CONFIG_PCM_S24BE_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_S24DAUD_DECODER) += pcm.o OBJS-$(CONFIG_PCM_S24DAUD_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_S24LE_DECODER) += pcm.o OBJS-$(CONFIG_PCM_S24LE_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_S32BE_DECODER) += pcm.o OBJS-$(CONFIG_PCM_S32BE_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_S32LE_DECODER) += pcm.o OBJS-$(CONFIG_PCM_S32LE_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_U8_DECODER) += pcm.o OBJS-$(CONFIG_PCM_U8_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_U16BE_DECODER) += pcm.o OBJS-$(CONFIG_PCM_U16BE_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_U16LE_DECODER) += pcm.o OBJS-$(CONFIG_PCM_U16LE_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_U24BE_DECODER) += pcm.o OBJS-$(CONFIG_PCM_U24BE_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_U24LE_DECODER) += pcm.o OBJS-$(CONFIG_PCM_U24LE_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_U32BE_DECODER) += pcm.o OBJS-$(CONFIG_PCM_U32BE_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_U32LE_DECODER) += pcm.o OBJS-$(CONFIG_PCM_U32LE_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_ZORK_DECODER) += pcm.o OBJS-$(CONFIG_PCM_ZORK_ENCODER) += pcm.o OBJS-$(CONFIG_ADPCM_4XM_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_ADX_DECODER) += adxdec.o OBJS-$(CONFIG_ADPCM_ADX_ENCODER) += adxenc.o OBJS-$(CONFIG_ADPCM_CT_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_EA_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_EA_MAXIS_XA_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_EA_R1_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_EA_R2_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_EA_R3_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_EA_XAS_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_G726_DECODER) += g726.o OBJS-$(CONFIG_ADPCM_G726_ENCODER) += g726.o OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_IMA_DK3_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_IMA_DK4_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_IMA_EA_EACS_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_IMA_EA_SEAD_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_IMA_ISS_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_IMA_QT_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_IMA_QT_ENCODER) += adpcm.o OBJS-$(CONFIG_ADPCM_IMA_SMJPEG_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_IMA_WAV_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_IMA_WAV_ENCODER) += adpcm.o OBJS-$(CONFIG_ADPCM_IMA_WS_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_MS_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_MS_ENCODER) += adpcm.o OBJS-$(CONFIG_ADPCM_SBPRO_2_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_SBPRO_3_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_SBPRO_4_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_SWF_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_SWF_ENCODER) += adpcm.o OBJS-$(CONFIG_ADPCM_THP_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_XA_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_YAMAHA_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_YAMAHA_ENCODER) += adpcm.o # libavformat dependencies OBJS-$(CONFIG_ADTS_MUXER) += mpeg4audio.o OBJS-$(CONFIG_CAF_DEMUXER) += mpeg4audio.o mpegaudiodata.o OBJS-$(CONFIG_DV_DEMUXER) += dvdata.o OBJS-$(CONFIG_DV_MUXER) += dvdata.o OBJS-$(CONFIG_FLAC_DEMUXER) += flacdec.o flacdata.o flac.o OBJS-$(CONFIG_FLAC_MUXER) += flacdec.o flacdata.o flac.o OBJS-$(CONFIG_FLV_DEMUXER) += mpeg4audio.o OBJS-$(CONFIG_GXF_DEMUXER) += mpeg12data.o OBJS-$(CONFIG_IFF_DEMUXER) += iff.o OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER) += xiph.o mpeg4audio.o \ flacdec.o flacdata.o flac.o OBJS-$(CONFIG_MATROSKA_DEMUXER) += mpeg4audio.o OBJS-$(CONFIG_MATROSKA_MUXER) += xiph.o mpeg4audio.o \ flacdec.o flacdata.o flac.o OBJS-$(CONFIG_MOV_DEMUXER) += mpeg4audio.o mpegaudiodata.o OBJS-$(CONFIG_MPEGTS_MUXER) += mpegvideo.o mpeg4audio.o OBJS-$(CONFIG_NUT_MUXER) += mpegaudiodata.o OBJS-$(CONFIG_OGG_DEMUXER) += flacdec.o flacdata.o flac.o \ dirac.o mpeg12data.o OBJS-$(CONFIG_OGG_MUXER) += xiph.o flacdec.o flacdata.o flac.o OBJS-$(CONFIG_RTP_MUXER) += mpegvideo.o OBJS-$(CONFIG_WEBM_MUXER) += xiph.o mpeg4audio.o \ flacdec.o flacdata.o flac.o # external codec libraries OBJS-$(CONFIG_LIBDIRAC_DECODER) += libdiracdec.o OBJS-$(CONFIG_LIBDIRAC_ENCODER) += libdiracenc.o libdirac_libschro.o OBJS-$(CONFIG_LIBFAAC_ENCODER) += libfaac.o OBJS-$(CONFIG_LIBFAAD_DECODER) += libfaad.o OBJS-$(CONFIG_LIBGSM_DECODER) += libgsm.o OBJS-$(CONFIG_LIBGSM_ENCODER) += libgsm.o OBJS-$(CONFIG_LIBGSM_MS_DECODER) += libgsm.o OBJS-$(CONFIG_LIBGSM_MS_ENCODER) += libgsm.o OBJS-$(CONFIG_LIBMP3LAME_ENCODER) += libmp3lame.o OBJS-$(CONFIG_LIBOPENCORE_AMRNB_DECODER) += libopencore-amr.o OBJS-$(CONFIG_LIBOPENCORE_AMRNB_ENCODER) += libopencore-amr.o OBJS-$(CONFIG_LIBOPENCORE_AMRWB_DECODER) += libopencore-amr.o OBJS-$(CONFIG_LIBOPENJPEG_DECODER) += libopenjpeg.o OBJS-$(CONFIG_LIBSCHROEDINGER_DECODER) += libschroedingerdec.o \ libschroedinger.o \ libdirac_libschro.o OBJS-$(CONFIG_LIBSCHROEDINGER_ENCODER) += libschroedingerenc.o \ libschroedinger.o \ libdirac_libschro.o OBJS-$(CONFIG_LIBSPEEX_DECODER) += libspeexdec.o OBJS-$(CONFIG_LIBTHEORA_ENCODER) += libtheoraenc.o OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbis.o OBJS-$(CONFIG_LIBVPX_DECODER) += libvpxdec.o OBJS-$(CONFIG_LIBVPX_ENCODER) += libvpxenc.o OBJS-$(CONFIG_LIBX264_ENCODER) += libx264.o OBJS-$(CONFIG_LIBXVID_ENCODER) += libxvidff.o libxvid_rc.o # parsers OBJS-$(CONFIG_AAC_PARSER) += aac_parser.o aac_ac3_parser.o \ mpeg4audio.o OBJS-$(CONFIG_AC3_PARSER) += ac3_parser.o ac3tab.o \ aac_ac3_parser.o OBJS-$(CONFIG_CAVSVIDEO_PARSER) += cavs_parser.o OBJS-$(CONFIG_DCA_PARSER) += dca_parser.o OBJS-$(CONFIG_DIRAC_PARSER) += dirac_parser.o OBJS-$(CONFIG_DNXHD_PARSER) += dnxhd_parser.o OBJS-$(CONFIG_DVBSUB_PARSER) += dvbsub_parser.o OBJS-$(CONFIG_DVDSUB_PARSER) += dvdsub_parser.o OBJS-$(CONFIG_H261_PARSER) += h261_parser.o OBJS-$(CONFIG_H263_PARSER) += h263_parser.o OBJS-$(CONFIG_H264_PARSER) += h264_parser.o h264.o \ cabac.o \ h264_refs.o h264_sei.o h264_direct.o \ h264_loopfilter.o h264_cabac.o \ h264_cavlc.o h264_ps.o \ mpegvideo.o error_resilience.o OBJS-$(CONFIG_MJPEG_PARSER) += mjpeg_parser.o OBJS-$(CONFIG_MLP_PARSER) += mlp_parser.o mlp.o OBJS-$(CONFIG_MPEG4VIDEO_PARSER) += mpeg4video_parser.o h263.o \ mpegvideo.o error_resilience.o \ mpeg4videodec.o mpeg4video.o \ ituh263dec.o h263dec.o OBJS-$(CONFIG_MPEGAUDIO_PARSER) += mpegaudio_parser.o \ mpegaudiodecheader.o mpegaudiodata.o OBJS-$(CONFIG_MPEGVIDEO_PARSER) += mpegvideo_parser.o \ mpeg12.o mpeg12data.o \ mpegvideo.o error_resilience.o OBJS-$(CONFIG_PNM_PARSER) += pnm_parser.o pnm.o OBJS-$(CONFIG_VC1_PARSER) += vc1_parser.o vc1.o vc1data.o \ msmpeg4.o msmpeg4data.o mpeg4video.o \ h263.o mpegvideo.o error_resilience.o OBJS-$(CONFIG_VP3_PARSER) += vp3_parser.o # bitstream filters OBJS-$(CONFIG_AAC_ADTSTOASC_BSF) += aac_adtstoasc_bsf.o OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o OBJS-$(CONFIG_H264_MP4TOANNEXB_BSF) += h264_mp4toannexb_bsf.o OBJS-$(CONFIG_IMX_DUMP_HEADER_BSF) += imx_dump_header_bsf.o OBJS-$(CONFIG_MJPEGA_DUMP_HEADER_BSF) += mjpega_dump_header_bsf.o OBJS-$(CONFIG_MOV2TEXTSUB_BSF) += movsub_bsf.o OBJS-$(CONFIG_MP3_HEADER_COMPRESS_BSF) += mp3_header_compress_bsf.o OBJS-$(CONFIG_MP3_HEADER_DECOMPRESS_BSF) += mp3_header_decompress_bsf.o \ mpegaudiodata.o OBJS-$(CONFIG_NOISE_BSF) += noise_bsf.o OBJS-$(CONFIG_REMOVE_EXTRADATA_BSF) += remove_extradata_bsf.o OBJS-$(CONFIG_TEXT2MOVSUB_BSF) += movsub_bsf.o # thread libraries OBJS-$(HAVE_BEOSTHREADS) += beosthread.o OBJS-$(HAVE_OS2THREADS) += os2thread.o OBJS-$(HAVE_PTHREADS) += pthread.o OBJS-$(HAVE_W32THREADS) += w32thread.o OBJS-$(CONFIG_MLIB) += mlib/dsputil_mlib.o \ -include $(SUBDIR)$(ARCH)/Makefile SKIPHEADERS = %_tablegen.h SKIPHEADERS-$(CONFIG_DXVA2) += dxva2.h dxva2_internal.h SKIPHEADERS-$(CONFIG_LIBDIRAC) += libdirac.h SKIPHEADERS-$(CONFIG_LIBSCHROEDINGER) += libschroedinger.h SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_internal.h SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h SKIPHEADERS-$(CONFIG_XVMC) += xvmc.h SKIPHEADERS += mpegaudio3.h EXAMPLES = api TESTPROGS = cabac dct eval fft h264 iirfilter rangecoder snow TESTPROGS-$(ARCH_X86) += x86/cpuid TESTPROGS-$(HAVE_MMX) += motion TESTOBJS = dctref.o HOSTPROGS = costablegen DIRS = alpha arm bfin mlib ppc ps2 sh4 sparc x86 CLEANFILES = sin_tables.c cos_tables.c *_tables.h *_tablegen$(HOSTEXESUF) $(SUBDIR)dct-test$(EXESUF): $(SUBDIR)dctref.o $(SUBDIR)cos_tables.c: $(SUBDIR)costablegen$(HOSTEXESUF) $(M)./$< > $@ $(SUBDIR)sin_tables.c: $(SUBDIR)costablegen$(HOSTEXESUF) $(M)./$< sin > $@ ifdef CONFIG_MPEGAUDIO_HP $(SUBDIR)mpegaudio_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DFRAC_BITS=23 $(SUBDIR)mpegaudio_tablegen.ho: CPPFLAGS += -DFRAC_BITS=23 else $(SUBDIR)mpegaudio_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DFRAC_BITS=15 $(SUBDIR)mpegaudio_tablegen.ho: CPPFLAGS += -DFRAC_BITS=15 endif ifdef CONFIG_SMALL $(SUBDIR)%_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DCONFIG_SMALL=1 else $(SUBDIR)%_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DCONFIG_SMALL=0 endif $(SUBDIR)%_tablegen$(HOSTEXESUF): $(SUBDIR)%_tablegen.c $(SUBDIR)tableprint.c $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ $(HOSTLIBS) $(SUBDIR)%_tables.h: $(SUBDIR)%_tablegen$(HOSTEXESUF) $(M)./$< > $@ ifdef CONFIG_HARDCODED_TABLES $(SUBDIR)aac.o: $(SUBDIR)cbrt_tables.h $(SUBDIR)dv.o: $(SUBDIR)dv_tables.h $(SUBDIR)mdct.o: $(SUBDIR)mdct_tables.h $(SUBDIR)mpegaudiodec.o: $(SUBDIR)mpegaudio_tables.h $(SUBDIR)motionpixels.o: $(SUBDIR)motionpixels_tables.h $(SUBDIR)pcm.o: $(SUBDIR)pcm_tables.h $(SUBDIR)qdm2.o: $(SUBDIR)qdm2_tables.h endif
123linslouis-android-video-cutter
jni/libavcodec/Makefile
Makefile
asf20
36,876
/* * various filters for ACELP-based codecs * * Copyright (c) 2008 Vladimir Voroshilov * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <inttypes.h> #include "avcodec.h" #include "acelp_filters.h" const int16_t ff_acelp_interp_filter[61] = { /* (0.15) */ 29443, 28346, 25207, 20449, 14701, 8693, 3143, -1352, -4402, -5865, -5850, -4673, -2783, -672, 1211, 2536, 3130, 2991, 2259, 1170, 0, -1001, -1652, -1868, -1666, -1147, -464, 218, 756, 1060, 1099, 904, 550, 135, -245, -514, -634, -602, -451, -231, 0, 191, 308, 340, 296, 198, 78, -36, -120, -163, -165, -132, -79, -19, 34, 73, 91, 89, 70, 38, 0, }; void ff_acelp_interpolate(int16_t* out, const int16_t* in, const int16_t* filter_coeffs, int precision, int frac_pos, int filter_length, int length) { int n, i; assert(frac_pos >= 0 && frac_pos < precision); for (n = 0; n < length; n++) { int idx = 0; int v = 0x4000; for (i = 0; i < filter_length;) { /* The reference G.729 and AMR fixed point code performs clipping after each of the two following accumulations. Since clipping affects only the synthetic OVERFLOW test without causing an int type overflow, it was moved outside the loop. */ /* R(x):=ac_v[-k+x] v += R(n-i)*ff_acelp_interp_filter(t+6i) v += R(n+i+1)*ff_acelp_interp_filter(6-t+6i) */ v += in[n + i] * filter_coeffs[idx + frac_pos]; idx += precision; i++; v += in[n - i] * filter_coeffs[idx - frac_pos]; } if (av_clip_int16(v >> 15) != (v >> 15)) av_log(NULL, AV_LOG_WARNING, "overflow that would need cliping in ff_acelp_interpolate()\n"); out[n] = v >> 15; } } void ff_acelp_interpolatef(float *out, const float *in, const float *filter_coeffs, int precision, int frac_pos, int filter_length, int length) { int n, i; for (n = 0; n < length; n++) { int idx = 0; float v = 0; for (i = 0; i < filter_length;) { v += in[n + i] * filter_coeffs[idx + frac_pos]; idx += precision; i++; v += in[n - i] * filter_coeffs[idx - frac_pos]; } out[n] = v; } } void ff_acelp_high_pass_filter(int16_t* out, int hpf_f[2], const int16_t* in, int length) { int i; int tmp; for (i = 0; i < length; i++) { tmp = (hpf_f[0]* 15836LL) >> 13; tmp += (hpf_f[1]* -7667LL) >> 13; tmp += 7699 * (in[i] - 2*in[i-1] + in[i-2]); /* With "+0x800" rounding, clipping is needed for ALGTHM and SPEECH tests. */ out[i] = av_clip_int16((tmp + 0x800) >> 12); hpf_f[1] = hpf_f[0]; hpf_f[0] = tmp; } } void ff_acelp_apply_order_2_transfer_function(float *out, const float *in, const float zero_coeffs[2], const float pole_coeffs[2], float gain, float mem[2], int n) { int i; float tmp; for (i = 0; i < n; i++) { tmp = gain * in[i] - pole_coeffs[0] * mem[0] - pole_coeffs[1] * mem[1]; out[i] = tmp + zero_coeffs[0] * mem[0] + zero_coeffs[1] * mem[1]; mem[1] = mem[0]; mem[0] = tmp; } } void ff_tilt_compensation(float *mem, float tilt, float *samples, int size) { float new_tilt_mem = samples[size - 1]; int i; for (i = size - 1; i > 0; i--) samples[i] -= tilt * samples[i - 1]; samples[0] -= tilt * *mem; *mem = new_tilt_mem; }
123linslouis-android-video-cutter
jni/libavcodec/acelp_filters.c
C
asf20
4,580
/* * Creative YUV (CYUV) Video Decoder * by Mike Melanson (melanson@pcisys.net) * based on "Creative YUV (CYUV) stream format for AVI": * http://www.csse.monash.edu.au/~timf/videocodec/cyuv.txt * * Copyright (C) 2003 the ffmpeg project * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * Creative YUV (CYUV) Video Decoder. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "avcodec.h" #include "dsputil.h" typedef struct CyuvDecodeContext { AVCodecContext *avctx; int width, height; AVFrame frame; } CyuvDecodeContext; static av_cold int cyuv_decode_init(AVCodecContext *avctx) { CyuvDecodeContext *s = avctx->priv_data; s->avctx = avctx; s->width = avctx->width; /* width needs to be divisible by 4 for this codec to work */ if (s->width & 0x3) return -1; s->height = avctx->height; avctx->pix_fmt = PIX_FMT_YUV411P; return 0; } static int cyuv_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; CyuvDecodeContext *s=avctx->priv_data; unsigned char *y_plane; unsigned char *u_plane; unsigned char *v_plane; int y_ptr; int u_ptr; int v_ptr; /* prediction error tables (make it clear that they are signed values) */ const signed char *y_table = (const signed char*)buf + 0; const signed char *u_table = (const signed char*)buf + 16; const signed char *v_table = (const signed char*)buf + 32; unsigned char y_pred, u_pred, v_pred; int stream_ptr; unsigned char cur_byte; int pixel_groups; if (avctx->codec_id == CODEC_ID_AURA) { y_table = u_table; u_table = v_table; } /* sanity check the buffer size: A buffer has 3x16-bytes tables * followed by (height) lines each with 3 bytes to represent groups * of 4 pixels. Thus, the total size of the buffer ought to be: * (3 * 16) + height * (width * 3 / 4) */ if (buf_size != 48 + s->height * (s->width * 3 / 4)) { av_log(avctx, AV_LOG_ERROR, "got a buffer with %d bytes when %d were expected\n", buf_size, 48 + s->height * (s->width * 3 / 4)); return -1; } /* pixel data starts 48 bytes in, after 3x16-byte tables */ stream_ptr = 48; if (s->frame.data[0]) avctx->release_buffer(avctx, &s->frame); s->frame.buffer_hints = FF_BUFFER_HINTS_VALID; s->frame.reference = 0; if (avctx->get_buffer(avctx, &s->frame) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } y_plane = s->frame.data[0]; u_plane = s->frame.data[1]; v_plane = s->frame.data[2]; /* iterate through each line in the height */ for (y_ptr = 0, u_ptr = 0, v_ptr = 0; y_ptr < (s->height * s->frame.linesize[0]); y_ptr += s->frame.linesize[0] - s->width, u_ptr += s->frame.linesize[1] - s->width / 4, v_ptr += s->frame.linesize[2] - s->width / 4) { /* reset predictors */ cur_byte = buf[stream_ptr++]; u_plane[u_ptr++] = u_pred = cur_byte & 0xF0; y_plane[y_ptr++] = y_pred = (cur_byte & 0x0F) << 4; cur_byte = buf[stream_ptr++]; v_plane[v_ptr++] = v_pred = cur_byte & 0xF0; y_pred += y_table[cur_byte & 0x0F]; y_plane[y_ptr++] = y_pred; cur_byte = buf[stream_ptr++]; y_pred += y_table[cur_byte & 0x0F]; y_plane[y_ptr++] = y_pred; y_pred += y_table[(cur_byte & 0xF0) >> 4]; y_plane[y_ptr++] = y_pred; /* iterate through the remaining pixel groups (4 pixels/group) */ pixel_groups = s->width / 4 - 1; while (pixel_groups--) { cur_byte = buf[stream_ptr++]; u_pred += u_table[(cur_byte & 0xF0) >> 4]; u_plane[u_ptr++] = u_pred; y_pred += y_table[cur_byte & 0x0F]; y_plane[y_ptr++] = y_pred; cur_byte = buf[stream_ptr++]; v_pred += v_table[(cur_byte & 0xF0) >> 4]; v_plane[v_ptr++] = v_pred; y_pred += y_table[cur_byte & 0x0F]; y_plane[y_ptr++] = y_pred; cur_byte = buf[stream_ptr++]; y_pred += y_table[cur_byte & 0x0F]; y_plane[y_ptr++] = y_pred; y_pred += y_table[(cur_byte & 0xF0) >> 4]; y_plane[y_ptr++] = y_pred; } } *data_size=sizeof(AVFrame); *(AVFrame*)data= s->frame; return buf_size; } static av_cold int cyuv_decode_end(AVCodecContext *avctx) { CyuvDecodeContext *s = avctx->priv_data; if (s->frame.data[0]) avctx->release_buffer(avctx, &s->frame); return 0; } #if CONFIG_AURA_DECODER AVCodec aura_decoder = { "aura", AVMEDIA_TYPE_VIDEO, CODEC_ID_AURA, sizeof(CyuvDecodeContext), cyuv_decode_init, NULL, cyuv_decode_end, cyuv_decode_frame, CODEC_CAP_DR1, NULL, .long_name = NULL_IF_CONFIG_SMALL("Auravision AURA"), }; #endif #if CONFIG_CYUV_DECODER AVCodec cyuv_decoder = { "cyuv", AVMEDIA_TYPE_VIDEO, CODEC_ID_CYUV, sizeof(CyuvDecodeContext), cyuv_decode_init, NULL, cyuv_decode_end, cyuv_decode_frame, CODEC_CAP_DR1, NULL, .long_name = NULL_IF_CONFIG_SMALL("Creative YUV (CYUV)"), }; #endif
123linslouis-android-video-cutter
jni/libavcodec/cyuv.c
C
asf20
6,121
/* * Duck TrueMotion 1.0 Decoder * Copyright (C) 2003 Alex Beregszaszi & Mike Melanson * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * Duck TrueMotion v1 Video Decoder by * Alex Beregszaszi and * Mike Melanson (melanson@pcisys.net) * * The TrueMotion v1 decoder presently only decodes 16-bit TM1 data and * outputs RGB555 (or RGB565) data. 24-bit TM1 data is not supported yet. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "avcodec.h" #include "dsputil.h" #include "truemotion1data.h" typedef struct TrueMotion1Context { AVCodecContext *avctx; AVFrame frame; const uint8_t *buf; int size; const uint8_t *mb_change_bits; int mb_change_bits_row_size; const uint8_t *index_stream; int index_stream_size; int flags; int x, y, w, h; uint32_t y_predictor_table[1024]; uint32_t c_predictor_table[1024]; uint32_t fat_y_predictor_table[1024]; uint32_t fat_c_predictor_table[1024]; int compression; int block_type; int block_width; int block_height; int16_t ydt[8]; int16_t cdt[8]; int16_t fat_ydt[8]; int16_t fat_cdt[8]; int last_deltaset, last_vectable; unsigned int *vert_pred; } TrueMotion1Context; #define FLAG_SPRITE 32 #define FLAG_KEYFRAME 16 #define FLAG_INTERFRAME 8 #define FLAG_INTERPOLATED 4 struct frame_header { uint8_t header_size; uint8_t compression; uint8_t deltaset; uint8_t vectable; uint16_t ysize; uint16_t xsize; uint16_t checksum; uint8_t version; uint8_t header_type; uint8_t flags; uint8_t control; uint16_t xoffset; uint16_t yoffset; uint16_t width; uint16_t height; }; #define ALGO_NOP 0 #define ALGO_RGB16V 1 #define ALGO_RGB16H 2 #define ALGO_RGB24H 3 /* these are the various block sizes that can occupy a 4x4 block */ #define BLOCK_2x2 0 #define BLOCK_2x4 1 #define BLOCK_4x2 2 #define BLOCK_4x4 3 typedef struct comp_types { int algorithm; int block_width; // vres int block_height; // hres int block_type; } comp_types; /* { valid for metatype }, algorithm, num of deltas, vert res, horiz res */ static const comp_types compression_types[17] = { { ALGO_NOP, 0, 0, 0 }, { ALGO_RGB16V, 4, 4, BLOCK_4x4 }, { ALGO_RGB16H, 4, 4, BLOCK_4x4 }, { ALGO_RGB16V, 4, 2, BLOCK_4x2 }, { ALGO_RGB16H, 4, 2, BLOCK_4x2 }, { ALGO_RGB16V, 2, 4, BLOCK_2x4 }, { ALGO_RGB16H, 2, 4, BLOCK_2x4 }, { ALGO_RGB16V, 2, 2, BLOCK_2x2 }, { ALGO_RGB16H, 2, 2, BLOCK_2x2 }, { ALGO_NOP, 4, 4, BLOCK_4x4 }, { ALGO_RGB24H, 4, 4, BLOCK_4x4 }, { ALGO_NOP, 4, 2, BLOCK_4x2 }, { ALGO_RGB24H, 4, 2, BLOCK_4x2 }, { ALGO_NOP, 2, 4, BLOCK_2x4 }, { ALGO_RGB24H, 2, 4, BLOCK_2x4 }, { ALGO_NOP, 2, 2, BLOCK_2x2 }, { ALGO_RGB24H, 2, 2, BLOCK_2x2 } }; static void select_delta_tables(TrueMotion1Context *s, int delta_table_index) { int i; if (delta_table_index > 3) return; memcpy(s->ydt, ydts[delta_table_index], 8 * sizeof(int16_t)); memcpy(s->cdt, cdts[delta_table_index], 8 * sizeof(int16_t)); memcpy(s->fat_ydt, fat_ydts[delta_table_index], 8 * sizeof(int16_t)); memcpy(s->fat_cdt, fat_cdts[delta_table_index], 8 * sizeof(int16_t)); /* Y skinny deltas need to be halved for some reason; maybe the * skinny Y deltas should be modified */ for (i = 0; i < 8; i++) { /* drop the lsb before dividing by 2-- net effect: round down * when dividing a negative number (e.g., -3/2 = -2, not -1) */ s->ydt[i] &= 0xFFFE; s->ydt[i] /= 2; } } #if HAVE_BIGENDIAN static int make_ydt15_entry(int p2, int p1, int16_t *ydt) #else static int make_ydt15_entry(int p1, int p2, int16_t *ydt) #endif { int lo, hi; lo = ydt[p1]; lo += (lo << 5) + (lo << 10); hi = ydt[p2]; hi += (hi << 5) + (hi << 10); return (lo + (hi << 16)) << 1; } #if HAVE_BIGENDIAN static int make_cdt15_entry(int p2, int p1, int16_t *cdt) #else static int make_cdt15_entry(int p1, int p2, int16_t *cdt) #endif { int r, b, lo; b = cdt[p2]; r = cdt[p1] << 10; lo = b + r; return (lo + (lo << 16)) << 1; } #if HAVE_BIGENDIAN static int make_ydt16_entry(int p2, int p1, int16_t *ydt) #else static int make_ydt16_entry(int p1, int p2, int16_t *ydt) #endif { int lo, hi; lo = ydt[p1]; lo += (lo << 6) + (lo << 11); hi = ydt[p2]; hi += (hi << 6) + (hi << 11); return (lo + (hi << 16)) << 1; } #if HAVE_BIGENDIAN static int make_cdt16_entry(int p2, int p1, int16_t *cdt) #else static int make_cdt16_entry(int p1, int p2, int16_t *cdt) #endif { int r, b, lo; b = cdt[p2]; r = cdt[p1] << 11; lo = b + r; return (lo + (lo << 16)) << 1; } #if HAVE_BIGENDIAN static int make_ydt24_entry(int p2, int p1, int16_t *ydt) #else static int make_ydt24_entry(int p1, int p2, int16_t *ydt) #endif { int lo, hi; lo = ydt[p1]; hi = ydt[p2]; return (lo + (hi << 8) + (hi << 16)) << 1; } #if HAVE_BIGENDIAN static int make_cdt24_entry(int p2, int p1, int16_t *cdt) #else static int make_cdt24_entry(int p1, int p2, int16_t *cdt) #endif { int r, b; b = cdt[p2]; r = cdt[p1]<<16; return (b+r) << 1; } static void gen_vector_table15(TrueMotion1Context *s, const uint8_t *sel_vector_table) { int len, i, j; unsigned char delta_pair; for (i = 0; i < 1024; i += 4) { len = *sel_vector_table++ / 2; for (j = 0; j < len; j++) { delta_pair = *sel_vector_table++; s->y_predictor_table[i+j] = 0xfffffffe & make_ydt15_entry(delta_pair >> 4, delta_pair & 0xf, s->ydt); s->c_predictor_table[i+j] = 0xfffffffe & make_cdt15_entry(delta_pair >> 4, delta_pair & 0xf, s->cdt); } s->y_predictor_table[i+(j-1)] |= 1; s->c_predictor_table[i+(j-1)] |= 1; } } static void gen_vector_table16(TrueMotion1Context *s, const uint8_t *sel_vector_table) { int len, i, j; unsigned char delta_pair; for (i = 0; i < 1024; i += 4) { len = *sel_vector_table++ / 2; for (j = 0; j < len; j++) { delta_pair = *sel_vector_table++; s->y_predictor_table[i+j] = 0xfffffffe & make_ydt16_entry(delta_pair >> 4, delta_pair & 0xf, s->ydt); s->c_predictor_table[i+j] = 0xfffffffe & make_cdt16_entry(delta_pair >> 4, delta_pair & 0xf, s->cdt); } s->y_predictor_table[i+(j-1)] |= 1; s->c_predictor_table[i+(j-1)] |= 1; } } static void gen_vector_table24(TrueMotion1Context *s, const uint8_t *sel_vector_table) { int len, i, j; unsigned char delta_pair; for (i = 0; i < 1024; i += 4) { len = *sel_vector_table++ / 2; for (j = 0; j < len; j++) { delta_pair = *sel_vector_table++; s->y_predictor_table[i+j] = 0xfffffffe & make_ydt24_entry(delta_pair >> 4, delta_pair & 0xf, s->ydt); s->c_predictor_table[i+j] = 0xfffffffe & make_cdt24_entry(delta_pair >> 4, delta_pair & 0xf, s->cdt); s->fat_y_predictor_table[i+j] = 0xfffffffe & make_ydt24_entry(delta_pair >> 4, delta_pair & 0xf, s->fat_ydt); s->fat_c_predictor_table[i+j] = 0xfffffffe & make_cdt24_entry(delta_pair >> 4, delta_pair & 0xf, s->fat_cdt); } s->y_predictor_table[i+(j-1)] |= 1; s->c_predictor_table[i+(j-1)] |= 1; s->fat_y_predictor_table[i+(j-1)] |= 1; s->fat_c_predictor_table[i+(j-1)] |= 1; } } /* Returns the number of bytes consumed from the bytestream. Returns -1 if * there was an error while decoding the header */ static int truemotion1_decode_header(TrueMotion1Context *s) { int i; struct frame_header header; uint8_t header_buffer[128]; /* logical maximum size of the header */ const uint8_t *sel_vector_table; /* There is 1 change bit per 4 pixels, so each change byte represents * 32 pixels; divide width by 4 to obtain the number of change bits and * then round up to the nearest byte. */ s->mb_change_bits_row_size = ((s->avctx->width >> 2) + 7) >> 3; header.header_size = ((s->buf[0] >> 5) | (s->buf[0] << 3)) & 0x7f; if (s->buf[0] < 0x10) { av_log(s->avctx, AV_LOG_ERROR, "invalid header size (%d)\n", s->buf[0]); return -1; } /* unscramble the header bytes with a XOR operation */ memset(header_buffer, 0, 128); for (i = 1; i < header.header_size; i++) header_buffer[i - 1] = s->buf[i] ^ s->buf[i + 1]; header.compression = header_buffer[0]; header.deltaset = header_buffer[1]; header.vectable = header_buffer[2]; header.ysize = AV_RL16(&header_buffer[3]); header.xsize = AV_RL16(&header_buffer[5]); header.checksum = AV_RL16(&header_buffer[7]); header.version = header_buffer[9]; header.header_type = header_buffer[10]; header.flags = header_buffer[11]; header.control = header_buffer[12]; /* Version 2 */ if (header.version >= 2) { if (header.header_type > 3) { av_log(s->avctx, AV_LOG_ERROR, "invalid header type (%d)\n", header.header_type); return -1; } else if ((header.header_type == 2) || (header.header_type == 3)) { s->flags = header.flags; if (!(s->flags & FLAG_INTERFRAME)) s->flags |= FLAG_KEYFRAME; } else s->flags = FLAG_KEYFRAME; } else /* Version 1 */ s->flags = FLAG_KEYFRAME; if (s->flags & FLAG_SPRITE) { av_log(s->avctx, AV_LOG_INFO, "SPRITE frame found, please report the sample to the developers\n"); /* FIXME header.width, height, xoffset and yoffset aren't initialized */ #if 0 s->w = header.width; s->h = header.height; s->x = header.xoffset; s->y = header.yoffset; #else return -1; #endif } else { s->w = header.xsize; s->h = header.ysize; if (header.header_type < 2) { if ((s->w < 213) && (s->h >= 176)) { s->flags |= FLAG_INTERPOLATED; av_log(s->avctx, AV_LOG_INFO, "INTERPOLATION selected, please report the sample to the developers\n"); } } } if (header.compression >= 17) { av_log(s->avctx, AV_LOG_ERROR, "invalid compression type (%d)\n", header.compression); return -1; } if ((header.deltaset != s->last_deltaset) || (header.vectable != s->last_vectable)) select_delta_tables(s, header.deltaset); if ((header.compression & 1) && header.header_type) sel_vector_table = pc_tbl2; else { if (header.vectable < 4) sel_vector_table = tables[header.vectable - 1]; else { av_log(s->avctx, AV_LOG_ERROR, "invalid vector table id (%d)\n", header.vectable); return -1; } } // FIXME: where to place this ?!?! if (compression_types[header.compression].algorithm == ALGO_RGB24H) s->avctx->pix_fmt = PIX_FMT_RGB32; else s->avctx->pix_fmt = PIX_FMT_RGB555; // RGB565 is supported as well if ((header.deltaset != s->last_deltaset) || (header.vectable != s->last_vectable)) { if (compression_types[header.compression].algorithm == ALGO_RGB24H) gen_vector_table24(s, sel_vector_table); else if (s->avctx->pix_fmt == PIX_FMT_RGB555) gen_vector_table15(s, sel_vector_table); else gen_vector_table16(s, sel_vector_table); } /* set up pointers to the other key data chunks */ s->mb_change_bits = s->buf + header.header_size; if (s->flags & FLAG_KEYFRAME) { /* no change bits specified for a keyframe; only index bytes */ s->index_stream = s->mb_change_bits; } else { /* one change bit per 4x4 block */ s->index_stream = s->mb_change_bits + (s->mb_change_bits_row_size * (s->avctx->height >> 2)); } s->index_stream_size = s->size - (s->index_stream - s->buf); s->last_deltaset = header.deltaset; s->last_vectable = header.vectable; s->compression = header.compression; s->block_width = compression_types[header.compression].block_width; s->block_height = compression_types[header.compression].block_height; s->block_type = compression_types[header.compression].block_type; if (s->avctx->debug & FF_DEBUG_PICT_INFO) av_log(s->avctx, AV_LOG_INFO, "tables: %d / %d c:%d %dx%d t:%d %s%s%s%s\n", s->last_deltaset, s->last_vectable, s->compression, s->block_width, s->block_height, s->block_type, s->flags & FLAG_KEYFRAME ? " KEY" : "", s->flags & FLAG_INTERFRAME ? " INTER" : "", s->flags & FLAG_SPRITE ? " SPRITE" : "", s->flags & FLAG_INTERPOLATED ? " INTERPOL" : ""); return header.header_size; } static av_cold int truemotion1_decode_init(AVCodecContext *avctx) { TrueMotion1Context *s = avctx->priv_data; s->avctx = avctx; // FIXME: it may change ? // if (avctx->bits_per_sample == 24) // avctx->pix_fmt = PIX_FMT_RGB24; // else // avctx->pix_fmt = PIX_FMT_RGB555; s->frame.data[0] = NULL; /* there is a vertical predictor for each pixel in a line; each vertical * predictor is 0 to start with */ s->vert_pred = (unsigned int *)av_malloc(s->avctx->width * sizeof(unsigned int)); return 0; } /* Block decoding order: dxi: Y-Y dxic: Y-C-Y dxic2: Y-C-Y-C hres,vres,i,i%vres (0 < i < 4) 2x2 0: 0 dxic2 2x2 1: 1 dxi 2x2 2: 0 dxic2 2x2 3: 1 dxi 2x4 0: 0 dxic2 2x4 1: 1 dxi 2x4 2: 2 dxi 2x4 3: 3 dxi 4x2 0: 0 dxic 4x2 1: 1 dxi 4x2 2: 0 dxic 4x2 3: 1 dxi 4x4 0: 0 dxic 4x4 1: 1 dxi 4x4 2: 2 dxi 4x4 3: 3 dxi */ #define GET_NEXT_INDEX() \ {\ if (index_stream_index >= s->index_stream_size) { \ av_log(s->avctx, AV_LOG_INFO, " help! truemotion1 decoder went out of bounds\n"); \ return; \ } \ index = s->index_stream[index_stream_index++] * 4; \ } #define APPLY_C_PREDICTOR() \ predictor_pair = s->c_predictor_table[index]; \ horiz_pred += (predictor_pair >> 1); \ if (predictor_pair & 1) { \ GET_NEXT_INDEX() \ if (!index) { \ GET_NEXT_INDEX() \ predictor_pair = s->c_predictor_table[index]; \ horiz_pred += ((predictor_pair >> 1) * 5); \ if (predictor_pair & 1) \ GET_NEXT_INDEX() \ else \ index++; \ } \ } else \ index++; #define APPLY_C_PREDICTOR_24() \ predictor_pair = s->c_predictor_table[index]; \ horiz_pred += (predictor_pair >> 1); \ if (predictor_pair & 1) { \ GET_NEXT_INDEX() \ if (!index) { \ GET_NEXT_INDEX() \ predictor_pair = s->fat_c_predictor_table[index]; \ horiz_pred += (predictor_pair >> 1); \ if (predictor_pair & 1) \ GET_NEXT_INDEX() \ else \ index++; \ } \ } else \ index++; #define APPLY_Y_PREDICTOR() \ predictor_pair = s->y_predictor_table[index]; \ horiz_pred += (predictor_pair >> 1); \ if (predictor_pair & 1) { \ GET_NEXT_INDEX() \ if (!index) { \ GET_NEXT_INDEX() \ predictor_pair = s->y_predictor_table[index]; \ horiz_pred += ((predictor_pair >> 1) * 5); \ if (predictor_pair & 1) \ GET_NEXT_INDEX() \ else \ index++; \ } \ } else \ index++; #define APPLY_Y_PREDICTOR_24() \ predictor_pair = s->y_predictor_table[index]; \ horiz_pred += (predictor_pair >> 1); \ if (predictor_pair & 1) { \ GET_NEXT_INDEX() \ if (!index) { \ GET_NEXT_INDEX() \ predictor_pair = s->fat_y_predictor_table[index]; \ horiz_pred += (predictor_pair >> 1); \ if (predictor_pair & 1) \ GET_NEXT_INDEX() \ else \ index++; \ } \ } else \ index++; #define OUTPUT_PIXEL_PAIR() \ *current_pixel_pair = *vert_pred + horiz_pred; \ *vert_pred++ = *current_pixel_pair++; static void truemotion1_decode_16bit(TrueMotion1Context *s) { int y; int pixels_left; /* remaining pixels on this line */ unsigned int predictor_pair; unsigned int horiz_pred; unsigned int *vert_pred; unsigned int *current_pixel_pair; unsigned char *current_line = s->frame.data[0]; int keyframe = s->flags & FLAG_KEYFRAME; /* these variables are for managing the stream of macroblock change bits */ const unsigned char *mb_change_bits = s->mb_change_bits; unsigned char mb_change_byte; unsigned char mb_change_byte_mask; int mb_change_index; /* these variables are for managing the main index stream */ int index_stream_index = 0; /* yes, the index into the index stream */ int index; /* clean out the line buffer */ memset(s->vert_pred, 0, s->avctx->width * sizeof(unsigned int)); GET_NEXT_INDEX(); for (y = 0; y < s->avctx->height; y++) { /* re-init variables for the next line iteration */ horiz_pred = 0; current_pixel_pair = (unsigned int *)current_line; vert_pred = s->vert_pred; mb_change_index = 0; mb_change_byte = mb_change_bits[mb_change_index++]; mb_change_byte_mask = 0x01; pixels_left = s->avctx->width; while (pixels_left > 0) { if (keyframe || ((mb_change_byte & mb_change_byte_mask) == 0)) { switch (y & 3) { case 0: /* if macroblock width is 2, apply C-Y-C-Y; else * apply C-Y-Y */ if (s->block_width == 2) { APPLY_C_PREDICTOR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); APPLY_C_PREDICTOR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); } else { APPLY_C_PREDICTOR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); } break; case 1: case 3: /* always apply 2 Y predictors on these iterations */ APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); break; case 2: /* this iteration might be C-Y-C-Y, Y-Y, or C-Y-Y * depending on the macroblock type */ if (s->block_type == BLOCK_2x2) { APPLY_C_PREDICTOR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); APPLY_C_PREDICTOR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); } else if (s->block_type == BLOCK_4x2) { APPLY_C_PREDICTOR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); } else { APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); } break; } } else { /* skip (copy) four pixels, but reassign the horizontal * predictor */ *vert_pred++ = *current_pixel_pair++; horiz_pred = *current_pixel_pair - *vert_pred; *vert_pred++ = *current_pixel_pair++; } if (!keyframe) { mb_change_byte_mask <<= 1; /* next byte */ if (!mb_change_byte_mask) { mb_change_byte = mb_change_bits[mb_change_index++]; mb_change_byte_mask = 0x01; } } pixels_left -= 4; } /* next change row */ if (((y + 1) & 3) == 0) mb_change_bits += s->mb_change_bits_row_size; current_line += s->frame.linesize[0]; } } static void truemotion1_decode_24bit(TrueMotion1Context *s) { int y; int pixels_left; /* remaining pixels on this line */ unsigned int predictor_pair; unsigned int horiz_pred; unsigned int *vert_pred; unsigned int *current_pixel_pair; unsigned char *current_line = s->frame.data[0]; int keyframe = s->flags & FLAG_KEYFRAME; /* these variables are for managing the stream of macroblock change bits */ const unsigned char *mb_change_bits = s->mb_change_bits; unsigned char mb_change_byte; unsigned char mb_change_byte_mask; int mb_change_index; /* these variables are for managing the main index stream */ int index_stream_index = 0; /* yes, the index into the index stream */ int index; /* clean out the line buffer */ memset(s->vert_pred, 0, s->avctx->width * sizeof(unsigned int)); GET_NEXT_INDEX(); for (y = 0; y < s->avctx->height; y++) { /* re-init variables for the next line iteration */ horiz_pred = 0; current_pixel_pair = (unsigned int *)current_line; vert_pred = s->vert_pred; mb_change_index = 0; mb_change_byte = mb_change_bits[mb_change_index++]; mb_change_byte_mask = 0x01; pixels_left = s->avctx->width; while (pixels_left > 0) { if (keyframe || ((mb_change_byte & mb_change_byte_mask) == 0)) { switch (y & 3) { case 0: /* if macroblock width is 2, apply C-Y-C-Y; else * apply C-Y-Y */ if (s->block_width == 2) { APPLY_C_PREDICTOR_24(); APPLY_Y_PREDICTOR_24(); OUTPUT_PIXEL_PAIR(); APPLY_C_PREDICTOR_24(); APPLY_Y_PREDICTOR_24(); OUTPUT_PIXEL_PAIR(); } else { APPLY_C_PREDICTOR_24(); APPLY_Y_PREDICTOR_24(); OUTPUT_PIXEL_PAIR(); APPLY_Y_PREDICTOR_24(); OUTPUT_PIXEL_PAIR(); } break; case 1: case 3: /* always apply 2 Y predictors on these iterations */ APPLY_Y_PREDICTOR_24(); OUTPUT_PIXEL_PAIR(); APPLY_Y_PREDICTOR_24(); OUTPUT_PIXEL_PAIR(); break; case 2: /* this iteration might be C-Y-C-Y, Y-Y, or C-Y-Y * depending on the macroblock type */ if (s->block_type == BLOCK_2x2) { APPLY_C_PREDICTOR_24(); APPLY_Y_PREDICTOR_24(); OUTPUT_PIXEL_PAIR(); APPLY_C_PREDICTOR_24(); APPLY_Y_PREDICTOR_24(); OUTPUT_PIXEL_PAIR(); } else if (s->block_type == BLOCK_4x2) { APPLY_C_PREDICTOR_24(); APPLY_Y_PREDICTOR_24(); OUTPUT_PIXEL_PAIR(); APPLY_Y_PREDICTOR_24(); OUTPUT_PIXEL_PAIR(); } else { APPLY_Y_PREDICTOR_24(); OUTPUT_PIXEL_PAIR(); APPLY_Y_PREDICTOR_24(); OUTPUT_PIXEL_PAIR(); } break; } } else { /* skip (copy) four pixels, but reassign the horizontal * predictor */ *vert_pred++ = *current_pixel_pair++; horiz_pred = *current_pixel_pair - *vert_pred; *vert_pred++ = *current_pixel_pair++; } if (!keyframe) { mb_change_byte_mask <<= 1; /* next byte */ if (!mb_change_byte_mask) { mb_change_byte = mb_change_bits[mb_change_index++]; mb_change_byte_mask = 0x01; } } pixels_left -= 4; } /* next change row */ if (((y + 1) & 3) == 0) mb_change_bits += s->mb_change_bits_row_size; current_line += s->frame.linesize[0]; } } static int truemotion1_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; TrueMotion1Context *s = avctx->priv_data; s->buf = buf; s->size = buf_size; if (truemotion1_decode_header(s) == -1) return -1; s->frame.reference = 1; s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; if (avctx->reget_buffer(avctx, &s->frame) < 0) { av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } if (compression_types[s->compression].algorithm == ALGO_RGB24H) { truemotion1_decode_24bit(s); } else if (compression_types[s->compression].algorithm != ALGO_NOP) { truemotion1_decode_16bit(s); } *data_size = sizeof(AVFrame); *(AVFrame*)data = s->frame; /* report that the buffer was completely consumed */ return buf_size; } static av_cold int truemotion1_decode_end(AVCodecContext *avctx) { TrueMotion1Context *s = avctx->priv_data; if (s->frame.data[0]) avctx->release_buffer(avctx, &s->frame); av_free(s->vert_pred); return 0; } AVCodec truemotion1_decoder = { "truemotion1", AVMEDIA_TYPE_VIDEO, CODEC_ID_TRUEMOTION1, sizeof(TrueMotion1Context), truemotion1_decode_init, NULL, truemotion1_decode_end, truemotion1_decode_frame, CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Duck TrueMotion 1.0"), };
123linslouis-android-video-cutter
jni/libavcodec/truemotion1.c
C
asf20
27,513
/* * Copyright (C) 2004 Michael Niedermayer <michaelni@gmx.at> * Copyright (C) 2006 Robert Edele <yartrebo@earthlink.net> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AVCODEC_SNOW_H #define AVCODEC_SNOW_H #include "dsputil.h" #include "dwt.h" #define MID_STATE 128 #define MAX_PLANES 4 #define QSHIFT 5 #define QROOT (1<<QSHIFT) #define LOSSLESS_QLOG -128 #define FRAC_BITS 4 #define MAX_REF_FRAMES 8 #define LOG2_OBMC_MAX 8 #define OBMC_MAX (1<<(LOG2_OBMC_MAX)) /* C bits used by mmx/sse2/altivec */ static av_always_inline void snow_interleave_line_header(int * i, int width, IDWTELEM * low, IDWTELEM * high){ (*i) = (width) - 2; if (width & 1){ low[(*i)+1] = low[((*i)+1)>>1]; (*i)--; } } static av_always_inline void snow_interleave_line_footer(int * i, IDWTELEM * low, IDWTELEM * high){ for (; (*i)>=0; (*i)-=2){ low[(*i)+1] = high[(*i)>>1]; low[*i] = low[(*i)>>1]; } } static av_always_inline void snow_horizontal_compose_lift_lead_out(int i, IDWTELEM * dst, IDWTELEM * src, IDWTELEM * ref, int width, int w, int lift_high, int mul, int add, int shift){ for(; i<w; i++){ dst[i] = src[i] - ((mul * (ref[i] + ref[i + 1]) + add) >> shift); } if((width^lift_high)&1){ dst[w] = src[w] - ((mul * 2 * ref[w] + add) >> shift); } } static av_always_inline void snow_horizontal_compose_liftS_lead_out(int i, IDWTELEM * dst, IDWTELEM * src, IDWTELEM * ref, int width, int w){ for(; i<w; i++){ dst[i] = src[i] + ((ref[i] + ref[(i+1)]+W_BO + 4 * src[i]) >> W_BS); } if(width&1){ dst[w] = src[w] + ((2 * ref[w] + W_BO + 4 * src[w]) >> W_BS); } } #endif /* AVCODEC_SNOW_H */
123linslouis-android-video-cutter
jni/libavcodec/snow.h
C
asf20
2,448
/* * Copyright (C) 2004 Michael Niedermayer <michaelni@gmx.at> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "libavutil/intmath.h" #include "avcodec.h" #include "dsputil.h" #include "dwt.h" #include "snow.h" #include "rangecoder.h" #include "mathops.h" #include "mpegvideo.h" #include "h263.h" #undef NDEBUG #include <assert.h> static const int8_t quant3[256]={ 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 0, }; static const int8_t quant3b[256]={ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, }; static const int8_t quant3bA[256]={ 0, 0, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, }; static const int8_t quant5[256]={ 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-1,-1,-1, }; static const int8_t quant7[256]={ 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, -3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3, -3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3, -3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3, -3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3, -3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3, -3,-3,-3,-3,-3,-3,-3,-3,-3,-2,-2,-2,-2,-2,-2,-2, -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-1,-1, }; static const int8_t quant9[256]={ 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, -4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4, -4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4, -4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4, -4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4, -4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4, -4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4, -4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-3,-3,-3,-3, -3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-2,-2,-2,-2,-1,-1, }; static const int8_t quant11[256]={ 0, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5, -5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5, -5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5, -5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5, -5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5, -5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-4,-4, -4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4, -4,-4,-4,-4,-4,-3,-3,-3,-3,-3,-3,-3,-2,-2,-2,-1, }; static const int8_t quant13[256]={ 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, -6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6, -6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6, -6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6, -6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6, -6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-5, -5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5, -5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5, -4,-4,-4,-4,-4,-4,-4,-4,-4,-3,-3,-3,-3,-2,-2,-1, }; #if 0 //64*cubic static const uint8_t obmc32[1024]={ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 8, 8, 12, 12, 12, 16, 16, 16, 16, 16, 16, 16, 16, 12, 12, 12, 8, 8, 4, 4, 4, 4, 0, 0, 0, 0, 0, 4, 4, 8, 8, 12, 16, 16, 20, 24, 24, 28, 28, 32, 32, 32, 32, 28, 28, 24, 24, 20, 16, 16, 12, 8, 8, 4, 4, 0, 0, 0, 0, 4, 8, 8, 12, 16, 24, 28, 32, 36, 40, 44, 48, 48, 48, 48, 48, 48, 44, 40, 36, 32, 28, 24, 16, 12, 8, 8, 4, 0, 0, 0, 4, 4, 8, 12, 20, 24, 32, 40, 44, 52, 56, 60, 64, 68, 72, 72, 68, 64, 60, 56, 52, 44, 40, 32, 24, 20, 12, 8, 4, 4, 0, 0, 4, 4, 12, 16, 24, 32, 40, 52, 60, 68, 76, 80, 88, 88, 92, 92, 88, 88, 80, 76, 68, 60, 52, 40, 32, 24, 16, 12, 4, 4, 0, 0, 4, 8, 16, 24, 32, 40, 52, 64, 76, 84, 92,100,108,112,116,116,112,108,100, 92, 84, 76, 64, 52, 40, 32, 24, 16, 8, 4, 0, 0, 4, 8, 16, 28, 40, 52, 64, 76, 88,100,112,124,132,136,140,140,136,132,124,112,100, 88, 76, 64, 52, 40, 28, 16, 8, 4, 0, 0, 4, 12, 20, 32, 44, 60, 76, 88,104,120,132,144,152,160,164,164,160,152,144,132,120,104, 88, 76, 60, 44, 32, 20, 12, 4, 0, 0, 4, 12, 24, 36, 48, 68, 84,100,120,136,152,164,176,180,184,184,180,176,164,152,136,120,100, 84, 68, 48, 36, 24, 12, 4, 0, 0, 4, 12, 24, 40, 56, 76, 92,112,132,152,168,180,192,204,208,208,204,192,180,168,152,132,112, 92, 76, 56, 40, 24, 12, 4, 0, 0, 4, 16, 28, 44, 60, 80,100,124,144,164,180,196,208,220,224,224,220,208,196,180,164,144,124,100, 80, 60, 44, 28, 16, 4, 0, 0, 8, 16, 28, 48, 64, 88,108,132,152,176,192,208,224,232,240,240,232,224,208,192,176,152,132,108, 88, 64, 48, 28, 16, 8, 0, 0, 4, 16, 32, 48, 68, 88,112,136,160,180,204,220,232,244,248,248,244,232,220,204,180,160,136,112, 88, 68, 48, 32, 16, 4, 0, 1, 8, 16, 32, 48, 72, 92,116,140,164,184,208,224,240,248,255,255,248,240,224,208,184,164,140,116, 92, 72, 48, 32, 16, 8, 1, 1, 8, 16, 32, 48, 72, 92,116,140,164,184,208,224,240,248,255,255,248,240,224,208,184,164,140,116, 92, 72, 48, 32, 16, 8, 1, 0, 4, 16, 32, 48, 68, 88,112,136,160,180,204,220,232,244,248,248,244,232,220,204,180,160,136,112, 88, 68, 48, 32, 16, 4, 0, 0, 8, 16, 28, 48, 64, 88,108,132,152,176,192,208,224,232,240,240,232,224,208,192,176,152,132,108, 88, 64, 48, 28, 16, 8, 0, 0, 4, 16, 28, 44, 60, 80,100,124,144,164,180,196,208,220,224,224,220,208,196,180,164,144,124,100, 80, 60, 44, 28, 16, 4, 0, 0, 4, 12, 24, 40, 56, 76, 92,112,132,152,168,180,192,204,208,208,204,192,180,168,152,132,112, 92, 76, 56, 40, 24, 12, 4, 0, 0, 4, 12, 24, 36, 48, 68, 84,100,120,136,152,164,176,180,184,184,180,176,164,152,136,120,100, 84, 68, 48, 36, 24, 12, 4, 0, 0, 4, 12, 20, 32, 44, 60, 76, 88,104,120,132,144,152,160,164,164,160,152,144,132,120,104, 88, 76, 60, 44, 32, 20, 12, 4, 0, 0, 4, 8, 16, 28, 40, 52, 64, 76, 88,100,112,124,132,136,140,140,136,132,124,112,100, 88, 76, 64, 52, 40, 28, 16, 8, 4, 0, 0, 4, 8, 16, 24, 32, 40, 52, 64, 76, 84, 92,100,108,112,116,116,112,108,100, 92, 84, 76, 64, 52, 40, 32, 24, 16, 8, 4, 0, 0, 4, 4, 12, 16, 24, 32, 40, 52, 60, 68, 76, 80, 88, 88, 92, 92, 88, 88, 80, 76, 68, 60, 52, 40, 32, 24, 16, 12, 4, 4, 0, 0, 4, 4, 8, 12, 20, 24, 32, 40, 44, 52, 56, 60, 64, 68, 72, 72, 68, 64, 60, 56, 52, 44, 40, 32, 24, 20, 12, 8, 4, 4, 0, 0, 0, 4, 8, 8, 12, 16, 24, 28, 32, 36, 40, 44, 48, 48, 48, 48, 48, 48, 44, 40, 36, 32, 28, 24, 16, 12, 8, 8, 4, 0, 0, 0, 0, 4, 4, 8, 8, 12, 16, 16, 20, 24, 24, 28, 28, 32, 32, 32, 32, 28, 28, 24, 24, 20, 16, 16, 12, 8, 8, 4, 4, 0, 0, 0, 0, 0, 4, 4, 4, 4, 8, 8, 12, 12, 12, 16, 16, 16, 16, 16, 16, 16, 16, 12, 12, 12, 8, 8, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //error:0.000022 }; static const uint8_t obmc16[256]={ 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 4, 4, 8, 16, 20, 20, 24, 24, 20, 20, 16, 8, 4, 4, 0, 0, 4, 16, 24, 36, 44, 52, 60, 60, 52, 44, 36, 24, 16, 4, 0, 0, 8, 24, 44, 60, 80, 96,104,104, 96, 80, 60, 44, 24, 8, 0, 0, 16, 36, 60, 92,116,136,152,152,136,116, 92, 60, 36, 16, 0, 0, 20, 44, 80,116,152,180,196,196,180,152,116, 80, 44, 20, 0, 4, 20, 52, 96,136,180,212,228,228,212,180,136, 96, 52, 20, 4, 4, 24, 60,104,152,196,228,248,248,228,196,152,104, 60, 24, 4, 4, 24, 60,104,152,196,228,248,248,228,196,152,104, 60, 24, 4, 4, 20, 52, 96,136,180,212,228,228,212,180,136, 96, 52, 20, 4, 0, 20, 44, 80,116,152,180,196,196,180,152,116, 80, 44, 20, 0, 0, 16, 36, 60, 92,116,136,152,152,136,116, 92, 60, 36, 16, 0, 0, 8, 24, 44, 60, 80, 96,104,104, 96, 80, 60, 44, 24, 8, 0, 0, 4, 16, 24, 36, 44, 52, 60, 60, 52, 44, 36, 24, 16, 4, 0, 0, 4, 4, 8, 16, 20, 20, 24, 24, 20, 20, 16, 8, 4, 4, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, //error:0.000033 }; #elif 1 // 64*linear static const uint8_t obmc32[1024]={ 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 4, 4, 4, 8, 8, 8, 12, 12, 16, 16, 16, 20, 20, 20, 24, 24, 20, 20, 20, 16, 16, 16, 12, 12, 8, 8, 8, 4, 4, 4, 0, 0, 4, 8, 8, 12, 12, 16, 20, 20, 24, 28, 28, 32, 32, 36, 40, 40, 36, 32, 32, 28, 28, 24, 20, 20, 16, 12, 12, 8, 8, 4, 0, 0, 4, 8, 12, 16, 20, 24, 28, 28, 32, 36, 40, 44, 48, 52, 56, 56, 52, 48, 44, 40, 36, 32, 28, 28, 24, 20, 16, 12, 8, 4, 0, 4, 8, 12, 16, 20, 24, 28, 32, 40, 44, 48, 52, 56, 60, 64, 68, 68, 64, 60, 56, 52, 48, 44, 40, 32, 28, 24, 20, 16, 12, 8, 4, 4, 8, 12, 20, 24, 32, 36, 40, 48, 52, 56, 64, 68, 76, 80, 84, 84, 80, 76, 68, 64, 56, 52, 48, 40, 36, 32, 24, 20, 12, 8, 4, 4, 8, 16, 24, 28, 36, 44, 48, 56, 60, 68, 76, 80, 88, 96,100,100, 96, 88, 80, 76, 68, 60, 56, 48, 44, 36, 28, 24, 16, 8, 4, 4, 12, 20, 28, 32, 40, 48, 56, 64, 72, 80, 88, 92,100,108,116,116,108,100, 92, 88, 80, 72, 64, 56, 48, 40, 32, 28, 20, 12, 4, 4, 12, 20, 28, 40, 48, 56, 64, 72, 80, 88, 96,108,116,124,132,132,124,116,108, 96, 88, 80, 72, 64, 56, 48, 40, 28, 20, 12, 4, 4, 16, 24, 32, 44, 52, 60, 72, 80, 92,100,108,120,128,136,148,148,136,128,120,108,100, 92, 80, 72, 60, 52, 44, 32, 24, 16, 4, 4, 16, 28, 36, 48, 56, 68, 80, 88,100,112,120,132,140,152,164,164,152,140,132,120,112,100, 88, 80, 68, 56, 48, 36, 28, 16, 4, 4, 16, 28, 40, 52, 64, 76, 88, 96,108,120,132,144,156,168,180,180,168,156,144,132,120,108, 96, 88, 76, 64, 52, 40, 28, 16, 4, 8, 20, 32, 44, 56, 68, 80, 92,108,120,132,144,156,168,180,192,192,180,168,156,144,132,120,108, 92, 80, 68, 56, 44, 32, 20, 8, 8, 20, 32, 48, 60, 76, 88,100,116,128,140,156,168,184,196,208,208,196,184,168,156,140,128,116,100, 88, 76, 60, 48, 32, 20, 8, 8, 20, 36, 52, 64, 80, 96,108,124,136,152,168,180,196,212,224,224,212,196,180,168,152,136,124,108, 96, 80, 64, 52, 36, 20, 8, 8, 24, 40, 56, 68, 84,100,116,132,148,164,180,192,208,224,240,240,224,208,192,180,164,148,132,116,100, 84, 68, 56, 40, 24, 8, 8, 24, 40, 56, 68, 84,100,116,132,148,164,180,192,208,224,240,240,224,208,192,180,164,148,132,116,100, 84, 68, 56, 40, 24, 8, 8, 20, 36, 52, 64, 80, 96,108,124,136,152,168,180,196,212,224,224,212,196,180,168,152,136,124,108, 96, 80, 64, 52, 36, 20, 8, 8, 20, 32, 48, 60, 76, 88,100,116,128,140,156,168,184,196,208,208,196,184,168,156,140,128,116,100, 88, 76, 60, 48, 32, 20, 8, 8, 20, 32, 44, 56, 68, 80, 92,108,120,132,144,156,168,180,192,192,180,168,156,144,132,120,108, 92, 80, 68, 56, 44, 32, 20, 8, 4, 16, 28, 40, 52, 64, 76, 88, 96,108,120,132,144,156,168,180,180,168,156,144,132,120,108, 96, 88, 76, 64, 52, 40, 28, 16, 4, 4, 16, 28, 36, 48, 56, 68, 80, 88,100,112,120,132,140,152,164,164,152,140,132,120,112,100, 88, 80, 68, 56, 48, 36, 28, 16, 4, 4, 16, 24, 32, 44, 52, 60, 72, 80, 92,100,108,120,128,136,148,148,136,128,120,108,100, 92, 80, 72, 60, 52, 44, 32, 24, 16, 4, 4, 12, 20, 28, 40, 48, 56, 64, 72, 80, 88, 96,108,116,124,132,132,124,116,108, 96, 88, 80, 72, 64, 56, 48, 40, 28, 20, 12, 4, 4, 12, 20, 28, 32, 40, 48, 56, 64, 72, 80, 88, 92,100,108,116,116,108,100, 92, 88, 80, 72, 64, 56, 48, 40, 32, 28, 20, 12, 4, 4, 8, 16, 24, 28, 36, 44, 48, 56, 60, 68, 76, 80, 88, 96,100,100, 96, 88, 80, 76, 68, 60, 56, 48, 44, 36, 28, 24, 16, 8, 4, 4, 8, 12, 20, 24, 32, 36, 40, 48, 52, 56, 64, 68, 76, 80, 84, 84, 80, 76, 68, 64, 56, 52, 48, 40, 36, 32, 24, 20, 12, 8, 4, 4, 8, 12, 16, 20, 24, 28, 32, 40, 44, 48, 52, 56, 60, 64, 68, 68, 64, 60, 56, 52, 48, 44, 40, 32, 28, 24, 20, 16, 12, 8, 4, 0, 4, 8, 12, 16, 20, 24, 28, 28, 32, 36, 40, 44, 48, 52, 56, 56, 52, 48, 44, 40, 36, 32, 28, 28, 24, 20, 16, 12, 8, 4, 0, 0, 4, 8, 8, 12, 12, 16, 20, 20, 24, 28, 28, 32, 32, 36, 40, 40, 36, 32, 32, 28, 28, 24, 20, 20, 16, 12, 12, 8, 8, 4, 0, 0, 4, 4, 4, 8, 8, 8, 12, 12, 16, 16, 16, 20, 20, 20, 24, 24, 20, 20, 20, 16, 16, 16, 12, 12, 8, 8, 8, 4, 4, 4, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, //error:0.000020 }; static const uint8_t obmc16[256]={ 0, 4, 4, 8, 8, 12, 12, 16, 16, 12, 12, 8, 8, 4, 4, 0, 4, 8, 16, 20, 28, 32, 40, 44, 44, 40, 32, 28, 20, 16, 8, 4, 4, 16, 24, 36, 44, 56, 64, 76, 76, 64, 56, 44, 36, 24, 16, 4, 8, 20, 36, 48, 64, 76, 92,104,104, 92, 76, 64, 48, 36, 20, 8, 8, 28, 44, 64, 80,100,116,136,136,116,100, 80, 64, 44, 28, 8, 12, 32, 56, 76,100,120,144,164,164,144,120,100, 76, 56, 32, 12, 12, 40, 64, 92,116,144,168,196,196,168,144,116, 92, 64, 40, 12, 16, 44, 76,104,136,164,196,224,224,196,164,136,104, 76, 44, 16, 16, 44, 76,104,136,164,196,224,224,196,164,136,104, 76, 44, 16, 12, 40, 64, 92,116,144,168,196,196,168,144,116, 92, 64, 40, 12, 12, 32, 56, 76,100,120,144,164,164,144,120,100, 76, 56, 32, 12, 8, 28, 44, 64, 80,100,116,136,136,116,100, 80, 64, 44, 28, 8, 8, 20, 36, 48, 64, 76, 92,104,104, 92, 76, 64, 48, 36, 20, 8, 4, 16, 24, 36, 44, 56, 64, 76, 76, 64, 56, 44, 36, 24, 16, 4, 4, 8, 16, 20, 28, 32, 40, 44, 44, 40, 32, 28, 20, 16, 8, 4, 0, 4, 4, 8, 8, 12, 12, 16, 16, 12, 12, 8, 8, 4, 4, 0, //error:0.000015 }; #else //64*cos static const uint8_t obmc32[1024]={ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 8, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 8, 8, 12, 12, 12, 12, 16, 16, 16, 16, 16, 16, 12, 12, 12, 12, 8, 8, 4, 4, 4, 4, 0, 0, 0, 0, 0, 4, 4, 4, 8, 8, 12, 16, 20, 20, 24, 28, 28, 28, 28, 28, 28, 28, 28, 24, 20, 20, 16, 12, 8, 8, 4, 4, 4, 0, 0, 0, 0, 4, 4, 8, 12, 16, 20, 24, 28, 36, 40, 44, 44, 48, 48, 48, 48, 44, 44, 40, 36, 28, 24, 20, 16, 12, 8, 4, 4, 0, 0, 0, 0, 4, 8, 12, 20, 24, 32, 36, 44, 48, 56, 60, 64, 68, 68, 68, 68, 64, 60, 56, 48, 44, 36, 32, 24, 20, 12, 8, 4, 0, 0, 0, 4, 4, 8, 16, 24, 32, 40, 48, 60, 68, 76, 80, 84, 88, 92, 92, 88, 84, 80, 76, 68, 60, 48, 40, 32, 24, 16, 8, 4, 4, 0, 0, 4, 8, 12, 20, 32, 40, 52, 64, 76, 84, 96,104,108,112,116,116,112,108,104, 96, 84, 76, 64, 52, 40, 32, 20, 12, 8, 4, 0, 0, 4, 8, 16, 24, 36, 48, 64, 76, 92,104,116,124,132,136,140,140,136,132,124,116,104, 92, 76, 64, 48, 36, 24, 16, 8, 4, 0, 0, 4, 12, 20, 28, 44, 60, 76, 92,104,120,136,148,156,160,164,164,160,156,148,136,120,104, 92, 76, 60, 44, 28, 20, 12, 4, 0, 0, 4, 12, 20, 36, 48, 68, 84,104,120,140,152,168,176,184,188,188,184,176,168,152,140,120,104, 84, 68, 48, 36, 20, 12, 4, 0, 0, 4, 12, 24, 36, 56, 76, 96,116,136,152,172,184,196,204,208,208,204,196,184,172,152,136,116, 96, 76, 56, 36, 24, 12, 4, 0, 0, 4, 12, 24, 44, 60, 80,104,124,148,168,184,200,212,224,228,228,224,212,200,184,168,148,124,104, 80, 60, 44, 24, 12, 4, 0, 0, 4, 12, 28, 44, 64, 84,108,132,156,176,196,212,228,236,240,240,236,228,212,196,176,156,132,108, 84, 64, 44, 28, 12, 4, 0, 0, 4, 16, 28, 48, 68, 88,112,136,160,184,204,224,236,244,252,252,244,236,224,204,184,160,136,112, 88, 68, 48, 28, 16, 4, 0, 1, 4, 16, 28, 48, 68, 92,116,140,164,188,208,228,240,252,255,255,252,240,228,208,188,164,140,116, 92, 68, 48, 28, 16, 4, 1, 1, 4, 16, 28, 48, 68, 92,116,140,164,188,208,228,240,252,255,255,252,240,228,208,188,164,140,116, 92, 68, 48, 28, 16, 4, 1, 0, 4, 16, 28, 48, 68, 88,112,136,160,184,204,224,236,244,252,252,244,236,224,204,184,160,136,112, 88, 68, 48, 28, 16, 4, 0, 0, 4, 12, 28, 44, 64, 84,108,132,156,176,196,212,228,236,240,240,236,228,212,196,176,156,132,108, 84, 64, 44, 28, 12, 4, 0, 0, 4, 12, 24, 44, 60, 80,104,124,148,168,184,200,212,224,228,228,224,212,200,184,168,148,124,104, 80, 60, 44, 24, 12, 4, 0, 0, 4, 12, 24, 36, 56, 76, 96,116,136,152,172,184,196,204,208,208,204,196,184,172,152,136,116, 96, 76, 56, 36, 24, 12, 4, 0, 0, 4, 12, 20, 36, 48, 68, 84,104,120,140,152,168,176,184,188,188,184,176,168,152,140,120,104, 84, 68, 48, 36, 20, 12, 4, 0, 0, 4, 12, 20, 28, 44, 60, 76, 92,104,120,136,148,156,160,164,164,160,156,148,136,120,104, 92, 76, 60, 44, 28, 20, 12, 4, 0, 0, 4, 8, 16, 24, 36, 48, 64, 76, 92,104,116,124,132,136,140,140,136,132,124,116,104, 92, 76, 64, 48, 36, 24, 16, 8, 4, 0, 0, 4, 8, 12, 20, 32, 40, 52, 64, 76, 84, 96,104,108,112,116,116,112,108,104, 96, 84, 76, 64, 52, 40, 32, 20, 12, 8, 4, 0, 0, 4, 4, 8, 16, 24, 32, 40, 48, 60, 68, 76, 80, 84, 88, 92, 92, 88, 84, 80, 76, 68, 60, 48, 40, 32, 24, 16, 8, 4, 4, 0, 0, 0, 4, 8, 12, 20, 24, 32, 36, 44, 48, 56, 60, 64, 68, 68, 68, 68, 64, 60, 56, 48, 44, 36, 32, 24, 20, 12, 8, 4, 0, 0, 0, 0, 4, 4, 8, 12, 16, 20, 24, 28, 36, 40, 44, 44, 48, 48, 48, 48, 44, 44, 40, 36, 28, 24, 20, 16, 12, 8, 4, 4, 0, 0, 0, 0, 4, 4, 4, 8, 8, 12, 16, 20, 20, 24, 28, 28, 28, 28, 28, 28, 28, 28, 24, 20, 20, 16, 12, 8, 8, 4, 4, 4, 0, 0, 0, 0, 0, 4, 4, 4, 4, 8, 8, 12, 12, 12, 12, 16, 16, 16, 16, 16, 16, 12, 12, 12, 12, 8, 8, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 8, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //error:0.000022 }; static const uint8_t obmc16[256]={ 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 4, 8, 12, 16, 20, 20, 20, 20, 16, 12, 8, 4, 0, 0, 0, 4, 12, 24, 32, 44, 52, 56, 56, 52, 44, 32, 24, 12, 4, 0, 0, 8, 24, 40, 60, 80, 96,104,104, 96, 80, 60, 40, 24, 8, 0, 0, 12, 32, 64, 92,120,140,152,152,140,120, 92, 64, 32, 12, 0, 4, 16, 44, 80,120,156,184,196,196,184,156,120, 80, 44, 16, 4, 4, 20, 52, 96,140,184,216,232,232,216,184,140, 96, 52, 20, 4, 0, 20, 56,104,152,196,232,252,252,232,196,152,104, 56, 20, 0, 0, 20, 56,104,152,196,232,252,252,232,196,152,104, 56, 20, 0, 4, 20, 52, 96,140,184,216,232,232,216,184,140, 96, 52, 20, 4, 4, 16, 44, 80,120,156,184,196,196,184,156,120, 80, 44, 16, 4, 0, 12, 32, 64, 92,120,140,152,152,140,120, 92, 64, 32, 12, 0, 0, 8, 24, 40, 60, 80, 96,104,104, 96, 80, 60, 40, 24, 8, 0, 0, 4, 12, 24, 32, 44, 52, 56, 56, 52, 44, 32, 24, 12, 4, 0, 0, 0, 4, 8, 12, 16, 20, 20, 20, 20, 16, 12, 8, 4, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, //error:0.000022 }; #endif /* 0 */ //linear *64 static const uint8_t obmc8[64]={ 4, 12, 20, 28, 28, 20, 12, 4, 12, 36, 60, 84, 84, 60, 36, 12, 20, 60,100,140,140,100, 60, 20, 28, 84,140,196,196,140, 84, 28, 28, 84,140,196,196,140, 84, 28, 20, 60,100,140,140,100, 60, 20, 12, 36, 60, 84, 84, 60, 36, 12, 4, 12, 20, 28, 28, 20, 12, 4, //error:0.000000 }; //linear *64 static const uint8_t obmc4[16]={ 16, 48, 48, 16, 48,144,144, 48, 48,144,144, 48, 16, 48, 48, 16, //error:0.000000 }; static const uint8_t * const obmc_tab[4]={ obmc32, obmc16, obmc8, obmc4 }; static int scale_mv_ref[MAX_REF_FRAMES][MAX_REF_FRAMES]; typedef struct BlockNode{ int16_t mx; int16_t my; uint8_t ref; uint8_t color[3]; uint8_t type; //#define TYPE_SPLIT 1 #define BLOCK_INTRA 1 #define BLOCK_OPT 2 //#define TYPE_NOCOLOR 4 uint8_t level; //FIXME merge into type? }BlockNode; static const BlockNode null_block= { //FIXME add border maybe .color= {128,128,128}, .mx= 0, .my= 0, .ref= 0, .type= 0, .level= 0, }; #define LOG2_MB_SIZE 4 #define MB_SIZE (1<<LOG2_MB_SIZE) #define ENCODER_EXTRA_BITS 4 #define HTAPS_MAX 8 typedef struct x_and_coeff{ int16_t x; uint16_t coeff; } x_and_coeff; typedef struct SubBand{ int level; int stride; int width; int height; int qlog; ///< log(qscale)/log[2^(1/6)] DWTELEM *buf; IDWTELEM *ibuf; int buf_x_offset; int buf_y_offset; int stride_line; ///< Stride measured in lines, not pixels. x_and_coeff * x_coeff; struct SubBand *parent; uint8_t state[/*7*2*/ 7 + 512][32]; }SubBand; typedef struct Plane{ int width; int height; SubBand band[MAX_DECOMPOSITIONS][4]; int htaps; int8_t hcoeff[HTAPS_MAX/2]; int diag_mc; int fast_mc; int last_htaps; int8_t last_hcoeff[HTAPS_MAX/2]; int last_diag_mc; }Plane; typedef struct SnowContext{ AVCodecContext *avctx; RangeCoder c; DSPContext dsp; DWTContext dwt; AVFrame new_picture; AVFrame input_picture; ///< new_picture with the internal linesizes AVFrame current_picture; AVFrame last_picture[MAX_REF_FRAMES]; uint8_t *halfpel_plane[MAX_REF_FRAMES][4][4]; AVFrame mconly_picture; // uint8_t q_context[16]; uint8_t header_state[32]; uint8_t block_state[128 + 32*128]; int keyframe; int always_reset; int version; int spatial_decomposition_type; int last_spatial_decomposition_type; int temporal_decomposition_type; int spatial_decomposition_count; int last_spatial_decomposition_count; int temporal_decomposition_count; int max_ref_frames; int ref_frames; int16_t (*ref_mvs[MAX_REF_FRAMES])[2]; uint32_t *ref_scores[MAX_REF_FRAMES]; DWTELEM *spatial_dwt_buffer; IDWTELEM *spatial_idwt_buffer; int colorspace_type; int chroma_h_shift; int chroma_v_shift; int spatial_scalability; int qlog; int last_qlog; int lambda; int lambda2; int pass1_rc; int mv_scale; int last_mv_scale; int qbias; int last_qbias; #define QBIAS_SHIFT 3 int b_width; int b_height; int block_max_depth; int last_block_max_depth; Plane plane[MAX_PLANES]; BlockNode *block; #define ME_CACHE_SIZE 1024 int me_cache[ME_CACHE_SIZE]; int me_cache_generation; slice_buffer sb; MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to eventually make the motion estimation independent of MpegEncContext, so this will be removed then (FIXME/XXX) uint8_t *scratchbuf; }SnowContext; #ifdef __sgi // Avoid a name clash on SGI IRIX #undef qexp #endif #define QEXPSHIFT (7-FRAC_BITS+8) //FIXME try to change this to 0 static uint8_t qexp[QROOT]; static inline void put_symbol(RangeCoder *c, uint8_t *state, int v, int is_signed){ int i; if(v){ const int a= FFABS(v); const int e= av_log2(a); #if 1 const int el= FFMIN(e, 10); put_rac(c, state+0, 0); for(i=0; i<el; i++){ put_rac(c, state+1+i, 1); //1..10 } for(; i<e; i++){ put_rac(c, state+1+9, 1); //1..10 } put_rac(c, state+1+FFMIN(i,9), 0); for(i=e-1; i>=el; i--){ put_rac(c, state+22+9, (a>>i)&1); //22..31 } for(; i>=0; i--){ put_rac(c, state+22+i, (a>>i)&1); //22..31 } if(is_signed) put_rac(c, state+11 + el, v < 0); //11..21 #else put_rac(c, state+0, 0); if(e<=9){ for(i=0; i<e; i++){ put_rac(c, state+1+i, 1); //1..10 } put_rac(c, state+1+i, 0); for(i=e-1; i>=0; i--){ put_rac(c, state+22+i, (a>>i)&1); //22..31 } if(is_signed) put_rac(c, state+11 + e, v < 0); //11..21 }else{ for(i=0; i<e; i++){ put_rac(c, state+1+FFMIN(i,9), 1); //1..10 } put_rac(c, state+1+9, 0); for(i=e-1; i>=0; i--){ put_rac(c, state+22+FFMIN(i,9), (a>>i)&1); //22..31 } if(is_signed) put_rac(c, state+11 + 10, v < 0); //11..21 } #endif /* 1 */ }else{ put_rac(c, state+0, 1); } } static inline int get_symbol(RangeCoder *c, uint8_t *state, int is_signed){ if(get_rac(c, state+0)) return 0; else{ int i, e, a; e= 0; while(get_rac(c, state+1 + FFMIN(e,9))){ //1..10 e++; } a= 1; for(i=e-1; i>=0; i--){ a += a + get_rac(c, state+22 + FFMIN(i,9)); //22..31 } e= -(is_signed && get_rac(c, state+11 + FFMIN(e,10))); //11..21 return (a^e)-e; } } static inline void put_symbol2(RangeCoder *c, uint8_t *state, int v, int log2){ int i; int r= log2>=0 ? 1<<log2 : 1; assert(v>=0); assert(log2>=-4); while(v >= r){ put_rac(c, state+4+log2, 1); v -= r; log2++; if(log2>0) r+=r; } put_rac(c, state+4+log2, 0); for(i=log2-1; i>=0; i--){ put_rac(c, state+31-i, (v>>i)&1); } } static inline int get_symbol2(RangeCoder *c, uint8_t *state, int log2){ int i; int r= log2>=0 ? 1<<log2 : 1; int v=0; assert(log2>=-4); while(get_rac(c, state+4+log2)){ v+= r; log2++; if(log2>0) r+=r; } for(i=log2-1; i>=0; i--){ v+= get_rac(c, state+31-i)<<i; } return v; } static inline void unpack_coeffs(SnowContext *s, SubBand *b, SubBand * parent, int orientation){ const int w= b->width; const int h= b->height; int x,y; int run, runs; x_and_coeff *xc= b->x_coeff; x_and_coeff *prev_xc= NULL; x_and_coeff *prev2_xc= xc; x_and_coeff *parent_xc= parent ? parent->x_coeff : NULL; x_and_coeff *prev_parent_xc= parent_xc; runs= get_symbol2(&s->c, b->state[30], 0); if(runs-- > 0) run= get_symbol2(&s->c, b->state[1], 3); else run= INT_MAX; for(y=0; y<h; y++){ int v=0; int lt=0, t=0, rt=0; if(y && prev_xc->x == 0){ rt= prev_xc->coeff; } for(x=0; x<w; x++){ int p=0; const int l= v; lt= t; t= rt; if(y){ if(prev_xc->x <= x) prev_xc++; if(prev_xc->x == x + 1) rt= prev_xc->coeff; else rt=0; } if(parent_xc){ if(x>>1 > parent_xc->x){ parent_xc++; } if(x>>1 == parent_xc->x){ p= parent_xc->coeff; } } if(/*ll|*/l|lt|t|rt|p){ int context= av_log2(/*FFABS(ll) + */3*(l>>1) + (lt>>1) + (t&~1) + (rt>>1) + (p>>1)); v=get_rac(&s->c, &b->state[0][context]); if(v){ v= 2*(get_symbol2(&s->c, b->state[context + 2], context-4) + 1); v+=get_rac(&s->c, &b->state[0][16 + 1 + 3 + quant3bA[l&0xFF] + 3*quant3bA[t&0xFF]]); xc->x=x; (xc++)->coeff= v; } }else{ if(!run){ if(runs-- > 0) run= get_symbol2(&s->c, b->state[1], 3); else run= INT_MAX; v= 2*(get_symbol2(&s->c, b->state[0 + 2], 0-4) + 1); v+=get_rac(&s->c, &b->state[0][16 + 1 + 3]); xc->x=x; (xc++)->coeff= v; }else{ int max_run; run--; v=0; if(y) max_run= FFMIN(run, prev_xc->x - x - 2); else max_run= FFMIN(run, w-x-1); if(parent_xc) max_run= FFMIN(max_run, 2*parent_xc->x - x - 1); x+= max_run; run-= max_run; } } } (xc++)->x= w+1; //end marker prev_xc= prev2_xc; prev2_xc= xc; if(parent_xc){ if(y&1){ while(parent_xc->x != parent->width+1) parent_xc++; parent_xc++; prev_parent_xc= parent_xc; }else{ parent_xc= prev_parent_xc; } } } (xc++)->x= w+1; //end marker } static inline void decode_subband_slice_buffered(SnowContext *s, SubBand *b, slice_buffer * sb, int start_y, int h, int save_state[1]){ const int w= b->width; int y; const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16); int qmul= qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT); int qadd= (s->qbias*qmul)>>QBIAS_SHIFT; int new_index = 0; if(b->ibuf == s->spatial_idwt_buffer || s->qlog == LOSSLESS_QLOG){ qadd= 0; qmul= 1<<QEXPSHIFT; } /* If we are on the second or later slice, restore our index. */ if (start_y != 0) new_index = save_state[0]; for(y=start_y; y<h; y++){ int x = 0; int v; IDWTELEM * line = slice_buffer_get_line(sb, y * b->stride_line + b->buf_y_offset) + b->buf_x_offset; memset(line, 0, b->width*sizeof(IDWTELEM)); v = b->x_coeff[new_index].coeff; x = b->x_coeff[new_index++].x; while(x < w){ register int t= ( (v>>1)*qmul + qadd)>>QEXPSHIFT; register int u= -(v&1); line[x] = (t^u) - u; v = b->x_coeff[new_index].coeff; x = b->x_coeff[new_index++].x; } } /* Save our variables for the next slice. */ save_state[0] = new_index; return; } static void reset_contexts(SnowContext *s){ //FIXME better initial contexts int plane_index, level, orientation; for(plane_index=0; plane_index<3; plane_index++){ for(level=0; level<MAX_DECOMPOSITIONS; level++){ for(orientation=level ? 1:0; orientation<4; orientation++){ memset(s->plane[plane_index].band[level][orientation].state, MID_STATE, sizeof(s->plane[plane_index].band[level][orientation].state)); } } } memset(s->header_state, MID_STATE, sizeof(s->header_state)); memset(s->block_state, MID_STATE, sizeof(s->block_state)); } static int alloc_blocks(SnowContext *s){ int w= -((-s->avctx->width )>>LOG2_MB_SIZE); int h= -((-s->avctx->height)>>LOG2_MB_SIZE); s->b_width = w; s->b_height= h; av_free(s->block); s->block= av_mallocz(w * h * sizeof(BlockNode) << (s->block_max_depth*2)); return 0; } static inline void copy_rac_state(RangeCoder *d, RangeCoder *s){ uint8_t *bytestream= d->bytestream; uint8_t *bytestream_start= d->bytestream_start; *d= *s; d->bytestream= bytestream; d->bytestream_start= bytestream_start; } static inline void set_blocks(SnowContext *s, int level, int x, int y, int l, int cb, int cr, int mx, int my, int ref, int type){ const int w= s->b_width << s->block_max_depth; const int rem_depth= s->block_max_depth - level; const int index= (x + y*w) << rem_depth; const int block_w= 1<<rem_depth; BlockNode block; int i,j; block.color[0]= l; block.color[1]= cb; block.color[2]= cr; block.mx= mx; block.my= my; block.ref= ref; block.type= type; block.level= level; for(j=0; j<block_w; j++){ for(i=0; i<block_w; i++){ s->block[index + i + j*w]= block; } } } static inline void init_ref(MotionEstContext *c, uint8_t *src[3], uint8_t *ref[3], uint8_t *ref2[3], int x, int y, int ref_index){ const int offset[3]= { y*c-> stride + x, ((y*c->uvstride + x)>>1), ((y*c->uvstride + x)>>1), }; int i; for(i=0; i<3; i++){ c->src[0][i]= src [i]; c->ref[0][i]= ref [i] + offset[i]; } assert(!ref_index); } static inline void pred_mv(SnowContext *s, int *mx, int *my, int ref, const BlockNode *left, const BlockNode *top, const BlockNode *tr){ if(s->ref_frames == 1){ *mx = mid_pred(left->mx, top->mx, tr->mx); *my = mid_pred(left->my, top->my, tr->my); }else{ const int *scale = scale_mv_ref[ref]; *mx = mid_pred((left->mx * scale[left->ref] + 128) >>8, (top ->mx * scale[top ->ref] + 128) >>8, (tr ->mx * scale[tr ->ref] + 128) >>8); *my = mid_pred((left->my * scale[left->ref] + 128) >>8, (top ->my * scale[top ->ref] + 128) >>8, (tr ->my * scale[tr ->ref] + 128) >>8); } } static av_always_inline int same_block(BlockNode *a, BlockNode *b){ if((a->type&BLOCK_INTRA) && (b->type&BLOCK_INTRA)){ return !((a->color[0] - b->color[0]) | (a->color[1] - b->color[1]) | (a->color[2] - b->color[2])); }else{ return !((a->mx - b->mx) | (a->my - b->my) | (a->ref - b->ref) | ((a->type ^ b->type)&BLOCK_INTRA)); } } static void decode_q_branch(SnowContext *s, int level, int x, int y){ const int w= s->b_width << s->block_max_depth; const int rem_depth= s->block_max_depth - level; const int index= (x + y*w) << rem_depth; int trx= (x+1)<<rem_depth; const BlockNode *left = x ? &s->block[index-1] : &null_block; const BlockNode *top = y ? &s->block[index-w] : &null_block; const BlockNode *tl = y && x ? &s->block[index-w-1] : left; const BlockNode *tr = y && trx<w && ((x&1)==0 || level==0) ? &s->block[index-w+(1<<rem_depth)] : tl; //FIXME use lt int s_context= 2*left->level + 2*top->level + tl->level + tr->level; if(s->keyframe){ set_blocks(s, level, x, y, null_block.color[0], null_block.color[1], null_block.color[2], null_block.mx, null_block.my, null_block.ref, BLOCK_INTRA); return; } if(level==s->block_max_depth || get_rac(&s->c, &s->block_state[4 + s_context])){ int type, mx, my; int l = left->color[0]; int cb= left->color[1]; int cr= left->color[2]; int ref = 0; int ref_context= av_log2(2*left->ref) + av_log2(2*top->ref); int mx_context= av_log2(2*FFABS(left->mx - top->mx)) + 0*av_log2(2*FFABS(tr->mx - top->mx)); int my_context= av_log2(2*FFABS(left->my - top->my)) + 0*av_log2(2*FFABS(tr->my - top->my)); type= get_rac(&s->c, &s->block_state[1 + left->type + top->type]) ? BLOCK_INTRA : 0; if(type){ pred_mv(s, &mx, &my, 0, left, top, tr); l += get_symbol(&s->c, &s->block_state[32], 1); cb+= get_symbol(&s->c, &s->block_state[64], 1); cr+= get_symbol(&s->c, &s->block_state[96], 1); }else{ if(s->ref_frames > 1) ref= get_symbol(&s->c, &s->block_state[128 + 1024 + 32*ref_context], 0); pred_mv(s, &mx, &my, ref, left, top, tr); mx+= get_symbol(&s->c, &s->block_state[128 + 32*(mx_context + 16*!!ref)], 1); my+= get_symbol(&s->c, &s->block_state[128 + 32*(my_context + 16*!!ref)], 1); } set_blocks(s, level, x, y, l, cb, cr, mx, my, ref, type); }else{ decode_q_branch(s, level+1, 2*x+0, 2*y+0); decode_q_branch(s, level+1, 2*x+1, 2*y+0); decode_q_branch(s, level+1, 2*x+0, 2*y+1); decode_q_branch(s, level+1, 2*x+1, 2*y+1); } } static void decode_blocks(SnowContext *s){ int x, y; int w= s->b_width; int h= s->b_height; for(y=0; y<h; y++){ for(x=0; x<w; x++){ decode_q_branch(s, 0, x, y); } } } static void mc_block(Plane *p, uint8_t *dst, const uint8_t *src, uint8_t *tmp, int stride, int b_w, int b_h, int dx, int dy){ static const uint8_t weight[64]={ 8,7,6,5,4,3,2,1, 7,7,0,0,0,0,0,1, 6,0,6,0,0,0,2,0, 5,0,0,5,0,3,0,0, 4,0,0,0,4,0,0,0, 3,0,0,5,0,3,0,0, 2,0,6,0,0,0,2,0, 1,7,0,0,0,0,0,1, }; static const uint8_t brane[256]={ 0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x11,0x12,0x12,0x12,0x12,0x12,0x12,0x12, 0x04,0x05,0xcc,0xcc,0xcc,0xcc,0xcc,0x41,0x15,0x16,0xcc,0xcc,0xcc,0xcc,0xcc,0x52, 0x04,0xcc,0x05,0xcc,0xcc,0xcc,0x41,0xcc,0x15,0xcc,0x16,0xcc,0xcc,0xcc,0x52,0xcc, 0x04,0xcc,0xcc,0x05,0xcc,0x41,0xcc,0xcc,0x15,0xcc,0xcc,0x16,0xcc,0x52,0xcc,0xcc, 0x04,0xcc,0xcc,0xcc,0x41,0xcc,0xcc,0xcc,0x15,0xcc,0xcc,0xcc,0x16,0xcc,0xcc,0xcc, 0x04,0xcc,0xcc,0x41,0xcc,0x05,0xcc,0xcc,0x15,0xcc,0xcc,0x52,0xcc,0x16,0xcc,0xcc, 0x04,0xcc,0x41,0xcc,0xcc,0xcc,0x05,0xcc,0x15,0xcc,0x52,0xcc,0xcc,0xcc,0x16,0xcc, 0x04,0x41,0xcc,0xcc,0xcc,0xcc,0xcc,0x05,0x15,0x52,0xcc,0xcc,0xcc,0xcc,0xcc,0x16, 0x44,0x45,0x45,0x45,0x45,0x45,0x45,0x45,0x55,0x56,0x56,0x56,0x56,0x56,0x56,0x56, 0x48,0x49,0xcc,0xcc,0xcc,0xcc,0xcc,0x85,0x59,0x5A,0xcc,0xcc,0xcc,0xcc,0xcc,0x96, 0x48,0xcc,0x49,0xcc,0xcc,0xcc,0x85,0xcc,0x59,0xcc,0x5A,0xcc,0xcc,0xcc,0x96,0xcc, 0x48,0xcc,0xcc,0x49,0xcc,0x85,0xcc,0xcc,0x59,0xcc,0xcc,0x5A,0xcc,0x96,0xcc,0xcc, 0x48,0xcc,0xcc,0xcc,0x49,0xcc,0xcc,0xcc,0x59,0xcc,0xcc,0xcc,0x96,0xcc,0xcc,0xcc, 0x48,0xcc,0xcc,0x85,0xcc,0x49,0xcc,0xcc,0x59,0xcc,0xcc,0x96,0xcc,0x5A,0xcc,0xcc, 0x48,0xcc,0x85,0xcc,0xcc,0xcc,0x49,0xcc,0x59,0xcc,0x96,0xcc,0xcc,0xcc,0x5A,0xcc, 0x48,0x85,0xcc,0xcc,0xcc,0xcc,0xcc,0x49,0x59,0x96,0xcc,0xcc,0xcc,0xcc,0xcc,0x5A, }; static const uint8_t needs[16]={ 0,1,0,0, 2,4,2,0, 0,1,0,0, 15 }; int x, y, b, r, l; int16_t tmpIt [64*(32+HTAPS_MAX)]; uint8_t tmp2t[3][stride*(32+HTAPS_MAX)]; int16_t *tmpI= tmpIt; uint8_t *tmp2= tmp2t[0]; const uint8_t *hpel[11]; assert(dx<16 && dy<16); r= brane[dx + 16*dy]&15; l= brane[dx + 16*dy]>>4; b= needs[l] | needs[r]; if(p && !p->diag_mc) b= 15; if(b&5){ for(y=0; y < b_h+HTAPS_MAX-1; y++){ for(x=0; x < b_w; x++){ int a_1=src[x + HTAPS_MAX/2-4]; int a0= src[x + HTAPS_MAX/2-3]; int a1= src[x + HTAPS_MAX/2-2]; int a2= src[x + HTAPS_MAX/2-1]; int a3= src[x + HTAPS_MAX/2+0]; int a4= src[x + HTAPS_MAX/2+1]; int a5= src[x + HTAPS_MAX/2+2]; int a6= src[x + HTAPS_MAX/2+3]; int am=0; if(!p || p->fast_mc){ am= 20*(a2+a3) - 5*(a1+a4) + (a0+a5); tmpI[x]= am; am= (am+16)>>5; }else{ am= p->hcoeff[0]*(a2+a3) + p->hcoeff[1]*(a1+a4) + p->hcoeff[2]*(a0+a5) + p->hcoeff[3]*(a_1+a6); tmpI[x]= am; am= (am+32)>>6; } if(am&(~255)) am= ~(am>>31); tmp2[x]= am; } tmpI+= 64; tmp2+= stride; src += stride; } src -= stride*y; } src += HTAPS_MAX/2 - 1; tmp2= tmp2t[1]; if(b&2){ for(y=0; y < b_h; y++){ for(x=0; x < b_w+1; x++){ int a_1=src[x + (HTAPS_MAX/2-4)*stride]; int a0= src[x + (HTAPS_MAX/2-3)*stride]; int a1= src[x + (HTAPS_MAX/2-2)*stride]; int a2= src[x + (HTAPS_MAX/2-1)*stride]; int a3= src[x + (HTAPS_MAX/2+0)*stride]; int a4= src[x + (HTAPS_MAX/2+1)*stride]; int a5= src[x + (HTAPS_MAX/2+2)*stride]; int a6= src[x + (HTAPS_MAX/2+3)*stride]; int am=0; if(!p || p->fast_mc) am= (20*(a2+a3) - 5*(a1+a4) + (a0+a5) + 16)>>5; else am= (p->hcoeff[0]*(a2+a3) + p->hcoeff[1]*(a1+a4) + p->hcoeff[2]*(a0+a5) + p->hcoeff[3]*(a_1+a6) + 32)>>6; if(am&(~255)) am= ~(am>>31); tmp2[x]= am; } src += stride; tmp2+= stride; } src -= stride*y; } src += stride*(HTAPS_MAX/2 - 1); tmp2= tmp2t[2]; tmpI= tmpIt; if(b&4){ for(y=0; y < b_h; y++){ for(x=0; x < b_w; x++){ int a_1=tmpI[x + (HTAPS_MAX/2-4)*64]; int a0= tmpI[x + (HTAPS_MAX/2-3)*64]; int a1= tmpI[x + (HTAPS_MAX/2-2)*64]; int a2= tmpI[x + (HTAPS_MAX/2-1)*64]; int a3= tmpI[x + (HTAPS_MAX/2+0)*64]; int a4= tmpI[x + (HTAPS_MAX/2+1)*64]; int a5= tmpI[x + (HTAPS_MAX/2+2)*64]; int a6= tmpI[x + (HTAPS_MAX/2+3)*64]; int am=0; if(!p || p->fast_mc) am= (20*(a2+a3) - 5*(a1+a4) + (a0+a5) + 512)>>10; else am= (p->hcoeff[0]*(a2+a3) + p->hcoeff[1]*(a1+a4) + p->hcoeff[2]*(a0+a5) + p->hcoeff[3]*(a_1+a6) + 2048)>>12; if(am&(~255)) am= ~(am>>31); tmp2[x]= am; } tmpI+= 64; tmp2+= stride; } } hpel[ 0]= src; hpel[ 1]= tmp2t[0] + stride*(HTAPS_MAX/2-1); hpel[ 2]= src + 1; hpel[ 4]= tmp2t[1]; hpel[ 5]= tmp2t[2]; hpel[ 6]= tmp2t[1] + 1; hpel[ 8]= src + stride; hpel[ 9]= hpel[1] + stride; hpel[10]= hpel[8] + 1; if(b==15){ const uint8_t *src1= hpel[dx/8 + dy/8*4 ]; const uint8_t *src2= hpel[dx/8 + dy/8*4+1]; const uint8_t *src3= hpel[dx/8 + dy/8*4+4]; const uint8_t *src4= hpel[dx/8 + dy/8*4+5]; dx&=7; dy&=7; for(y=0; y < b_h; y++){ for(x=0; x < b_w; x++){ dst[x]= ((8-dx)*(8-dy)*src1[x] + dx*(8-dy)*src2[x]+ (8-dx)* dy *src3[x] + dx* dy *src4[x]+32)>>6; } src1+=stride; src2+=stride; src3+=stride; src4+=stride; dst +=stride; } }else{ const uint8_t *src1= hpel[l]; const uint8_t *src2= hpel[r]; int a= weight[((dx&7) + (8*(dy&7)))]; int b= 8-a; for(y=0; y < b_h; y++){ for(x=0; x < b_w; x++){ dst[x]= (a*src1[x] + b*src2[x] + 4)>>3; } src1+=stride; src2+=stride; dst +=stride; } } } #define mca(dx,dy,b_w)\ static void mc_block_hpel ## dx ## dy ## b_w(uint8_t *dst, const uint8_t *src, int stride, int h){\ uint8_t tmp[stride*(b_w+HTAPS_MAX-1)];\ assert(h==b_w);\ mc_block(NULL, dst, src-(HTAPS_MAX/2-1)-(HTAPS_MAX/2-1)*stride, tmp, stride, b_w, b_w, dx, dy);\ } mca( 0, 0,16) mca( 8, 0,16) mca( 0, 8,16) mca( 8, 8,16) mca( 0, 0,8) mca( 8, 0,8) mca( 0, 8,8) mca( 8, 8,8) static void pred_block(SnowContext *s, uint8_t *dst, uint8_t *tmp, int stride, int sx, int sy, int b_w, int b_h, BlockNode *block, int plane_index, int w, int h){ if(block->type & BLOCK_INTRA){ int x, y; const int color = block->color[plane_index]; const int color4= color*0x01010101; if(b_w==32){ for(y=0; y < b_h; y++){ *(uint32_t*)&dst[0 + y*stride]= color4; *(uint32_t*)&dst[4 + y*stride]= color4; *(uint32_t*)&dst[8 + y*stride]= color4; *(uint32_t*)&dst[12+ y*stride]= color4; *(uint32_t*)&dst[16+ y*stride]= color4; *(uint32_t*)&dst[20+ y*stride]= color4; *(uint32_t*)&dst[24+ y*stride]= color4; *(uint32_t*)&dst[28+ y*stride]= color4; } }else if(b_w==16){ for(y=0; y < b_h; y++){ *(uint32_t*)&dst[0 + y*stride]= color4; *(uint32_t*)&dst[4 + y*stride]= color4; *(uint32_t*)&dst[8 + y*stride]= color4; *(uint32_t*)&dst[12+ y*stride]= color4; } }else if(b_w==8){ for(y=0; y < b_h; y++){ *(uint32_t*)&dst[0 + y*stride]= color4; *(uint32_t*)&dst[4 + y*stride]= color4; } }else if(b_w==4){ for(y=0; y < b_h; y++){ *(uint32_t*)&dst[0 + y*stride]= color4; } }else{ for(y=0; y < b_h; y++){ for(x=0; x < b_w; x++){ dst[x + y*stride]= color; } } } }else{ uint8_t *src= s->last_picture[block->ref].data[plane_index]; const int scale= plane_index ? s->mv_scale : 2*s->mv_scale; int mx= block->mx*scale; int my= block->my*scale; const int dx= mx&15; const int dy= my&15; const int tab_index= 3 - (b_w>>2) + (b_w>>4); sx += (mx>>4) - (HTAPS_MAX/2-1); sy += (my>>4) - (HTAPS_MAX/2-1); src += sx + sy*stride; if( (unsigned)sx >= w - b_w - (HTAPS_MAX-2) || (unsigned)sy >= h - b_h - (HTAPS_MAX-2)){ ff_emulated_edge_mc(tmp + MB_SIZE, src, stride, b_w+HTAPS_MAX-1, b_h+HTAPS_MAX-1, sx, sy, w, h); src= tmp + MB_SIZE; } // assert(b_w == b_h || 2*b_w == b_h || b_w == 2*b_h); // assert(!(b_w&(b_w-1))); assert(b_w>1 && b_h>1); assert((tab_index>=0 && tab_index<4) || b_w==32); if((dx&3) || (dy&3) || !(b_w == b_h || 2*b_w == b_h || b_w == 2*b_h) || (b_w&(b_w-1)) || !s->plane[plane_index].fast_mc ) mc_block(&s->plane[plane_index], dst, src, tmp, stride, b_w, b_h, dx, dy); else if(b_w==32){ int y; for(y=0; y<b_h; y+=16){ s->dsp.put_h264_qpel_pixels_tab[0][dy+(dx>>2)](dst + y*stride, src + 3 + (y+3)*stride,stride); s->dsp.put_h264_qpel_pixels_tab[0][dy+(dx>>2)](dst + 16 + y*stride, src + 19 + (y+3)*stride,stride); } }else if(b_w==b_h) s->dsp.put_h264_qpel_pixels_tab[tab_index ][dy+(dx>>2)](dst,src + 3 + 3*stride,stride); else if(b_w==2*b_h){ s->dsp.put_h264_qpel_pixels_tab[tab_index+1][dy+(dx>>2)](dst ,src + 3 + 3*stride,stride); s->dsp.put_h264_qpel_pixels_tab[tab_index+1][dy+(dx>>2)](dst+b_h,src + 3 + b_h + 3*stride,stride); }else{ assert(2*b_w==b_h); s->dsp.put_h264_qpel_pixels_tab[tab_index ][dy+(dx>>2)](dst ,src + 3 + 3*stride ,stride); s->dsp.put_h264_qpel_pixels_tab[tab_index ][dy+(dx>>2)](dst+b_w*stride,src + 3 + 3*stride+b_w*stride,stride); } } } void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h, int src_x, int src_y, int src_stride, slice_buffer * sb, int add, uint8_t * dst8){ int y, x; IDWTELEM * dst; for(y=0; y<b_h; y++){ //FIXME ugly misuse of obmc_stride const uint8_t *obmc1= obmc + y*obmc_stride; const uint8_t *obmc2= obmc1+ (obmc_stride>>1); const uint8_t *obmc3= obmc1+ obmc_stride*(obmc_stride>>1); const uint8_t *obmc4= obmc3+ (obmc_stride>>1); dst = slice_buffer_get_line(sb, src_y + y); for(x=0; x<b_w; x++){ int v= obmc1[x] * block[3][x + y*src_stride] +obmc2[x] * block[2][x + y*src_stride] +obmc3[x] * block[1][x + y*src_stride] +obmc4[x] * block[0][x + y*src_stride]; v <<= 8 - LOG2_OBMC_MAX; if(FRAC_BITS != 8){ v >>= 8 - FRAC_BITS; } if(add){ v += dst[x + src_x]; v = (v + (1<<(FRAC_BITS-1))) >> FRAC_BITS; if(v&(~255)) v= ~(v>>31); dst8[x + y*src_stride] = v; }else{ dst[x + src_x] -= v; } } } } //FIXME name cleanup (b_w, block_w, b_width stuff) static av_always_inline void add_yblock(SnowContext *s, int sliced, slice_buffer *sb, IDWTELEM *dst, uint8_t *dst8, const uint8_t *obmc, int src_x, int src_y, int b_w, int b_h, int w, int h, int dst_stride, int src_stride, int obmc_stride, int b_x, int b_y, int add, int offset_dst, int plane_index){ const int b_width = s->b_width << s->block_max_depth; const int b_height= s->b_height << s->block_max_depth; const int b_stride= b_width; BlockNode *lt= &s->block[b_x + b_y*b_stride]; BlockNode *rt= lt+1; BlockNode *lb= lt+b_stride; BlockNode *rb= lb+1; uint8_t *block[4]; int tmp_step= src_stride >= 7*MB_SIZE ? MB_SIZE : MB_SIZE*src_stride; uint8_t *tmp = s->scratchbuf; uint8_t *ptmp; int x,y; if(b_x<0){ lt= rt; lb= rb; }else if(b_x + 1 >= b_width){ rt= lt; rb= lb; } if(b_y<0){ lt= lb; rt= rb; }else if(b_y + 1 >= b_height){ lb= lt; rb= rt; } if(src_x<0){ //FIXME merge with prev & always round internal width up to *16 obmc -= src_x; b_w += src_x; if(!sliced && !offset_dst) dst -= src_x; src_x=0; }else if(src_x + b_w > w){ b_w = w - src_x; } if(src_y<0){ obmc -= src_y*obmc_stride; b_h += src_y; if(!sliced && !offset_dst) dst -= src_y*dst_stride; src_y=0; }else if(src_y + b_h> h){ b_h = h - src_y; } if(b_w<=0 || b_h<=0) return; assert(src_stride > 2*MB_SIZE + 5); if(!sliced && offset_dst) dst += src_x + src_y*dst_stride; dst8+= src_x + src_y*src_stride; // src += src_x + src_y*src_stride; ptmp= tmp + 3*tmp_step; block[0]= ptmp; ptmp+=tmp_step; pred_block(s, block[0], tmp, src_stride, src_x, src_y, b_w, b_h, lt, plane_index, w, h); if(same_block(lt, rt)){ block[1]= block[0]; }else{ block[1]= ptmp; ptmp+=tmp_step; pred_block(s, block[1], tmp, src_stride, src_x, src_y, b_w, b_h, rt, plane_index, w, h); } if(same_block(lt, lb)){ block[2]= block[0]; }else if(same_block(rt, lb)){ block[2]= block[1]; }else{ block[2]= ptmp; ptmp+=tmp_step; pred_block(s, block[2], tmp, src_stride, src_x, src_y, b_w, b_h, lb, plane_index, w, h); } if(same_block(lt, rb) ){ block[3]= block[0]; }else if(same_block(rt, rb)){ block[3]= block[1]; }else if(same_block(lb, rb)){ block[3]= block[2]; }else{ block[3]= ptmp; pred_block(s, block[3], tmp, src_stride, src_x, src_y, b_w, b_h, rb, plane_index, w, h); } #if 0 for(y=0; y<b_h; y++){ for(x=0; x<b_w; x++){ int v= obmc [x + y*obmc_stride] * block[3][x + y*src_stride] * (256/OBMC_MAX); if(add) dst[x + y*dst_stride] += v; else dst[x + y*dst_stride] -= v; } } for(y=0; y<b_h; y++){ uint8_t *obmc2= obmc + (obmc_stride>>1); for(x=0; x<b_w; x++){ int v= obmc2[x + y*obmc_stride] * block[2][x + y*src_stride] * (256/OBMC_MAX); if(add) dst[x + y*dst_stride] += v; else dst[x + y*dst_stride] -= v; } } for(y=0; y<b_h; y++){ uint8_t *obmc3= obmc + obmc_stride*(obmc_stride>>1); for(x=0; x<b_w; x++){ int v= obmc3[x + y*obmc_stride] * block[1][x + y*src_stride] * (256/OBMC_MAX); if(add) dst[x + y*dst_stride] += v; else dst[x + y*dst_stride] -= v; } } for(y=0; y<b_h; y++){ uint8_t *obmc3= obmc + obmc_stride*(obmc_stride>>1); uint8_t *obmc4= obmc3+ (obmc_stride>>1); for(x=0; x<b_w; x++){ int v= obmc4[x + y*obmc_stride] * block[0][x + y*src_stride] * (256/OBMC_MAX); if(add) dst[x + y*dst_stride] += v; else dst[x + y*dst_stride] -= v; } } #else if(sliced){ s->dwt.inner_add_yblock(obmc, obmc_stride, block, b_w, b_h, src_x,src_y, src_stride, sb, add, dst8); }else{ for(y=0; y<b_h; y++){ //FIXME ugly misuse of obmc_stride const uint8_t *obmc1= obmc + y*obmc_stride; const uint8_t *obmc2= obmc1+ (obmc_stride>>1); const uint8_t *obmc3= obmc1+ obmc_stride*(obmc_stride>>1); const uint8_t *obmc4= obmc3+ (obmc_stride>>1); for(x=0; x<b_w; x++){ int v= obmc1[x] * block[3][x + y*src_stride] +obmc2[x] * block[2][x + y*src_stride] +obmc3[x] * block[1][x + y*src_stride] +obmc4[x] * block[0][x + y*src_stride]; v <<= 8 - LOG2_OBMC_MAX; if(FRAC_BITS != 8){ v >>= 8 - FRAC_BITS; } if(add){ v += dst[x + y*dst_stride]; v = (v + (1<<(FRAC_BITS-1))) >> FRAC_BITS; if(v&(~255)) v= ~(v>>31); dst8[x + y*src_stride] = v; }else{ dst[x + y*dst_stride] -= v; } } } } #endif /* 0 */ } static av_always_inline void predict_slice_buffered(SnowContext *s, slice_buffer * sb, IDWTELEM * old_buffer, int plane_index, int add, int mb_y){ Plane *p= &s->plane[plane_index]; const int mb_w= s->b_width << s->block_max_depth; const int mb_h= s->b_height << s->block_max_depth; int x, y, mb_x; int block_size = MB_SIZE >> s->block_max_depth; int block_w = plane_index ? block_size/2 : block_size; const uint8_t *obmc = plane_index ? obmc_tab[s->block_max_depth+1] : obmc_tab[s->block_max_depth]; int obmc_stride= plane_index ? block_size : 2*block_size; int ref_stride= s->current_picture.linesize[plane_index]; uint8_t *dst8= s->current_picture.data[plane_index]; int w= p->width; int h= p->height; if(s->keyframe || (s->avctx->debug&512)){ if(mb_y==mb_h) return; if(add){ for(y=block_w*mb_y; y<FFMIN(h,block_w*(mb_y+1)); y++){ // DWTELEM * line = slice_buffer_get_line(sb, y); IDWTELEM * line = sb->line[y]; for(x=0; x<w; x++){ // int v= buf[x + y*w] + (128<<FRAC_BITS) + (1<<(FRAC_BITS-1)); int v= line[x] + (128<<FRAC_BITS) + (1<<(FRAC_BITS-1)); v >>= FRAC_BITS; if(v&(~255)) v= ~(v>>31); dst8[x + y*ref_stride]= v; } } }else{ for(y=block_w*mb_y; y<FFMIN(h,block_w*(mb_y+1)); y++){ // DWTELEM * line = slice_buffer_get_line(sb, y); IDWTELEM * line = sb->line[y]; for(x=0; x<w; x++){ line[x] -= 128 << FRAC_BITS; // buf[x + y*w]-= 128<<FRAC_BITS; } } } return; } for(mb_x=0; mb_x<=mb_w; mb_x++){ add_yblock(s, 1, sb, old_buffer, dst8, obmc, block_w*mb_x - block_w/2, block_w*mb_y - block_w/2, block_w, block_w, w, h, w, ref_stride, obmc_stride, mb_x - 1, mb_y - 1, add, 0, plane_index); } } static av_always_inline void predict_slice(SnowContext *s, IDWTELEM *buf, int plane_index, int add, int mb_y){ Plane *p= &s->plane[plane_index]; const int mb_w= s->b_width << s->block_max_depth; const int mb_h= s->b_height << s->block_max_depth; int x, y, mb_x; int block_size = MB_SIZE >> s->block_max_depth; int block_w = plane_index ? block_size/2 : block_size; const uint8_t *obmc = plane_index ? obmc_tab[s->block_max_depth+1] : obmc_tab[s->block_max_depth]; const int obmc_stride= plane_index ? block_size : 2*block_size; int ref_stride= s->current_picture.linesize[plane_index]; uint8_t *dst8= s->current_picture.data[plane_index]; int w= p->width; int h= p->height; if(s->keyframe || (s->avctx->debug&512)){ if(mb_y==mb_h) return; if(add){ for(y=block_w*mb_y; y<FFMIN(h,block_w*(mb_y+1)); y++){ for(x=0; x<w; x++){ int v= buf[x + y*w] + (128<<FRAC_BITS) + (1<<(FRAC_BITS-1)); v >>= FRAC_BITS; if(v&(~255)) v= ~(v>>31); dst8[x + y*ref_stride]= v; } } }else{ for(y=block_w*mb_y; y<FFMIN(h,block_w*(mb_y+1)); y++){ for(x=0; x<w; x++){ buf[x + y*w]-= 128<<FRAC_BITS; } } } return; } for(mb_x=0; mb_x<=mb_w; mb_x++){ add_yblock(s, 0, NULL, buf, dst8, obmc, block_w*mb_x - block_w/2, block_w*mb_y - block_w/2, block_w, block_w, w, h, w, ref_stride, obmc_stride, mb_x - 1, mb_y - 1, add, 1, plane_index); } } static av_always_inline void predict_plane(SnowContext *s, IDWTELEM *buf, int plane_index, int add){ const int mb_h= s->b_height << s->block_max_depth; int mb_y; for(mb_y=0; mb_y<=mb_h; mb_y++) predict_slice(s, buf, plane_index, add, mb_y); } static void dequantize_slice_buffered(SnowContext *s, slice_buffer * sb, SubBand *b, IDWTELEM *src, int stride, int start_y, int end_y){ const int w= b->width; const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16); const int qmul= qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT); const int qadd= (s->qbias*qmul)>>QBIAS_SHIFT; int x,y; if(s->qlog == LOSSLESS_QLOG) return; for(y=start_y; y<end_y; y++){ // DWTELEM * line = slice_buffer_get_line_from_address(sb, src + (y * stride)); IDWTELEM * line = slice_buffer_get_line(sb, (y * b->stride_line) + b->buf_y_offset) + b->buf_x_offset; for(x=0; x<w; x++){ int i= line[x]; if(i<0){ line[x]= -((-i*qmul + qadd)>>(QEXPSHIFT)); //FIXME try different bias }else if(i>0){ line[x]= (( i*qmul + qadd)>>(QEXPSHIFT)); } } } } static void correlate_slice_buffered(SnowContext *s, slice_buffer * sb, SubBand *b, IDWTELEM *src, int stride, int inverse, int use_median, int start_y, int end_y){ const int w= b->width; int x,y; IDWTELEM * line=0; // silence silly "could be used without having been initialized" warning IDWTELEM * prev; if (start_y != 0) line = slice_buffer_get_line(sb, ((start_y - 1) * b->stride_line) + b->buf_y_offset) + b->buf_x_offset; for(y=start_y; y<end_y; y++){ prev = line; // line = slice_buffer_get_line_from_address(sb, src + (y * stride)); line = slice_buffer_get_line(sb, (y * b->stride_line) + b->buf_y_offset) + b->buf_x_offset; for(x=0; x<w; x++){ if(x){ if(use_median){ if(y && x+1<w) line[x] += mid_pred(line[x - 1], prev[x], prev[x + 1]); else line[x] += line[x - 1]; }else{ if(y) line[x] += mid_pred(line[x - 1], prev[x], line[x - 1] + prev[x] - prev[x - 1]); else line[x] += line[x - 1]; } }else{ if(y) line[x] += prev[x]; } } } } static void decode_qlogs(SnowContext *s){ int plane_index, level, orientation; for(plane_index=0; plane_index<3; plane_index++){ for(level=0; level<s->spatial_decomposition_count; level++){ for(orientation=level ? 1:0; orientation<4; orientation++){ int q; if (plane_index==2) q= s->plane[1].band[level][orientation].qlog; else if(orientation==2) q= s->plane[plane_index].band[level][1].qlog; else q= get_symbol(&s->c, s->header_state, 1); s->plane[plane_index].band[level][orientation].qlog= q; } } } } #define GET_S(dst, check) \ tmp= get_symbol(&s->c, s->header_state, 0);\ if(!(check)){\ av_log(s->avctx, AV_LOG_ERROR, "Error " #dst " is %d\n", tmp);\ return -1;\ }\ dst= tmp; static int decode_header(SnowContext *s){ int plane_index, tmp; uint8_t kstate[32]; memset(kstate, MID_STATE, sizeof(kstate)); s->keyframe= get_rac(&s->c, kstate); if(s->keyframe || s->always_reset){ reset_contexts(s); s->spatial_decomposition_type= s->qlog= s->qbias= s->mv_scale= s->block_max_depth= 0; } if(s->keyframe){ GET_S(s->version, tmp <= 0U) s->always_reset= get_rac(&s->c, s->header_state); s->temporal_decomposition_type= get_symbol(&s->c, s->header_state, 0); s->temporal_decomposition_count= get_symbol(&s->c, s->header_state, 0); GET_S(s->spatial_decomposition_count, 0 < tmp && tmp <= MAX_DECOMPOSITIONS) s->colorspace_type= get_symbol(&s->c, s->header_state, 0); s->chroma_h_shift= get_symbol(&s->c, s->header_state, 0); s->chroma_v_shift= get_symbol(&s->c, s->header_state, 0); s->spatial_scalability= get_rac(&s->c, s->header_state); // s->rate_scalability= get_rac(&s->c, s->header_state); GET_S(s->max_ref_frames, tmp < (unsigned)MAX_REF_FRAMES) s->max_ref_frames++; decode_qlogs(s); } if(!s->keyframe){ if(get_rac(&s->c, s->header_state)){ for(plane_index=0; plane_index<2; plane_index++){ int htaps, i, sum=0; Plane *p= &s->plane[plane_index]; p->diag_mc= get_rac(&s->c, s->header_state); htaps= get_symbol(&s->c, s->header_state, 0)*2 + 2; if((unsigned)htaps > HTAPS_MAX || htaps==0) return -1; p->htaps= htaps; for(i= htaps/2; i; i--){ p->hcoeff[i]= get_symbol(&s->c, s->header_state, 0) * (1-2*(i&1)); sum += p->hcoeff[i]; } p->hcoeff[0]= 32-sum; } s->plane[2].diag_mc= s->plane[1].diag_mc; s->plane[2].htaps = s->plane[1].htaps; memcpy(s->plane[2].hcoeff, s->plane[1].hcoeff, sizeof(s->plane[1].hcoeff)); } if(get_rac(&s->c, s->header_state)){ GET_S(s->spatial_decomposition_count, 0 < tmp && tmp <= MAX_DECOMPOSITIONS) decode_qlogs(s); } } s->spatial_decomposition_type+= get_symbol(&s->c, s->header_state, 1); if(s->spatial_decomposition_type > 1U){ av_log(s->avctx, AV_LOG_ERROR, "spatial_decomposition_type %d not supported", s->spatial_decomposition_type); return -1; } if(FFMIN(s->avctx-> width>>s->chroma_h_shift, s->avctx->height>>s->chroma_v_shift) >> (s->spatial_decomposition_count-1) <= 0){ av_log(s->avctx, AV_LOG_ERROR, "spatial_decomposition_count %d too large for size", s->spatial_decomposition_count); return -1; } s->qlog += get_symbol(&s->c, s->header_state, 1); s->mv_scale += get_symbol(&s->c, s->header_state, 1); s->qbias += get_symbol(&s->c, s->header_state, 1); s->block_max_depth+= get_symbol(&s->c, s->header_state, 1); if(s->block_max_depth > 1 || s->block_max_depth < 0){ av_log(s->avctx, AV_LOG_ERROR, "block_max_depth= %d is too large", s->block_max_depth); s->block_max_depth= 0; return -1; } return 0; } static void init_qexp(void){ int i; double v=128; for(i=0; i<QROOT; i++){ qexp[i]= lrintf(v); v *= pow(2, 1.0 / QROOT); } } static av_cold int common_init(AVCodecContext *avctx){ SnowContext *s = avctx->priv_data; int width, height; int i, j; s->avctx= avctx; s->max_ref_frames=1; //just make sure its not an invalid value in case of no initial keyframe dsputil_init(&s->dsp, avctx); ff_dwt_init(&s->dwt); #define mcf(dx,dy)\ s->dsp.put_qpel_pixels_tab [0][dy+dx/4]=\ s->dsp.put_no_rnd_qpel_pixels_tab[0][dy+dx/4]=\ s->dsp.put_h264_qpel_pixels_tab[0][dy+dx/4];\ s->dsp.put_qpel_pixels_tab [1][dy+dx/4]=\ s->dsp.put_no_rnd_qpel_pixels_tab[1][dy+dx/4]=\ s->dsp.put_h264_qpel_pixels_tab[1][dy+dx/4]; mcf( 0, 0) mcf( 4, 0) mcf( 8, 0) mcf(12, 0) mcf( 0, 4) mcf( 4, 4) mcf( 8, 4) mcf(12, 4) mcf( 0, 8) mcf( 4, 8) mcf( 8, 8) mcf(12, 8) mcf( 0,12) mcf( 4,12) mcf( 8,12) mcf(12,12) #define mcfh(dx,dy)\ s->dsp.put_pixels_tab [0][dy/4+dx/8]=\ s->dsp.put_no_rnd_pixels_tab[0][dy/4+dx/8]=\ mc_block_hpel ## dx ## dy ## 16;\ s->dsp.put_pixels_tab [1][dy/4+dx/8]=\ s->dsp.put_no_rnd_pixels_tab[1][dy/4+dx/8]=\ mc_block_hpel ## dx ## dy ## 8; mcfh(0, 0) mcfh(8, 0) mcfh(0, 8) mcfh(8, 8) if(!qexp[0]) init_qexp(); // dec += FFMAX(s->chroma_h_shift, s->chroma_v_shift); width= s->avctx->width; height= s->avctx->height; s->spatial_idwt_buffer= av_mallocz(width*height*sizeof(IDWTELEM)); s->spatial_dwt_buffer= av_mallocz(width*height*sizeof(DWTELEM)); //FIXME this does not belong here for(i=0; i<MAX_REF_FRAMES; i++) for(j=0; j<MAX_REF_FRAMES; j++) scale_mv_ref[i][j] = 256*(i+1)/(j+1); s->avctx->get_buffer(s->avctx, &s->mconly_picture); s->scratchbuf = av_malloc(s->mconly_picture.linesize[0]*7*MB_SIZE); return 0; } static int common_init_after_header(AVCodecContext *avctx){ SnowContext *s = avctx->priv_data; int plane_index, level, orientation; for(plane_index=0; plane_index<3; plane_index++){ int w= s->avctx->width; int h= s->avctx->height; if(plane_index){ w>>= s->chroma_h_shift; h>>= s->chroma_v_shift; } s->plane[plane_index].width = w; s->plane[plane_index].height= h; for(level=s->spatial_decomposition_count-1; level>=0; level--){ for(orientation=level ? 1 : 0; orientation<4; orientation++){ SubBand *b= &s->plane[plane_index].band[level][orientation]; b->buf= s->spatial_dwt_buffer; b->level= level; b->stride= s->plane[plane_index].width << (s->spatial_decomposition_count - level); b->width = (w + !(orientation&1))>>1; b->height= (h + !(orientation>1))>>1; b->stride_line = 1 << (s->spatial_decomposition_count - level); b->buf_x_offset = 0; b->buf_y_offset = 0; if(orientation&1){ b->buf += (w+1)>>1; b->buf_x_offset = (w+1)>>1; } if(orientation>1){ b->buf += b->stride>>1; b->buf_y_offset = b->stride_line >> 1; } b->ibuf= s->spatial_idwt_buffer + (b->buf - s->spatial_dwt_buffer); if(level) b->parent= &s->plane[plane_index].band[level-1][orientation]; //FIXME avoid this realloc av_freep(&b->x_coeff); b->x_coeff=av_mallocz(((b->width+1) * b->height+1)*sizeof(x_and_coeff)); } w= (w+1)>>1; h= (h+1)>>1; } } return 0; } #define QUANTIZE2 0 #if QUANTIZE2==1 #define Q2_STEP 8 static void find_sse(SnowContext *s, Plane *p, int *score, int score_stride, IDWTELEM *r0, IDWTELEM *r1, int level, int orientation){ SubBand *b= &p->band[level][orientation]; int x, y; int xo=0; int yo=0; int step= 1 << (s->spatial_decomposition_count - level); if(orientation&1) xo= step>>1; if(orientation&2) yo= step>>1; //FIXME bias for nonzero ? //FIXME optimize memset(score, 0, sizeof(*score)*score_stride*((p->height + Q2_STEP-1)/Q2_STEP)); for(y=0; y<p->height; y++){ for(x=0; x<p->width; x++){ int sx= (x-xo + step/2) / step / Q2_STEP; int sy= (y-yo + step/2) / step / Q2_STEP; int v= r0[x + y*p->width] - r1[x + y*p->width]; assert(sx>=0 && sy>=0 && sx < score_stride); v= ((v+8)>>4)<<4; score[sx + sy*score_stride] += v*v; assert(score[sx + sy*score_stride] >= 0); } } } static void dequantize_all(SnowContext *s, Plane *p, IDWTELEM *buffer, int width, int height){ int level, orientation; for(level=0; level<s->spatial_decomposition_count; level++){ for(orientation=level ? 1 : 0; orientation<4; orientation++){ SubBand *b= &p->band[level][orientation]; IDWTELEM *dst= buffer + (b->ibuf - s->spatial_idwt_buffer); dequantize(s, b, dst, b->stride); } } } static void dwt_quantize(SnowContext *s, Plane *p, DWTELEM *buffer, int width, int height, int stride, int type){ int level, orientation, ys, xs, x, y, pass; IDWTELEM best_dequant[height * stride]; IDWTELEM idwt2_buffer[height * stride]; const int score_stride= (width + 10)/Q2_STEP; int best_score[(width + 10)/Q2_STEP * (height + 10)/Q2_STEP]; //FIXME size int score[(width + 10)/Q2_STEP * (height + 10)/Q2_STEP]; //FIXME size int threshold= (s->m.lambda * s->m.lambda) >> 6; //FIXME pass the copy cleanly ? // memcpy(dwt_buffer, buffer, height * stride * sizeof(DWTELEM)); ff_spatial_dwt(buffer, width, height, stride, type, s->spatial_decomposition_count); for(level=0; level<s->spatial_decomposition_count; level++){ for(orientation=level ? 1 : 0; orientation<4; orientation++){ SubBand *b= &p->band[level][orientation]; IDWTELEM *dst= best_dequant + (b->ibuf - s->spatial_idwt_buffer); DWTELEM *src= buffer + (b-> buf - s->spatial_dwt_buffer); assert(src == b->buf); // code does not depend on this but it is true currently quantize(s, b, dst, src, b->stride, s->qbias); } } for(pass=0; pass<1; pass++){ if(s->qbias == 0) //keyframe continue; for(level=0; level<s->spatial_decomposition_count; level++){ for(orientation=level ? 1 : 0; orientation<4; orientation++){ SubBand *b= &p->band[level][orientation]; IDWTELEM *dst= idwt2_buffer + (b->ibuf - s->spatial_idwt_buffer); IDWTELEM *best_dst= best_dequant + (b->ibuf - s->spatial_idwt_buffer); for(ys= 0; ys<Q2_STEP; ys++){ for(xs= 0; xs<Q2_STEP; xs++){ memcpy(idwt2_buffer, best_dequant, height * stride * sizeof(IDWTELEM)); dequantize_all(s, p, idwt2_buffer, width, height); ff_spatial_idwt(idwt2_buffer, width, height, stride, type, s->spatial_decomposition_count); find_sse(s, p, best_score, score_stride, idwt2_buffer, s->spatial_idwt_buffer, level, orientation); memcpy(idwt2_buffer, best_dequant, height * stride * sizeof(IDWTELEM)); for(y=ys; y<b->height; y+= Q2_STEP){ for(x=xs; x<b->width; x+= Q2_STEP){ if(dst[x + y*b->stride]<0) dst[x + y*b->stride]++; if(dst[x + y*b->stride]>0) dst[x + y*b->stride]--; //FIXME try more than just -- } } dequantize_all(s, p, idwt2_buffer, width, height); ff_spatial_idwt(idwt2_buffer, width, height, stride, type, s->spatial_decomposition_count); find_sse(s, p, score, score_stride, idwt2_buffer, s->spatial_idwt_buffer, level, orientation); for(y=ys; y<b->height; y+= Q2_STEP){ for(x=xs; x<b->width; x+= Q2_STEP){ int score_idx= x/Q2_STEP + (y/Q2_STEP)*score_stride; if(score[score_idx] <= best_score[score_idx] + threshold){ best_score[score_idx]= score[score_idx]; if(best_dst[x + y*b->stride]<0) best_dst[x + y*b->stride]++; if(best_dst[x + y*b->stride]>0) best_dst[x + y*b->stride]--; //FIXME copy instead } } } } } } } } memcpy(s->spatial_idwt_buffer, best_dequant, height * stride * sizeof(IDWTELEM)); //FIXME work with that directly instead of copy at the end } #endif /* QUANTIZE2==1 */ #define USE_HALFPEL_PLANE 0 static void halfpel_interpol(SnowContext *s, uint8_t *halfpel[4][4], AVFrame *frame){ int p,x,y; assert(!(s->avctx->flags & CODEC_FLAG_EMU_EDGE)); for(p=0; p<3; p++){ int is_chroma= !!p; int w= s->avctx->width >>is_chroma; int h= s->avctx->height >>is_chroma; int ls= frame->linesize[p]; uint8_t *src= frame->data[p]; halfpel[1][p]= (uint8_t*)av_malloc(ls * (h+2*EDGE_WIDTH)) + EDGE_WIDTH*(1+ls); halfpel[2][p]= (uint8_t*)av_malloc(ls * (h+2*EDGE_WIDTH)) + EDGE_WIDTH*(1+ls); halfpel[3][p]= (uint8_t*)av_malloc(ls * (h+2*EDGE_WIDTH)) + EDGE_WIDTH*(1+ls); halfpel[0][p]= src; for(y=0; y<h; y++){ for(x=0; x<w; x++){ int i= y*ls + x; halfpel[1][p][i]= (20*(src[i] + src[i+1]) - 5*(src[i-1] + src[i+2]) + (src[i-2] + src[i+3]) + 16 )>>5; } } for(y=0; y<h; y++){ for(x=0; x<w; x++){ int i= y*ls + x; halfpel[2][p][i]= (20*(src[i] + src[i+ls]) - 5*(src[i-ls] + src[i+2*ls]) + (src[i-2*ls] + src[i+3*ls]) + 16 )>>5; } } src= halfpel[1][p]; for(y=0; y<h; y++){ for(x=0; x<w; x++){ int i= y*ls + x; halfpel[3][p][i]= (20*(src[i] + src[i+ls]) - 5*(src[i-ls] + src[i+2*ls]) + (src[i-2*ls] + src[i+3*ls]) + 16 )>>5; } } //FIXME border! } } static void release_buffer(AVCodecContext *avctx){ SnowContext *s = avctx->priv_data; int i; if(s->last_picture[s->max_ref_frames-1].data[0]){ avctx->release_buffer(avctx, &s->last_picture[s->max_ref_frames-1]); for(i=0; i<9; i++) if(s->halfpel_plane[s->max_ref_frames-1][1+i/3][i%3]) av_free(s->halfpel_plane[s->max_ref_frames-1][1+i/3][i%3] - EDGE_WIDTH*(1+s->current_picture.linesize[i%3])); } } static int frame_start(SnowContext *s){ AVFrame tmp; int w= s->avctx->width; //FIXME round up to x16 ? int h= s->avctx->height; if(s->current_picture.data[0]){ s->dsp.draw_edges(s->current_picture.data[0], s->current_picture.linesize[0], w , h , EDGE_WIDTH ); s->dsp.draw_edges(s->current_picture.data[1], s->current_picture.linesize[1], w>>1, h>>1, EDGE_WIDTH/2); s->dsp.draw_edges(s->current_picture.data[2], s->current_picture.linesize[2], w>>1, h>>1, EDGE_WIDTH/2); } release_buffer(s->avctx); tmp= s->last_picture[s->max_ref_frames-1]; memmove(s->last_picture+1, s->last_picture, (s->max_ref_frames-1)*sizeof(AVFrame)); memmove(s->halfpel_plane+1, s->halfpel_plane, (s->max_ref_frames-1)*sizeof(void*)*4*4); if(USE_HALFPEL_PLANE && s->current_picture.data[0]) halfpel_interpol(s, s->halfpel_plane[0], &s->current_picture); s->last_picture[0]= s->current_picture; s->current_picture= tmp; if(s->keyframe){ s->ref_frames= 0; }else{ int i; for(i=0; i<s->max_ref_frames && s->last_picture[i].data[0]; i++) if(i && s->last_picture[i-1].key_frame) break; s->ref_frames= i; if(s->ref_frames==0){ av_log(s->avctx,AV_LOG_ERROR, "No reference frames\n"); return -1; } } s->current_picture.reference= 1; if(s->avctx->get_buffer(s->avctx, &s->current_picture) < 0){ av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } s->current_picture.key_frame= s->keyframe; return 0; } static av_cold void common_end(SnowContext *s){ int plane_index, level, orientation, i; av_freep(&s->spatial_dwt_buffer); av_freep(&s->spatial_idwt_buffer); s->m.me.temp= NULL; av_freep(&s->m.me.scratchpad); av_freep(&s->m.me.map); av_freep(&s->m.me.score_map); av_freep(&s->m.obmc_scratchpad); av_freep(&s->block); av_freep(&s->scratchbuf); for(i=0; i<MAX_REF_FRAMES; i++){ av_freep(&s->ref_mvs[i]); av_freep(&s->ref_scores[i]); if(s->last_picture[i].data[0]) s->avctx->release_buffer(s->avctx, &s->last_picture[i]); } for(plane_index=0; plane_index<3; plane_index++){ for(level=s->spatial_decomposition_count-1; level>=0; level--){ for(orientation=level ? 1 : 0; orientation<4; orientation++){ SubBand *b= &s->plane[plane_index].band[level][orientation]; av_freep(&b->x_coeff); } } } if (s->mconly_picture.data[0]) s->avctx->release_buffer(s->avctx, &s->mconly_picture); if (s->current_picture.data[0]) s->avctx->release_buffer(s->avctx, &s->current_picture); } static av_cold int decode_init(AVCodecContext *avctx) { avctx->pix_fmt= PIX_FMT_YUV420P; common_init(avctx); return 0; } static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt){ const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; SnowContext *s = avctx->priv_data; RangeCoder * const c= &s->c; int bytes_read; AVFrame *picture = data; int level, orientation, plane_index; ff_init_range_decoder(c, buf, buf_size); ff_build_rac_states(c, 0.05*(1LL<<32), 256-8); s->current_picture.pict_type= FF_I_TYPE; //FIXME I vs. P if(decode_header(s)<0) return -1; common_init_after_header(avctx); // realloc slice buffer for the case that spatial_decomposition_count changed ff_slice_buffer_destroy(&s->sb); ff_slice_buffer_init(&s->sb, s->plane[0].height, (MB_SIZE >> s->block_max_depth) + s->spatial_decomposition_count * 8 + 1, s->plane[0].width, s->spatial_idwt_buffer); for(plane_index=0; plane_index<3; plane_index++){ Plane *p= &s->plane[plane_index]; p->fast_mc= p->diag_mc && p->htaps==6 && p->hcoeff[0]==40 && p->hcoeff[1]==-10 && p->hcoeff[2]==2; } alloc_blocks(s); if(frame_start(s) < 0) return -1; //keyframe flag duplication mess FIXME if(avctx->debug&FF_DEBUG_PICT_INFO) av_log(avctx, AV_LOG_ERROR, "keyframe:%d qlog:%d\n", s->keyframe, s->qlog); decode_blocks(s); for(plane_index=0; plane_index<3; plane_index++){ Plane *p= &s->plane[plane_index]; int w= p->width; int h= p->height; int x, y; int decode_state[MAX_DECOMPOSITIONS][4][1]; /* Stored state info for unpack_coeffs. 1 variable per instance. */ if(s->avctx->debug&2048){ memset(s->spatial_dwt_buffer, 0, sizeof(DWTELEM)*w*h); predict_plane(s, s->spatial_idwt_buffer, plane_index, 1); for(y=0; y<h; y++){ for(x=0; x<w; x++){ int v= s->current_picture.data[plane_index][y*s->current_picture.linesize[plane_index] + x]; s->mconly_picture.data[plane_index][y*s->mconly_picture.linesize[plane_index] + x]= v; } } } { for(level=0; level<s->spatial_decomposition_count; level++){ for(orientation=level ? 1 : 0; orientation<4; orientation++){ SubBand *b= &p->band[level][orientation]; unpack_coeffs(s, b, b->parent, orientation); } } } { const int mb_h= s->b_height << s->block_max_depth; const int block_size = MB_SIZE >> s->block_max_depth; const int block_w = plane_index ? block_size/2 : block_size; int mb_y; DWTCompose cs[MAX_DECOMPOSITIONS]; int yd=0, yq=0; int y; int end_y; ff_spatial_idwt_buffered_init(cs, &s->sb, w, h, 1, s->spatial_decomposition_type, s->spatial_decomposition_count); for(mb_y=0; mb_y<=mb_h; mb_y++){ int slice_starty = block_w*mb_y; int slice_h = block_w*(mb_y+1); if (!(s->keyframe || s->avctx->debug&512)){ slice_starty = FFMAX(0, slice_starty - (block_w >> 1)); slice_h -= (block_w >> 1); } for(level=0; level<s->spatial_decomposition_count; level++){ for(orientation=level ? 1 : 0; orientation<4; orientation++){ SubBand *b= &p->band[level][orientation]; int start_y; int end_y; int our_mb_start = mb_y; int our_mb_end = (mb_y + 1); const int extra= 3; start_y = (mb_y ? ((block_w * our_mb_start) >> (s->spatial_decomposition_count - level)) + s->spatial_decomposition_count - level + extra: 0); end_y = (((block_w * our_mb_end) >> (s->spatial_decomposition_count - level)) + s->spatial_decomposition_count - level + extra); if (!(s->keyframe || s->avctx->debug&512)){ start_y = FFMAX(0, start_y - (block_w >> (1+s->spatial_decomposition_count - level))); end_y = FFMAX(0, end_y - (block_w >> (1+s->spatial_decomposition_count - level))); } start_y = FFMIN(b->height, start_y); end_y = FFMIN(b->height, end_y); if (start_y != end_y){ if (orientation == 0){ SubBand * correlate_band = &p->band[0][0]; int correlate_end_y = FFMIN(b->height, end_y + 1); int correlate_start_y = FFMIN(b->height, (start_y ? start_y + 1 : 0)); decode_subband_slice_buffered(s, correlate_band, &s->sb, correlate_start_y, correlate_end_y, decode_state[0][0]); correlate_slice_buffered(s, &s->sb, correlate_band, correlate_band->ibuf, correlate_band->stride, 1, 0, correlate_start_y, correlate_end_y); dequantize_slice_buffered(s, &s->sb, correlate_band, correlate_band->ibuf, correlate_band->stride, start_y, end_y); } else decode_subband_slice_buffered(s, b, &s->sb, start_y, end_y, decode_state[level][orientation]); } } } for(; yd<slice_h; yd+=4){ ff_spatial_idwt_buffered_slice(&s->dwt, cs, &s->sb, w, h, 1, s->spatial_decomposition_type, s->spatial_decomposition_count, yd); } if(s->qlog == LOSSLESS_QLOG){ for(; yq<slice_h && yq<h; yq++){ IDWTELEM * line = slice_buffer_get_line(&s->sb, yq); for(x=0; x<w; x++){ line[x] <<= FRAC_BITS; } } } predict_slice_buffered(s, &s->sb, s->spatial_idwt_buffer, plane_index, 1, mb_y); y = FFMIN(p->height, slice_starty); end_y = FFMIN(p->height, slice_h); while(y < end_y) ff_slice_buffer_release(&s->sb, y++); } ff_slice_buffer_flush(&s->sb); } } emms_c(); release_buffer(avctx); if(!(s->avctx->debug&2048)) *picture= s->current_picture; else *picture= s->mconly_picture; *data_size = sizeof(AVFrame); bytes_read= c->bytestream - c->bytestream_start; if(bytes_read ==0) av_log(s->avctx, AV_LOG_ERROR, "error at end of frame\n"); //FIXME return bytes_read; } static av_cold int decode_end(AVCodecContext *avctx) { SnowContext *s = avctx->priv_data; ff_slice_buffer_destroy(&s->sb); common_end(s); return 0; } AVCodec snow_decoder = { "snow", AVMEDIA_TYPE_VIDEO, CODEC_ID_SNOW, sizeof(SnowContext), decode_init, NULL, decode_end, decode_frame, CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/, NULL, .long_name = NULL_IF_CONFIG_SMALL("Snow"), }; #if CONFIG_SNOW_ENCODER static av_cold int encode_init(AVCodecContext *avctx) { SnowContext *s = avctx->priv_data; int plane_index; if(avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL){ av_log(avctx, AV_LOG_ERROR, "This codec is under development, files encoded with it may not be decodable with future versions!!!\n" "Use vstrict=-2 / -strict -2 to use it anyway.\n"); return -1; } if(avctx->prediction_method == DWT_97 && (avctx->flags & CODEC_FLAG_QSCALE) && avctx->global_quality == 0){ av_log(avctx, AV_LOG_ERROR, "The 9/7 wavelet is incompatible with lossless mode.\n"); return -1; } s->spatial_decomposition_type= avctx->prediction_method; //FIXME add decorrelator type r transform_type s->mv_scale = (avctx->flags & CODEC_FLAG_QPEL) ? 2 : 4; s->block_max_depth= (avctx->flags & CODEC_FLAG_4MV ) ? 1 : 0; for(plane_index=0; plane_index<3; plane_index++){ s->plane[plane_index].diag_mc= 1; s->plane[plane_index].htaps= 6; s->plane[plane_index].hcoeff[0]= 40; s->plane[plane_index].hcoeff[1]= -10; s->plane[plane_index].hcoeff[2]= 2; s->plane[plane_index].fast_mc= 1; } common_init(avctx); alloc_blocks(s); s->version=0; s->m.avctx = avctx; s->m.flags = avctx->flags; s->m.bit_rate= avctx->bit_rate; s->m.me.temp = s->m.me.scratchpad= av_mallocz((avctx->width+64)*2*16*2*sizeof(uint8_t)); s->m.me.map = av_mallocz(ME_MAP_SIZE*sizeof(uint32_t)); s->m.me.score_map = av_mallocz(ME_MAP_SIZE*sizeof(uint32_t)); s->m.obmc_scratchpad= av_mallocz(MB_SIZE*MB_SIZE*12*sizeof(uint32_t)); h263_encode_init(&s->m); //mv_penalty s->max_ref_frames = FFMAX(FFMIN(avctx->refs, MAX_REF_FRAMES), 1); if(avctx->flags&CODEC_FLAG_PASS1){ if(!avctx->stats_out) avctx->stats_out = av_mallocz(256); } if((avctx->flags&CODEC_FLAG_PASS2) || !(avctx->flags&CODEC_FLAG_QSCALE)){ if(ff_rate_control_init(&s->m) < 0) return -1; } s->pass1_rc= !(avctx->flags & (CODEC_FLAG_QSCALE|CODEC_FLAG_PASS2)); avctx->coded_frame= &s->current_picture; switch(avctx->pix_fmt){ // case PIX_FMT_YUV444P: // case PIX_FMT_YUV422P: case PIX_FMT_YUV420P: case PIX_FMT_GRAY8: // case PIX_FMT_YUV411P: // case PIX_FMT_YUV410P: s->colorspace_type= 0; break; /* case PIX_FMT_RGB32: s->colorspace= 1; break;*/ default: av_log(avctx, AV_LOG_ERROR, "pixel format not supported\n"); return -1; } // avcodec_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_h_shift, &s->chroma_v_shift); s->chroma_h_shift= 1; s->chroma_v_shift= 1; ff_set_cmp(&s->dsp, s->dsp.me_cmp, s->avctx->me_cmp); ff_set_cmp(&s->dsp, s->dsp.me_sub_cmp, s->avctx->me_sub_cmp); s->avctx->get_buffer(s->avctx, &s->input_picture); if(s->avctx->me_method == ME_ITER){ int i; int size= s->b_width * s->b_height << 2*s->block_max_depth; for(i=0; i<s->max_ref_frames; i++){ s->ref_mvs[i]= av_mallocz(size*sizeof(int16_t[2])); s->ref_scores[i]= av_mallocz(size*sizeof(uint32_t)); } } return 0; } //near copy & paste from dsputil, FIXME static int pix_sum(uint8_t * pix, int line_size, int w) { int s, i, j; s = 0; for (i = 0; i < w; i++) { for (j = 0; j < w; j++) { s += pix[0]; pix ++; } pix += line_size - w; } return s; } //near copy & paste from dsputil, FIXME static int pix_norm1(uint8_t * pix, int line_size, int w) { int s, i, j; uint32_t *sq = ff_squareTbl + 256; s = 0; for (i = 0; i < w; i++) { for (j = 0; j < w; j ++) { s += sq[pix[0]]; pix ++; } pix += line_size - w; } return s; } //FIXME copy&paste #define P_LEFT P[1] #define P_TOP P[2] #define P_TOPRIGHT P[3] #define P_MEDIAN P[4] #define P_MV1 P[9] #define FLAG_QPEL 1 //must be 1 static int encode_q_branch(SnowContext *s, int level, int x, int y){ uint8_t p_buffer[1024]; uint8_t i_buffer[1024]; uint8_t p_state[sizeof(s->block_state)]; uint8_t i_state[sizeof(s->block_state)]; RangeCoder pc, ic; uint8_t *pbbak= s->c.bytestream; uint8_t *pbbak_start= s->c.bytestream_start; int score, score2, iscore, i_len, p_len, block_s, sum, base_bits; const int w= s->b_width << s->block_max_depth; const int h= s->b_height << s->block_max_depth; const int rem_depth= s->block_max_depth - level; const int index= (x + y*w) << rem_depth; const int block_w= 1<<(LOG2_MB_SIZE - level); int trx= (x+1)<<rem_depth; int try= (y+1)<<rem_depth; const BlockNode *left = x ? &s->block[index-1] : &null_block; const BlockNode *top = y ? &s->block[index-w] : &null_block; const BlockNode *right = trx<w ? &s->block[index+1] : &null_block; const BlockNode *bottom= try<h ? &s->block[index+w] : &null_block; const BlockNode *tl = y && x ? &s->block[index-w-1] : left; const BlockNode *tr = y && trx<w && ((x&1)==0 || level==0) ? &s->block[index-w+(1<<rem_depth)] : tl; //FIXME use lt int pl = left->color[0]; int pcb= left->color[1]; int pcr= left->color[2]; int pmx, pmy; int mx=0, my=0; int l,cr,cb; const int stride= s->current_picture.linesize[0]; const int uvstride= s->current_picture.linesize[1]; uint8_t *current_data[3]= { s->input_picture.data[0] + (x + y* stride)*block_w, s->input_picture.data[1] + (x + y*uvstride)*block_w/2, s->input_picture.data[2] + (x + y*uvstride)*block_w/2}; int P[10][2]; int16_t last_mv[3][2]; int qpel= !!(s->avctx->flags & CODEC_FLAG_QPEL); //unused const int shift= 1+qpel; MotionEstContext *c= &s->m.me; int ref_context= av_log2(2*left->ref) + av_log2(2*top->ref); int mx_context= av_log2(2*FFABS(left->mx - top->mx)); int my_context= av_log2(2*FFABS(left->my - top->my)); int s_context= 2*left->level + 2*top->level + tl->level + tr->level; int ref, best_ref, ref_score, ref_mx, ref_my; assert(sizeof(s->block_state) >= 256); if(s->keyframe){ set_blocks(s, level, x, y, pl, pcb, pcr, 0, 0, 0, BLOCK_INTRA); return 0; } // clip predictors / edge ? P_LEFT[0]= left->mx; P_LEFT[1]= left->my; P_TOP [0]= top->mx; P_TOP [1]= top->my; P_TOPRIGHT[0]= tr->mx; P_TOPRIGHT[1]= tr->my; last_mv[0][0]= s->block[index].mx; last_mv[0][1]= s->block[index].my; last_mv[1][0]= right->mx; last_mv[1][1]= right->my; last_mv[2][0]= bottom->mx; last_mv[2][1]= bottom->my; s->m.mb_stride=2; s->m.mb_x= s->m.mb_y= 0; c->skip= 0; assert(c-> stride == stride); assert(c->uvstride == uvstride); c->penalty_factor = get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_cmp); c->sub_penalty_factor= get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_sub_cmp); c->mb_penalty_factor = get_penalty_factor(s->lambda, s->lambda2, c->avctx->mb_cmp); c->current_mv_penalty= c->mv_penalty[s->m.f_code=1] + MAX_MV; c->xmin = - x*block_w - 16+3; c->ymin = - y*block_w - 16+3; c->xmax = - (x+1)*block_w + (w<<(LOG2_MB_SIZE - s->block_max_depth)) + 16-3; c->ymax = - (y+1)*block_w + (h<<(LOG2_MB_SIZE - s->block_max_depth)) + 16-3; if(P_LEFT[0] > (c->xmax<<shift)) P_LEFT[0] = (c->xmax<<shift); if(P_LEFT[1] > (c->ymax<<shift)) P_LEFT[1] = (c->ymax<<shift); if(P_TOP[0] > (c->xmax<<shift)) P_TOP[0] = (c->xmax<<shift); if(P_TOP[1] > (c->ymax<<shift)) P_TOP[1] = (c->ymax<<shift); if(P_TOPRIGHT[0] < (c->xmin<<shift)) P_TOPRIGHT[0]= (c->xmin<<shift); if(P_TOPRIGHT[0] > (c->xmax<<shift)) P_TOPRIGHT[0]= (c->xmax<<shift); //due to pmx no clip if(P_TOPRIGHT[1] > (c->ymax<<shift)) P_TOPRIGHT[1]= (c->ymax<<shift); P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]); P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]); if (!y) { c->pred_x= P_LEFT[0]; c->pred_y= P_LEFT[1]; } else { c->pred_x = P_MEDIAN[0]; c->pred_y = P_MEDIAN[1]; } score= INT_MAX; best_ref= 0; for(ref=0; ref<s->ref_frames; ref++){ init_ref(c, current_data, s->last_picture[ref].data, NULL, block_w*x, block_w*y, 0); ref_score= ff_epzs_motion_search(&s->m, &ref_mx, &ref_my, P, 0, /*ref_index*/ 0, last_mv, (1<<16)>>shift, level-LOG2_MB_SIZE+4, block_w); assert(ref_mx >= c->xmin); assert(ref_mx <= c->xmax); assert(ref_my >= c->ymin); assert(ref_my <= c->ymax); ref_score= c->sub_motion_search(&s->m, &ref_mx, &ref_my, ref_score, 0, 0, level-LOG2_MB_SIZE+4, block_w); ref_score= ff_get_mb_score(&s->m, ref_mx, ref_my, 0, 0, level-LOG2_MB_SIZE+4, block_w, 0); ref_score+= 2*av_log2(2*ref)*c->penalty_factor; if(s->ref_mvs[ref]){ s->ref_mvs[ref][index][0]= ref_mx; s->ref_mvs[ref][index][1]= ref_my; s->ref_scores[ref][index]= ref_score; } if(score > ref_score){ score= ref_score; best_ref= ref; mx= ref_mx; my= ref_my; } } //FIXME if mb_cmp != SSE then intra cannot be compared currently and mb_penalty vs. lambda2 // subpel search base_bits= get_rac_count(&s->c) - 8*(s->c.bytestream - s->c.bytestream_start); pc= s->c; pc.bytestream_start= pc.bytestream= p_buffer; //FIXME end/start? and at the other stoo memcpy(p_state, s->block_state, sizeof(s->block_state)); if(level!=s->block_max_depth) put_rac(&pc, &p_state[4 + s_context], 1); put_rac(&pc, &p_state[1 + left->type + top->type], 0); if(s->ref_frames > 1) put_symbol(&pc, &p_state[128 + 1024 + 32*ref_context], best_ref, 0); pred_mv(s, &pmx, &pmy, best_ref, left, top, tr); put_symbol(&pc, &p_state[128 + 32*(mx_context + 16*!!best_ref)], mx - pmx, 1); put_symbol(&pc, &p_state[128 + 32*(my_context + 16*!!best_ref)], my - pmy, 1); p_len= pc.bytestream - pc.bytestream_start; score += (s->lambda2*(get_rac_count(&pc)-base_bits))>>FF_LAMBDA_SHIFT; block_s= block_w*block_w; sum = pix_sum(current_data[0], stride, block_w); l= (sum + block_s/2)/block_s; iscore = pix_norm1(current_data[0], stride, block_w) - 2*l*sum + l*l*block_s; block_s= block_w*block_w>>2; sum = pix_sum(current_data[1], uvstride, block_w>>1); cb= (sum + block_s/2)/block_s; // iscore += pix_norm1(&current_mb[1][0], uvstride, block_w>>1) - 2*cb*sum + cb*cb*block_s; sum = pix_sum(current_data[2], uvstride, block_w>>1); cr= (sum + block_s/2)/block_s; // iscore += pix_norm1(&current_mb[2][0], uvstride, block_w>>1) - 2*cr*sum + cr*cr*block_s; ic= s->c; ic.bytestream_start= ic.bytestream= i_buffer; //FIXME end/start? and at the other stoo memcpy(i_state, s->block_state, sizeof(s->block_state)); if(level!=s->block_max_depth) put_rac(&ic, &i_state[4 + s_context], 1); put_rac(&ic, &i_state[1 + left->type + top->type], 1); put_symbol(&ic, &i_state[32], l-pl , 1); put_symbol(&ic, &i_state[64], cb-pcb, 1); put_symbol(&ic, &i_state[96], cr-pcr, 1); i_len= ic.bytestream - ic.bytestream_start; iscore += (s->lambda2*(get_rac_count(&ic)-base_bits))>>FF_LAMBDA_SHIFT; // assert(score==256*256*256*64-1); assert(iscore < 255*255*256 + s->lambda2*10); assert(iscore >= 0); assert(l>=0 && l<=255); assert(pl>=0 && pl<=255); if(level==0){ int varc= iscore >> 8; int vard= score >> 8; if (vard <= 64 || vard < varc) c->scene_change_score+= ff_sqrt(vard) - ff_sqrt(varc); else c->scene_change_score+= s->m.qscale; } if(level!=s->block_max_depth){ put_rac(&s->c, &s->block_state[4 + s_context], 0); score2 = encode_q_branch(s, level+1, 2*x+0, 2*y+0); score2+= encode_q_branch(s, level+1, 2*x+1, 2*y+0); score2+= encode_q_branch(s, level+1, 2*x+0, 2*y+1); score2+= encode_q_branch(s, level+1, 2*x+1, 2*y+1); score2+= s->lambda2>>FF_LAMBDA_SHIFT; //FIXME exact split overhead if(score2 < score && score2 < iscore) return score2; } if(iscore < score){ pred_mv(s, &pmx, &pmy, 0, left, top, tr); memcpy(pbbak, i_buffer, i_len); s->c= ic; s->c.bytestream_start= pbbak_start; s->c.bytestream= pbbak + i_len; set_blocks(s, level, x, y, l, cb, cr, pmx, pmy, 0, BLOCK_INTRA); memcpy(s->block_state, i_state, sizeof(s->block_state)); return iscore; }else{ memcpy(pbbak, p_buffer, p_len); s->c= pc; s->c.bytestream_start= pbbak_start; s->c.bytestream= pbbak + p_len; set_blocks(s, level, x, y, pl, pcb, pcr, mx, my, best_ref, 0); memcpy(s->block_state, p_state, sizeof(s->block_state)); return score; } } static void encode_q_branch2(SnowContext *s, int level, int x, int y){ const int w= s->b_width << s->block_max_depth; const int rem_depth= s->block_max_depth - level; const int index= (x + y*w) << rem_depth; int trx= (x+1)<<rem_depth; BlockNode *b= &s->block[index]; const BlockNode *left = x ? &s->block[index-1] : &null_block; const BlockNode *top = y ? &s->block[index-w] : &null_block; const BlockNode *tl = y && x ? &s->block[index-w-1] : left; const BlockNode *tr = y && trx<w && ((x&1)==0 || level==0) ? &s->block[index-w+(1<<rem_depth)] : tl; //FIXME use lt int pl = left->color[0]; int pcb= left->color[1]; int pcr= left->color[2]; int pmx, pmy; int ref_context= av_log2(2*left->ref) + av_log2(2*top->ref); int mx_context= av_log2(2*FFABS(left->mx - top->mx)) + 16*!!b->ref; int my_context= av_log2(2*FFABS(left->my - top->my)) + 16*!!b->ref; int s_context= 2*left->level + 2*top->level + tl->level + tr->level; if(s->keyframe){ set_blocks(s, level, x, y, pl, pcb, pcr, 0, 0, 0, BLOCK_INTRA); return; } if(level!=s->block_max_depth){ if(same_block(b,b+1) && same_block(b,b+w) && same_block(b,b+w+1)){ put_rac(&s->c, &s->block_state[4 + s_context], 1); }else{ put_rac(&s->c, &s->block_state[4 + s_context], 0); encode_q_branch2(s, level+1, 2*x+0, 2*y+0); encode_q_branch2(s, level+1, 2*x+1, 2*y+0); encode_q_branch2(s, level+1, 2*x+0, 2*y+1); encode_q_branch2(s, level+1, 2*x+1, 2*y+1); return; } } if(b->type & BLOCK_INTRA){ pred_mv(s, &pmx, &pmy, 0, left, top, tr); put_rac(&s->c, &s->block_state[1 + (left->type&1) + (top->type&1)], 1); put_symbol(&s->c, &s->block_state[32], b->color[0]-pl , 1); put_symbol(&s->c, &s->block_state[64], b->color[1]-pcb, 1); put_symbol(&s->c, &s->block_state[96], b->color[2]-pcr, 1); set_blocks(s, level, x, y, b->color[0], b->color[1], b->color[2], pmx, pmy, 0, BLOCK_INTRA); }else{ pred_mv(s, &pmx, &pmy, b->ref, left, top, tr); put_rac(&s->c, &s->block_state[1 + (left->type&1) + (top->type&1)], 0); if(s->ref_frames > 1) put_symbol(&s->c, &s->block_state[128 + 1024 + 32*ref_context], b->ref, 0); put_symbol(&s->c, &s->block_state[128 + 32*mx_context], b->mx - pmx, 1); put_symbol(&s->c, &s->block_state[128 + 32*my_context], b->my - pmy, 1); set_blocks(s, level, x, y, pl, pcb, pcr, b->mx, b->my, b->ref, 0); } } static int get_dc(SnowContext *s, int mb_x, int mb_y, int plane_index){ int i, x2, y2; Plane *p= &s->plane[plane_index]; const int block_size = MB_SIZE >> s->block_max_depth; const int block_w = plane_index ? block_size/2 : block_size; const uint8_t *obmc = plane_index ? obmc_tab[s->block_max_depth+1] : obmc_tab[s->block_max_depth]; const int obmc_stride= plane_index ? block_size : 2*block_size; const int ref_stride= s->current_picture.linesize[plane_index]; uint8_t *src= s-> input_picture.data[plane_index]; IDWTELEM *dst= (IDWTELEM*)s->m.obmc_scratchpad + plane_index*block_size*block_size*4; //FIXME change to unsigned const int b_stride = s->b_width << s->block_max_depth; const int w= p->width; const int h= p->height; int index= mb_x + mb_y*b_stride; BlockNode *b= &s->block[index]; BlockNode backup= *b; int ab=0; int aa=0; b->type|= BLOCK_INTRA; b->color[plane_index]= 0; memset(dst, 0, obmc_stride*obmc_stride*sizeof(IDWTELEM)); for(i=0; i<4; i++){ int mb_x2= mb_x + (i &1) - 1; int mb_y2= mb_y + (i>>1) - 1; int x= block_w*mb_x2 + block_w/2; int y= block_w*mb_y2 + block_w/2; add_yblock(s, 0, NULL, dst + ((i&1)+(i>>1)*obmc_stride)*block_w, NULL, obmc, x, y, block_w, block_w, w, h, obmc_stride, ref_stride, obmc_stride, mb_x2, mb_y2, 0, 0, plane_index); for(y2= FFMAX(y, 0); y2<FFMIN(h, y+block_w); y2++){ for(x2= FFMAX(x, 0); x2<FFMIN(w, x+block_w); x2++){ int index= x2-(block_w*mb_x - block_w/2) + (y2-(block_w*mb_y - block_w/2))*obmc_stride; int obmc_v= obmc[index]; int d; if(y<0) obmc_v += obmc[index + block_w*obmc_stride]; if(x<0) obmc_v += obmc[index + block_w]; if(y+block_w>h) obmc_v += obmc[index - block_w*obmc_stride]; if(x+block_w>w) obmc_v += obmc[index - block_w]; //FIXME precalculate this or simplify it somehow else d = -dst[index] + (1<<(FRAC_BITS-1)); dst[index] = d; ab += (src[x2 + y2*ref_stride] - (d>>FRAC_BITS)) * obmc_v; aa += obmc_v * obmc_v; //FIXME precalculate this } } } *b= backup; return av_clip(((ab<<LOG2_OBMC_MAX) + aa/2)/aa, 0, 255); //FIXME we should not need clipping } static inline int get_block_bits(SnowContext *s, int x, int y, int w){ const int b_stride = s->b_width << s->block_max_depth; const int b_height = s->b_height<< s->block_max_depth; int index= x + y*b_stride; const BlockNode *b = &s->block[index]; const BlockNode *left = x ? &s->block[index-1] : &null_block; const BlockNode *top = y ? &s->block[index-b_stride] : &null_block; const BlockNode *tl = y && x ? &s->block[index-b_stride-1] : left; const BlockNode *tr = y && x+w<b_stride ? &s->block[index-b_stride+w] : tl; int dmx, dmy; // int mx_context= av_log2(2*FFABS(left->mx - top->mx)); // int my_context= av_log2(2*FFABS(left->my - top->my)); if(x<0 || x>=b_stride || y>=b_height) return 0; /* 1 0 0 01X 1-2 1 001XX 3-6 2-3 0001XXX 7-14 4-7 00001XXXX 15-30 8-15 */ //FIXME try accurate rate //FIXME intra and inter predictors if surrounding blocks are not the same type if(b->type & BLOCK_INTRA){ return 3+2*( av_log2(2*FFABS(left->color[0] - b->color[0])) + av_log2(2*FFABS(left->color[1] - b->color[1])) + av_log2(2*FFABS(left->color[2] - b->color[2]))); }else{ pred_mv(s, &dmx, &dmy, b->ref, left, top, tr); dmx-= b->mx; dmy-= b->my; return 2*(1 + av_log2(2*FFABS(dmx)) //FIXME kill the 2* can be merged in lambda + av_log2(2*FFABS(dmy)) + av_log2(2*b->ref)); } } static int get_block_rd(SnowContext *s, int mb_x, int mb_y, int plane_index, const uint8_t *obmc_edged){ Plane *p= &s->plane[plane_index]; const int block_size = MB_SIZE >> s->block_max_depth; const int block_w = plane_index ? block_size/2 : block_size; const int obmc_stride= plane_index ? block_size : 2*block_size; const int ref_stride= s->current_picture.linesize[plane_index]; uint8_t *dst= s->current_picture.data[plane_index]; uint8_t *src= s-> input_picture.data[plane_index]; IDWTELEM *pred= (IDWTELEM*)s->m.obmc_scratchpad + plane_index*block_size*block_size*4; uint8_t *cur = s->scratchbuf; uint8_t tmp[ref_stride*(2*MB_SIZE+HTAPS_MAX-1)]; const int b_stride = s->b_width << s->block_max_depth; const int b_height = s->b_height<< s->block_max_depth; const int w= p->width; const int h= p->height; int distortion; int rate= 0; const int penalty_factor= get_penalty_factor(s->lambda, s->lambda2, s->avctx->me_cmp); int sx= block_w*mb_x - block_w/2; int sy= block_w*mb_y - block_w/2; int x0= FFMAX(0,-sx); int y0= FFMAX(0,-sy); int x1= FFMIN(block_w*2, w-sx); int y1= FFMIN(block_w*2, h-sy); int i,x,y; pred_block(s, cur, tmp, ref_stride, sx, sy, block_w*2, block_w*2, &s->block[mb_x + mb_y*b_stride], plane_index, w, h); for(y=y0; y<y1; y++){ const uint8_t *obmc1= obmc_edged + y*obmc_stride; const IDWTELEM *pred1 = pred + y*obmc_stride; uint8_t *cur1 = cur + y*ref_stride; uint8_t *dst1 = dst + sx + (sy+y)*ref_stride; for(x=x0; x<x1; x++){ #if FRAC_BITS >= LOG2_OBMC_MAX int v = (cur1[x] * obmc1[x]) << (FRAC_BITS - LOG2_OBMC_MAX); #else int v = (cur1[x] * obmc1[x] + (1<<(LOG2_OBMC_MAX - FRAC_BITS-1))) >> (LOG2_OBMC_MAX - FRAC_BITS); #endif v = (v + pred1[x]) >> FRAC_BITS; if(v&(~255)) v= ~(v>>31); dst1[x] = v; } } /* copy the regions where obmc[] = (uint8_t)256 */ if(LOG2_OBMC_MAX == 8 && (mb_x == 0 || mb_x == b_stride-1) && (mb_y == 0 || mb_y == b_height-1)){ if(mb_x == 0) x1 = block_w; else x0 = block_w; if(mb_y == 0) y1 = block_w; else y0 = block_w; for(y=y0; y<y1; y++) memcpy(dst + sx+x0 + (sy+y)*ref_stride, cur + x0 + y*ref_stride, x1-x0); } if(block_w==16){ /* FIXME rearrange dsputil to fit 32x32 cmp functions */ /* FIXME check alignment of the cmp wavelet vs the encoding wavelet */ /* FIXME cmps overlap but do not cover the wavelet's whole support. * So improving the score of one block is not strictly guaranteed * to improve the score of the whole frame, thus iterative motion * estimation does not always converge. */ if(s->avctx->me_cmp == FF_CMP_W97) distortion = ff_w97_32_c(&s->m, src + sx + sy*ref_stride, dst + sx + sy*ref_stride, ref_stride, 32); else if(s->avctx->me_cmp == FF_CMP_W53) distortion = ff_w53_32_c(&s->m, src + sx + sy*ref_stride, dst + sx + sy*ref_stride, ref_stride, 32); else{ distortion = 0; for(i=0; i<4; i++){ int off = sx+16*(i&1) + (sy+16*(i>>1))*ref_stride; distortion += s->dsp.me_cmp[0](&s->m, src + off, dst + off, ref_stride, 16); } } }else{ assert(block_w==8); distortion = s->dsp.me_cmp[0](&s->m, src + sx + sy*ref_stride, dst + sx + sy*ref_stride, ref_stride, block_w*2); } if(plane_index==0){ for(i=0; i<4; i++){ /* ..RRr * .RXx. * rxx.. */ rate += get_block_bits(s, mb_x + (i&1) - (i>>1), mb_y + (i>>1), 1); } if(mb_x == b_stride-2) rate += get_block_bits(s, mb_x + 1, mb_y + 1, 1); } return distortion + rate*penalty_factor; } static int get_4block_rd(SnowContext *s, int mb_x, int mb_y, int plane_index){ int i, y2; Plane *p= &s->plane[plane_index]; const int block_size = MB_SIZE >> s->block_max_depth; const int block_w = plane_index ? block_size/2 : block_size; const uint8_t *obmc = plane_index ? obmc_tab[s->block_max_depth+1] : obmc_tab[s->block_max_depth]; const int obmc_stride= plane_index ? block_size : 2*block_size; const int ref_stride= s->current_picture.linesize[plane_index]; uint8_t *dst= s->current_picture.data[plane_index]; uint8_t *src= s-> input_picture.data[plane_index]; //FIXME zero_dst is const but add_yblock changes dst if add is 0 (this is never the case for dst=zero_dst // const has only been removed from zero_dst to suppress a warning static IDWTELEM zero_dst[4096]; //FIXME const int b_stride = s->b_width << s->block_max_depth; const int w= p->width; const int h= p->height; int distortion= 0; int rate= 0; const int penalty_factor= get_penalty_factor(s->lambda, s->lambda2, s->avctx->me_cmp); for(i=0; i<9; i++){ int mb_x2= mb_x + (i%3) - 1; int mb_y2= mb_y + (i/3) - 1; int x= block_w*mb_x2 + block_w/2; int y= block_w*mb_y2 + block_w/2; add_yblock(s, 0, NULL, zero_dst, dst, obmc, x, y, block_w, block_w, w, h, /*dst_stride*/0, ref_stride, obmc_stride, mb_x2, mb_y2, 1, 1, plane_index); //FIXME find a cleaner/simpler way to skip the outside stuff for(y2= y; y2<0; y2++) memcpy(dst + x + y2*ref_stride, src + x + y2*ref_stride, block_w); for(y2= h; y2<y+block_w; y2++) memcpy(dst + x + y2*ref_stride, src + x + y2*ref_stride, block_w); if(x<0){ for(y2= y; y2<y+block_w; y2++) memcpy(dst + x + y2*ref_stride, src + x + y2*ref_stride, -x); } if(x+block_w > w){ for(y2= y; y2<y+block_w; y2++) memcpy(dst + w + y2*ref_stride, src + w + y2*ref_stride, x+block_w - w); } assert(block_w== 8 || block_w==16); distortion += s->dsp.me_cmp[block_w==8](&s->m, src + x + y*ref_stride, dst + x + y*ref_stride, ref_stride, block_w); } if(plane_index==0){ BlockNode *b= &s->block[mb_x+mb_y*b_stride]; int merged= same_block(b,b+1) && same_block(b,b+b_stride) && same_block(b,b+b_stride+1); /* ..RRRr * .RXXx. * .RXXx. * rxxx. */ if(merged) rate = get_block_bits(s, mb_x, mb_y, 2); for(i=merged?4:0; i<9; i++){ static const int dxy[9][2] = {{0,0},{1,0},{0,1},{1,1},{2,0},{2,1},{-1,2},{0,2},{1,2}}; rate += get_block_bits(s, mb_x + dxy[i][0], mb_y + dxy[i][1], 1); } } return distortion + rate*penalty_factor; } static int encode_subband_c0run(SnowContext *s, SubBand *b, IDWTELEM *src, IDWTELEM *parent, int stride, int orientation){ const int w= b->width; const int h= b->height; int x, y; if(1){ int run=0; int runs[w*h]; int run_index=0; int max_index; for(y=0; y<h; y++){ for(x=0; x<w; x++){ int v, p=0; int /*ll=0, */l=0, lt=0, t=0, rt=0; v= src[x + y*stride]; if(y){ t= src[x + (y-1)*stride]; if(x){ lt= src[x - 1 + (y-1)*stride]; } if(x + 1 < w){ rt= src[x + 1 + (y-1)*stride]; } } if(x){ l= src[x - 1 + y*stride]; /*if(x > 1){ if(orientation==1) ll= src[y + (x-2)*stride]; else ll= src[x - 2 + y*stride]; }*/ } if(parent){ int px= x>>1; int py= y>>1; if(px<b->parent->width && py<b->parent->height) p= parent[px + py*2*stride]; } if(!(/*ll|*/l|lt|t|rt|p)){ if(v){ runs[run_index++]= run; run=0; }else{ run++; } } } } max_index= run_index; runs[run_index++]= run; run_index=0; run= runs[run_index++]; put_symbol2(&s->c, b->state[30], max_index, 0); if(run_index <= max_index) put_symbol2(&s->c, b->state[1], run, 3); for(y=0; y<h; y++){ if(s->c.bytestream_end - s->c.bytestream < w*40){ av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n"); return -1; } for(x=0; x<w; x++){ int v, p=0; int /*ll=0, */l=0, lt=0, t=0, rt=0; v= src[x + y*stride]; if(y){ t= src[x + (y-1)*stride]; if(x){ lt= src[x - 1 + (y-1)*stride]; } if(x + 1 < w){ rt= src[x + 1 + (y-1)*stride]; } } if(x){ l= src[x - 1 + y*stride]; /*if(x > 1){ if(orientation==1) ll= src[y + (x-2)*stride]; else ll= src[x - 2 + y*stride]; }*/ } if(parent){ int px= x>>1; int py= y>>1; if(px<b->parent->width && py<b->parent->height) p= parent[px + py*2*stride]; } if(/*ll|*/l|lt|t|rt|p){ int context= av_log2(/*FFABS(ll) + */3*FFABS(l) + FFABS(lt) + 2*FFABS(t) + FFABS(rt) + FFABS(p)); put_rac(&s->c, &b->state[0][context], !!v); }else{ if(!run){ run= runs[run_index++]; if(run_index <= max_index) put_symbol2(&s->c, b->state[1], run, 3); assert(v); }else{ run--; assert(!v); } } if(v){ int context= av_log2(/*FFABS(ll) + */3*FFABS(l) + FFABS(lt) + 2*FFABS(t) + FFABS(rt) + FFABS(p)); int l2= 2*FFABS(l) + (l<0); int t2= 2*FFABS(t) + (t<0); put_symbol2(&s->c, b->state[context + 2], FFABS(v)-1, context-4); put_rac(&s->c, &b->state[0][16 + 1 + 3 + quant3bA[l2&0xFF] + 3*quant3bA[t2&0xFF]], v<0); } } } } return 0; } static int encode_subband(SnowContext *s, SubBand *b, IDWTELEM *src, IDWTELEM *parent, int stride, int orientation){ // encode_subband_qtree(s, b, src, parent, stride, orientation); // encode_subband_z0run(s, b, src, parent, stride, orientation); return encode_subband_c0run(s, b, src, parent, stride, orientation); // encode_subband_dzr(s, b, src, parent, stride, orientation); } static av_always_inline int check_block(SnowContext *s, int mb_x, int mb_y, int p[3], int intra, const uint8_t *obmc_edged, int *best_rd){ const int b_stride= s->b_width << s->block_max_depth; BlockNode *block= &s->block[mb_x + mb_y * b_stride]; BlockNode backup= *block; int rd, index, value; assert(mb_x>=0 && mb_y>=0); assert(mb_x<b_stride); if(intra){ block->color[0] = p[0]; block->color[1] = p[1]; block->color[2] = p[2]; block->type |= BLOCK_INTRA; }else{ index= (p[0] + 31*p[1]) & (ME_CACHE_SIZE-1); value= s->me_cache_generation + (p[0]>>10) + (p[1]<<6) + (block->ref<<12); if(s->me_cache[index] == value) return 0; s->me_cache[index]= value; block->mx= p[0]; block->my= p[1]; block->type &= ~BLOCK_INTRA; } rd= get_block_rd(s, mb_x, mb_y, 0, obmc_edged); //FIXME chroma if(rd < *best_rd){ *best_rd= rd; return 1; }else{ *block= backup; return 0; } } /* special case for int[2] args we discard afterwards, * fixes compilation problem with gcc 2.95 */ static av_always_inline int check_block_inter(SnowContext *s, int mb_x, int mb_y, int p0, int p1, const uint8_t *obmc_edged, int *best_rd){ int p[2] = {p0, p1}; return check_block(s, mb_x, mb_y, p, 0, obmc_edged, best_rd); } static av_always_inline int check_4block_inter(SnowContext *s, int mb_x, int mb_y, int p0, int p1, int ref, int *best_rd){ const int b_stride= s->b_width << s->block_max_depth; BlockNode *block= &s->block[mb_x + mb_y * b_stride]; BlockNode backup[4]= {block[0], block[1], block[b_stride], block[b_stride+1]}; int rd, index, value; assert(mb_x>=0 && mb_y>=0); assert(mb_x<b_stride); assert(((mb_x|mb_y)&1) == 0); index= (p0 + 31*p1) & (ME_CACHE_SIZE-1); value= s->me_cache_generation + (p0>>10) + (p1<<6) + (block->ref<<12); if(s->me_cache[index] == value) return 0; s->me_cache[index]= value; block->mx= p0; block->my= p1; block->ref= ref; block->type &= ~BLOCK_INTRA; block[1]= block[b_stride]= block[b_stride+1]= *block; rd= get_4block_rd(s, mb_x, mb_y, 0); //FIXME chroma if(rd < *best_rd){ *best_rd= rd; return 1; }else{ block[0]= backup[0]; block[1]= backup[1]; block[b_stride]= backup[2]; block[b_stride+1]= backup[3]; return 0; } } static void iterative_me(SnowContext *s){ int pass, mb_x, mb_y; const int b_width = s->b_width << s->block_max_depth; const int b_height= s->b_height << s->block_max_depth; const int b_stride= b_width; int color[3]; { RangeCoder r = s->c; uint8_t state[sizeof(s->block_state)]; memcpy(state, s->block_state, sizeof(s->block_state)); for(mb_y= 0; mb_y<s->b_height; mb_y++) for(mb_x= 0; mb_x<s->b_width; mb_x++) encode_q_branch(s, 0, mb_x, mb_y); s->c = r; memcpy(s->block_state, state, sizeof(s->block_state)); } for(pass=0; pass<25; pass++){ int change= 0; for(mb_y= 0; mb_y<b_height; mb_y++){ for(mb_x= 0; mb_x<b_width; mb_x++){ int dia_change, i, j, ref; int best_rd= INT_MAX, ref_rd; BlockNode backup, ref_b; const int index= mb_x + mb_y * b_stride; BlockNode *block= &s->block[index]; BlockNode *tb = mb_y ? &s->block[index-b_stride ] : NULL; BlockNode *lb = mb_x ? &s->block[index -1] : NULL; BlockNode *rb = mb_x+1<b_width ? &s->block[index +1] : NULL; BlockNode *bb = mb_y+1<b_height ? &s->block[index+b_stride ] : NULL; BlockNode *tlb= mb_x && mb_y ? &s->block[index-b_stride-1] : NULL; BlockNode *trb= mb_x+1<b_width && mb_y ? &s->block[index-b_stride+1] : NULL; BlockNode *blb= mb_x && mb_y+1<b_height ? &s->block[index+b_stride-1] : NULL; BlockNode *brb= mb_x+1<b_width && mb_y+1<b_height ? &s->block[index+b_stride+1] : NULL; const int b_w= (MB_SIZE >> s->block_max_depth); uint8_t obmc_edged[b_w*2][b_w*2]; if(pass && (block->type & BLOCK_OPT)) continue; block->type |= BLOCK_OPT; backup= *block; if(!s->me_cache_generation) memset(s->me_cache, 0, sizeof(s->me_cache)); s->me_cache_generation += 1<<22; //FIXME precalculate { int x, y; memcpy(obmc_edged, obmc_tab[s->block_max_depth], b_w*b_w*4); if(mb_x==0) for(y=0; y<b_w*2; y++) memset(obmc_edged[y], obmc_edged[y][0] + obmc_edged[y][b_w-1], b_w); if(mb_x==b_stride-1) for(y=0; y<b_w*2; y++) memset(obmc_edged[y]+b_w, obmc_edged[y][b_w] + obmc_edged[y][b_w*2-1], b_w); if(mb_y==0){ for(x=0; x<b_w*2; x++) obmc_edged[0][x] += obmc_edged[b_w-1][x]; for(y=1; y<b_w; y++) memcpy(obmc_edged[y], obmc_edged[0], b_w*2); } if(mb_y==b_height-1){ for(x=0; x<b_w*2; x++) obmc_edged[b_w*2-1][x] += obmc_edged[b_w][x]; for(y=b_w; y<b_w*2-1; y++) memcpy(obmc_edged[y], obmc_edged[b_w*2-1], b_w*2); } } //skip stuff outside the picture if(mb_x==0 || mb_y==0 || mb_x==b_width-1 || mb_y==b_height-1){ uint8_t *src= s-> input_picture.data[0]; uint8_t *dst= s->current_picture.data[0]; const int stride= s->current_picture.linesize[0]; const int block_w= MB_SIZE >> s->block_max_depth; const int sx= block_w*mb_x - block_w/2; const int sy= block_w*mb_y - block_w/2; const int w= s->plane[0].width; const int h= s->plane[0].height; int y; for(y=sy; y<0; y++) memcpy(dst + sx + y*stride, src + sx + y*stride, block_w*2); for(y=h; y<sy+block_w*2; y++) memcpy(dst + sx + y*stride, src + sx + y*stride, block_w*2); if(sx<0){ for(y=sy; y<sy+block_w*2; y++) memcpy(dst + sx + y*stride, src + sx + y*stride, -sx); } if(sx+block_w*2 > w){ for(y=sy; y<sy+block_w*2; y++) memcpy(dst + w + y*stride, src + w + y*stride, sx+block_w*2 - w); } } // intra(black) = neighbors' contribution to the current block for(i=0; i<3; i++) color[i]= get_dc(s, mb_x, mb_y, i); // get previous score (cannot be cached due to OBMC) if(pass > 0 && (block->type&BLOCK_INTRA)){ int color0[3]= {block->color[0], block->color[1], block->color[2]}; check_block(s, mb_x, mb_y, color0, 1, *obmc_edged, &best_rd); }else check_block_inter(s, mb_x, mb_y, block->mx, block->my, *obmc_edged, &best_rd); ref_b= *block; ref_rd= best_rd; for(ref=0; ref < s->ref_frames; ref++){ int16_t (*mvr)[2]= &s->ref_mvs[ref][index]; if(s->ref_scores[ref][index] > s->ref_scores[ref_b.ref][index]*3/2) //FIXME tune threshold continue; block->ref= ref; best_rd= INT_MAX; check_block_inter(s, mb_x, mb_y, mvr[0][0], mvr[0][1], *obmc_edged, &best_rd); check_block_inter(s, mb_x, mb_y, 0, 0, *obmc_edged, &best_rd); if(tb) check_block_inter(s, mb_x, mb_y, mvr[-b_stride][0], mvr[-b_stride][1], *obmc_edged, &best_rd); if(lb) check_block_inter(s, mb_x, mb_y, mvr[-1][0], mvr[-1][1], *obmc_edged, &best_rd); if(rb) check_block_inter(s, mb_x, mb_y, mvr[1][0], mvr[1][1], *obmc_edged, &best_rd); if(bb) check_block_inter(s, mb_x, mb_y, mvr[b_stride][0], mvr[b_stride][1], *obmc_edged, &best_rd); /* fullpel ME */ //FIXME avoid subpel interpolation / round to nearest integer do{ dia_change=0; for(i=0; i<FFMAX(s->avctx->dia_size, 1); i++){ for(j=0; j<i; j++){ dia_change |= check_block_inter(s, mb_x, mb_y, block->mx+4*(i-j), block->my+(4*j), *obmc_edged, &best_rd); dia_change |= check_block_inter(s, mb_x, mb_y, block->mx-4*(i-j), block->my-(4*j), *obmc_edged, &best_rd); dia_change |= check_block_inter(s, mb_x, mb_y, block->mx+4*(i-j), block->my-(4*j), *obmc_edged, &best_rd); dia_change |= check_block_inter(s, mb_x, mb_y, block->mx-4*(i-j), block->my+(4*j), *obmc_edged, &best_rd); } } }while(dia_change); /* subpel ME */ do{ static const int square[8][2]= {{+1, 0},{-1, 0},{ 0,+1},{ 0,-1},{+1,+1},{-1,-1},{+1,-1},{-1,+1},}; dia_change=0; for(i=0; i<8; i++) dia_change |= check_block_inter(s, mb_x, mb_y, block->mx+square[i][0], block->my+square[i][1], *obmc_edged, &best_rd); }while(dia_change); //FIXME or try the standard 2 pass qpel or similar mvr[0][0]= block->mx; mvr[0][1]= block->my; if(ref_rd > best_rd){ ref_rd= best_rd; ref_b= *block; } } best_rd= ref_rd; *block= ref_b; #if 1 check_block(s, mb_x, mb_y, color, 1, *obmc_edged, &best_rd); //FIXME RD style color selection #endif if(!same_block(block, &backup)){ if(tb ) tb ->type &= ~BLOCK_OPT; if(lb ) lb ->type &= ~BLOCK_OPT; if(rb ) rb ->type &= ~BLOCK_OPT; if(bb ) bb ->type &= ~BLOCK_OPT; if(tlb) tlb->type &= ~BLOCK_OPT; if(trb) trb->type &= ~BLOCK_OPT; if(blb) blb->type &= ~BLOCK_OPT; if(brb) brb->type &= ~BLOCK_OPT; change ++; } } } av_log(s->avctx, AV_LOG_ERROR, "pass:%d changed:%d\n", pass, change); if(!change) break; } if(s->block_max_depth == 1){ int change= 0; for(mb_y= 0; mb_y<b_height; mb_y+=2){ for(mb_x= 0; mb_x<b_width; mb_x+=2){ int i; int best_rd, init_rd; const int index= mb_x + mb_y * b_stride; BlockNode *b[4]; b[0]= &s->block[index]; b[1]= b[0]+1; b[2]= b[0]+b_stride; b[3]= b[2]+1; if(same_block(b[0], b[1]) && same_block(b[0], b[2]) && same_block(b[0], b[3])) continue; if(!s->me_cache_generation) memset(s->me_cache, 0, sizeof(s->me_cache)); s->me_cache_generation += 1<<22; init_rd= best_rd= get_4block_rd(s, mb_x, mb_y, 0); //FIXME more multiref search? check_4block_inter(s, mb_x, mb_y, (b[0]->mx + b[1]->mx + b[2]->mx + b[3]->mx + 2) >> 2, (b[0]->my + b[1]->my + b[2]->my + b[3]->my + 2) >> 2, 0, &best_rd); for(i=0; i<4; i++) if(!(b[i]->type&BLOCK_INTRA)) check_4block_inter(s, mb_x, mb_y, b[i]->mx, b[i]->my, b[i]->ref, &best_rd); if(init_rd != best_rd) change++; } } av_log(s->avctx, AV_LOG_ERROR, "pass:4mv changed:%d\n", change*4); } } static void encode_blocks(SnowContext *s, int search){ int x, y; int w= s->b_width; int h= s->b_height; if(s->avctx->me_method == ME_ITER && !s->keyframe && search) iterative_me(s); for(y=0; y<h; y++){ if(s->c.bytestream_end - s->c.bytestream < w*MB_SIZE*MB_SIZE*3){ //FIXME nicer limit av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n"); return; } for(x=0; x<w; x++){ if(s->avctx->me_method == ME_ITER || !search) encode_q_branch2(s, 0, x, y); else encode_q_branch (s, 0, x, y); } } } static void quantize(SnowContext *s, SubBand *b, IDWTELEM *dst, DWTELEM *src, int stride, int bias){ const int w= b->width; const int h= b->height; const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16); const int qmul= qexp[qlog&(QROOT-1)]<<((qlog>>QSHIFT) + ENCODER_EXTRA_BITS); int x,y, thres1, thres2; if(s->qlog == LOSSLESS_QLOG){ for(y=0; y<h; y++) for(x=0; x<w; x++) dst[x + y*stride]= src[x + y*stride]; return; } bias= bias ? 0 : (3*qmul)>>3; thres1= ((qmul - bias)>>QEXPSHIFT) - 1; thres2= 2*thres1; if(!bias){ for(y=0; y<h; y++){ for(x=0; x<w; x++){ int i= src[x + y*stride]; if((unsigned)(i+thres1) > thres2){ if(i>=0){ i<<= QEXPSHIFT; i/= qmul; //FIXME optimize dst[x + y*stride]= i; }else{ i= -i; i<<= QEXPSHIFT; i/= qmul; //FIXME optimize dst[x + y*stride]= -i; } }else dst[x + y*stride]= 0; } } }else{ for(y=0; y<h; y++){ for(x=0; x<w; x++){ int i= src[x + y*stride]; if((unsigned)(i+thres1) > thres2){ if(i>=0){ i<<= QEXPSHIFT; i= (i + bias) / qmul; //FIXME optimize dst[x + y*stride]= i; }else{ i= -i; i<<= QEXPSHIFT; i= (i + bias) / qmul; //FIXME optimize dst[x + y*stride]= -i; } }else dst[x + y*stride]= 0; } } } } static void dequantize(SnowContext *s, SubBand *b, IDWTELEM *src, int stride){ const int w= b->width; const int h= b->height; const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16); const int qmul= qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT); const int qadd= (s->qbias*qmul)>>QBIAS_SHIFT; int x,y; if(s->qlog == LOSSLESS_QLOG) return; for(y=0; y<h; y++){ for(x=0; x<w; x++){ int i= src[x + y*stride]; if(i<0){ src[x + y*stride]= -((-i*qmul + qadd)>>(QEXPSHIFT)); //FIXME try different bias }else if(i>0){ src[x + y*stride]= (( i*qmul + qadd)>>(QEXPSHIFT)); } } } } static void decorrelate(SnowContext *s, SubBand *b, IDWTELEM *src, int stride, int inverse, int use_median){ const int w= b->width; const int h= b->height; int x,y; for(y=h-1; y>=0; y--){ for(x=w-1; x>=0; x--){ int i= x + y*stride; if(x){ if(use_median){ if(y && x+1<w) src[i] -= mid_pred(src[i - 1], src[i - stride], src[i - stride + 1]); else src[i] -= src[i - 1]; }else{ if(y) src[i] -= mid_pred(src[i - 1], src[i - stride], src[i - 1] + src[i - stride] - src[i - 1 - stride]); else src[i] -= src[i - 1]; } }else{ if(y) src[i] -= src[i - stride]; } } } } static void correlate(SnowContext *s, SubBand *b, IDWTELEM *src, int stride, int inverse, int use_median){ const int w= b->width; const int h= b->height; int x,y; for(y=0; y<h; y++){ for(x=0; x<w; x++){ int i= x + y*stride; if(x){ if(use_median){ if(y && x+1<w) src[i] += mid_pred(src[i - 1], src[i - stride], src[i - stride + 1]); else src[i] += src[i - 1]; }else{ if(y) src[i] += mid_pred(src[i - 1], src[i - stride], src[i - 1] + src[i - stride] - src[i - 1 - stride]); else src[i] += src[i - 1]; } }else{ if(y) src[i] += src[i - stride]; } } } } static void encode_qlogs(SnowContext *s){ int plane_index, level, orientation; for(plane_index=0; plane_index<2; plane_index++){ for(level=0; level<s->spatial_decomposition_count; level++){ for(orientation=level ? 1:0; orientation<4; orientation++){ if(orientation==2) continue; put_symbol(&s->c, s->header_state, s->plane[plane_index].band[level][orientation].qlog, 1); } } } } static void encode_header(SnowContext *s){ int plane_index, i; uint8_t kstate[32]; memset(kstate, MID_STATE, sizeof(kstate)); put_rac(&s->c, kstate, s->keyframe); if(s->keyframe || s->always_reset){ reset_contexts(s); s->last_spatial_decomposition_type= s->last_qlog= s->last_qbias= s->last_mv_scale= s->last_block_max_depth= 0; for(plane_index=0; plane_index<2; plane_index++){ Plane *p= &s->plane[plane_index]; p->last_htaps=0; p->last_diag_mc=0; memset(p->last_hcoeff, 0, sizeof(p->last_hcoeff)); } } if(s->keyframe){ put_symbol(&s->c, s->header_state, s->version, 0); put_rac(&s->c, s->header_state, s->always_reset); put_symbol(&s->c, s->header_state, s->temporal_decomposition_type, 0); put_symbol(&s->c, s->header_state, s->temporal_decomposition_count, 0); put_symbol(&s->c, s->header_state, s->spatial_decomposition_count, 0); put_symbol(&s->c, s->header_state, s->colorspace_type, 0); put_symbol(&s->c, s->header_state, s->chroma_h_shift, 0); put_symbol(&s->c, s->header_state, s->chroma_v_shift, 0); put_rac(&s->c, s->header_state, s->spatial_scalability); // put_rac(&s->c, s->header_state, s->rate_scalability); put_symbol(&s->c, s->header_state, s->max_ref_frames-1, 0); encode_qlogs(s); } if(!s->keyframe){ int update_mc=0; for(plane_index=0; plane_index<2; plane_index++){ Plane *p= &s->plane[plane_index]; update_mc |= p->last_htaps != p->htaps; update_mc |= p->last_diag_mc != p->diag_mc; update_mc |= !!memcmp(p->last_hcoeff, p->hcoeff, sizeof(p->hcoeff)); } put_rac(&s->c, s->header_state, update_mc); if(update_mc){ for(plane_index=0; plane_index<2; plane_index++){ Plane *p= &s->plane[plane_index]; put_rac(&s->c, s->header_state, p->diag_mc); put_symbol(&s->c, s->header_state, p->htaps/2-1, 0); for(i= p->htaps/2; i; i--) put_symbol(&s->c, s->header_state, FFABS(p->hcoeff[i]), 0); } } if(s->last_spatial_decomposition_count != s->spatial_decomposition_count){ put_rac(&s->c, s->header_state, 1); put_symbol(&s->c, s->header_state, s->spatial_decomposition_count, 0); encode_qlogs(s); }else put_rac(&s->c, s->header_state, 0); } put_symbol(&s->c, s->header_state, s->spatial_decomposition_type - s->last_spatial_decomposition_type, 1); put_symbol(&s->c, s->header_state, s->qlog - s->last_qlog , 1); put_symbol(&s->c, s->header_state, s->mv_scale - s->last_mv_scale, 1); put_symbol(&s->c, s->header_state, s->qbias - s->last_qbias , 1); put_symbol(&s->c, s->header_state, s->block_max_depth - s->last_block_max_depth, 1); } static void update_last_header_values(SnowContext *s){ int plane_index; if(!s->keyframe){ for(plane_index=0; plane_index<2; plane_index++){ Plane *p= &s->plane[plane_index]; p->last_diag_mc= p->diag_mc; p->last_htaps = p->htaps; memcpy(p->last_hcoeff, p->hcoeff, sizeof(p->hcoeff)); } } s->last_spatial_decomposition_type = s->spatial_decomposition_type; s->last_qlog = s->qlog; s->last_qbias = s->qbias; s->last_mv_scale = s->mv_scale; s->last_block_max_depth = s->block_max_depth; s->last_spatial_decomposition_count = s->spatial_decomposition_count; } static int qscale2qlog(int qscale){ return rint(QROOT*log(qscale / (float)FF_QP2LAMBDA)/log(2)) + 61*QROOT/8; //<64 >60 } static int ratecontrol_1pass(SnowContext *s, AVFrame *pict) { /* Estimate the frame's complexity as a sum of weighted dwt coefficients. * FIXME we know exact mv bits at this point, * but ratecontrol isn't set up to include them. */ uint32_t coef_sum= 0; int level, orientation, delta_qlog; for(level=0; level<s->spatial_decomposition_count; level++){ for(orientation=level ? 1 : 0; orientation<4; orientation++){ SubBand *b= &s->plane[0].band[level][orientation]; IDWTELEM *buf= b->ibuf; const int w= b->width; const int h= b->height; const int stride= b->stride; const int qlog= av_clip(2*QROOT + b->qlog, 0, QROOT*16); const int qmul= qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT); const int qdiv= (1<<16)/qmul; int x, y; //FIXME this is ugly for(y=0; y<h; y++) for(x=0; x<w; x++) buf[x+y*stride]= b->buf[x+y*stride]; if(orientation==0) decorrelate(s, b, buf, stride, 1, 0); for(y=0; y<h; y++) for(x=0; x<w; x++) coef_sum+= abs(buf[x+y*stride]) * qdiv >> 16; } } /* ugly, ratecontrol just takes a sqrt again */ coef_sum = (uint64_t)coef_sum * coef_sum >> 16; assert(coef_sum < INT_MAX); if(pict->pict_type == FF_I_TYPE){ s->m.current_picture.mb_var_sum= coef_sum; s->m.current_picture.mc_mb_var_sum= 0; }else{ s->m.current_picture.mc_mb_var_sum= coef_sum; s->m.current_picture.mb_var_sum= 0; } pict->quality= ff_rate_estimate_qscale(&s->m, 1); if (pict->quality < 0) return INT_MIN; s->lambda= pict->quality * 3/2; delta_qlog= qscale2qlog(pict->quality) - s->qlog; s->qlog+= delta_qlog; return delta_qlog; } static void calculate_visual_weight(SnowContext *s, Plane *p){ int width = p->width; int height= p->height; int level, orientation, x, y; for(level=0; level<s->spatial_decomposition_count; level++){ for(orientation=level ? 1 : 0; orientation<4; orientation++){ SubBand *b= &p->band[level][orientation]; IDWTELEM *ibuf= b->ibuf; int64_t error=0; memset(s->spatial_idwt_buffer, 0, sizeof(*s->spatial_idwt_buffer)*width*height); ibuf[b->width/2 + b->height/2*b->stride]= 256*16; ff_spatial_idwt(s->spatial_idwt_buffer, width, height, width, s->spatial_decomposition_type, s->spatial_decomposition_count); for(y=0; y<height; y++){ for(x=0; x<width; x++){ int64_t d= s->spatial_idwt_buffer[x + y*width]*16; error += d*d; } } b->qlog= (int)(log(352256.0/sqrt(error)) / log(pow(2.0, 1.0/QROOT))+0.5); } } } static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ SnowContext *s = avctx->priv_data; RangeCoder * const c= &s->c; AVFrame *pict = data; const int width= s->avctx->width; const int height= s->avctx->height; int level, orientation, plane_index, i, y; uint8_t rc_header_bak[sizeof(s->header_state)]; uint8_t rc_block_bak[sizeof(s->block_state)]; ff_init_range_encoder(c, buf, buf_size); ff_build_rac_states(c, 0.05*(1LL<<32), 256-8); for(i=0; i<3; i++){ int shift= !!i; for(y=0; y<(height>>shift); y++) memcpy(&s->input_picture.data[i][y * s->input_picture.linesize[i]], &pict->data[i][y * pict->linesize[i]], width>>shift); } s->new_picture = *pict; s->m.picture_number= avctx->frame_number; if(avctx->flags&CODEC_FLAG_PASS2){ s->m.pict_type = pict->pict_type= s->m.rc_context.entry[avctx->frame_number].new_pict_type; s->keyframe= pict->pict_type==FF_I_TYPE; if(!(avctx->flags&CODEC_FLAG_QSCALE)) { pict->quality= ff_rate_estimate_qscale(&s->m, 0); if (pict->quality < 0) return -1; } }else{ s->keyframe= avctx->gop_size==0 || avctx->frame_number % avctx->gop_size == 0; s->m.pict_type= pict->pict_type= s->keyframe ? FF_I_TYPE : FF_P_TYPE; } if(s->pass1_rc && avctx->frame_number == 0) pict->quality= 2*FF_QP2LAMBDA; if(pict->quality){ s->qlog= qscale2qlog(pict->quality); s->lambda = pict->quality * 3/2; } if(s->qlog < 0 || (!pict->quality && (avctx->flags & CODEC_FLAG_QSCALE))){ s->qlog= LOSSLESS_QLOG; s->lambda = 0; }//else keep previous frame's qlog until after motion estimation frame_start(s); s->m.current_picture_ptr= &s->m.current_picture; s->m.last_picture.pts= s->m.current_picture.pts; s->m.current_picture.pts= pict->pts; if(pict->pict_type == FF_P_TYPE){ int block_width = (width +15)>>4; int block_height= (height+15)>>4; int stride= s->current_picture.linesize[0]; assert(s->current_picture.data[0]); assert(s->last_picture[0].data[0]); s->m.avctx= s->avctx; s->m.current_picture.data[0]= s->current_picture.data[0]; s->m. last_picture.data[0]= s->last_picture[0].data[0]; s->m. new_picture.data[0]= s-> input_picture.data[0]; s->m. last_picture_ptr= &s->m. last_picture; s->m.linesize= s->m. last_picture.linesize[0]= s->m. new_picture.linesize[0]= s->m.current_picture.linesize[0]= stride; s->m.uvlinesize= s->current_picture.linesize[1]; s->m.width = width; s->m.height= height; s->m.mb_width = block_width; s->m.mb_height= block_height; s->m.mb_stride= s->m.mb_width+1; s->m.b8_stride= 2*s->m.mb_width+1; s->m.f_code=1; s->m.pict_type= pict->pict_type; s->m.me_method= s->avctx->me_method; s->m.me.scene_change_score=0; s->m.flags= s->avctx->flags; s->m.quarter_sample= (s->avctx->flags & CODEC_FLAG_QPEL)!=0; s->m.out_format= FMT_H263; s->m.unrestricted_mv= 1; s->m.lambda = s->lambda; s->m.qscale= (s->m.lambda*139 + FF_LAMBDA_SCALE*64) >> (FF_LAMBDA_SHIFT + 7); s->lambda2= s->m.lambda2= (s->m.lambda*s->m.lambda + FF_LAMBDA_SCALE/2) >> FF_LAMBDA_SHIFT; s->m.dsp= s->dsp; //move ff_init_me(&s->m); s->dsp= s->m.dsp; } if(s->pass1_rc){ memcpy(rc_header_bak, s->header_state, sizeof(s->header_state)); memcpy(rc_block_bak, s->block_state, sizeof(s->block_state)); } redo_frame: if(pict->pict_type == FF_I_TYPE) s->spatial_decomposition_count= 5; else s->spatial_decomposition_count= 5; s->m.pict_type = pict->pict_type; s->qbias= pict->pict_type == FF_P_TYPE ? 2 : 0; common_init_after_header(avctx); if(s->last_spatial_decomposition_count != s->spatial_decomposition_count){ for(plane_index=0; plane_index<3; plane_index++){ calculate_visual_weight(s, &s->plane[plane_index]); } } encode_header(s); s->m.misc_bits = 8*(s->c.bytestream - s->c.bytestream_start); encode_blocks(s, 1); s->m.mv_bits = 8*(s->c.bytestream - s->c.bytestream_start) - s->m.misc_bits; for(plane_index=0; plane_index<3; plane_index++){ Plane *p= &s->plane[plane_index]; int w= p->width; int h= p->height; int x, y; // int bits= put_bits_count(&s->c.pb); if(!(avctx->flags2 & CODEC_FLAG2_MEMC_ONLY)){ //FIXME optimize if(pict->data[plane_index]) //FIXME gray hack for(y=0; y<h; y++){ for(x=0; x<w; x++){ s->spatial_idwt_buffer[y*w + x]= pict->data[plane_index][y*pict->linesize[plane_index] + x]<<FRAC_BITS; } } predict_plane(s, s->spatial_idwt_buffer, plane_index, 0); if( plane_index==0 && pict->pict_type == FF_P_TYPE && !(avctx->flags&CODEC_FLAG_PASS2) && s->m.me.scene_change_score > s->avctx->scenechange_threshold){ ff_init_range_encoder(c, buf, buf_size); ff_build_rac_states(c, 0.05*(1LL<<32), 256-8); pict->pict_type= FF_I_TYPE; s->keyframe=1; s->current_picture.key_frame=1; goto redo_frame; } if(s->qlog == LOSSLESS_QLOG){ for(y=0; y<h; y++){ for(x=0; x<w; x++){ s->spatial_dwt_buffer[y*w + x]= (s->spatial_idwt_buffer[y*w + x] + (1<<(FRAC_BITS-1))-1)>>FRAC_BITS; } } }else{ for(y=0; y<h; y++){ for(x=0; x<w; x++){ s->spatial_dwt_buffer[y*w + x]=s->spatial_idwt_buffer[y*w + x]<<ENCODER_EXTRA_BITS; } } } /* if(QUANTIZE2) dwt_quantize(s, p, s->spatial_dwt_buffer, w, h, w, s->spatial_decomposition_type); else*/ ff_spatial_dwt(s->spatial_dwt_buffer, w, h, w, s->spatial_decomposition_type, s->spatial_decomposition_count); if(s->pass1_rc && plane_index==0){ int delta_qlog = ratecontrol_1pass(s, pict); if (delta_qlog <= INT_MIN) return -1; if(delta_qlog){ //reordering qlog in the bitstream would eliminate this reset ff_init_range_encoder(c, buf, buf_size); memcpy(s->header_state, rc_header_bak, sizeof(s->header_state)); memcpy(s->block_state, rc_block_bak, sizeof(s->block_state)); encode_header(s); encode_blocks(s, 0); } } for(level=0; level<s->spatial_decomposition_count; level++){ for(orientation=level ? 1 : 0; orientation<4; orientation++){ SubBand *b= &p->band[level][orientation]; if(!QUANTIZE2) quantize(s, b, b->ibuf, b->buf, b->stride, s->qbias); if(orientation==0) decorrelate(s, b, b->ibuf, b->stride, pict->pict_type == FF_P_TYPE, 0); encode_subband(s, b, b->ibuf, b->parent ? b->parent->ibuf : NULL, b->stride, orientation); assert(b->parent==NULL || b->parent->stride == b->stride*2); if(orientation==0) correlate(s, b, b->ibuf, b->stride, 1, 0); } } for(level=0; level<s->spatial_decomposition_count; level++){ for(orientation=level ? 1 : 0; orientation<4; orientation++){ SubBand *b= &p->band[level][orientation]; dequantize(s, b, b->ibuf, b->stride); } } ff_spatial_idwt(s->spatial_idwt_buffer, w, h, w, s->spatial_decomposition_type, s->spatial_decomposition_count); if(s->qlog == LOSSLESS_QLOG){ for(y=0; y<h; y++){ for(x=0; x<w; x++){ s->spatial_idwt_buffer[y*w + x]<<=FRAC_BITS; } } } predict_plane(s, s->spatial_idwt_buffer, plane_index, 1); }else{ //ME/MC only if(pict->pict_type == FF_I_TYPE){ for(y=0; y<h; y++){ for(x=0; x<w; x++){ s->current_picture.data[plane_index][y*s->current_picture.linesize[plane_index] + x]= pict->data[plane_index][y*pict->linesize[plane_index] + x]; } } }else{ memset(s->spatial_idwt_buffer, 0, sizeof(IDWTELEM)*w*h); predict_plane(s, s->spatial_idwt_buffer, plane_index, 1); } } if(s->avctx->flags&CODEC_FLAG_PSNR){ int64_t error= 0; if(pict->data[plane_index]) //FIXME gray hack for(y=0; y<h; y++){ for(x=0; x<w; x++){ int d= s->current_picture.data[plane_index][y*s->current_picture.linesize[plane_index] + x] - pict->data[plane_index][y*pict->linesize[plane_index] + x]; error += d*d; } } s->avctx->error[plane_index] += error; s->current_picture.error[plane_index] = error; } } update_last_header_values(s); release_buffer(avctx); s->current_picture.coded_picture_number = avctx->frame_number; s->current_picture.pict_type = pict->pict_type; s->current_picture.quality = pict->quality; s->m.frame_bits = 8*(s->c.bytestream - s->c.bytestream_start); s->m.p_tex_bits = s->m.frame_bits - s->m.misc_bits - s->m.mv_bits; s->m.current_picture.display_picture_number = s->m.current_picture.coded_picture_number = avctx->frame_number; s->m.current_picture.quality = pict->quality; s->m.total_bits += 8*(s->c.bytestream - s->c.bytestream_start); if(s->pass1_rc) if (ff_rate_estimate_qscale(&s->m, 0) < 0) return -1; if(avctx->flags&CODEC_FLAG_PASS1) ff_write_pass1_stats(&s->m); s->m.last_pict_type = s->m.pict_type; avctx->frame_bits = s->m.frame_bits; avctx->mv_bits = s->m.mv_bits; avctx->misc_bits = s->m.misc_bits; avctx->p_tex_bits = s->m.p_tex_bits; emms_c(); return ff_rac_terminate(c); } static av_cold int encode_end(AVCodecContext *avctx) { SnowContext *s = avctx->priv_data; common_end(s); if (s->input_picture.data[0]) avctx->release_buffer(avctx, &s->input_picture); av_free(avctx->stats_out); return 0; } AVCodec snow_encoder = { "snow", AVMEDIA_TYPE_VIDEO, CODEC_ID_SNOW, sizeof(SnowContext), encode_init, encode_frame, encode_end, .long_name = NULL_IF_CONFIG_SMALL("Snow"), }; #endif #ifdef TEST #undef malloc #undef free #undef printf #include "libavutil/lfg.h" int main(void){ int width=256; int height=256; int buffer[2][width*height]; SnowContext s; int i; AVLFG prng; s.spatial_decomposition_count=6; s.spatial_decomposition_type=1; av_lfg_init(&prng, 1); printf("testing 5/3 DWT\n"); for(i=0; i<width*height; i++) buffer[0][i] = buffer[1][i] = av_lfg_get(&prng) % 54321 - 12345; ff_spatial_dwt(buffer[0], width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count); ff_spatial_idwt(buffer[0], width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count); for(i=0; i<width*height; i++) if(buffer[0][i]!= buffer[1][i]) printf("fsck: %6d %12d %7d\n",i, buffer[0][i], buffer[1][i]); printf("testing 9/7 DWT\n"); s.spatial_decomposition_type=0; for(i=0; i<width*height; i++) buffer[0][i] = buffer[1][i] = av_lfg_get(&prng) % 54321 - 12345; ff_spatial_dwt(buffer[0], width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count); ff_spatial_idwt(buffer[0], width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count); for(i=0; i<width*height; i++) if(FFABS(buffer[0][i] - buffer[1][i])>20) printf("fsck: %6d %12d %7d\n",i, buffer[0][i], buffer[1][i]); #if 0 printf("testing AC coder\n"); memset(s.header_state, 0, sizeof(s.header_state)); ff_init_range_encoder(&s.c, buffer[0], 256*256); ff_init_cabac_states(&s.c, ff_h264_lps_range, ff_h264_mps_state, ff_h264_lps_state, 64); for(i=-256; i<256; i++){ put_symbol(&s.c, s.header_state, i*i*i/3*FFABS(i), 1); } ff_rac_terminate(&s.c); memset(s.header_state, 0, sizeof(s.header_state)); ff_init_range_decoder(&s.c, buffer[0], 256*256); ff_init_cabac_states(&s.c, ff_h264_lps_range, ff_h264_mps_state, ff_h264_lps_state, 64); for(i=-256; i<256; i++){ int j; j= get_symbol(&s.c, s.header_state, 1); if(j!=i*i*i/3*FFABS(i)) printf("fsck: %d != %d\n", i, j); } #endif { int level, orientation, x, y; int64_t errors[8][4]; int64_t g=0; memset(errors, 0, sizeof(errors)); s.spatial_decomposition_count=3; s.spatial_decomposition_type=0; for(level=0; level<s.spatial_decomposition_count; level++){ for(orientation=level ? 1 : 0; orientation<4; orientation++){ int w= width >> (s.spatial_decomposition_count-level); int h= height >> (s.spatial_decomposition_count-level); int stride= width << (s.spatial_decomposition_count-level); DWTELEM *buf= buffer[0]; int64_t error=0; if(orientation&1) buf+=w; if(orientation>1) buf+=stride>>1; memset(buffer[0], 0, sizeof(int)*width*height); buf[w/2 + h/2*stride]= 256*256; ff_spatial_idwt(buffer[0], width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count); for(y=0; y<height; y++){ for(x=0; x<width; x++){ int64_t d= buffer[0][x + y*width]; error += d*d; if(FFABS(width/2-x)<9 && FFABS(height/2-y)<9 && level==2) printf("%8"PRId64" ", d); } if(FFABS(height/2-y)<9 && level==2) printf("\n"); } error= (int)(sqrt(error)+0.5); errors[level][orientation]= error; if(g) g=av_gcd(g, error); else g= error; } } printf("static int const visual_weight[][4]={\n"); for(level=0; level<s.spatial_decomposition_count; level++){ printf(" {"); for(orientation=0; orientation<4; orientation++){ printf("%8"PRId64",", errors[level][orientation]/g); } printf("},\n"); } printf("};\n"); { int level=2; int w= width >> (s.spatial_decomposition_count-level); //int h= height >> (s.spatial_decomposition_count-level); int stride= width << (s.spatial_decomposition_count-level); DWTELEM *buf= buffer[0]; int64_t error=0; buf+=w; buf+=stride>>1; memset(buffer[0], 0, sizeof(int)*width*height); #if 1 for(y=0; y<height; y++){ for(x=0; x<width; x++){ int tab[4]={0,2,3,1}; buffer[0][x+width*y]= 256*256*tab[(x&1) + 2*(y&1)]; } } ff_spatial_dwt(buffer[0], width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count); #else for(y=0; y<h; y++){ for(x=0; x<w; x++){ buf[x + y*stride ]=169; buf[x + y*stride-w]=64; } } ff_spatial_idwt(buffer[0], width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count); #endif for(y=0; y<height; y++){ for(x=0; x<width; x++){ int64_t d= buffer[0][x + y*width]; error += d*d; if(FFABS(width/2-x)<9 && FFABS(height/2-y)<9) printf("%8"PRId64" ", d); } if(FFABS(height/2-y)<9) printf("\n"); } } } return 0; } #endif /* TEST */
123linslouis-android-video-cutter
jni/libavcodec/snow.c
C
asf20
162,382
/* * RL2 Video Decoder * Copyright (C) 2008 Sascha Sommer (saschasommer@freenet.de) * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * RL2 Video Decoder * @file * @author Sascha Sommer (saschasommer@freenet.de) * For more information about the RL2 format, visit: * http://wiki.multimedia.cx/index.php?title=RL2 */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "libavutil/intreadwrite.h" #include "avcodec.h" #define EXTRADATA1_SIZE (6 + 256 * 3) ///< video base, clr count, palette typedef struct Rl2Context { AVCodecContext *avctx; AVFrame frame; unsigned short video_base; ///< initial drawing offset unsigned int clr_count; ///< number of used colors (currently unused) unsigned char* back_frame; ///< background frame unsigned int palette[AVPALETTE_COUNT]; } Rl2Context; /** * Run Length Decode a single 320x200 frame * @param s rl2 context * @param buf input buffer * @param size input buffer size * @param out ouput buffer * @param stride stride of the output buffer * @param video_base offset of the rle data inside the frame */ static void rl2_rle_decode(Rl2Context *s,const unsigned char* in,int size, unsigned char* out,int stride,int video_base){ int base_x = video_base % s->avctx->width; int base_y = video_base / s->avctx->width; int stride_adj = stride - s->avctx->width; int i; const unsigned char* back_frame = s->back_frame; const unsigned char* in_end = in + size; const unsigned char* out_end = out + stride * s->avctx->height; unsigned char* line_end = out + s->avctx->width; /** copy start of the background frame */ for(i=0;i<=base_y;i++){ if(s->back_frame) memcpy(out,back_frame,s->avctx->width); out += stride; back_frame += s->avctx->width; } back_frame += base_x - s->avctx->width; line_end = out - stride_adj; out += base_x - stride; /** decode the variable part of the frame */ while(in < in_end){ unsigned char val = *in++; int len = 1; if(val >= 0x80){ if(in >= in_end) break; len = *in++; if(!len) break; } if(len >= out_end - out) break; if(s->back_frame) val |= 0x80; else val &= ~0x80; while(len--){ *out++ = (val == 0x80)? *back_frame:val; back_frame++; if(out == line_end){ out += stride_adj; line_end += stride; if(len >= out_end - out) break; } } } /** copy the rest from the background frame */ if(s->back_frame){ while(out < out_end){ memcpy(out, back_frame, line_end - out); back_frame += line_end - out; out = line_end + stride_adj; line_end += stride; } } } /** * Initialize the decoder * @param avctx decoder context * @return 0 success, -1 on error */ static av_cold int rl2_decode_init(AVCodecContext *avctx) { Rl2Context *s = avctx->priv_data; int back_size; int i; s->avctx = avctx; avctx->pix_fmt = PIX_FMT_PAL8; /** parse extra data */ if(!avctx->extradata || avctx->extradata_size < EXTRADATA1_SIZE){ av_log(avctx, AV_LOG_ERROR, "invalid extradata size\n"); return -1; } /** get frame_offset */ s->video_base = AV_RL16(&avctx->extradata[0]); s->clr_count = AV_RL32(&avctx->extradata[2]); if(s->video_base >= avctx->width * avctx->height){ av_log(avctx, AV_LOG_ERROR, "invalid video_base\n"); return -1; } /** initialize palette */ for(i=0;i<AVPALETTE_COUNT;i++) s->palette[i] = AV_RB24(&avctx->extradata[6 + i * 3]); /** decode background frame if present */ back_size = avctx->extradata_size - EXTRADATA1_SIZE; if(back_size > 0){ unsigned char* back_frame = av_mallocz(avctx->width*avctx->height); if(!back_frame) return -1; rl2_rle_decode(s,avctx->extradata + EXTRADATA1_SIZE,back_size, back_frame,avctx->width,0); s->back_frame = back_frame; } return 0; } /** * Decode a single frame * @param avctx decoder context * @param data decoded frame * @param data_size size of the decoded frame * @param buf input buffer * @param buf_size input buffer size * @return 0 success, -1 on error */ static int rl2_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; Rl2Context *s = avctx->priv_data; if(s->frame.data[0]) avctx->release_buffer(avctx, &s->frame); /** get buffer */ s->frame.reference= 0; if(avctx->get_buffer(avctx, &s->frame)) { av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } /** run length decode */ rl2_rle_decode(s,buf,buf_size,s->frame.data[0],s->frame.linesize[0],s->video_base); /** make the palette available on the way out */ memcpy(s->frame.data[1], s->palette, AVPALETTE_SIZE); *data_size = sizeof(AVFrame); *(AVFrame*)data = s->frame; /** report that the buffer was completely consumed */ return buf_size; } /** * Uninit decoder * @param avctx decoder context * @return 0 success, -1 on error */ static av_cold int rl2_decode_end(AVCodecContext *avctx) { Rl2Context *s = avctx->priv_data; if(s->frame.data[0]) avctx->release_buffer(avctx, &s->frame); av_free(s->back_frame); return 0; } AVCodec rl2_decoder = { "rl2", AVMEDIA_TYPE_VIDEO, CODEC_ID_RL2, sizeof(Rl2Context), rl2_decode_init, NULL, rl2_decode_end, rl2_decode_frame, CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("RL2 video"), };
123linslouis-android-video-cutter
jni/libavcodec/rl2.c
C
asf20
6,729
/* * copyright (c) 2000,2001 Fabrice Bellard * H263+ support * copyright (c) 2001 Juan J. Sierralta P * copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * H.263 tables. */ #ifndef AVCODEC_H263DATA_H #define AVCODEC_H263DATA_H #include <stdint.h> #include "mpegvideo.h" /* intra MCBPC, mb_type = (intra), then (intraq) */ const uint8_t ff_h263_intra_MCBPC_code[9] = { 1, 1, 2, 3, 1, 1, 2, 3, 1 }; const uint8_t ff_h263_intra_MCBPC_bits[9] = { 1, 3, 3, 3, 4, 6, 6, 6, 9 }; /* inter MCBPC, mb_type = (inter), (intra), (interq), (intraq), (inter4v) */ /* Changed the tables for interq and inter4v+q, following the standard ** Juanjo ** */ const uint8_t ff_h263_inter_MCBPC_code[28] = { 1, 3, 2, 5, 3, 4, 3, 3, 3, 7, 6, 5, 4, 4, 3, 2, 2, 5, 4, 5, 1, 0, 0, 0, /* Stuffing */ 2, 12, 14, 15, }; const uint8_t ff_h263_inter_MCBPC_bits[28] = { 1, 4, 4, 6, /* inter */ 5, 8, 8, 7, /* intra */ 3, 7, 7, 9, /* interQ */ 6, 9, 9, 9, /* intraQ */ 3, 7, 7, 8, /* inter4 */ 9, 0, 0, 0, /* Stuffing */ 11, 13, 13, 13,/* inter4Q*/ }; const uint8_t h263_mbtype_b_tab[15][2] = { {1, 1}, {3, 3}, {1, 5}, {4, 4}, {5, 4}, {6, 6}, {2, 4}, {3, 4}, {7, 6}, {4, 6}, {5, 6}, {1, 6}, {1,10}, {1, 7}, {1, 8}, }; const uint8_t cbpc_b_tab[4][2] = { {0, 1}, {2, 2}, {7, 3}, {6, 3}, }; const uint8_t ff_h263_cbpy_tab[16][2] = { {3,4}, {5,5}, {4,5}, {9,4}, {3,5}, {7,4}, {2,6}, {11,4}, {2,5}, {3,6}, {5,4}, {10,4}, {4,4}, {8,4}, {6,4}, {3,2} }; const uint8_t mvtab[33][2] = { {1,1}, {1,2}, {1,3}, {1,4}, {3,6}, {5,7}, {4,7}, {3,7}, {11,9}, {10,9}, {9,9}, {17,10}, {16,10}, {15,10}, {14,10}, {13,10}, {12,10}, {11,10}, {10,10}, {9,10}, {8,10}, {7,10}, {6,10}, {5,10}, {4,10}, {7,11}, {6,11}, {5,11}, {4,11}, {3,11}, {2,11}, {3,12}, {2,12} }; /* third non intra table */ const uint16_t inter_vlc[103][2] = { { 0x2, 2 },{ 0xf, 4 },{ 0x15, 6 },{ 0x17, 7 }, { 0x1f, 8 },{ 0x25, 9 },{ 0x24, 9 },{ 0x21, 10 }, { 0x20, 10 },{ 0x7, 11 },{ 0x6, 11 },{ 0x20, 11 }, { 0x6, 3 },{ 0x14, 6 },{ 0x1e, 8 },{ 0xf, 10 }, { 0x21, 11 },{ 0x50, 12 },{ 0xe, 4 },{ 0x1d, 8 }, { 0xe, 10 },{ 0x51, 12 },{ 0xd, 5 },{ 0x23, 9 }, { 0xd, 10 },{ 0xc, 5 },{ 0x22, 9 },{ 0x52, 12 }, { 0xb, 5 },{ 0xc, 10 },{ 0x53, 12 },{ 0x13, 6 }, { 0xb, 10 },{ 0x54, 12 },{ 0x12, 6 },{ 0xa, 10 }, { 0x11, 6 },{ 0x9, 10 },{ 0x10, 6 },{ 0x8, 10 }, { 0x16, 7 },{ 0x55, 12 },{ 0x15, 7 },{ 0x14, 7 }, { 0x1c, 8 },{ 0x1b, 8 },{ 0x21, 9 },{ 0x20, 9 }, { 0x1f, 9 },{ 0x1e, 9 },{ 0x1d, 9 },{ 0x1c, 9 }, { 0x1b, 9 },{ 0x1a, 9 },{ 0x22, 11 },{ 0x23, 11 }, { 0x56, 12 },{ 0x57, 12 },{ 0x7, 4 },{ 0x19, 9 }, { 0x5, 11 },{ 0xf, 6 },{ 0x4, 11 },{ 0xe, 6 }, { 0xd, 6 },{ 0xc, 6 },{ 0x13, 7 },{ 0x12, 7 }, { 0x11, 7 },{ 0x10, 7 },{ 0x1a, 8 },{ 0x19, 8 }, { 0x18, 8 },{ 0x17, 8 },{ 0x16, 8 },{ 0x15, 8 }, { 0x14, 8 },{ 0x13, 8 },{ 0x18, 9 },{ 0x17, 9 }, { 0x16, 9 },{ 0x15, 9 },{ 0x14, 9 },{ 0x13, 9 }, { 0x12, 9 },{ 0x11, 9 },{ 0x7, 10 },{ 0x6, 10 }, { 0x5, 10 },{ 0x4, 10 },{ 0x24, 11 },{ 0x25, 11 }, { 0x26, 11 },{ 0x27, 11 },{ 0x58, 12 },{ 0x59, 12 }, { 0x5a, 12 },{ 0x5b, 12 },{ 0x5c, 12 },{ 0x5d, 12 }, { 0x5e, 12 },{ 0x5f, 12 },{ 0x3, 7 }, }; const int8_t inter_level[102] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; const int8_t inter_run[102] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, }; RLTable ff_h263_rl_inter = { 102, 58, inter_vlc, inter_run, inter_level, }; static const uint16_t intra_vlc_aic[103][2] = { { 0x2, 2 }, { 0x6, 3 }, { 0xe, 4 }, { 0xc, 5 }, { 0xd, 5 }, { 0x10, 6 }, { 0x11, 6 }, { 0x12, 6 }, { 0x16, 7 }, { 0x1b, 8 }, { 0x20, 9 }, { 0x21, 9 }, { 0x1a, 9 }, { 0x1b, 9 }, { 0x1c, 9 }, { 0x1d, 9 }, { 0x1e, 9 }, { 0x1f, 9 }, { 0x23, 11 }, { 0x22, 11 }, { 0x57, 12 }, { 0x56, 12 }, { 0x55, 12 }, { 0x54, 12 }, { 0x53, 12 }, { 0xf, 4 }, { 0x14, 6 }, { 0x14, 7 }, { 0x1e, 8 }, { 0xf, 10 }, { 0x21, 11 }, { 0x50, 12 }, { 0xb, 5 }, { 0x15, 7 }, { 0xe, 10 }, { 0x9, 10 }, { 0x15, 6 }, { 0x1d, 8 }, { 0xd, 10 }, { 0x51, 12 }, { 0x13, 6 }, { 0x23, 9 }, { 0x7, 11 }, { 0x17, 7 }, { 0x22, 9 }, { 0x52, 12 }, { 0x1c, 8 }, { 0xc, 10 }, { 0x1f, 8 }, { 0xb, 10 }, { 0x25, 9 }, { 0xa, 10 }, { 0x24, 9 }, { 0x6, 11 }, { 0x21, 10 }, { 0x20, 10 }, { 0x8, 10 }, { 0x20, 11 }, { 0x7, 4 }, { 0xc, 6 }, { 0x10, 7 }, { 0x13, 8 }, { 0x11, 9 }, { 0x12, 9 }, { 0x4, 10 }, { 0x27, 11 }, { 0x26, 11 }, { 0x5f, 12 }, { 0xf, 6 }, { 0x13, 9 }, { 0x5, 10 }, { 0x25, 11 }, { 0xe, 6 }, { 0x14, 9 }, { 0x24, 11 }, { 0xd, 6 }, { 0x6, 10 }, { 0x5e, 12 }, { 0x11, 7 }, { 0x7, 10 }, { 0x13, 7 }, { 0x5d, 12 }, { 0x12, 7 }, { 0x5c, 12 }, { 0x14, 8 }, { 0x5b, 12 }, { 0x15, 8 }, { 0x1a, 8 }, { 0x19, 8 }, { 0x18, 8 }, { 0x17, 8 }, { 0x16, 8 }, { 0x19, 9 }, { 0x15, 9 }, { 0x16, 9 }, { 0x18, 9 }, { 0x17, 9 }, { 0x4, 11 }, { 0x5, 11 }, { 0x58, 12 }, { 0x59, 12 }, { 0x5a, 12 }, { 0x3, 7 }, }; static const int8_t intra_run_aic[102] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 11, 12, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, }; static const int8_t intra_level_aic[102] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 1, 2, 3, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 1, 2, 3, 1, 2, 3, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; RLTable rl_intra_aic = { 102, 58, intra_vlc_aic, intra_run_aic, intra_level_aic, }; const uint16_t h263_format[8][2] = { { 0, 0 }, { 128, 96 }, { 176, 144 }, { 352, 288 }, { 704, 576 }, { 1408, 1152 }, }; const uint8_t ff_aic_dc_scale_table[32]={ // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 0, 2, 4, 6, 8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62 }; const uint8_t modified_quant_tab[2][32]={ // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 { 0, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9,10,11,12,13,14,15,16,17,18,18,19,20,21,22,23,24,25,26,27,28 },{ 0, 2, 3, 4, 5, 6, 7, 8, 9,10,11,13,14,15,16,17,18,19,20,21,22,24,25,26,27,28,29,30,31,31,31,26 } }; const uint8_t ff_h263_chroma_qscale_table[32]={ // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 0, 1, 2, 3, 4, 5, 6, 6, 7, 8, 9, 9,10,10,11,11,12,12,12,13,13,13,14,14,14,14,14,15,15,15,15,15 }; uint16_t ff_mba_max[6]={ 47, 98, 395,1583,6335,9215 }; uint8_t ff_mba_length[7]={ 6, 7, 9, 11, 13, 14, 14 }; const uint8_t ff_h263_loop_filter_strength[32]={ // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 0, 1, 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9,10,10,10,11,11,11,12,12,12 }; const AVRational ff_h263_pixel_aspect[16]={ {0, 1}, {1, 1}, {12, 11}, {10, 11}, {16, 11}, {40, 33}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, }; #endif /* AVCODEC_H263DATA_H */
123linslouis-android-video-cutter
jni/libavcodec/h263data.h
C
asf20
9,071
/* * GIF decoder * Copyright (c) 2003 Fabrice Bellard * Copyright (c) 2006 Baptiste Coudurier * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ //#define DEBUG #include "avcodec.h" #include "bytestream.h" #include "lzw.h" #define GCE_DISPOSAL_NONE 0 #define GCE_DISPOSAL_INPLACE 1 #define GCE_DISPOSAL_BACKGROUND 2 #define GCE_DISPOSAL_RESTORE 3 typedef struct GifState { AVFrame picture; int screen_width; int screen_height; int bits_per_pixel; int background_color_index; int transparent_color_index; int color_resolution; uint32_t *image_palette; /* after the frame is displayed, the disposal method is used */ int gce_disposal; /* delay during which the frame is shown */ int gce_delay; /* LZW compatible decoder */ const uint8_t *bytestream; const uint8_t *bytestream_end; LZWState *lzw; /* aux buffers */ uint8_t global_palette[256 * 3]; uint8_t local_palette[256 * 3]; AVCodecContext* avctx; } GifState; static const uint8_t gif87a_sig[6] = "GIF87a"; static const uint8_t gif89a_sig[6] = "GIF89a"; static int gif_read_image(GifState *s) { int left, top, width, height, bits_per_pixel, code_size, flags; int is_interleaved, has_local_palette, y, pass, y1, linesize, n, i; uint8_t *ptr, *spal, *palette, *ptr1; left = bytestream_get_le16(&s->bytestream); top = bytestream_get_le16(&s->bytestream); width = bytestream_get_le16(&s->bytestream); height = bytestream_get_le16(&s->bytestream); flags = bytestream_get_byte(&s->bytestream); is_interleaved = flags & 0x40; has_local_palette = flags & 0x80; bits_per_pixel = (flags & 0x07) + 1; #ifdef DEBUG dprintf(s->avctx, "gif: image x=%d y=%d w=%d h=%d\n", left, top, width, height); #endif if (has_local_palette) { bytestream_get_buffer(&s->bytestream, s->local_palette, 3 * (1 << bits_per_pixel)); palette = s->local_palette; } else { palette = s->global_palette; bits_per_pixel = s->bits_per_pixel; } /* verify that all the image is inside the screen dimensions */ if (left + width > s->screen_width || top + height > s->screen_height) return AVERROR(EINVAL); /* build the palette */ n = (1 << bits_per_pixel); spal = palette; for(i = 0; i < n; i++) { s->image_palette[i] = (0xff << 24) | AV_RB24(spal); spal += 3; } for(; i < 256; i++) s->image_palette[i] = (0xff << 24); /* handle transparency */ if (s->transparent_color_index >= 0) s->image_palette[s->transparent_color_index] = 0; /* now get the image data */ code_size = bytestream_get_byte(&s->bytestream); ff_lzw_decode_init(s->lzw, code_size, s->bytestream, s->bytestream_end - s->bytestream, FF_LZW_GIF); /* read all the image */ linesize = s->picture.linesize[0]; ptr1 = s->picture.data[0] + top * linesize + left; ptr = ptr1; pass = 0; y1 = 0; for (y = 0; y < height; y++) { ff_lzw_decode(s->lzw, ptr, width); if (is_interleaved) { switch(pass) { default: case 0: case 1: y1 += 8; ptr += linesize * 8; if (y1 >= height) { y1 = pass ? 2 : 4; ptr = ptr1 + linesize * y1; pass++; } break; case 2: y1 += 4; ptr += linesize * 4; if (y1 >= height) { y1 = 1; ptr = ptr1 + linesize; pass++; } break; case 3: y1 += 2; ptr += linesize * 2; break; } } else { ptr += linesize; } } /* read the garbage data until end marker is found */ ff_lzw_decode_tail(s->lzw); s->bytestream = ff_lzw_cur_ptr(s->lzw); return 0; } static int gif_read_extension(GifState *s) { int ext_code, ext_len, i, gce_flags, gce_transparent_index; /* extension */ ext_code = bytestream_get_byte(&s->bytestream); ext_len = bytestream_get_byte(&s->bytestream); #ifdef DEBUG dprintf(s->avctx, "gif: ext_code=0x%x len=%d\n", ext_code, ext_len); #endif switch(ext_code) { case 0xf9: if (ext_len != 4) goto discard_ext; s->transparent_color_index = -1; gce_flags = bytestream_get_byte(&s->bytestream); s->gce_delay = bytestream_get_le16(&s->bytestream); gce_transparent_index = bytestream_get_byte(&s->bytestream); if (gce_flags & 0x01) s->transparent_color_index = gce_transparent_index; else s->transparent_color_index = -1; s->gce_disposal = (gce_flags >> 2) & 0x7; #ifdef DEBUG dprintf(s->avctx, "gif: gce_flags=%x delay=%d tcolor=%d disposal=%d\n", gce_flags, s->gce_delay, s->transparent_color_index, s->gce_disposal); #endif ext_len = bytestream_get_byte(&s->bytestream); break; } /* NOTE: many extension blocks can come after */ discard_ext: while (ext_len != 0) { for (i = 0; i < ext_len; i++) bytestream_get_byte(&s->bytestream); ext_len = bytestream_get_byte(&s->bytestream); #ifdef DEBUG dprintf(s->avctx, "gif: ext_len1=%d\n", ext_len); #endif } return 0; } static int gif_read_header1(GifState *s) { uint8_t sig[6]; int v, n; int has_global_palette; if (s->bytestream_end < s->bytestream + 13) return -1; /* read gif signature */ bytestream_get_buffer(&s->bytestream, sig, 6); if (memcmp(sig, gif87a_sig, 6) != 0 && memcmp(sig, gif89a_sig, 6) != 0) return -1; /* read screen header */ s->transparent_color_index = -1; s->screen_width = bytestream_get_le16(&s->bytestream); s->screen_height = bytestream_get_le16(&s->bytestream); if( (unsigned)s->screen_width > 32767 || (unsigned)s->screen_height > 32767){ av_log(NULL, AV_LOG_ERROR, "picture size too large\n"); return -1; } v = bytestream_get_byte(&s->bytestream); s->color_resolution = ((v & 0x70) >> 4) + 1; has_global_palette = (v & 0x80); s->bits_per_pixel = (v & 0x07) + 1; s->background_color_index = bytestream_get_byte(&s->bytestream); bytestream_get_byte(&s->bytestream); /* ignored */ #ifdef DEBUG dprintf(s->avctx, "gif: screen_w=%d screen_h=%d bpp=%d global_palette=%d\n", s->screen_width, s->screen_height, s->bits_per_pixel, has_global_palette); #endif if (has_global_palette) { n = 1 << s->bits_per_pixel; if (s->bytestream_end < s->bytestream + n * 3) return -1; bytestream_get_buffer(&s->bytestream, s->global_palette, n * 3); } return 0; } static int gif_parse_next_image(GifState *s) { while (s->bytestream < s->bytestream_end) { int code = bytestream_get_byte(&s->bytestream); #ifdef DEBUG dprintf(s->avctx, "gif: code=%02x '%c'\n", code, code); #endif switch (code) { case ',': return gif_read_image(s); case '!': if (gif_read_extension(s) < 0) return -1; break; case ';': /* end of image */ default: /* error or erroneous EOF */ return -1; } } return -1; } static av_cold int gif_decode_init(AVCodecContext *avctx) { GifState *s = avctx->priv_data; s->avctx = avctx; avcodec_get_frame_defaults(&s->picture); avctx->coded_frame= &s->picture; s->picture.data[0] = NULL; ff_lzw_decode_open(&s->lzw); return 0; } static int gif_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; GifState *s = avctx->priv_data; AVFrame *picture = data; int ret; s->bytestream = buf; s->bytestream_end = buf + buf_size; if (gif_read_header1(s) < 0) return -1; avctx->pix_fmt = PIX_FMT_PAL8; if (avcodec_check_dimensions(avctx, s->screen_width, s->screen_height)) return -1; avcodec_set_dimensions(avctx, s->screen_width, s->screen_height); if (s->picture.data[0]) avctx->release_buffer(avctx, &s->picture); if (avctx->get_buffer(avctx, &s->picture) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } s->image_palette = (uint32_t *)s->picture.data[1]; ret = gif_parse_next_image(s); if (ret < 0) return ret; *picture = s->picture; *data_size = sizeof(AVPicture); return s->bytestream - buf; } static av_cold int gif_decode_close(AVCodecContext *avctx) { GifState *s = avctx->priv_data; ff_lzw_decode_close(&s->lzw); if(s->picture.data[0]) avctx->release_buffer(avctx, &s->picture); return 0; } AVCodec gif_decoder = { "gif", AVMEDIA_TYPE_VIDEO, CODEC_ID_GIF, sizeof(GifState), gif_decode_init, NULL, gif_decode_close, gif_decode_frame, CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("GIF (Graphics Interchange Format)"), };
123linslouis-android-video-cutter
jni/libavcodec/gifdec.c
C
asf20
10,077
/* * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AVCODEC_INTRAX8_H #define AVCODEC_INTRAX8_H #include "get_bits.h" #include "mpegvideo.h" typedef struct{ VLC * j_ac_vlc[4];//they point to the static j_mb_vlc VLC * j_orient_vlc; VLC * j_dc_vlc[3]; int use_quant_matrix; //set by ff_intrax8_common_init uint8_t * prediction_table;//2*(mb_w*2) ScanTable scantable[3]; //set by the caller codec MpegEncContext * s; int quant; int dquant; int qsum; //calculated per frame int quant_dc_chroma; int divide_quant_dc_luma; int divide_quant_dc_chroma; //changed per block int edges; int flat_dc; int predicted_dc; int raw_orient; int chroma_orient; int orient; int est_run; } IntraX8Context; void ff_intrax8_common_init(IntraX8Context * w, MpegEncContext * const s); void ff_intrax8_common_end(IntraX8Context * w); int ff_intrax8_decode_picture(IntraX8Context * w, int quant, int halfpq); #endif /* AVCODEC_INTRAX8_H */
123linslouis-android-video-cutter
jni/libavcodec/intrax8.h
C
asf20
1,719
/* * AC-3 Audio Decoder * This code was developed as part of Google Summer of Code 2006. * E-AC-3 support was added as part of Google Summer of Code 2007. * * Copyright (c) 2006 Kartikey Mahendra BHATT (bhattkm at gmail dot com) * Copyright (c) 2007-2008 Bartlomiej Wolowiec <bartek.wolowiec@gmail.com> * Copyright (c) 2007 Justin Ruggles <justin.ruggles@gmail.com> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <stdio.h> #include <stddef.h> #include <math.h> #include <string.h> #include "libavutil/crc.h" #include "internal.h" #include "aac_ac3_parser.h" #include "ac3_parser.h" #include "ac3dec.h" #include "ac3dec_data.h" /** Large enough for maximum possible frame size when the specification limit is ignored */ #define AC3_FRAME_BUFFER_SIZE 32768 /** * table for ungrouping 3 values in 7 bits. * used for exponents and bap=2 mantissas */ static uint8_t ungroup_3_in_7_bits_tab[128][3]; /** tables for ungrouping mantissas */ static int b1_mantissas[32][3]; static int b2_mantissas[128][3]; static int b3_mantissas[8]; static int b4_mantissas[128][2]; static int b5_mantissas[16]; /** * Quantization table: levels for symmetric. bits for asymmetric. * reference: Table 7.18 Mapping of bap to Quantizer */ static const uint8_t quantization_tab[16] = { 0, 3, 5, 7, 11, 15, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16 }; /** dynamic range table. converts codes to scale factors. */ static float dynamic_range_tab[256]; /** Adjustments in dB gain */ #define LEVEL_PLUS_3DB 1.4142135623730950 #define LEVEL_PLUS_1POINT5DB 1.1892071150027209 #define LEVEL_MINUS_1POINT5DB 0.8408964152537145 #define LEVEL_MINUS_3DB 0.7071067811865476 #define LEVEL_MINUS_4POINT5DB 0.5946035575013605 #define LEVEL_MINUS_6DB 0.5000000000000000 #define LEVEL_MINUS_9DB 0.3535533905932738 #define LEVEL_ZERO 0.0000000000000000 #define LEVEL_ONE 1.0000000000000000 static const float gain_levels[9] = { LEVEL_PLUS_3DB, LEVEL_PLUS_1POINT5DB, LEVEL_ONE, LEVEL_MINUS_1POINT5DB, LEVEL_MINUS_3DB, LEVEL_MINUS_4POINT5DB, LEVEL_MINUS_6DB, LEVEL_ZERO, LEVEL_MINUS_9DB }; /** * Table for center mix levels * reference: Section 5.4.2.4 cmixlev */ static const uint8_t center_levels[4] = { 4, 5, 6, 5 }; /** * Table for surround mix levels * reference: Section 5.4.2.5 surmixlev */ static const uint8_t surround_levels[4] = { 4, 6, 7, 6 }; /** * Table for default stereo downmixing coefficients * reference: Section 7.8.2 Downmixing Into Two Channels */ static const uint8_t ac3_default_coeffs[8][5][2] = { { { 2, 7 }, { 7, 2 }, }, { { 4, 4 }, }, { { 2, 7 }, { 7, 2 }, }, { { 2, 7 }, { 5, 5 }, { 7, 2 }, }, { { 2, 7 }, { 7, 2 }, { 6, 6 }, }, { { 2, 7 }, { 5, 5 }, { 7, 2 }, { 8, 8 }, }, { { 2, 7 }, { 7, 2 }, { 6, 7 }, { 7, 6 }, }, { { 2, 7 }, { 5, 5 }, { 7, 2 }, { 6, 7 }, { 7, 6 }, }, }; /** * Symmetrical Dequantization * reference: Section 7.3.3 Expansion of Mantissas for Symmetrical Quantization * Tables 7.19 to 7.23 */ static inline int symmetric_dequant(int code, int levels) { return ((code - (levels >> 1)) << 24) / levels; } /* * Initialize tables at runtime. */ static av_cold void ac3_tables_init(void) { int i; /* generate table for ungrouping 3 values in 7 bits reference: Section 7.1.3 Exponent Decoding */ for(i=0; i<128; i++) { ungroup_3_in_7_bits_tab[i][0] = i / 25; ungroup_3_in_7_bits_tab[i][1] = (i % 25) / 5; ungroup_3_in_7_bits_tab[i][2] = (i % 25) % 5; } /* generate grouped mantissa tables reference: Section 7.3.5 Ungrouping of Mantissas */ for(i=0; i<32; i++) { /* bap=1 mantissas */ b1_mantissas[i][0] = symmetric_dequant(ff_ac3_ungroup_3_in_5_bits_tab[i][0], 3); b1_mantissas[i][1] = symmetric_dequant(ff_ac3_ungroup_3_in_5_bits_tab[i][1], 3); b1_mantissas[i][2] = symmetric_dequant(ff_ac3_ungroup_3_in_5_bits_tab[i][2], 3); } for(i=0; i<128; i++) { /* bap=2 mantissas */ b2_mantissas[i][0] = symmetric_dequant(ungroup_3_in_7_bits_tab[i][0], 5); b2_mantissas[i][1] = symmetric_dequant(ungroup_3_in_7_bits_tab[i][1], 5); b2_mantissas[i][2] = symmetric_dequant(ungroup_3_in_7_bits_tab[i][2], 5); /* bap=4 mantissas */ b4_mantissas[i][0] = symmetric_dequant(i / 11, 11); b4_mantissas[i][1] = symmetric_dequant(i % 11, 11); } /* generate ungrouped mantissa tables reference: Tables 7.21 and 7.23 */ for(i=0; i<7; i++) { /* bap=3 mantissas */ b3_mantissas[i] = symmetric_dequant(i, 7); } for(i=0; i<15; i++) { /* bap=5 mantissas */ b5_mantissas[i] = symmetric_dequant(i, 15); } /* generate dynamic range table reference: Section 7.7.1 Dynamic Range Control */ for(i=0; i<256; i++) { int v = (i >> 5) - ((i >> 7) << 3) - 5; dynamic_range_tab[i] = powf(2.0f, v) * ((i & 0x1F) | 0x20); } } /** * AVCodec initialization */ static av_cold int ac3_decode_init(AVCodecContext *avctx) { AC3DecodeContext *s = avctx->priv_data; s->avctx = avctx; ac3_common_init(); ac3_tables_init(); ff_mdct_init(&s->imdct_256, 8, 1, 1.0); ff_mdct_init(&s->imdct_512, 9, 1, 1.0); ff_kbd_window_init(s->window, 5.0, 256); dsputil_init(&s->dsp, avctx); av_lfg_init(&s->dith_state, 0); /* set bias values for float to int16 conversion */ if(s->dsp.float_to_int16_interleave == ff_float_to_int16_interleave_c) { s->add_bias = 385.0f; s->mul_bias = 1.0f; } else { s->add_bias = 0.0f; s->mul_bias = 32767.0f; } /* allow downmixing to stereo or mono */ if (avctx->channels > 0 && avctx->request_channels > 0 && avctx->request_channels < avctx->channels && avctx->request_channels <= 2) { avctx->channels = avctx->request_channels; } s->downmixed = 1; /* allocate context input buffer */ if (avctx->error_recognition >= FF_ER_CAREFUL) { s->input_buffer = av_mallocz(AC3_FRAME_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE); if (!s->input_buffer) return AVERROR(ENOMEM); } avctx->sample_fmt = SAMPLE_FMT_S16; return 0; } /** * Parse the 'sync info' and 'bit stream info' from the AC-3 bitstream. * GetBitContext within AC3DecodeContext must point to * the start of the synchronized AC-3 bitstream. */ static int ac3_parse_header(AC3DecodeContext *s) { GetBitContext *gbc = &s->gbc; int i; /* read the rest of the bsi. read twice for dual mono mode. */ i = !(s->channel_mode); do { skip_bits(gbc, 5); // skip dialog normalization if (get_bits1(gbc)) skip_bits(gbc, 8); //skip compression if (get_bits1(gbc)) skip_bits(gbc, 8); //skip language code if (get_bits1(gbc)) skip_bits(gbc, 7); //skip audio production information } while (i--); skip_bits(gbc, 2); //skip copyright bit and original bitstream bit /* skip the timecodes (or extra bitstream information for Alternate Syntax) TODO: read & use the xbsi1 downmix levels */ if (get_bits1(gbc)) skip_bits(gbc, 14); //skip timecode1 / xbsi1 if (get_bits1(gbc)) skip_bits(gbc, 14); //skip timecode2 / xbsi2 /* skip additional bitstream info */ if (get_bits1(gbc)) { i = get_bits(gbc, 6); do { skip_bits(gbc, 8); } while(i--); } return 0; } /** * Common function to parse AC-3 or E-AC-3 frame header */ static int parse_frame_header(AC3DecodeContext *s) { AC3HeaderInfo hdr; int err; err = ff_ac3_parse_header(&s->gbc, &hdr); if(err) return err; /* get decoding parameters from header info */ s->bit_alloc_params.sr_code = hdr.sr_code; s->channel_mode = hdr.channel_mode; s->channel_layout = hdr.channel_layout; s->lfe_on = hdr.lfe_on; s->bit_alloc_params.sr_shift = hdr.sr_shift; s->sample_rate = hdr.sample_rate; s->bit_rate = hdr.bit_rate; s->channels = hdr.channels; s->fbw_channels = s->channels - s->lfe_on; s->lfe_ch = s->fbw_channels + 1; s->frame_size = hdr.frame_size; s->center_mix_level = hdr.center_mix_level; s->surround_mix_level = hdr.surround_mix_level; s->num_blocks = hdr.num_blocks; s->frame_type = hdr.frame_type; s->substreamid = hdr.substreamid; if(s->lfe_on) { s->start_freq[s->lfe_ch] = 0; s->end_freq[s->lfe_ch] = 7; s->num_exp_groups[s->lfe_ch] = 2; s->channel_in_cpl[s->lfe_ch] = 0; } if (hdr.bitstream_id <= 10) { s->eac3 = 0; s->snr_offset_strategy = 2; s->block_switch_syntax = 1; s->dither_flag_syntax = 1; s->bit_allocation_syntax = 1; s->fast_gain_syntax = 0; s->first_cpl_leak = 0; s->dba_syntax = 1; s->skip_syntax = 1; memset(s->channel_uses_aht, 0, sizeof(s->channel_uses_aht)); return ac3_parse_header(s); } else if (CONFIG_EAC3_DECODER) { s->eac3 = 1; return ff_eac3_parse_header(s); } else { av_log(s->avctx, AV_LOG_ERROR, "E-AC-3 support not compiled in\n"); return -1; } } /** * Set stereo downmixing coefficients based on frame header info. * reference: Section 7.8.2 Downmixing Into Two Channels */ static void set_downmix_coeffs(AC3DecodeContext *s) { int i; float cmix = gain_levels[center_levels[s->center_mix_level]]; float smix = gain_levels[surround_levels[s->surround_mix_level]]; float norm0, norm1; for(i=0; i<s->fbw_channels; i++) { s->downmix_coeffs[i][0] = gain_levels[ac3_default_coeffs[s->channel_mode][i][0]]; s->downmix_coeffs[i][1] = gain_levels[ac3_default_coeffs[s->channel_mode][i][1]]; } if(s->channel_mode > 1 && s->channel_mode & 1) { s->downmix_coeffs[1][0] = s->downmix_coeffs[1][1] = cmix; } if(s->channel_mode == AC3_CHMODE_2F1R || s->channel_mode == AC3_CHMODE_3F1R) { int nf = s->channel_mode - 2; s->downmix_coeffs[nf][0] = s->downmix_coeffs[nf][1] = smix * LEVEL_MINUS_3DB; } if(s->channel_mode == AC3_CHMODE_2F2R || s->channel_mode == AC3_CHMODE_3F2R) { int nf = s->channel_mode - 4; s->downmix_coeffs[nf][0] = s->downmix_coeffs[nf+1][1] = smix; } /* renormalize */ norm0 = norm1 = 0.0; for(i=0; i<s->fbw_channels; i++) { norm0 += s->downmix_coeffs[i][0]; norm1 += s->downmix_coeffs[i][1]; } norm0 = 1.0f / norm0; norm1 = 1.0f / norm1; for(i=0; i<s->fbw_channels; i++) { s->downmix_coeffs[i][0] *= norm0; s->downmix_coeffs[i][1] *= norm1; } if(s->output_mode == AC3_CHMODE_MONO) { for(i=0; i<s->fbw_channels; i++) s->downmix_coeffs[i][0] = (s->downmix_coeffs[i][0] + s->downmix_coeffs[i][1]) * LEVEL_MINUS_3DB; } } /** * Decode the grouped exponents according to exponent strategy. * reference: Section 7.1.3 Exponent Decoding */ static int decode_exponents(GetBitContext *gbc, int exp_strategy, int ngrps, uint8_t absexp, int8_t *dexps) { int i, j, grp, group_size; int dexp[256]; int expacc, prevexp; /* unpack groups */ group_size = exp_strategy + (exp_strategy == EXP_D45); for(grp=0,i=0; grp<ngrps; grp++) { expacc = get_bits(gbc, 7); dexp[i++] = ungroup_3_in_7_bits_tab[expacc][0]; dexp[i++] = ungroup_3_in_7_bits_tab[expacc][1]; dexp[i++] = ungroup_3_in_7_bits_tab[expacc][2]; } /* convert to absolute exps and expand groups */ prevexp = absexp; for(i=0,j=0; i<ngrps*3; i++) { prevexp += dexp[i] - 2; if (prevexp > 24U) return -1; switch (group_size) { case 4: dexps[j++] = prevexp; dexps[j++] = prevexp; case 2: dexps[j++] = prevexp; case 1: dexps[j++] = prevexp; } } return 0; } /** * Generate transform coefficients for each coupled channel in the coupling * range using the coupling coefficients and coupling coordinates. * reference: Section 7.4.3 Coupling Coordinate Format */ static void calc_transform_coeffs_cpl(AC3DecodeContext *s) { int bin, band, ch; bin = s->start_freq[CPL_CH]; for (band = 0; band < s->num_cpl_bands; band++) { int band_start = bin; int band_end = bin + s->cpl_band_sizes[band]; for (ch = 1; ch <= s->fbw_channels; ch++) { if (s->channel_in_cpl[ch]) { int cpl_coord = s->cpl_coords[ch][band] << 5; for (bin = band_start; bin < band_end; bin++) { s->fixed_coeffs[ch][bin] = MULH(s->fixed_coeffs[CPL_CH][bin] << 4, cpl_coord); } if (ch == 2 && s->phase_flags[band]) { for (bin = band_start; bin < band_end; bin++) s->fixed_coeffs[2][bin] = -s->fixed_coeffs[2][bin]; } } } bin = band_end; } } /** * Grouped mantissas for 3-level 5-level and 11-level quantization */ typedef struct { int b1_mant[2]; int b2_mant[2]; int b4_mant; int b1; int b2; int b4; } mant_groups; /** * Decode the transform coefficients for a particular channel * reference: Section 7.3 Quantization and Decoding of Mantissas */ static void ac3_decode_transform_coeffs_ch(AC3DecodeContext *s, int ch_index, mant_groups *m) { int start_freq = s->start_freq[ch_index]; int end_freq = s->end_freq[ch_index]; uint8_t *baps = s->bap[ch_index]; int8_t *exps = s->dexps[ch_index]; int *coeffs = s->fixed_coeffs[ch_index]; int dither = (ch_index == CPL_CH) || s->dither_flag[ch_index]; GetBitContext *gbc = &s->gbc; int freq; for(freq = start_freq; freq < end_freq; freq++){ int bap = baps[freq]; int mantissa; switch(bap){ case 0: if (dither) mantissa = (av_lfg_get(&s->dith_state) & 0x7FFFFF) - 0x400000; else mantissa = 0; break; case 1: if(m->b1){ m->b1--; mantissa = m->b1_mant[m->b1]; } else{ int bits = get_bits(gbc, 5); mantissa = b1_mantissas[bits][0]; m->b1_mant[1] = b1_mantissas[bits][1]; m->b1_mant[0] = b1_mantissas[bits][2]; m->b1 = 2; } break; case 2: if(m->b2){ m->b2--; mantissa = m->b2_mant[m->b2]; } else{ int bits = get_bits(gbc, 7); mantissa = b2_mantissas[bits][0]; m->b2_mant[1] = b2_mantissas[bits][1]; m->b2_mant[0] = b2_mantissas[bits][2]; m->b2 = 2; } break; case 3: mantissa = b3_mantissas[get_bits(gbc, 3)]; break; case 4: if(m->b4){ m->b4 = 0; mantissa = m->b4_mant; } else{ int bits = get_bits(gbc, 7); mantissa = b4_mantissas[bits][0]; m->b4_mant = b4_mantissas[bits][1]; m->b4 = 1; } break; case 5: mantissa = b5_mantissas[get_bits(gbc, 4)]; break; default: /* 6 to 15 */ mantissa = get_bits(gbc, quantization_tab[bap]); /* Shift mantissa and sign-extend it. */ mantissa = (mantissa << (32-quantization_tab[bap]))>>8; break; } coeffs[freq] = mantissa >> exps[freq]; } } /** * Remove random dithering from coupling range coefficients with zero-bit * mantissas for coupled channels which do not use dithering. * reference: Section 7.3.4 Dither for Zero Bit Mantissas (bap=0) */ static void remove_dithering(AC3DecodeContext *s) { int ch, i; for(ch=1; ch<=s->fbw_channels; ch++) { if(!s->dither_flag[ch] && s->channel_in_cpl[ch]) { for(i = s->start_freq[CPL_CH]; i<s->end_freq[CPL_CH]; i++) { if(!s->bap[CPL_CH][i]) s->fixed_coeffs[ch][i] = 0; } } } } static void decode_transform_coeffs_ch(AC3DecodeContext *s, int blk, int ch, mant_groups *m) { if (!s->channel_uses_aht[ch]) { ac3_decode_transform_coeffs_ch(s, ch, m); } else { /* if AHT is used, mantissas for all blocks are encoded in the first block of the frame. */ int bin; if (!blk && CONFIG_EAC3_DECODER) ff_eac3_decode_transform_coeffs_aht_ch(s, ch); for (bin = s->start_freq[ch]; bin < s->end_freq[ch]; bin++) { s->fixed_coeffs[ch][bin] = s->pre_mantissa[ch][bin][blk] >> s->dexps[ch][bin]; } } } /** * Decode the transform coefficients. */ static void decode_transform_coeffs(AC3DecodeContext *s, int blk) { int ch, end; int got_cplchan = 0; mant_groups m; m.b1 = m.b2 = m.b4 = 0; for (ch = 1; ch <= s->channels; ch++) { /* transform coefficients for full-bandwidth channel */ decode_transform_coeffs_ch(s, blk, ch, &m); /* tranform coefficients for coupling channel come right after the coefficients for the first coupled channel*/ if (s->channel_in_cpl[ch]) { if (!got_cplchan) { decode_transform_coeffs_ch(s, blk, CPL_CH, &m); calc_transform_coeffs_cpl(s); got_cplchan = 1; } end = s->end_freq[CPL_CH]; } else { end = s->end_freq[ch]; } do s->fixed_coeffs[ch][end] = 0; while(++end < 256); } /* zero the dithered coefficients for appropriate channels */ remove_dithering(s); } /** * Stereo rematrixing. * reference: Section 7.5.4 Rematrixing : Decoding Technique */ static void do_rematrixing(AC3DecodeContext *s) { int bnd, i; int end, bndend; end = FFMIN(s->end_freq[1], s->end_freq[2]); for(bnd=0; bnd<s->num_rematrixing_bands; bnd++) { if(s->rematrixing_flags[bnd]) { bndend = FFMIN(end, ff_ac3_rematrix_band_tab[bnd+1]); for(i=ff_ac3_rematrix_band_tab[bnd]; i<bndend; i++) { int tmp0 = s->fixed_coeffs[1][i]; s->fixed_coeffs[1][i] += s->fixed_coeffs[2][i]; s->fixed_coeffs[2][i] = tmp0 - s->fixed_coeffs[2][i]; } } } } /** * Inverse MDCT Transform. * Convert frequency domain coefficients to time-domain audio samples. * reference: Section 7.9.4 Transformation Equations */ static inline void do_imdct(AC3DecodeContext *s, int channels) { int ch; float add_bias = s->add_bias; if(s->out_channels==1 && channels>1) add_bias *= LEVEL_MINUS_3DB; // compensate for the gain in downmix for (ch=1; ch<=channels; ch++) { if (s->block_switch[ch]) { int i; float *x = s->tmp_output+128; for(i=0; i<128; i++) x[i] = s->transform_coeffs[ch][2*i]; ff_imdct_half(&s->imdct_256, s->tmp_output, x); s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, add_bias, 128); for(i=0; i<128; i++) x[i] = s->transform_coeffs[ch][2*i+1]; ff_imdct_half(&s->imdct_256, s->delay[ch-1], x); } else { ff_imdct_half(&s->imdct_512, s->tmp_output, s->transform_coeffs[ch]); s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, add_bias, 128); memcpy(s->delay[ch-1], s->tmp_output+128, 128*sizeof(float)); } } } /** * Downmix the output to mono or stereo. */ void ff_ac3_downmix_c(float (*samples)[256], float (*matrix)[2], int out_ch, int in_ch, int len) { int i, j; float v0, v1; if(out_ch == 2) { for(i=0; i<len; i++) { v0 = v1 = 0.0f; for(j=0; j<in_ch; j++) { v0 += samples[j][i] * matrix[j][0]; v1 += samples[j][i] * matrix[j][1]; } samples[0][i] = v0; samples[1][i] = v1; } } else if(out_ch == 1) { for(i=0; i<len; i++) { v0 = 0.0f; for(j=0; j<in_ch; j++) v0 += samples[j][i] * matrix[j][0]; samples[0][i] = v0; } } } /** * Upmix delay samples from stereo to original channel layout. */ static void ac3_upmix_delay(AC3DecodeContext *s) { int channel_data_size = sizeof(s->delay[0]); switch(s->channel_mode) { case AC3_CHMODE_DUALMONO: case AC3_CHMODE_STEREO: /* upmix mono to stereo */ memcpy(s->delay[1], s->delay[0], channel_data_size); break; case AC3_CHMODE_2F2R: memset(s->delay[3], 0, channel_data_size); case AC3_CHMODE_2F1R: memset(s->delay[2], 0, channel_data_size); break; case AC3_CHMODE_3F2R: memset(s->delay[4], 0, channel_data_size); case AC3_CHMODE_3F1R: memset(s->delay[3], 0, channel_data_size); case AC3_CHMODE_3F: memcpy(s->delay[2], s->delay[1], channel_data_size); memset(s->delay[1], 0, channel_data_size); break; } } /** * Decode band structure for coupling, spectral extension, or enhanced coupling. * The band structure defines how many subbands are in each band. For each * subband in the range, 1 means it is combined with the previous band, and 0 * means that it starts a new band. * * @param[in] gbc bit reader context * @param[in] blk block number * @param[in] eac3 flag to indicate E-AC-3 * @param[in] ecpl flag to indicate enhanced coupling * @param[in] start_subband subband number for start of range * @param[in] end_subband subband number for end of range * @param[in] default_band_struct default band structure table * @param[out] num_bands number of bands (optionally NULL) * @param[out] band_sizes array containing the number of bins in each band (optionally NULL) */ static void decode_band_structure(GetBitContext *gbc, int blk, int eac3, int ecpl, int start_subband, int end_subband, const uint8_t *default_band_struct, int *num_bands, uint8_t *band_sizes) { int subbnd, bnd, n_subbands, n_bands=0; uint8_t bnd_sz[22]; uint8_t coded_band_struct[22]; const uint8_t *band_struct; n_subbands = end_subband - start_subband; /* decode band structure from bitstream or use default */ if (!eac3 || get_bits1(gbc)) { for (subbnd = 0; subbnd < n_subbands - 1; subbnd++) { coded_band_struct[subbnd] = get_bits1(gbc); } band_struct = coded_band_struct; } else if (!blk) { band_struct = &default_band_struct[start_subband+1]; } else { /* no change in band structure */ return; } /* calculate number of bands and band sizes based on band structure. note that the first 4 subbands in enhanced coupling span only 6 bins instead of 12. */ if (num_bands || band_sizes ) { n_bands = n_subbands; bnd_sz[0] = ecpl ? 6 : 12; for (bnd = 0, subbnd = 1; subbnd < n_subbands; subbnd++) { int subbnd_size = (ecpl && subbnd < 4) ? 6 : 12; if (band_struct[subbnd-1]) { n_bands--; bnd_sz[bnd] += subbnd_size; } else { bnd_sz[++bnd] = subbnd_size; } } } /* set optional output params */ if (num_bands) *num_bands = n_bands; if (band_sizes) memcpy(band_sizes, bnd_sz, n_bands); } /** * Decode a single audio block from the AC-3 bitstream. */ static int decode_audio_block(AC3DecodeContext *s, int blk) { int fbw_channels = s->fbw_channels; int channel_mode = s->channel_mode; int i, bnd, seg, ch; int different_transforms; int downmix_output; int cpl_in_use; GetBitContext *gbc = &s->gbc; uint8_t bit_alloc_stages[AC3_MAX_CHANNELS]; memset(bit_alloc_stages, 0, AC3_MAX_CHANNELS); /* block switch flags */ different_transforms = 0; if (s->block_switch_syntax) { for (ch = 1; ch <= fbw_channels; ch++) { s->block_switch[ch] = get_bits1(gbc); if(ch > 1 && s->block_switch[ch] != s->block_switch[1]) different_transforms = 1; } } /* dithering flags */ if (s->dither_flag_syntax) { for (ch = 1; ch <= fbw_channels; ch++) { s->dither_flag[ch] = get_bits1(gbc); } } /* dynamic range */ i = !(s->channel_mode); do { if(get_bits1(gbc)) { s->dynamic_range[i] = ((dynamic_range_tab[get_bits(gbc, 8)]-1.0) * s->avctx->drc_scale)+1.0; } else if(blk == 0) { s->dynamic_range[i] = 1.0f; } } while(i--); /* spectral extension strategy */ if (s->eac3 && (!blk || get_bits1(gbc))) { s->spx_in_use = get_bits1(gbc); if (s->spx_in_use) { int dst_start_freq, dst_end_freq, src_start_freq, start_subband, end_subband; /* determine which channels use spx */ if (s->channel_mode == AC3_CHMODE_MONO) { s->channel_uses_spx[1] = 1; } else { for (ch = 1; ch <= fbw_channels; ch++) s->channel_uses_spx[ch] = get_bits1(gbc); } /* get the frequency bins of the spx copy region and the spx start and end subbands */ dst_start_freq = get_bits(gbc, 2); start_subband = get_bits(gbc, 3) + 2; if (start_subband > 7) start_subband += start_subband - 7; end_subband = get_bits(gbc, 3) + 5; if (end_subband > 7) end_subband += end_subband - 7; dst_start_freq = dst_start_freq * 12 + 25; src_start_freq = start_subband * 12 + 25; dst_end_freq = end_subband * 12 + 25; /* check validity of spx ranges */ if (start_subband >= end_subband) { av_log(s->avctx, AV_LOG_ERROR, "invalid spectral extension " "range (%d >= %d)\n", start_subband, end_subband); return -1; } if (dst_start_freq >= src_start_freq) { av_log(s->avctx, AV_LOG_ERROR, "invalid spectral extension " "copy start bin (%d >= %d)\n", dst_start_freq, src_start_freq); return -1; } s->spx_dst_start_freq = dst_start_freq; s->spx_src_start_freq = src_start_freq; s->spx_dst_end_freq = dst_end_freq; decode_band_structure(gbc, blk, s->eac3, 0, start_subband, end_subband, ff_eac3_default_spx_band_struct, &s->num_spx_bands, s->spx_band_sizes); } else { for (ch = 1; ch <= fbw_channels; ch++) { s->channel_uses_spx[ch] = 0; s->first_spx_coords[ch] = 1; } } } /* spectral extension coordinates */ if (s->spx_in_use) { for (ch = 1; ch <= fbw_channels; ch++) { if (s->channel_uses_spx[ch]) { if (s->first_spx_coords[ch] || get_bits1(gbc)) { float spx_blend; int bin, master_spx_coord; s->first_spx_coords[ch] = 0; spx_blend = get_bits(gbc, 5) * (1.0f/32); master_spx_coord = get_bits(gbc, 2) * 3; bin = s->spx_src_start_freq; for (bnd = 0; bnd < s->num_spx_bands; bnd++) { int bandsize; int spx_coord_exp, spx_coord_mant; float nratio, sblend, nblend, spx_coord; /* calculate blending factors */ bandsize = s->spx_band_sizes[bnd]; nratio = ((float)((bin + (bandsize >> 1))) / s->spx_dst_end_freq) - spx_blend; nratio = av_clipf(nratio, 0.0f, 1.0f); nblend = sqrtf(3.0f * nratio); // noise is scaled by sqrt(3) to give unity variance sblend = sqrtf(1.0f - nratio); bin += bandsize; /* decode spx coordinates */ spx_coord_exp = get_bits(gbc, 4); spx_coord_mant = get_bits(gbc, 2); if (spx_coord_exp == 15) spx_coord_mant <<= 1; else spx_coord_mant += 4; spx_coord_mant <<= (25 - spx_coord_exp - master_spx_coord); spx_coord = spx_coord_mant * (1.0f/(1<<23)); /* multiply noise and signal blending factors by spx coordinate */ s->spx_noise_blend [ch][bnd] = nblend * spx_coord; s->spx_signal_blend[ch][bnd] = sblend * spx_coord; } } } else { s->first_spx_coords[ch] = 1; } } } /* coupling strategy */ if (s->eac3 ? s->cpl_strategy_exists[blk] : get_bits1(gbc)) { memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS); if (!s->eac3) s->cpl_in_use[blk] = get_bits1(gbc); if (s->cpl_in_use[blk]) { /* coupling in use */ int cpl_start_subband, cpl_end_subband; if (channel_mode < AC3_CHMODE_STEREO) { av_log(s->avctx, AV_LOG_ERROR, "coupling not allowed in mono or dual-mono\n"); return -1; } /* check for enhanced coupling */ if (s->eac3 && get_bits1(gbc)) { /* TODO: parse enhanced coupling strategy info */ av_log_missing_feature(s->avctx, "Enhanced coupling", 1); return -1; } /* determine which channels are coupled */ if (s->eac3 && s->channel_mode == AC3_CHMODE_STEREO) { s->channel_in_cpl[1] = 1; s->channel_in_cpl[2] = 1; } else { for (ch = 1; ch <= fbw_channels; ch++) s->channel_in_cpl[ch] = get_bits1(gbc); } /* phase flags in use */ if (channel_mode == AC3_CHMODE_STEREO) s->phase_flags_in_use = get_bits1(gbc); /* coupling frequency range */ cpl_start_subband = get_bits(gbc, 4); cpl_end_subband = s->spx_in_use ? (s->spx_src_start_freq - 37) / 12 : get_bits(gbc, 4) + 3; if (cpl_start_subband >= cpl_end_subband) { av_log(s->avctx, AV_LOG_ERROR, "invalid coupling range (%d >= %d)\n", cpl_start_subband, cpl_end_subband); return -1; } s->start_freq[CPL_CH] = cpl_start_subband * 12 + 37; s->end_freq[CPL_CH] = cpl_end_subband * 12 + 37; decode_band_structure(gbc, blk, s->eac3, 0, cpl_start_subband, cpl_end_subband, ff_eac3_default_cpl_band_struct, &s->num_cpl_bands, s->cpl_band_sizes); } else { /* coupling not in use */ for (ch = 1; ch <= fbw_channels; ch++) { s->channel_in_cpl[ch] = 0; s->first_cpl_coords[ch] = 1; } s->first_cpl_leak = s->eac3; s->phase_flags_in_use = 0; } } else if (!s->eac3) { if(!blk) { av_log(s->avctx, AV_LOG_ERROR, "new coupling strategy must be present in block 0\n"); return -1; } else { s->cpl_in_use[blk] = s->cpl_in_use[blk-1]; } } cpl_in_use = s->cpl_in_use[blk]; /* coupling coordinates */ if (cpl_in_use) { int cpl_coords_exist = 0; for (ch = 1; ch <= fbw_channels; ch++) { if (s->channel_in_cpl[ch]) { if ((s->eac3 && s->first_cpl_coords[ch]) || get_bits1(gbc)) { int master_cpl_coord, cpl_coord_exp, cpl_coord_mant; s->first_cpl_coords[ch] = 0; cpl_coords_exist = 1; master_cpl_coord = 3 * get_bits(gbc, 2); for (bnd = 0; bnd < s->num_cpl_bands; bnd++) { cpl_coord_exp = get_bits(gbc, 4); cpl_coord_mant = get_bits(gbc, 4); if (cpl_coord_exp == 15) s->cpl_coords[ch][bnd] = cpl_coord_mant << 22; else s->cpl_coords[ch][bnd] = (cpl_coord_mant + 16) << 21; s->cpl_coords[ch][bnd] >>= (cpl_coord_exp + master_cpl_coord); } } else if (!blk) { av_log(s->avctx, AV_LOG_ERROR, "new coupling coordinates must be present in block 0\n"); return -1; } } else { /* channel not in coupling */ s->first_cpl_coords[ch] = 1; } } /* phase flags */ if (channel_mode == AC3_CHMODE_STEREO && cpl_coords_exist) { for (bnd = 0; bnd < s->num_cpl_bands; bnd++) { s->phase_flags[bnd] = s->phase_flags_in_use? get_bits1(gbc) : 0; } } } /* stereo rematrixing strategy and band structure */ if (channel_mode == AC3_CHMODE_STEREO) { if ((s->eac3 && !blk) || get_bits1(gbc)) { s->num_rematrixing_bands = 4; if (cpl_in_use && s->start_freq[CPL_CH] <= 61) { s->num_rematrixing_bands -= 1 + (s->start_freq[CPL_CH] == 37); } else if (s->spx_in_use && s->spx_src_start_freq <= 61) { s->num_rematrixing_bands--; } for(bnd=0; bnd<s->num_rematrixing_bands; bnd++) s->rematrixing_flags[bnd] = get_bits1(gbc); } else if (!blk) { av_log(s->avctx, AV_LOG_WARNING, "Warning: new rematrixing strategy not present in block 0\n"); s->num_rematrixing_bands = 0; } } /* exponent strategies for each channel */ for (ch = !cpl_in_use; ch <= s->channels; ch++) { if (!s->eac3) s->exp_strategy[blk][ch] = get_bits(gbc, 2 - (ch == s->lfe_ch)); if(s->exp_strategy[blk][ch] != EXP_REUSE) bit_alloc_stages[ch] = 3; } /* channel bandwidth */ for (ch = 1; ch <= fbw_channels; ch++) { s->start_freq[ch] = 0; if (s->exp_strategy[blk][ch] != EXP_REUSE) { int group_size; int prev = s->end_freq[ch]; if (s->channel_in_cpl[ch]) s->end_freq[ch] = s->start_freq[CPL_CH]; else if (s->channel_uses_spx[ch]) s->end_freq[ch] = s->spx_src_start_freq; else { int bandwidth_code = get_bits(gbc, 6); if (bandwidth_code > 60) { av_log(s->avctx, AV_LOG_ERROR, "bandwidth code = %d > 60\n", bandwidth_code); return -1; } s->end_freq[ch] = bandwidth_code * 3 + 73; } group_size = 3 << (s->exp_strategy[blk][ch] - 1); s->num_exp_groups[ch] = (s->end_freq[ch]+group_size-4) / group_size; if(blk > 0 && s->end_freq[ch] != prev) memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS); } } if (cpl_in_use && s->exp_strategy[blk][CPL_CH] != EXP_REUSE) { s->num_exp_groups[CPL_CH] = (s->end_freq[CPL_CH] - s->start_freq[CPL_CH]) / (3 << (s->exp_strategy[blk][CPL_CH] - 1)); } /* decode exponents for each channel */ for (ch = !cpl_in_use; ch <= s->channels; ch++) { if (s->exp_strategy[blk][ch] != EXP_REUSE) { s->dexps[ch][0] = get_bits(gbc, 4) << !ch; if (decode_exponents(gbc, s->exp_strategy[blk][ch], s->num_exp_groups[ch], s->dexps[ch][0], &s->dexps[ch][s->start_freq[ch]+!!ch])) { av_log(s->avctx, AV_LOG_ERROR, "exponent out-of-range\n"); return -1; } if(ch != CPL_CH && ch != s->lfe_ch) skip_bits(gbc, 2); /* skip gainrng */ } } /* bit allocation information */ if (s->bit_allocation_syntax) { if (get_bits1(gbc)) { s->bit_alloc_params.slow_decay = ff_ac3_slow_decay_tab[get_bits(gbc, 2)] >> s->bit_alloc_params.sr_shift; s->bit_alloc_params.fast_decay = ff_ac3_fast_decay_tab[get_bits(gbc, 2)] >> s->bit_alloc_params.sr_shift; s->bit_alloc_params.slow_gain = ff_ac3_slow_gain_tab[get_bits(gbc, 2)]; s->bit_alloc_params.db_per_bit = ff_ac3_db_per_bit_tab[get_bits(gbc, 2)]; s->bit_alloc_params.floor = ff_ac3_floor_tab[get_bits(gbc, 3)]; for(ch=!cpl_in_use; ch<=s->channels; ch++) bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2); } else if (!blk) { av_log(s->avctx, AV_LOG_ERROR, "new bit allocation info must be present in block 0\n"); return -1; } } /* signal-to-noise ratio offsets and fast gains (signal-to-mask ratios) */ if(!s->eac3 || !blk){ if(s->snr_offset_strategy && get_bits1(gbc)) { int snr = 0; int csnr; csnr = (get_bits(gbc, 6) - 15) << 4; for (i = ch = !cpl_in_use; ch <= s->channels; ch++) { /* snr offset */ if (ch == i || s->snr_offset_strategy == 2) snr = (csnr + get_bits(gbc, 4)) << 2; /* run at least last bit allocation stage if snr offset changes */ if(blk && s->snr_offset[ch] != snr) { bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 1); } s->snr_offset[ch] = snr; /* fast gain (normal AC-3 only) */ if (!s->eac3) { int prev = s->fast_gain[ch]; s->fast_gain[ch] = ff_ac3_fast_gain_tab[get_bits(gbc, 3)]; /* run last 2 bit allocation stages if fast gain changes */ if(blk && prev != s->fast_gain[ch]) bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2); } } } else if (!s->eac3 && !blk) { av_log(s->avctx, AV_LOG_ERROR, "new snr offsets must be present in block 0\n"); return -1; } } /* fast gain (E-AC-3 only) */ if (s->fast_gain_syntax && get_bits1(gbc)) { for (ch = !cpl_in_use; ch <= s->channels; ch++) { int prev = s->fast_gain[ch]; s->fast_gain[ch] = ff_ac3_fast_gain_tab[get_bits(gbc, 3)]; /* run last 2 bit allocation stages if fast gain changes */ if(blk && prev != s->fast_gain[ch]) bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2); } } else if (s->eac3 && !blk) { for (ch = !cpl_in_use; ch <= s->channels; ch++) s->fast_gain[ch] = ff_ac3_fast_gain_tab[4]; } /* E-AC-3 to AC-3 converter SNR offset */ if (s->frame_type == EAC3_FRAME_TYPE_INDEPENDENT && get_bits1(gbc)) { skip_bits(gbc, 10); // skip converter snr offset } /* coupling leak information */ if (cpl_in_use) { if (s->first_cpl_leak || get_bits1(gbc)) { int fl = get_bits(gbc, 3); int sl = get_bits(gbc, 3); /* run last 2 bit allocation stages for coupling channel if coupling leak changes */ if(blk && (fl != s->bit_alloc_params.cpl_fast_leak || sl != s->bit_alloc_params.cpl_slow_leak)) { bit_alloc_stages[CPL_CH] = FFMAX(bit_alloc_stages[CPL_CH], 2); } s->bit_alloc_params.cpl_fast_leak = fl; s->bit_alloc_params.cpl_slow_leak = sl; } else if (!s->eac3 && !blk) { av_log(s->avctx, AV_LOG_ERROR, "new coupling leak info must be present in block 0\n"); return -1; } s->first_cpl_leak = 0; } /* delta bit allocation information */ if (s->dba_syntax && get_bits1(gbc)) { /* delta bit allocation exists (strategy) */ for (ch = !cpl_in_use; ch <= fbw_channels; ch++) { s->dba_mode[ch] = get_bits(gbc, 2); if (s->dba_mode[ch] == DBA_RESERVED) { av_log(s->avctx, AV_LOG_ERROR, "delta bit allocation strategy reserved\n"); return -1; } bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2); } /* channel delta offset, len and bit allocation */ for (ch = !cpl_in_use; ch <= fbw_channels; ch++) { if (s->dba_mode[ch] == DBA_NEW) { s->dba_nsegs[ch] = get_bits(gbc, 3); for (seg = 0; seg <= s->dba_nsegs[ch]; seg++) { s->dba_offsets[ch][seg] = get_bits(gbc, 5); s->dba_lengths[ch][seg] = get_bits(gbc, 4); s->dba_values[ch][seg] = get_bits(gbc, 3); } /* run last 2 bit allocation stages if new dba values */ bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2); } } } else if(blk == 0) { for(ch=0; ch<=s->channels; ch++) { s->dba_mode[ch] = DBA_NONE; } } /* Bit allocation */ for(ch=!cpl_in_use; ch<=s->channels; ch++) { if(bit_alloc_stages[ch] > 2) { /* Exponent mapping into PSD and PSD integration */ ff_ac3_bit_alloc_calc_psd(s->dexps[ch], s->start_freq[ch], s->end_freq[ch], s->psd[ch], s->band_psd[ch]); } if(bit_alloc_stages[ch] > 1) { /* Compute excitation function, Compute masking curve, and Apply delta bit allocation */ if (ff_ac3_bit_alloc_calc_mask(&s->bit_alloc_params, s->band_psd[ch], s->start_freq[ch], s->end_freq[ch], s->fast_gain[ch], (ch == s->lfe_ch), s->dba_mode[ch], s->dba_nsegs[ch], s->dba_offsets[ch], s->dba_lengths[ch], s->dba_values[ch], s->mask[ch])) { av_log(s->avctx, AV_LOG_ERROR, "error in bit allocation\n"); return -1; } } if(bit_alloc_stages[ch] > 0) { /* Compute bit allocation */ const uint8_t *bap_tab = s->channel_uses_aht[ch] ? ff_eac3_hebap_tab : ff_ac3_bap_tab; ff_ac3_bit_alloc_calc_bap(s->mask[ch], s->psd[ch], s->start_freq[ch], s->end_freq[ch], s->snr_offset[ch], s->bit_alloc_params.floor, bap_tab, s->bap[ch]); } } /* unused dummy data */ if (s->skip_syntax && get_bits1(gbc)) { int skipl = get_bits(gbc, 9); while(skipl--) skip_bits(gbc, 8); } /* unpack the transform coefficients this also uncouples channels if coupling is in use. */ decode_transform_coeffs(s, blk); /* TODO: generate enhanced coupling coordinates and uncouple */ /* recover coefficients if rematrixing is in use */ if(s->channel_mode == AC3_CHMODE_STEREO) do_rematrixing(s); /* apply scaling to coefficients (headroom, dynrng) */ for(ch=1; ch<=s->channels; ch++) { float gain = s->mul_bias / 4194304.0f; if(s->channel_mode == AC3_CHMODE_DUALMONO) { gain *= s->dynamic_range[2-ch]; } else { gain *= s->dynamic_range[0]; } s->dsp.int32_to_float_fmul_scalar(s->transform_coeffs[ch], s->fixed_coeffs[ch], gain, 256); } /* apply spectral extension to high frequency bins */ if (s->spx_in_use && CONFIG_EAC3_DECODER) { ff_eac3_apply_spectral_extension(s); } /* downmix and MDCT. order depends on whether block switching is used for any channel in this block. this is because coefficients for the long and short transforms cannot be mixed. */ downmix_output = s->channels != s->out_channels && !((s->output_mode & AC3_OUTPUT_LFEON) && s->fbw_channels == s->out_channels); if(different_transforms) { /* the delay samples have already been downmixed, so we upmix the delay samples in order to reconstruct all channels before downmixing. */ if(s->downmixed) { s->downmixed = 0; ac3_upmix_delay(s); } do_imdct(s, s->channels); if(downmix_output) { s->dsp.ac3_downmix(s->output, s->downmix_coeffs, s->out_channels, s->fbw_channels, 256); } } else { if(downmix_output) { s->dsp.ac3_downmix(s->transform_coeffs+1, s->downmix_coeffs, s->out_channels, s->fbw_channels, 256); } if(downmix_output && !s->downmixed) { s->downmixed = 1; s->dsp.ac3_downmix(s->delay, s->downmix_coeffs, s->out_channels, s->fbw_channels, 128); } do_imdct(s, s->out_channels); } return 0; } /** * Decode a single AC-3 frame. */ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; AC3DecodeContext *s = avctx->priv_data; int16_t *out_samples = (int16_t *)data; int blk, ch, err; const uint8_t *channel_map; const float *output[AC3_MAX_CHANNELS]; /* initialize the GetBitContext with the start of valid AC-3 Frame */ if (s->input_buffer) { /* copy input buffer to decoder context to avoid reading past the end of the buffer, which can be caused by a damaged input stream. */ memcpy(s->input_buffer, buf, FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE)); init_get_bits(&s->gbc, s->input_buffer, buf_size * 8); } else { init_get_bits(&s->gbc, buf, buf_size * 8); } /* parse the syncinfo */ *data_size = 0; err = parse_frame_header(s); if (err) { switch(err) { case AAC_AC3_PARSE_ERROR_SYNC: av_log(avctx, AV_LOG_ERROR, "frame sync error\n"); return -1; case AAC_AC3_PARSE_ERROR_BSID: av_log(avctx, AV_LOG_ERROR, "invalid bitstream id\n"); break; case AAC_AC3_PARSE_ERROR_SAMPLE_RATE: av_log(avctx, AV_LOG_ERROR, "invalid sample rate\n"); break; case AAC_AC3_PARSE_ERROR_FRAME_SIZE: av_log(avctx, AV_LOG_ERROR, "invalid frame size\n"); break; case AAC_AC3_PARSE_ERROR_FRAME_TYPE: /* skip frame if CRC is ok. otherwise use error concealment. */ /* TODO: add support for substreams and dependent frames */ if(s->frame_type == EAC3_FRAME_TYPE_DEPENDENT || s->substreamid) { av_log(avctx, AV_LOG_ERROR, "unsupported frame type : skipping frame\n"); return s->frame_size; } else { av_log(avctx, AV_LOG_ERROR, "invalid frame type\n"); } break; default: av_log(avctx, AV_LOG_ERROR, "invalid header\n"); break; } } else { /* check that reported frame size fits in input buffer */ if (s->frame_size > buf_size) { av_log(avctx, AV_LOG_ERROR, "incomplete frame\n"); err = AAC_AC3_PARSE_ERROR_FRAME_SIZE; } else if (avctx->error_recognition >= FF_ER_CAREFUL) { /* check for crc mismatch */ if (av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &buf[2], s->frame_size-2)) { av_log(avctx, AV_LOG_ERROR, "frame CRC mismatch\n"); err = AAC_AC3_PARSE_ERROR_CRC; } } } /* if frame is ok, set audio parameters */ if (!err) { avctx->sample_rate = s->sample_rate; avctx->bit_rate = s->bit_rate; /* channel config */ s->out_channels = s->channels; s->output_mode = s->channel_mode; if(s->lfe_on) s->output_mode |= AC3_OUTPUT_LFEON; if (avctx->request_channels > 0 && avctx->request_channels <= 2 && avctx->request_channels < s->channels) { s->out_channels = avctx->request_channels; s->output_mode = avctx->request_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO; s->channel_layout = ff_ac3_channel_layout_tab[s->output_mode]; } avctx->channels = s->out_channels; avctx->channel_layout = s->channel_layout; /* set downmixing coefficients if needed */ if(s->channels != s->out_channels && !((s->output_mode & AC3_OUTPUT_LFEON) && s->fbw_channels == s->out_channels)) { set_downmix_coeffs(s); } } else if (!s->out_channels) { s->out_channels = avctx->channels; if(s->out_channels < s->channels) s->output_mode = s->out_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO; } /* decode the audio blocks */ channel_map = ff_ac3_dec_channel_map[s->output_mode & ~AC3_OUTPUT_LFEON][s->lfe_on]; for (ch = 0; ch < s->out_channels; ch++) output[ch] = s->output[channel_map[ch]]; for (blk = 0; blk < s->num_blocks; blk++) { if (!err && decode_audio_block(s, blk)) { av_log(avctx, AV_LOG_ERROR, "error decoding the audio block\n"); err = 1; } s->dsp.float_to_int16_interleave(out_samples, output, 256, s->out_channels); out_samples += 256 * s->out_channels; } *data_size = s->num_blocks * 256 * avctx->channels * sizeof (int16_t); return FFMIN(buf_size, s->frame_size); } /** * Uninitialize the AC-3 decoder. */ static av_cold int ac3_decode_end(AVCodecContext *avctx) { AC3DecodeContext *s = avctx->priv_data; ff_mdct_end(&s->imdct_512); ff_mdct_end(&s->imdct_256); av_freep(&s->input_buffer); return 0; } AVCodec ac3_decoder = { .name = "ac3", .type = AVMEDIA_TYPE_AUDIO, .id = CODEC_ID_AC3, .priv_data_size = sizeof (AC3DecodeContext), .init = ac3_decode_init, .close = ac3_decode_end, .decode = ac3_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"), }; #if CONFIG_EAC3_DECODER AVCodec eac3_decoder = { .name = "eac3", .type = AVMEDIA_TYPE_AUDIO, .id = CODEC_ID_EAC3, .priv_data_size = sizeof (AC3DecodeContext), .init = ac3_decode_init, .close = ac3_decode_end, .decode = ac3_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"), }; #endif
123linslouis-android-video-cutter
jni/libavcodec/ac3dec.c
C
asf20
53,491
/* * AMR narrowband data and definitions * Copyright (c) 2006-2007 Robert Swain * Copyright (c) 2009 Colin McQuillan * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * AMR narrowband data and definitions */ #ifndef AVCODEC_AMRNBDATA_H #define AVCODEC_AMRNBDATA_H #include <stdint.h> #include "libavutil/common.h" /* offsetof */ #define AMR_SUBFRAME_SIZE 40 ///< samples per subframe /** Frame type (Table 1a in 3GPP TS 26.101) */ enum Mode { MODE_4k75 = 0, ///< 4.75 kbit/s MODE_5k15, ///< 5.15 kbit/s MODE_5k9, ///< 5.90 kbit/s MODE_6k7, ///< 6.70 kbit/s MODE_7k4, ///< 7.40 kbit/s MODE_7k95, ///< 7.95 kbit/s MODE_10k2, ///< 10.2 kbit/s MODE_12k2, ///< 12.2 kbit/s MODE_DTX, ///< silent frame N_MODES, ///< number of modes NO_DATA = 15 ///< no transmission }; #define LP_FILTER_ORDER 10 ///< linear predictive coding filter order /** * AMRNB unpacked data subframe */ typedef struct { uint16_t p_lag; ///< index to decode the pitch lag uint16_t p_gain; ///< index to decode the pitch gain uint16_t fixed_gain; ///< index to decode the fixed gain factor, for MODE_12k2 and MODE_7k95 uint16_t pulses[10]; ///< pulses: 10 for MODE_12k2, 7 for MODE_10k2, and index and sign for others } AMRNBSubframe; /** * AMRNB unpacked data frame */ typedef struct { uint16_t lsf[5]; ///< lsf parameters: 5 parameters for MODE_12k2, only 3 for other modes AMRNBSubframe subframe[4]; ///< unpacked data for each subframe } AMRNBFrame; /** The index of a frame parameter */ #define AMR_BIT(field) (offsetof(AMRNBFrame, field) >> 1) /** The index of a subframe-specific parameter */ #define AMR_OF(frame_num, variable) AMR_BIT(subframe[frame_num].variable) // The following order* tables are used to convert AMR frame parameters to and // from a bitstream. See 3GPP TS 26.101 for more information. // Each field in AMRNBFrame is stored as: // * one byte for the number of bits in the field // * one byte for the field index // * then, one byte for each bit of the field (from most-significant to least) // of the position of that bit in the AMR frame. static const uint8_t order_MODE_4k75[] = { 8, AMR_BIT(lsf[0]), 7, 6, 5, 4, 3, 2, 1, 0, 8, AMR_BIT(lsf[1]), 15, 14, 13, 12, 11, 10, 9, 8, 7, AMR_BIT(lsf[2]), 51, 35, 34, 50, 33, 49, 32, 8, AMR_OF(0,p_lag), 23, 22, 21, 20, 19, 18, 43, 42, 8, AMR_OF(0,p_gain), 54, 55, 40, 41, 24, 25, 26, 27, 7, AMR_OF(0,pulses[0]), 92, 68, 67, 84, 66, 65, 80, 2, AMR_OF(0,pulses[1]), 53, 52, 4, AMR_OF(1,p_lag), 17, 16, 48, 63, 7, AMR_OF(1,pulses[0]), 91, 64, 79, 83, 78, 77, 95, 2, AMR_OF(1,pulses[1]), 62, 61, 4, AMR_OF(2,p_lag), 31, 30, 60, 59, 8, AMR_OF(2,p_gain), 44, 45, 46, 47, 36, 37, 38, 39, 7, AMR_OF(2,pulses[0]), 90, 76, 75, 82, 74, 73, 94, 2, AMR_OF(2,pulses[1]), 58, 57, 4, AMR_OF(3,p_lag), 29, 28, 56, 71, 7, AMR_OF(3,pulses[0]), 89, 72, 87, 81, 86, 85, 93, 2, AMR_OF(3,pulses[1]), 70, 69, 0 }; static const uint8_t order_MODE_5k15[] = { 8, AMR_BIT(lsf[0]), 0, 1, 2, 3, 4, 5, 6, 7, 8, AMR_BIT(lsf[1]), 8, 9, 10, 11, 12, 13, 14, 15, 7, AMR_BIT(lsf[2]), 70, 51, 43, 71, 50, 60, 49, 8, AMR_OF(0,p_lag), 23, 22, 21, 20, 19, 47, 54, 59, 6, AMR_OF(0,p_gain), 48, 42, 35, 29, 30, 31, 7, AMR_OF(0,pulses[0]), 92, 84, 82, 100, 79, 72, 88, 2, AMR_OF(0,pulses[1]), 67, 68, 4, AMR_OF(1,p_lag), 18, 46, 53, 58, 6, AMR_OF(1,p_gain), 63, 41, 34, 26, 27, 28, 7, AMR_OF(1,pulses[0]), 91, 83, 81, 99, 78, 87, 103, 2, AMR_OF(1,pulses[1]), 65, 66, 4, AMR_OF(2,p_lag), 17, 45, 52, 57, 6, AMR_OF(2,p_gain), 62, 40, 33, 39, 24, 25, 7, AMR_OF(2,pulses[0]), 90, 80, 95, 98, 77, 86, 102, 2, AMR_OF(2,pulses[1]), 75, 64, 4, AMR_OF(3,p_lag), 16, 44, 56, 69, 6, AMR_OF(3,p_gain), 61, 55, 32, 36, 37, 38, 7, AMR_OF(3,pulses[0]), 89, 94, 93, 97, 76, 85, 101, 2, AMR_OF(3,pulses[1]), 73, 74, 0 }; static const uint8_t order_MODE_5k9[] = { 8, AMR_BIT(lsf[0]), 7, 6, 0, 3, 5, 4, 2, 1, 9, AMR_BIT(lsf[1]), 13, 12, 8, 11, 10, 15, 9, 14, 23, 9, AMR_BIT(lsf[2]), 71, 56, 60, 70, 59, 57, 58, 69, 76, 8, AMR_OF(0,p_lag), 16, 18, 22, 20, 30, 38, 44, 42, 6, AMR_OF(0,p_gain), 75, 48, 52, 40, 34, 26, 9, AMR_OF(0,pulses[0]), 101, 89, 93, 117, 105, 81, 85, 109, 97, 2, AMR_OF(0,pulses[1]), 67, 78, 4, AMR_OF(1,p_lag), 28, 36, 46, 87, 6, AMR_OF(1,p_gain), 74, 63, 51, 55, 33, 25, 9, AMR_OF(1,pulses[0]), 100, 88, 92, 116, 104, 80, 84, 108, 96, 2, AMR_OF(1,pulses[1]), 64, 79, 8, AMR_OF(2,p_lag), 31, 17, 21, 19, 29, 37, 43, 41, 6, AMR_OF(2,p_gain), 73, 62, 50, 54, 32, 24, 9, AMR_OF(2,pulses[0]), 99, 103, 91, 115, 119, 95, 83, 107, 111, 2, AMR_OF(2,pulses[1]), 66, 77, 4, AMR_OF(3,p_lag), 27, 35, 45, 86, 6, AMR_OF(3,p_gain), 72, 61, 49, 53, 47, 39, 9, AMR_OF(3,pulses[0]), 98, 102, 90, 114, 118, 94, 82, 106, 110, 2, AMR_OF(3,pulses[1]), 65, 68, 0 }; static const uint8_t order_MODE_6k7[] = { 8, AMR_BIT(lsf[0]), 7, 6, 15, 4, 5, 3, 2, 0, 9, AMR_BIT(lsf[1]), 14, 13, 8, 12, 10, 1, 9, 11, 29, 9, AMR_BIT(lsf[2]), 57, 58, 50, 56, 60, 59, 49, 71, 70, 8, AMR_OF(0,p_lag), 17, 19, 23, 21, 31, 24, 32, 52, 7, AMR_OF(0,p_gain), 36, 82, 69, 46, 42, 48, 77, 11, AMR_OF(0,pulses[0]), 109, 97, 133, 121, 101, 89, 125, 113, 93, 117, 105, 3, AMR_OF(0,pulses[1]), 81, 73, 65, 4, AMR_OF(1,p_lag), 28, 26, 38, 54, 7, AMR_OF(1,p_gain), 35, 83, 68, 45, 41, 63, 76, 11, AMR_OF(1,pulses[0]), 108, 96, 132, 120, 100, 88, 124, 112, 92, 116, 104, 3, AMR_OF(1,pulses[1]), 80, 72, 64, 8, AMR_OF(2,p_lag), 16, 18, 22, 20, 30, 39, 47, 51, 7, AMR_OF(2,p_gain), 34, 84, 67, 44, 40, 62, 75, 11, AMR_OF(2,pulses[0]), 107, 111, 131, 135, 99, 103, 123, 127, 91, 115, 119, 3, AMR_OF(2,pulses[1]), 95, 87, 79, 4, AMR_OF(3,p_lag), 27, 25, 37, 53, 7, AMR_OF(3,p_gain), 33, 85, 66, 43, 55, 61, 74, 11, AMR_OF(3,pulses[0]), 106, 110, 130, 134, 98, 102, 122, 126, 90, 114, 118, 3, AMR_OF(3,pulses[1]), 94, 86, 78, 0 }; static const uint8_t order_MODE_7k4[] = { 8, AMR_BIT(lsf[0]), 7, 6, 5, 4, 3, 2, 1, 0, 9, AMR_BIT(lsf[1]), 15, 14, 13, 12, 11, 10, 9, 8, 23, 9, AMR_BIT(lsf[2]), 53, 52, 51, 58, 40, 55, 54, 57, 56, 8, AMR_OF(0,p_lag), 22, 20, 18, 16, 30, 50, 95, 94, 7, AMR_OF(0,p_gain), 28, 24, 73, 36, 32, 62, 67, 13, AMR_OF(0,pulses[0]), 127, 123, 135, 131, 143, 139, 151, 103, 102, 101, 100, 99, 98, 4, AMR_OF(0,pulses[1]), 83, 75, 79, 71, 5, AMR_OF(1,p_lag), 44, 42, 49, 93, 92, 7, AMR_OF(1,p_gain), 27, 39, 72, 35, 47, 61, 66, 13, AMR_OF(1,pulses[0]), 126, 122, 134, 130, 142, 138, 150, 97, 96, 111, 110, 109, 108, 4, AMR_OF(1,pulses[1]), 82, 74, 78, 70, 8, AMR_OF(2,p_lag), 21, 19, 17, 31, 29, 48, 91, 90, 7, AMR_OF(2,p_gain), 26, 38, 87, 34, 46, 60, 65, 13, AMR_OF(2,pulses[0]), 125, 121, 133, 129, 141, 137, 149, 107, 106, 105, 104, 119, 118, 4, AMR_OF(2,pulses[1]), 81, 85, 77, 69, 5, AMR_OF(3,p_lag), 43, 41, 63, 89, 88, 7, AMR_OF(3,p_gain), 25, 37, 86, 33, 45, 59, 64, 13, AMR_OF(3,pulses[0]), 124, 120, 132, 128, 140, 136, 148, 117, 116, 115, 114, 113, 112, 4, AMR_OF(3,pulses[1]), 80, 84, 76, 68, 0 }; static const uint8_t order_MODE_7k95[] = { 9, AMR_BIT(lsf[0]), 67, 68, 1, 2, 3, 4, 5, 6, 7, 9, AMR_BIT(lsf[1]), 14, 13, 9, 12, 11, 0, 10, 15, 8, 9, AMR_BIT(lsf[2]), 18, 19, 23, 17, 22, 20, 21, 66, 65, 8, AMR_OF(0,p_lag), 44, 42, 40, 54, 52, 56, 64, 78, 4, AMR_OF(0,p_gain), 36, 32, 72, 80, 5, AMR_OF(0,fixed_gain), 16, 28, 24, 60, 84, 13, AMR_OF(0,pulses[0]), 135, 109, 144, 156, 120, 97, 148, 121, 101, 122, 123, 89, 124, 4, AMR_OF(0,pulses[1]), 125, 126, 127, 112, 6, AMR_OF(1,p_lag), 50, 48, 62, 70, 76, 74, 4, AMR_OF(1,p_gain), 35, 47, 87, 95, 5, AMR_OF(1,fixed_gain), 31, 27, 39, 59, 83, 13, AMR_OF(1,pulses[0]), 129, 108, 159, 155, 130, 96, 147, 131, 100, 132, 133, 88, 134, 4, AMR_OF(1,pulses[1]), 113, 114, 115, 116, 8, AMR_OF(2,p_lag), 43, 41, 55, 53, 51, 71, 79, 77, 4, AMR_OF(2,p_gain), 34, 46, 86, 94, 5, AMR_OF(2,fixed_gain), 30, 26, 38, 58, 82, 13, AMR_OF(2,pulses[0]), 139, 107, 158, 154, 140, 111, 146, 141, 99, 142, 143, 103, 128, 4, AMR_OF(2,pulses[1]), 105, 90, 91, 92, 6, AMR_OF(3,p_lag), 49, 63, 61, 69, 75, 73, 4, AMR_OF(3,p_gain), 33, 45, 85, 93, 5, AMR_OF(3,fixed_gain), 29, 25, 37, 57, 81, 13, AMR_OF(3,pulses[0]), 149, 106, 157, 153, 150, 110, 145, 151, 98, 136, 137, 102, 138, 4, AMR_OF(3,pulses[1]), 117, 118, 119, 104, 0 }; static const uint8_t order_MODE_10k2[] = { 8, AMR_BIT(lsf[0]), 0, 1, 2, 3, 4, 5, 6, 7, 9, AMR_BIT(lsf[1]), 23, 8, 9, 10, 11, 12, 13, 14, 15, 9, AMR_BIT(lsf[2]), 57, 58, 62, 56, 60, 59, 61, 71, 70, 8, AMR_OF(0,p_lag), 22, 21, 20, 19, 18, 17, 42, 41, 7, AMR_OF(0,p_gain), 38, 50, 84, 37, 36, 85, 83, 1, AMR_OF(0,pulses[0]), 66, 1, AMR_OF(0,pulses[1]), 67, 1, AMR_OF(0,pulses[2]), 68, 1, AMR_OF(0,pulses[3]), 69, 10, AMR_OF(0,pulses[4]), 145, 144, 156, 153, 154, 163, 161, 192, 206, 195, 10, AMR_OF(0,pulses[5]), 158, 159, 157, 152, 155, 165, 160, 205, 204, 194, 7, AMR_OF(0,pulses[6]), 167, 166, 162, 164, 196, 207, 193, 5, AMR_OF(1,p_lag), 26, 25, 54, 53, 89, 7, AMR_OF(1,p_gain), 35, 49, 81, 34, 33, 82, 80, 1, AMR_OF(1,pulses[0]), 78, 1, AMR_OF(1,pulses[1]), 79, 1, AMR_OF(1,pulses[2]), 64, 1, AMR_OF(1,pulses[3]), 65, 10, AMR_OF(1,pulses[4]), 103, 102, 98, 111, 96, 105, 119, 185, 199, 188, 10, AMR_OF(1,pulses[5]), 100, 101, 99, 110, 97, 107, 118, 198, 197, 187, 7, AMR_OF(1,pulses[6]), 109, 108, 104, 106, 189, 184, 186, 8, AMR_OF(2,p_lag), 16, 31, 30, 29, 28, 27, 40, 55, 7, AMR_OF(2,p_gain), 32, 48, 94, 47, 46, 95, 93, 1, AMR_OF(2,pulses[0]), 74, 1, AMR_OF(2,pulses[1]), 75, 1, AMR_OF(2,pulses[2]), 76, 1, AMR_OF(2,pulses[3]), 77, 10, AMR_OF(2,pulses[4]), 117, 116, 112, 125, 126, 135, 133, 178, 176, 181, 10, AMR_OF(2,pulses[5]), 114, 115, 113, 124, 127, 121, 132, 191, 190, 180, 7, AMR_OF(2,pulses[6]), 123, 122, 134, 120, 182, 177, 179, 5, AMR_OF(3,p_lag), 24, 39, 52, 51, 88, 7, AMR_OF(3,p_gain), 45, 63, 91, 44, 43, 92, 90, 1, AMR_OF(3,pulses[0]), 86, 1, AMR_OF(3,pulses[1]), 87, 1, AMR_OF(3,pulses[2]), 72, 1, AMR_OF(3,pulses[3]), 73, 10, AMR_OF(3,pulses[4]), 131, 130, 142, 139, 140, 149, 147, 171, 169, 174, 10, AMR_OF(3,pulses[5]), 128, 129, 143, 138, 141, 151, 146, 168, 183, 173, 7, AMR_OF(3,pulses[6]), 137, 136, 148, 150, 175, 170, 172, 0 }; static const uint8_t order_MODE_12k2[] = { 7, AMR_BIT(lsf[0]), 7, 6, 5, 4, 3, 2, 1, 8, AMR_BIT(lsf[1]), 0, 15, 14, 13, 12, 11, 10, 9, 9, AMR_BIT(lsf[2]), 23, 22, 21, 20, 19, 18, 17, 16, 8, 8, AMR_BIT(lsf[3]), 31, 30, 29, 28, 27, 86, 85, 84, 6, AMR_BIT(lsf[4]), 83, 82, 81, 80, 127, 126, 9, AMR_OF(0,p_lag), 26, 24, 38, 36, 34, 32, 46, 44, 42, 4, AMR_OF(0,p_gain), 40, 52, 48, 95, 5, AMR_OF(0,fixed_gain), 60, 56, 68, 91, 111, 3, AMR_OF(0,pulses[0]), 191, 176, 177, 4, AMR_OF(0,pulses[1]), 103, 123, 124, 125, 3, AMR_OF(0,pulses[2]), 188, 189, 190, 4, AMR_OF(0,pulses[3]), 99, 120, 121, 122, 3, AMR_OF(0,pulses[4]), 185, 186, 187, 4, AMR_OF(0,pulses[5]), 107, 133, 134, 135, 3, AMR_OF(0,pulses[6]), 198, 199, 184, 4, AMR_OF(0,pulses[7]), 119, 130, 131, 132, 3, AMR_OF(0,pulses[8]), 195, 196, 197, 4, AMR_OF(0,pulses[9]), 115, 143, 128, 129, 6, AMR_OF(1,p_lag), 64, 78, 76, 74, 72, 245, 4, AMR_OF(1,p_gain), 55, 51, 63, 94, 5, AMR_OF(1,fixed_gain), 59, 71, 67, 90, 110, 3, AMR_OF(1,pulses[0]), 192, 193, 194, 4, AMR_OF(1,pulses[1]), 102, 140, 141, 142, 3, AMR_OF(1,pulses[2]), 205, 206, 207, 4, AMR_OF(1,pulses[3]), 98, 137, 138, 139, 3, AMR_OF(1,pulses[4]), 202, 203, 204, 4, AMR_OF(1,pulses[5]), 106, 150, 151, 136, 3, AMR_OF(1,pulses[6]), 215, 200, 201, 4, AMR_OF(1,pulses[7]), 118, 147, 148, 149, 3, AMR_OF(1,pulses[8]), 212, 213, 214, 4, AMR_OF(1,pulses[9]), 114, 144, 145, 146, 9, AMR_OF(2,p_lag), 25, 39, 37, 35, 33, 47, 45, 43, 41, 4, AMR_OF(2,p_gain), 54, 50, 62, 93, 5, AMR_OF(2,fixed_gain), 58, 70, 66, 89, 109, 3, AMR_OF(2,pulses[0]), 209, 210, 211, 4, AMR_OF(2,pulses[1]), 101, 157, 158, 159, 3, AMR_OF(2,pulses[2]), 222, 223, 208, 4, AMR_OF(2,pulses[3]), 97, 154, 155, 156, 3, AMR_OF(2,pulses[4]), 219, 220, 221, 4, AMR_OF(2,pulses[5]), 105, 167, 152, 153, 3, AMR_OF(2,pulses[6]), 216, 217, 218, 4, AMR_OF(2,pulses[7]), 117, 164, 165, 166, 3, AMR_OF(2,pulses[8]), 229, 230, 231, 4, AMR_OF(2,pulses[9]), 113, 161, 162, 163, 6, AMR_OF(3,p_lag), 79, 77, 75, 73, 87, 244, 4, AMR_OF(3,p_gain), 53, 49, 61, 92, 5, AMR_OF(3,fixed_gain), 57, 69, 65, 88, 108, 3, AMR_OF(3,pulses[0]), 226, 227, 228, 4, AMR_OF(3,pulses[1]), 100, 174, 175, 160, 3, AMR_OF(3,pulses[2]), 239, 224, 225, 4, AMR_OF(3,pulses[3]), 96, 171, 172, 173, 3, AMR_OF(3,pulses[4]), 236, 237, 238, 4, AMR_OF(3,pulses[5]), 104, 168, 169, 170, 3, AMR_OF(3,pulses[6]), 233, 234, 235, 4, AMR_OF(3,pulses[7]), 116, 181, 182, 183, 3, AMR_OF(3,pulses[8]), 246, 247, 232, 4, AMR_OF(3,pulses[9]), 112, 178, 179, 180, 0 }; /** * position of the bitmapping data for each packet type in * the AMRNBFrame */ static const uint8_t * const amr_unpacking_bitmaps_per_mode[N_MODES] = { order_MODE_4k75, order_MODE_5k15, order_MODE_5k9, order_MODE_6k7, order_MODE_7k4, order_MODE_7k95, order_MODE_10k2, order_MODE_12k2, }; /** number of bytes for each mode */ static const uint8_t frame_sizes_nb[N_MODES] = { 12, 13, 15, 17, 19, 20, 26, 31, 5 }; /** * Base-5 representation for values 0-124 * * This is useful for decoding pulse positions in 10.2 kbit/s frames. * Safe values are provided for out of range positions 125-127. */ static const uint8_t base_five_table[128][3] = { {0, 0, 0}, {0, 0, 1}, {0, 0, 2}, {0, 0, 3}, {0, 0, 4}, {0, 1, 0}, {0, 1, 1}, {0, 1, 2}, {0, 1, 3}, {0, 1, 4}, {0, 2, 0}, {0, 2, 1}, {0, 2, 2}, {0, 2, 3}, {0, 2, 4}, {0, 3, 0}, {0, 3, 1}, {0, 3, 2}, {0, 3, 3}, {0, 3, 4}, {0, 4, 0}, {0, 4, 1}, {0, 4, 2}, {0, 4, 3}, {0, 4, 4}, {1, 0, 0}, {1, 0, 1}, {1, 0, 2}, {1, 0, 3}, {1, 0, 4}, {1, 1, 0}, {1, 1, 1}, {1, 1, 2}, {1, 1, 3}, {1, 1, 4}, {1, 2, 0}, {1, 2, 1}, {1, 2, 2}, {1, 2, 3}, {1, 2, 4}, {1, 3, 0}, {1, 3, 1}, {1, 3, 2}, {1, 3, 3}, {1, 3, 4}, {1, 4, 0}, {1, 4, 1}, {1, 4, 2}, {1, 4, 3}, {1, 4, 4}, {2, 0, 0}, {2, 0, 1}, {2, 0, 2}, {2, 0, 3}, {2, 0, 4}, {2, 1, 0}, {2, 1, 1}, {2, 1, 2}, {2, 1, 3}, {2, 1, 4}, {2, 2, 0}, {2, 2, 1}, {2, 2, 2}, {2, 2, 3}, {2, 2, 4}, {2, 3, 0}, {2, 3, 1}, {2, 3, 2}, {2, 3, 3}, {2, 3, 4}, {2, 4, 0}, {2, 4, 1}, {2, 4, 2}, {2, 4, 3}, {2, 4, 4}, {3, 0, 0}, {3, 0, 1}, {3, 0, 2}, {3, 0, 3}, {3, 0, 4}, {3, 1, 0}, {3, 1, 1}, {3, 1, 2}, {3, 1, 3}, {3, 1, 4}, {3, 2, 0}, {3, 2, 1}, {3, 2, 2}, {3, 2, 3}, {3, 2, 4}, {3, 3, 0}, {3, 3, 1}, {3, 3, 2}, {3, 3, 3}, {3, 3, 4}, {3, 4, 0}, {3, 4, 1}, {3, 4, 2}, {3, 4, 3}, {3, 4, 4}, {4, 0, 0}, {4, 0, 1}, {4, 0, 2}, {4, 0, 3}, {4, 0, 4}, {4, 1, 0}, {4, 1, 1}, {4, 1, 2}, {4, 1, 3}, {4, 1, 4}, {4, 2, 0}, {4, 2, 1}, {4, 2, 2}, {4, 2, 3}, {4, 2, 4}, {4, 3, 0}, {4, 3, 1}, {4, 3, 2}, {4, 3, 3}, {4, 3, 4}, {4, 4, 0}, {4, 4, 1}, {4, 4, 2}, {4, 4, 3}, {4, 4, 4}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0} }; /** * Values for the lsp vector from the 4th subframe of the * previous subframe values. * * @note: Taken from Decoder_amr_reset in Q15 using val/1000 */ static const int8_t lsp_sub4_init[LP_FILTER_ORDER] = { 30, 26, 21, 15, 8, 0, -8, -15, -21, -26 }; /** * Mean lsp values. * * @note: Taken from Decoder_amr_reset in Q15 */ static const int16_t lsp_avg_init[LP_FILTER_ORDER] = { 1384, 2077, 3420, 5108, 6742, 8122, 9863, 11092, 12714, 13701 }; // LSF tables // These are stored as integers to save space. The values are taken from // q_plsf_3.tab and q_plsf_5.tab in 3GPP TS 26.090. static const int16_t lsf_3_3_MODE_5k15[128][4] = { { 419, 163, -30, -262}, { -455, -789,-1430, -721}, { 1006, 664, 269, 25}, { 619, 260, 183, 96}, { -968,-1358, -388, 135}, { -693, 835, 456, 154}, { 1105, 703, 569, 363}, { 1625, 1326, 985, 748}, { -220, 219, 76, -208}, {-1455,-1662, 49, 149}, { -964, -172, -752, -336}, { 625, 209, -250, -66}, {-1017, -838, -2, 317}, {-2168,-1485, -138, 123}, {-1876,-2099, -521, 85}, { -967, -366, -695, -881}, { -921,-1011, -763, -949}, { -124, -256, -352, -660}, { 178, 463, 354, 304}, {-1744, -591, -282, 79}, {-2249, 175, 867, 499}, { -138, -180, -181, -21}, {-2291,-1241, -460, -520}, { -771, 451, -10, -308}, { 271, -65, 4, 214}, { -279, -435, -43, -348}, { -670, 35, -65, -211}, { 806, 535, 85, 297}, { 57, 239, 722, 493}, { 225, 661, 840, 547}, { -540, -376, 14, 349}, { 469, 721, 331, 162}, { -544, -752, -62, -10}, { 398, -88, 724, 701}, { -19, -533, -94, 601}, { 136, -71, -681, -747}, { -166, -344, 261, -50}, { 161, -52, 485, 337}, {-1675, 50, 190, -93}, {-2282, -231, -194, -82}, { -95, -595, -154, 128}, { 894, 501, 588, 457}, { -345, 206, 122, 110}, { -631, -227, -569, 3}, { 408, 239, 397, 226}, { -197, -2, 128, 491}, { 1281, 904, 292, 215}, { 538, 306, 259, 509}, { -677,-1047, 13, 321}, { -679, -588, -358, -212}, { -558, 243, 646, 479}, { 486, 342, 634, 532}, { 107, 802, 331, 136}, { -112, -398,-1031, -286}, { -326, -705, 288, 272}, { 1299, 1144, 1178, 860}, { -423, 121, -385, -148}, { -295, -302, -834, -819}, { 16, -24, -201, -476}, { 555, 91, -245, 294}, { -38, -379, -962,-1221}, {-1191,-1518, -273, -395}, { -390,-1013, -645, 573}, {-1843,-1030, 505, 468}, { 744, 947, 609, 493}, { -689,-1172, -628, -135}, {-1026, 195, 411, 196}, { 1582, 1147, 575, 337}, {-1239, -777, -648, -142}, { 595, 825, 967, 735}, {-1206, -970, -81, -342}, { -745, 13, -72, 375}, { 454, 19, 1407, 921}, {-1647, -172, 861, 562}, { 928, 1537, 1063, 740}, {-2472, -952, 264, 82}, { -502, -965,-1334, 123}, { 867, 1236, 534, 171}, {-2320, -460, 780, 363}, {-1190, -617, 252, -61}, { -174, 34, 1011, 788}, {-2333, 247, 423, 153}, { -16, -355, 262, 449}, {-1576,-1073, -544, -371}, { -615, -305, 1051, 805}, { 687, 528, 6, -182}, { 935, 875, 1002, 809}, { 199, 257, 126, 76}, { -584,-1138, 599, 556}, {-1105,-1391,-1591, -519}, { -977,-1325, 108, 347}, { -722, -975, 365, 101}, { -145, 681, 249, -153}, { 0, -334, -570, 159}, { 412, 285, -336, -617}, { -953, -966, 887, 689}, {-1251, 84, -185, -398}, { -592, 433, 1044, 653}, { 85, 329, -40, 361}, { -433, -705, 466, 574}, { -154, 654, 592, 290}, { -167, 72, 349, 175}, { 674, 297, 977, 720}, { 1235, 1204, 757, 488}, { -400, -269, 538, 372}, {-1350,-1387,-1194, -91}, { 1262, 876, 775, 700}, { -599, -38, -430, -722}, { 1976, 1630, 991, 608}, { 111, 276, -226, -96}, { -947, -388, -11, -7}, { -303, -531, -839, 338}, { 1734, 1710, 1405, 1013}, { -516, -855, -645, 210}, { -688, -416, 513, 230}, { -822, -637,-1146, -320}, { -952, -658, -694, 183}, { -114, -623, 818, 674}, { -191, -204, 731, 635}, { 51, 1221, 883, 576}, { -954, -431, 826, 598}, { -342, -755, -900, -407}, {-1126, -354, -206, -512}, { -547, -810, -357, -620}, { 66, 515, -73, -410}, { -872, -945,-1444,-1227}, { 191, -17, -544, -231}, {-1540, -544, -901, -886} }; static const int16_t lsf_3_1_MODE_7k95[512][3] = { { -890,-1550,-2541}, { -819, -970, 175}, { -826,-1234, -762}, { -599, -22, 634}, { -811, -987, -902}, { -323, 203, 26}, { -383, -235, -781}, { -399, 1262, 906}, { -932,-1399,-1380}, { -624, 93, 87}, { -414, -539, -691}, { 37, 633, 510}, { -387, -476,-1330}, { 399, 66, 263}, { -407, -49, -335}, { -417, 1041, 1865}, { -779,-1089,-1440}, { -746, -858, 832}, { -581, -759, -371}, { -673, -506, 2088}, { -560, -634,-1179}, { 271, 241, 14}, { -438, -244, -397}, { 463, 1202, 1047}, { -606, -797,-1438}, { -51, -323, 481}, { -224, -584, -527}, { 494, 881, 682}, { -433, -306,-1002}, { 554, 659, 222}, { 171, -160, -353}, { 681, 1798, 1565}, { -852,-1181,-1695}, { -336, -666, 114}, { -581, -756, -744}, { -195, 375, 497}, { -465, -804,-1098}, { 154, 282, -131}, { -50, -191, -719}, { 323, 732, 1542}, { -722, -819,-1404}, { 105, -250, 185}, { -178, -502, -742}, { 321, 510, 1111}, { -323, -567, -966}, { 127, 484, 338}, { -160, 52, -338}, { 732, 1367, 1554}, { -626, -802,-1696}, { -286, -586, 676}, { -695, -343, -370}, { -490, 295, 1893}, { -630, -574,-1014}, { -80, 645, -69}, { -6, -318, -364}, { 782, 1450, 1038}, { -313, -733,-1395}, { 120, 60, 477}, { -264, -585, -123}, { 711, 1245, 633}, { -91, -355,-1016}, { 771, 758, 261}, { 253, 81, -474}, { 930, 2215, 1720}, { -808,-1099,-1925}, { -560, -782, 169}, { -804,-1074, -188}, { -626, -55, 1405}, { -694, -716,-1194}, { -660, 354, 329}, { -514, -55, -543}, { 366, 1033, 1182}, { -658, -959,-1357}, { -55, -184, 93}, { -605, -286, -662}, { 404, 449, 827}, { -286, -350,-1263}, { 628, 306, 227}, { -16, 147, -623}, { 186, 923, 2146}, { -674, -890,-1606}, { -443, -228, 339}, { -369, -790, -409}, { 231, 86, 1469}, { -448, -581,-1061}, { 594, 450, -177}, { -124, -170, -447}, { 671, 1159, 1404}, { -476, -667,-1511}, { -77, -138, 716}, { -177, -372, -381}, { 451, 934, 915}, { -250, -432, -822}, { 272, 828, 446}, { 26, 19, -31}, { 698, 1692, 2168}, { -646, -977,-1924}, { -179, -473, 268}, { -379, -745, -691}, { 11, 127, 1033}, { -488, -917, -825}, { 61, 323, 135}, { 147, -145, -686}, { 685, 786, 1682}, { -506, -848,-1297}, { 35, 90, 222}, { -23, -346, -670}, { 455, 591, 1287}, { -203, -593,-1086}, { 652, 352, 437}, { 39, 63, -457}, { 841, 1265, 2105}, { -520, -882,-1584}, { -328, -711, 1421}, { -596, -342, -70}, { 209, 173, 1928}, { -423, -598, -921}, { 421, 605, -38}, { -2, -245, -127}, { 896, 1969, 1135}, { -379, -518,-1579}, { 173, 118, 753}, { -55, -381, -52}, { 985, 1021, 753}, { -2, -291, -891}, { 753, 992, 423}, { 264, 131, -196}, { 895, 2274, 2543}, { -635,-1088,-2499}, { -529, -982, 526}, { -764, -830, -548}, { -436, 316, 599}, { -675, -940, -746}, { -57, 236, -11}, { -201, -81, -798}, { 16, 845, 1558}, { -737, -985,-1212}, { -468, 17, 290}, { -279, -584, -700}, { 183, 822, 705}, { -265, -492,-1187}, { 421, 152, 468}, { -390, 166, -268}, { 39, 1550, 1868}, { -635, -966,-1571}, { -453, -492, 910}, { -284,-1027, -75}, { -181, -133, 1852}, { -445, -624,-1174}, { 420, 367, -49}, { -389, -212, -169}, { 707, 1073, 1208}, { -539, -710,-1449}, { 83, -163, 484}, { -236, -543, -355}, { 338, 1175, 814}, { -246, -309, -958}, { 606, 760, 60}, { 166, -8, -163}, { -306, 1849, 2563}, { -747,-1025,-1783}, { -419, -446, 209}, { -718, -566, -534}, { -506, 693, 857}, { -463, -697,-1082}, { 325, 431, -206}, { -15, -8, -763}, { 545, 919, 1518}, { -611, -783,-1313}, { 256, -55, 208}, { -165, -348, -662}, { 321, 680, 930}, { -326, -429, -951}, { 484, 446, 570}, { -197, 72, -73}, { 909, 1455, 1741}, { -563, -737,-1974}, { -124, -416, 718}, { -478, -404, -314}, { -16, 446, 1636}, { -551, -537, -750}, { -58, 638, 214}, { 55, -185, -271}, { 1148, 1301, 1212}, { -483, -671,-1264}, { 117, 285, 543}, { -204, -391, -111}, { 513, 1538, 854}, { -114, -190, -978}, { 877, 595, 464}, { 260, 260, -311}, { 748, 2283, 2216}, { -517, -945,-2171}, { -326, -708, 378}, { -812, -691, -232}, { -560, 687, 1409}, { -732, -690, -836}, { -359, 645, 386}, { -265, 62, -678}, { 145, 1644, 1208}, { -555, -988,-1233}, { -78, 14, 114}, { -327, -358, -489}, { 392, 677, 697}, { -201, -236,-1140}, { 693, 449, 178}, { -243, 256, -433}, { 611, 1385, 2456}, { -612, -901,-1464}, { -307, -17, 499}, { -315, -667, -254}, { 256, 428, 1463}, { -486, -422,-1056}, { 655, 370, 18}, { -102, -185, -276}, { 755, 1578, 1335}, { -488, -603,-1418}, { 182, -93, 870}, { -73, -458, -348}, { 835, 862, 957}, { -282, -333, -746}, { 547, 839, 428}, { 273, -89, 13}, { 940, 1708, 2576}, { -418,-1084,-1758}, { -44, -358, 259}, { -497, -643, -560}, { 99, 557, 961}, { -421, -766, -917}, { 295, 326, 184}, { 175, 15, -626}, { 532, 878, 1981}, { -443, -768,-1275}, { 221, 156, 268}, { 39, -363, -505}, { 695, 772, 1140}, { -162, -459, -912}, { 709, 444, 658}, { 25, 303, -312}, { 1268, 1410, 1715}, { -297, -766,-1836}, { -263, -108, 1070}, { -406, -13, -129}, { 57, 438, 2734}, { -374, -487, -835}, { 304, 696, 164}, { 104, -235, 5}, { 1611, 1900, 1399}, { -229, -582,-1325}, { 405, 192, 817}, { -87, -438, 111}, { 1028, 1199, 993}, { 68, -175, -934}, { 1033, 1117, 451}, { 478, 200, -248}, { 2127, 2696, 2042}, { -835,-1323,-2131}, { -799, -692, 466}, { -812,-1032, -469}, { -622, 288, 920}, { -701, -841,-1070}, { -411, 512, 8}, { -390, -91, -744}, { -30, 1043, 1161}, { -822,-1148,-1156}, { -294, -46, 110}, { -411, -374, -678}, { 214, 531, 668}, { -406, -420,-1194}, { 487, 232, 303}, { -318, 91, -472}, { 123, 1232, 2445}, { -722, -952,-1495}, { -738, -675, 1332}, { -543, -606, -211}, { -95, -98, 1508}, { -549, -514,-1193}, { 473, 211, 73}, { -288, -112, -389}, { 537, 1332, 1258}, { -567, -755,-1545}, { 71, -283, 632}, { -170, -481, -493}, { 681, 1002, 817}, { -356, -331, -877}, { 419, 706, 346}, { 241, -34, -326}, { 377, 1950, 1883}, { -727,-1075,-1625}, { -233, -543, 116}, { -524, -806, -585}, { -73, 478, 729}, { -288, -925,-1143}, { 173, 447, -52}, { 68, -229, -606}, { 449, 529, 1797}, { -591, -875,-1363}, { 183, -144, 324}, { -103, -452, -666}, { 623, 488, 1176}, { -238, -511,-1004}, { 326, 552, 458}, { 136, 108, -319}, { 626, 1343, 1883}, { -490, -646,-1730}, { -186, -449, 984}, { -738, -76, -170}, { -550, 755, 2560}, { -496, -510, -947}, { 210, 694, -52}, { 84, -322, -199}, { 1090, 1625, 1224}, { -376, -603,-1396}, { 343, 74, 632}, { -175, -502, -32}, { 972, 1332, 734}, { 52, -295,-1113}, { 1065, 918, 160}, { 393, 107, -397}, { 1214, 2649, 1741}, { -632,-1201,-1891}, { -719, -277, 353}, { -651, -880, -122}, { -211, 209, 1338}, { -562, -714,-1059}, { -208, 388, 159}, { -320, -61, -551}, { 293, 1092, 1443}, { -648, -865,-1253}, { -49, -143, 305}, { -401, -227, -585}, { 561, 532, 927}, { -117, -443,-1188}, { 507, 436, 292}, { -79, 233, -458}, { 671, 1025, 2396}, { -633, -842,-1525}, { -308, -286, 640}, { -373, -621, -407}, { 418, 253, 1305}, { -315, -581,-1137}, { 572, 685, -281}, { 61, -68, -371}, { 991, 1101, 1498}, { -493, -683,-1362}, { -47, 164, 704}, { -256, -314, -268}, { 631, 949, 1052}, { -118, -348, -833}, { 68, 1180, 568}, { 152, 117, 34}, { 1113, 1902, 2239}, { -601, -959,-1706}, { -143, -489, 480}, { -332, -655, -574}, { 54, 353, 1192}, { -462, -652, -796}, { 150, 549, 112}, { 195, -111, -515}, { 679, 1108, 1647}, { -558, -749,-1217}, { -9, 272, 341}, { -53, -265, -535}, { 489, 843, 1298}, { -120, -482,-1032}, { 632, 543, 408}, { 179, 306, -526}, { 1124, 1464, 2244}, { -417, -786,-1562}, { -224, -384, 1364}, { -377, -459, -25}, { 385, 489, 2174}, { -332, -651, -829}, { 544, 553, 61}, { 22, -113, -89}, { 1128, 1725, 1524}, { -216, -373,-1653}, { 161, 316, 908}, { -165, -222, -67}, { 1362, 1175, 789}, { 73, -252, -767}, { 738, 932, 616}, { 362, 246, -126}, { 787, 2654, 3027}, { -691,-1106,-2190}, { -565, -588, 524}, { -590, -979, -490}, { -263, 397, 982}, { -577, -837, -945}, { -22, 435, -49}, { -190, -118, -629}, { -88, 1240, 1513}, { -636,-1051,-1019}, { -291, 189, 259}, { -257, -470, -629}, { 145, 945, 894}, { -326, -364,-1094}, { 543, 260, 630}, { -202, 189, -209}, { 357, 1379, 2091}, { -569,-1075,-1449}, { -714, -239, 919}, { -420, -705, -84}, { -109, -114, 2407}, { -413, -529,-1177}, { 482, 368, 131}, { -186, -72, -131}, { 861, 1255, 1220}, { -611, -658,-1341}, { 227, -121, 631}, { -176, -489, -218}, { 745, 1175, 957}, { -321, -148, -936}, { 671, 966, 216}, { 340, -3, -143}, { 469, 1848, 2437}, { -729, -961,-1683}, { -213, -254, 321}, { -511, -438, -521}, { -126, 725, 903}, { -340, -685,-1032}, { 316, 480, 20}, { 23, -89, -551}, { 353, 1051, 1789}, { -544, -757,-1364}, { 298, -25, 436}, { -100, -392, -519}, { 467, 754, 1078}, { -210, -398,-1078}, { 620, 658, 630}, { 33, 147, -178}, { 921, 1687, 1921}, { -325, -528,-1978}, { 2, -285, 910}, { -371, -490, -230}, { 0, 597, 2010}, { -496, -395, -834}, { 37, 945, 245}, { 181, -160, -144}, { 1481, 1373, 1357}, { -355, -601,-1270}, { 298, 322, 672}, { -193, -336, 77}, { 1089, 1533, 922}, { 177, -39,-1125}, { 996, 781, 536}, { 456, 366, -432}, { 1415, 2440, 2279}, { -466, -758,-2325}, { -303, -509, 387}, { -727, -557, 66}, { -145, 643, 1248}, { -544, -676, -916}, { -225, 862, 588}, { -152, 40, -533}, { 423, 1423, 1558}, { -572, -843,-1145}, { -128, 85, 461}, { -238, -257, -584}, { 605, 748, 861}, { 24, -202,-1409}, { 797, 487, 303}, { -181, 364, -182}, { 616, 1378, 2942}, { -494, -852,-1441}, { -292, 61, 812}, { -84, -723, -182}, { 555, 532, 1506}, { -365, -493,-1057}, { 822, 588, 11}, { -14, -18, -230}, { 1001, 1401, 1451}, { -474, -569,-1292}, { 302, 62, 1062}, { -70, -376, -222}, { 982, 974, 1149}, { -196, -234, -795}, { 479, 1098, 499}, { 362, 58, 70}, { 1147, 2069, 2857}, { -487, -878,-1824}, { 73, -288, 348}, { -358, -500, -508}, { 199, 721, 1242}, { -78, -697, -795}, { 361, 536, 196}, { 374, 110, -735}, { 847, 1051, 1896}, { -366, -713,-1182}, { 315, 320, 429}, { 72, -215, -450}, { 759, 886, 1363}, { -30, -428, -834}, { 861, 627, 796}, { 118, 468, -279}, { 1355, 1883, 1893}, { -188, -642,-1612}, { 63, -175, 1198}, { -418, -211, 51}, { 414, 587, 2601}, { -234, -557, -858}, { 424, 889, 222}, { 136, -101, 83}, { 1413, 2278, 1383}, { -84, -445,-1389}, { 414, 313, 1045}, { 29, -343, 65}, { 1552, 1647, 980}, { 183, -91, -829}, { 1273, 1413, 360}, { 553, 272, -107}, { 1587, 3149, 2603} }; static const int16_t lsf_3_1[256][3] = { { 6, 82, -131}, { 154, -56, -735}, { 183, -65, -265}, { 9, -210, -361}, { 113, 718, 1817}, { 1010, 1214, 1573}, { 857, 1333, 2276}, { 827, 1568, 1933}, { 717, 1989, 2206}, { 838, 1172, 1823}, { 721, 1000, 2154}, { 286, 476, 1509}, { -247, -531, 230}, { 147, -82, 569}, { 26, -177, -944}, { -27, -273, 692}, { -164, -264, -183}, { 224, 790, 1039}, { 899, 946, 601}, { 485, 771, 1150}, { 524, 677, 903}, { -140, 375, 778}, { 410, 676, 429}, { 301, 530, 1009}, { 719, 646, 38}, { 226, 367, 40}, { 145, -45, -505}, { 290, 121, -121}, { 302, 127, 166}, { -124, -383, -956}, { -358, -455, -977}, { 715, 878, 894}, { 978, 923, 211}, { 477, 272, 64}, { 188, -78, 17}, { -143, -65, 38}, { 643, 586, 621}, { -134, -426, -651}, { 347, 545, 2820}, { 1188, 2726, 2442}, { 142, -80, 1735}, { 283, 130, 461}, { -262, -399,-1145}, { -411, 155, 430}, { 329, 375, 779}, { 53, -226, -139}, { -129, -236, 1682}, { 285, 744, 1327}, { 738, 697, 1664}, { 312, 409, 266}, { 325, 720, 135}, { 1, 221, 453}, { 8, 203, 145}, { 299, 640, 760}, { 29, 468, 638}, { 103, 429, 379}, { 420, 954, 932}, { 1326, 1210, 1258}, { 704, 1012, 1152}, { -166, -444, -266}, { -316, -130, -376}, { 191, 1151, 1904}, { -240, -543,-1260}, { -112, 268, 1207}, { 70, 1062, 1583}, { 278, 1360, 1574}, { -258, -272, -768}, { 19, 563, 2240}, { -3, -265, 135}, { -295, -591, -388}, { 140, 354, -206}, { -260, -504, -795}, { -433, -718,-1319}, { 109, 331, 962}, { -429, -87, 652}, { -296, 426, 1019}, { -239, 775, 851}, { 489, 1334, 1073}, { -334, -332, 25}, { 543, 1206, 1807}, { 326, 61, 727}, { 578, 849, 1405}, { -208, -277, 329}, { -152, 64, 669}, { -434, -678, -727}, { -454, -71, 251}, { 605, 480, 254}, { -482, 11, 996}, { -289, 395, 486}, { 722, 1049, 1440}, { -30, -316, -786}, { -106, -115, -619}, { 861, 1474, 1412}, { 1055, 1366, 1184}, { 812, 1237, 925}, { 42, -251, -576}, { 342, 141, -454}, { -168, -80, 1359}, { -342, -656,-1763}, { 100, 821, 725}, { 990, 747, 800}, { 332, 440, 568}, { 663, 379, 852}, { 112, 165, -369}, { 597, 910, 282}, { -8, 834, 1281}, { -352, 572, 695}, { 462, 2246, 1806}, { 345, 190, 1374}, { 416, 915, 2166}, { 168, -82, 280}, { -516, -446, 840}, { 47, 533, 44}, { -362, -711,-1143}, { 22, 193, 1472}, { -85, 233, 1813}, { -62, 579, 1504}, { 550, 944, 1749}, { 723, 650, 1148}, { 972, 884, 1395}, { -425, 643, 0}, { 1000, 952, 1098}, { 249, 1446, 672}, { -334, -87, 2172}, { -554, 1882, 2672}, { 140, 1826, 1853}, { 920, 1749, 2590}, { 1076, 1933, 2038}, { -137, -443,-1555}, { 1269, 1174, 468}, { -493, -122, 1521}, { -451, 1033, 1214}, { 482, 1695, 1118}, { 815, 649, 384}, { -446, -692, 107}, { -319, -605, -118}, { -207, -505, 525}, { -468, -12, 2736}, { 75, 1934, 1305}, { 880, 2358, 2267}, { 1285, 1575, 2004}, { -48, -304,-1186}, { -435, -461, -251}, { -366, -404, -547}, { -289, -605, -597}, { -538, -810, -165}, { -120, 3, 356}, { 639, 1241, 1502}, { 96, 177, 750}, { -435, -585,-1174}, { -356, 109, -79}, { -485, 288, 2005}, { 9, 1116, 731}, { 880, 2134, 946}, { -265, 1585, 1065}, { 1157, 1210, 843}, { -498, -668, 431}, { 374, 321, -229}, { 1440, 2101, 1381}, { 449, 461, 1155}, { -105, 39, -384}, { -263, 367, 182}, { -371, -660, 773}, { -188, 1151, 971}, { 1333, 1632, 1435}, { 774, 1267, 1221}, { -482, -832,-1489}, { -237, -210, 860}, { 890, 1615, 1064}, { 472, 1062, 1192}, { 185, 1077, 989}, { -568, -992,-1704}, { -449, -902,-2043}, { -142, -377, -458}, { -210, -554,-1029}, { -11, 1133, 2265}, { -329, -675, -893}, { -250, 657, 1187}, { 519, 1510, 1779}, { 520, 539, 1403}, { 527, 1421, 1302}, { -563, -871,-1248}, { -147, -463, 879}, { -76, 2334, 2840}, { 563, 2573, 2385}, { 632, 1926, 2920}, { 719, 2023, 1840}, { -545, -723, 1108}, { 129, -125, 884}, { 1417, 1632, 925}, { -94, 1566, 1751}, { -341, 1533, 1551}, { 591, 395, -274}, { -76, 981, 2831}, { 153, 2985, 1844}, { 1032, 2565, 2749}, { 1508, 2832, 1879}, { 791, 1199, 538}, { -190, -453, 1489}, { -278, -548, 1158}, { -245, 1941, 2044}, { 1024, 1560, 1650}, { 512, 253, 466}, { -62, -323, 1151}, { -473, -376, 507}, { -433, 1380, 2162}, { 899, 1943, 1445}, { 134, 704, 440}, { 460, 525, -28}, { -450, 279, 1338}, { 0, 971, 252}, { -445, -627, -991}, { -348, -602,-1424}, { 398, 712, 1656}, { -107, 314, -178}, { 93, 2226, 2238}, { 518, 849, 656}, { -462, -711, -447}, { 174, -34, 1191}, { -119, 42, 1005}, { -372, 274, 758}, { 1036, 2352, 1838}, { 675, 1724, 1498}, { 430, 1286, 2133}, { -129, -439, 0}, { -373, 800, 2144}, { 6, 1587, 2478}, { 478, 596, 2128}, { -428, -736, 1505}, { 385, 178, 980}, { 139, 449, 1225}, { -526, -842, -982}, { 145, 1554, 1242}, { 623, 1448, 656}, { 349, 1016, 1482}, { 31, -280, 415}, { -316, 724, 1641}, { 360, 1058, 556}, { -436, -358, 1201}, { -355, 1123, 1939}, { 401, 1584, 2248}, { -527,-1012, 355}, { 233, 238, 2233}, { -550, -897, -639}, { -365, -501, 1957}, { 389, 1860, 1621}, { 162, 1132, 1264}, { -237, 1174, 1390}, { -640, -411, 116}, { -228, 1694, 2298}, { 1639, 2186, 2267}, { 562, 1273, 2658}, { 323, 338, 1774}, { 578, 1107, 852}, { 22, 594, 934}, { -143, 718, 446} }; static const int16_t lsf_3_2[512][3] = { { 50, 71, -9}, { -338, -698,-1407}, { 102, -138, -820}, { -310, -469,-1147}, { 414, 67, -267}, { 1060, 814, 1441}, { 1548, 1360, 1272}, { 1754, 1895, 1661}, { 2019, 2133, 1820}, { 1808, 2318, 1845}, { 644, -93, 454}, { 858, 329, -136}, { 489, -258, -128}, { -198, -745, -41}, { -52, -265, -985}, { 346, 137, 479}, {-1741, -748, -684}, {-1163,-1725, -367}, { -895,-1145, -784}, { -488, -946, -968}, { -85, -390, -725}, { 215, -340, -171}, { 1020, 916, 1969}, { 564, 179, 746}, { 662, 977, 1734}, { 887, 622, 914}, { 939, 856, 1165}, { 309, 688, 803}, { 917, 161, 570}, { 118, -20, -283}, { -816, -42, 204}, {-1228, -325, -462}, { -963, -202, -143}, { -988, -484, -361}, { -702, -978, -477}, { -302, -790,-1188}, { -100, -786,-1088}, {-1054, -947,-1684}, { -202, -843, -782}, {-1039,-1378, -901}, { -624, -110, -85}, { 356, 213, -10}, { -493, 364, 774}, { 425, 822, 479}, { -83, 557, 520}, { -992,-1560, -572}, { -603, -741, -26}, { -502, -638, -903}, { 209, 306, 147}, { -316, -593, -596}, { -85, -211, -225}, { -918, -529, 117}, { 233, -439, -738}, { 1101, 751, 633}, { 1457, 1716, 1511}, { 1765, 1457, 910}, { 1122, 1156, 849}, { 1354, 868, 470}, { -871,-1150,-1796}, { -871, -861, -992}, { -118, 155, 212}, {-1051, -849, -606}, {-1117,-1849,-2750}, {-1019,-1427,-1869}, { 370, -184, -414}, { 959, 493, 104}, { 958, 1039, 543}, { 154, 653, 201}, { 1249, 507, 150}, { 663, 503, 230}, { 623, 777, 675}, { 659, 88, -110}, { 843, 244, 224}, { 382, 541, 302}, { 724, 433, 666}, { 1166, 734, 341}, { -138, 20, -397}, {-1183, -424, -46}, { -321, -352, -124}, { 1333, 1021, 1080}, { 262, 366, 723}, { 922, 283, -551}, { 31, -636, -611}, { -689, -697, -415}, { -952, -779, -201}, {-1329, -598, -359}, { -953,-1285, 166}, { 493, 305, 221}, { 846, 703, 610}, { 840, 936, 774}, { -723,-1324,-1261}, { -357,-1025,-1388}, {-1096,-1376, -365}, {-1416,-1881, -608}, {-1798,-1727, -674}, { -545,-1173, -703}, { 678, 786, 148}, { -123, 696, 1288}, { 644, 350, -10}, { 414, 614, 15}, { 137, 344, -211}, { -814,-1512, -819}, { -391, -930, -588}, { 47, -591, -898}, { -909,-1097, -163}, {-1272,-1167, -157}, {-1464,-1525, -389}, {-1274,-1188, -624}, { 671, 213, 454}, { 124, -274, -525}, { -729, -496, -152}, {-1344, 122, 135}, {-2905, -589, -394}, {-1728, 441, -50}, { 1476, 904, 787}, { 316, 236, -440}, { -347, 217, 413}, { -911, -917, 121}, { -455, -932, 202}, { -92, -465, -375}, { 488, 390, 474}, { 876, 729, 316}, {-1815,-1312, -669}, { 87, 962, 432}, { 563, -249,-1058}, { 250, 285, 1105}, { 1141, 427, 696}, {-1038,-1664,-1582}, { -948, 346, 160}, { -309, -272, -858}, { 670, 624, 1250}, { -944, -408, -666}, { -606, -320, -384}, { -492, 230, 65}, { 334, -50, -16}, { -16, -690,-1397}, { 1791, 1716, 1399}, { 2478, 2063, 1404}, { 1245, 1471, 1426}, { -382,-1037, -2}, { 173, -398, 1145}, { 1491, 2024, 1801}, { 772, 1274, 1506}, { 1429, 1735, 2001}, { 1079, 1218, 1273}, {-1154,-1851,-1329}, { -808,-1133,-1096}, { -451,-1033,-1722}, { 65, 578, -84}, {-1476,-2434,-1778}, { -765,-1366, -494}, { -218, -594, -931}, { 337, -236, 562}, { 2357, 2662, 1938}, { 1489, 1276, 874}, { 189, 358, 374}, {-1519,-2281,-2346}, { -967,-1271,-2095}, { -628,-1188,-1542}, { 1661, 1043, 546}, { 565, 1061, 732}, { -64, -836, -434}, { -436, -96, 203}, { 1078, 1216, 1636}, { 907, 1534, 986}, { 326, 965, 845}, { 142, -84, 197}, { 470, 2379, 1570}, { 1133, 470, 1214}, { 395, 1376, 1200}, { 1125, 1042, 348}, { -543,-1234, -376}, { -215, -181, 481}, {-1947,-1621, -210}, { -750,-1185, 390}, { 29, -399, 27}, { 820, 1236, 755}, { 695, 979, 409}, { -174, 1197, 1035}, { 912, 1356, 1846}, { -992,-1437, 484}, {-1485,-1700, 208}, { -412, 1204, 1432}, { -271, 896, 1144}, { -416, 1777, 1434}, {-1696,-2644, -204}, {-1789,-1551, 1033}, {-1656,-1559, 1303}, {-1253,-1589, 1081}, { -669,-1095, -66}, { -682, 320, -345}, { 659, 305, 1069}, {-1292, -804, -19}, {-1635,-1291, 29}, {-1683, -497, 71}, { -287, -7, -100}, { -494, -962, -237}, { 852, 1881, 1740}, {-1217,-1387, 227}, { -660, 302, 373}, { 96, 1087, 1257}, {-1074,-1669, 160}, { 485, 2076, 1798}, { -934, -220, 552}, { -596, -612, 237}, { 336, 1720, 879}, { 643, 629, 434}, { 1267, 522, 1633}, { 15, 244, -441}, { 1475, 717, 184}, { 1819, 1590, 1709}, { 988, 261, 937}, { 2093, 2345, 1520}, { 2139, 1858, 1606}, { -577, -579,-1203}, { -956, 135, -488}, { -464, 51, -338}, { -629, -348, -723}, { 1146, 2073, 1442}, { 2192, 1466, 911}, {-1444,-1572,-2278}, { 1400, 710, 1297}, { 1335, 633, 928}, { 1434, 2194, 2594}, { 2422, 2204, 1881}, { 982, 2242, 1854}, { 380, 792, 1145}, { -63, -539, 414}, { -252, -964, -314}, {-1261, -683, -780}, { -831, -526,-1005}, {-1666,-1135, -424}, {-1611, -452, -299}, { 1268, 1048, 642}, { 1147, 853, 856}, { -675, -336, 139}, { 2268, 1343, 1418}, { 29, 768, 797}, {-1224, 423, 564}, {-1318,-1082, 245}, {-1302, -812, 573}, {-1298,-1617, 646}, { -968, 834, 723}, { 993, 1652, 2027}, { -191, -817, 432}, { 662, 60, 198}, { 626, 997, 1330}, { 1648, 1963, 1289}, {-1597, -93, -45}, {-1088, 37, -84}, { 1653, 2607, 2337}, { 1065, 2040, 2377}, { 1139, 2326, 2118}, { 859, 357, 1510}, { 664, 1227, 1099}, { 479, 1360, 912}, { 1897, 1754, 2019}, { 1168, 1909, 1784}, { 399, 34, 256}, { -593, -304,-1053}, { 547, 1694, 1407}, { 647, -99, -341}, { 1492, 1647, 1190}, { 38, -644, -212}, { 395, 846, 222}, { -704, -765, -716}, { -724,-1964,-2804}, { -150, 291, -82}, { 1233, 1459, 1007}, { -140, -155, 153}, { 439, 297, 1568}, {-1529, -410, -636}, { 1536, 455, -237}, {-1328, -139, -260}, { 531, 554, 868}, { 269, 1264, 606}, { -233, 883, 463}, { 742, 600, -120}, { -73, 421, 212}, { -439, -58, 804}, {-1286,-1241, 728}, { 294, -490, 50}, { -591, -905,-1254}, { 42, -687, 147}, { -25, 273, 596}, { -311, 1213, 601}, { -754, 849, 584}, { 429, 607, 587}, { -602, -166, 461}, { -796, -823, 777}, { 1380, 910, 1755}, { 119, 1417, 972}, { -219, -880,-1596}, {-1049,-1010, 438}, { -713,-1379, 78}, { 0, -447,-1179}, {-1136,-1319,-1573}, { 2248, 1767, 1309}, { 946, 1583, 1432}, { 1150, 482, 436}, { -469,-1108, 618}, { -447, -966, 1088}, {-1252,-1515, -114}, {-1104,-2008, -579}, { 210, 613, 497}, {-1975,-1437, 642}, {-1269, -856, 1011}, {-1646,-1185, 1063}, {-1555, -672, 1204}, {-1692,-1114, 623}, { -979,-1326,-1277}, { 539, -147, 894}, {-1354, -897, -434}, { 888, 475, 428}, { 153, -384, 338}, {-1492, -511, 359}, { -974,-1115, -470}, { 105, -550, 677}, { -937,-1145, 877}, { 380, -260, 210}, { 1685, 924, 1256}, { 1775, 1190, 1095}, { 1419, 631, 533}, { 627, 299, -347}, { -411, -534, 647}, { -650, 29, -595}, { -378,-1367, 1563}, { 1402, 1121, 1465}, { 1089, 1410, 648}, {-2096,-1090, -6}, { 311, -194, -869}, { -639, -831, 416}, {-1162,-1224, 1349}, {-1247, -941, 1813}, {-2193,-1987, 453}, { -619,-1367, -956}, {-1606,-1972,-1507}, {-1175,-1057,-1104}, { -377, 601, 201}, { 1876, 825, 374}, { -430,-1323, 29}, {-1397,-1249,-1331}, {-1007,-1504, 960}, {-1401,-2009, 197}, {-1379,-1949, -236}, {-1077, 123, 422}, { 615, 1269, 546}, { -306, 1526, 904}, { 1194, 1788, 1177}, { -626, -884,-1526}, { 199, 766, 1504}, {-1065, 862, 197}, {-1034,-1773, -887}, { -800, 145, 599}, {-1134, -519, 626}, {-1205,-1926, 500}, { -910,-1041,-1395}, {-1476,-1567, -969}, { -523, 842, 34}, { 1794, 646, 862}, {-1207,-1888,-1002}, { -78, -9, -672}, { 1044, 759, 80}, { -600, 1139, 1019}, { 57, 2000, 1422}, { -833, 1414, 1121}, {-1202, 1630, 1260}, { -461, 1420, 1244}, { 1537, 975, 253}, { -283, 324, -359}, { 599, -195, 106}, { 588, 62, -587}, { -757, 645, 205}, { 51, 1201, 758}, {-1209, 673, -390}, { -624, 1581, 941}, { -151, 1023, 735}, { 2820, 1301, 690}, { -302, 524, -99}, { -900,-1588,-1189}, { 1084, 251, 238}, { 2014, 1792, 1010}, { 1245, 1633, 1741}, {-1227,-1540,-1208}, { -621, 456, -109}, { 40, -65, 788}, { -805, -699,-1350}, { -583, 904, 832}, { -801, 532, 594}, { 1972, 1408, 1351}, {-1177,-1880,-2114}, { -773, 568, 948}, {-1015, 1079, 1260}, {-1111, 482, -130}, { 1778, 1044, 780}, {-1491, 245, 912}, { -316,-1141, -917}, { -536,-1442,-2346}, { -785,-1546,-1988}, {-2003, 257, 909}, {-1849, -633,-1209}, {-1538,-1918,-1054}, { 1606, 2239, 1576}, { -567,-1500,-1544}, {-1279, 195, 1369}, { -817, 293, 1219}, { -525, 630, 1197}, {-1698,-2425,-1840}, { -303, 731, 747}, {-1169, -251, 269}, { -950, -75, 1684}, {-1182, -453, 1005}, {-1599, 585, 378}, {-2075, -571, -427}, { -529,-1159,-1171}, { -283, -205, -564}, { -796, 1246, 717}, { 2277, 927, 539}, { -454, 559, 440}, { -717, 1460, 1615}, {-1030, 1052, 1610}, {-1169, -138, 847}, { 226, 39, -612}, {-1251, -106, -729}, { -651, 968, 1302}, { -714, -636, 1727}, { 353, 1069, 410}, { -798, -156, 1099}, { -574, 918, 446}, {-1310, 1012, 466}, { 1408, 1591, 765}, { 1429, 1380, 1757}, { 1949, 1956, 2378}, { 1578, 2047, 2148}, { 916, 98, -7}, { 1893, 1418, 2141}, { 348, 1405, 1579}, { 152, 1134, 1801}, { -267, 154, 1395}, {-1166, 469, 1054}, {-1142, -405,-1073}, {-1341,-2264,-1581}, { -364, 869, 1706}, {-1162, 549, 1550}, {-1225,-1932,-1666}, {-1485,-1977,-2055}, {-1727, -906, -98}, {-1897, 233, 1492}, { 892, 108, -331}, {-1728,-1170,-1700}, {-1060, 1980, 1790}, {-1070,-1741,-1909}, { -11, 1539, 1317}, {-1600, 94, 497}, { 421, 443, -197}, {-1578, -349, -994}, { -599, -539, 1140}, { -965,-1419, -129}, {-1341, 175, -447}, { -375, 1311, 2055}, { -371, -650, -307}, {-1073, 605, 365}, {-2057, -113, 430}, { 652, 914, 967}, {-1012,-1586,-2323}, { 1505, 1248, 559}, { 262, -486, -401}, {-1727, 1342, 1546}, { 50, 56, 432}, { -330, 119, -604}, {-1517,-1080, -810}, { 946, 1127, 1055}, {-1400,-1703,-1712}, {-1270, -704,-1317}, { 807, 1821, 1143}, { 2760, 1606, 2171}, { 1120, 409, -150}, { -147, 404, 959}, { 2439, 1911, 2189}, { -906, -141, -866}, { -904, -142, -458}, { -557, -708,-1679}, { -830,-1431,-1583}, {-1842,-1346,-1086}, {-1604, -272, 915}, {-1196, 772, 1056}, { -638,-1234,-1897}, { -500, -81, -822}, {-1289,-1613, -735}, { -117, 785, 168}, {-1090, 1133, 922}, {-1096, -746, 1384}, { 287, -547,-1063}, {-1376,-2201,-1204}, {-2176,-1570,-1757}, {-1511,-2241, -771}, {-1737, 1099, 830}, {-1588, 724, 1243}, {-1542, 693, 805}, {-1690, -240, 1665}, {-1700, -4, -668}, { 2149, 816, 1042}, { -818,-1841, 22}, { -764, -507, 449}, {-1151, -617, 289}, { -843,-1596, -240}, { 498, -234, -657}, { -752, 480, 1678}, { -319, -481, 193}, { -811, 171, -119}, {-2128, -202, -848}, { 1717, 1140, 1700} }; static const int16_t lsf_3_3[512][4] = { { 67, -17, 66, -12}, {-1690, -581, -104, -272}, {-1076,-1186,-1845, -376}, {-1140, -926, -420, -58}, { -259, -656,-1134, -553}, { 1788, 1227, 455, 129}, { 462, 441, -240, -528}, { 840, 514, 130, -75}, { 1114, 623, 153, 216}, { 1068, 564, -6, -276}, { 1119, 727, 190, -68}, { 704, 306, 119, -264}, { 329, 61, -100, 156}, { 364, 123, 183, -208}, { -171, -123, 220, -65}, { -306, -62, 402, 17}, { -660, -938, -266, 0}, { 385, 235, 276, 285}, { 320, 268, -336, -200}, { -724, 17, -84, 381}, { -544, 429, 494, 519}, { -117, 288, 304, 329}, { 643, 157, 701, 508}, { 1200, 625, 796, 608}, { 998, 421, 492, 632}, { 1204, 780, 446, 132}, { 1257, 844, 547, 449}, { 829, 658, 541, 470}, { 1132, 1258, 918, 639}, { 547, 51, 423, 279}, { 9, 392, 83, 94}, { 542, 543, 229, -147}, { -198, 129, 194, -185}, { -863,-1321, -302, 30}, { -597, -629, -19, 114}, { -900,-1081, 466, 353}, {-1483,-1573, 15, -143}, {-1708,-2059, -751, 196}, {-1876,-2067, -642, -258}, {-2335,-1470, -450, -564}, { -584, -186, -872, -414}, {-1805, -988,-1125,-1310}, { -726,-1129, 28, 169}, {-1039, -864, -718, -246}, { 484, 36, -233, -49}, { 265, 67, 289, 467}, { 178, 543, 810, 540}, { 84, 282, 672, 703}, { -975, -777, 129, 287}, { -938, -227, 955, 595}, {-1617, -289, 836, 649}, {-1847, -215, 1106, 718}, {-2034,-1085, 650, 440}, {-2101, -529, 907, 575}, {-2011, -336, 670, 204}, {-2389, -692, 360, 137}, {-2156,-2204, -9, 280}, { -266, 119, 39, 193}, { 78, -59, -120, 226}, { -975, -858, -781,-1095}, { -619, -413, -451, -842}, {-1216,-1321, -813, -883}, {-1376,-1615, -394, -428}, { -737,-1113, -549, -790}, { -880, -975, -967, -642}, { -985, -886,-1273,-1361}, { -473, -804,-1401,-1407}, { 160, -265, -919, -275}, { -248, -250, -718, -380}, { 97, -103, -375, -229}, { -415, -193, -135, -555}, { 628, 361, 119, 216}, { 579, 364, 391, 209}, { 634, 522, -154, -148}, { 526, 389, 170, 33}, { 105, 267, 64, 380}, {-1503,-1000, -30, -369}, {-1070, 58, 647, 223}, {-1520, -291, 621, 307}, {-1531, 156, 762, 404}, {-2029, 141, 734, 499}, {-1849, -650, 306, 512}, { -187, -104, -59, 438}, { 134, -230, 156, -186}, { -61, -260, -16, 10}, { -569, -3, -421, -297}, {-1725, -521, -346, 178}, {-1362, -59, -44, 157}, {-2146, -461, -470, -349}, {-2170, -1, -369, -121}, {-1579, -373, -900,-1015}, {-1117, -591, -613, -784}, { -561, 122, -75, -449}, { -4, -171, -123, -372}, { 192, 168, -76, -132}, { 252, -107, 340, 210}, { 392, 509, 272, 181}, { -109, 145, 218, 119}, { -416, -263, 485, 265}, { -181, -8, -286, 226}, { -244, -218, 69, -290}, { -158, 191, -1, -64}, { -592, -90, 213, -96}, { 255, 435, 178, -80}, { -369, -18, -33, -80}, { -42, 415, 140, -222}, { 1143, 651, 649, 329}, { 767, 556, 249, 235}, { 948, 413, 442, 279}, { 141, 339, 356, 557}, { -470, -170, 99, 237}, { -569, -800, 352, 565}, { 282, 473, 470, 332}, { -199, -690,-1284, -917}, { -193, -426, -800,-1122}, { -26, -371, -490, -193}, { 637, 595, 519, 330}, { 408, -115, 79, 12}, { 477, 87, -103, -376}, { -666, -347, -277, -291}, { -510, -481, 169, 297}, { -829, -738, -205, -171}, { -320, -540, 328, 283}, { -859, -958, 442, -2}, { 556, 686, 130, 56}, { 1383, 1012, 755, 427}, { 612, 741, 628, 553}, { -339, -796, 134, 277}, { -633,-1085, -2, -246}, { -880,-1035,-1607,-1064}, { -994, -474,-1138, -488}, { -414, -795, 73, -206}, { -8, -139, 439, 204}, { -176, -578, 23, 131}, { -269, -757, -191, 245}, { -109, -338, 112, 316}, { 120, -406, -118, 611}, { -180, -186, -645, 115}, { -173, 34, -518, -489}, { -151, 61, -583, -844}, { 220, -138, -681,-1020}, { 391, -17, -598, -321}, { 157, -295, 129, 155}, { -926, -875, -987, 285}, { 241, -83, -125, -125}, { 620, 597, 432, 92}, { 393, 78, 409, 61}, { -393, -739, -413, -748}, { 83, 54, 361, 27}, {-1084, 130, -337, -694}, {-1565, 297, 318, -19}, {-1873, 36, 51, -317}, {-2323, -246, 231, -84}, {-2306, -783, 40, -179}, {-2233, -930, -474, -462}, { -754, -86, -288, -626}, {-2411, -455, -63, 171}, {-1099,-1094, -26, -143}, {-1193, -455, -406, -381}, { -605, -210, -96, -51}, { -580, -476, -276, -15}, {-1195, -634,-1203, -881}, { -378, -221, -669, -952}, { 594, 178, -403, -676}, { 763, 327, 601, 290}, { 172, 300, 203, 157}, { -56, -336, 356, 24}, { -228, -296, -259, -29}, { -186, 263, 416, 14}, { -353, 373, -12, -216}, { 257, 96, 174, 57}, {-1526, -616, -954, -499}, { -497, -152, -333, 125}, { 105, 200, 179, -97}, { -331, -224, 765, 697}, { 760, 256, 301, 59}, { 455, -85, 204, 288}, { -514, 240, 251, -109}, { 256, 417, -34, -413}, { 101, 430, 384, 156}, { -31, -10, 206, 426}, { 589, 145, 143, 71}, { 808, 906, 333, 349}, { 986, 938, 589, 331}, { 1300, 824, 187, 509}, { 1062, 653, 379, 466}, { 1462, 937, 401, 274}, { 787, 861, 265, 2}, { 609, 553, 28, 305}, { 926, 340, 106, 386}, { 241, -267, -147, 225}, { -178, -534, 347, 502}, { -643, -381, 397, 30}, { -651, -733, -435, 398}, { -407, -726, -484, -248}, { -789, -914, -438, -476}, { -498, -390, 75, -295}, { -964, -590, -606, 150}, { -121, -49, -155, -78}, { 935, 550, 389, 38}, { -321, 127, 424, 315}, { -285, -113, 283, 259}, { 658, 203, 322, 486}, { 903, 505, 748, 417}, { 611, 423, 555, 512}, { 239, -83, -578, -19}, { -339, -731, 349, 13}, { -934,-1399, -114, -360}, { 107, 692, 182, 90}, {-1243,-1538,-1551, -725}, { -568, -903,-1363, -525}, { -517, -853, -861,-1004}, { -168, -690, -835, 63}, { -137, -556, -547, 144}, { -286, -817, 485, 319}, { -147, -408, 526, 246}, { -347, -434, 297, -28}, { -290, -471,-1110,-1285}, { -460, -359, -988, -794}, { 1347, 1299, 690, 523}, { 1216, 1068, 1094, 757}, { 825, 1140, 752, 494}, { 1252, 1365, 1195, 898}, { 521, 1053, 532, 432}, { -334, -216, -313, -263}, { -160, 52, -472, -155}, { 127, 136, -380, 44}, { 851, 410, -162, -489}, { 123, -255, -796, -667}, { 1090, 917, 789, 493}, { 1397, 1197, 558, 202}, { -51, -118, -342, -701}, { 83, 108, -42, -441}, { 61, 95, 287, 256}, { -27, 89, 524, 531}, { 351, 227, 592, 545}, { 697, 155, -164, 307}, { 638, 274, -489, -50}, { 754, 240, -166, -124}, { -116, -579,-1212, -63}, { 190, -295,-1040,-1296}, { 147, -376, -177, -113}, { 841, 1241, 1051, 668}, { 2, 293, 551, 304}, {-1096, -953, -248, 376}, { -750, -965, 87, 516}, { -275, -516, 689, 391}, { -379, -643, 876, 594}, { -390,-1013, -645, 573}, { -107, -568, -689, -826}, {-1025, -27, -328, -203}, { 861, 749, 548, 233}, {-1660,-1043, 451, 108}, { -660, -620, 430, 236}, { 21, -396,-1158, -631}, { 1372, 1298, 967, 577}, { 1125, 1125, 589, 454}, { -323, -865, -467, 153}, { -468, -699, -804, -509}, { -392, -718, -204, -35}, { -603,-1093, -567, -162}, { -505,-1004, -102, 350}, { 219, 224, 423, 252}, { 395, 591, 608, 363}, { -746, -96, 373, 172}, { 171, 295, 714, 339}, { 233, 77, 107, 277}, { 157, 153, -499, -356}, { 1547, 1073, 576, 494}, { -292, -339, -504, -592}, { -903, -72, -619, -481}, {-1594,-1117, -567, -254}, { -793, -507, -564, -291}, { -492, -532, 502, 560}, { -382, 427, 600, 230}, { -227, 477, 251, 75}, { 285, 842, 813, 476}, {-1310,-1333, 186, 377}, { -587, -917, 643, 381}, {-1186, -553, 411, 82}, {-1127, -820, -174, -540}, { -604, 119, 543, 205}, { -380, 657, 909, 567}, { 112, -298, -374, 114}, { -857, -251, 56, 159}, { 401, 345, -34, -140}, { -111, -607, 41, 614}, { 355, -114, -77, 474}, { 578, 56, 1450, 924}, { 1098, 1420, 741, 400}, { 246, 22, 588, 313}, { -121, 327, 831, 472}, {-1138, -608, 856, 552}, {-1241,-1072, 638, 600}, { -358, 254, -333, -303}, { -646, 739, 358, 74}, { 1226, 1671, 1221, 849}, { 2241, 1624, 983, 636}, { 1841, 1477, 749, 384}, { 350, 263, 87, 128}, {-1902, -941, -144, -64}, {-1734, -255, 288, -31}, {-2644,-1238, 366, 235}, {-1643,-1092,-1344, -304}, { -541,-1075,-1116, 123}, {-1178, -252, -816, -180}, {-1016, 533, 565, 233}, { -487, -430, -188, 334}, { 867, 1236, 534, 171}, {-1590,-1607, 635, 630}, {-2196, 310, 924, 412}, {-2358, -328, 956, 529}, {-2639, -377, 630, 278}, {-2602, 317, 799, 299}, {-2406, 133, 340, 31}, {-2156,-1468, 131, 125}, {-1184, -490, -139, 46}, { -744, 447, 891, 564}, { 67, -451, 646, 604}, { -553, -429, -876, 396}, { 162, -66, 1305, 915}, { 479, 579, 1088, 794}, { 450, 278, 566, 324}, {-1057, -154, 148, -177}, {-2545, 168, 1070, 592}, {-2351, -42, 819, 345}, {-2344, -707, 721, 250}, {-2175,-1497, -309, 122}, { -78, -73, 120, 173}, { -4, 262, -263, -261}, { -431, -64, -405, -732}, {-2609, 116, -83, -193}, {-1525, -944, -477, -725}, { -508, 307, 170, 172}, { 832, 417, 832, 686}, { -225, 177, 894, 818}, { -482, -389, 1279, 1039}, { -383, 201, -350, 40}, { 730, 635, 226, 526}, { 503, 462, 338, 398}, { 535, 714, 40, -282}, { 1482, 1471, 1085, 731}, { 1561, 1072, 909, 693}, { 1419, 1282, 889, 879}, { 1153, 728, 1186, 840}, { -226, 1130, 949, 689}, { -494, -986,-1556, -128}, { -568, -721, -713, -26}, { 317, 524, 70, 135}, { -405, -865,-1766, -652}, { -174, -801, 885, 773}, { -153, -91, 1099, 751}, { -506,-1149, 853, 646}, { 241, 782, 519, 539}, { 1853, 1700, 1101, 684}, {-1249,-1486, -464, 188}, { -893,-1409,-1312, -341}, { -135, 438, -175, 18}, { 1111, 976, 319, 208}, {-1430,-1768, 83, 458}, { -530,-1000, 307, 129}, { -840, -15, -29, -356}, { -911, -924,-1147, -242}, { -119, -528, 127, -133}, { -761, -765, 190, -83}, { -315, 895, 522, 231}, { -222, 102, -63, -428}, { 316, 699, 379, 70}, { 25, 716, 314, -108}, { 507, 874, 566, 238}, { 108, 941, 519, 195}, { 425, -60, -427, 257}, { 139, -103, -630, 446}, { 334, 370, 412, 48}, { -172, -690, -283, 557}, { 187, -286, 158, 483}, { 140, 270, -344, -631}, { 924, 579, -116, 132}, { 142, 466, -68, -64}, { 230, -145, -302, -542}, { -803, -912, 1018, 737}, { -773, 1015, 630, 297}, {-2596, 95, 445, 336}, {-2122, 491, 510, 191}, {-1253, 161, -2, -324}, {-1450, -633, -712, -105}, { -842, -254, -411, 100}, { -640, -290, 1010, 763}, { -650, 313, 1169, 730}, { 140, 505, 1030, 766}, { 772, 287, 1067, 823}, { 495, 749, 305, 323}, { -164, 462, 78, 399}, { -342, -874, 69, 597}, { -16, 620, 621, 337}, { -138, -444, -265, 218}, { 84, -450, 953, 666}, { -222, -803, 541, 604}, { -921,-1376, 244, 116}, { -841, -723, 630, 588}, { 140, 663, 294, 368}, { 935, 1046, 881, 759}, { 1746, 1464, 916, 628}, { 436, 963, 281, 1}, { -119, 74, 542, 213}, { 1, -567, 301, 241}, { 260, 435, 222, 396}, { 936, 957, 1108, 703}, { 510, 506, 808, 478}, { 601, 694, 960, 620}, { 972, 741, 980, 600}, { 834, 717, 767, 684}, { 643, 972, 935, 638}, { 501, 661, 720, 851}, { -105, -632, -303, -117}, { -429, 130, 789, 442}, { -522, -188, 704, 373}, { -759, 42, 814, 523}, { -531,-1137, 373, 578}, { -682,-1203, -455, 285}, {-1163,-1577,-1098, 44}, { 81, -82, 712, 363}, { 477, 246, 954, 622}, { 1604, 1622, 1277, 891}, { 1409, 859, 924, 892}, { 774, 1041, 947, 1142}, { 40, -546, -75, 288}, { -616, -106, -697, -26}, { -169, -160, -891, -739}, { -279, -384,-1029, -350}, { 1781, 1308, 1046, 816}, { 1580, 1533, 1472, 1178}, { 1505, 1076, 1216, 899}, { 890, 904, 564, 654}, { 920, 692, 1021, 856}, { -493, 132, 177, 505}, { 71, 195, -28, 97}, { 456, 351, -164, 88}, { 439, 278, -40, 350}, { 1395, 949, 234, -95}, { -805, -472, 38, -163}, { 367, -98, 489, 523}, { 1025, 1178, 1212, 906}, { 319, 1314, 814, 461}, { -123, -543, -804, 447}, { -748, -324, -897,-1127}, { -737, -501, -789, -713}, { 715, 777, 1239, 922}, { 1949, 1939, 1368, 865}, { 730, 880, 758, 388}, { -871, 454, 17, -251}, { -381, -810,-1583, 239}, { -521, -966, -792, 259}, { -890,-1358, -770, -73}, { 166, 349, -212, 323}, { -840, -301, 473, 435}, { -679, -464, 728, 351}, { -156, -199, 667, 432}, { 29, -252, 415, 480}, { -731, -379, 145, 559}, { -528, -631,-1158, -159}, { 445, 273, 123, 639}, { 373, -126, 800, 568}, { 84, -162, 720, 712}, { -830, -536, -185, 222}, { 408, 452, 501, 771}, { -897,-1355, -67, 442}, { -792,-1406, 566, 602}, { 167, -326, 509, 330}, { -95, -626, -730, -344}, { 1668, 1217, 779, 455}, { 1316, 828, 584, 719}, { 404, -31, 1013, 789}, { 89, 107, 891, 549}, { 871, 1581, 917, 671}, { 866, 1479, 1289, 854}, { 391, 1068, 1122, 812}, { 78, -562, 345, 563}, { 429, -103, 417, 787}, { -122, -437, 411, 788}, { -913, -417, 602, 754}, { -226, -16, 151, 760}, { -700, 118, -104, -14}, {-1128, 48, 284, 393}, { -390, -419, -639, -116}, { -910, 306, 316, -13}, { 1207, 984, 821, 669}, {-1195, -693, 140, -213}, { -884, -416, -199, -558}, { -616, 245, -404, -664}, { 262, 56, -617, -724}, { -85, -491, -320, -656}, { -570, -831, -129, -528}, {-1506, -63, -367, -385}, { -358, -321, 4, 51}, { -366, -214, 319, 511}, { 146, 671, -17, -291}, { -110, 464, -139, -496}, { -202, 220, -312, -631}, { -660, -73, -655, -820}, { -662, -653,-1288, -857}, { -430, -953, -959, -264}, { -49, -468, -72, -381}, { -350, -563, -193, -407}, { 55, -408, -803, 11}, { -309, 649, 188, -198}, { -512, 461, -79, -458}, {-1318, -263, -134, -523}, {-1657, -435, -495, -765}, { 57, -347, -414, 434}, {-1141, -242, -664, -857}, { 34, -68, -707, -338} }; static const int16_t lsf_5_1[128][4] = { { -451,-1065, -529,-1305}, { -450, -756, -497, -863}, { -384, -619, -413, -669}, { -317, -538, -331, -556}, { -414, -508, -424, -378}, { -274, -324, -434, -614}, { -226, -500, -232, -514}, { -263, -377, -298, -410}, { -151, -710, -174, -818}, { -149, -412, -156, -429}, { -288, -462, -186, -203}, { -170, -302, -191, -321}, { -131, -147, -297, -395}, { -228, -214, -245, -192}, { -67, -316, -71, -327}, { -104, -205, -94, -183}, { -143, -38, -193, -95}, { 16, -76, -124, -248}, { 23, -237, 24, -244}, { 18, -136, 44, -111}, { -33, -24, -25, 0}, { 149, 19, 23, -143}, { 158, -169, 174, -181}, { 133, -55, 165, -26}, { 111, 84, 98, 75}, { 87, 183, -115, -11}, { -8, 130, 11, 170}, { 254, 77, 205, 17}, { 183, 112, 262, 194}, { 202, 287, 95, 189}, { -42, -105, 234, 179}, { 39, 186, 163, 345}, { 332, 199, 299, 161}, { -54, 285, -78, 281}, { -133, 141, -182, 111}, { 249, 341, 271, 364}, { 93, 403, 75, 391}, { 92, 510, -138, 220}, { -185, -29, -34, 361}, { -115, 320, 3, 554}, { 99, 286, 218, 591}, { -245, 406, -268, 453}, { 0, 580, 25, 606}, { 275, 532, 148, 450}, { -73, 739, -285, 518}, { -288, 94, -203, 674}, { -140, -74, 205, 714}, { -114, 299, 176, 923}, { 182, 557, 240, 705}, { -16, 513, 485, 593}, { 293, 384, 451, 617}, { -38, 50, 563, 529}, { 303, 209, 459, 363}, { 433, 452, 450, 454}, { 367, 606, 477, 741}, { 432, 353, 368, 267}, { 361, 716, 273, 583}, { 453, 166, 510, 172}, { 201, 629, 274, 191}, { 568, 639, 302, 298}, { 634, 387, 643, 350}, { 587, 560, 612, 565}, { 600, 788, 487, 672}, { 512, 1015, 321, 333}, { 357, 854, -125, 413}, { 474, 712, 17, -151}, { 564, 285, 270, -241}, { 971, 889, 489, 220}, { 510, 896, 549, 924}, { 327, 825, 290, 911}, { 540, 1108, 158, 805}, { 199, 957, 511, 730}, { 100, 874, 13, 791}, { 435, 632, 676, 972}, { 249, 900, 467, 1218}, { 781, 1074, 585, 785}, { -23, 669, 267, 1043}, { 619, 1084, 615, 1145}, { 622, 905, 916, 1049}, { 80, 331, 584, 1075}, { 89, 639, 988, 961}, { 770, 720, 798, 699}, { 492, 447, 899, 627}, { 271, 1188, 725, 1333}, { 87, 603, 832, 1603}, { 616, 1127, 890, 1505}, { 1000, 1156, 866, 1009}, { 995, 827, 1149, 858}, { 817, 1450, 773, 1320}, { 500, 1389, 312, 1153}, { -20, 1084, 64, 1283}, { 2, 1172, 399, 1869}, { 514, 1706, 502, 1636}, { 886, 1522, 416, 600}, { 1131, 1350, 1275, 1390}, { 889, 1795, 914, 1766}, { 227, 1183, 1250, 1826}, { 505, 1854, 919, 2353}, { -199, 431, 152, 1735}, { -213, -28, 392, 1334}, { -153, -52, 978, 1151}, { -323, -400, 813, 1703}, { -136, 84, 1449, 2015}, { -331, -143, -137, 1192}, { -256, 534, -157, 1031}, { -307, -439, 542, 731}, { -329, -420, -97, 616}, { -362, -168, -322, 366}, { -247, -110, -211, 89}, { -196, -309, 20, 59}, { -364, -463, -286, 89}, { -336, 175, -432, 141}, { -379, -190, -434, -196}, { -79, 150, -278, -227}, { -280, 166, -555, -422}, { -155, 541, -366, 54}, { -29, -83, -301, -774}, { 186, 628, -397, -264}, { 242, 293, -197, -585}, { 124, 410, 53, -133}, { 10, 340, -570,-1065}, { 65, -446, 68, -493}, { 383, 937, -357, -711}, { -359, -250, -677,-1068}, { 292, -26, 363, 6}, { 607, 1313, -127, -10}, { 1513, 1886, 713, 972}, { 1469, 2181, 1443, 2016} }; static const int16_t lsf_5_2[256][4] = { {-1631,-1600,-1796,-2290}, {-1027,-1770,-1100,-2025}, {-1277,-1388,-1367,-1534}, { -947,-1461, -972,-1524}, { -999,-1222,-1020,-1172}, { -815, -987, -992,-1371}, {-1216,-1006,-1289,-1094}, { -744,-1268, -755,-1293}, { -862, -923, -905, -984}, { -678,-1051, -685,-1050}, {-1087, -985,-1062, -679}, { -989, -641,-1127, -976}, { -762, -654, -890, -806}, { -833,-1091, -706, -629}, { -621, -806, -640, -812}, { -775, -634, -779, -543}, { -996, -565,-1075, -580}, { -546, -611, -572, -619}, { -760, -290, -879, -526}, { -823, -462, -795, -253}, { -553, -415, -589, -439}, { -533, -340, -692, -935}, { -505, -772, -702,-1131}, { -263, -306, -971, -483}, { -445, -74, -555, -548}, { -614, -129, -693, -234}, { -396, -246, -475, -250}, { -265, -404, -376, -514}, { -417, -510, -300, -313}, { -334, -664, -463, -814}, { -386, -704, -337, -615}, { -234, -201, -233, -239}, { -167, -567, -203, -619}, { -147, -415, -115, -352}, { -166, -750, -171, -761}, { -270, -879, -264, -903}, { -367, -744, 43, -475}, { 14, -653, 43, -670}, { 11, -448, -59, -521}, { -126, -119, -155, -613}, { -42, -863, -27, -931}, { 136, -483, 183, -468}, { 55, -298, 55, -304}, { 313, -609, 313, -720}, { 322, -167, 100, -541}, { -3, -119, -111, -187}, { 233, -236, 260, -234}, { 26, -165, 134, -45}, { -40, -549, 360, -203}, { 378, -388, 450, -383}, { 275, 20, 182, -103}, { 246, -111, 431, 37}, { 462, -146, 487, -157}, { -284, -59, 503, -184}, { 24, 53, -3, 54}, { 122, 259, 333, 66}, { 484, 104, 436, 68}, { 195, 116, 190, 206}, { 269, -9, 482, 352}, { 382, 285, 399, 277}, { 452, 256, 69, 186}, { 13, 297, -13, 259}, { -95, 30, 56, 394}, { 196, 425, 205, 456}, { 281, 577, 15, 191}, { 375, 290, 407, 576}, { -56, 227, 544, 405}, { 0, 549, -92, 528}, { -229, 351, -245, 338}, { -362, 435, 167, 527}, { -75, 302, 91, 824}, { 129, 599, 496, 679}, { 186, 749, 153, 737}, { -281, 600, -348, 615}, { -236, 769, 41, 881}, { 38, 890, -220, 841}, { -357, 883, -393, 903}, { -634, 474, -444, 850}, { -175, 678, -493, 242}, { -519, 785, -714, 582}, { -541, 366, -543, 434}, { -597, 500, -765, 222}, { -702, 917, -743, 962}, { -869, 501, -899, 548}, { -379, 200, -435, 157}, { -819, 214, -861, 157}, { -614, 40, -632, 94}, { -883, -54, -741, 516}, { -501, 298, -614, -171}, { -870, -161, -865, -23}, { -818, 93,-1015, -267}, { -662, -359, -549, 2}, { -442, -121, -377, 0}, { -227, 33, -414, -126}, { -129, 212, -934, 34}, {-1082, -282,-1119, -268}, { -710, -825, -420, -191}, {-1076, -928, -917, -93}, { -628, -358, 97, 7}, { -206, -393, -101, 24}, { -203, 38, -168, 83}, { -599, -423, -279, 426}, { -700, 118, -75, 206}, { -981, -673, -680, 417}, { -367, 37, -279, 474}, { -129, -318, 319, 296}, { -626, -39, 343, 602}, { -696, -39, -303, 940}, { 104, 233, -380, 137}, { -36, 269, -75, -214}, { 120, 43, -529, -477}, { 459, 164, -202, -229}, { -49, -167, 609, 792}, { 98, -220, 915, 148}, { 293, 283, 869, 91}, { 575, 394, 326, -78}, { 717, 67, 365, -323}, { 616, -36, 731, 27}, { 619, 238, 632, 273}, { 448, 99, 801, 476}, { 869, 273, 685, 64}, { 789, 72, 1021, 217}, { 793, 459, 734, 360}, { 646, 480, 360, 322}, { 429, 464, 638, 430}, { 756, 363, 1000, 404}, { 683, 528, 602, 615}, { 655, 413, 946, 687}, { 937, 602, 904, 604}, { 555, 737, 786, 662}, { 467, 654, 362, 589}, { 929, 710, 498, 478}, { 415, 420, 693, 883}, { 813, 683, 781, 925}, { 913, 939, 726, 732}, { 491, 853, 531, 948}, { 734, 963, 315, 808}, { 761, 755, 1144, 760}, { 655, 1076, 826, 1057}, { 1091, 838, 1003, 808}, { 1047, 1133, 659, 1101}, { 992, 1050, 1074, 1075}, { 971, 694, 1226, 1054}, { 571, 841, 884, 1404}, { 1379, 1096, 1080, 861}, { 1231, 735, 1284, 760}, { 1272, 991, 1367, 1053}, { 1257, 700, 1050, 534}, { 988, 453, 1264, 599}, { 1140, 679, 1621, 815}, { 1384, 521, 1317, 393}, { 1564, 805, 1448, 686}, { 1068, 648, 875, 307}, { 1083, 361, 1047, 317}, { 1417, 964, 675, 571}, { 1152, 79, 1114, -47}, { 1530, 311, 1721, 314}, { 1166, 689, 514, -94}, { 349, 282, 1412, 328}, { 1025, 487, -65, 57}, { 805, 970, 36, 62}, { 769, -263, 791, -346}, { 637, 699, -137, 620}, { 534, 541, -735, 194}, { 711, 300, -268, -863}, { 926, 769, -708, -428}, { 506, 174, -892, -630}, { 435, 547,-1435, -258}, { 621, 471,-1018,-1368}, { -393, 521, -920, -686}, { -25, 20, -982,-1156}, { 340, 9,-1558,-1135}, { -352, 48,-1579, -402}, { -887, 6,-1156, -888}, { -548, -352,-1643,-1168}, { -159, 610,-2024, -963}, { -225, 193,-1656,-1960}, { -245, -493, -964,-1680}, { -936, -635,-1299,-1744}, {-1388, -604,-1540, -835}, {-1397, -135,-1588, -290}, {-1670, -712,-2011,-1632}, {-1663, -27,-2258, -811}, {-1157, 184,-1265, 189}, {-1367, 586,-2011, 201}, { -790, 712,-1210, 3}, {-1033, 808,-1251, 830}, { -111, 635,-1636, 447}, { -463, -949, -445, -928}, { -504,-1162, -501,-1211}, { 144, -351, -372,-1052}, { -283,-1059, -279,-1123}, { -575,-1438, -587,-1614}, { -935, -984, 229, 690}, { -921, -719, -403, 1362}, { -685, -465, 874, 397}, { -509, -46, 317, 1334}, { -485, 456, 813, 439}, { -411, 339, 898, 1067}, { -425, 46, 1441, 497}, { -909, -800, 1465, 1046}, { -254, -321, 1430, 1165}, { 68, 350, 1034, 666}, { 370, 11, 1311, 790}, { 143, 232, 1041, 1562}, { -114, 663, 1616, 1078}, { 454, 579, 1275, 1040}, { -76, 909, 752, 1067}, { 153, 512, 348, 1214}, { 614, 385, 1843, 808}, { 269, 1034, 203, 1086}, { 652, 1017, 1783, 1130}, { 429, 1327, 387, 1384}, { -49, 1183, -72, 1215}, { -416, 1001, 544, 1749}, { -352, 1223, -502, 1199}, { -589, 569, -227, 1630}, { -142, 1578, -230, 1715}, { -714, 1288, -838, 1398}, { 1131, 1357, -208, 1232}, { 437, 965, -929, 818}, { 811, 1410, 859, 1507}, { 164, 1212, 1387, 1793}, { 484, 1874, 456, 2063}, { 996, 1170, 1326, 1402}, { 1316, 1360, 1135, 1262}, { 1234, 1618, 1361, 1768}, { 1421, 1227, 1584, 1347}, { 854, 672, 1685, 1566}, { 1139, 1270, 2016, 1825}, { 1773, 1581, 1532, 1460}, { 1487, 946, 1659, 1021}, { 1744, 1212, 1392, 977}, { 1772, 1161, 1826, 1164}, { 1718, 1429, 1973, 1591}, { 1185, 864, 2132, 1061}, { 1799, 814, 1838, 757}, { 2104, 1315, 2054, 1258}, { 2113, 915, 2331, 930}, { 1467, 1147, 2590, 1439}, { 2245, 1744, 2090, 1620}, { 2358, 1454, 2666, 1506}, { 1876, 1837, 2070, 1975}, { 1739, 1577, 682, 1289}, { 1584, 2045, 1454, 2098}, { 2498, 2004, 2711, 2066}, { 726, 1588, 2756, 2336}, { 228, 847, 2456, 1659}, { 36, 301, 1942, 1957}, { -446, -96, 2154, 1396}, { 1533, 1101, 14, 608}, { -923, -732, 1383, 1982}, { 1345, 952, -680, 321}, { 1281, 1268,-1594, 365}, { 941, 946,-1737, -822}, { 2374, 2787, 1821, 2788} }; static const int16_t lsf_5_3[256][4] = { {-1812,-2275,-1879,-2537}, {-1640,-1848,-1695,-2004}, {-1220,-1912,-1221,-2106}, {-1559,-1588,-1573,-1556}, {-1195,-1615,-1224,-1727}, {-1359,-1151,-1616,-1948}, {-1274,-1391,-1305,-1403}, {-1607,-1179,-1676,-1311}, {-1443,-1478,-1367, -898}, {-1256,-1059,-1331,-1134}, { -982,-1133,-1149,-1504}, {-1080,-1308,-1020,-1183}, { -980,-1486, -967,-1495}, { -988, -922,-1047,-1077}, { -838,-1179, -858,-1222}, {-1131,-1041,-1064, -767}, { -872,-1157, -701, -880}, { -706, -906, -774,-1016}, { -578,-1080, -801,-1478}, { -591,-1111, -592,-1146}, { -713,-1388, -640,-1376}, { -597,-1059, -416, -903}, { -686, -832, -661, -708}, { -444, -868, -490, -921}, { -374, -776, -619,-1170}, { -585, -549, -769, -795}, { -435, -659, -530, -741}, { -498, -837, -357, -597}, { -279, -871, -243, -887}, { -282, -665, -280, -667}, { -165, -560, -394, -903}, { -362, -410, -448, -583}, { -409, -574, -313, -357}, { -637, -548, -570, -436}, { -896, -504, -382, -757}, { -58, -481, -165, -618}, { -191, -374, -234, -382}, { -222, -683, -25, -480}, { -418, -359, -730, -353}, { -324, -157, -432, -322}, { -394, -303, -284, -104}, { -601, -289, -556, -196}, { -588, -150, -659, -608}, { -473, -24, -68, -448}, { -474, -8, -506, -45}, { -748, -184, -844, -252}, { -901, -91, -584, -97}, { -652, 138, -764, -131}, { -678, -12, -670, 165}, { -259, -3, -840, -107}, { -909, 37, -992, 44}, { -854, -415, -839, 13}, {-1001, -271,-1026, -309}, { -798, -478, -832, -488}, { -943, 168,-1112, -387}, {-1185, -101,-1183, -40}, { -941, -316,-1030, -770}, {-1044, -625,-1081, -538}, {-1224, -299,-1312, -436}, {-1197, -663,-1167, -161}, {-1216, -690,-1237, -831}, {-1432, -720,-1403, -493}, { -898, -740, -922, -801}, {-1102, -402,-1579, -964}, {-1061, -638,-1269,-1438}, {-1499, -934,-1502, -895}, {-1598, -564,-1723, -717}, { -606, -597,-1166,-1085}, {-1369, -468,-1946,-1493}, {-1838, -953,-1932, -931}, {-1499, -188,-1635, -421}, {-1457, -338,-1448, -22}, {-1942, -422,-2006, -249}, { -496, -114,-1910, -755}, {-1289, 174,-1451, -109}, { -482, -257,-1221, -508}, {-1617, 151,-1694, 208}, { -654, 107,-1651, 29}, {-1141, 279,-1215, 306}, {-1228, -506, -730, -175}, {-1236, -101, -969, 551}, { -870, 278, -823, 315}, { -563, 376,-1051, 228}, { -507, 280, -599, 281}, { -758, 253, -305, 379}, { -755, -134, -611, 660}, { -824, 536, -817, 646}, { -413, 49, -341, 177}, { -453, 526, -482, 589}, { -71, 339, -657, 264}, { -244, 295, -237, 315}, { -387, 569, -506, -9}, { -377, 14, -160, 661}, { -216, 40, -308, -46}, { 95, 214, -242, 167}, { -86, 192, -56, 27}, { -76, 31, 36, 309}, { -106, -182, -113, 74}, { -441, -22, 23, 139}, { 81, -11, 44, 15}, { -87, -137, -118, -207}, { -158, -58, 272, -92}, { -156, -441, 8, -136}, { 128, -221, 101, -218}, { 40, -197, -76, -456}, { 9, -445, 33, -423}, { 226, 60, 73, -222}, { 156, -399, 280, -318}, { 245, -341, 166, -499}, { 339, -190, 327, -219}, { 325, -137, -89, -596}, { 100, -627, 144, -677}, { 487, 28, 252, -391}, { 214, -41, 282, -28}, { 99, -286, 331, 49}, { 459, -388, 565, -369}, { 436, 28, 336, -9}, { 397, -167, 618, 34}, { 596, -17, 561, -140}, { 299, 79, 522, 125}, { 203, 2, 244, 288}, { 255, 211, 175, 82}, { 596, 187, 517, 108}, { 381, 255, 365, 297}, { 497, 352, 327, -82}, { 25, 210, 371, 245}, { 261, 3, 545, 449}, { 140, 294, 44, 295}, { 212, 347, 244, 494}, { 331, 528, 201, 307}, { 349, 411, 613, 284}, { 614, 413, 464, 322}, { 624, 397, 97, 200}, { -160, 384, 149, 362}, { 495, 525, 269, 585}, { 33, 491, -121, 433}, { 427, 611, 498, 516}, { 171, 443, 497, 666}, { 440, 275, 566, 575}, { 146, 639, 155, 670}, { -33, 173, 212, 696}, { -166, 601, -191, 695}, { -489, 503, 175, 742}, { 214, 476, 372, 1083}, { 578, 530, 586, 777}, { 425, 874, 315, 841}, { 374, 848, -165, 565}, { 35, 991, -39, 1062}, { 329, 712, 786, 840}, { 645, 795, 661, 676}, { 571, 918, 632, 1079}, { 673, 817, 318, 388}, { 874, 1012, 564, 848}, { 880, 620, 557, 479}, { 671, 453, 692, 468}, { 840, 642, 844, 645}, { 506, 428, 897, 567}, { 837, 387, 962, 499}, { 691, 561, 939, 926}, { 783, 296, 790, 268}, { 1028, 530, 874, 329}, { 548, 143, 675, 291}, { 503, 66, 1041, 359}, { 786, 97, 805, 33}, { 837, 470, 511, 49}, { 1092, 327, 1174, 323}, { 3, 242, 872, 474}, { 689, 429, 1329, 678}, { 1042, 620, 1109, 664}, { 321, 193, 889, 950}, { 1153, 874, 893, 635}, { 877, 862, 948, 913}, { 1293, 665, 1320, 639}, { 997, 793, 1402, 1030}, { 1176, 1012, 1110, 959}, { 1410, 925, 1403, 915}, { 543, 862, 1116, 1222}, { 835, 1190, 835, 1190}, { 959, 1148, 1147, 1376}, { 1300, 1193, 1415, 1231}, { 1335, 1341, 746, 1092}, { 1711, 1283, 1389, 1073}, { 1334, 1566, 1153, 1475}, { 1645, 1137, 1825, 1220}, { 1056, 1382, 1521, 1730}, { 1632, 1545, 1620, 1542}, { 855, 1596, 865, 1667}, { 693, 885, 1716, 1519}, { 1167, 1296, 2209, 1760}, { 1952, 1493, 2020, 1482}, { 1534, 1866, 1694, 2008}, { 1566, 748, 1761, 825}, { 294, 1392, 1084, 2058}, { 621, 1315, 365, 1287}, { 198, 1028, 488, 1408}, { 249, 403, 1014, 1561}, { 324, 363, 1645, 1044}, { 193, 367, 2034, 1859}, { -251, 579, 750, 994}, { -243, 30, 1325, 879}, { -28, -169, 624, 917}, { -453, 159, 186, 1370}, { -614, 6, 537, 392}, { -94, -291, 781, 229}, { -128, -298, 245, 491}, { -701, -648, 972, 789}, { -501, -640, 178, 255}, { -365, -390, -255, 317}, { -958, -294, -191, 228}, { -775, -447, 157, -237}, { -657, -720, -407, 92}, { -117, -611, 334, -230}, { -679,-1084, -144, -317}, { -901, -861, -738, -360}, { -85, -727, -90, -787}, { 100, -22, -391, -263}, { -56, -73, -337, -754}, { 5, -189, -706, -624}, { 89, -344, -135,-1113}, { -353, -237, -684,-1135}, { -275,-1102, -269,-1203}, { 152, 145, -722,-1232}, { 49, 80,-1248, -776}, { -248, 391, -732, -547}, { 469, 218, -255, -864}, { 69, 366, -166, -485}, { -688, 191,-1212,-1196}, { -170, -169,-1308,-1631}, { 321, 470,-1419,-1243}, { -64, 272,-1361, -248}, { 492, 565, -721, -609}, { 195, 485, -573, -133}, { 427, 202, -171, -118}, { 199, 575, 2, -31}, { 694, 755,-1366, -39}, { 552, 557, -489, 271}, { 680, 537, 13, -453}, { 855, 954, -133, -52}, { -81, 738,-1169, 637}, { 1055, 1059, -95, 676}, { 1259, 1081, 489, 305}, { -449, 954, -534, 996}, { -969, 866,-1058, 1059}, {-1294, 618,-1416, 617}, { -458, 1366, -159, 1821}, { -774, -528, -14, 1110}, {-1202, -901, -772, 433}, {-1256,-1255,-1011, -302}, { -602, -585, -759,-1618}, { -760,-1549, -840,-1921}, { -816, -539,-1769,-2235}, { -227, -36,-2034,-1831}, {-2107,-1126,-2471,-1816}, {-1470, 252,-2701, -415}, { -571, -467, 1509, 1554}, { 2180, 1975, 2326, 2020} }; static const int16_t lsf_5_4[256][4] = { {-1857,-1681,-1857,-1755}, {-2056,-1150,-2134,-1654}, {-1619,-1099,-1704,-1131}, {-1345,-1608,-1359,-1638}, {-1338,-1293,-1325,-1265}, {-1664,-1649,-1487, -851}, {-1346,-1832,-1413,-2188}, {-1282, -681,-1785,-1649}, { -966,-1082,-1183,-1676}, {-1054,-1073,-1142,-1158}, {-1207, -744,-1274, -997}, { -934,-1383, -927,-1416}, {-1010,-1305, -783, -955}, {-1049, -900, -993, -817}, { -737, -823, -972,-1189}, { -738,-1094, -738,-1154}, { -784, -801, -810, -786}, { -892, -520,-1000, -818}, { -644, -965, -577, -882}, { -541, -694, -671, -917}, { -595, -642, -646, -615}, { -956, -621, -925, -515}, { -727, -483, -815, -485}, { -840, -578, -440, -713}, { -578, -325, -657, -670}, { -386, -570, -441, -666}, { -514, -787, -392, -529}, { -522, -453, -487, -423}, { -616, -585, -617, -157}, { -662, -268, -680, -348}, { -322, -323, -632, -444}, { -304, -430, -332, -458}, { -277, -468, -659, -793}, { -319, -636, -227, -554}, { -373, -347, -334, -210}, { -456, -192, -530, -242}, { -216, -198, -366, -370}, { -338, -161, -409, -748}, { -107, -380, -294, -643}, { -223, -665, -234, -741}, { -141, -496, -130, -510}, { -139, -327, -172, -305}, { -306, -580, -164, -263}, { -262, -172, -67, -402}, { 31, -366, -10, -436}, { -86, -527, 71, -377}, { -22, -609, -12, -678}, { -67, -319, 63, -191}, { 35, -181, -39, -242}, { 126, -167, -140, -544}, { 155, -297, 174, -297}, { 38, -8, 117, -380}, { 197, -452, 240, -522}, { 223, -103, 110, -187}, { 87, -155, 169, -47}, { 157, 26, -83, -100}, { 128, 80, 209, -62}, { 6, 7, 22, 5}, { 318, -20, 248, -45}, { -200, -63, 156, -69}, { 250, -183, 369, -126}, { -113, -76, -142, -122}, { -64, -254, -31, 35}, { -177, -71, -7, 171}, { 93, 27, 108, 212}, { -330, -209, -123, -70}, { -279, 95, -96, 20}, { -188, -61, -314, 87}, { -300, -78, -354, -134}, { 11, 122, -140, 122}, { -275, 152, -293, 140}, { -82, 138, -321, -111}, { -480, -156, -359, 76}, { -254, -40, -635, -96}, { -522, 79, -507, 8}, { -268, 303, -539, 68}, { -446, 61, -522, 306}, { 111, 189, -435, 122}, { -379, 166, -571, -398}, { -632, -74, -747, -95}, { -455, 194, -952, 83}, { -798, 192, -755, 192}, { -781, -162, -619, 234}, { -663, -297, -488, -109}, { -964, -132, -838, -68}, { -843, 58,-1112, -86}, { -805, -299, -944, -253}, { -778, -50, -965, -549}, { -352, -98, -992, -343}, {-1117, -315,-1117, -307}, {-1155, -374, -637, -230}, {-1166, -43,-1299, -100}, { -925, -393,-1274, -600}, { -689, -130,-1479, -312}, {-1321, -254,-1464, -442}, {-1292, -613,-1261, -503}, {-1501, -368,-1322, 26}, {-1432, -66,-1743, -161}, {-1644, -467,-1760, -548}, {-1393, -568,-1556, -871}, {-1495,-1034,-1387, -571}, {-1917, -528,-1783, -123}, {-1897, -231,-2054, -323}, {-2052, -906,-1976, -567}, {-1917, -620,-2047, -989}, {-1077, -370,-2031, -704}, {-2355, -749,-2740,-1089}, {-1909, 159,-2012, 248}, { -626, -123,-2339, -962}, { -669, -408,-1379,-1174}, { -452, -364,-1044, -735}, { -132, 183,-1620, -752}, { -547, -307, -777,-1261}, { -98, 41, -880,-1091}, { -257, 97,-1602,-1833}, { 31, -26, -644, -561}, { -180, -546, -385,-1095}, { -410, -802, -414, -827}, { -457, -970, -490,-1109}, { -215, -916, -144, -937}, { -493,-1269, -517,-1507}, { 181, 101, -332, -889}, { -836, -937, -559, -429}, { -629, -547, -183, -337}, { -545, -82, -250, -286}, { 5, -132, -348, -252}, { -293, -472, -158, 100}, { -29, 197, -236, -424}, { -861, -213, -140, -7}, { -427, -443, 187, -97}, { -684, -736, -293, 258}, { -368, -152, -150, 392}, { -609, 175, -142, 299}, { -138, 152, -119, 329}, { -486, -52, 293, 198}, { -183, 117, 175, 331}, { -58, -274, 231, 300}, { -288, 330, -305, 372}, { -111, 409, -9, 423}, { 83, 256, 67, 367}, { -19, 248, 91, 113}, { -35, 406, -191, 154}, { 238, 296, 5, 197}, { 141, 221, 313, 198}, { 211, 421, 244, 334}, { 88, 426, -243, 454}, { 202, 552, -5, 403}, { 291, 185, 219, 301}, { 251, 138, 128, 69}, { 197, 288, -140, -61}, { 188, 361, 197, 598}, { 442, 273, 290, 143}, { 472, 482, 157, 370}, { 415, 321, 372, 385}, { 402, 552, 155, 24}, { 550, 263, -11, 21}, { 360, 227, 147, -254}, { 424, 97, 366, -13}, { 375, 141, 449, 232}, { 396, 507, 474, 272}, { 701, 324, 362, -47}, { 587, 148, 543, 69}, { 400, -51, 561, 59}, { 220, -10, 352, 147}, { 206, 211, 653, 185}, { 563, 297, 565, 284}, { 594, 121, 766, 192}, { 398, 118, 642, 434}, { 233, 264, 481, 467}, { 129, -165, 699, 239}, { 90, 26, 342, 474}, { -55, 27, 388, 94}, { -172, 0, 725, 379}, { -60, 337, 370, 465}, { 95, 319, 806, 595}, { 78, 260, 497, 851}, { 210, 560, 458, 574}, { -464, 202, 497, 625}, { -202, 152, 48, 712}, { -20, 566, 100, 715}, { 455, 468, 411, 605}, { 319, 646, 195, 615}, { 401, 538, 680, 739}, { 201, 667, 434, 954}, { 454, 425, 646, 491}, { 606, 681, 416, 508}, { 497, 822, 426, 815}, { 660, 647, 628, 716}, { 697, 466, 618, 457}, { 685, 460, 365, 309}, { 721, 567, 836, 601}, { 609, 300, 825, 459}, { 943, 687, 681, 533}, { 915, 598, 591, 243}, { 876, 451, 874, 420}, { 786, 317, 732, 220}, { 922, 317, 1108, 367}, { 531, 466, 1028, 649}, { 1053, 615, 1034, 553}, { 829, 602, 1021, 799}, { 927, 803, 878, 763}, { 799, 496, 1373, 773}, { 585, 770, 803, 930}, { 1099, 793, 1222, 862}, { 1209, 895, 1025, 727}, { 772, 845, 1172, 1115}, { 867, 1021, 830, 1013}, { 841, 910, 506, 703}, { 1239, 1077, 620, 819}, { 1196, 1083, 1155, 1081}, { 1142, 907, 1547, 1121}, { 1309, 648, 1343, 612}, { 1484, 988, 1479, 937}, { 985, 1328, 955, 1341}, { 429, 910, 841, 1338}, { 564, 1179, 412, 1156}, { 1427, 1320, 1434, 1330}, { 640, 760, 1726, 1410}, { 190, 555, 1073, 1005}, { 426, 257, 839, 980}, { 235, 231, 1520, 1167}, { 109, 293, 1014, 1569}, { 305, 142, 1148, 539}, { -291, -108, 1213, 972}, { 22, -216, 667, 828}, { -482, 438, 453, 1431}, { -581, -422, 789, 387}, { -358, -454, 174, 780}, { -36, -372, 390, -134}, { -629, 160, -306, 751}, {-1258, -331, 177, 522}, { -248, 574, -251, 639}, { -531, 407, -596, 394}, { -419, 789, -617, 801}, { -986, 399, -857, 727}, { -7, 518, -703, 310}, {-1143, -24,-1002, 287}, { -960, 363,-1299, 312}, {-1534, 245,-1557, 305}, { 28, 153, -859, -175}, { -33, 332,-1398, -154}, { 212, 410, -593, -197}, {-1092, -704, -904, -65}, { 282, 367, -918, -686}, { 345, 93, -258, -357}, { 696, 644, -693, -28}, { 448, 493, -273, 193}, { 527, 546, -243, -513}, { 384, -136, 273, -353}, { 512, -142, 537, -198}, { 941, 750, 83, 248}, { 578, 861, -56, 592}, { 842, 44, 892, 24}, { 33, 890, -16, 982}, { 831, 1398, 1535, 1898}, { 1716, 1376, 1948, 1465} }; static const int16_t lsf_5_5[64][4] = { {-1002, -929,-1096,-1203}, { -641, -931, -604, -961}, { -779, -673, -835, -788}, { -416, -664, -458, -766}, { -652, -521, -662, -495}, {-1023, -509,-1023, -428}, { -444, -552, -368, -449}, { -479, -211,-1054, -903}, { -316, -249, -569, -591}, { -569, -275, -541, -191}, { -716, -188, -842, -264}, { -333, -248, -318, -228}, { -275, 1, -567, -228}, { -115, -221, -238, -374}, { -197, -507, -222, -579}, { -258, -432, -61, -244}, { -345, 2, -338, 39}, { -215, -169, -58, 0}, { -56, -6, -203, -131}, { 1, -186, -5, -211}, { 6, -380, 11, -418}, { -116, 131, -134, 113}, { 89, -4, 71, -2}, { -19, -192, 262, 24}, { 189, 151, -133, -109}, { 186, -153, 166, -219}, { 37, 139, 193, 171}, { 337, 124, 158, -61}, { 141, 226, -13, 190}, { 231, 34, 354, 109}, { 316, 201, 244, 164}, { 330, -85, 390, -84}, { 254, 327, 257, 335}, { 491, 147, 476, 105}, { 54, 77, 437, 370}, { 421, 314, 449, 342}, { 329, 126, 673, 292}, { 571, 388, 243, 193}, { 653, 320, 621, 280}, { 194, 380, 517, 581}, { 45, 323, 111, 422}, { 489, 395, 734, 534}, { 622, 546, 486, 502}, { 318, 572, 189, 550}, { 385, 422, -157, 153}, { -125, 382, -197, 386}, { -263, 334, 228, 697}, { -188, 1, 51, 297}, { -507, 213, -376, 397}, { -24, 255, -547, 89}, { -502, -94, 387, 179}, { -620, 68, -684, 112}, { -642, -350, -260, 172}, { -438, -324, 264, 648}, { -964, -4,-1121, 7}, { -134, 134,-1133, -306}, { 143, 96, -420, -497}, {-1221, -350,-1527, -685}, { -161, 72, 873, 691}, { 732, 283, 921, 353}, { 334, 475, 1095, 821}, { 864, 524, 843, 497}, { 714, 711, 788, 750}, { 1076, 714, 1204, 753} }; static const float lsf_3_mean[LP_FILTER_ORDER] = { 377.441, 554.688, 922.363, 1339.84, 1702.15, 2046.390, 2452.880, 2741.460, 3116.70, 3348.14 }; static const float lsf_5_mean[LP_FILTER_ORDER] = { 337.891, 507.080, 834.961, 1247.07, 1646.00, 1982.910, 2407.960, 2708.010, 3104.00, 3344.97 }; /** Prediction factor table for modes other than 12.2kbit/s */ static const float pred_fac[LP_FILTER_ORDER] = { 0.291626, 0.328644, 0.383636, 0.405640, 0.438873, 0.355560, 0.323120, 0.298065, 0.262238, 0.197876, }; // fixed tables /** * number of pulses per mode */ static const uint8_t pulses_nb_per_mode[] = {2, 2, 2, 3, 4, 4, 8, 10}; /** track start positions for algebraic code book routines */ static const uint8_t track_position[16] = { 0, 2, 0, 3, 0, 2, 0, 3, 1, 3, 2, 4, 1, 4, 1, 4 }; /** 3-bit Gray code to binary lookup table */ static const uint8_t gray_decode[8] = { 0, 5, 15, 10, 25, 30, 20, 35 }; // gain tables /** scalar quantized pitch gain table for 7.95 and 12.2 kbps modes */ static const uint16_t qua_gain_pit[16] = { 0, 3277, 6556, 8192, 9830, 11469, 12288, 13107, 13926, 14746, 15565, 16384, 17203, 18022, 18842, 19661 }; /** scalar quantized fixed gain table for 7.95 and 12.2 kbps modes */ static const uint16_t qua_gain_code[32] = { 159, 206, 268, 349, 419, 482, 554, 637, 733, 842, 969, 1114, 1281, 1473, 1694, 1948, 2241, 2577, 2963, 3408, 3919, 4507, 5183, 5960, 6855, 7883, 9065, 10425, 12510, 16263, 21142, 27485 }; /** desired mean innovation energy, indexed by active mode */ static const float energy_mean[8] = { 33.0, 33.0, 33.0, 28.75, 30.0, 36.0, 33.0, 36.0 }; /** 4-tap moving average prediction coefficients in reverse order */ static const float energy_pred_fac[4] = { 0.19, 0.34, 0.58, 0.68 }; /** gain table for 4.75 kbps mode * * first index has even/odd indexes for subframes 0,2/1,3 * second index is {pitch_gain, fixed_gain_factor} */ static const uint16_t gains_MODE_4k75[512][2] = { { 812, 128}, { 542, 140}, { 2873, 1135}, { 2266, 3402}, { 2067, 563}, {12677, 647}, { 4132, 1798}, { 5601, 5285}, { 7689, 374}, { 3735, 441}, {10912, 2638}, {11807, 2494}, {20490, 797}, { 5218, 675}, { 6724, 8354}, { 5282, 1696}, { 1488, 428}, { 5882, 452}, { 5332, 4072}, { 3583, 1268}, { 2469, 901}, {15894, 1005}, {14982, 3271}, {10331, 4858}, { 3635, 2021}, { 2596, 835}, {12360, 4892}, {12206, 1704}, {13432, 1604}, { 9118, 2341}, { 3968, 1538}, { 5479, 9936}, { 3795, 417}, { 1359, 414}, { 3640, 1569}, { 7995, 3541}, {11405, 645}, { 8552, 635}, { 4056, 1377}, {16608, 6124}, {11420, 700}, { 2007, 607}, {12415, 1578}, {11119, 4654}, {13680, 1708}, {11990, 1229}, { 7996, 7297}, {13231, 5715}, { 2428, 1159}, { 2073, 1941}, { 6218, 6121}, { 3546, 1804}, { 8925, 1802}, { 8679, 1580}, {13935, 3576}, {13313, 6237}, { 6142, 1130}, { 5994, 1734}, {14141, 4662}, {11271, 3321}, {12226, 1551}, {13931, 3015}, { 5081,10464}, { 9444, 6706}, { 1689, 683}, { 1436, 1306}, { 7212, 3933}, { 4082, 2713}, { 7793, 704}, {15070, 802}, { 6299, 5212}, { 4337, 5357}, { 6676, 541}, { 6062, 626}, {13651, 3700}, {11498, 2408}, {16156, 716}, {12177, 751}, { 8065,11489}, { 6314, 2256}, { 4466, 496}, { 7293, 523}, {10213, 3833}, { 8394, 3037}, { 8403, 966}, {14228, 1880}, { 8703, 5409}, {16395, 4863}, { 7420, 1979}, { 6089, 1230}, { 9371, 4398}, {14558, 3363}, {13559, 2873}, {13163, 1465}, { 5534, 1678}, {13138,14771}, { 7338, 600}, { 1318, 548}, { 4252, 3539}, {10044, 2364}, {10587, 622}, {13088, 669}, {14126, 3526}, { 5039, 9784}, {15338, 619}, { 3115, 590}, {16442, 3013}, {15542, 4168}, {15537, 1611}, {15405, 1228}, {16023, 9299}, { 7534, 4976}, { 1990, 1213}, {11447, 1157}, {12512, 5519}, { 9475, 2644}, { 7716, 2034}, {13280, 2239}, {16011, 5093}, { 8066, 6761}, {10083, 1413}, { 5002, 2347}, {12523, 5975}, {15126, 2899}, {18264, 2289}, {15827, 2527}, {16265,10254}, {14651,11319}, { 1797, 337}, { 3115, 397}, { 3510, 2928}, { 4592, 2670}, { 7519, 628}, {11415, 656}, { 5946, 2435}, { 6544, 7367}, { 8238, 829}, { 4000, 863}, {10032, 2492}, {16057, 3551}, {18204, 1054}, { 6103, 1454}, { 5884, 7900}, {18752, 3468}, { 1864, 544}, { 9198, 683}, {11623, 4160}, { 4594, 1644}, { 3158, 1157}, {15953, 2560}, {12349, 3733}, {17420, 5260}, { 6106, 2004}, { 2917, 1742}, {16467, 5257}, {16787, 1680}, {17205, 1759}, { 4773, 3231}, { 7386, 6035}, {14342,10012}, { 4035, 442}, { 4194, 458}, { 9214, 2242}, { 7427, 4217}, {12860, 801}, {11186, 825}, {12648, 2084}, {12956, 6554}, { 9505, 996}, { 6629, 985}, {10537, 2502}, {15289, 5006}, {12602, 2055}, {15484, 1653}, {16194, 6921}, {14231, 5790}, { 2626, 828}, { 5615, 1686}, {13663, 5778}, { 3668, 1554}, {11313, 2633}, { 9770, 1459}, {14003, 4733}, {15897, 6291}, { 6278, 1870}, { 7910, 2285}, {16978, 4571}, {16576, 3849}, {15248, 2311}, {16023, 3244}, {14459,17808}, {11847, 2763}, { 1981, 1407}, { 1400, 876}, { 4335, 3547}, { 4391, 4210}, { 5405, 680}, {17461, 781}, { 6501, 5118}, { 8091, 7677}, { 7355, 794}, { 8333, 1182}, {15041, 3160}, {14928, 3039}, {20421, 880}, {14545, 852}, {12337,14708}, { 6904, 1920}, { 4225, 933}, { 8218, 1087}, {10659, 4084}, {10082, 4533}, { 2735, 840}, {20657, 1081}, {16711, 5966}, {15873, 4578}, {10871, 2574}, { 3773, 1166}, {14519, 4044}, {20699, 2627}, {15219, 2734}, {15274, 2186}, { 6257, 3226}, {13125,19480}, { 7196, 930}, { 2462, 1618}, { 4515, 3092}, {13852, 4277}, {10460, 833}, {17339, 810}, {16891, 2289}, {15546, 8217}, {13603, 1684}, { 3197, 1834}, {15948, 2820}, {15812, 5327}, {17006, 2438}, {16788, 1326}, {15671, 8156}, {11726, 8556}, { 3762, 2053}, { 9563, 1317}, {13561, 6790}, {12227, 1936}, { 8180, 3550}, {13287, 1778}, {16299, 6599}, {16291, 7758}, { 8521, 2551}, { 7225, 2645}, {18269, 7489}, {16885, 2248}, {17882, 2884}, {17265, 3328}, { 9417,20162}, {11042, 8320}, { 1286, 620}, { 1431, 583}, { 5993, 2289}, { 3978, 3626}, { 5144, 752}, {13409, 830}, { 5553, 2860}, {11764, 5908}, {10737, 560}, { 5446, 564}, {13321, 3008}, {11946, 3683}, {19887, 798}, { 9825, 728}, {13663, 8748}, { 7391, 3053}, { 2515, 778}, { 6050, 833}, { 6469, 5074}, { 8305, 2463}, { 6141, 1865}, {15308, 1262}, {14408, 4547}, {13663, 4515}, { 3137, 2983}, { 2479, 1259}, {15088, 4647}, {15382, 2607}, {14492, 2392}, {12462, 2537}, { 7539, 2949}, {12909,12060}, { 5468, 684}, { 3141, 722}, { 5081, 1274}, {12732, 4200}, {15302, 681}, { 7819, 592}, { 6534, 2021}, {16478, 8737}, {13364, 882}, { 5397, 899}, {14656, 2178}, {14741, 4227}, {14270, 1298}, {13929, 2029}, {15477, 7482}, {15815, 4572}, { 2521, 2013}, { 5062, 1804}, { 5159, 6582}, { 7130, 3597}, {10920, 1611}, {11729, 1708}, {16903, 3455}, {16268, 6640}, { 9306, 1007}, { 9369, 2106}, {19182, 5037}, {12441, 4269}, {15919, 1332}, {15357, 3512}, {11898,14141}, {16101, 6854}, { 2010, 737}, { 3779, 861}, {11454, 2880}, { 3564, 3540}, { 9057, 1241}, {12391, 896}, { 8546, 4629}, {11561, 5776}, { 8129, 589}, { 8218, 588}, {18728, 3755}, {12973, 3149}, {15729, 758}, {16634, 754}, {15222,11138}, {15871, 2208}, { 4673, 610}, {10218, 678}, {15257, 4146}, { 5729, 3327}, { 8377, 1670}, {19862, 2321}, {15450, 5511}, {14054, 5481}, { 5728, 2888}, { 7580, 1346}, {14384, 5325}, {16236, 3950}, {15118, 3744}, {15306, 1435}, {14597, 4070}, {12301,15696}, { 7617, 1699}, { 2170, 884}, { 4459, 4567}, {18094, 3306}, {12742, 815}, {14926, 907}, {15016, 4281}, {15518, 8368}, {17994, 1087}, { 2358, 865}, {16281, 3787}, {15679, 4596}, {16356, 1534}, {16584, 2210}, {16833, 9697}, {15929, 4513}, { 3277, 1085}, { 9643, 2187}, {11973, 6068}, { 9199, 4462}, { 8955, 1629}, {10289, 3062}, {16481, 5155}, {15466, 7066}, {13678, 2543}, { 5273, 2277}, {16746, 6213}, {16655, 3408}, {20304, 3363}, {18688, 1985}, {14172,12867}, {15154,15703}, { 4473, 1020}, { 1681, 886}, { 4311, 4301}, { 8952, 3657}, { 5893, 1147}, {11647, 1452}, {15886, 2227}, { 4582, 6644}, { 6929, 1205}, { 6220, 799}, {12415, 3409}, {15968, 3877}, {19859, 2109}, { 9689, 2141}, {14742, 8830}, {14480, 2599}, { 1817, 1238}, { 7771, 813}, {19079, 4410}, { 5554, 2064}, { 3687, 2844}, {17435, 2256}, {16697, 4486}, {16199, 5388}, { 8028, 2763}, { 3405, 2119}, {17426, 5477}, {13698, 2786}, {19879, 2720}, { 9098, 3880}, {18172, 4833}, {17336,12207}, { 5116, 996}, { 4935, 988}, { 9888, 3081}, { 6014, 5371}, {15881, 1667}, { 8405, 1183}, {15087, 2366}, {19777, 7002}, {11963, 1562}, { 7279, 1128}, {16859, 1532}, {15762, 5381}, {14708, 2065}, {20105, 2155}, {17158, 8245}, {17911, 6318}, { 5467, 1504}, { 4100, 2574}, {17421, 6810}, { 5673, 2888}, {16636, 3382}, { 8975, 1831}, {20159, 4737}, {19550, 7294}, { 6658, 2781}, {11472, 3321}, {19397, 5054}, {18878, 4722}, {16439, 2373}, {20430, 4386}, {11353,26526}, {11593, 3068}, { 2866, 1566}, { 5108, 1070}, { 9614, 4915}, { 4939, 3536}, { 7541, 878}, {20717, 851}, { 6938, 4395}, {16799, 7733}, {10137, 1019}, { 9845, 964}, {15494, 3955}, {15459, 3430}, {18863, 982}, {20120, 963}, {16876,12887}, {14334, 4200}, { 6599, 1220}, { 9222, 814}, {16942, 5134}, { 5661, 4898}, { 5488, 1798}, {20258, 3962}, {17005, 6178}, {17929, 5929}, { 9365, 3420}, { 7474, 1971}, {19537, 5177}, {19003, 3006}, {16454, 3788}, {16070, 2367}, { 8664, 2743}, { 9445,26358}, {10856, 1287}, { 3555, 1009}, { 5606, 3622}, {19453, 5512}, {12453, 797}, {20634, 911}, {15427, 3066}, {17037,10275}, {18883, 2633}, { 3913, 1268}, {19519, 3371}, {18052, 5230}, {19291, 1678}, {19508, 3172}, {18072,10754}, {16625, 6845}, { 3134, 2298}, {10869, 2437}, {15580, 6913}, {12597, 3381}, {11116, 3297}, {16762, 2424}, {18853, 6715}, {17171, 9887}, {12743, 2605}, { 8937, 3140}, {19033, 7764}, {18347, 3880}, {20475, 3682}, {19602, 3380}, {13044,19373}, {10526,23124} }; /** gain table for 6.70, 7.40 and 10.2 kbps modes * * second index is {pitch_gain, fixed_gain_factor} */ static const uint16_t gains_high[128][2] = { { 577, 662}, { 806, 1836}, { 3109, 1052}, { 4181, 1387}, { 2373, 1425}, { 3248, 1985}, { 1827, 2320}, { 941, 3314}, { 2351, 2977}, { 3616, 2420}, { 3451, 3096}, { 2955, 4301}, { 1848, 4500}, { 3884, 5416}, { 1187, 7210}, { 3083, 9000}, { 7384, 883}, { 5962, 1506}, { 5155, 2134}, { 7944, 2009}, { 6507, 2250}, { 7670, 2752}, { 5952, 3016}, { 4898, 3764}, { 6989, 3588}, { 8174, 3978}, { 6064, 4404}, { 7709, 5087}, { 5523, 6021}, { 7769, 7126}, { 6060, 7938}, { 5594,11487}, {10581, 1356}, { 9049, 1597}, { 9794, 2035}, { 8946, 2415}, {10296, 2584}, { 9407, 2734}, { 8700, 3218}, { 9757, 3395}, {10177, 3892}, { 9170, 4528}, {10152, 5004}, { 9114, 5735}, {10500, 6266}, {10110, 7631}, { 8844, 8727}, { 8956,12496}, {12924, 976}, {11435, 1755}, {12138, 2328}, {11388, 2368}, {10700, 3064}, {12332, 2861}, {11722, 3327}, {11270, 3700}, {10861, 4413}, {12082, 4533}, {11283, 5205}, {11960, 6305}, {11167, 7534}, {12128, 8329}, {10969,10777}, {10300,17376}, {13899, 1681}, {12580, 2045}, {13265, 2439}, {14033, 2989}, {13452, 3098}, {12396, 3658}, {13510, 3780}, {12880, 4272}, {13533, 4861}, {12667, 5457}, {13854, 6106}, {13031, 6483}, {13557, 7721}, {12957, 9311}, {13714,11551}, {12591,15206}, {15113, 1540}, {15072, 2333}, {14527, 2511}, {14692, 3199}, {15382, 3560}, {14133, 3960}, {15102, 4236}, {14332, 4824}, {14846, 5451}, {15306, 6083}, {14329, 6888}, {15060, 7689}, {14406, 9426}, {15387, 9741}, {14824,14271}, {13600,24939}, {16396, 1969}, {16817, 2832}, {15713, 2843}, {16104, 3336}, {16384, 3963}, {16940, 4579}, {15711, 4599}, {16222, 5448}, {16832, 6382}, {15745, 7141}, {16326, 7469}, {16611, 8624}, {17028,10418}, {15905,11817}, {16878,14690}, {16515,20870}, {18142, 2083}, {19401, 3178}, {17508, 3426}, {20054, 4027}, {18069, 4249}, {18952, 5066}, {17711, 5402}, {19835, 6192}, {17950, 7014}, {21318, 7877}, {17910, 9289}, {19144, 9290}, {20517,11381}, {18075,14485}, {19999,17882}, {18842,32764} }; /** gain table for 5.15 and 5.90 kbps modes * * second index is {pitch_gain, fixed_gain_factor} */ static const uint16_t gains_low[64][2] = { {10813,28753}, {20480, 2785}, {18841, 6594}, { 6225, 7413}, {17203,10444}, {21626, 1269}, {21135, 4423}, {11304, 1556}, {19005,12820}, {17367, 2498}, {17858, 4833}, { 9994, 2498}, {17530, 7864}, {14254, 1884}, {15892, 3153}, { 6717, 1802}, {18186,20193}, {18022, 3031}, {16711, 5857}, { 8847, 4014}, {15892, 8970}, {18022, 1392}, {16711, 4096}, { 8192, 655}, {15237,13926}, {14254, 3112}, {14090, 4669}, { 5406, 2703}, {13434, 6553}, {12451, 901}, {12451, 2662}, { 3768, 655}, {14745,23511}, {19169, 2457}, {20152, 5079}, { 6881, 4096}, {20480, 8560}, {19660, 737}, {19005, 4259}, { 7864, 2088}, {11468,12288}, {15892, 1474}, {15728, 4628}, { 9175, 1433}, {16056, 7004}, {14827, 737}, {15073, 2252}, { 5079, 1228}, {13271,17326}, {16547, 2334}, {15073, 5816}, { 3932, 3686}, {14254, 8601}, {16875, 778}, {15073, 3809}, { 6062, 614}, { 9338, 9256}, {13271, 1761}, {13271, 3522}, { 2457, 1966}, {11468, 5529}, {10485, 737}, {11632, 3194}, { 1474, 778} }; // pre-processing tables /** impulse response filter tables converted to float from Q15 int32_t * used for anti-sparseness processing */ static const float ir_filter_strong_MODE_7k95[AMR_SUBFRAME_SIZE] = { 0.817169, 0.024445, 0.076447, -0.020844, -0.042175, 0.017761, 0.018433, -0.038879, 0.107147, -0.179871, 0.138367, -0.015228, -0.059204, 0.091888, -0.154358, 0.171326, -0.060730, -0.032379, -0.044525, 0.135559, -0.021362, -0.162811, 0.140656, 0.013794, -0.017975, -0.102295, 0.090118, 0.038666, -0.036987, -0.079041, 0.052826, 0.112000, -0.136566, -0.029755, 0.134003, -0.077423, 0.028961, -0.041595, -0.029877, 0.174988, }; static const float ir_filter_strong[AMR_SUBFRAME_SIZE] = { 0.448303, 0.351501, 0.038696, -0.084259, -0.173065, 0.229309, -0.001068, -0.085663, -0.092773, 0.147186, 0.090088, -0.257080, 0.115509, 0.044403, 0.066498, -0.263580, 0.245697, -0.064178, -0.044373, 0.023712, 0.033813, -0.072784, 0.068787, -0.011078, -0.020569, -0.064178, 0.184509, -0.173370, 0.032715, 0.095306, -0.154358, 0.162109, -0.071075, -0.113770, 0.211304, -0.118683, 0.020599, -0.054169, 0.000885, 0.309601, }; static const float ir_filter_medium[AMR_SUBFRAME_SIZE] = { 0.923889, 0.116913, -0.123169, 0.090698, -0.031982, -0.030579, 0.075592, -0.092865, 0.085907, -0.068085, 0.053497, -0.049164, 0.052307, -0.054169, 0.047089, -0.030762, 0.013092, -0.005157, 0.014404, -0.038574, 0.066406, -0.082581, 0.076996, -0.049469, 0.010498, 0.025208, -0.046661, 0.052612, -0.050568, 0.051910, -0.062958, 0.080688, -0.093384, 0.088409, -0.060364, 0.016998, 0.023804, -0.041779, 0.025696, 0.019989, }; static const float *ir_filters_lookup[2] = { ir_filter_strong, ir_filter_medium }; static const float *ir_filters_lookup_MODE_7k95[2] = { ir_filter_strong_MODE_7k95, ir_filter_medium }; // High-pass coefficients static const float highpass_zeros[2] = { -2.0, 1.0 }; static const float highpass_poles[2] = { -1.933105469, 0.935913085 }; static const float highpass_gain = 0.939819335; #endif /* AVCODEC_AMRNBDATA_H */
123linslouis-android-video-cutter
jni/libavcodec/amrnbdata.h
C
asf20
104,668
/* * AAC Spectral Band Replication decoding functions * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl ) * Copyright (c) 2009-2010 Alex Converse <alex.converse@gmail.com> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * AAC Spectral Band Replication decoding functions * @author Robert Swain ( rob opendot cl ) */ #include "aac.h" #include "sbr.h" #include "aacsbr.h" #include "aacsbrdata.h" #include "fft.h" #include "aacps.h" #include <stdint.h> #include <float.h> #define ENVELOPE_ADJUSTMENT_OFFSET 2 #define NOISE_FLOOR_OFFSET 6.0f /** * SBR VLC tables */ enum { T_HUFFMAN_ENV_1_5DB, F_HUFFMAN_ENV_1_5DB, T_HUFFMAN_ENV_BAL_1_5DB, F_HUFFMAN_ENV_BAL_1_5DB, T_HUFFMAN_ENV_3_0DB, F_HUFFMAN_ENV_3_0DB, T_HUFFMAN_ENV_BAL_3_0DB, F_HUFFMAN_ENV_BAL_3_0DB, T_HUFFMAN_NOISE_3_0DB, T_HUFFMAN_NOISE_BAL_3_0DB, }; /** * bs_frame_class - frame class of current SBR frame (14496-3 sp04 p98) */ enum { FIXFIX, FIXVAR, VARFIX, VARVAR, }; enum { EXTENSION_ID_PS = 2, }; static VLC vlc_sbr[10]; static const int8_t vlc_sbr_lav[10] = { 60, 60, 24, 24, 31, 31, 12, 12, 31, 12 }; static const DECLARE_ALIGNED(16, float, zero64)[64]; #define SBR_INIT_VLC_STATIC(num, size) \ INIT_VLC_STATIC(&vlc_sbr[num], 9, sbr_tmp[num].table_size / sbr_tmp[num].elem_size, \ sbr_tmp[num].sbr_bits , 1, 1, \ sbr_tmp[num].sbr_codes, sbr_tmp[num].elem_size, sbr_tmp[num].elem_size, \ size) #define SBR_VLC_ROW(name) \ { name ## _codes, name ## _bits, sizeof(name ## _codes), sizeof(name ## _codes[0]) } av_cold void ff_aac_sbr_init(void) { int n; static const struct { const void *sbr_codes, *sbr_bits; const unsigned int table_size, elem_size; } sbr_tmp[] = { SBR_VLC_ROW(t_huffman_env_1_5dB), SBR_VLC_ROW(f_huffman_env_1_5dB), SBR_VLC_ROW(t_huffman_env_bal_1_5dB), SBR_VLC_ROW(f_huffman_env_bal_1_5dB), SBR_VLC_ROW(t_huffman_env_3_0dB), SBR_VLC_ROW(f_huffman_env_3_0dB), SBR_VLC_ROW(t_huffman_env_bal_3_0dB), SBR_VLC_ROW(f_huffman_env_bal_3_0dB), SBR_VLC_ROW(t_huffman_noise_3_0dB), SBR_VLC_ROW(t_huffman_noise_bal_3_0dB), }; // SBR VLC table initialization SBR_INIT_VLC_STATIC(0, 1098); SBR_INIT_VLC_STATIC(1, 1092); SBR_INIT_VLC_STATIC(2, 768); SBR_INIT_VLC_STATIC(3, 1026); SBR_INIT_VLC_STATIC(4, 1058); SBR_INIT_VLC_STATIC(5, 1052); SBR_INIT_VLC_STATIC(6, 544); SBR_INIT_VLC_STATIC(7, 544); SBR_INIT_VLC_STATIC(8, 592); SBR_INIT_VLC_STATIC(9, 512); for (n = 1; n < 320; n++) sbr_qmf_window_us[320 + n] = sbr_qmf_window_us[320 - n]; sbr_qmf_window_us[384] = -sbr_qmf_window_us[384]; sbr_qmf_window_us[512] = -sbr_qmf_window_us[512]; for (n = 0; n < 320; n++) sbr_qmf_window_ds[n] = sbr_qmf_window_us[2*n]; ff_ps_init(); } av_cold void ff_aac_sbr_ctx_init(SpectralBandReplication *sbr) { sbr->kx[0] = sbr->kx[1] = 32; //Typo in spec, kx' inits to 32 sbr->data[0].e_a[1] = sbr->data[1].e_a[1] = -1; sbr->data[0].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE - (1280 - 128); sbr->data[1].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE - (1280 - 128); ff_mdct_init(&sbr->mdct, 7, 1, 1.0/64); ff_mdct_init(&sbr->mdct_ana, 7, 1, -2.0); ff_ps_ctx_init(&sbr->ps); } av_cold void ff_aac_sbr_ctx_close(SpectralBandReplication *sbr) { ff_mdct_end(&sbr->mdct); ff_mdct_end(&sbr->mdct_ana); } static int qsort_comparison_function_int16(const void *a, const void *b) { return *(const int16_t *)a - *(const int16_t *)b; } static inline int in_table_int16(const int16_t *table, int last_el, int16_t needle) { int i; for (i = 0; i <= last_el; i++) if (table[i] == needle) return 1; return 0; } /// Limiter Frequency Band Table (14496-3 sp04 p198) static void sbr_make_f_tablelim(SpectralBandReplication *sbr) { int k; if (sbr->bs_limiter_bands > 0) { static const float bands_warped[3] = { 1.32715174233856803909f, //2^(0.49/1.2) 1.18509277094158210129f, //2^(0.49/2) 1.11987160404675912501f }; //2^(0.49/3) const float lim_bands_per_octave_warped = bands_warped[sbr->bs_limiter_bands - 1]; int16_t patch_borders[7]; uint16_t *in = sbr->f_tablelim + 1, *out = sbr->f_tablelim; patch_borders[0] = sbr->kx[1]; for (k = 1; k <= sbr->num_patches; k++) patch_borders[k] = patch_borders[k-1] + sbr->patch_num_subbands[k-1]; memcpy(sbr->f_tablelim, sbr->f_tablelow, (sbr->n[0] + 1) * sizeof(sbr->f_tablelow[0])); if (sbr->num_patches > 1) memcpy(sbr->f_tablelim + sbr->n[0] + 1, patch_borders + 1, (sbr->num_patches - 1) * sizeof(patch_borders[0])); qsort(sbr->f_tablelim, sbr->num_patches + sbr->n[0], sizeof(sbr->f_tablelim[0]), qsort_comparison_function_int16); sbr->n_lim = sbr->n[0] + sbr->num_patches - 1; while (out < sbr->f_tablelim + sbr->n_lim) { if (*in >= *out * lim_bands_per_octave_warped) { *++out = *in++; } else if (*in == *out || !in_table_int16(patch_borders, sbr->num_patches, *in)) { in++; sbr->n_lim--; } else if (!in_table_int16(patch_borders, sbr->num_patches, *out)) { *out = *in++; sbr->n_lim--; } else { *++out = *in++; } } } else { sbr->f_tablelim[0] = sbr->f_tablelow[0]; sbr->f_tablelim[1] = sbr->f_tablelow[sbr->n[0]]; sbr->n_lim = 1; } } static unsigned int read_sbr_header(SpectralBandReplication *sbr, GetBitContext *gb) { unsigned int cnt = get_bits_count(gb); uint8_t bs_header_extra_1; uint8_t bs_header_extra_2; int old_bs_limiter_bands = sbr->bs_limiter_bands; SpectrumParameters old_spectrum_params; sbr->start = 1; // Save last spectrum parameters variables to compare to new ones memcpy(&old_spectrum_params, &sbr->spectrum_params, sizeof(SpectrumParameters)); sbr->bs_amp_res_header = get_bits1(gb); sbr->spectrum_params.bs_start_freq = get_bits(gb, 4); sbr->spectrum_params.bs_stop_freq = get_bits(gb, 4); sbr->spectrum_params.bs_xover_band = get_bits(gb, 3); skip_bits(gb, 2); // bs_reserved bs_header_extra_1 = get_bits1(gb); bs_header_extra_2 = get_bits1(gb); if (bs_header_extra_1) { sbr->spectrum_params.bs_freq_scale = get_bits(gb, 2); sbr->spectrum_params.bs_alter_scale = get_bits1(gb); sbr->spectrum_params.bs_noise_bands = get_bits(gb, 2); } else { sbr->spectrum_params.bs_freq_scale = 2; sbr->spectrum_params.bs_alter_scale = 1; sbr->spectrum_params.bs_noise_bands = 2; } // Check if spectrum parameters changed if (memcmp(&old_spectrum_params, &sbr->spectrum_params, sizeof(SpectrumParameters))) sbr->reset = 1; if (bs_header_extra_2) { sbr->bs_limiter_bands = get_bits(gb, 2); sbr->bs_limiter_gains = get_bits(gb, 2); sbr->bs_interpol_freq = get_bits1(gb); sbr->bs_smoothing_mode = get_bits1(gb); } else { sbr->bs_limiter_bands = 2; sbr->bs_limiter_gains = 2; sbr->bs_interpol_freq = 1; sbr->bs_smoothing_mode = 1; } if (sbr->bs_limiter_bands != old_bs_limiter_bands && !sbr->reset) sbr_make_f_tablelim(sbr); return get_bits_count(gb) - cnt; } static int array_min_int16(const int16_t *array, int nel) { int i, min = array[0]; for (i = 1; i < nel; i++) min = FFMIN(array[i], min); return min; } static void make_bands(int16_t* bands, int start, int stop, int num_bands) { int k, previous, present; float base, prod; base = powf((float)stop / start, 1.0f / num_bands); prod = start; previous = start; for (k = 0; k < num_bands-1; k++) { prod *= base; present = lrintf(prod); bands[k] = present - previous; previous = present; } bands[num_bands-1] = stop - previous; } static int check_n_master(AVCodecContext *avctx, int n_master, int bs_xover_band) { // Requirements (14496-3 sp04 p205) if (n_master <= 0) { av_log(avctx, AV_LOG_ERROR, "Invalid n_master: %d\n", n_master); return -1; } if (bs_xover_band >= n_master) { av_log(avctx, AV_LOG_ERROR, "Invalid bitstream, crossover band index beyond array bounds: %d\n", bs_xover_band); return -1; } return 0; } /// Master Frequency Band Table (14496-3 sp04 p194) static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, SpectrumParameters *spectrum) { unsigned int temp, max_qmf_subbands; unsigned int start_min, stop_min; int k; const int8_t *sbr_offset_ptr; int16_t stop_dk[13]; if (sbr->sample_rate < 32000) { temp = 3000; } else if (sbr->sample_rate < 64000) { temp = 4000; } else temp = 5000; start_min = ((temp << 7) + (sbr->sample_rate >> 1)) / sbr->sample_rate; stop_min = ((temp << 8) + (sbr->sample_rate >> 1)) / sbr->sample_rate; switch (sbr->sample_rate) { case 16000: sbr_offset_ptr = sbr_offset[0]; break; case 22050: sbr_offset_ptr = sbr_offset[1]; break; case 24000: sbr_offset_ptr = sbr_offset[2]; break; case 32000: sbr_offset_ptr = sbr_offset[3]; break; case 44100: case 48000: case 64000: sbr_offset_ptr = sbr_offset[4]; break; case 88200: case 96000: case 128000: case 176400: case 192000: sbr_offset_ptr = sbr_offset[5]; break; default: av_log(ac->avctx, AV_LOG_ERROR, "Unsupported sample rate for SBR: %d\n", sbr->sample_rate); return -1; } sbr->k[0] = start_min + sbr_offset_ptr[spectrum->bs_start_freq]; if (spectrum->bs_stop_freq < 14) { sbr->k[2] = stop_min; make_bands(stop_dk, stop_min, 64, 13); qsort(stop_dk, 13, sizeof(stop_dk[0]), qsort_comparison_function_int16); for (k = 0; k < spectrum->bs_stop_freq; k++) sbr->k[2] += stop_dk[k]; } else if (spectrum->bs_stop_freq == 14) { sbr->k[2] = 2*sbr->k[0]; } else if (spectrum->bs_stop_freq == 15) { sbr->k[2] = 3*sbr->k[0]; } else { av_log(ac->avctx, AV_LOG_ERROR, "Invalid bs_stop_freq: %d\n", spectrum->bs_stop_freq); return -1; } sbr->k[2] = FFMIN(64, sbr->k[2]); // Requirements (14496-3 sp04 p205) if (sbr->sample_rate <= 32000) { max_qmf_subbands = 48; } else if (sbr->sample_rate == 44100) { max_qmf_subbands = 35; } else if (sbr->sample_rate >= 48000) max_qmf_subbands = 32; if (sbr->k[2] - sbr->k[0] > max_qmf_subbands) { av_log(ac->avctx, AV_LOG_ERROR, "Invalid bitstream, too many QMF subbands: %d\n", sbr->k[2] - sbr->k[0]); return -1; } if (!spectrum->bs_freq_scale) { int dk, k2diff; dk = spectrum->bs_alter_scale + 1; sbr->n_master = ((sbr->k[2] - sbr->k[0] + (dk&2)) >> dk) << 1; if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band)) return -1; for (k = 1; k <= sbr->n_master; k++) sbr->f_master[k] = dk; k2diff = sbr->k[2] - sbr->k[0] - sbr->n_master * dk; if (k2diff < 0) { sbr->f_master[1]--; sbr->f_master[2]-= (k2diff < -1); } else if (k2diff) { sbr->f_master[sbr->n_master]++; } sbr->f_master[0] = sbr->k[0]; for (k = 1; k <= sbr->n_master; k++) sbr->f_master[k] += sbr->f_master[k - 1]; } else { int half_bands = 7 - spectrum->bs_freq_scale; // bs_freq_scale = {1,2,3} int two_regions, num_bands_0; int vdk0_max, vdk1_min; int16_t vk0[49]; if (49 * sbr->k[2] > 110 * sbr->k[0]) { two_regions = 1; sbr->k[1] = 2 * sbr->k[0]; } else { two_regions = 0; sbr->k[1] = sbr->k[2]; } num_bands_0 = lrintf(half_bands * log2f(sbr->k[1] / (float)sbr->k[0])) * 2; if (num_bands_0 <= 0) { // Requirements (14496-3 sp04 p205) av_log(ac->avctx, AV_LOG_ERROR, "Invalid num_bands_0: %d\n", num_bands_0); return -1; } vk0[0] = 0; make_bands(vk0+1, sbr->k[0], sbr->k[1], num_bands_0); qsort(vk0 + 1, num_bands_0, sizeof(vk0[1]), qsort_comparison_function_int16); vdk0_max = vk0[num_bands_0]; vk0[0] = sbr->k[0]; for (k = 1; k <= num_bands_0; k++) { if (vk0[k] <= 0) { // Requirements (14496-3 sp04 p205) av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk0[%d]: %d\n", k, vk0[k]); return -1; } vk0[k] += vk0[k-1]; } if (two_regions) { int16_t vk1[49]; float invwarp = spectrum->bs_alter_scale ? 0.76923076923076923077f : 1.0f; // bs_alter_scale = {0,1} int num_bands_1 = lrintf(half_bands * invwarp * log2f(sbr->k[2] / (float)sbr->k[1])) * 2; make_bands(vk1+1, sbr->k[1], sbr->k[2], num_bands_1); vdk1_min = array_min_int16(vk1 + 1, num_bands_1); if (vdk1_min < vdk0_max) { int change; qsort(vk1 + 1, num_bands_1, sizeof(vk1[1]), qsort_comparison_function_int16); change = FFMIN(vdk0_max - vk1[1], (vk1[num_bands_1] - vk1[1]) >> 1); vk1[1] += change; vk1[num_bands_1] -= change; } qsort(vk1 + 1, num_bands_1, sizeof(vk1[1]), qsort_comparison_function_int16); vk1[0] = sbr->k[1]; for (k = 1; k <= num_bands_1; k++) { if (vk1[k] <= 0) { // Requirements (14496-3 sp04 p205) av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk1[%d]: %d\n", k, vk1[k]); return -1; } vk1[k] += vk1[k-1]; } sbr->n_master = num_bands_0 + num_bands_1; if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band)) return -1; memcpy(&sbr->f_master[0], vk0, (num_bands_0 + 1) * sizeof(sbr->f_master[0])); memcpy(&sbr->f_master[num_bands_0 + 1], vk1 + 1, num_bands_1 * sizeof(sbr->f_master[0])); } else { sbr->n_master = num_bands_0; if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band)) return -1; memcpy(sbr->f_master, vk0, (num_bands_0 + 1) * sizeof(sbr->f_master[0])); } } return 0; } /// High Frequency Generation - Patch Construction (14496-3 sp04 p216 fig. 4.46) static int sbr_hf_calc_npatches(AACContext *ac, SpectralBandReplication *sbr) { int i, k, sb = 0; int msb = sbr->k[0]; int usb = sbr->kx[1]; int goal_sb = ((1000 << 11) + (sbr->sample_rate >> 1)) / sbr->sample_rate; sbr->num_patches = 0; if (goal_sb < sbr->kx[1] + sbr->m[1]) { for (k = 0; sbr->f_master[k] < goal_sb; k++) ; } else k = sbr->n_master; do { int odd = 0; for (i = k; i == k || sb > (sbr->k[0] - 1 + msb - odd); i--) { sb = sbr->f_master[i]; odd = (sb + sbr->k[0]) & 1; } // Requirements (14496-3 sp04 p205) sets the maximum number of patches to 5. // After this check the final number of patches can still be six which is // illegal however the Coding Technologies decoder check stream has a final // count of 6 patches if (sbr->num_patches > 5) { av_log(ac->avctx, AV_LOG_ERROR, "Too many patches: %d\n", sbr->num_patches); return -1; } sbr->patch_num_subbands[sbr->num_patches] = FFMAX(sb - usb, 0); sbr->patch_start_subband[sbr->num_patches] = sbr->k[0] - odd - sbr->patch_num_subbands[sbr->num_patches]; if (sbr->patch_num_subbands[sbr->num_patches] > 0) { usb = sb; msb = sb; sbr->num_patches++; } else msb = sbr->kx[1]; if (sbr->f_master[k] - sb < 3) k = sbr->n_master; } while (sb != sbr->kx[1] + sbr->m[1]); if (sbr->patch_num_subbands[sbr->num_patches-1] < 3 && sbr->num_patches > 1) sbr->num_patches--; return 0; } /// Derived Frequency Band Tables (14496-3 sp04 p197) static int sbr_make_f_derived(AACContext *ac, SpectralBandReplication *sbr) { int k, temp; sbr->n[1] = sbr->n_master - sbr->spectrum_params.bs_xover_band; sbr->n[0] = (sbr->n[1] + 1) >> 1; memcpy(sbr->f_tablehigh, &sbr->f_master[sbr->spectrum_params.bs_xover_band], (sbr->n[1] + 1) * sizeof(sbr->f_master[0])); sbr->m[1] = sbr->f_tablehigh[sbr->n[1]] - sbr->f_tablehigh[0]; sbr->kx[1] = sbr->f_tablehigh[0]; // Requirements (14496-3 sp04 p205) if (sbr->kx[1] + sbr->m[1] > 64) { av_log(ac->avctx, AV_LOG_ERROR, "Stop frequency border too high: %d\n", sbr->kx[1] + sbr->m[1]); return -1; } if (sbr->kx[1] > 32) { av_log(ac->avctx, AV_LOG_ERROR, "Start frequency border too high: %d\n", sbr->kx[1]); return -1; } sbr->f_tablelow[0] = sbr->f_tablehigh[0]; temp = sbr->n[1] & 1; for (k = 1; k <= sbr->n[0]; k++) sbr->f_tablelow[k] = sbr->f_tablehigh[2 * k - temp]; sbr->n_q = FFMAX(1, lrintf(sbr->spectrum_params.bs_noise_bands * log2f(sbr->k[2] / (float)sbr->kx[1]))); // 0 <= bs_noise_bands <= 3 if (sbr->n_q > 5) { av_log(ac->avctx, AV_LOG_ERROR, "Too many noise floor scale factors: %d\n", sbr->n_q); return -1; } sbr->f_tablenoise[0] = sbr->f_tablelow[0]; temp = 0; for (k = 1; k <= sbr->n_q; k++) { temp += (sbr->n[0] - temp) / (sbr->n_q + 1 - k); sbr->f_tablenoise[k] = sbr->f_tablelow[temp]; } if (sbr_hf_calc_npatches(ac, sbr) < 0) return -1; sbr_make_f_tablelim(sbr); sbr->data[0].f_indexnoise = 0; sbr->data[1].f_indexnoise = 0; return 0; } static av_always_inline void get_bits1_vector(GetBitContext *gb, uint8_t *vec, int elements) { int i; for (i = 0; i < elements; i++) { vec[i] = get_bits1(gb); } } /** ceil(log2(index+1)) */ static const int8_t ceil_log2[] = { 0, 1, 2, 2, 3, 3, }; static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, SBRData *ch_data) { int i; unsigned bs_pointer = 0; // frameLengthFlag ? 15 : 16; 960 sample length frames unsupported; this value is numTimeSlots int abs_bord_trail = 16; int num_rel_lead, num_rel_trail; unsigned bs_num_env_old = ch_data->bs_num_env; ch_data->bs_freq_res[0] = ch_data->bs_freq_res[ch_data->bs_num_env]; ch_data->bs_amp_res = sbr->bs_amp_res_header; ch_data->t_env_num_env_old = ch_data->t_env[bs_num_env_old]; switch (ch_data->bs_frame_class = get_bits(gb, 2)) { case FIXFIX: ch_data->bs_num_env = 1 << get_bits(gb, 2); num_rel_lead = ch_data->bs_num_env - 1; if (ch_data->bs_num_env == 1) ch_data->bs_amp_res = 0; if (ch_data->bs_num_env > 4) { av_log(ac->avctx, AV_LOG_ERROR, "Invalid bitstream, too many SBR envelopes in FIXFIX type SBR frame: %d\n", ch_data->bs_num_env); return -1; } ch_data->t_env[0] = 0; ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail; abs_bord_trail = (abs_bord_trail + (ch_data->bs_num_env >> 1)) / ch_data->bs_num_env; for (i = 0; i < num_rel_lead; i++) ch_data->t_env[i + 1] = ch_data->t_env[i] + abs_bord_trail; ch_data->bs_freq_res[1] = get_bits1(gb); for (i = 1; i < ch_data->bs_num_env; i++) ch_data->bs_freq_res[i + 1] = ch_data->bs_freq_res[1]; break; case FIXVAR: abs_bord_trail += get_bits(gb, 2); num_rel_trail = get_bits(gb, 2); ch_data->bs_num_env = num_rel_trail + 1; ch_data->t_env[0] = 0; ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail; for (i = 0; i < num_rel_trail; i++) ch_data->t_env[ch_data->bs_num_env - 1 - i] = ch_data->t_env[ch_data->bs_num_env - i] - 2 * get_bits(gb, 2) - 2; bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env]); for (i = 0; i < ch_data->bs_num_env; i++) ch_data->bs_freq_res[ch_data->bs_num_env - i] = get_bits1(gb); break; case VARFIX: ch_data->t_env[0] = get_bits(gb, 2); num_rel_lead = get_bits(gb, 2); ch_data->bs_num_env = num_rel_lead + 1; ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail; for (i = 0; i < num_rel_lead; i++) ch_data->t_env[i + 1] = ch_data->t_env[i] + 2 * get_bits(gb, 2) + 2; bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env]); get_bits1_vector(gb, ch_data->bs_freq_res + 1, ch_data->bs_num_env); break; case VARVAR: ch_data->t_env[0] = get_bits(gb, 2); abs_bord_trail += get_bits(gb, 2); num_rel_lead = get_bits(gb, 2); num_rel_trail = get_bits(gb, 2); ch_data->bs_num_env = num_rel_lead + num_rel_trail + 1; if (ch_data->bs_num_env > 5) { av_log(ac->avctx, AV_LOG_ERROR, "Invalid bitstream, too many SBR envelopes in VARVAR type SBR frame: %d\n", ch_data->bs_num_env); return -1; } ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail; for (i = 0; i < num_rel_lead; i++) ch_data->t_env[i + 1] = ch_data->t_env[i] + 2 * get_bits(gb, 2) + 2; for (i = 0; i < num_rel_trail; i++) ch_data->t_env[ch_data->bs_num_env - 1 - i] = ch_data->t_env[ch_data->bs_num_env - i] - 2 * get_bits(gb, 2) - 2; bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env]); get_bits1_vector(gb, ch_data->bs_freq_res + 1, ch_data->bs_num_env); break; } if (bs_pointer > ch_data->bs_num_env + 1) { av_log(ac->avctx, AV_LOG_ERROR, "Invalid bitstream, bs_pointer points to a middle noise border outside the time borders table: %d\n", bs_pointer); return -1; } for (i = 1; i <= ch_data->bs_num_env; i++) { if (ch_data->t_env[i-1] > ch_data->t_env[i]) { av_log(ac->avctx, AV_LOG_ERROR, "Non monotone time borders\n"); return -1; } } ch_data->bs_num_noise = (ch_data->bs_num_env > 1) + 1; ch_data->t_q[0] = ch_data->t_env[0]; ch_data->t_q[ch_data->bs_num_noise] = ch_data->t_env[ch_data->bs_num_env]; if (ch_data->bs_num_noise > 1) { unsigned int idx; if (ch_data->bs_frame_class == FIXFIX) { idx = ch_data->bs_num_env >> 1; } else if (ch_data->bs_frame_class & 1) { // FIXVAR or VARVAR idx = ch_data->bs_num_env - FFMAX(bs_pointer - 1, 1); } else { // VARFIX if (!bs_pointer) idx = 1; else if (bs_pointer == 1) idx = ch_data->bs_num_env - 1; else // bs_pointer > 1 idx = bs_pointer - 1; } ch_data->t_q[1] = ch_data->t_env[idx]; } ch_data->e_a[0] = -(ch_data->e_a[1] != bs_num_env_old); // l_APrev ch_data->e_a[1] = -1; if ((ch_data->bs_frame_class & 1) && bs_pointer) { // FIXVAR or VARVAR and bs_pointer != 0 ch_data->e_a[1] = ch_data->bs_num_env + 1 - bs_pointer; } else if ((ch_data->bs_frame_class == 2) && (bs_pointer > 1)) // VARFIX and bs_pointer > 1 ch_data->e_a[1] = bs_pointer - 1; return 0; } static void copy_sbr_grid(SBRData *dst, const SBRData *src) { //These variables are saved from the previous frame rather than copied dst->bs_freq_res[0] = dst->bs_freq_res[dst->bs_num_env]; dst->t_env_num_env_old = dst->t_env[dst->bs_num_env]; dst->e_a[0] = -(dst->e_a[1] != dst->bs_num_env); //These variables are read from the bitstream and therefore copied memcpy(dst->bs_freq_res+1, src->bs_freq_res+1, sizeof(dst->bs_freq_res)-sizeof(*dst->bs_freq_res)); memcpy(dst->t_env, src->t_env, sizeof(dst->t_env)); memcpy(dst->t_q, src->t_q, sizeof(dst->t_q)); dst->bs_num_env = src->bs_num_env; dst->bs_amp_res = src->bs_amp_res; dst->bs_num_noise = src->bs_num_noise; dst->bs_frame_class = src->bs_frame_class; dst->e_a[1] = src->e_a[1]; } /// Read how the envelope and noise floor data is delta coded static void read_sbr_dtdf(SpectralBandReplication *sbr, GetBitContext *gb, SBRData *ch_data) { get_bits1_vector(gb, ch_data->bs_df_env, ch_data->bs_num_env); get_bits1_vector(gb, ch_data->bs_df_noise, ch_data->bs_num_noise); } /// Read inverse filtering data static void read_sbr_invf(SpectralBandReplication *sbr, GetBitContext *gb, SBRData *ch_data) { int i; memcpy(ch_data->bs_invf_mode[1], ch_data->bs_invf_mode[0], 5 * sizeof(uint8_t)); for (i = 0; i < sbr->n_q; i++) ch_data->bs_invf_mode[0][i] = get_bits(gb, 2); } static void read_sbr_envelope(SpectralBandReplication *sbr, GetBitContext *gb, SBRData *ch_data, int ch) { int bits; int i, j, k; VLC_TYPE (*t_huff)[2], (*f_huff)[2]; int t_lav, f_lav; const int delta = (ch == 1 && sbr->bs_coupling == 1) + 1; const int odd = sbr->n[1] & 1; if (sbr->bs_coupling && ch) { if (ch_data->bs_amp_res) { bits = 5; t_huff = vlc_sbr[T_HUFFMAN_ENV_BAL_3_0DB].table; t_lav = vlc_sbr_lav[T_HUFFMAN_ENV_BAL_3_0DB]; f_huff = vlc_sbr[F_HUFFMAN_ENV_BAL_3_0DB].table; f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_BAL_3_0DB]; } else { bits = 6; t_huff = vlc_sbr[T_HUFFMAN_ENV_BAL_1_5DB].table; t_lav = vlc_sbr_lav[T_HUFFMAN_ENV_BAL_1_5DB]; f_huff = vlc_sbr[F_HUFFMAN_ENV_BAL_1_5DB].table; f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_BAL_1_5DB]; } } else { if (ch_data->bs_amp_res) { bits = 6; t_huff = vlc_sbr[T_HUFFMAN_ENV_3_0DB].table; t_lav = vlc_sbr_lav[T_HUFFMAN_ENV_3_0DB]; f_huff = vlc_sbr[F_HUFFMAN_ENV_3_0DB].table; f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_3_0DB]; } else { bits = 7; t_huff = vlc_sbr[T_HUFFMAN_ENV_1_5DB].table; t_lav = vlc_sbr_lav[T_HUFFMAN_ENV_1_5DB]; f_huff = vlc_sbr[F_HUFFMAN_ENV_1_5DB].table; f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_1_5DB]; } } for (i = 0; i < ch_data->bs_num_env; i++) { if (ch_data->bs_df_env[i]) { // bs_freq_res[0] == bs_freq_res[bs_num_env] from prev frame if (ch_data->bs_freq_res[i + 1] == ch_data->bs_freq_res[i]) { for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) ch_data->env_facs[i + 1][j] = ch_data->env_facs[i][j] + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav); } else if (ch_data->bs_freq_res[i + 1]) { for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) { k = (j + odd) >> 1; // find k such that f_tablelow[k] <= f_tablehigh[j] < f_tablelow[k + 1] ch_data->env_facs[i + 1][j] = ch_data->env_facs[i][k] + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav); } } else { for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) { k = j ? 2*j - odd : 0; // find k such that f_tablehigh[k] == f_tablelow[j] ch_data->env_facs[i + 1][j] = ch_data->env_facs[i][k] + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav); } } } else { ch_data->env_facs[i + 1][0] = delta * get_bits(gb, bits); // bs_env_start_value_balance for (j = 1; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) ch_data->env_facs[i + 1][j] = ch_data->env_facs[i + 1][j - 1] + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav); } } //assign 0th elements of env_facs from last elements memcpy(ch_data->env_facs[0], ch_data->env_facs[ch_data->bs_num_env], sizeof(ch_data->env_facs[0])); } static void read_sbr_noise(SpectralBandReplication *sbr, GetBitContext *gb, SBRData *ch_data, int ch) { int i, j; VLC_TYPE (*t_huff)[2], (*f_huff)[2]; int t_lav, f_lav; int delta = (ch == 1 && sbr->bs_coupling == 1) + 1; if (sbr->bs_coupling && ch) { t_huff = vlc_sbr[T_HUFFMAN_NOISE_BAL_3_0DB].table; t_lav = vlc_sbr_lav[T_HUFFMAN_NOISE_BAL_3_0DB]; f_huff = vlc_sbr[F_HUFFMAN_ENV_BAL_3_0DB].table; f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_BAL_3_0DB]; } else { t_huff = vlc_sbr[T_HUFFMAN_NOISE_3_0DB].table; t_lav = vlc_sbr_lav[T_HUFFMAN_NOISE_3_0DB]; f_huff = vlc_sbr[F_HUFFMAN_ENV_3_0DB].table; f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_3_0DB]; } for (i = 0; i < ch_data->bs_num_noise; i++) { if (ch_data->bs_df_noise[i]) { for (j = 0; j < sbr->n_q; j++) ch_data->noise_facs[i + 1][j] = ch_data->noise_facs[i][j] + delta * (get_vlc2(gb, t_huff, 9, 2) - t_lav); } else { ch_data->noise_facs[i + 1][0] = delta * get_bits(gb, 5); // bs_noise_start_value_balance or bs_noise_start_value_level for (j = 1; j < sbr->n_q; j++) ch_data->noise_facs[i + 1][j] = ch_data->noise_facs[i + 1][j - 1] + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav); } } //assign 0th elements of noise_facs from last elements memcpy(ch_data->noise_facs[0], ch_data->noise_facs[ch_data->bs_num_noise], sizeof(ch_data->noise_facs[0])); } static void read_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, int bs_extension_id, int *num_bits_left) { switch (bs_extension_id) { case EXTENSION_ID_PS: if (!ac->m4ac.ps) { av_log(ac->avctx, AV_LOG_ERROR, "Parametric Stereo signaled to be not-present but was found in the bitstream.\n"); skip_bits_long(gb, *num_bits_left); // bs_fill_bits *num_bits_left = 0; } else { #if 1 *num_bits_left -= ff_ps_read_data(ac->avctx, gb, &sbr->ps, *num_bits_left); #else av_log_missing_feature(ac->avctx, "Parametric Stereo is", 0); skip_bits_long(gb, *num_bits_left); // bs_fill_bits *num_bits_left = 0; #endif } break; default: av_log_missing_feature(ac->avctx, "Reserved SBR extensions are", 1); skip_bits_long(gb, *num_bits_left); // bs_fill_bits *num_bits_left = 0; break; } } static int read_sbr_single_channel_element(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb) { if (get_bits1(gb)) // bs_data_extra skip_bits(gb, 4); // bs_reserved if (read_sbr_grid(ac, sbr, gb, &sbr->data[0])) return -1; read_sbr_dtdf(sbr, gb, &sbr->data[0]); read_sbr_invf(sbr, gb, &sbr->data[0]); read_sbr_envelope(sbr, gb, &sbr->data[0], 0); read_sbr_noise(sbr, gb, &sbr->data[0], 0); if ((sbr->data[0].bs_add_harmonic_flag = get_bits1(gb))) get_bits1_vector(gb, sbr->data[0].bs_add_harmonic, sbr->n[1]); return 0; } static int read_sbr_channel_pair_element(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb) { if (get_bits1(gb)) // bs_data_extra skip_bits(gb, 8); // bs_reserved if ((sbr->bs_coupling = get_bits1(gb))) { if (read_sbr_grid(ac, sbr, gb, &sbr->data[0])) return -1; copy_sbr_grid(&sbr->data[1], &sbr->data[0]); read_sbr_dtdf(sbr, gb, &sbr->data[0]); read_sbr_dtdf(sbr, gb, &sbr->data[1]); read_sbr_invf(sbr, gb, &sbr->data[0]); memcpy(sbr->data[1].bs_invf_mode[1], sbr->data[1].bs_invf_mode[0], sizeof(sbr->data[1].bs_invf_mode[0])); memcpy(sbr->data[1].bs_invf_mode[0], sbr->data[0].bs_invf_mode[0], sizeof(sbr->data[1].bs_invf_mode[0])); read_sbr_envelope(sbr, gb, &sbr->data[0], 0); read_sbr_noise(sbr, gb, &sbr->data[0], 0); read_sbr_envelope(sbr, gb, &sbr->data[1], 1); read_sbr_noise(sbr, gb, &sbr->data[1], 1); } else { if (read_sbr_grid(ac, sbr, gb, &sbr->data[0]) || read_sbr_grid(ac, sbr, gb, &sbr->data[1])) return -1; read_sbr_dtdf(sbr, gb, &sbr->data[0]); read_sbr_dtdf(sbr, gb, &sbr->data[1]); read_sbr_invf(sbr, gb, &sbr->data[0]); read_sbr_invf(sbr, gb, &sbr->data[1]); read_sbr_envelope(sbr, gb, &sbr->data[0], 0); read_sbr_envelope(sbr, gb, &sbr->data[1], 1); read_sbr_noise(sbr, gb, &sbr->data[0], 0); read_sbr_noise(sbr, gb, &sbr->data[1], 1); } if ((sbr->data[0].bs_add_harmonic_flag = get_bits1(gb))) get_bits1_vector(gb, sbr->data[0].bs_add_harmonic, sbr->n[1]); if ((sbr->data[1].bs_add_harmonic_flag = get_bits1(gb))) get_bits1_vector(gb, sbr->data[1].bs_add_harmonic, sbr->n[1]); return 0; } static unsigned int read_sbr_data(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, int id_aac) { unsigned int cnt = get_bits_count(gb); if (id_aac == TYPE_SCE || id_aac == TYPE_CCE) { if (read_sbr_single_channel_element(ac, sbr, gb)) { sbr->start = 0; return get_bits_count(gb) - cnt; } } else if (id_aac == TYPE_CPE) { if (read_sbr_channel_pair_element(ac, sbr, gb)) { sbr->start = 0; return get_bits_count(gb) - cnt; } } else { av_log(ac->avctx, AV_LOG_ERROR, "Invalid bitstream - cannot apply SBR to element type %d\n", id_aac); sbr->start = 0; return get_bits_count(gb) - cnt; } if (get_bits1(gb)) { // bs_extended_data int num_bits_left = get_bits(gb, 4); // bs_extension_size if (num_bits_left == 15) num_bits_left += get_bits(gb, 8); // bs_esc_count num_bits_left <<= 3; while (num_bits_left > 7) { num_bits_left -= 2; read_sbr_extension(ac, sbr, gb, get_bits(gb, 2), &num_bits_left); // bs_extension_id } if (num_bits_left < 0) { av_log(ac->avctx, AV_LOG_ERROR, "SBR Extension over read.\n"); } if (num_bits_left > 0) skip_bits(gb, num_bits_left); } return get_bits_count(gb) - cnt; } static void sbr_reset(AACContext *ac, SpectralBandReplication *sbr) { int err; err = sbr_make_f_master(ac, sbr, &sbr->spectrum_params); if (err >= 0) err = sbr_make_f_derived(ac, sbr); if (err < 0) { av_log(ac->avctx, AV_LOG_ERROR, "SBR reset failed. Switching SBR to pure upsampling mode.\n"); sbr->start = 0; } } /** * Decode Spectral Band Replication extension data; reference: table 4.55. * * @param crc flag indicating the presence of CRC checksum * @param cnt length of TYPE_FIL syntactic element in bytes * * @return Returns number of bytes consumed from the TYPE_FIL element. */ int ff_decode_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb_host, int crc, int cnt, int id_aac) { unsigned int num_sbr_bits = 0, num_align_bits; unsigned bytes_read; GetBitContext gbc = *gb_host, *gb = &gbc; skip_bits_long(gb_host, cnt*8 - 4); sbr->reset = 0; if (!sbr->sample_rate) sbr->sample_rate = 2 * ac->m4ac.sample_rate; //TODO use the nominal sample rate for arbitrary sample rate support if (!ac->m4ac.ext_sample_rate) ac->m4ac.ext_sample_rate = 2 * ac->m4ac.sample_rate; if (crc) { skip_bits(gb, 10); // bs_sbr_crc_bits; TODO - implement CRC check num_sbr_bits += 10; } //Save some state from the previous frame. sbr->kx[0] = sbr->kx[1]; sbr->m[0] = sbr->m[1]; num_sbr_bits++; if (get_bits1(gb)) // bs_header_flag num_sbr_bits += read_sbr_header(sbr, gb); if (sbr->reset) sbr_reset(ac, sbr); if (sbr->start) num_sbr_bits += read_sbr_data(ac, sbr, gb, id_aac); num_align_bits = ((cnt << 3) - 4 - num_sbr_bits) & 7; bytes_read = ((num_sbr_bits + num_align_bits + 4) >> 3); if (bytes_read > cnt) { av_log(ac->avctx, AV_LOG_ERROR, "Expected to read %d SBR bytes actually read %d.\n", cnt, bytes_read); } return cnt; } /// Dequantization and stereo decoding (14496-3 sp04 p203) static void sbr_dequant(SpectralBandReplication *sbr, int id_aac) { int k, e; int ch; if (id_aac == TYPE_CPE && sbr->bs_coupling) { float alpha = sbr->data[0].bs_amp_res ? 1.0f : 0.5f; float pan_offset = sbr->data[0].bs_amp_res ? 12.0f : 24.0f; for (e = 1; e <= sbr->data[0].bs_num_env; e++) { for (k = 0; k < sbr->n[sbr->data[0].bs_freq_res[e]]; k++) { float temp1 = exp2f(sbr->data[0].env_facs[e][k] * alpha + 7.0f); float temp2 = exp2f((pan_offset - sbr->data[1].env_facs[e][k]) * alpha); float fac = temp1 / (1.0f + temp2); sbr->data[0].env_facs[e][k] = fac; sbr->data[1].env_facs[e][k] = fac * temp2; } } for (e = 1; e <= sbr->data[0].bs_num_noise; e++) { for (k = 0; k < sbr->n_q; k++) { float temp1 = exp2f(NOISE_FLOOR_OFFSET - sbr->data[0].noise_facs[e][k] + 1); float temp2 = exp2f(12 - sbr->data[1].noise_facs[e][k]); float fac = temp1 / (1.0f + temp2); sbr->data[0].noise_facs[e][k] = fac; sbr->data[1].noise_facs[e][k] = fac * temp2; } } } else { // SCE or one non-coupled CPE for (ch = 0; ch < (id_aac == TYPE_CPE) + 1; ch++) { float alpha = sbr->data[ch].bs_amp_res ? 1.0f : 0.5f; for (e = 1; e <= sbr->data[ch].bs_num_env; e++) for (k = 0; k < sbr->n[sbr->data[ch].bs_freq_res[e]]; k++) sbr->data[ch].env_facs[e][k] = exp2f(alpha * sbr->data[ch].env_facs[e][k] + 6.0f); for (e = 1; e <= sbr->data[ch].bs_num_noise; e++) for (k = 0; k < sbr->n_q; k++) sbr->data[ch].noise_facs[e][k] = exp2f(NOISE_FLOOR_OFFSET - sbr->data[ch].noise_facs[e][k]); } } } /** * Analysis QMF Bank (14496-3 sp04 p206) * * @param x pointer to the beginning of the first sample window * @param W array of complex-valued samples split into subbands */ static void sbr_qmf_analysis(DSPContext *dsp, FFTContext *mdct, const float *in, float *x, float z[320], float W[2][32][32][2], float scale) { int i, k; memcpy(W[0], W[1], sizeof(W[0])); memcpy(x , x+1024, (320-32)*sizeof(x[0])); if (scale != 1.0f) dsp->vector_fmul_scalar(x+288, in, scale, 1024); else memcpy(x+288, in, 1024*sizeof(*x)); for (i = 0; i < 32; i++) { // numTimeSlots*RATE = 16*2 as 960 sample frames // are not supported dsp->vector_fmul_reverse(z, sbr_qmf_window_ds, x, 320); for (k = 0; k < 64; k++) { float f = z[k] + z[k + 64] + z[k + 128] + z[k + 192] + z[k + 256]; z[k] = f; } //Shuffle to IMDCT z[64] = z[0]; for (k = 1; k < 32; k++) { z[64+2*k-1] = z[ k]; z[64+2*k ] = -z[64-k]; } z[64+63] = z[32]; ff_imdct_half(mdct, z, z+64); for (k = 0; k < 32; k++) { W[1][i][k][0] = -z[63-k]; W[1][i][k][1] = z[k]; } x += 32; } } /** * Synthesis QMF Bank (14496-3 sp04 p206) and Downsampled Synthesis QMF Bank * (14496-3 sp04 p206) */ static void sbr_qmf_synthesis(DSPContext *dsp, FFTContext *mdct, float *out, float X[2][38][64], float mdct_buf[2][64], float *v0, int *v_off, const unsigned int div, float bias, float scale) { int i, n; const float *sbr_qmf_window = div ? sbr_qmf_window_ds : sbr_qmf_window_us; int scale_and_bias = scale != 1.0f || bias != 0.0f; float *v; for (i = 0; i < 32; i++) { if (*v_off == 0) { int saved_samples = (1280 - 128) >> div; memcpy(&v0[SBR_SYNTHESIS_BUF_SIZE - saved_samples], v0, saved_samples * sizeof(float)); *v_off = SBR_SYNTHESIS_BUF_SIZE - saved_samples - (128 >> div); } else { *v_off -= 128 >> div; } v = v0 + *v_off; if (div) { for (n = 0; n < 32; n++) { X[0][i][ n] = -X[0][i][n]; X[0][i][32+n] = X[1][i][31-n]; } ff_imdct_half(mdct, mdct_buf[0], X[0][i]); for (n = 0; n < 32; n++) { v[ n] = mdct_buf[0][63 - 2*n]; v[63 - n] = -mdct_buf[0][62 - 2*n]; } } else { for (n = 1; n < 64; n+=2) { X[1][i][n] = -X[1][i][n]; } ff_imdct_half(mdct, mdct_buf[0], X[0][i]); ff_imdct_half(mdct, mdct_buf[1], X[1][i]); for (n = 0; n < 64; n++) { v[ n] = -mdct_buf[0][63 - n] + mdct_buf[1][ n ]; v[127 - n] = mdct_buf[0][63 - n] + mdct_buf[1][ n ]; } } dsp->vector_fmul_add(out, v , sbr_qmf_window , zero64, 64 >> div); dsp->vector_fmul_add(out, v + ( 192 >> div), sbr_qmf_window + ( 64 >> div), out , 64 >> div); dsp->vector_fmul_add(out, v + ( 256 >> div), sbr_qmf_window + (128 >> div), out , 64 >> div); dsp->vector_fmul_add(out, v + ( 448 >> div), sbr_qmf_window + (192 >> div), out , 64 >> div); dsp->vector_fmul_add(out, v + ( 512 >> div), sbr_qmf_window + (256 >> div), out , 64 >> div); dsp->vector_fmul_add(out, v + ( 704 >> div), sbr_qmf_window + (320 >> div), out , 64 >> div); dsp->vector_fmul_add(out, v + ( 768 >> div), sbr_qmf_window + (384 >> div), out , 64 >> div); dsp->vector_fmul_add(out, v + ( 960 >> div), sbr_qmf_window + (448 >> div), out , 64 >> div); dsp->vector_fmul_add(out, v + (1024 >> div), sbr_qmf_window + (512 >> div), out , 64 >> div); dsp->vector_fmul_add(out, v + (1216 >> div), sbr_qmf_window + (576 >> div), out , 64 >> div); if (scale_and_bias) for (n = 0; n < 64 >> div; n++) out[n] = out[n] * scale + bias; out += 64 >> div; } } static void autocorrelate(const float x[40][2], float phi[3][2][2], int lag) { int i; float real_sum = 0.0f; float imag_sum = 0.0f; if (lag) { for (i = 1; i < 38; i++) { real_sum += x[i][0] * x[i+lag][0] + x[i][1] * x[i+lag][1]; imag_sum += x[i][0] * x[i+lag][1] - x[i][1] * x[i+lag][0]; } phi[2-lag][1][0] = real_sum + x[ 0][0] * x[lag][0] + x[ 0][1] * x[lag][1]; phi[2-lag][1][1] = imag_sum + x[ 0][0] * x[lag][1] - x[ 0][1] * x[lag][0]; if (lag == 1) { phi[0][0][0] = real_sum + x[38][0] * x[39][0] + x[38][1] * x[39][1]; phi[0][0][1] = imag_sum + x[38][0] * x[39][1] - x[38][1] * x[39][0]; } } else { for (i = 1; i < 38; i++) { real_sum += x[i][0] * x[i][0] + x[i][1] * x[i][1]; } phi[2][1][0] = real_sum + x[ 0][0] * x[ 0][0] + x[ 0][1] * x[ 0][1]; phi[1][0][0] = real_sum + x[38][0] * x[38][0] + x[38][1] * x[38][1]; } } /** High Frequency Generation (14496-3 sp04 p214+) and Inverse Filtering * (14496-3 sp04 p214) * Warning: This routine does not seem numerically stable. */ static void sbr_hf_inverse_filter(float (*alpha0)[2], float (*alpha1)[2], const float X_low[32][40][2], int k0) { int k; for (k = 0; k < k0; k++) { float phi[3][2][2], dk; autocorrelate(X_low[k], phi, 0); autocorrelate(X_low[k], phi, 1); autocorrelate(X_low[k], phi, 2); dk = phi[2][1][0] * phi[1][0][0] - (phi[1][1][0] * phi[1][1][0] + phi[1][1][1] * phi[1][1][1]) / 1.000001f; if (!dk) { alpha1[k][0] = 0; alpha1[k][1] = 0; } else { float temp_real, temp_im; temp_real = phi[0][0][0] * phi[1][1][0] - phi[0][0][1] * phi[1][1][1] - phi[0][1][0] * phi[1][0][0]; temp_im = phi[0][0][0] * phi[1][1][1] + phi[0][0][1] * phi[1][1][0] - phi[0][1][1] * phi[1][0][0]; alpha1[k][0] = temp_real / dk; alpha1[k][1] = temp_im / dk; } if (!phi[1][0][0]) { alpha0[k][0] = 0; alpha0[k][1] = 0; } else { float temp_real, temp_im; temp_real = phi[0][0][0] + alpha1[k][0] * phi[1][1][0] + alpha1[k][1] * phi[1][1][1]; temp_im = phi[0][0][1] + alpha1[k][1] * phi[1][1][0] - alpha1[k][0] * phi[1][1][1]; alpha0[k][0] = -temp_real / phi[1][0][0]; alpha0[k][1] = -temp_im / phi[1][0][0]; } if (alpha1[k][0] * alpha1[k][0] + alpha1[k][1] * alpha1[k][1] >= 16.0f || alpha0[k][0] * alpha0[k][0] + alpha0[k][1] * alpha0[k][1] >= 16.0f) { alpha1[k][0] = 0; alpha1[k][1] = 0; alpha0[k][0] = 0; alpha0[k][1] = 0; } } } /// Chirp Factors (14496-3 sp04 p214) static void sbr_chirp(SpectralBandReplication *sbr, SBRData *ch_data) { int i; float new_bw; static const float bw_tab[] = { 0.0f, 0.75f, 0.9f, 0.98f }; for (i = 0; i < sbr->n_q; i++) { if (ch_data->bs_invf_mode[0][i] + ch_data->bs_invf_mode[1][i] == 1) { new_bw = 0.6f; } else new_bw = bw_tab[ch_data->bs_invf_mode[0][i]]; if (new_bw < ch_data->bw_array[i]) { new_bw = 0.75f * new_bw + 0.25f * ch_data->bw_array[i]; } else new_bw = 0.90625f * new_bw + 0.09375f * ch_data->bw_array[i]; ch_data->bw_array[i] = new_bw < 0.015625f ? 0.0f : new_bw; } } /// Generate the subband filtered lowband static int sbr_lf_gen(AACContext *ac, SpectralBandReplication *sbr, float X_low[32][40][2], const float W[2][32][32][2]) { int i, k; const int t_HFGen = 8; const int i_f = 32; memset(X_low, 0, 32*sizeof(*X_low)); for (k = 0; k < sbr->kx[1]; k++) { for (i = t_HFGen; i < i_f + t_HFGen; i++) { X_low[k][i][0] = W[1][i - t_HFGen][k][0]; X_low[k][i][1] = W[1][i - t_HFGen][k][1]; } } for (k = 0; k < sbr->kx[0]; k++) { for (i = 0; i < t_HFGen; i++) { X_low[k][i][0] = W[0][i + i_f - t_HFGen][k][0]; X_low[k][i][1] = W[0][i + i_f - t_HFGen][k][1]; } } return 0; } /// High Frequency Generator (14496-3 sp04 p215) static int sbr_hf_gen(AACContext *ac, SpectralBandReplication *sbr, float X_high[64][40][2], const float X_low[32][40][2], const float (*alpha0)[2], const float (*alpha1)[2], const float bw_array[5], const uint8_t *t_env, int bs_num_env) { int i, j, x; int g = 0; int k = sbr->kx[1]; for (j = 0; j < sbr->num_patches; j++) { for (x = 0; x < sbr->patch_num_subbands[j]; x++, k++) { float alpha[4]; const int p = sbr->patch_start_subband[j] + x; while (g <= sbr->n_q && k >= sbr->f_tablenoise[g]) g++; g--; if (g < 0) { av_log(ac->avctx, AV_LOG_ERROR, "ERROR : no subband found for frequency %d\n", k); return -1; } alpha[0] = alpha1[p][0] * bw_array[g] * bw_array[g]; alpha[1] = alpha1[p][1] * bw_array[g] * bw_array[g]; alpha[2] = alpha0[p][0] * bw_array[g]; alpha[3] = alpha0[p][1] * bw_array[g]; for (i = 2 * t_env[0]; i < 2 * t_env[bs_num_env]; i++) { const int idx = i + ENVELOPE_ADJUSTMENT_OFFSET; X_high[k][idx][0] = X_low[p][idx - 2][0] * alpha[0] - X_low[p][idx - 2][1] * alpha[1] + X_low[p][idx - 1][0] * alpha[2] - X_low[p][idx - 1][1] * alpha[3] + X_low[p][idx][0]; X_high[k][idx][1] = X_low[p][idx - 2][1] * alpha[0] + X_low[p][idx - 2][0] * alpha[1] + X_low[p][idx - 1][1] * alpha[2] + X_low[p][idx - 1][0] * alpha[3] + X_low[p][idx][1]; } } } if (k < sbr->m[1] + sbr->kx[1]) memset(X_high + k, 0, (sbr->m[1] + sbr->kx[1] - k) * sizeof(*X_high)); return 0; } /// Generate the subband filtered lowband static int sbr_x_gen(SpectralBandReplication *sbr, float X[2][38][64], const float X_low[32][40][2], const float Y[2][38][64][2], int ch) { int k, i; const int i_f = 32; const int i_Temp = FFMAX(2*sbr->data[ch].t_env_num_env_old - i_f, 0); memset(X, 0, 2*sizeof(*X)); for (k = 0; k < sbr->kx[0]; k++) { for (i = 0; i < i_Temp; i++) { X[0][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][0]; X[1][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][1]; } } for (; k < sbr->kx[0] + sbr->m[0]; k++) { for (i = 0; i < i_Temp; i++) { X[0][i][k] = Y[0][i + i_f][k][0]; X[1][i][k] = Y[0][i + i_f][k][1]; } } for (k = 0; k < sbr->kx[1]; k++) { for (i = i_Temp; i < 38; i++) { X[0][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][0]; X[1][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][1]; } } for (; k < sbr->kx[1] + sbr->m[1]; k++) { for (i = i_Temp; i < i_f; i++) { X[0][i][k] = Y[1][i][k][0]; X[1][i][k] = Y[1][i][k][1]; } } return 0; } /** High Frequency Adjustment (14496-3 sp04 p217) and Mapping * (14496-3 sp04 p217) */ static void sbr_mapping(AACContext *ac, SpectralBandReplication *sbr, SBRData *ch_data, int e_a[2]) { int e, i, m; memset(ch_data->s_indexmapped[1], 0, 7*sizeof(ch_data->s_indexmapped[1])); for (e = 0; e < ch_data->bs_num_env; e++) { const unsigned int ilim = sbr->n[ch_data->bs_freq_res[e + 1]]; uint16_t *table = ch_data->bs_freq_res[e + 1] ? sbr->f_tablehigh : sbr->f_tablelow; int k; for (i = 0; i < ilim; i++) for (m = table[i]; m < table[i + 1]; m++) sbr->e_origmapped[e][m - sbr->kx[1]] = ch_data->env_facs[e+1][i]; // ch_data->bs_num_noise > 1 => 2 noise floors k = (ch_data->bs_num_noise > 1) && (ch_data->t_env[e] >= ch_data->t_q[1]); for (i = 0; i < sbr->n_q; i++) for (m = sbr->f_tablenoise[i]; m < sbr->f_tablenoise[i + 1]; m++) sbr->q_mapped[e][m - sbr->kx[1]] = ch_data->noise_facs[k+1][i]; for (i = 0; i < sbr->n[1]; i++) { if (ch_data->bs_add_harmonic_flag) { const unsigned int m_midpoint = (sbr->f_tablehigh[i] + sbr->f_tablehigh[i + 1]) >> 1; ch_data->s_indexmapped[e + 1][m_midpoint - sbr->kx[1]] = ch_data->bs_add_harmonic[i] * (e >= e_a[1] || (ch_data->s_indexmapped[0][m_midpoint - sbr->kx[1]] == 1)); } } for (i = 0; i < ilim; i++) { int additional_sinusoid_present = 0; for (m = table[i]; m < table[i + 1]; m++) { if (ch_data->s_indexmapped[e + 1][m - sbr->kx[1]]) { additional_sinusoid_present = 1; break; } } memset(&sbr->s_mapped[e][table[i] - sbr->kx[1]], additional_sinusoid_present, (table[i + 1] - table[i]) * sizeof(sbr->s_mapped[e][0])); } } memcpy(ch_data->s_indexmapped[0], ch_data->s_indexmapped[ch_data->bs_num_env], sizeof(ch_data->s_indexmapped[0])); } /// Estimation of current envelope (14496-3 sp04 p218) static void sbr_env_estimate(float (*e_curr)[48], float X_high[64][40][2], SpectralBandReplication *sbr, SBRData *ch_data) { int e, i, m; if (sbr->bs_interpol_freq) { for (e = 0; e < ch_data->bs_num_env; e++) { const float recip_env_size = 0.5f / (ch_data->t_env[e + 1] - ch_data->t_env[e]); int ilb = ch_data->t_env[e] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; int iub = ch_data->t_env[e + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; for (m = 0; m < sbr->m[1]; m++) { float sum = 0.0f; for (i = ilb; i < iub; i++) { sum += X_high[m + sbr->kx[1]][i][0] * X_high[m + sbr->kx[1]][i][0] + X_high[m + sbr->kx[1]][i][1] * X_high[m + sbr->kx[1]][i][1]; } e_curr[e][m] = sum * recip_env_size; } } } else { int k, p; for (e = 0; e < ch_data->bs_num_env; e++) { const int env_size = 2 * (ch_data->t_env[e + 1] - ch_data->t_env[e]); int ilb = ch_data->t_env[e] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; int iub = ch_data->t_env[e + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; const uint16_t *table = ch_data->bs_freq_res[e + 1] ? sbr->f_tablehigh : sbr->f_tablelow; for (p = 0; p < sbr->n[ch_data->bs_freq_res[e + 1]]; p++) { float sum = 0.0f; const int den = env_size * (table[p + 1] - table[p]); for (k = table[p]; k < table[p + 1]; k++) { for (i = ilb; i < iub; i++) { sum += X_high[k][i][0] * X_high[k][i][0] + X_high[k][i][1] * X_high[k][i][1]; } } sum /= den; for (k = table[p]; k < table[p + 1]; k++) { e_curr[e][k - sbr->kx[1]] = sum; } } } } } /** * Calculation of levels of additional HF signal components (14496-3 sp04 p219) * and Calculation of gain (14496-3 sp04 p219) */ static void sbr_gain_calc(AACContext *ac, SpectralBandReplication *sbr, SBRData *ch_data, const int e_a[2]) { int e, k, m; // max gain limits : -3dB, 0dB, 3dB, inf dB (limiter off) static const float limgain[4] = { 0.70795, 1.0, 1.41254, 10000000000 }; for (e = 0; e < ch_data->bs_num_env; e++) { int delta = !((e == e_a[1]) || (e == e_a[0])); for (k = 0; k < sbr->n_lim; k++) { float gain_boost, gain_max; float sum[2] = { 0.0f, 0.0f }; for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { const float temp = sbr->e_origmapped[e][m] / (1.0f + sbr->q_mapped[e][m]); sbr->q_m[e][m] = sqrtf(temp * sbr->q_mapped[e][m]); sbr->s_m[e][m] = sqrtf(temp * ch_data->s_indexmapped[e + 1][m]); if (!sbr->s_mapped[e][m]) { sbr->gain[e][m] = sqrtf(sbr->e_origmapped[e][m] / ((1.0f + sbr->e_curr[e][m]) * (1.0f + sbr->q_mapped[e][m] * delta))); } else { sbr->gain[e][m] = sqrtf(sbr->e_origmapped[e][m] * sbr->q_mapped[e][m] / ((1.0f + sbr->e_curr[e][m]) * (1.0f + sbr->q_mapped[e][m]))); } } for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { sum[0] += sbr->e_origmapped[e][m]; sum[1] += sbr->e_curr[e][m]; } gain_max = limgain[sbr->bs_limiter_gains] * sqrtf((FLT_EPSILON + sum[0]) / (FLT_EPSILON + sum[1])); gain_max = FFMIN(100000, gain_max); for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { float q_m_max = sbr->q_m[e][m] * gain_max / sbr->gain[e][m]; sbr->q_m[e][m] = FFMIN(sbr->q_m[e][m], q_m_max); sbr->gain[e][m] = FFMIN(sbr->gain[e][m], gain_max); } sum[0] = sum[1] = 0.0f; for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { sum[0] += sbr->e_origmapped[e][m]; sum[1] += sbr->e_curr[e][m] * sbr->gain[e][m] * sbr->gain[e][m] + sbr->s_m[e][m] * sbr->s_m[e][m] + (delta && !sbr->s_m[e][m]) * sbr->q_m[e][m] * sbr->q_m[e][m]; } gain_boost = sqrtf((FLT_EPSILON + sum[0]) / (FLT_EPSILON + sum[1])); gain_boost = FFMIN(1.584893192, gain_boost); for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { sbr->gain[e][m] *= gain_boost; sbr->q_m[e][m] *= gain_boost; sbr->s_m[e][m] *= gain_boost; } } } } /// Assembling HF Signals (14496-3 sp04 p220) static void sbr_hf_assemble(float Y[2][38][64][2], const float X_high[64][40][2], SpectralBandReplication *sbr, SBRData *ch_data, const int e_a[2]) { int e, i, j, m; const int h_SL = 4 * !sbr->bs_smoothing_mode; const int kx = sbr->kx[1]; const int m_max = sbr->m[1]; static const float h_smooth[5] = { 0.33333333333333, 0.30150283239582, 0.21816949906249, 0.11516383427084, 0.03183050093751, }; static const int8_t phi[2][4] = { { 1, 0, -1, 0}, // real { 0, 1, 0, -1}, // imaginary }; float (*g_temp)[48] = ch_data->g_temp, (*q_temp)[48] = ch_data->q_temp; int indexnoise = ch_data->f_indexnoise; int indexsine = ch_data->f_indexsine; memcpy(Y[0], Y[1], sizeof(Y[0])); if (sbr->reset) { for (i = 0; i < h_SL; i++) { memcpy(g_temp[i + 2*ch_data->t_env[0]], sbr->gain[0], m_max * sizeof(sbr->gain[0][0])); memcpy(q_temp[i + 2*ch_data->t_env[0]], sbr->q_m[0], m_max * sizeof(sbr->q_m[0][0])); } } else if (h_SL) { memcpy(g_temp[2*ch_data->t_env[0]], g_temp[2*ch_data->t_env_num_env_old], 4*sizeof(g_temp[0])); memcpy(q_temp[2*ch_data->t_env[0]], q_temp[2*ch_data->t_env_num_env_old], 4*sizeof(q_temp[0])); } for (e = 0; e < ch_data->bs_num_env; e++) { for (i = 2 * ch_data->t_env[e]; i < 2 * ch_data->t_env[e + 1]; i++) { memcpy(g_temp[h_SL + i], sbr->gain[e], m_max * sizeof(sbr->gain[0][0])); memcpy(q_temp[h_SL + i], sbr->q_m[e], m_max * sizeof(sbr->q_m[0][0])); } } for (e = 0; e < ch_data->bs_num_env; e++) { for (i = 2 * ch_data->t_env[e]; i < 2 * ch_data->t_env[e + 1]; i++) { int phi_sign = (1 - 2*(kx & 1)); if (h_SL && e != e_a[0] && e != e_a[1]) { for (m = 0; m < m_max; m++) { const int idx1 = i + h_SL; float g_filt = 0.0f; for (j = 0; j <= h_SL; j++) g_filt += g_temp[idx1 - j][m] * h_smooth[j]; Y[1][i][m + kx][0] = X_high[m + kx][i + ENVELOPE_ADJUSTMENT_OFFSET][0] * g_filt; Y[1][i][m + kx][1] = X_high[m + kx][i + ENVELOPE_ADJUSTMENT_OFFSET][1] * g_filt; } } else { for (m = 0; m < m_max; m++) { const float g_filt = g_temp[i + h_SL][m]; Y[1][i][m + kx][0] = X_high[m + kx][i + ENVELOPE_ADJUSTMENT_OFFSET][0] * g_filt; Y[1][i][m + kx][1] = X_high[m + kx][i + ENVELOPE_ADJUSTMENT_OFFSET][1] * g_filt; } } if (e != e_a[0] && e != e_a[1]) { for (m = 0; m < m_max; m++) { indexnoise = (indexnoise + 1) & 0x1ff; if (sbr->s_m[e][m]) { Y[1][i][m + kx][0] += sbr->s_m[e][m] * phi[0][indexsine]; Y[1][i][m + kx][1] += sbr->s_m[e][m] * (phi[1][indexsine] * phi_sign); } else { float q_filt; if (h_SL) { const int idx1 = i + h_SL; q_filt = 0.0f; for (j = 0; j <= h_SL; j++) q_filt += q_temp[idx1 - j][m] * h_smooth[j]; } else { q_filt = q_temp[i][m]; } Y[1][i][m + kx][0] += q_filt * sbr_noise_table[indexnoise][0]; Y[1][i][m + kx][1] += q_filt * sbr_noise_table[indexnoise][1]; } phi_sign = -phi_sign; } } else { indexnoise = (indexnoise + m_max) & 0x1ff; for (m = 0; m < m_max; m++) { Y[1][i][m + kx][0] += sbr->s_m[e][m] * phi[0][indexsine]; Y[1][i][m + kx][1] += sbr->s_m[e][m] * (phi[1][indexsine] * phi_sign); phi_sign = -phi_sign; } } indexsine = (indexsine + 1) & 3; } } ch_data->f_indexnoise = indexnoise; ch_data->f_indexsine = indexsine; } void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac, float* L, float* R) { int downsampled = ac->m4ac.ext_sample_rate < sbr->sample_rate; int ch; int nch = (id_aac == TYPE_CPE) ? 2 : 1; if (sbr->start) { sbr_dequant(sbr, id_aac); } for (ch = 0; ch < nch; ch++) { /* decode channel */ sbr_qmf_analysis(&ac->dsp, &sbr->mdct_ana, ch ? R : L, sbr->data[ch].analysis_filterbank_samples, (float*)sbr->qmf_filter_scratch, sbr->data[ch].W, 1/(-1024 * ac->sf_scale)); sbr_lf_gen(ac, sbr, sbr->X_low, sbr->data[ch].W); if (sbr->start) { sbr_hf_inverse_filter(sbr->alpha0, sbr->alpha1, sbr->X_low, sbr->k[0]); sbr_chirp(sbr, &sbr->data[ch]); sbr_hf_gen(ac, sbr, sbr->X_high, sbr->X_low, sbr->alpha0, sbr->alpha1, sbr->data[ch].bw_array, sbr->data[ch].t_env, sbr->data[ch].bs_num_env); // hf_adj sbr_mapping(ac, sbr, &sbr->data[ch], sbr->data[ch].e_a); sbr_env_estimate(sbr->e_curr, sbr->X_high, sbr, &sbr->data[ch]); sbr_gain_calc(ac, sbr, &sbr->data[ch], sbr->data[ch].e_a); sbr_hf_assemble(sbr->data[ch].Y, sbr->X_high, sbr, &sbr->data[ch], sbr->data[ch].e_a); } /* synthesis */ sbr_x_gen(sbr, sbr->X[ch], sbr->X_low, sbr->data[ch].Y, ch); } if (ac->m4ac.ps == 1) { if (sbr->ps.start) { ff_ps_apply(ac->avctx, &sbr->ps, sbr->X[0], sbr->X[1], sbr->kx[1] + sbr->m[1]); } else { memcpy(sbr->X[1], sbr->X[0], sizeof(sbr->X[0])); } nch = 2; } sbr_qmf_synthesis(&ac->dsp, &sbr->mdct, L, sbr->X[0], sbr->qmf_filter_scratch, sbr->data[0].synthesis_filterbank_samples, &sbr->data[0].synthesis_filterbank_samples_offset, downsampled, ac->add_bias, -1024 * ac->sf_scale); if (nch == 2) sbr_qmf_synthesis(&ac->dsp, &sbr->mdct, R, sbr->X[1], sbr->qmf_filter_scratch, sbr->data[1].synthesis_filterbank_samples, &sbr->data[1].synthesis_filterbank_samples_offset, downsampled, ac->add_bias, -1024 * ac->sf_scale); }
123linslouis-android-video-cutter
jni/libavcodec/aacsbr.c
C
asf20
67,269
/* * RLE encoder * Copyright (c) 2007 Bobby Bingham * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avcodec.h" #include "rle.h" /** * Count up to 127 consecutive pixels which are either all the same or * all differ from the previous and next pixels. * @param start Pointer to the first pixel * @param len Maximum number of pixels * @param bpp Bytes per pixel * @param same 1 if searching for identical pixel values. 0 for differing * @return Number of matching consecutive pixels found */ static int count_pixels(const uint8_t *start, int len, int bpp, int same) { const uint8_t *pos; int count = 1; for(pos = start + bpp; count < FFMIN(127, len); pos += bpp, count ++) { if(same != !memcmp(pos-bpp, pos, bpp)) { if(!same) { /* if bpp == 1, then 0 1 1 0 is more efficiently encoded as a single * raw block of pixels. for larger bpp, RLE is as good or better */ if(bpp == 1 && count + 1 < FFMIN(127, len) && *pos != *(pos+1)) continue; /* if RLE can encode the next block better than as a raw block, * back up and leave _all_ the identical pixels for RLE */ count --; } break; } } return count; } int ff_rle_encode(uint8_t *outbuf, int out_size, const uint8_t *ptr , int bpp, int w, int add_rep, int xor_rep, int add_raw, int xor_raw) { int count, x; uint8_t *out = outbuf; for(x = 0; x < w; x += count) { /* see if we can encode the next set of pixels with RLE */ if((count = count_pixels(ptr, w-x, bpp, 1)) > 1) { if(out + bpp + 1 > outbuf + out_size) return -1; *out++ = (count ^ xor_rep) + add_rep; memcpy(out, ptr, bpp); out += bpp; } else { /* fall back on uncompressed */ count = count_pixels(ptr, w-x, bpp, 0); if(out + bpp*count >= outbuf + out_size) return -1; *out++ = (count ^ xor_raw) + add_raw; memcpy(out, ptr, bpp * count); out += bpp * count; } ptr += count * bpp; } return out - outbuf; }
123linslouis-android-video-cutter
jni/libavcodec/rle.c
C
asf20
2,940
/* * Quicktime Graphics (SMC) Video Decoder * Copyright (C) 2003 the ffmpeg project * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * QT SMC Video Decoder by Mike Melanson (melanson@pcisys.net) * For more information about the SMC format, visit: * http://www.pcisys.net/~melanson/codecs/ * * The SMC decoder outputs PAL8 colorspace data. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "libavutil/intreadwrite.h" #include "avcodec.h" #define CPAIR 2 #define CQUAD 4 #define COCTET 8 #define COLORS_PER_TABLE 256 typedef struct SmcContext { AVCodecContext *avctx; AVFrame frame; const unsigned char *buf; int size; /* SMC color tables */ unsigned char color_pairs[COLORS_PER_TABLE * CPAIR]; unsigned char color_quads[COLORS_PER_TABLE * CQUAD]; unsigned char color_octets[COLORS_PER_TABLE * COCTET]; } SmcContext; #define GET_BLOCK_COUNT() \ (opcode & 0x10) ? (1 + s->buf[stream_ptr++]) : 1 + (opcode & 0x0F); #define ADVANCE_BLOCK() \ { \ pixel_ptr += 4; \ if (pixel_ptr >= width) \ { \ pixel_ptr = 0; \ row_ptr += stride * 4; \ } \ total_blocks--; \ if (total_blocks < 0) \ { \ av_log(s->avctx, AV_LOG_INFO, "warning: block counter just went negative (this should not happen)\n"); \ return; \ } \ } static void smc_decode_stream(SmcContext *s) { int width = s->avctx->width; int height = s->avctx->height; int stride = s->frame.linesize[0]; int i; int stream_ptr = 0; int chunk_size; unsigned char opcode; int n_blocks; unsigned int color_flags; unsigned int color_flags_a; unsigned int color_flags_b; unsigned int flag_mask; unsigned char *pixels = s->frame.data[0]; int image_size = height * s->frame.linesize[0]; int row_ptr = 0; int pixel_ptr = 0; int pixel_x, pixel_y; int row_inc = stride - 4; int block_ptr; int prev_block_ptr; int prev_block_ptr1, prev_block_ptr2; int prev_block_flag; int total_blocks; int color_table_index; /* indexes to color pair, quad, or octet tables */ int pixel; int color_pair_index = 0; int color_quad_index = 0; int color_octet_index = 0; /* make the palette available */ memcpy(s->frame.data[1], s->avctx->palctrl->palette, AVPALETTE_SIZE); if (s->avctx->palctrl->palette_changed) { s->frame.palette_has_changed = 1; s->avctx->palctrl->palette_changed = 0; } chunk_size = AV_RB32(&s->buf[stream_ptr]) & 0x00FFFFFF; stream_ptr += 4; if (chunk_size != s->size) av_log(s->avctx, AV_LOG_INFO, "warning: MOV chunk size != encoded chunk size (%d != %d); using MOV chunk size\n", chunk_size, s->size); chunk_size = s->size; total_blocks = ((s->avctx->width + 3) / 4) * ((s->avctx->height + 3) / 4); /* traverse through the blocks */ while (total_blocks) { /* sanity checks */ /* make sure stream ptr hasn't gone out of bounds */ if (stream_ptr > chunk_size) { av_log(s->avctx, AV_LOG_INFO, "SMC decoder just went out of bounds (stream ptr = %d, chunk size = %d)\n", stream_ptr, chunk_size); return; } /* make sure the row pointer hasn't gone wild */ if (row_ptr >= image_size) { av_log(s->avctx, AV_LOG_INFO, "SMC decoder just went out of bounds (row ptr = %d, height = %d)\n", row_ptr, image_size); return; } opcode = s->buf[stream_ptr++]; switch (opcode & 0xF0) { /* skip n blocks */ case 0x00: case 0x10: n_blocks = GET_BLOCK_COUNT(); while (n_blocks--) { ADVANCE_BLOCK(); } break; /* repeat last block n times */ case 0x20: case 0x30: n_blocks = GET_BLOCK_COUNT(); /* sanity check */ if ((row_ptr == 0) && (pixel_ptr == 0)) { av_log(s->avctx, AV_LOG_INFO, "encountered repeat block opcode (%02X) but no blocks rendered yet\n", opcode & 0xF0); break; } /* figure out where the previous block started */ if (pixel_ptr == 0) prev_block_ptr1 = (row_ptr - s->avctx->width * 4) + s->avctx->width - 4; else prev_block_ptr1 = row_ptr + pixel_ptr - 4; while (n_blocks--) { block_ptr = row_ptr + pixel_ptr; prev_block_ptr = prev_block_ptr1; for (pixel_y = 0; pixel_y < 4; pixel_y++) { for (pixel_x = 0; pixel_x < 4; pixel_x++) { pixels[block_ptr++] = pixels[prev_block_ptr++]; } block_ptr += row_inc; prev_block_ptr += row_inc; } ADVANCE_BLOCK(); } break; /* repeat previous pair of blocks n times */ case 0x40: case 0x50: n_blocks = GET_BLOCK_COUNT(); n_blocks *= 2; /* sanity check */ if ((row_ptr == 0) && (pixel_ptr < 2 * 4)) { av_log(s->avctx, AV_LOG_INFO, "encountered repeat block opcode (%02X) but not enough blocks rendered yet\n", opcode & 0xF0); break; } /* figure out where the previous 2 blocks started */ if (pixel_ptr == 0) prev_block_ptr1 = (row_ptr - s->avctx->width * 4) + s->avctx->width - 4 * 2; else if (pixel_ptr == 4) prev_block_ptr1 = (row_ptr - s->avctx->width * 4) + row_inc; else prev_block_ptr1 = row_ptr + pixel_ptr - 4 * 2; if (pixel_ptr == 0) prev_block_ptr2 = (row_ptr - s->avctx->width * 4) + row_inc; else prev_block_ptr2 = row_ptr + pixel_ptr - 4; prev_block_flag = 0; while (n_blocks--) { block_ptr = row_ptr + pixel_ptr; if (prev_block_flag) prev_block_ptr = prev_block_ptr2; else prev_block_ptr = prev_block_ptr1; prev_block_flag = !prev_block_flag; for (pixel_y = 0; pixel_y < 4; pixel_y++) { for (pixel_x = 0; pixel_x < 4; pixel_x++) { pixels[block_ptr++] = pixels[prev_block_ptr++]; } block_ptr += row_inc; prev_block_ptr += row_inc; } ADVANCE_BLOCK(); } break; /* 1-color block encoding */ case 0x60: case 0x70: n_blocks = GET_BLOCK_COUNT(); pixel = s->buf[stream_ptr++]; while (n_blocks--) { block_ptr = row_ptr + pixel_ptr; for (pixel_y = 0; pixel_y < 4; pixel_y++) { for (pixel_x = 0; pixel_x < 4; pixel_x++) { pixels[block_ptr++] = pixel; } block_ptr += row_inc; } ADVANCE_BLOCK(); } break; /* 2-color block encoding */ case 0x80: case 0x90: n_blocks = (opcode & 0x0F) + 1; /* figure out which color pair to use to paint the 2-color block */ if ((opcode & 0xF0) == 0x80) { /* fetch the next 2 colors from bytestream and store in next * available entry in the color pair table */ for (i = 0; i < CPAIR; i++) { pixel = s->buf[stream_ptr++]; color_table_index = CPAIR * color_pair_index + i; s->color_pairs[color_table_index] = pixel; } /* this is the base index to use for this block */ color_table_index = CPAIR * color_pair_index; color_pair_index++; /* wraparound */ if (color_pair_index == COLORS_PER_TABLE) color_pair_index = 0; } else color_table_index = CPAIR * s->buf[stream_ptr++]; while (n_blocks--) { color_flags = AV_RB16(&s->buf[stream_ptr]); stream_ptr += 2; flag_mask = 0x8000; block_ptr = row_ptr + pixel_ptr; for (pixel_y = 0; pixel_y < 4; pixel_y++) { for (pixel_x = 0; pixel_x < 4; pixel_x++) { if (color_flags & flag_mask) pixel = color_table_index + 1; else pixel = color_table_index; flag_mask >>= 1; pixels[block_ptr++] = s->color_pairs[pixel]; } block_ptr += row_inc; } ADVANCE_BLOCK(); } break; /* 4-color block encoding */ case 0xA0: case 0xB0: n_blocks = (opcode & 0x0F) + 1; /* figure out which color quad to use to paint the 4-color block */ if ((opcode & 0xF0) == 0xA0) { /* fetch the next 4 colors from bytestream and store in next * available entry in the color quad table */ for (i = 0; i < CQUAD; i++) { pixel = s->buf[stream_ptr++]; color_table_index = CQUAD * color_quad_index + i; s->color_quads[color_table_index] = pixel; } /* this is the base index to use for this block */ color_table_index = CQUAD * color_quad_index; color_quad_index++; /* wraparound */ if (color_quad_index == COLORS_PER_TABLE) color_quad_index = 0; } else color_table_index = CQUAD * s->buf[stream_ptr++]; while (n_blocks--) { color_flags = AV_RB32(&s->buf[stream_ptr]); stream_ptr += 4; /* flag mask actually acts as a bit shift count here */ flag_mask = 30; block_ptr = row_ptr + pixel_ptr; for (pixel_y = 0; pixel_y < 4; pixel_y++) { for (pixel_x = 0; pixel_x < 4; pixel_x++) { pixel = color_table_index + ((color_flags >> flag_mask) & 0x03); flag_mask -= 2; pixels[block_ptr++] = s->color_quads[pixel]; } block_ptr += row_inc; } ADVANCE_BLOCK(); } break; /* 8-color block encoding */ case 0xC0: case 0xD0: n_blocks = (opcode & 0x0F) + 1; /* figure out which color octet to use to paint the 8-color block */ if ((opcode & 0xF0) == 0xC0) { /* fetch the next 8 colors from bytestream and store in next * available entry in the color octet table */ for (i = 0; i < COCTET; i++) { pixel = s->buf[stream_ptr++]; color_table_index = COCTET * color_octet_index + i; s->color_octets[color_table_index] = pixel; } /* this is the base index to use for this block */ color_table_index = COCTET * color_octet_index; color_octet_index++; /* wraparound */ if (color_octet_index == COLORS_PER_TABLE) color_octet_index = 0; } else color_table_index = COCTET * s->buf[stream_ptr++]; while (n_blocks--) { /* For this input of 6 hex bytes: 01 23 45 67 89 AB Mangle it to this output: flags_a = xx012456, flags_b = xx89A37B */ /* build the color flags */ color_flags_a = ((AV_RB16(s->buf + stream_ptr ) & 0xFFF0) << 8) | (AV_RB16(s->buf + stream_ptr + 2) >> 4); color_flags_b = ((AV_RB16(s->buf + stream_ptr + 4) & 0xFFF0) << 8) | ((s->buf[stream_ptr + 1] & 0x0F) << 8) | ((s->buf[stream_ptr + 3] & 0x0F) << 4) | (s->buf[stream_ptr + 5] & 0x0F); stream_ptr += 6; color_flags = color_flags_a; /* flag mask actually acts as a bit shift count here */ flag_mask = 21; block_ptr = row_ptr + pixel_ptr; for (pixel_y = 0; pixel_y < 4; pixel_y++) { /* reload flags at third row (iteration pixel_y == 2) */ if (pixel_y == 2) { color_flags = color_flags_b; flag_mask = 21; } for (pixel_x = 0; pixel_x < 4; pixel_x++) { pixel = color_table_index + ((color_flags >> flag_mask) & 0x07); flag_mask -= 3; pixels[block_ptr++] = s->color_octets[pixel]; } block_ptr += row_inc; } ADVANCE_BLOCK(); } break; /* 16-color block encoding (every pixel is a different color) */ case 0xE0: n_blocks = (opcode & 0x0F) + 1; while (n_blocks--) { block_ptr = row_ptr + pixel_ptr; for (pixel_y = 0; pixel_y < 4; pixel_y++) { for (pixel_x = 0; pixel_x < 4; pixel_x++) { pixels[block_ptr++] = s->buf[stream_ptr++]; } block_ptr += row_inc; } ADVANCE_BLOCK(); } break; case 0xF0: av_log(s->avctx, AV_LOG_INFO, "0xF0 opcode seen in SMC chunk (contact the developers)\n"); break; } } } static av_cold int smc_decode_init(AVCodecContext *avctx) { SmcContext *s = avctx->priv_data; s->avctx = avctx; avctx->pix_fmt = PIX_FMT_PAL8; s->frame.data[0] = NULL; return 0; } static int smc_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; SmcContext *s = avctx->priv_data; s->buf = buf; s->size = buf_size; s->frame.reference = 1; s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE | FF_BUFFER_HINTS_READABLE; if (avctx->reget_buffer(avctx, &s->frame)) { av_log(s->avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return -1; } smc_decode_stream(s); *data_size = sizeof(AVFrame); *(AVFrame*)data = s->frame; /* always report that the buffer was completely consumed */ return buf_size; } static av_cold int smc_decode_end(AVCodecContext *avctx) { SmcContext *s = avctx->priv_data; if (s->frame.data[0]) avctx->release_buffer(avctx, &s->frame); return 0; } AVCodec smc_decoder = { "smc", AVMEDIA_TYPE_VIDEO, CODEC_ID_SMC, sizeof(SmcContext), smc_decode_init, NULL, smc_decode_end, smc_decode_frame, CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("QuickTime Graphics (SMC)"), };
123linslouis-android-video-cutter
jni/libavcodec/smc.c
C
asf20
16,597
/* * Video Acceleration API (video decoding) * HW decode acceleration for MPEG-2, MPEG-4, H.264 and VC-1 * * Copyright (C) 2008-2009 Splitted-Desktop Systems * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "vaapi_internal.h" /** * \addtogroup VAAPI_Decoding * * @{ */ static void destroy_buffers(VADisplay display, VABufferID *buffers, unsigned int n_buffers) { unsigned int i; for (i = 0; i < n_buffers; i++) { if (buffers[i]) { vaDestroyBuffer(display, buffers[i]); buffers[i] = 0; } } } static int render_picture(struct vaapi_context *vactx, VASurfaceID surface) { VABufferID va_buffers[3]; unsigned int n_va_buffers = 0; vaUnmapBuffer(vactx->display, vactx->pic_param_buf_id); va_buffers[n_va_buffers++] = vactx->pic_param_buf_id; if (vactx->iq_matrix_buf_id) { vaUnmapBuffer(vactx->display, vactx->iq_matrix_buf_id); va_buffers[n_va_buffers++] = vactx->iq_matrix_buf_id; } if (vactx->bitplane_buf_id) { vaUnmapBuffer(vactx->display, vactx->bitplane_buf_id); va_buffers[n_va_buffers++] = vactx->bitplane_buf_id; } if (vaBeginPicture(vactx->display, vactx->context_id, surface) != VA_STATUS_SUCCESS) return -1; if (vaRenderPicture(vactx->display, vactx->context_id, va_buffers, n_va_buffers) != VA_STATUS_SUCCESS) return -1; if (vaRenderPicture(vactx->display, vactx->context_id, vactx->slice_buf_ids, vactx->n_slice_buf_ids) != VA_STATUS_SUCCESS) return -1; if (vaEndPicture(vactx->display, vactx->context_id) != VA_STATUS_SUCCESS) return -1; return 0; } static int commit_slices(struct vaapi_context *vactx) { VABufferID *slice_buf_ids; VABufferID slice_param_buf_id, slice_data_buf_id; if (vactx->slice_count == 0) return 0; slice_buf_ids = av_fast_realloc(vactx->slice_buf_ids, &vactx->slice_buf_ids_alloc, (vactx->n_slice_buf_ids + 2) * sizeof(slice_buf_ids[0])); if (!slice_buf_ids) return -1; vactx->slice_buf_ids = slice_buf_ids; slice_param_buf_id = 0; if (vaCreateBuffer(vactx->display, vactx->context_id, VASliceParameterBufferType, vactx->slice_param_size, vactx->slice_count, vactx->slice_params, &slice_param_buf_id) != VA_STATUS_SUCCESS) return -1; vactx->slice_count = 0; slice_data_buf_id = 0; if (vaCreateBuffer(vactx->display, vactx->context_id, VASliceDataBufferType, vactx->slice_data_size, 1, (void *)vactx->slice_data, &slice_data_buf_id) != VA_STATUS_SUCCESS) return -1; vactx->slice_data = NULL; vactx->slice_data_size = 0; slice_buf_ids[vactx->n_slice_buf_ids++] = slice_param_buf_id; slice_buf_ids[vactx->n_slice_buf_ids++] = slice_data_buf_id; return 0; } static void *alloc_buffer(struct vaapi_context *vactx, int type, unsigned int size, uint32_t *buf_id) { void *data = NULL; *buf_id = 0; if (vaCreateBuffer(vactx->display, vactx->context_id, type, size, 1, NULL, buf_id) == VA_STATUS_SUCCESS) vaMapBuffer(vactx->display, *buf_id, &data); return data; } void *ff_vaapi_alloc_pic_param(struct vaapi_context *vactx, unsigned int size) { return alloc_buffer(vactx, VAPictureParameterBufferType, size, &vactx->pic_param_buf_id); } void *ff_vaapi_alloc_iq_matrix(struct vaapi_context *vactx, unsigned int size) { return alloc_buffer(vactx, VAIQMatrixBufferType, size, &vactx->iq_matrix_buf_id); } uint8_t *ff_vaapi_alloc_bitplane(struct vaapi_context *vactx, uint32_t size) { return alloc_buffer(vactx, VABitPlaneBufferType, size, &vactx->bitplane_buf_id); } VASliceParameterBufferBase *ff_vaapi_alloc_slice(struct vaapi_context *vactx, const uint8_t *buffer, uint32_t size) { uint8_t *slice_params; VASliceParameterBufferBase *slice_param; if (!vactx->slice_data) vactx->slice_data = buffer; if (vactx->slice_data + vactx->slice_data_size != buffer) { if (commit_slices(vactx) < 0) return NULL; vactx->slice_data = buffer; } slice_params = av_fast_realloc(vactx->slice_params, &vactx->slice_params_alloc, (vactx->slice_count + 1) * vactx->slice_param_size); if (!slice_params) return NULL; vactx->slice_params = slice_params; slice_param = (VASliceParameterBufferBase *)(slice_params + vactx->slice_count * vactx->slice_param_size); slice_param->slice_data_size = size; slice_param->slice_data_offset = vactx->slice_data_size; slice_param->slice_data_flag = VA_SLICE_DATA_FLAG_ALL; vactx->slice_count++; vactx->slice_data_size += size; return slice_param; } int ff_vaapi_common_end_frame(MpegEncContext *s) { struct vaapi_context * const vactx = s->avctx->hwaccel_context; int ret = -1; dprintf(s->avctx, "ff_vaapi_common_end_frame()\n"); if (commit_slices(vactx) < 0) goto done; if (vactx->n_slice_buf_ids > 0) { if (render_picture(vactx, ff_vaapi_get_surface_id(s->current_picture_ptr)) < 0) goto done; ff_draw_horiz_band(s, 0, s->avctx->height); } ret = 0; done: destroy_buffers(vactx->display, &vactx->pic_param_buf_id, 1); destroy_buffers(vactx->display, &vactx->iq_matrix_buf_id, 1); destroy_buffers(vactx->display, &vactx->bitplane_buf_id, 1); destroy_buffers(vactx->display, vactx->slice_buf_ids, vactx->n_slice_buf_ids); av_freep(&vactx->slice_buf_ids); av_freep(&vactx->slice_params); vactx->n_slice_buf_ids = 0; vactx->slice_buf_ids_alloc = 0; vactx->slice_count = 0; vactx->slice_params_alloc = 0; return ret; } /* @} */
123linslouis-android-video-cutter
jni/libavcodec/vaapi.c
C
asf20
6,772
/* * GIF encoder. * Copyright (c) 2000 Fabrice Bellard * Copyright (c) 2002 Francois Revol * Copyright (c) 2006 Baptiste Coudurier * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* * First version by Francois Revol revol@free.fr * * Features and limitations: * - currently no compression is performed, * in fact the size of the data is 9/8 the size of the image in 8bpp * - uses only a global standard palette * - tested with IE 5.0, Opera for BeOS, NetPositive (BeOS), and Mozilla (BeOS). * * Reference documents: * http://www.goice.co.jp/member/mo/formats/gif.html * http://astronomy.swin.edu.au/pbourke/dataformats/gif/ * http://www.dcs.ed.ac.uk/home/mxr/gfx/2d/GIF89a.txt * * this url claims to have an LZW algorithm not covered by Unisys patent: * http://www.msg.net/utility/whirlgif/gifencod.html * could help reduce the size of the files _a lot_... * some sites mentions an RLE type compression also. */ #include "avcodec.h" #include "bytestream.h" #include "lzw.h" /* The GIF format uses reversed order for bitstreams... */ /* at least they don't use PDP_ENDIAN :) */ #define BITSTREAM_WRITER_LE #include "put_bits.h" typedef struct { AVFrame picture; LZWState *lzw; uint8_t *buf; } GIFContext; /* GIF header */ static int gif_image_write_header(AVCodecContext *avctx, uint8_t **bytestream, uint32_t *palette) { int i; unsigned int v; bytestream_put_buffer(bytestream, "GIF", 3); bytestream_put_buffer(bytestream, "89a", 3); bytestream_put_le16(bytestream, avctx->width); bytestream_put_le16(bytestream, avctx->height); bytestream_put_byte(bytestream, 0xf7); /* flags: global clut, 256 entries */ bytestream_put_byte(bytestream, 0x1f); /* background color index */ bytestream_put_byte(bytestream, 0); /* aspect ratio */ /* the global palette */ for(i=0;i<256;i++) { v = palette[i]; bytestream_put_be24(bytestream, v); } return 0; } static int gif_image_write_image(AVCodecContext *avctx, uint8_t **bytestream, uint8_t *end, const uint8_t *buf, int linesize) { GIFContext *s = avctx->priv_data; int len, height; const uint8_t *ptr; /* image block */ bytestream_put_byte(bytestream, 0x2c); bytestream_put_le16(bytestream, 0); bytestream_put_le16(bytestream, 0); bytestream_put_le16(bytestream, avctx->width); bytestream_put_le16(bytestream, avctx->height); bytestream_put_byte(bytestream, 0x00); /* flags */ /* no local clut */ bytestream_put_byte(bytestream, 0x08); ff_lzw_encode_init(s->lzw, s->buf, avctx->width*avctx->height, 12, FF_LZW_GIF, put_bits); ptr = buf; for (height = avctx->height; height--;) { len += ff_lzw_encode(s->lzw, ptr, avctx->width); ptr += linesize; } len += ff_lzw_encode_flush(s->lzw, flush_put_bits); ptr = s->buf; while (len > 0) { int size = FFMIN(255, len); bytestream_put_byte(bytestream, size); if (end - *bytestream < size) return -1; bytestream_put_buffer(bytestream, ptr, size); ptr += size; len -= size; } bytestream_put_byte(bytestream, 0x00); /* end of image block */ bytestream_put_byte(bytestream, 0x3b); return 0; } static av_cold int gif_encode_init(AVCodecContext *avctx) { GIFContext *s = avctx->priv_data; avctx->coded_frame = &s->picture; s->lzw = av_mallocz(ff_lzw_encode_state_size); if (!s->lzw) return AVERROR(ENOMEM); s->buf = av_malloc(avctx->width*avctx->height*2); if (!s->buf) return AVERROR(ENOMEM); return 0; } /* better than nothing gif encoder */ static int gif_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, int buf_size, void *data) { GIFContext *s = avctx->priv_data; AVFrame *pict = data; AVFrame *const p = (AVFrame *)&s->picture; uint8_t *outbuf_ptr = outbuf; uint8_t *end = outbuf + buf_size; *p = *pict; p->pict_type = FF_I_TYPE; p->key_frame = 1; gif_image_write_header(avctx, &outbuf_ptr, (uint32_t *)pict->data[1]); gif_image_write_image(avctx, &outbuf_ptr, end, pict->data[0], pict->linesize[0]); return outbuf_ptr - outbuf; } static int gif_encode_close(AVCodecContext *avctx) { GIFContext *s = avctx->priv_data; av_freep(&s->lzw); av_freep(&s->buf); return 0; } AVCodec gif_encoder = { "gif", AVMEDIA_TYPE_VIDEO, CODEC_ID_GIF, sizeof(GIFContext), gif_encode_init, gif_encode_frame, gif_encode_close, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_RGB8, PIX_FMT_BGR8, PIX_FMT_RGB4_BYTE, PIX_FMT_BGR4_BYTE, PIX_FMT_GRAY8, PIX_FMT_PAL8, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("GIF (Graphics Interchange Format)"), };
123linslouis-android-video-cutter
jni/libavcodec/gif.c
C
asf20
5,590
/* * IIR filter * Copyright (c) 2008 Konstantin Shishkov * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * IIR filter interface */ #ifndef AVCODEC_IIRFILTER_H #define AVCODEC_IIRFILTER_H #include "avcodec.h" struct FFIIRFilterCoeffs; struct FFIIRFilterState; enum IIRFilterType{ FF_FILTER_TYPE_BESSEL, FF_FILTER_TYPE_BUTTERWORTH, FF_FILTER_TYPE_CHEBYSHEV, FF_FILTER_TYPE_ELLIPTIC, }; enum IIRFilterMode{ FF_FILTER_MODE_LOWPASS, FF_FILTER_MODE_HIGHPASS, FF_FILTER_MODE_BANDPASS, FF_FILTER_MODE_BANDSTOP, }; /** * Initialize filter coefficients. * * @param filt_type filter type (e.g. Butterworth) * @param filt_mode filter mode (e.g. lowpass) * @param order filter order * @param cutoff_ratio cutoff to input frequency ratio * @param stopband stopband to input frequency ratio (used by bandpass and bandstop filter modes) * @param ripple ripple factor (used only in Chebyshev filters) * * @return pointer to filter coefficients structure or NULL if filter cannot be created */ struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(enum IIRFilterType filt_type, enum IIRFilterMode filt_mode, int order, float cutoff_ratio, float stopband, float ripple); /** * Create new filter state. * * @param order filter order * * @return pointer to new filter state or NULL if state creation fails */ struct FFIIRFilterState* ff_iir_filter_init_state(int order); /** * Free filter coefficients. * * @param coeffs pointer allocated with ff_iir_filter_init_coeffs() */ void ff_iir_filter_free_coeffs(struct FFIIRFilterCoeffs *coeffs); /** * Free filter state. * * @param state pointer allocated with ff_iir_filter_init_state() */ void ff_iir_filter_free_state(struct FFIIRFilterState *state); /** * Perform lowpass filtering on input samples. * * @param coeffs pointer to filter coefficients * @param state pointer to filter state * @param size input length * @param src source samples * @param sstep source stride * @param dst filtered samples (destination may be the same as input) * @param dstep destination stride */ void ff_iir_filter(const struct FFIIRFilterCoeffs *coeffs, struct FFIIRFilterState *state, int size, const int16_t *src, int sstep, int16_t *dst, int dstep); #endif /* AVCODEC_IIRFILTER_H */
123linslouis-android-video-cutter
jni/libavcodec/iirfilter.h
C
asf20
3,215
/* * common functions for Indeo Video Interactive codecs (Indeo4 and Indeo5) * * Copyright (c) 2009 Maxim Poliakovski * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * This file contains functions and data shared by both Indeo4 and * Indeo5 decoders. */ #define ALT_BITSTREAM_READER_LE #include "avcodec.h" #include "get_bits.h" #include "ivi_common.h" #include "libavutil/common.h" #include "ivi_dsp.h" extern const IVIHuffDesc ff_ivi_mb_huff_desc[8]; ///< static macroblock huffman tables extern const IVIHuffDesc ff_ivi_blk_huff_desc[8]; ///< static block huffman tables VLC ff_ivi_mb_vlc_tabs [8]; VLC ff_ivi_blk_vlc_tabs[8]; /** * Reverses "nbits" bits of the value "val" and returns the result * in the least significant bits. */ static uint16_t inv_bits(uint16_t val, int nbits) { uint16_t res; if (nbits <= 8) { res = av_reverse[val] >> (8-nbits); } else res = ((av_reverse[val & 0xFF] << 8) + (av_reverse[val >> 8])) >> (16-nbits); return res; } int ff_ivi_create_huff_from_desc(const IVIHuffDesc *cb, VLC *vlc, int flag) { int pos, i, j, codes_per_row, prefix, not_last_row; uint16_t codewords[256]; /* FIXME: move this temporal storage out? */ uint8_t bits[256]; pos = 0; /* current position = 0 */ for (i = 0; i < cb->num_rows; i++) { codes_per_row = 1 << cb->xbits[i]; not_last_row = (i != cb->num_rows - 1); prefix = ((1 << i) - 1) << (cb->xbits[i] + not_last_row); for (j = 0; j < codes_per_row; j++) { if (pos >= 256) /* Some Indeo5 codebooks can have more than 256 */ break; /* elements, but only 256 codes are allowed! */ bits[pos] = i + cb->xbits[i] + not_last_row; if (bits[pos] > IVI_VLC_BITS) return -1; /* invalid descriptor */ codewords[pos] = inv_bits((prefix | j), bits[pos]); if (!bits[pos]) bits[pos] = 1; pos++; }//for j }//for i /* number of codewords = pos */ return init_vlc(vlc, IVI_VLC_BITS, pos, bits, 1, 1, codewords, 2, 2, (flag ? INIT_VLC_USE_NEW_STATIC : 0) | INIT_VLC_LE); } void ff_ivi_init_static_vlc(void) { int i; static VLC_TYPE table_data[8192 * 16][2]; static int initialized_vlcs = 0; if (initialized_vlcs) return; for (i = 0; i < 8; i++) { ff_ivi_mb_vlc_tabs[i].table = table_data + i * 2 * 8192; ff_ivi_mb_vlc_tabs[i].table_allocated = 8192; ff_ivi_create_huff_from_desc(&ff_ivi_mb_huff_desc[i], &ff_ivi_mb_vlc_tabs[i], 1); ff_ivi_blk_vlc_tabs[i].table = table_data + (i * 2 + 1) * 8192; ff_ivi_blk_vlc_tabs[i].table_allocated = 8192; ff_ivi_create_huff_from_desc(&ff_ivi_blk_huff_desc[i], &ff_ivi_blk_vlc_tabs[i], 1); } initialized_vlcs = 1; } int ff_ivi_dec_huff_desc(GetBitContext *gb, int desc_coded, int which_tab, IVIHuffTab *huff_tab, AVCodecContext *avctx) { int i, result; IVIHuffDesc new_huff; if (!desc_coded) { /* select default table */ huff_tab->tab = (which_tab) ? &ff_ivi_blk_vlc_tabs[7] : &ff_ivi_mb_vlc_tabs [7]; } else { huff_tab->tab_sel = get_bits(gb, 3); if (huff_tab->tab_sel == 7) { /* custom huffman table (explicitly encoded) */ new_huff.num_rows = get_bits(gb, 4); for (i = 0; i < new_huff.num_rows; i++) new_huff.xbits[i] = get_bits(gb, 4); /* Have we got the same custom table? Rebuild if not. */ if (ff_ivi_huff_desc_cmp(&new_huff, &huff_tab->cust_desc)) { ff_ivi_huff_desc_copy(&huff_tab->cust_desc, &new_huff); if (huff_tab->cust_tab.table) free_vlc(&huff_tab->cust_tab); result = ff_ivi_create_huff_from_desc(&huff_tab->cust_desc, &huff_tab->cust_tab, 0); if (result) { av_log(avctx, AV_LOG_ERROR, "Error while initializing custom vlc table!\n"); return -1; } } huff_tab->tab = &huff_tab->cust_tab; } else { /* select one of predefined tables */ huff_tab->tab = (which_tab) ? &ff_ivi_blk_vlc_tabs[huff_tab->tab_sel] : &ff_ivi_mb_vlc_tabs [huff_tab->tab_sel]; } } return 0; } int ff_ivi_huff_desc_cmp(const IVIHuffDesc *desc1, const IVIHuffDesc *desc2) { return desc1->num_rows != desc2->num_rows || memcmp(desc1->xbits, desc2->xbits, desc1->num_rows); } void ff_ivi_huff_desc_copy(IVIHuffDesc *dst, const IVIHuffDesc *src) { dst->num_rows = src->num_rows; memcpy(dst->xbits, src->xbits, src->num_rows); } int av_cold ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg) { int p, b; uint32_t b_width, b_height, align_fac, width_aligned, height_aligned, buf_size; IVIBandDesc *band; ff_ivi_free_buffers(planes); /* fill in the descriptor of the luminance plane */ planes[0].width = cfg->pic_width; planes[0].height = cfg->pic_height; planes[0].num_bands = cfg->luma_bands; /* fill in the descriptors of the chrominance planes */ planes[1].width = planes[2].width = (cfg->pic_width + 3) >> 2; planes[1].height = planes[2].height = (cfg->pic_height + 3) >> 2; planes[1].num_bands = planes[2].num_bands = cfg->chroma_bands; for (p = 0; p < 3; p++) { planes[p].bands = av_mallocz(planes[p].num_bands * sizeof(IVIBandDesc)); if (!planes[p].bands) return AVERROR(ENOMEM); /* select band dimensions: if there is only one band then it * has the full size, if there are several bands each of them * has only half size */ b_width = planes[p].num_bands == 1 ? planes[p].width : (planes[p].width + 1) >> 1; b_height = planes[p].num_bands == 1 ? planes[p].height : (planes[p].height + 1) >> 1; /* luma band buffers will be aligned on 16x16 (max macroblock size) */ /* chroma band buffers will be aligned on 8x8 (max macroblock size) */ align_fac = p ? 8 : 16; width_aligned = FFALIGN(b_width , align_fac); height_aligned = FFALIGN(b_height, align_fac); buf_size = width_aligned * height_aligned * sizeof(int16_t); for (b = 0; b < planes[p].num_bands; b++) { band = &planes[p].bands[b]; /* select appropriate plane/band */ band->plane = p; band->band_num = b; band->width = b_width; band->height = b_height; band->pitch = width_aligned; band->bufs[0] = av_malloc(buf_size); band->bufs[1] = av_malloc(buf_size); if (!band->bufs[0] || !band->bufs[1]) return AVERROR(ENOMEM); /* allocate the 3rd band buffer for scalability mode */ if (cfg->luma_bands > 1) { band->bufs[2] = av_malloc(buf_size); if (!band->bufs[2]) return AVERROR(ENOMEM); } planes[p].bands[0].blk_vlc.cust_desc.num_rows = 0; /* reset custom vlc */ } } return 0; } void av_cold ff_ivi_free_buffers(IVIPlaneDesc *planes) { int p, b, t; for (p = 0; p < 3; p++) { for (b = 0; b < planes[p].num_bands; b++) { av_freep(&planes[p].bands[b].bufs[0]); av_freep(&planes[p].bands[b].bufs[1]); av_freep(&planes[p].bands[b].bufs[2]); if (planes[p].bands[b].blk_vlc.cust_tab.table) free_vlc(&planes[p].bands[b].blk_vlc.cust_tab); for (t = 0; t < planes[p].bands[b].num_tiles; t++) av_freep(&planes[p].bands[b].tiles[t].mbs); av_freep(&planes[p].bands[b].tiles); } av_freep(&planes[p].bands); } } int av_cold ff_ivi_init_tiles(IVIPlaneDesc *planes, int tile_width, int tile_height) { int p, b, x, y, x_tiles, y_tiles, t_width, t_height; IVIBandDesc *band; IVITile *tile, *ref_tile; for (p = 0; p < 3; p++) { t_width = !p ? tile_width : (tile_width + 3) >> 2; t_height = !p ? tile_height : (tile_height + 3) >> 2; if (!p && planes[0].num_bands == 4) { t_width >>= 1; t_height >>= 1; } for (b = 0; b < planes[p].num_bands; b++) { band = &planes[p].bands[b]; x_tiles = IVI_NUM_TILES(band->width, t_width); y_tiles = IVI_NUM_TILES(band->height, t_height); band->num_tiles = x_tiles * y_tiles; av_freep(&band->tiles); band->tiles = av_mallocz(band->num_tiles * sizeof(IVITile)); if (!band->tiles) return AVERROR(ENOMEM); tile = band->tiles; /* use the first luma band as reference for motion vectors * and quant */ ref_tile = planes[0].bands[0].tiles; for (y = 0; y < band->height; y += t_height) { for (x = 0; x < band->width; x += t_width) { tile->xpos = x; tile->ypos = y; tile->width = FFMIN(band->width - x, t_width); tile->height = FFMIN(band->height - y, t_height); tile->is_empty = tile->data_size = 0; /* calculate number of macroblocks */ tile->num_MBs = IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size); av_freep(&tile->mbs); tile->mbs = av_malloc(tile->num_MBs * sizeof(IVIMbInfo)); if (!tile->mbs) return AVERROR(ENOMEM); tile->ref_mbs = 0; if (p || b) { tile->ref_mbs = ref_tile->mbs; ref_tile++; } tile++; } } }// for b }// for p return 0; } int ff_ivi_dec_tile_data_size(GetBitContext *gb) { int len; len = 0; if (get_bits1(gb)) { len = get_bits(gb, 8); if (len == 255) len = get_bits_long(gb, 24); } /* align the bitstream reader on the byte boundary */ align_get_bits(gb); return len; } int ff_ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile) { int mbn, blk, num_blocks, num_coeffs, blk_size, scan_pos, run, val, pos, is_intra, mc_type, mv_x, mv_y, col_mask; uint8_t col_flags[8]; int32_t prev_dc, trvec[64]; uint32_t cbp, sym, lo, hi, quant, buf_offs, q; IVIMbInfo *mb; RVMapDesc *rvmap = band->rv_map; void (*mc_with_delta_func)(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type); void (*mc_no_delta_func) (int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type); const uint8_t *base_tab, *scale_tab; prev_dc = 0; /* init intra prediction for the DC coefficient */ blk_size = band->blk_size; col_mask = blk_size - 1; /* column mask for tracking non-zero coeffs */ num_blocks = (band->mb_size != blk_size) ? 4 : 1; /* number of blocks per mb */ num_coeffs = blk_size * blk_size; if (blk_size == 8) { mc_with_delta_func = ff_ivi_mc_8x8_delta; mc_no_delta_func = ff_ivi_mc_8x8_no_delta; } else { mc_with_delta_func = ff_ivi_mc_4x4_delta; mc_no_delta_func = ff_ivi_mc_4x4_no_delta; } for (mbn = 0, mb = tile->mbs; mbn < tile->num_MBs; mb++, mbn++) { is_intra = !mb->type; cbp = mb->cbp; buf_offs = mb->buf_offs; quant = av_clip(band->glob_quant + mb->q_delta, 0, 23); base_tab = is_intra ? band->intra_base : band->inter_base; scale_tab = is_intra ? band->intra_scale : band->inter_scale; if (!is_intra) { mv_x = mb->mv_x; mv_y = mb->mv_y; if (!band->is_halfpel) { mc_type = 0; /* we have only fullpel vectors */ } else { mc_type = ((mv_y & 1) << 1) | (mv_x & 1); mv_x >>= 1; mv_y >>= 1; /* convert halfpel vectors into fullpel ones */ } } for (blk = 0; blk < num_blocks; blk++) { /* adjust block position in the buffer according to its number */ if (blk & 1) { buf_offs += blk_size; } else if (blk == 2) { buf_offs -= blk_size; buf_offs += blk_size * band->pitch; } if (cbp & 1) { /* block coded ? */ scan_pos = -1; memset(trvec, 0, num_coeffs*sizeof(trvec[0])); /* zero transform vector */ memset(col_flags, 0, sizeof(col_flags)); /* zero column flags */ while (scan_pos <= num_coeffs) { sym = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1); if (sym == rvmap->eob_sym) break; /* End of block */ if (sym == rvmap->esc_sym) { /* Escape - run/val explicitly coded using 3 vlc codes */ run = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1) + 1; lo = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1); hi = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1); val = IVI_TOSIGNED((hi << 6) | lo); /* merge them and convert into signed val */ } else { run = rvmap->runtab[sym]; val = rvmap->valtab[sym]; } /* de-zigzag and dequantize */ scan_pos += run; if (scan_pos >= num_coeffs) break; pos = band->scan[scan_pos]; if (IVI_DEBUG && !val) av_log(NULL, AV_LOG_ERROR, "Val = 0 encountered!\n"); q = (base_tab[pos] * scale_tab[quant]) >> 8; if (q > 1) val = val * q + FFSIGN(val) * ((q >> 1) - (q & 1)); trvec[pos] = val; col_flags[pos & col_mask] |= !!val; /* track columns containing non-zero coeffs */ }// while if (scan_pos >= num_coeffs && sym != rvmap->eob_sym) return -1; /* corrupt block data */ /* undoing DC coeff prediction for intra-blocks */ if (is_intra && band->is_2d_trans) { prev_dc += trvec[0]; trvec[0] = prev_dc; col_flags[0] |= !!prev_dc; } /* apply inverse transform */ band->inv_transform(trvec, band->buf + buf_offs, band->pitch, col_flags); /* apply motion compensation */ if (!is_intra) mc_with_delta_func(band->buf + buf_offs, band->ref_buf + buf_offs + mv_y * band->pitch + mv_x, band->pitch, mc_type); } else { /* block not coded */ /* for intra blocks apply the dc slant transform */ /* for inter - perform the motion compensation without delta */ if (is_intra && band->dc_transform) { band->dc_transform(&prev_dc, band->buf + buf_offs, band->pitch, blk_size); } else mc_no_delta_func(band->buf + buf_offs, band->ref_buf + buf_offs + mv_y * band->pitch + mv_x, band->pitch, mc_type); } cbp >>= 1; }// for blk }// for mbn align_get_bits(gb); return 0; } void ff_ivi_process_empty_tile(AVCodecContext *avctx, IVIBandDesc *band, IVITile *tile, int32_t mv_scale) { int x, y, need_mc, mbn, blk, num_blocks, mv_x, mv_y, mc_type; int offs, mb_offset, row_offset; IVIMbInfo *mb, *ref_mb; const int16_t *src; int16_t *dst; void (*mc_no_delta_func)(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type); offs = tile->ypos * band->pitch + tile->xpos; mb = tile->mbs; ref_mb = tile->ref_mbs; row_offset = band->mb_size * band->pitch; need_mc = 0; /* reset the mc tracking flag */ for (y = tile->ypos; y < (tile->ypos + tile->height); y += band->mb_size) { mb_offset = offs; for (x = tile->xpos; x < (tile->xpos + tile->width); x += band->mb_size) { mb->xpos = x; mb->ypos = y; mb->buf_offs = mb_offset; mb->type = 1; /* set the macroblocks type = INTER */ mb->cbp = 0; /* all blocks are empty */ if (!band->qdelta_present && !band->plane && !band->band_num) { mb->q_delta = band->glob_quant; mb->mv_x = 0; mb->mv_y = 0; } if (band->inherit_qdelta && ref_mb) mb->q_delta = ref_mb->q_delta; if (band->inherit_mv) { /* motion vector inheritance */ if (mv_scale) { mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale); mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale); } else { mb->mv_x = ref_mb->mv_x; mb->mv_y = ref_mb->mv_y; } need_mc |= mb->mv_x || mb->mv_y; /* tracking non-zero motion vectors */ } mb++; if (ref_mb) ref_mb++; mb_offset += band->mb_size; } // for x offs += row_offset; } // for y if (band->inherit_mv && need_mc) { /* apply motion compensation if there is at least one non-zero motion vector */ num_blocks = (band->mb_size != band->blk_size) ? 4 : 1; /* number of blocks per mb */ mc_no_delta_func = (band->blk_size == 8) ? ff_ivi_mc_8x8_no_delta : ff_ivi_mc_4x4_no_delta; for (mbn = 0, mb = tile->mbs; mbn < tile->num_MBs; mb++, mbn++) { mv_x = mb->mv_x; mv_y = mb->mv_y; if (!band->is_halfpel) { mc_type = 0; /* we have only fullpel vectors */ } else { mc_type = ((mv_y & 1) << 1) | (mv_x & 1); mv_x >>= 1; mv_y >>= 1; /* convert halfpel vectors into fullpel ones */ } for (blk = 0; blk < num_blocks; blk++) { /* adjust block position in the buffer according with its number */ offs = mb->buf_offs + band->blk_size * ((blk & 1) + !!(blk & 2) * band->pitch); mc_no_delta_func(band->buf + offs, band->ref_buf + offs + mv_y * band->pitch + mv_x, band->pitch, mc_type); } } } else { /* copy data from the reference tile into the current one */ src = band->ref_buf + tile->ypos * band->pitch + tile->xpos; dst = band->buf + tile->ypos * band->pitch + tile->xpos; for (y = 0; y < tile->height; y++) { memcpy(dst, src, tile->width*sizeof(band->buf[0])); src += band->pitch; dst += band->pitch; } } } #if IVI_DEBUG uint16_t ivi_calc_band_checksum (IVIBandDesc *band) { int x, y; int16_t *src, checksum; src = band->buf; checksum = 0; for (y = 0; y < band->height; src += band->pitch, y++) for (x = 0; x < band->width; x++) checksum += src[x]; return checksum; } int ivi_check_band (IVIBandDesc *band, const uint8_t *ref, int pitch) { int x, y, result; uint8_t t1, t2; int16_t *src; src = band->buf; result = 0; for (y = 0; y < band->height; src += band->pitch, y++) { for (x = 0; x < band->width; x++) { t1 = av_clip(src[x] + 128, 0, 255); t2 = ref[x]; if (t1 != t2) { av_log(NULL, AV_LOG_ERROR, "Data mismatch: row %d, column %d\n", y / band->blk_size, x / band->blk_size); result = -1; } } ref += pitch; } return result; } #endif void ff_ivi_output_plane(IVIPlaneDesc *plane, uint8_t *dst, int dst_pitch) { int x, y; const int16_t *src = plane->bands[0].buf; uint32_t pitch = plane->bands[0].pitch; for (y = 0; y < plane->height; y++) { for (x = 0; x < plane->width; x++) dst[x] = av_clip_uint8(src[x] + 128); src += pitch; dst += dst_pitch; } } /** * These are 2x8 predefined Huffman codebooks for coding macroblock/block * signals. They are specified using "huffman descriptors" in order to * avoid huge static tables. The decoding tables will be generated at * startup from these descriptors. */ const IVIHuffDesc ff_ivi_mb_huff_desc[8] = { {8, {0, 4, 5, 4, 4, 4, 6, 6}}, {12, {0, 2, 2, 3, 3, 3, 3, 5, 3, 2, 2, 2}}, {12, {0, 2, 3, 4, 3, 3, 3, 3, 4, 3, 2, 2}}, {12, {0, 3, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2}}, {13, {0, 4, 4, 3, 3, 3, 3, 2, 3, 3, 2, 1, 1}}, {9, {0, 4, 4, 4, 4, 3, 3, 3, 2}}, {10, {0, 4, 4, 4, 4, 3, 3, 2, 2, 2}}, {12, {0, 4, 4, 4, 3, 3, 2, 3, 2, 2, 2, 2}} }; const IVIHuffDesc ff_ivi_blk_huff_desc[8] = { {10, {1, 2, 3, 4, 4, 7, 5, 5, 4, 1}}, {11, {2, 3, 4, 4, 4, 7, 5, 4, 3, 3, 2}}, {12, {2, 4, 5, 5, 5, 5, 6, 4, 4, 3, 1, 1}}, {13, {3, 3, 4, 4, 5, 6, 6, 4, 4, 3, 2, 1, 1}}, {11, {3, 4, 4, 5, 5, 5, 6, 5, 4, 2, 2}}, {13, {3, 4, 5, 5, 5, 5, 6, 4, 3, 3, 2, 1, 1}}, {13, {3, 4, 5, 5, 5, 6, 5, 4, 3, 3, 2, 1, 1}}, {9, {3, 4, 4, 5, 5, 5, 6, 5, 5}} }; /** * Run-value (RLE) tables. */ const RVMapDesc ff_ivi_rvmap_tabs[9] = { { /* MapTab0 */ 5, /* eob_sym */ 2, /* esc_sym */ /* run table */ {1, 1, 0, 1, 1, 0, 1, 1, 2, 2, 1, 1, 1, 1, 3, 3, 1, 1, 2, 2, 1, 1, 4, 4, 1, 1, 1, 1, 2, 2, 5, 5, 1, 1, 3, 3, 1, 1, 6, 6, 1, 2, 1, 2, 7, 7, 1, 1, 8, 8, 1, 1, 4, 2, 1, 4, 2, 1, 3, 3, 1, 1, 1, 9, 9, 1, 2, 1, 2, 1, 5, 5, 1, 1, 10, 10, 1, 1, 3, 3, 2, 2, 1, 1, 11, 11, 6, 4, 4, 1, 6, 1, 2, 1, 2, 12, 8, 1, 12, 7, 8, 7, 1, 16, 1, 16, 1, 3, 3, 13, 1, 13, 2, 2, 1, 15, 1, 5, 14, 15, 1, 5, 14, 1, 17, 8, 17, 8, 1, 4, 4, 2, 2, 1, 25, 25, 24, 24, 1, 3, 1, 3, 1, 8, 6, 7, 6, 1, 18, 8, 18, 1, 7, 23, 2, 2, 23, 1, 1, 21, 22, 9, 9, 22, 19, 1, 21, 5, 19, 5, 1, 33, 20, 33, 20, 8, 4, 4, 1, 32, 2, 2, 8, 3, 32, 26, 3, 1, 7, 7, 26, 6, 1, 6, 1, 1, 16, 1, 10, 1, 10, 2, 16, 29, 28, 2, 29, 28, 1, 27, 5, 8, 5, 27, 1, 8, 3, 7, 3, 31, 41, 31, 1, 41, 6, 1, 6, 7, 4, 4, 1, 1, 2, 1, 2, 11, 34, 30, 11, 1, 30, 15, 15, 34, 36, 40, 36, 40, 35, 35, 37, 37, 39, 39, 38, 38}, /* value table */ { 1, -1, 0, 2, -2, 0, 3, -3, 1, -1, 4, -4, 5, -5, 1, -1, 6, -6, 2, -2, 7, -7, 1, -1, 8, -8, 9, -9, 3, -3, 1, -1, 10, -10, 2, -2, 11, -11, 1, -1, 12, 4, -12, -4, 1, -1, 13, -13, 1, -1, 14, -14, 2, 5, 15, -2, -5, -15, -3, 3, 16, -16, 17, 1, -1, -17, 6, 18, -6, -18, 2, -2, 19, -19, 1, -1, 20, -20, 4, -4, 7, -7, 21, -21, 1, -1, 2, 3, -3, 22, -2, -22, 8, 23, -8, 1, 2, -23, -1, 2, -2, -2, 24, 1, -24, -1, 25, 5, -5, 1, -25, -1, 9, -9, 26, 1, -26, 3, 1, -1, 27, -3, -1, -27, 1, 3, -1, -3, 28, -4, 4, 10, -10, -28, 1, -1, 1, -1, 29, 6, -29, -6, 30, -4, 3, 3, -3, -30, 1, 4, -1, 31, -3, 1, 11, -11, -1, -31, 32, -1, -1, 2, -2, 1, 1, -32, 1, 4, -1, -4, 33, -1, 1, 1, -1, 5, 5, -5, -33, -1, -12, 12, -5, -7, 1, 1, 7, 34, 4, -4, -1, 4, -34, -4, 35, 36, -2, -35, -2, -36, 2, 13, 2, -1, 1, -13, 1, -1, 37, 1, -5, 6, 5, -1, 38, -6, -8, 5, 8, -1, 1, 1, -37, -1, 5, 39, -5, -5, 6, -6, -38, -39, -14, 40, 14, 2, 1, 1, -2, -40, -1, -2, 2, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1} },{ /* MapTab1 */ 0, /* eob_sym */ 38, /* esc_sym */ /* run table */ {0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 8, 6, 8, 7, 7, 9, 9, 10, 10, 11, 11, 1, 12, 1, 12, 13, 13, 16, 14, 16, 14, 15, 15, 17, 17, 18, 0, 18, 19, 20, 21, 19, 22, 21, 20, 22, 25, 24, 2, 25, 24, 23, 23, 2, 26, 28, 26, 28, 29, 27, 29, 27, 33, 33, 1, 32, 1, 3, 32, 30, 36, 3, 36, 30, 31, 31, 35, 34, 37, 41, 34, 35, 37, 4, 41, 4, 49, 8, 8, 49, 40, 38, 5, 38, 40, 39, 5, 39, 42, 43, 42, 7, 57, 6, 43, 44, 6, 50, 7, 44, 57, 48, 50, 48, 45, 45, 46, 47, 51, 46, 47, 58, 1, 51, 58, 1, 52, 59, 53, 9, 52, 55, 55, 59, 53, 56, 54, 56, 54, 9, 64, 64, 60, 63, 60, 63, 61, 62, 61, 62, 2, 10, 2, 10, 11, 1, 11, 13, 12, 1, 12, 13, 16, 16, 8, 8, 14, 3, 3, 15, 14, 15, 4, 4, 1, 17, 17, 5, 1, 7, 7, 5, 6, 1, 2, 2, 6, 22, 1, 25, 21, 22, 8, 24, 1, 21, 25, 24, 8, 18, 18, 23, 9, 20, 23, 33, 29, 33, 20, 1, 19, 1, 29, 36, 9, 36, 19, 41, 28, 57, 32, 3, 28, 3, 1, 27, 49, 49, 1, 32, 26, 26, 2, 4, 4, 7, 57, 41, 2, 7, 10, 5, 37, 16, 10, 27, 8, 8, 13, 16, 37, 13, 1, 5}, /* value table */ {0, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 2, 1, -2, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 0, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 2, -1, -1, 1, -1, -2, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 3, 1, -3, 2, -1, 1, 1, -2, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 2, -1, -2, 1, 2, -2, -1, 1, 1, 2, -1, -1, 1, -2, -1, 1, 1, -1, 2, 1, 2, -1, 1, -2, -1, -2, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 4, -1, -1, -4, 1, 1, 1, 2, -1, -1, 1, -1, -1, 1, -1, -1, 1, -2, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 3, 2, -3, -2, 2, 5, -2, 2, 2, -5, -2, -2, -2, 2, -3, 3, 2, 3, -3, 2, -2, -2, 3, -3, 6, 2, -2, 3, -6, 3, -3, -3, 3, 7, -4, 4, -3, 2, -7, 2, 2, -2, -4, 2, 8, -2, -2, -2, 4, 2, -2, 2, 3, 2, -2, -2, 2, 2, -2, -8, -2, 9, -2, 2, -3, -2, 2, -2, 2, 2, 2, 4, -2, -4, 10, 2, 2, -2, -9, -2, 2, -2, 5, 4, -4, 4, -2, 2, -5, -4, -3, 4, 2, -3, 3, -2, -5, 5, 3, 3, -2, -3, -10, -4} },{ /* MapTab2 */ 2, /* eob_sym */ 11, /* esc_sym */ /* run table */ {1, 1, 0, 2, 2, 1, 1, 3, 3, 4, 4, 0, 1, 1, 5, 5, 2, 2, 6, 6, 7, 7, 1, 8, 1, 8, 3, 3, 9, 9, 1, 2, 2, 1, 4, 10, 4, 10, 11, 11, 1, 5, 12, 12, 1, 5, 13, 13, 3, 3, 6, 6, 2, 2, 14, 14, 16, 16, 15, 7, 15, 8, 8, 7, 1, 1, 17, 17, 4, 4, 1, 1, 18, 18, 2, 2, 5, 5, 25, 3, 9, 3, 25, 9, 19, 24, 19, 24, 1, 21, 20, 1, 21, 22, 20, 22, 23, 23, 8, 6, 33, 6, 8, 33, 7, 7, 26, 26, 1, 32, 1, 32, 28, 4, 28, 10, 29, 27, 27, 10, 41, 4, 29, 2, 2, 41, 36, 31, 49, 31, 34, 30, 34, 36, 30, 35, 1, 49, 11, 5, 35, 11, 1, 3, 3, 5, 37, 37, 8, 40, 8, 40, 12, 12, 42, 42, 1, 38, 16, 57, 1, 6, 16, 39, 38, 6, 7, 7, 13, 13, 39, 43, 2, 43, 57, 2, 50, 9, 44, 9, 50, 4, 15, 48, 44, 4, 1, 15, 48, 14, 14, 1, 45, 45, 8, 3, 5, 8, 51, 47, 3, 46, 46, 47, 5, 51, 1, 17, 17, 58, 1, 58, 2, 52, 52, 2, 53, 7, 59, 6, 6, 56, 53, 55, 7, 55, 1, 54, 59, 56, 54, 10, 1, 10, 4, 60, 1, 60, 8, 4, 8, 64, 64, 61, 1, 63, 3, 63, 62, 61, 5, 11, 5, 3, 11, 62}, /* value table */ { 1, -1, 0, 1, -1, 2, -2, 1, -1, 1, -1, 0, 3, -3, 1, -1, 2, -2, 1, -1, 1, -1, 4, 1, -4, -1, 2, -2, 1, -1, 5, 3, -3, -5, 2, 1, -2, -1, 1, -1, 6, 2, 1, -1, -6, -2, 1, -1, 3, -3, 2, -2, 4, -4, 1, -1, 1, -1, 1, 2, -1, 2, -2, -2, 7, -7, 1, -1, 3, -3, 8, -8, 1, -1, 5, -5, 3, -3, 1, 4, 2, -4, -1, -2, 1, 1, -1, -1, 9, 1, 1, -9, -1, 1, -1, -1, 1, -1, 3, -3, 1, 3, -3, -1, 3, -3, 1, -1, 10, 1, -10, -1, 1, 4, -1, 2, 1, -1, 1, -2, 1, -4, -1, 6, -6, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 11, -1, -2, 4, -1, 2, -11, 5, -5, -4, -1, 1, 4, 1, -4, -1, -2, 2, 1, -1, 12, 1, -2, 1, -12, 4, 2, 1, -1, -4, 4, -4, 2, -2, -1, 1, 7, -1, -1, -7, -1, -3, 1, 3, 1, 5, 2, 1, -1, -5, 13, -2, -1, 2, -2, -13, 1, -1, 5, 6, 5, -5, 1, 1, -6, 1, -1, -1, -5, -1, 14, 2, -2, 1, -14, -1, 8, 1, -1, -8, 1, 5, 1, 5, -5, 1, -1, 1, -5, -1, 15, 1, -1, -1, -1, 3, -15, -3, 6, 1, 16, -1, 6, -6, -6, 1, -1, 1, -16, 1, 7, -1, 1, -1, -6, -3, 6, -7, 3, -1} },{ /* MapTab3 */ 0, /* eob_sym */ 35, /* esc_sym */ /* run table */ {0, 1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 2, 2, 10, 10, 1, 1, 11, 11, 12, 12, 3, 3, 13, 13, 0, 14, 14, 16, 15, 16, 15, 4, 4, 17, 1, 17, 1, 5, 5, 18, 18, 2, 2, 6, 6, 8, 19, 7, 8, 7, 19, 20, 20, 21, 21, 22, 24, 22, 24, 23, 23, 1, 1, 25, 25, 3, 3, 26, 26, 9, 9, 27, 27, 28, 28, 33, 29, 4, 33, 29, 1, 4, 1, 32, 32, 2, 2, 31, 10, 30, 10, 30, 31, 34, 34, 5, 5, 36, 36, 35, 41, 35, 11, 41, 11, 37, 1, 8, 8, 37, 6, 1, 6, 40, 7, 7, 40, 12, 38, 12, 39, 39, 38, 49, 13, 49, 13, 3, 42, 3, 42, 16, 16, 43, 43, 14, 14, 1, 1, 44, 15, 44, 15, 2, 2, 57, 48, 50, 48, 57, 50, 4, 45, 45, 4, 46, 47, 47, 46, 1, 51, 1, 17, 17, 51, 8, 9, 9, 5, 58, 8, 58, 5, 52, 52, 55, 56, 53, 56, 55, 59, 59, 53, 54, 1, 6, 54, 7, 7, 6, 1, 2, 3, 2, 3, 64, 60, 60, 10, 10, 64, 61, 62, 61, 63, 1, 63, 62, 1, 18, 24, 18, 4, 25, 4, 8, 21, 21, 1, 24, 22, 25, 22, 8, 11, 19, 11, 23, 1, 20, 23, 19, 20, 5, 12, 5, 1, 16, 2, 12, 13, 2, 13, 1, 16}, /* value table */ { 0, 1, -1, 1, -1, 1, -1, 1, -1, 2, -2, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 2, -2, 1, -1, 3, -3, 1, -1, 1, -1, 2, -2, 1, -1, 0, 1, -1, 1, 1, -1, -1, 2, -2, 1, 4, -1, -4, 2, -2, 1, -1, -3, 3, 2, -2, 2, 1, 2, -2, -2, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 5, -5, 1, -1, 3, -3, 1, -1, 2, -2, 1, -1, 1, -1, 1, 1, 3, -1, -1, 6, -3, -6, -1, 1, 4, -4, 1, 2, 1, -2, -1, -1, 1, -1, 3, -3, 1, -1, 1, 1, -1, 2, -1, -2, 1, 7, -3, 3, -1, 3, -7, -3, 1, -3, 3, -1, 2, 1, -2, 1, -1, -1, 1, 2, -1, -2, -4, -1, 4, 1, 2, -2, 1, -1, -2, 2, 8, -8, -1, 2, 1, -2, -5, 5, 1, -1, -1, 1, -1, 1, 4, -1, 1, -4, -1, -1, 1, 1, 9, 1, -9, 2, -2, -1, -4, 3, -3, -4, -1, 4, 1, 4, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 10, 4, 1, 4, -4, -4, -10, 6, 5, -6, -5, 1, -1, 1, 3, -3, -1, 1, -1, -1, -1, 11, 1, 1, -11, -2, -2, 2, 5, -2, -5, -5, 2, -2, 12, 2, -2, 2, 2, 5, -3, -2, 3, -2, -12, -2, 2, 2, 2, -5, 3, 5, 13, -3, 7, -3, -3, -7, 3, -13, 3} },{ /* MapTab4 */ 0, /* eob_sym */ 34, /* esc_sym */ /* run table */ {0, 1, 1, 1, 2, 2, 1, 3, 3, 1, 1, 1, 4, 4, 1, 5, 2, 1, 5, 2, 1, 1, 6, 6, 1, 1, 1, 1, 1, 7, 3, 1, 2, 3, 0, 1, 2, 7, 1, 1, 1, 8, 1, 1, 8, 1, 1, 1, 9, 1, 9, 1, 2, 1, 1, 2, 1, 1, 10, 4, 1, 10, 1, 4, 1, 1, 1, 1, 1, 3, 1, 1, 1, 3, 2, 1, 5, 1, 1, 1, 2, 5, 1, 11, 1, 11, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 6, 1, 6, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 12, 3, 1, 12, 1, 1, 1, 2, 1, 1, 3, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 2, 1, 1, 4, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 2, 1, 1, 5, 1, 1, 1, 1, 1, 7, 1, 7, 1, 1, 2, 3, 1, 1, 1, 1, 5, 1, 1, 1, 1, 1, 1, 2, 13, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 13, 2, 1, 1, 4, 1, 1, 1, 3, 1, 6, 1, 1, 1, 14, 1, 1, 1, 1, 1, 14, 6, 1, 1, 1, 1, 15, 2, 4, 1, 2, 3, 15, 1, 1, 1, 8, 1, 1, 8, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1}, /* value table */ { 0, 1, -1, 2, 1, -1, -2, 1, -1, 3, -3, 4, 1, -1, -4, 1, 2, 5, -1, -2, -5, 6, 1, -1, -6, 7, -7, 8, -8, 1, 2, 9, 3, -2, 0, -9, -3, -1, 10, -10, 11, 1, -11, 12, -1, -12, 13, -13, 1, 14, -1, -14, 4, 15, -15, -4, 16, -16, 1, 2, 17, -1, -17, -2, 18, -18, 19, -19, 20, 3, -20, 21, -21, -3, 5, 22, 2, -22, -23, 23, -5, -2, 24, 1, -24, -1, 25, -25, 26, -26, -27, 27, 28, 29, -28, -29, 6, 30, 2, -31, -2, -30, 31, -6, -32, 32, 33, -33, 34, -35, -34, 1, 4, -36, -1, 35, 37, 36, 7, -37, 38, -4, -38, 39, 41, 40, -40, -39, 3, 42, -43, -41, -7, -42, 43, -3, 44, -44, 45, -45, 46, 47, 8, -47, -48, -46, 50, -50, 48, 49, 51, -49, 52, -52, 5, -51, -8, -53, 53, 3, -56, 56, 55, 54, -54, 2, 60, -2, -55, 58, 9, -5, 59, 57, -57, -63, -3, -58, -60, -61, 61, -59, -62, -9, 1, 64, 62, 69, -64, 63, 65, -67, -68, 66, -65, 68, -66, -69, 67, -70, -1, 10, 71, -71, 4, 73, 72, 70, 6, -76, -3, 74, -78, -74, 1, 78, 80, -72, -75, 76, -1, 3, -73, 79, 75, 77, 1, 11, -4, -79, -10, -6, -1, -77, -83, -80, 2, 81, -84, -2, 83, -81, 82, -82, 84, -87, -86, 85, -11, -85, 86, -89, 87, -88, 88, 89} },{ /* MapTab5 */ 2, /* eob_sym */ 33, /* esc_sym */ /* run table */ {1, 1, 0, 2, 1, 2, 1, 3, 3, 1, 1, 4, 4, 2, 2, 1, 1, 5, 5, 6, 1, 6, 1, 7, 7, 3, 3, 2, 8, 2, 8, 1, 1, 0, 9, 9, 1, 1, 10, 4, 10, 4, 11, 11, 2, 1, 2, 1, 12, 12, 3, 3, 1, 1, 13, 5, 5, 13, 14, 1, 1, 14, 2, 2, 6, 6, 15, 1, 1, 15, 16, 4, 7, 16, 4, 7, 1, 1, 3, 3, 8, 8, 2, 2, 1, 1, 17, 17, 1, 1, 18, 18, 5, 5, 2, 2, 1, 1, 9, 19, 9, 19, 20, 3, 3, 20, 1, 10, 21, 1, 10, 4, 4, 21, 22, 6, 6, 22, 1, 1, 23, 24, 2, 2, 23, 24, 11, 1, 1, 11, 7, 25, 7, 1, 1, 25, 8, 8, 3, 26, 3, 1, 12, 2, 2, 26, 1, 12, 5, 5, 27, 4, 1, 4, 1, 27, 28, 1, 28, 13, 1, 13, 2, 29, 2, 1, 32, 6, 1, 30, 14, 29, 14, 6, 3, 31, 3, 1, 30, 1, 32, 31, 33, 9, 33, 1, 1, 7, 9, 7, 2, 2, 1, 1, 4, 36, 34, 4, 5, 10, 10, 5, 34, 1, 1, 35, 8, 8, 36, 3, 35, 1, 15, 3, 2, 1, 16, 15, 16, 2, 37, 1, 37, 1, 1, 1, 6, 6, 38, 1, 38, 11, 1, 39, 39, 40, 11, 2, 41, 4, 40, 1, 2, 4, 1, 1, 1, 41, 3, 1, 3, 1, 5, 7, 5, 7}, /* value table */ { 1, -1, 0, 1, 2, -1, -2, 1, -1, 3, -3, 1, -1, 2, -2, 4, -4, 1, -1, 1, 5, -1, -5, 1, -1, 2, -2, 3, 1, -3, -1, 6, -6, 0, 1, -1, 7, -7, 1, 2, -1, -2, 1, -1, 4, 8, -4, -8, 1, -1, 3, -3, 9, -9, 1, 2, -2, -1, 1, 10, -10, -1, 5, -5, 2, -2, 1, 11, -11, -1, 1, 3, 2, -1, -3, -2, 12, -12, 4, -4, 2, -2, -6, 6, 13, -13, 1, -1, 14, -14, 1, -1, 3, -3, 7, -7, 15, -15, 2, 1, -2, -1, 1, 5, -5, -1, -16, 2, 1, 16, -2, 4, -4, -1, 1, 3, -3, -1, 17, -17, 1, 1, -8, 8, -1, -1, 2, 18, -18, -2, 3, 1, -3, 19, -19, -1, 3, -3, 6, 1, -6, 20, 2, 9, -9, -1, -20, -2, 4, -4, 1, -5, 21, 5, -21, -1, 1, -22, -1, 2, 22, -2, 10, 1, -10, 23, 1, 4, -23, 1, 2, -1, -2, -4, -7, 1, 7, -24, -1, 24, -1, -1, 1, 3, -1, -25, 25, 4, -3, -4, 11, -11, 26, -26, 6, 1, 1, -6, -5, -3, 3, 5, -1, -27, 27, 1, 4, -4, -1, -8, -1, 28, 2, 8, -12, -28, -2, -2, 2, 12, -1, 29, 1, -29, 30, -30, 5, -5, 1, -31, -1, 3, 31, -1, 1, 1, -3, -13, 1, -7, -1, -32, 13, 7, 32, 33, -33, -1, -9, -34, 9, 34, -6, 5, 6, -5} },{ /* MapTab6 */ 2, /* eob_sym */ 13, /* esc_sym */ /* run table */ {1, 1, 0, 1, 1, 2, 2, 1, 1, 3, 3, 1, 1, 0, 2, 2, 4, 1, 4, 1, 1, 1, 5, 5, 1, 1, 6, 6, 2, 2, 1, 1, 3, 3, 7, 7, 1, 1, 8, 8, 1, 1, 2, 2, 1, 9, 1, 9, 4, 4, 10, 1, 1, 10, 1, 1, 11, 11, 3, 3, 1, 2, 1, 2, 1, 1, 12, 12, 5, 5, 1, 1, 13, 1, 1, 13, 2, 2, 1, 1, 6, 6, 1, 1, 4, 14, 4, 14, 3, 1, 3, 1, 1, 1, 15, 7, 15, 2, 2, 7, 1, 1, 1, 8, 1, 8, 16, 16, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 3, 5, 5, 3, 4, 1, 1, 4, 1, 1, 17, 17, 9, 1, 1, 9, 2, 2, 1, 1, 10, 10, 1, 6, 1, 1, 6, 18, 1, 1, 18, 1, 1, 1, 2, 2, 3, 1, 3, 1, 1, 1, 4, 1, 19, 1, 19, 7, 1, 1, 20, 1, 4, 20, 1, 7, 11, 2, 1, 11, 21, 2, 8, 5, 1, 8, 1, 5, 21, 1, 1, 1, 22, 1, 1, 22, 1, 1, 3, 3, 1, 23, 2, 12, 24, 1, 1, 2, 1, 1, 12, 23, 1, 1, 24, 1, 1, 1, 4, 1, 1, 1, 2, 1, 6, 6, 4, 2, 1, 1, 1, 1, 1, 1, 1, 14, 13, 3, 1, 25, 9, 25, 14, 1, 9, 3, 13, 1, 1, 1, 1, 1, 10, 1, 1, 2, 10, 2}, /* value table */ {-20, -1, 0, 2, -2, 1, -1, 3, -3, 1, -1, 4, -4, 0, 2, -2, 1, 5, -1, -5, 6, -6, 1, -1, 7, -7, 1, -1, 3, -3, 8, -8, 2, -2, 1, -1, 9, -9, 1, -1, 10, -10, 4, -4, 11, 1, -11, -1, 2, -2, 1, 12, -12, -1, 13, -13, 1, -1, 3, -3, 14, 5, -14, -5, -15, 15, -1, 1, 2, -2, 16, -16, 1, 17, -17, -1, 6, -6, 18, -18, 2, -2, -19, 19, -3, 1, 3, -1, 4, 20, -4, 1, -21, 21, 1, 2, -1, -7, 7, -2, 22, -22, 23, 2, -23, -2, 1, -1, -24, 24, -25, 25, -8, -26, 26, 8, -27, 27, 5, 3, -3, -5, -4, 28, -28, 4, 29, -29, 1, -1, -2, -30, 30, 2, 9, -9, -31, 31, 2, -2, -32, 3, 32, -33, -3, 1, 33, -34, -1, 34, -35, 35, -10, 10, -6, 36, 6, -36, 37, -37, -5, 38, 1, -38, -1, 3, 39, -39, -1, 40, 5, 1, -40, -3, 2, -11, -41, -2, 1, 11, -3, -4, 41, 3, 42, 4, -1, -43, -42, 43, 1, -44, 45, -1, 44, -45, -7, 7, -46, 1, -12, 2, 1, -47, 46, 12, 47, 48, -2, -1, -48, 49, -1, -50, -49, 50, -6, -51, 51, 52, -13, 53, -4, 4, 6, 13, -53, -52, -54, 55, 54, -55, -56, -2, 2, -8, 56, 1, -3, -1, 2, 58, 3, 8, -2, 57, -58, -60, -59, -57, -3, 60, 59, -14, 3, 14} },{ /* MapTab7 */ 2, /* eob_sym */ 38, /* esc_sym */ /* run table */ {1, 1, 0, 2, 2, 1, 1, 3, 3, 4, 4, 5, 5, 1, 1, 6, 6, 2, 2, 7, 7, 8, 8, 1, 1, 3, 3, 9, 9, 10, 10, 1, 1, 2, 2, 4, 4, 11, 0, 11, 12, 12, 13, 13, 1, 1, 5, 5, 14, 14, 15, 16, 15, 16, 3, 3, 1, 6, 1, 6, 2, 2, 7, 7, 8, 8, 17, 17, 1, 1, 4, 4, 18, 18, 2, 2, 1, 19, 1, 20, 19, 20, 21, 21, 3, 3, 22, 22, 5, 5, 24, 1, 1, 23, 9, 23, 24, 9, 2, 2, 10, 1, 1, 10, 6, 6, 25, 4, 4, 25, 7, 7, 26, 8, 1, 8, 3, 1, 26, 3, 11, 11, 27, 27, 2, 28, 1, 2, 28, 1, 12, 12, 5, 5, 29, 13, 13, 29, 32, 1, 1, 33, 31, 30, 32, 4, 30, 33, 4, 31, 3, 14, 1, 1, 3, 34, 34, 2, 2, 14, 6, 6, 35, 36, 35, 36, 1, 15, 1, 16, 16, 15, 7, 9, 7, 9, 37, 8, 8, 37, 1, 1, 39, 2, 38, 39, 2, 40, 5, 38, 40, 5, 3, 3, 4, 4, 10, 10, 1, 1, 1, 1, 41, 2, 41, 2, 6, 6, 1, 1, 11, 42, 11, 43, 3, 42, 3, 17, 4, 43, 1, 17, 7, 1, 8, 44, 4, 7, 44, 5, 8, 2, 5, 1, 2, 48, 45, 1, 12, 45, 12, 48, 13, 13, 1, 9, 9, 46, 1, 46, 47, 47, 49, 18, 18, 49}, /* value table */ { 1, -1, 0, 1, -1, 2, -2, 1, -1, 1, -1, 1, -1, 3, -3, 1, -1, -2, 2, 1, -1, 1, -1, 4, -4, -2, 2, 1, -1, 1, -1, 5, -5, -3, 3, 2, -2, 1, 0, -1, 1, -1, 1, -1, 6, -6, 2, -2, 1, -1, 1, 1, -1, -1, -3, 3, 7, 2, -7, -2, -4, 4, 2, -2, 2, -2, 1, -1, 8, -8, 3, -3, 1, -1, -5, 5, 9, 1, -9, 1, -1, -1, 1, -1, -4, 4, 1, -1, 3, -3, 1, -10, 10, 1, 2, -1, -1, -2, 6, -6, 2, 11, -11, -2, 3, -3, 1, -4, 4, -1, 3, -3, 1, 3, 12, -3, -5, -12, -1, 5, 2, -2, 1, -1, -7, 1, 13, 7, -1, -13, 2, -2, 4, -4, 1, 2, -2, -1, 1, 14, -14, 1, 1, 1, -1, -5, -1, -1, 5, -1, -6, 2, -15, 15, 6, 1, -1, -8, 8, -2, -4, 4, 1, 1, -1, -1, 16, 2, -16, -2, 2, -2, 4, 3, -4, -3, -1, -4, 4, 1, -17, 17, -1, -9, 1, 1, 9, 1, -5, -1, -1, 5, -7, 7, 6, -6, 3, -3, 18, -18, 19, -19, 1, -10, -1, 10, -5, 5, 20, -20, -3, 1, 3, 1, 8, -1, -8, 2, 7, -1, -21, -2, 5, 21, 5, -1, -7, -5, 1, -6, -5, -11, 6, 22, 11, 1, 1, -22, -3, -1, 3, -1, 3, -3, -23, 4, -4, 1, 23, -1, 1, -1, 1, -2, 2, -1} },{ /* MapTab8 */ 4, /* eob_sym */ 11, /* esc_sym */ /* run table */ {1, 1, 1, 1, 0, 2, 2, 1, 1, 3, 3, 0, 1, 1, 2, 2, 4, 4, 1, 1, 5, 5, 1, 1, 2, 2, 3, 3, 6, 6, 1, 1, 7, 7, 8, 1, 8, 2, 2, 1, 4, 4, 1, 3, 1, 3, 9, 9, 2, 2, 1, 5, 1, 5, 10, 10, 1, 1, 11, 11, 3, 6, 3, 4, 4, 6, 2, 2, 1, 12, 1, 12, 7, 13, 7, 13, 1, 1, 8, 8, 2, 2, 14, 14, 16, 15, 16, 5, 5, 1, 3, 15, 1, 3, 4, 4, 1, 1, 17, 17, 2, 2, 6, 6, 1, 18, 1, 18, 22, 21, 22, 21, 25, 24, 25, 19, 9, 20, 9, 23, 19, 24, 20, 3, 23, 7, 3, 1, 1, 7, 28, 26, 29, 5, 28, 26, 5, 8, 29, 4, 8, 27, 2, 2, 4, 27, 1, 1, 10, 36, 10, 33, 33, 36, 30, 1, 32, 32, 1, 30, 6, 31, 31, 35, 3, 6, 11, 11, 3, 2, 35, 2, 34, 1, 34, 1, 37, 37, 12, 7, 12, 5, 41, 5, 4, 7, 1, 8, 13, 4, 1, 41, 13, 38, 8, 38, 9, 1, 40, 40, 9, 1, 39, 2, 2, 49, 39, 42, 3, 3, 14, 16, 49, 14, 16, 42, 43, 43, 6, 6, 15, 1, 1, 15, 44, 44, 1, 1, 50, 48, 4, 5, 4, 7, 5, 2, 10, 10, 48, 7, 50, 45, 2, 1, 45, 8, 8, 1, 46, 46, 3, 47, 47, 3, 1, 1}, /* value table */ { 1, -1, 2, -2, 0, 1, -1, 3, -3, 1, -1, 0, 4, -4, 2, -2, 1, -1, 5, -5, 1, -1, 6, -6, 3, -3, 2, -2, 1, -1, 7, -7, 1, -1, 1, 8, -1, 4, -4, -8, 2, -2, 9, 3, -9, -3, 1, -1, 5, -5, 10, 2, -10, -2, 1, -1, 11, -11, 1, -1, -4, 2, 4, 3, -3, -2, 6, -6, 12, 1, -12, -1, 2, 1, -2, -1, 13, -13, 2, -2, 7, -7, 1, -1, 1, 1, -1, 3, -3, 14, 5, -1, -14, -5, 4, -4, 15, -15, 1, -1, 8, -8, -3, 3, 16, 1, -16, -1, 1, 1, -1, -1, 1, 1, -1, 1, 2, 1, -2, 1, -1, -1, -1, 6, -1, 3, -6, 17, -17, -3, 1, 1, 1, 4, -1, -1, -4, 3, -1, 5, -3, -1, -9, 9, -5, 1, 18, -18, 2, 1, -2, 1, -1, -1, 1, 19, -1, 1, -19, -1, 4, 1, -1, 1, 7, -4, -2, 2, -7, 10, -1, -10, 1, 20, -1, -20, 1, -1, 2, 4, -2, 5, 1, -5, 6, -4, 21, 4, 2, -6, -21, -1, -2, 1, -4, -1, -3, 22, -1, 1, 3, -22, -1, 11, -11, 1, 1, 1, 8, -8, 2, 2, -1, -2, -2, -1, 1, -1, -5, 5, 2, 23, -23, -2, 1, -1, 24, -24, -1, -1, 7, 6, -7, 5, -6, 12, -3, 3, 1, -5, 1, 1, -12, 25, -1, -5, 5, -25, -1, 1, 9, 1, -1, -9, 26, -26} } };
123linslouis-android-video-cutter
jni/libavcodec/ivi_common.c
C
asf20
46,119
/* * gain code, gain pitch and pitch delay decoding * * Copyright (c) 2008 Vladimir Voroshilov * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AVCODEC_ACELP_PITCH_DELAY_H #define AVCODEC_ACELP_PITCH_DELAY_H #include <stdint.h> #include "dsputil.h" #define PITCH_DELAY_MIN 20 #define PITCH_DELAY_MAX 143 /** * \brief Decode pitch delay of the first subframe encoded by 8 bits with 1/3 * resolution. * \param ac_index adaptive codebook index (8 bits) * * \return pitch delay in 1/3 units * * Pitch delay is coded: * with 1/3 resolution, 19 < pitch_delay < 85 * integers only, 85 <= pitch_delay <= 143 */ int ff_acelp_decode_8bit_to_1st_delay3(int ac_index); /** * \brief Decode pitch delay of the second subframe encoded by 5 or 6 bits * with 1/3 precision. * \param ac_index adaptive codebook index (5 or 6 bits) * \param pitch_delay_min lower bound (integer) of pitch delay interval * for second subframe * * \return pitch delay in 1/3 units * * Pitch delay is coded: * with 1/3 resolution, -6 < pitch_delay - int(prev_pitch_delay) < 5 * * \remark The routine is used in G.729 @8k, AMR @10.2k, AMR @7.95k, * AMR @7.4k for the second subframe. */ int ff_acelp_decode_5_6_bit_to_2nd_delay3( int ac_index, int pitch_delay_min); /** * \brief Decode pitch delay with 1/3 precision. * \param ac_index adaptive codebook index (4 bits) * \param pitch_delay_min lower bound (integer) of pitch delay interval for * second subframe * * \return pitch delay in 1/3 units * * Pitch delay is coded: * integers only, -6 < pitch_delay - int(prev_pitch_delay) <= -2 * with 1/3 resolution, -2 < pitch_delay - int(prev_pitch_delay) < 1 * integers only, 1 <= pitch_delay - int(prev_pitch_delay) < 5 * * \remark The routine is used in G.729 @6.4k, AMR @6.7k, AMR @5.9k, * AMR @5.15k, AMR @4.75k for the second subframe. */ int ff_acelp_decode_4bit_to_2nd_delay3( int ac_index, int pitch_delay_min); /** * \brief Decode pitch delay of the first subframe encoded by 9 bits * with 1/6 precision. * \param ac_index adaptive codebook index (9 bits) * \param pitch_delay_min lower bound (integer) of pitch delay interval for * second subframe * * \return pitch delay in 1/6 units * * Pitch delay is coded: * with 1/6 resolution, 17 < pitch_delay < 95 * integers only, 95 <= pitch_delay <= 143 * * \remark The routine is used in AMR @12.2k for the first and third subframes. */ int ff_acelp_decode_9bit_to_1st_delay6(int ac_index); /** * \brief Decode pitch delay of the second subframe encoded by 6 bits * with 1/6 precision. * \param ac_index adaptive codebook index (6 bits) * \param pitch_delay_min lower bound (integer) of pitch delay interval for * second subframe * * \return pitch delay in 1/6 units * * Pitch delay is coded: * with 1/6 resolution, -6 < pitch_delay - int(prev_pitch_delay) < 5 * * \remark The routine is used in AMR @12.2k for the second and fourth subframes. */ int ff_acelp_decode_6bit_to_2nd_delay6( int ac_index, int pitch_delay_min); /** * \brief Update past quantized energies * \param quant_energy [in/out] past quantized energies (5.10) * \param gain_corr_factor gain correction factor * \param log2_ma_pred_order log2() of MA prediction order * \param erasure frame erasure flag * * If frame erasure flag is not equal to zero, memory is updated with * averaged energy, attenuated by 4dB: * max(avg(quant_energy[i])-4, -14), i=0,ma_pred_order * * In normal mode memory is updated with * Er - Ep = 20 * log10(gain_corr_factor) * * \remark The routine is used in G.729 and AMR (all modes). */ void ff_acelp_update_past_gain( int16_t* quant_energy, int gain_corr_factor, int log2_ma_pred_order, int erasure); /** * \brief Decode the adaptive codebook gain and add * correction (4.1.5 and 3.9.1 of G.729). * \param dsp initialized dsputil context * \param gain_corr_factor gain correction factor (2.13) * \param fc_v fixed-codebook vector (2.13) * \param mr_energy mean innovation energy and fixed-point correction (7.13) * \param quant_energy [in/out] past quantized energies (5.10) * \param subframe_size length of subframe * \param ma_pred_order MA prediction order * * \return quantized fixed-codebook gain (14.1) * * The routine implements equations 69, 66 and 71 of the G.729 specification (3.9.1) * * Em - mean innovation energy (dB, constant, depends on decoding algorithm) * Ep - mean-removed predicted energy (dB) * Er - mean-removed innovation energy (dB) * Ei - mean energy of the fixed-codebook contribution (dB) * N - subframe_size * M - MA (Moving Average) prediction order * gc - fixed-codebook gain * gc_p - predicted fixed-codebook gain * * Fixed codebook gain is computed using predicted gain gc_p and * correction factor gain_corr_factor as shown below: * * gc = gc_p * gain_corr_factor * * The predicted fixed codebook gain gc_p is found by predicting * the energy of the fixed-codebook contribution from the energy * of previous fixed-codebook contributions. * * mean = 1/N * sum(i,0,N){ fc_v[i] * fc_v[i] } * * Ei = 10log(mean) * * Er = 10log(1/N * gc^2 * mean) - Em = 20log(gc) + Ei - Em * * Replacing Er with Ep and gc with gc_p we will receive: * * Ep = 10log(1/N * gc_p^2 * mean) - Em = 20log(gc_p) + Ei - Em * * and from above: * * gc_p = 10^((Ep - Ei + Em) / 20) * * Ep is predicted using past energies and prediction coefficients: * * Ep = sum(i,0,M){ ma_prediction_coeff[i] * quant_energy[i] } * * gc_p in fixed-point arithmetic is calculated as following: * * mean = 1/N * sum(i,0,N){ (fc_v[i] / 2^13) * (fc_v[i] / 2^13) } = * = 1/N * sum(i,0,N) { fc_v[i] * fc_v[i] } / 2^26 * * Ei = 10log(mean) = -10log(N) - 10log(2^26) + * + 10log(sum(i,0,N) { fc_v[i] * fc_v[i] }) * * Ep - Ei + Em = Ep + Em + 10log(N) + 10log(2^26) - * - 10log(sum(i,0,N) { fc_v[i] * fc_v[i] }) = * = Ep + mr_energy - 10log(sum(i,0,N) { fc_v[i] * fc_v[i] }) * * gc_p = 10 ^ ((Ep - Ei + Em) / 20) = * = 2 ^ (3.3219 * (Ep - Ei + Em) / 20) = 2 ^ (0.166 * (Ep - Ei + Em)) * * where * * mr_energy = Em + 10log(N) + 10log(2^26) * * \remark The routine is used in G.729 and AMR (all modes). */ int16_t ff_acelp_decode_gain_code( DSPContext *dsp, int gain_corr_factor, const int16_t* fc_v, int mr_energy, const int16_t* quant_energy, const int16_t* ma_prediction_coeff, int subframe_size, int max_pred_order); /** * Calculate fixed gain (part of section 6.1.3 of AMR spec) * * @param fixed_gain_factor gain correction factor * @param fixed_energy decoded algebraic codebook vector energy * @param prediction_error vector of the quantified predictor errors of * the four previous subframes. It is updated by this function. * @param energy_mean desired mean innovation energy * @param pred_table table of four moving average coefficients */ float ff_amr_set_fixed_gain(float fixed_gain_factor, float fixed_mean_energy, float *prediction_error, float energy_mean, const float *pred_table); /** * Decode the adaptive codebook index to the integer and fractional parts * of the pitch lag for one subframe at 1/3 fractional precision. * * The choice of pitch lag is described in 3GPP TS 26.090 section 5.6.1. * * @param lag_int integer part of pitch lag of the current subframe * @param lag_frac fractional part of pitch lag of the current subframe * @param pitch_index parsed adaptive codebook (pitch) index * @param prev_lag_int integer part of pitch lag for the previous subframe * @param subframe current subframe number * @param third_as_first treat the third frame the same way as the first */ void ff_decode_pitch_lag(int *lag_int, int *lag_frac, int pitch_index, const int prev_lag_int, const int subframe, int third_as_first, int resolution); #endif /* AVCODEC_ACELP_PITCH_DELAY_H */
123linslouis-android-video-cutter
jni/libavcodec/acelp_pitch_delay.h
C
asf20
9,201
/* * Electronic Arts CMV Video Decoder * Copyright (c) 2007-2008 Peter Ross * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * Electronic Arts CMV Video Decoder * by Peter Ross (pross@xvid.org) * * Technical details here: * http://wiki.multimedia.cx/index.php?title=Electronic_Arts_CMV */ #include "libavutil/intreadwrite.h" #include "avcodec.h" typedef struct CmvContext { AVCodecContext *avctx; AVFrame frame; ///< current AVFrame last_frame; ///< last AVFrame last2_frame; ///< second-last int width, height; unsigned int palette[AVPALETTE_COUNT]; } CmvContext; static av_cold int cmv_decode_init(AVCodecContext *avctx){ CmvContext *s = avctx->priv_data; s->avctx = avctx; avctx->pix_fmt = PIX_FMT_PAL8; return 0; } static void cmv_decode_intra(CmvContext * s, const uint8_t *buf, const uint8_t *buf_end){ unsigned char *dst = s->frame.data[0]; int i; for (i=0; i < s->avctx->height && buf+s->avctx->width<=buf_end; i++) { memcpy(dst, buf, s->avctx->width); dst += s->frame.linesize[0]; buf += s->avctx->width; } } static void cmv_motcomp(unsigned char *dst, int dst_stride, const unsigned char *src, int src_stride, int x, int y, int xoffset, int yoffset, int width, int height){ int i,j; for(j=y;j<y+4;j++) for(i=x;i<x+4;i++) { if (i+xoffset>=0 && i+xoffset<width && j+yoffset>=0 && j+yoffset<height) { dst[j*dst_stride + i] = src[(j+yoffset)*src_stride + i+xoffset]; }else{ dst[j*dst_stride + i] = 0; } } } static void cmv_decode_inter(CmvContext * s, const uint8_t *buf, const uint8_t *buf_end){ const uint8_t *raw = buf + (s->avctx->width*s->avctx->height/16); int x,y,i; i = 0; for(y=0; y<s->avctx->height/4; y++) for(x=0; x<s->avctx->width/4 && buf+i<buf_end; x++) { if (buf[i]==0xFF) { unsigned char *dst = s->frame.data[0] + (y*4)*s->frame.linesize[0] + x*4; if (raw+16<buf_end && *raw==0xFF) { /* intra */ raw++; memcpy(dst, raw, 4); memcpy(dst+s->frame.linesize[0], raw+4, 4); memcpy(dst+2*s->frame.linesize[0], raw+8, 4); memcpy(dst+3*s->frame.linesize[0], raw+12, 4); raw+=16; }else if(raw<buf_end) { /* inter using second-last frame as reference */ int xoffset = (*raw & 0xF) - 7; int yoffset = ((*raw >> 4)) - 7; cmv_motcomp(s->frame.data[0], s->frame.linesize[0], s->last2_frame.data[0], s->last2_frame.linesize[0], x*4, y*4, xoffset, yoffset, s->avctx->width, s->avctx->height); raw++; } }else{ /* inter using last frame as reference */ int xoffset = (buf[i] & 0xF) - 7; int yoffset = ((buf[i] >> 4)) - 7; cmv_motcomp(s->frame.data[0], s->frame.linesize[0], s->last_frame.data[0], s->last_frame.linesize[0], x*4, y*4, xoffset, yoffset, s->avctx->width, s->avctx->height); } i++; } } static void cmv_process_header(CmvContext *s, const uint8_t *buf, const uint8_t *buf_end) { int pal_start, pal_count, i; if(buf+16>=buf_end) { av_log(s->avctx, AV_LOG_WARNING, "truncated header\n"); return; } s->width = AV_RL16(&buf[4]); s->height = AV_RL16(&buf[6]); if (s->avctx->width!=s->width || s->avctx->height!=s->height) avcodec_set_dimensions(s->avctx, s->width, s->height); s->avctx->time_base.num = 1; s->avctx->time_base.den = AV_RL16(&buf[10]); pal_start = AV_RL16(&buf[12]); pal_count = AV_RL16(&buf[14]); buf += 16; for (i=pal_start; i<pal_start+pal_count && i<AVPALETTE_COUNT && buf+2<buf_end; i++) { s->palette[i] = AV_RB24(buf); buf += 3; } } #define EA_PREAMBLE_SIZE 8 #define MVIh_TAG MKTAG('M', 'V', 'I', 'h') static int cmv_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; CmvContext *s = avctx->priv_data; const uint8_t *buf_end = buf + buf_size; if (AV_RL32(buf)==MVIh_TAG||AV_RB32(buf)==MVIh_TAG) { cmv_process_header(s, buf+EA_PREAMBLE_SIZE, buf_end); return buf_size; } if (avcodec_check_dimensions(s->avctx, s->width, s->height)) return -1; /* shuffle */ if (s->last2_frame.data[0]) avctx->release_buffer(avctx, &s->last2_frame); FFSWAP(AVFrame, s->last_frame, s->last2_frame); FFSWAP(AVFrame, s->frame, s->last_frame); s->frame.reference = 1; s->frame.buffer_hints = FF_BUFFER_HINTS_VALID; if (avctx->get_buffer(avctx, &s->frame)<0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } memcpy(s->frame.data[1], s->palette, AVPALETTE_SIZE); buf += EA_PREAMBLE_SIZE; if ((buf[0]&1)) { // subtype cmv_decode_inter(s, buf+2, buf_end); s->frame.key_frame = 0; s->frame.pict_type = FF_P_TYPE; }else{ s->frame.key_frame = 1; s->frame.pict_type = FF_I_TYPE; cmv_decode_intra(s, buf+2, buf_end); } *data_size = sizeof(AVFrame); *(AVFrame*)data = s->frame; return buf_size; } static av_cold int cmv_decode_end(AVCodecContext *avctx){ CmvContext *s = avctx->priv_data; if (s->frame.data[0]) s->avctx->release_buffer(avctx, &s->frame); if (s->last_frame.data[0]) s->avctx->release_buffer(avctx, &s->last_frame); if (s->last2_frame.data[0]) s->avctx->release_buffer(avctx, &s->last2_frame); return 0; } AVCodec eacmv_decoder = { "eacmv", AVMEDIA_TYPE_VIDEO, CODEC_ID_CMV, sizeof(CmvContext), cmv_decode_init, NULL, cmv_decode_end, cmv_decode_frame, CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Electronic Arts CMV video"), };
123linslouis-android-video-cutter
jni/libavcodec/eacmv.c
C
asf20
6,915
/* * Copyright (c) 2008 Siarhei Siamashka <ssvb@users.sourceforge.net> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "libavcodec/dsputil.h" #include "dsputil_arm.h" void ff_vector_fmul_vfp(float *dst, const float *src, int len); void ff_vector_fmul_reverse_vfp(float *dst, const float *src0, const float *src1, int len); void ff_float_to_int16_vfp(int16_t *dst, const float *src, long len); void ff_dsputil_init_vfp(DSPContext* c, AVCodecContext *avctx) { c->vector_fmul = ff_vector_fmul_vfp; c->vector_fmul_reverse = ff_vector_fmul_reverse_vfp; #if HAVE_ARMV6 c->float_to_int16 = ff_float_to_int16_vfp; #endif }
123linslouis-android-video-cutter
jni/libavcodec/arm/dsputil_init_vfp.c
C
asf20
1,387
/* * ARM NEON IDCT * * Copyright (c) 2008 Mans Rullgard <mans@mansr.com> * * Based on Simple IDCT * Copyright (c) 2001 Michael Niedermayer <michaelni@gmx.at> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "asm.S" #define W1 22725 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 #define W2 21407 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 #define W3 19266 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 #define W4 16383 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 #define W5 12873 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 #define W6 8867 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 #define W7 4520 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 #define W4c ((1<<(COL_SHIFT-1))/W4) #define ROW_SHIFT 11 #define COL_SHIFT 20 #define w1 d0[0] #define w2 d0[1] #define w3 d0[2] #define w4 d0[3] #define w5 d1[0] #define w6 d1[1] #define w7 d1[2] #define w4c d1[3] .macro idct_col4_top vmull.s16 q7, d6, w2 /* q9 = W2 * col[2] */ vmull.s16 q8, d6, w6 /* q10 = W6 * col[2] */ vmull.s16 q9, d4, w1 /* q9 = W1 * col[1] */ vadd.i32 q11, q15, q7 vmull.s16 q10, d4, w3 /* q10 = W3 * col[1] */ vadd.i32 q12, q15, q8 vmull.s16 q5, d4, w5 /* q5 = W5 * col[1] */ vsub.i32 q13, q15, q8 vmull.s16 q6, d4, w7 /* q6 = W7 * col[1] */ vsub.i32 q14, q15, q7 vmlal.s16 q9, d8, w3 /* q9 += W3 * col[3] */ vmlsl.s16 q10, d8, w7 /* q10 -= W7 * col[3] */ vmlsl.s16 q5, d8, w1 /* q5 -= W1 * col[3] */ vmlsl.s16 q6, d8, w5 /* q6 -= W5 * col[3] */ .endm .text .align 6 function idct_row4_pld_neon pld [r0] add r3, r0, r1, lsl #2 pld [r0, r1] pld [r0, r1, lsl #1] pld [r3, -r1] pld [r3] pld [r3, r1] add r3, r3, r1, lsl #1 pld [r3] pld [r3, r1] endfunc function idct_row4_neon vmov.i32 q15, #(1<<(ROW_SHIFT-1)) vld1.64 {d2-d5}, [r2,:128]! vmlal.s16 q15, d2, w4 /* q15 += W4 * col[0] */ vld1.64 {d6,d7}, [r2,:128]! vorr d10, d3, d5 vld1.64 {d8,d9}, [r2,:128]! add r2, r2, #-64 vorr d11, d7, d9 vorr d10, d10, d11 vmov r3, r4, d10 idct_col4_top orrs r3, r3, r4 beq 1f vmull.s16 q7, d3, w4 /* q7 = W4 * col[4] */ vmlal.s16 q9, d5, w5 /* q9 += W5 * col[5] */ vmlsl.s16 q10, d5, w1 /* q10 -= W1 * col[5] */ vmull.s16 q8, d7, w2 /* q8 = W2 * col[6] */ vmlal.s16 q5, d5, w7 /* q5 += W7 * col[5] */ vadd.i32 q11, q11, q7 vsub.i32 q12, q12, q7 vsub.i32 q13, q13, q7 vadd.i32 q14, q14, q7 vmlal.s16 q6, d5, w3 /* q6 += W3 * col[5] */ vmull.s16 q7, d7, w6 /* q7 = W6 * col[6] */ vmlal.s16 q9, d9, w7 vmlsl.s16 q10, d9, w5 vmlal.s16 q5, d9, w3 vmlsl.s16 q6, d9, w1 vadd.i32 q11, q11, q7 vsub.i32 q12, q12, q8 vadd.i32 q13, q13, q8 vsub.i32 q14, q14, q7 1: vadd.i32 q3, q11, q9 vadd.i32 q4, q12, q10 vshrn.i32 d2, q3, #ROW_SHIFT vshrn.i32 d4, q4, #ROW_SHIFT vadd.i32 q7, q13, q5 vadd.i32 q8, q14, q6 vtrn.16 d2, d4 vshrn.i32 d6, q7, #ROW_SHIFT vshrn.i32 d8, q8, #ROW_SHIFT vsub.i32 q14, q14, q6 vsub.i32 q11, q11, q9 vtrn.16 d6, d8 vsub.i32 q13, q13, q5 vshrn.i32 d3, q14, #ROW_SHIFT vtrn.32 d2, d6 vsub.i32 q12, q12, q10 vtrn.32 d4, d8 vshrn.i32 d5, q13, #ROW_SHIFT vshrn.i32 d7, q12, #ROW_SHIFT vshrn.i32 d9, q11, #ROW_SHIFT vtrn.16 d3, d5 vtrn.16 d7, d9 vtrn.32 d3, d7 vtrn.32 d5, d9 vst1.64 {d2-d5}, [r2,:128]! vst1.64 {d6-d9}, [r2,:128]! bx lr endfunc function idct_col4_neon mov ip, #16 vld1.64 {d2}, [r2,:64], ip /* d2 = col[0] */ vdup.16 d30, w4c vld1.64 {d4}, [r2,:64], ip /* d3 = col[1] */ vadd.i16 d30, d30, d2 vld1.64 {d6}, [r2,:64], ip /* d4 = col[2] */ vmull.s16 q15, d30, w4 /* q15 = W4*(col[0]+(1<<COL_SHIFT-1)/W4)*/ vld1.64 {d8}, [r2,:64], ip /* d5 = col[3] */ ldrd r4, [r2] ldrd r6, [r2, #16] orrs r4, r4, r5 idct_col4_top addeq r2, r2, #16 beq 1f vld1.64 {d3}, [r2,:64], ip /* d6 = col[4] */ vmull.s16 q7, d3, w4 /* q7 = W4 * col[4] */ vadd.i32 q11, q11, q7 vsub.i32 q12, q12, q7 vsub.i32 q13, q13, q7 vadd.i32 q14, q14, q7 1: orrs r6, r6, r7 ldrd r4, [r2, #16] addeq r2, r2, #16 beq 2f vld1.64 {d5}, [r2,:64], ip /* d7 = col[5] */ vmlal.s16 q9, d5, w5 /* q9 += W5 * col[5] */ vmlsl.s16 q10, d5, w1 /* q10 -= W1 * col[5] */ vmlal.s16 q5, d5, w7 /* q5 += W7 * col[5] */ vmlal.s16 q6, d5, w3 /* q6 += W3 * col[5] */ 2: orrs r4, r4, r5 ldrd r4, [r2, #16] addeq r2, r2, #16 beq 3f vld1.64 {d7}, [r2,:64], ip /* d8 = col[6] */ vmull.s16 q7, d7, w6 /* q7 = W6 * col[6] */ vmull.s16 q8, d7, w2 /* q8 = W2 * col[6] */ vadd.i32 q11, q11, q7 vsub.i32 q14, q14, q7 vsub.i32 q12, q12, q8 vadd.i32 q13, q13, q8 3: orrs r4, r4, r5 addeq r2, r2, #16 beq 4f vld1.64 {d9}, [r2,:64], ip /* d9 = col[7] */ vmlal.s16 q9, d9, w7 vmlsl.s16 q10, d9, w5 vmlal.s16 q5, d9, w3 vmlsl.s16 q6, d9, w1 4: vaddhn.i32 d2, q11, q9 vaddhn.i32 d3, q12, q10 vaddhn.i32 d4, q13, q5 vaddhn.i32 d5, q14, q6 vsubhn.i32 d9, q11, q9 vsubhn.i32 d8, q12, q10 vsubhn.i32 d7, q13, q5 vsubhn.i32 d6, q14, q6 bx lr endfunc .align 6 function idct_col4_st8_neon vqshrun.s16 d2, q1, #COL_SHIFT-16 vqshrun.s16 d3, q2, #COL_SHIFT-16 vqshrun.s16 d4, q3, #COL_SHIFT-16 vqshrun.s16 d5, q4, #COL_SHIFT-16 vst1.32 {d2[0]}, [r0,:32], r1 vst1.32 {d2[1]}, [r0,:32], r1 vst1.32 {d3[0]}, [r0,:32], r1 vst1.32 {d3[1]}, [r0,:32], r1 vst1.32 {d4[0]}, [r0,:32], r1 vst1.32 {d4[1]}, [r0,:32], r1 vst1.32 {d5[0]}, [r0,:32], r1 vst1.32 {d5[1]}, [r0,:32], r1 bx lr endfunc .section .rodata .align 4 idct_coeff_neon: .short W1, W2, W3, W4, W5, W6, W7, W4c .previous .macro idct_start data push {r4-r7, lr} pld [\data] pld [\data, #64] vpush {d8-d15} movrel r3, idct_coeff_neon vld1.64 {d0,d1}, [r3,:128] .endm .macro idct_end vpop {d8-d15} pop {r4-r7, pc} .endm /* void ff_simple_idct_put_neon(uint8_t *dst, int line_size, DCTELEM *data); */ function ff_simple_idct_put_neon, export=1 idct_start r2 bl idct_row4_pld_neon bl idct_row4_neon add r2, r2, #-128 bl idct_col4_neon bl idct_col4_st8_neon sub r0, r0, r1, lsl #3 add r0, r0, #4 add r2, r2, #-120 bl idct_col4_neon bl idct_col4_st8_neon idct_end endfunc .align 6 function idct_col4_add8_neon mov ip, r0 vld1.32 {d10[0]}, [r0,:32], r1 vshr.s16 q1, q1, #COL_SHIFT-16 vld1.32 {d10[1]}, [r0,:32], r1 vshr.s16 q2, q2, #COL_SHIFT-16 vld1.32 {d11[0]}, [r0,:32], r1 vshr.s16 q3, q3, #COL_SHIFT-16 vld1.32 {d11[1]}, [r0,:32], r1 vshr.s16 q4, q4, #COL_SHIFT-16 vld1.32 {d12[0]}, [r0,:32], r1 vaddw.u8 q1, q1, d10 vld1.32 {d12[1]}, [r0,:32], r1 vaddw.u8 q2, q2, d11 vld1.32 {d13[0]}, [r0,:32], r1 vqmovun.s16 d2, q1 vld1.32 {d13[1]}, [r0,:32], r1 vaddw.u8 q3, q3, d12 vst1.32 {d2[0]}, [ip,:32], r1 vqmovun.s16 d3, q2 vst1.32 {d2[1]}, [ip,:32], r1 vaddw.u8 q4, q4, d13 vst1.32 {d3[0]}, [ip,:32], r1 vqmovun.s16 d4, q3 vst1.32 {d3[1]}, [ip,:32], r1 vqmovun.s16 d5, q4 vst1.32 {d4[0]}, [ip,:32], r1 vst1.32 {d4[1]}, [ip,:32], r1 vst1.32 {d5[0]}, [ip,:32], r1 vst1.32 {d5[1]}, [ip,:32], r1 bx lr endfunc /* void ff_simple_idct_add_neon(uint8_t *dst, int line_size, DCTELEM *data); */ function ff_simple_idct_add_neon, export=1 idct_start r2 bl idct_row4_pld_neon bl idct_row4_neon add r2, r2, #-128 bl idct_col4_neon bl idct_col4_add8_neon sub r0, r0, r1, lsl #3 add r0, r0, #4 add r2, r2, #-120 bl idct_col4_neon bl idct_col4_add8_neon idct_end endfunc .align 6 function idct_col4_st16_neon mov ip, #16 vshr.s16 q1, q1, #COL_SHIFT-16 vshr.s16 q2, q2, #COL_SHIFT-16 vst1.64 {d2}, [r2,:64], ip vshr.s16 q3, q3, #COL_SHIFT-16 vst1.64 {d3}, [r2,:64], ip vshr.s16 q4, q4, #COL_SHIFT-16 vst1.64 {d4}, [r2,:64], ip vst1.64 {d5}, [r2,:64], ip vst1.64 {d6}, [r2,:64], ip vst1.64 {d7}, [r2,:64], ip vst1.64 {d8}, [r2,:64], ip vst1.64 {d9}, [r2,:64], ip bx lr endfunc /* void ff_simple_idct_neon(DCTELEM *data); */ function ff_simple_idct_neon, export=1 idct_start r0 mov r2, r0 bl idct_row4_neon bl idct_row4_neon add r2, r2, #-128 bl idct_col4_neon add r2, r2, #-128 bl idct_col4_st16_neon add r2, r2, #-120 bl idct_col4_neon add r2, r2, #-128 bl idct_col4_st16_neon idct_end endfunc
123linslouis-android-video-cutter
jni/libavcodec/arm/simple_idct_neon.S
Unix Assembly
asf20
12,743
/* * ARM NEON optimised DSP functions * Copyright (c) 2008 Mans Rullgard <mans@mansr.com> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <stdint.h> #include "libavcodec/avcodec.h" #include "libavcodec/dsputil.h" #include "dsputil_arm.h" void ff_simple_idct_neon(DCTELEM *data); void ff_simple_idct_put_neon(uint8_t *dest, int line_size, DCTELEM *data); void ff_simple_idct_add_neon(uint8_t *dest, int line_size, DCTELEM *data); void ff_vp3_idct_neon(DCTELEM *data); void ff_vp3_idct_put_neon(uint8_t *dest, int line_size, DCTELEM *data); void ff_vp3_idct_add_neon(uint8_t *dest, int line_size, DCTELEM *data); void ff_vp3_idct_dc_add_neon(uint8_t *dest, int line_size, const DCTELEM *data); void ff_put_pixels16_neon(uint8_t *, const uint8_t *, int, int); void ff_put_pixels16_x2_neon(uint8_t *, const uint8_t *, int, int); void ff_put_pixels16_y2_neon(uint8_t *, const uint8_t *, int, int); void ff_put_pixels16_xy2_neon(uint8_t *, const uint8_t *, int, int); void ff_put_pixels8_neon(uint8_t *, const uint8_t *, int, int); void ff_put_pixels8_x2_neon(uint8_t *, const uint8_t *, int, int); void ff_put_pixels8_y2_neon(uint8_t *, const uint8_t *, int, int); void ff_put_pixels8_xy2_neon(uint8_t *, const uint8_t *, int, int); void ff_put_pixels16_x2_no_rnd_neon(uint8_t *, const uint8_t *, int, int); void ff_put_pixels16_y2_no_rnd_neon(uint8_t *, const uint8_t *, int, int); void ff_put_pixels16_xy2_no_rnd_neon(uint8_t *, const uint8_t *, int, int); void ff_put_pixels8_x2_no_rnd_neon(uint8_t *, const uint8_t *, int, int); void ff_put_pixels8_y2_no_rnd_neon(uint8_t *, const uint8_t *, int, int); void ff_put_pixels8_xy2_no_rnd_neon(uint8_t *, const uint8_t *, int, int); void ff_avg_pixels16_neon(uint8_t *, const uint8_t *, int, int); void ff_avg_pixels8_neon(uint8_t *, const uint8_t *, int, int); void ff_add_pixels_clamped_neon(const DCTELEM *, uint8_t *, int); void ff_put_pixels_clamped_neon(const DCTELEM *, uint8_t *, int); void ff_put_signed_pixels_clamped_neon(const DCTELEM *, uint8_t *, int); void ff_put_h264_qpel16_mc00_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel16_mc10_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel16_mc20_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel16_mc30_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel16_mc01_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel16_mc11_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel16_mc21_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel16_mc31_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel16_mc02_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel16_mc12_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel16_mc22_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel16_mc32_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel16_mc03_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel16_mc13_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel16_mc23_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel16_mc33_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel8_mc00_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel8_mc10_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel8_mc20_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel8_mc30_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel8_mc01_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel8_mc11_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel8_mc21_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel8_mc31_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel8_mc02_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel8_mc12_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel8_mc22_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel8_mc32_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel8_mc03_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel8_mc13_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel8_mc23_neon(uint8_t *, uint8_t *, int); void ff_put_h264_qpel8_mc33_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel16_mc00_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel16_mc10_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel16_mc20_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel16_mc30_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel16_mc01_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel16_mc11_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel16_mc21_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel16_mc31_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel16_mc02_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel16_mc12_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel16_mc22_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel16_mc32_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel16_mc03_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel16_mc13_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel16_mc23_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel16_mc33_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel8_mc00_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel8_mc10_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel8_mc20_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel8_mc30_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel8_mc01_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel8_mc11_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel8_mc21_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel8_mc31_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel8_mc02_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel8_mc12_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel8_mc22_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel8_mc32_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel8_mc03_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel8_mc13_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel8_mc23_neon(uint8_t *, uint8_t *, int); void ff_avg_h264_qpel8_mc33_neon(uint8_t *, uint8_t *, int); void ff_put_h264_chroma_mc8_neon(uint8_t *, uint8_t *, int, int, int, int); void ff_put_h264_chroma_mc4_neon(uint8_t *, uint8_t *, int, int, int, int); void ff_put_h264_chroma_mc2_neon(uint8_t *, uint8_t *, int, int, int, int); void ff_avg_h264_chroma_mc8_neon(uint8_t *, uint8_t *, int, int, int, int); void ff_avg_h264_chroma_mc4_neon(uint8_t *, uint8_t *, int, int, int, int); void ff_avg_h264_chroma_mc2_neon(uint8_t *, uint8_t *, int, int, int, int); void ff_vp3_v_loop_filter_neon(uint8_t *, int, int *); void ff_vp3_h_loop_filter_neon(uint8_t *, int, int *); void ff_vector_fmul_neon(float *dst, const float *src, int len); void ff_vector_fmul_window_neon(float *dst, const float *src0, const float *src1, const float *win, float add_bias, int len); void ff_vector_fmul_scalar_neon(float *dst, const float *src, float mul, int len); void ff_vector_fmul_sv_scalar_2_neon(float *dst, const float *src, const float **vp, float mul, int len); void ff_vector_fmul_sv_scalar_4_neon(float *dst, const float *src, const float **vp, float mul, int len); void ff_sv_fmul_scalar_2_neon(float *dst, const float **vp, float mul, int len); void ff_sv_fmul_scalar_4_neon(float *dst, const float **vp, float mul, int len); void ff_butterflies_float_neon(float *v1, float *v2, int len); float ff_scalarproduct_float_neon(const float *v1, const float *v2, int len); void ff_int32_to_float_fmul_scalar_neon(float *dst, const int *src, float mul, int len); void ff_vector_fmul_reverse_neon(float *dst, const float *src0, const float *src1, int len); void ff_vector_fmul_add_neon(float *dst, const float *src0, const float *src1, const float *src2, int len); void ff_vector_clipf_neon(float *dst, const float *src, float min, float max, int len); void ff_float_to_int16_neon(int16_t *, const float *, long); void ff_float_to_int16_interleave_neon(int16_t *, const float **, long, int); void ff_vorbis_inverse_coupling_neon(float *mag, float *ang, int blocksize); int32_t ff_scalarproduct_int16_neon(int16_t *v1, int16_t *v2, int len, int shift); int32_t ff_scalarproduct_and_madd_int16_neon(int16_t *v1, int16_t *v2, int16_t *v3, int len, int mul); void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx) { if (!avctx->lowres) { if (avctx->idct_algo == FF_IDCT_AUTO || avctx->idct_algo == FF_IDCT_SIMPLENEON) { c->idct_put = ff_simple_idct_put_neon; c->idct_add = ff_simple_idct_add_neon; c->idct = ff_simple_idct_neon; c->idct_permutation_type = FF_PARTTRANS_IDCT_PERM; } else if ((CONFIG_VP3_DECODER || CONFIG_VP5_DECODER || CONFIG_VP6_DECODER) && avctx->idct_algo == FF_IDCT_VP3) { c->idct_put = ff_vp3_idct_put_neon; c->idct_add = ff_vp3_idct_add_neon; c->idct = ff_vp3_idct_neon; c->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM; } } c->put_pixels_tab[0][0] = ff_put_pixels16_neon; c->put_pixels_tab[0][1] = ff_put_pixels16_x2_neon; c->put_pixels_tab[0][2] = ff_put_pixels16_y2_neon; c->put_pixels_tab[0][3] = ff_put_pixels16_xy2_neon; c->put_pixels_tab[1][0] = ff_put_pixels8_neon; c->put_pixels_tab[1][1] = ff_put_pixels8_x2_neon; c->put_pixels_tab[1][2] = ff_put_pixels8_y2_neon; c->put_pixels_tab[1][3] = ff_put_pixels8_xy2_neon; c->put_no_rnd_pixels_tab[0][0] = ff_put_pixels16_neon; c->put_no_rnd_pixels_tab[0][1] = ff_put_pixels16_x2_no_rnd_neon; c->put_no_rnd_pixels_tab[0][2] = ff_put_pixels16_y2_no_rnd_neon; c->put_no_rnd_pixels_tab[0][3] = ff_put_pixels16_xy2_no_rnd_neon; c->put_no_rnd_pixels_tab[1][0] = ff_put_pixels8_neon; c->put_no_rnd_pixels_tab[1][1] = ff_put_pixels8_x2_no_rnd_neon; c->put_no_rnd_pixels_tab[1][2] = ff_put_pixels8_y2_no_rnd_neon; c->put_no_rnd_pixels_tab[1][3] = ff_put_pixels8_xy2_no_rnd_neon; c->avg_pixels_tab[0][0] = ff_avg_pixels16_neon; c->avg_pixels_tab[1][0] = ff_avg_pixels8_neon; c->add_pixels_clamped = ff_add_pixels_clamped_neon; c->put_pixels_clamped = ff_put_pixels_clamped_neon; c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_neon; if (CONFIG_H264_DECODER) { c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_neon; c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_neon; c->put_h264_chroma_pixels_tab[2] = ff_put_h264_chroma_mc2_neon; c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_neon; c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_neon; c->avg_h264_chroma_pixels_tab[2] = ff_avg_h264_chroma_mc2_neon; c->put_h264_qpel_pixels_tab[0][ 0] = ff_put_h264_qpel16_mc00_neon; c->put_h264_qpel_pixels_tab[0][ 1] = ff_put_h264_qpel16_mc10_neon; c->put_h264_qpel_pixels_tab[0][ 2] = ff_put_h264_qpel16_mc20_neon; c->put_h264_qpel_pixels_tab[0][ 3] = ff_put_h264_qpel16_mc30_neon; c->put_h264_qpel_pixels_tab[0][ 4] = ff_put_h264_qpel16_mc01_neon; c->put_h264_qpel_pixels_tab[0][ 5] = ff_put_h264_qpel16_mc11_neon; c->put_h264_qpel_pixels_tab[0][ 6] = ff_put_h264_qpel16_mc21_neon; c->put_h264_qpel_pixels_tab[0][ 7] = ff_put_h264_qpel16_mc31_neon; c->put_h264_qpel_pixels_tab[0][ 8] = ff_put_h264_qpel16_mc02_neon; c->put_h264_qpel_pixels_tab[0][ 9] = ff_put_h264_qpel16_mc12_neon; c->put_h264_qpel_pixels_tab[0][10] = ff_put_h264_qpel16_mc22_neon; c->put_h264_qpel_pixels_tab[0][11] = ff_put_h264_qpel16_mc32_neon; c->put_h264_qpel_pixels_tab[0][12] = ff_put_h264_qpel16_mc03_neon; c->put_h264_qpel_pixels_tab[0][13] = ff_put_h264_qpel16_mc13_neon; c->put_h264_qpel_pixels_tab[0][14] = ff_put_h264_qpel16_mc23_neon; c->put_h264_qpel_pixels_tab[0][15] = ff_put_h264_qpel16_mc33_neon; c->put_h264_qpel_pixels_tab[1][ 0] = ff_put_h264_qpel8_mc00_neon; c->put_h264_qpel_pixels_tab[1][ 1] = ff_put_h264_qpel8_mc10_neon; c->put_h264_qpel_pixels_tab[1][ 2] = ff_put_h264_qpel8_mc20_neon; c->put_h264_qpel_pixels_tab[1][ 3] = ff_put_h264_qpel8_mc30_neon; c->put_h264_qpel_pixels_tab[1][ 4] = ff_put_h264_qpel8_mc01_neon; c->put_h264_qpel_pixels_tab[1][ 5] = ff_put_h264_qpel8_mc11_neon; c->put_h264_qpel_pixels_tab[1][ 6] = ff_put_h264_qpel8_mc21_neon; c->put_h264_qpel_pixels_tab[1][ 7] = ff_put_h264_qpel8_mc31_neon; c->put_h264_qpel_pixels_tab[1][ 8] = ff_put_h264_qpel8_mc02_neon; c->put_h264_qpel_pixels_tab[1][ 9] = ff_put_h264_qpel8_mc12_neon; c->put_h264_qpel_pixels_tab[1][10] = ff_put_h264_qpel8_mc22_neon; c->put_h264_qpel_pixels_tab[1][11] = ff_put_h264_qpel8_mc32_neon; c->put_h264_qpel_pixels_tab[1][12] = ff_put_h264_qpel8_mc03_neon; c->put_h264_qpel_pixels_tab[1][13] = ff_put_h264_qpel8_mc13_neon; c->put_h264_qpel_pixels_tab[1][14] = ff_put_h264_qpel8_mc23_neon; c->put_h264_qpel_pixels_tab[1][15] = ff_put_h264_qpel8_mc33_neon; c->avg_h264_qpel_pixels_tab[0][ 0] = ff_avg_h264_qpel16_mc00_neon; c->avg_h264_qpel_pixels_tab[0][ 1] = ff_avg_h264_qpel16_mc10_neon; c->avg_h264_qpel_pixels_tab[0][ 2] = ff_avg_h264_qpel16_mc20_neon; c->avg_h264_qpel_pixels_tab[0][ 3] = ff_avg_h264_qpel16_mc30_neon; c->avg_h264_qpel_pixels_tab[0][ 4] = ff_avg_h264_qpel16_mc01_neon; c->avg_h264_qpel_pixels_tab[0][ 5] = ff_avg_h264_qpel16_mc11_neon; c->avg_h264_qpel_pixels_tab[0][ 6] = ff_avg_h264_qpel16_mc21_neon; c->avg_h264_qpel_pixels_tab[0][ 7] = ff_avg_h264_qpel16_mc31_neon; c->avg_h264_qpel_pixels_tab[0][ 8] = ff_avg_h264_qpel16_mc02_neon; c->avg_h264_qpel_pixels_tab[0][ 9] = ff_avg_h264_qpel16_mc12_neon; c->avg_h264_qpel_pixels_tab[0][10] = ff_avg_h264_qpel16_mc22_neon; c->avg_h264_qpel_pixels_tab[0][11] = ff_avg_h264_qpel16_mc32_neon; c->avg_h264_qpel_pixels_tab[0][12] = ff_avg_h264_qpel16_mc03_neon; c->avg_h264_qpel_pixels_tab[0][13] = ff_avg_h264_qpel16_mc13_neon; c->avg_h264_qpel_pixels_tab[0][14] = ff_avg_h264_qpel16_mc23_neon; c->avg_h264_qpel_pixels_tab[0][15] = ff_avg_h264_qpel16_mc33_neon; c->avg_h264_qpel_pixels_tab[1][ 0] = ff_avg_h264_qpel8_mc00_neon; c->avg_h264_qpel_pixels_tab[1][ 1] = ff_avg_h264_qpel8_mc10_neon; c->avg_h264_qpel_pixels_tab[1][ 2] = ff_avg_h264_qpel8_mc20_neon; c->avg_h264_qpel_pixels_tab[1][ 3] = ff_avg_h264_qpel8_mc30_neon; c->avg_h264_qpel_pixels_tab[1][ 4] = ff_avg_h264_qpel8_mc01_neon; c->avg_h264_qpel_pixels_tab[1][ 5] = ff_avg_h264_qpel8_mc11_neon; c->avg_h264_qpel_pixels_tab[1][ 6] = ff_avg_h264_qpel8_mc21_neon; c->avg_h264_qpel_pixels_tab[1][ 7] = ff_avg_h264_qpel8_mc31_neon; c->avg_h264_qpel_pixels_tab[1][ 8] = ff_avg_h264_qpel8_mc02_neon; c->avg_h264_qpel_pixels_tab[1][ 9] = ff_avg_h264_qpel8_mc12_neon; c->avg_h264_qpel_pixels_tab[1][10] = ff_avg_h264_qpel8_mc22_neon; c->avg_h264_qpel_pixels_tab[1][11] = ff_avg_h264_qpel8_mc32_neon; c->avg_h264_qpel_pixels_tab[1][12] = ff_avg_h264_qpel8_mc03_neon; c->avg_h264_qpel_pixels_tab[1][13] = ff_avg_h264_qpel8_mc13_neon; c->avg_h264_qpel_pixels_tab[1][14] = ff_avg_h264_qpel8_mc23_neon; c->avg_h264_qpel_pixels_tab[1][15] = ff_avg_h264_qpel8_mc33_neon; } if (CONFIG_VP3_DECODER) { c->vp3_v_loop_filter = ff_vp3_v_loop_filter_neon; c->vp3_h_loop_filter = ff_vp3_h_loop_filter_neon; c->vp3_idct_dc_add = ff_vp3_idct_dc_add_neon; } c->vector_fmul = ff_vector_fmul_neon; c->vector_fmul_window = ff_vector_fmul_window_neon; c->vector_fmul_scalar = ff_vector_fmul_scalar_neon; c->butterflies_float = ff_butterflies_float_neon; c->scalarproduct_float = ff_scalarproduct_float_neon; c->int32_to_float_fmul_scalar = ff_int32_to_float_fmul_scalar_neon; c->vector_fmul_reverse = ff_vector_fmul_reverse_neon; c->vector_fmul_add = ff_vector_fmul_add_neon; c->vector_clipf = ff_vector_clipf_neon; c->vector_fmul_sv_scalar[0] = ff_vector_fmul_sv_scalar_2_neon; c->vector_fmul_sv_scalar[1] = ff_vector_fmul_sv_scalar_4_neon; c->sv_fmul_scalar[0] = ff_sv_fmul_scalar_2_neon; c->sv_fmul_scalar[1] = ff_sv_fmul_scalar_4_neon; if (!(avctx->flags & CODEC_FLAG_BITEXACT)) { c->float_to_int16 = ff_float_to_int16_neon; c->float_to_int16_interleave = ff_float_to_int16_interleave_neon; } if (CONFIG_VORBIS_DECODER) c->vorbis_inverse_coupling = ff_vorbis_inverse_coupling_neon; c->scalarproduct_int16 = ff_scalarproduct_int16_neon; c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_neon; }
123linslouis-android-video-cutter
jni/libavcodec/arm/dsputil_init_neon.c
C
asf20
18,077
/* * Copyright (c) 2009 Mans Rullgard <mans@mansr.com> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "libavcodec/fft.h" #include "libavcodec/synth_filter.h" void ff_fft_permute_neon(FFTContext *s, FFTComplex *z); void ff_fft_calc_neon(FFTContext *s, FFTComplex *z); void ff_imdct_calc_neon(FFTContext *s, FFTSample *output, const FFTSample *input); void ff_imdct_half_neon(FFTContext *s, FFTSample *output, const FFTSample *input); void ff_mdct_calc_neon(FFTContext *s, FFTSample *output, const FFTSample *input); void ff_rdft_calc_neon(struct RDFTContext *s, FFTSample *z); void ff_synth_filter_float_neon(FFTContext *imdct, float *synth_buf_ptr, int *synth_buf_offset, float synth_buf2[32], const float window[512], float out[32], const float in[32], float scale, float bias); av_cold void ff_fft_init_arm(FFTContext *s) { if (HAVE_NEON) { s->fft_permute = ff_fft_permute_neon; s->fft_calc = ff_fft_calc_neon; s->imdct_calc = ff_imdct_calc_neon; s->imdct_half = ff_imdct_half_neon; s->mdct_calc = ff_mdct_calc_neon; s->permutation = FF_MDCT_PERM_INTERLEAVE; } } #if CONFIG_RDFT av_cold void ff_rdft_init_arm(RDFTContext *s) { if (HAVE_NEON) s->rdft_calc = ff_rdft_calc_neon; } #endif #if CONFIG_DCA_DECODER av_cold void ff_synth_filter_init_arm(SynthFilterContext *s) { if (HAVE_NEON) s->synth_filter_float = ff_synth_filter_float_neon; } #endif
123linslouis-android-video-cutter
jni/libavcodec/arm/fft_init_arm.c
C
asf20
2,307
/* * Copyright (c) 2009 Mans Rullgard <mans@mansr.com> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "asm.S" .macro ldcol.8 rd, rs, rt, n=8, hi=0 .if \n == 8 || \hi == 0 vld1.8 {\rd[0]}, [\rs], \rt vld1.8 {\rd[1]}, [\rs], \rt vld1.8 {\rd[2]}, [\rs], \rt vld1.8 {\rd[3]}, [\rs], \rt .endif .if \n == 8 || \hi == 1 vld1.8 {\rd[4]}, [\rs], \rt vld1.8 {\rd[5]}, [\rs], \rt vld1.8 {\rd[6]}, [\rs], \rt vld1.8 {\rd[7]}, [\rs], \rt .endif .endm .macro add16x8 dq, dl, dh, rl, rh vaddl.u8 \dq, \rl, \rh vadd.u16 \dl, \dl, \dh vpadd.u16 \dl, \dl, \dl vpadd.u16 \dl, \dl, \dl .endm function ff_pred16x16_128_dc_neon, export=1 vmov.i8 q0, #128 b .L_pred16x16_dc_end endfunc function ff_pred16x16_top_dc_neon, export=1 sub r2, r0, r1 vld1.8 {q0}, [r2,:128] add16x8 q0, d0, d1, d0, d1 vrshrn.u16 d0, q0, #4 vdup.8 q0, d0[0] b .L_pred16x16_dc_end endfunc function ff_pred16x16_left_dc_neon, export=1 sub r2, r0, #1 ldcol.8 d0, r2, r1 ldcol.8 d1, r2, r1 add16x8 q0, d0, d1, d0, d1 vrshrn.u16 d0, q0, #4 vdup.8 q0, d0[0] b .L_pred16x16_dc_end endfunc function ff_pred16x16_dc_neon, export=1 sub r2, r0, r1 vld1.8 {q0}, [r2,:128] sub r2, r0, #1 ldcol.8 d2, r2, r1 ldcol.8 d3, r2, r1 vaddl.u8 q0, d0, d1 vaddl.u8 q1, d2, d3 vadd.u16 q0, q0, q1 vadd.u16 d0, d0, d1 vpadd.u16 d0, d0, d0 vpadd.u16 d0, d0, d0 vrshrn.u16 d0, q0, #5 vdup.8 q0, d0[0] .L_pred16x16_dc_end: mov r3, #8 6: vst1.8 {q0}, [r0,:128], r1 vst1.8 {q0}, [r0,:128], r1 subs r3, r3, #1 bne 6b bx lr endfunc function ff_pred16x16_hor_neon, export=1 sub r2, r0, #1 mov r3, #16 1: vld1.8 {d0[],d1[]},[r2], r1 vst1.8 {q0}, [r0,:128], r1 subs r3, r3, #1 bne 1b bx lr endfunc function ff_pred16x16_vert_neon, export=1 sub r0, r0, r1 vld1.8 {q0}, [r0,:128], r1 mov r3, #8 1: vst1.8 {q0}, [r0,:128], r1 vst1.8 {q0}, [r0,:128], r1 subs r3, r3, #1 bne 1b bx lr endfunc function ff_pred16x16_plane_neon, export=1 sub r3, r0, r1 add r2, r3, #8 sub r3, r3, #1 vld1.8 {d0}, [r3] vld1.8 {d2}, [r2,:64], r1 ldcol.8 d1, r3, r1 add r3, r3, r1 ldcol.8 d3, r3, r1 vrev64.8 q0, q0 vaddl.u8 q8, d2, d3 vsubl.u8 q2, d2, d0 vsubl.u8 q3, d3, d1 movrel r3, p16weight vld1.8 {q0}, [r3,:128] vmul.s16 q2, q2, q0 vmul.s16 q3, q3, q0 vadd.i16 d4, d4, d5 vadd.i16 d5, d6, d7 vpadd.i16 d4, d4, d5 vpadd.i16 d4, d4, d4 vshl.i16 d5, d4, #2 vaddl.s16 q2, d4, d5 vrshrn.s32 d4, q2, #6 mov r3, #0 vtrn.16 d4, d5 vadd.i16 d2, d4, d5 vshl.i16 d3, d2, #3 vrev64.16 d16, d17 vsub.i16 d3, d3, d2 vadd.i16 d16, d16, d0 vshl.i16 d2, d16, #4 vsub.i16 d2, d2, d3 vshl.i16 d3, d4, #4 vext.16 q0, q0, q0, #7 vsub.i16 d6, d5, d3 vmov.16 d0[0], r3 vmul.i16 q0, q0, d4[0] vdup.16 q1, d2[0] vdup.16 q2, d4[0] vdup.16 q3, d6[0] vshl.i16 q2, q2, #3 vadd.i16 q1, q1, q0 vadd.i16 q3, q3, q2 mov r3, #16 1: vqshrun.s16 d0, q1, #5 vadd.i16 q1, q1, q2 vqshrun.s16 d1, q1, #5 vadd.i16 q1, q1, q3 vst1.8 {q0}, [r0,:128], r1 subs r3, r3, #1 bne 1b bx lr endfunc .section .rodata .align 4 p16weight: .short 1,2,3,4,5,6,7,8 .text function ff_pred8x8_hor_neon, export=1 sub r2, r0, #1 mov r3, #8 1: vld1.8 {d0[]}, [r2], r1 vst1.8 {d0}, [r0,:64], r1 subs r3, r3, #1 bne 1b bx lr endfunc function ff_pred8x8_vert_neon, export=1 sub r0, r0, r1 vld1.8 {d0}, [r0,:64], r1 mov r3, #4 1: vst1.8 {d0}, [r0,:64], r1 vst1.8 {d0}, [r0,:64], r1 subs r3, r3, #1 bne 1b bx lr endfunc function ff_pred8x8_plane_neon, export=1 sub r3, r0, r1 add r2, r3, #4 sub r3, r3, #1 vld1.32 {d0[0]}, [r3] vld1.32 {d2[0]}, [r2,:32], r1 ldcol.8 d0, r3, r1, 4, hi=1 add r3, r3, r1 ldcol.8 d3, r3, r1, 4 vaddl.u8 q8, d2, d3 vrev32.8 d0, d0 vtrn.32 d2, d3 vsubl.u8 q2, d2, d0 movrel r3, p16weight vld1.16 {q0}, [r3,:128] vmul.s16 d4, d4, d0 vmul.s16 d5, d5, d0 vpadd.i16 d4, d4, d5 vpaddl.s16 d4, d4 vshl.i32 d5, d4, #4 vadd.s32 d4, d4, d5 vrshrn.s32 d4, q2, #5 mov r3, #0 vtrn.16 d4, d5 vadd.i16 d2, d4, d5 vshl.i16 d3, d2, #2 vrev64.16 d16, d16 vsub.i16 d3, d3, d2 vadd.i16 d16, d16, d0 vshl.i16 d2, d16, #4 vsub.i16 d2, d2, d3 vshl.i16 d3, d4, #3 vext.16 q0, q0, q0, #7 vsub.i16 d6, d5, d3 vmov.16 d0[0], r3 vmul.i16 q0, q0, d4[0] vdup.16 q1, d2[0] vdup.16 q2, d4[0] vdup.16 q3, d6[0] vshl.i16 q2, q2, #3 vadd.i16 q1, q1, q0 vadd.i16 q3, q3, q2 mov r3, #8 1: vqshrun.s16 d0, q1, #5 vadd.i16 q1, q1, q3 vst1.8 {d0}, [r0,:64], r1 subs r3, r3, #1 bne 1b bx lr endfunc function ff_pred8x8_128_dc_neon, export=1 vmov.i8 q0, #128 b .L_pred8x8_dc_end endfunc function ff_pred8x8_top_dc_neon, export=1 sub r2, r0, r1 vld1.8 {d0}, [r2,:64] vpaddl.u8 d0, d0 vpadd.u16 d0, d0, d0 vrshrn.u16 d0, q0, #2 vdup.8 d1, d0[1] vdup.8 d0, d0[0] vtrn.32 d0, d1 b .L_pred8x8_dc_end endfunc function ff_pred8x8_left_dc_neon, export=1 sub r2, r0, #1 ldcol.8 d0, r2, r1 vpaddl.u8 d0, d0 vpadd.u16 d0, d0, d0 vrshrn.u16 d0, q0, #2 vdup.8 d1, d0[1] vdup.8 d0, d0[0] b .L_pred8x8_dc_end endfunc function ff_pred8x8_dc_neon, export=1 sub r2, r0, r1 vld1.8 {d0}, [r2,:64] sub r2, r0, #1 ldcol.8 d1, r2, r1 vtrn.32 d0, d1 vpaddl.u8 q0, q0 vpadd.u16 d0, d0, d1 vpadd.u16 d1, d0, d0 vrshrn.u16 d2, q0, #3 vrshrn.u16 d3, q0, #2 vdup.8 d0, d2[4] vdup.8 d1, d3[3] vdup.8 d4, d3[2] vdup.8 d5, d2[5] vtrn.32 q0, q2 .L_pred8x8_dc_end: mov r3, #4 add r2, r0, r1, lsl #2 6: vst1.8 {d0}, [r0,:64], r1 vst1.8 {d1}, [r2,:64], r1 subs r3, r3, #1 bne 6b bx lr endfunc function ff_pred8x8_l0t_dc_neon, export=1 sub r2, r0, r1 vld1.8 {d0}, [r2,:64] sub r2, r0, #1 ldcol.8 d1, r2, r1, 4 vtrn.32 d0, d1 vpaddl.u8 q0, q0 vpadd.u16 d0, d0, d1 vpadd.u16 d1, d0, d0 vrshrn.u16 d2, q0, #3 vrshrn.u16 d3, q0, #2 vdup.8 d0, d2[4] vdup.8 d1, d3[0] vdup.8 q2, d3[2] vtrn.32 q0, q2 b .L_pred8x8_dc_end endfunc function ff_pred8x8_l00_dc_neon, export=1 sub r2, r0, #1 ldcol.8 d0, r2, r1, 4 vpaddl.u8 d0, d0 vpadd.u16 d0, d0, d0 vrshrn.u16 d0, q0, #2 vmov.i8 d1, #128 vdup.8 d0, d0[0] b .L_pred8x8_dc_end endfunc function ff_pred8x8_0lt_dc_neon, export=1 sub r2, r0, r1 vld1.8 {d0}, [r2,:64] add r2, r0, r1, lsl #2 sub r2, r2, #1 ldcol.8 d1, r2, r1, 4, hi=1 vtrn.32 d0, d1 vpaddl.u8 q0, q0 vpadd.u16 d0, d0, d1 vpadd.u16 d1, d0, d0 vrshrn.u16 d3, q0, #2 vrshrn.u16 d2, q0, #3 vdup.8 d0, d3[0] vdup.8 d1, d3[3] vdup.8 d4, d3[2] vdup.8 d5, d2[5] vtrn.32 q0, q2 b .L_pred8x8_dc_end endfunc function ff_pred8x8_0l0_dc_neon, export=1 add r2, r0, r1, lsl #2 sub r2, r2, #1 ldcol.8 d1, r2, r1, 4 vpaddl.u8 d2, d1 vpadd.u16 d2, d2, d2 vrshrn.u16 d1, q1, #2 vmov.i8 d0, #128 vdup.8 d1, d1[0] b .L_pred8x8_dc_end endfunc
123linslouis-android-video-cutter
jni/libavcodec/arm/h264pred_neon.S
Unix Assembly
asf20
12,044
/* * Copyright (c) 2009 Mans Rullgard <mans@mansr.com> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "libavcodec/dsputil.h" #include "dsputil_arm.h" void ff_simple_idct_armv5te(DCTELEM *data); void ff_simple_idct_put_armv5te(uint8_t *dest, int line_size, DCTELEM *data); void ff_simple_idct_add_armv5te(uint8_t *dest, int line_size, DCTELEM *data); void ff_prefetch_arm(void *mem, int stride, int h); void av_cold ff_dsputil_init_armv5te(DSPContext* c, AVCodecContext *avctx) { if (!avctx->lowres && (avctx->idct_algo == FF_IDCT_AUTO || avctx->idct_algo == FF_IDCT_SIMPLEARMV5TE)) { c->idct_put = ff_simple_idct_put_armv5te; c->idct_add = ff_simple_idct_add_armv5te; c->idct = ff_simple_idct_armv5te; c->idct_permutation_type = FF_NO_IDCT_PERM; } c->prefetch = ff_prefetch_arm; }
123linslouis-android-video-cutter
jni/libavcodec/arm/dsputil_init_armv5te.c
C
asf20
1,626
/* * simple math operations * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> et al * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AVCODEC_ARM_MATHOPS_H #define AVCODEC_ARM_MATHOPS_H #include <stdint.h> #include "config.h" #include "libavutil/common.h" #if HAVE_INLINE_ASM # define MULL MULL static inline av_const int MULL(int a, int b, unsigned shift) { int lo, hi; __asm__("smull %0, %1, %2, %3 \n\t" "mov %0, %0, lsr %4 \n\t" "add %1, %0, %1, lsl %5 \n\t" : "=&r"(lo), "=&r"(hi) : "r"(b), "r"(a), "ir"(shift), "ir"(32-shift)); return hi; } #define MULH MULH #if HAVE_ARMV6 static inline av_const int MULH(int a, int b) { int r; __asm__ ("smmul %0, %1, %2" : "=r"(r) : "r"(a), "r"(b)); return r; } #else static inline av_const int MULH(int a, int b) { int lo, hi; __asm__ ("smull %0, %1, %2, %3" : "=&r"(lo), "=&r"(hi) : "r"(b), "r"(a)); return hi; } #endif static inline av_const int64_t MUL64(int a, int b) { union { uint64_t x; unsigned hl[2]; } x; __asm__ ("smull %0, %1, %2, %3" : "=r"(x.hl[0]), "=r"(x.hl[1]) : "r"(a), "r"(b)); return x.x; } #define MUL64 MUL64 static inline av_const int64_t MAC64(int64_t d, int a, int b) { union { uint64_t x; unsigned hl[2]; } x = { d }; __asm__ ("smlal %0, %1, %2, %3" : "+r"(x.hl[0]), "+r"(x.hl[1]) : "r"(a), "r"(b)); return x.x; } #define MAC64(d, a, b) ((d) = MAC64(d, a, b)) #define MLS64(d, a, b) MAC64(d, -(a), b) #if HAVE_ARMV5TE /* signed 16x16 -> 32 multiply add accumulate */ # define MAC16(rt, ra, rb) \ __asm__ ("smlabb %0, %1, %2, %0" : "+r"(rt) : "r"(ra), "r"(rb)); /* signed 16x16 -> 32 multiply */ # define MUL16 MUL16 static inline av_const int MUL16(int ra, int rb) { int rt; __asm__ ("smulbb %0, %1, %2" : "=r"(rt) : "r"(ra), "r"(rb)); return rt; } #endif #define mid_pred mid_pred static inline av_const int mid_pred(int a, int b, int c) { int m; __asm__ volatile ( "mov %0, %2 \n\t" "cmp %1, %2 \n\t" "movgt %0, %1 \n\t" "movgt %1, %2 \n\t" "cmp %1, %3 \n\t" "movle %1, %3 \n\t" "cmp %0, %1 \n\t" "movgt %0, %1 \n\t" : "=&r"(m), "+r"(a) : "r"(b), "r"(c)); return m; } #endif /* HAVE_INLINE_ASM */ #endif /* AVCODEC_ARM_MATHOPS_H */
123linslouis-android-video-cutter
jni/libavcodec/arm/mathops.h
C
asf20
3,169
/* * Copyright (c) 2008 Siarhei Siamashka <ssvb@users.sourceforge.net> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "config.h" #include "asm.S" .syntax unified /* * VFP is a floating point coprocessor used in some ARM cores. VFP11 has 1 cycle * throughput for almost all the instructions (except for double precision * arithmetics), but rather high latency. Latency is 4 cycles for loads and 8 cycles * for arithmetic operations. Scheduling code to avoid pipeline stalls is very * important for performance. One more interesting feature is that VFP has * independent load/store and arithmetics pipelines, so it is possible to make * them work simultaneously and get more than 1 operation per cycle. Load/store * pipeline can process 2 single precision floating point values per cycle and * supports bulk loads and stores for large sets of registers. Arithmetic operations * can be done on vectors, which allows to keep the arithmetics pipeline busy, * while the processor may issue and execute other instructions. Detailed * optimization manuals can be found at http://www.arm.com */ /** * ARM VFP optimized implementation of 'vector_fmul_c' function. * Assume that len is a positive number and is multiple of 8 */ @ void ff_vector_fmul_vfp(float *dst, const float *src, int len) function ff_vector_fmul_vfp, export=1 vpush {d8-d15} mov r3, r0 fmrx r12, fpscr orr r12, r12, #(3 << 16) /* set vector size to 4 */ fmxr fpscr, r12 vldmia r3!, {s0-s3} vldmia r1!, {s8-s11} vldmia r3!, {s4-s7} vldmia r1!, {s12-s15} vmul.f32 s8, s0, s8 1: subs r2, r2, #16 vmul.f32 s12, s4, s12 vldmiage r3!, {s16-s19} vldmiage r1!, {s24-s27} vldmiage r3!, {s20-s23} vldmiage r1!, {s28-s31} vmulge.f32 s24, s16, s24 vstmia r0!, {s8-s11} vstmia r0!, {s12-s15} vmulge.f32 s28, s20, s28 vldmiagt r3!, {s0-s3} vldmiagt r1!, {s8-s11} vldmiagt r3!, {s4-s7} vldmiagt r1!, {s12-s15} vmulge.f32 s8, s0, s8 vstmiage r0!, {s24-s27} vstmiage r0!, {s28-s31} bgt 1b bic r12, r12, #(7 << 16) /* set vector size back to 1 */ fmxr fpscr, r12 vpop {d8-d15} bx lr endfunc /** * ARM VFP optimized implementation of 'vector_fmul_reverse_c' function. * Assume that len is a positive number and is multiple of 8 */ @ void ff_vector_fmul_reverse_vfp(float *dst, const float *src0, @ const float *src1, int len) function ff_vector_fmul_reverse_vfp, export=1 vpush {d8-d15} add r2, r2, r3, lsl #2 vldmdb r2!, {s0-s3} vldmia r1!, {s8-s11} vldmdb r2!, {s4-s7} vldmia r1!, {s12-s15} vmul.f32 s8, s3, s8 vmul.f32 s9, s2, s9 vmul.f32 s10, s1, s10 vmul.f32 s11, s0, s11 1: subs r3, r3, #16 vldmdbge r2!, {s16-s19} vmul.f32 s12, s7, s12 vldmiage r1!, {s24-s27} vmul.f32 s13, s6, s13 vldmdbge r2!, {s20-s23} vmul.f32 s14, s5, s14 vldmiage r1!, {s28-s31} vmul.f32 s15, s4, s15 vmulge.f32 s24, s19, s24 vldmdbgt r2!, {s0-s3} vmulge.f32 s25, s18, s25 vstmia r0!, {s8-s13} vmulge.f32 s26, s17, s26 vldmiagt r1!, {s8-s11} vmulge.f32 s27, s16, s27 vmulge.f32 s28, s23, s28 vldmdbgt r2!, {s4-s7} vmulge.f32 s29, s22, s29 vstmia r0!, {s14-s15} vmulge.f32 s30, s21, s30 vmulge.f32 s31, s20, s31 vmulge.f32 s8, s3, s8 vldmiagt r1!, {s12-s15} vmulge.f32 s9, s2, s9 vmulge.f32 s10, s1, s10 vstmiage r0!, {s24-s27} vmulge.f32 s11, s0, s11 vstmiage r0!, {s28-s31} bgt 1b vpop {d8-d15} bx lr endfunc #if HAVE_ARMV6 /** * ARM VFP optimized float to int16 conversion. * Assume that len is a positive number and is multiple of 8, destination * buffer is at least 4 bytes aligned (8 bytes alignment is better for * performance), little endian byte sex */ @ void ff_float_to_int16_vfp(int16_t *dst, const float *src, int len) function ff_float_to_int16_vfp, export=1 push {r4-r8,lr} vpush {d8-d11} vldmia r1!, {s16-s23} vcvt.s32.f32 s0, s16 vcvt.s32.f32 s1, s17 vcvt.s32.f32 s2, s18 vcvt.s32.f32 s3, s19 vcvt.s32.f32 s4, s20 vcvt.s32.f32 s5, s21 vcvt.s32.f32 s6, s22 vcvt.s32.f32 s7, s23 1: subs r2, r2, #8 vmov r3, r4, s0, s1 vmov r5, r6, s2, s3 vmov r7, r8, s4, s5 vmov ip, lr, s6, s7 vldmiagt r1!, {s16-s23} ssat r4, #16, r4 ssat r3, #16, r3 ssat r6, #16, r6 ssat r5, #16, r5 pkhbt r3, r3, r4, lsl #16 pkhbt r4, r5, r6, lsl #16 vcvtgt.s32.f32 s0, s16 vcvtgt.s32.f32 s1, s17 vcvtgt.s32.f32 s2, s18 vcvtgt.s32.f32 s3, s19 vcvtgt.s32.f32 s4, s20 vcvtgt.s32.f32 s5, s21 vcvtgt.s32.f32 s6, s22 vcvtgt.s32.f32 s7, s23 ssat r8, #16, r8 ssat r7, #16, r7 ssat lr, #16, lr ssat ip, #16, ip pkhbt r5, r7, r8, lsl #16 pkhbt r6, ip, lr, lsl #16 stmia r0!, {r3-r6} bgt 1b vpop {d8-d11} pop {r4-r8,pc} endfunc #endif
123linslouis-android-video-cutter
jni/libavcodec/arm/dsputil_vfp.S
Motorola 68K Assembly
asf20
7,105
/* * ARM NEON optimised MDCT * Copyright (c) 2009 Mans Rullgard <mans@mansr.com> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "asm.S" preserve8 .text #define ff_fft_calc_neon X(ff_fft_calc_neon) function ff_imdct_half_neon, export=1 push {r4-r8,lr} mov r12, #1 ldr lr, [r0, #28] @ mdct_bits ldr r4, [r0, #32] @ tcos ldr r3, [r0, #8] @ revtab lsl r12, r12, lr @ n = 1 << nbits lsr lr, r12, #2 @ n4 = n >> 2 add r7, r2, r12, lsl #1 mov r12, #-16 sub r7, r7, #16 vld2.32 {d16-d17},[r7,:128],r12 @ d16=x,n1 d17=x,n0 vld2.32 {d0-d1}, [r2,:128]! @ d0 =m0,x d1 =m1,x vrev64.32 d17, d17 vld2.32 {d2,d3}, [r4,:128]! @ d2=c0,c1 d3=s0,s2 vmul.f32 d6, d17, d2 vmul.f32 d7, d0, d2 1: subs lr, lr, #2 ldr r6, [r3], #4 vmul.f32 d4, d0, d3 vmul.f32 d5, d17, d3 vsub.f32 d4, d6, d4 vadd.f32 d5, d5, d7 uxth r8, r6, ror #16 uxth r6, r6 add r8, r1, r8, lsl #3 add r6, r1, r6, lsl #3 beq 1f vld2.32 {d16-d17},[r7,:128],r12 vld2.32 {d0-d1}, [r2,:128]! vrev64.32 d17, d17 vld2.32 {d2,d3}, [r4,:128]! @ d2=c0,c1 d3=s0,s2 vmul.f32 d6, d17, d2 vmul.f32 d7, d0, d2 vst2.32 {d4[0],d5[0]}, [r6,:64] vst2.32 {d4[1],d5[1]}, [r8,:64] b 1b 1: vst2.32 {d4[0],d5[0]}, [r6,:64] vst2.32 {d4[1],d5[1]}, [r8,:64] mov r4, r0 mov r6, r1 bl ff_fft_calc_neon mov r12, #1 ldr lr, [r4, #28] @ mdct_bits ldr r4, [r4, #32] @ tcos lsl r12, r12, lr @ n = 1 << nbits lsr lr, r12, #3 @ n8 = n >> 3 add r4, r4, lr, lsl #3 add r6, r6, lr, lsl #3 sub r1, r4, #16 sub r3, r6, #16 mov r7, #-16 mov r8, r6 mov r0, r3 vld2.32 {d0-d1}, [r3,:128], r7 @ d0 =i1,r1 d1 =i0,r0 vld2.32 {d20-d21},[r6,:128]! @ d20=i2,r2 d21=i3,r3 vld2.32 {d16,d18},[r1,:128], r7 @ d16=c1,c0 d18=s1,s0 1: subs lr, lr, #2 vmul.f32 d7, d0, d18 vld2.32 {d17,d19},[r4,:128]! @ d17=c2,c3 d19=s2,s3 vmul.f32 d4, d1, d18 vmul.f32 d5, d21, d19 vmul.f32 d6, d20, d19 vmul.f32 d22, d1, d16 vmul.f32 d23, d21, d17 vmul.f32 d24, d0, d16 vmul.f32 d25, d20, d17 vadd.f32 d7, d7, d22 vadd.f32 d6, d6, d23 vsub.f32 d4, d4, d24 vsub.f32 d5, d5, d25 beq 1f vld2.32 {d0-d1}, [r3,:128], r7 vld2.32 {d20-d21},[r6,:128]! vld2.32 {d16,d18},[r1,:128], r7 @ d16=c1,c0 d18=s1,s0 vrev64.32 q3, q3 vst2.32 {d4,d6}, [r0,:128], r7 vst2.32 {d5,d7}, [r8,:128]! b 1b 1: vrev64.32 q3, q3 vst2.32 {d4,d6}, [r0,:128] vst2.32 {d5,d7}, [r8,:128] pop {r4-r8,pc} endfunc function ff_imdct_calc_neon, export=1 push {r4-r6,lr} ldr r3, [r0, #28] mov r4, #1 mov r5, r1 lsl r4, r4, r3 add r1, r1, r4 bl ff_imdct_half_neon add r0, r5, r4, lsl #2 add r1, r5, r4, lsl #1 sub r0, r0, #8 sub r2, r1, #16 mov r3, #-16 mov r6, #-8 vmov.i32 d30, #1<<31 1: vld1.32 {d0-d1}, [r2,:128], r3 pld [r0, #-16] vrev64.32 q0, q0 vld1.32 {d2-d3}, [r1,:128]! veor d4, d1, d30 pld [r2, #-16] vrev64.32 q1, q1 veor d5, d0, d30 vst1.32 {d2}, [r0,:64], r6 vst1.32 {d3}, [r0,:64], r6 vst1.32 {d4-d5}, [r5,:128]! subs r4, r4, #16 bgt 1b pop {r4-r6,pc} endfunc function ff_mdct_calc_neon, export=1 push {r4-r10,lr} mov r12, #1 ldr lr, [r0, #28] @ mdct_bits ldr r4, [r0, #32] @ tcos ldr r3, [r0, #8] @ revtab lsl lr, r12, lr @ n = 1 << nbits add r7, r2, lr @ in4u sub r9, r7, #16 @ in4d add r2, r7, lr, lsl #1 @ in3u add r8, r9, lr, lsl #1 @ in3d add r5, r4, lr, lsl #1 sub r5, r5, #16 sub r3, r3, #4 mov r12, #-16 vld2.32 {d16,d18},[r9,:128],r12 @ in0u0,in0u1 in4d1,in4d0 vld2.32 {d17,d19},[r8,:128],r12 @ in2u0,in2u1 in3d1,in3d0 vld2.32 {d0, d2}, [r7,:128]! @ in4u0,in4u1 in2d1,in2d0 vrev64.32 q9, q9 @ in4d0,in4d1 in3d0,in3d1 vld2.32 {d1, d3}, [r2,:128]! @ in3u0,in3u1 in1d1,in1d0 vsub.f32 d0, d18, d0 @ in4d-in4u I vld2.32 {d20,d21},[r4,:128]! @ c0,c1 s0,s1 vrev64.32 q1, q1 @ in2d0,in2d1 in1d0,in1d1 vld2.32 {d30,d31},[r5,:128],r12 @ c2,c3 s2,s3 vadd.f32 d1, d1, d19 @ in3u+in3d -R vsub.f32 d16, d16, d2 @ in0u-in2d R vadd.f32 d17, d17, d3 @ in2u+in1d -I 1: vmul.f32 d7, d0, d21 @ I*s ldr r10, [r3, lr, lsr #1] vmul.f32 d6, d1, d20 @ -R*c ldr r6, [r3, #4]! vmul.f32 d4, d1, d21 @ -R*s vmul.f32 d5, d0, d20 @ I*c vmul.f32 d24, d16, d30 @ R*c vmul.f32 d25, d17, d31 @ -I*s vmul.f32 d22, d16, d31 @ R*s vmul.f32 d23, d17, d30 @ I*c subs lr, lr, #16 vsub.f32 d6, d6, d7 @ -R*c-I*s vadd.f32 d7, d4, d5 @ -R*s+I*c vsub.f32 d24, d25, d24 @ I*s-R*c vadd.f32 d25, d22, d23 @ R*s-I*c beq 1f mov r12, #-16 vld2.32 {d16,d18},[r9,:128],r12 @ in0u0,in0u1 in4d1,in4d0 vld2.32 {d17,d19},[r8,:128],r12 @ in2u0,in2u1 in3d1,in3d0 vneg.f32 d7, d7 @ R*s-I*c vld2.32 {d0, d2}, [r7,:128]! @ in4u0,in4u1 in2d1,in2d0 vrev64.32 q9, q9 @ in4d0,in4d1 in3d0,in3d1 vld2.32 {d1, d3}, [r2,:128]! @ in3u0,in3u1 in1d1,in1d0 vsub.f32 d0, d18, d0 @ in4d-in4u I vld2.32 {d20,d21},[r4,:128]! @ c0,c1 s0,s1 vrev64.32 q1, q1 @ in2d0,in2d1 in1d0,in1d1 vld2.32 {d30,d31},[r5,:128],r12 @ c2,c3 s2,s3 vadd.f32 d1, d1, d19 @ in3u+in3d -R vsub.f32 d16, d16, d2 @ in0u-in2d R vadd.f32 d17, d17, d3 @ in2u+in1d -I uxth r12, r6, ror #16 uxth r6, r6 add r12, r1, r12, lsl #3 add r6, r1, r6, lsl #3 vst2.32 {d6[0],d7[0]}, [r6,:64] vst2.32 {d6[1],d7[1]}, [r12,:64] uxth r6, r10, ror #16 uxth r10, r10 add r6 , r1, r6, lsl #3 add r10, r1, r10, lsl #3 vst2.32 {d24[0],d25[0]},[r10,:64] vst2.32 {d24[1],d25[1]},[r6,:64] b 1b 1: vneg.f32 d7, d7 @ R*s-I*c uxth r12, r6, ror #16 uxth r6, r6 add r12, r1, r12, lsl #3 add r6, r1, r6, lsl #3 vst2.32 {d6[0],d7[0]}, [r6,:64] vst2.32 {d6[1],d7[1]}, [r12,:64] uxth r6, r10, ror #16 uxth r10, r10 add r6 , r1, r6, lsl #3 add r10, r1, r10, lsl #3 vst2.32 {d24[0],d25[0]},[r10,:64] vst2.32 {d24[1],d25[1]},[r6,:64] mov r4, r0 mov r6, r1 bl ff_fft_calc_neon mov r12, #1 ldr lr, [r4, #28] @ mdct_bits ldr r4, [r4, #32] @ tcos lsl r12, r12, lr @ n = 1 << nbits lsr lr, r12, #3 @ n8 = n >> 3 add r4, r4, lr, lsl #3 add r6, r6, lr, lsl #3 sub r1, r4, #16 sub r3, r6, #16 mov r7, #-16 mov r8, r6 mov r0, r3 vld2.32 {d0-d1}, [r3,:128], r7 @ d0 =r1,i1 d1 =r0,i0 vld2.32 {d20-d21},[r6,:128]! @ d20=r2,i2 d21=r3,i3 vld2.32 {d16,d18},[r1,:128], r7 @ c1,c0 s1,s0 1: subs lr, lr, #2 vmul.f32 d7, d0, d18 @ r1*s1,r0*s0 vld2.32 {d17,d19},[r4,:128]! @ c2,c3 s2,s3 vmul.f32 d4, d1, d18 @ i1*s1,i0*s0 vmul.f32 d5, d21, d19 @ i2*s2,i3*s3 vmul.f32 d6, d20, d19 @ r2*s2,r3*s3 vmul.f32 d24, d0, d16 @ r1*c1,r0*c0 vmul.f32 d25, d20, d17 @ r2*c2,r3*c3 vmul.f32 d22, d21, d17 @ i2*c2,i3*c3 vmul.f32 d23, d1, d16 @ i1*c1,i0*c0 vadd.f32 d4, d4, d24 @ i1*s1+r1*c1,i0*s0+r0*c0 vadd.f32 d5, d5, d25 @ i2*s2+r2*c2,i3*s3+r3*c3 vsub.f32 d6, d22, d6 @ i2*c2-r2*s2,i3*c3-r3*s3 vsub.f32 d7, d23, d7 @ i1*c1-r1*s1,i0*c0-r0*s0 vneg.f32 q2, q2 beq 1f vld2.32 {d0-d1}, [r3,:128], r7 vld2.32 {d20-d21},[r6,:128]! vld2.32 {d16,d18},[r1,:128], r7 @ c1,c0 s1,s0 vrev64.32 q3, q3 vst2.32 {d4,d6}, [r0,:128], r7 vst2.32 {d5,d7}, [r8,:128]! b 1b 1: vrev64.32 q3, q3 vst2.32 {d4,d6}, [r0,:128] vst2.32 {d5,d7}, [r8,:128] pop {r4-r10,pc} endfunc
123linslouis-android-video-cutter
jni/libavcodec/arm/mdct_neon.S
Unix Assembly
asf20
12,489
/* * iWMMXt optimized DSP utils * Copyright (c) 2004 AGAWA Koji * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "libavcodec/dsputil.h" #define DEF(x, y) x ## _no_rnd_ ## y ##_iwmmxt #define SET_RND(regd) __asm__ volatile ("mov r12, #1 \n\t tbcsth " #regd ", r12":::"r12"); #define WAVG2B "wavg2b" #include "dsputil_iwmmxt_rnd_template.c" #undef DEF #undef SET_RND #undef WAVG2B #define DEF(x, y) x ## _ ## y ##_iwmmxt #define SET_RND(regd) __asm__ volatile ("mov r12, #2 \n\t tbcsth " #regd ", r12":::"r12"); #define WAVG2B "wavg2br" #include "dsputil_iwmmxt_rnd_template.c" #undef DEF #undef SET_RND #undef WAVG2BR // need scheduling #define OP(AVG) \ __asm__ volatile ( \ /* alignment */ \ "and r12, %[pixels], #7 \n\t" \ "bic %[pixels], %[pixels], #7 \n\t" \ "tmcr wcgr1, r12 \n\t" \ \ "wldrd wr0, [%[pixels]] \n\t" \ "wldrd wr1, [%[pixels], #8] \n\t" \ "add %[pixels], %[pixels], %[line_size] \n\t" \ "walignr1 wr4, wr0, wr1 \n\t" \ \ "1: \n\t" \ \ "wldrd wr2, [%[pixels]] \n\t" \ "wldrd wr3, [%[pixels], #8] \n\t" \ "add %[pixels], %[pixels], %[line_size] \n\t" \ "pld [%[pixels]] \n\t" \ "walignr1 wr5, wr2, wr3 \n\t" \ AVG " wr6, wr4, wr5 \n\t" \ "wstrd wr6, [%[block]] \n\t" \ "add %[block], %[block], %[line_size] \n\t" \ \ "wldrd wr0, [%[pixels]] \n\t" \ "wldrd wr1, [%[pixels], #8] \n\t" \ "add %[pixels], %[pixels], %[line_size] \n\t" \ "walignr1 wr4, wr0, wr1 \n\t" \ "pld [%[pixels]] \n\t" \ AVG " wr6, wr4, wr5 \n\t" \ "wstrd wr6, [%[block]] \n\t" \ "add %[block], %[block], %[line_size] \n\t" \ \ "subs %[h], %[h], #2 \n\t" \ "bne 1b \n\t" \ : [block]"+r"(block), [pixels]"+r"(pixels), [h]"+r"(h) \ : [line_size]"r"(line_size) \ : "memory", "r12"); void put_pixels8_y2_iwmmxt(uint8_t *block, const uint8_t *pixels, const int line_size, int h) { OP("wavg2br"); } void put_no_rnd_pixels8_y2_iwmmxt(uint8_t *block, const uint8_t *pixels, const int line_size, int h) { OP("wavg2b"); } #undef OP void add_pixels_clamped_iwmmxt(const DCTELEM *block, uint8_t *pixels, int line_size) { uint8_t *pixels2 = pixels + line_size; __asm__ volatile ( "mov r12, #4 \n\t" "1: \n\t" "pld [%[pixels], %[line_size2]] \n\t" "pld [%[pixels2], %[line_size2]] \n\t" "wldrd wr4, [%[pixels]] \n\t" "wldrd wr5, [%[pixels2]] \n\t" "pld [%[block], #32] \n\t" "wunpckelub wr6, wr4 \n\t" "wldrd wr0, [%[block]] \n\t" "wunpckehub wr7, wr4 \n\t" "wldrd wr1, [%[block], #8] \n\t" "wunpckelub wr8, wr5 \n\t" "wldrd wr2, [%[block], #16] \n\t" "wunpckehub wr9, wr5 \n\t" "wldrd wr3, [%[block], #24] \n\t" "add %[block], %[block], #32 \n\t" "waddhss wr10, wr0, wr6 \n\t" "waddhss wr11, wr1, wr7 \n\t" "waddhss wr12, wr2, wr8 \n\t" "waddhss wr13, wr3, wr9 \n\t" "wpackhus wr14, wr10, wr11 \n\t" "wpackhus wr15, wr12, wr13 \n\t" "wstrd wr14, [%[pixels]] \n\t" "add %[pixels], %[pixels], %[line_size2] \n\t" "subs r12, r12, #1 \n\t" "wstrd wr15, [%[pixels2]] \n\t" "add %[pixels2], %[pixels2], %[line_size2] \n\t" "bne 1b \n\t" : [block]"+r"(block), [pixels]"+r"(pixels), [pixels2]"+r"(pixels2) : [line_size2]"r"(line_size << 1) : "cc", "memory", "r12"); } static void clear_blocks_iwmmxt(DCTELEM *blocks) { __asm__ volatile( "wzero wr0 \n\t" "mov r1, #(128 * 6 / 32) \n\t" "1: \n\t" "wstrd wr0, [%0] \n\t" "wstrd wr0, [%0, #8] \n\t" "wstrd wr0, [%0, #16] \n\t" "wstrd wr0, [%0, #24] \n\t" "subs r1, r1, #1 \n\t" "add %0, %0, #32 \n\t" "bne 1b \n\t" : "+r"(blocks) : : "r1" ); } static void nop(uint8_t *block, const uint8_t *pixels, int line_size, int h) { return; } /* A run time test is not simple. If this file is compiled in * then we should install the functions */ int mm_flags = FF_MM_IWMMXT; /* multimedia extension flags */ void ff_dsputil_init_iwmmxt(DSPContext* c, AVCodecContext *avctx) { if (avctx->dsp_mask) { if (avctx->dsp_mask & FF_MM_FORCE) mm_flags |= (avctx->dsp_mask & 0xffff); else mm_flags &= ~(avctx->dsp_mask & 0xffff); } if (!(mm_flags & FF_MM_IWMMXT)) return; c->add_pixels_clamped = add_pixels_clamped_iwmmxt; c->clear_blocks = clear_blocks_iwmmxt; c->put_pixels_tab[0][0] = put_pixels16_iwmmxt; c->put_pixels_tab[0][1] = put_pixels16_x2_iwmmxt; c->put_pixels_tab[0][2] = put_pixels16_y2_iwmmxt; c->put_pixels_tab[0][3] = put_pixels16_xy2_iwmmxt; c->put_no_rnd_pixels_tab[0][0] = put_pixels16_iwmmxt; c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_iwmmxt; c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_iwmmxt; c->put_no_rnd_pixels_tab[0][3] = put_no_rnd_pixels16_xy2_iwmmxt; c->put_pixels_tab[1][0] = put_pixels8_iwmmxt; c->put_pixels_tab[1][1] = put_pixels8_x2_iwmmxt; c->put_pixels_tab[1][2] = put_pixels8_y2_iwmmxt; c->put_pixels_tab[1][3] = put_pixels8_xy2_iwmmxt; c->put_no_rnd_pixels_tab[1][0] = put_pixels8_iwmmxt; c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_iwmmxt; c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_iwmmxt; c->put_no_rnd_pixels_tab[1][3] = put_no_rnd_pixels8_xy2_iwmmxt; c->avg_pixels_tab[0][0] = avg_pixels16_iwmmxt; c->avg_pixels_tab[0][1] = avg_pixels16_x2_iwmmxt; c->avg_pixels_tab[0][2] = avg_pixels16_y2_iwmmxt; c->avg_pixels_tab[0][3] = avg_pixels16_xy2_iwmmxt; c->avg_no_rnd_pixels_tab[0][0] = avg_pixels16_iwmmxt; c->avg_no_rnd_pixels_tab[0][1] = avg_no_rnd_pixels16_x2_iwmmxt; c->avg_no_rnd_pixels_tab[0][2] = avg_no_rnd_pixels16_y2_iwmmxt; c->avg_no_rnd_pixels_tab[0][3] = avg_no_rnd_pixels16_xy2_iwmmxt; c->avg_pixels_tab[1][0] = avg_pixels8_iwmmxt; c->avg_pixels_tab[1][1] = avg_pixels8_x2_iwmmxt; c->avg_pixels_tab[1][2] = avg_pixels8_y2_iwmmxt; c->avg_pixels_tab[1][3] = avg_pixels8_xy2_iwmmxt; c->avg_no_rnd_pixels_tab[1][0] = avg_no_rnd_pixels8_iwmmxt; c->avg_no_rnd_pixels_tab[1][1] = avg_no_rnd_pixels8_x2_iwmmxt; c->avg_no_rnd_pixels_tab[1][2] = avg_no_rnd_pixels8_y2_iwmmxt; c->avg_no_rnd_pixels_tab[1][3] = avg_no_rnd_pixels8_xy2_iwmmxt; }
123linslouis-android-video-cutter
jni/libavcodec/arm/dsputil_iwmmxt.c
C
asf20
8,884
/* * ARM NEON optimised integer operations * Copyright (c) 2009 Kostya Shishkov * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "asm.S" preserve8 .fpu neon .text function ff_scalarproduct_int16_neon, export=1 vmov.i16 q0, #0 vmov.i16 q1, #0 vmov.i16 q2, #0 vmov.i16 q3, #0 negs r3, r3 beq 2f vdup.s32 q12, r3 1: vld1.16 {d16-d17}, [r0]! vld1.16 {d20-d21}, [r1,:128]! vmull.s16 q12, d16, d20 vld1.16 {d18-d19}, [r0]! vmull.s16 q13, d17, d21 vld1.16 {d22-d23}, [r1,:128]! vmull.s16 q14, d18, d22 vmull.s16 q15, d19, d23 vshl.s32 q8, q12, q12 vshl.s32 q9, q13, q12 vadd.s32 q0, q0, q8 vshl.s32 q10, q14, q12 vadd.s32 q1, q1, q9 vshl.s32 q11, q15, q12 vadd.s32 q2, q2, q10 vadd.s32 q3, q3, q11 subs r2, r2, #16 bne 1b b 3f 2: vld1.16 {d16-d17}, [r0]! vld1.16 {d20-d21}, [r1,:128]! vmlal.s16 q0, d16, d20 vld1.16 {d18-d19}, [r0]! vmlal.s16 q1, d17, d21 vld1.16 {d22-d23}, [r1,:128]! vmlal.s16 q2, d18, d22 vmlal.s16 q3, d19, d23 subs r2, r2, #16 bne 2b 3: vpadd.s32 d16, d0, d1 vpadd.s32 d17, d2, d3 vpadd.s32 d10, d4, d5 vpadd.s32 d11, d6, d7 vpadd.s32 d0, d16, d17 vpadd.s32 d1, d10, d11 vpadd.s32 d2, d0, d1 vpaddl.s32 d3, d2 vmov.32 r0, d3[0] bx lr endfunc @ scalarproduct_and_madd_int16(/*aligned*/v0,v1,v2,order,mul) function ff_scalarproduct_and_madd_int16_neon, export=1 vld1.16 {d28[],d29[]}, [sp] vmov.i16 q0, #0 vmov.i16 q1, #0 vmov.i16 q2, #0 vmov.i16 q3, #0 mov r12, r0 1: vld1.16 {d16-d17}, [r0,:128]! vld1.16 {d18-d19}, [r1]! vld1.16 {d20-d21}, [r2]! vld1.16 {d22-d23}, [r0,:128]! vld1.16 {d24-d25}, [r1]! vld1.16 {d26-d27}, [r2]! vmul.s16 q10, q10, q14 vmul.s16 q13, q13, q14 vmlal.s16 q0, d16, d18 vmlal.s16 q1, d17, d19 vadd.s16 q10, q8, q10 vadd.s16 q13, q11, q13 vmlal.s16 q2, d22, d24 vmlal.s16 q3, d23, d25 vst1.16 {q10}, [r12,:128]! subs r3, r3, #16 vst1.16 {q13}, [r12,:128]! bne 1b vpadd.s32 d16, d0, d1 vpadd.s32 d17, d2, d3 vpadd.s32 d10, d4, d5 vpadd.s32 d11, d6, d7 vpadd.s32 d0, d16, d17 vpadd.s32 d1, d10, d11 vpadd.s32 d2, d0, d1 vpaddl.s32 d3, d2 vmov.32 r0, d3[0] bx lr endfunc
123linslouis-android-video-cutter
jni/libavcodec/arm/int_neon.S
Motorola 68K Assembly
asf20
4,106
/* * Copyright (c) 2010 Mans Rullgard <mans@mansr.com> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <stdint.h> #include "libavcodec/avcodec.h" #include "libavcodec/vp56dsp.h" void ff_vp6_edge_filter_hor_neon(uint8_t *yuv, int stride, int t); void ff_vp6_edge_filter_ver_neon(uint8_t *yuv, int stride, int t); void ff_vp56dsp_init_arm(VP56DSPContext *s, enum CodecID codec) { if (codec != CODEC_ID_VP5 && HAVE_NEON) { s->edge_filter_hor = ff_vp6_edge_filter_hor_neon; s->edge_filter_ver = ff_vp6_edge_filter_ver_neon; } }
123linslouis-android-video-cutter
jni/libavcodec/arm/vp56dsp_init_arm.c
C
asf20
1,276
/* * ARM NEON optimised DSP functions * Copyright (c) 2008 Mans Rullgard <mans@mansr.com> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "config.h" #include "asm.S" preserve8 .text .macro pixels16 avg=0 .if \avg mov ip, r0 .endif 1: vld1.64 {d0, d1}, [r1], r2 vld1.64 {d2, d3}, [r1], r2 vld1.64 {d4, d5}, [r1], r2 pld [r1, r2, lsl #2] vld1.64 {d6, d7}, [r1], r2 pld [r1] pld [r1, r2] pld [r1, r2, lsl #1] .if \avg vld1.64 {d16,d17}, [ip,:128], r2 vrhadd.u8 q0, q0, q8 vld1.64 {d18,d19}, [ip,:128], r2 vrhadd.u8 q1, q1, q9 vld1.64 {d20,d21}, [ip,:128], r2 vrhadd.u8 q2, q2, q10 vld1.64 {d22,d23}, [ip,:128], r2 vrhadd.u8 q3, q3, q11 .endif subs r3, r3, #4 vst1.64 {d0, d1}, [r0,:128], r2 vst1.64 {d2, d3}, [r0,:128], r2 vst1.64 {d4, d5}, [r0,:128], r2 vst1.64 {d6, d7}, [r0,:128], r2 bne 1b bx lr .endm .macro pixels16_x2 vhadd=vrhadd.u8 1: vld1.64 {d0-d2}, [r1], r2 vld1.64 {d4-d6}, [r1], r2 pld [r1] pld [r1, r2] subs r3, r3, #2 vext.8 q1, q0, q1, #1 \vhadd q0, q0, q1 vext.8 q3, q2, q3, #1 \vhadd q2, q2, q3 vst1.64 {d0, d1}, [r0,:128], r2 vst1.64 {d4, d5}, [r0,:128], r2 bne 1b bx lr .endm .macro pixels16_y2 vhadd=vrhadd.u8 vld1.64 {d0, d1}, [r1], r2 vld1.64 {d2, d3}, [r1], r2 1: subs r3, r3, #2 \vhadd q2, q0, q1 vld1.64 {d0, d1}, [r1], r2 \vhadd q3, q0, q1 vld1.64 {d2, d3}, [r1], r2 pld [r1] pld [r1, r2] vst1.64 {d4, d5}, [r0,:128], r2 vst1.64 {d6, d7}, [r0,:128], r2 bne 1b bx lr .endm .macro pixels16_xy2 vshrn=vrshrn.u16 no_rnd=0 vld1.64 {d0-d2}, [r1], r2 vld1.64 {d4-d6}, [r1], r2 .if \no_rnd vmov.i16 q13, #1 .endif pld [r1] pld [r1, r2] vext.8 q1, q0, q1, #1 vext.8 q3, q2, q3, #1 vaddl.u8 q8, d0, d2 vaddl.u8 q10, d1, d3 vaddl.u8 q9, d4, d6 vaddl.u8 q11, d5, d7 1: subs r3, r3, #2 vld1.64 {d0-d2}, [r1], r2 vadd.u16 q12, q8, q9 pld [r1] .if \no_rnd vadd.u16 q12, q12, q13 .endif vext.8 q15, q0, q1, #1 vadd.u16 q1 , q10, q11 \vshrn d28, q12, #2 .if \no_rnd vadd.u16 q1, q1, q13 .endif \vshrn d29, q1, #2 vaddl.u8 q8, d0, d30 vld1.64 {d2-d4}, [r1], r2 vaddl.u8 q10, d1, d31 vst1.64 {d28,d29}, [r0,:128], r2 vadd.u16 q12, q8, q9 pld [r1, r2] .if \no_rnd vadd.u16 q12, q12, q13 .endif vext.8 q2, q1, q2, #1 vadd.u16 q0, q10, q11 \vshrn d30, q12, #2 .if \no_rnd vadd.u16 q0, q0, q13 .endif \vshrn d31, q0, #2 vaddl.u8 q9, d2, d4 vaddl.u8 q11, d3, d5 vst1.64 {d30,d31}, [r0,:128], r2 bgt 1b bx lr .endm .macro pixels8 avg=0 1: vld1.64 {d0}, [r1], r2 vld1.64 {d1}, [r1], r2 vld1.64 {d2}, [r1], r2 pld [r1, r2, lsl #2] vld1.64 {d3}, [r1], r2 pld [r1] pld [r1, r2] pld [r1, r2, lsl #1] .if \avg vld1.64 {d4}, [r0,:64], r2 vrhadd.u8 d0, d0, d4 vld1.64 {d5}, [r0,:64], r2 vrhadd.u8 d1, d1, d5 vld1.64 {d6}, [r0,:64], r2 vrhadd.u8 d2, d2, d6 vld1.64 {d7}, [r0,:64], r2 vrhadd.u8 d3, d3, d7 sub r0, r0, r2, lsl #2 .endif subs r3, r3, #4 vst1.64 {d0}, [r0,:64], r2 vst1.64 {d1}, [r0,:64], r2 vst1.64 {d2}, [r0,:64], r2 vst1.64 {d3}, [r0,:64], r2 bne 1b bx lr .endm .macro pixels8_x2 vhadd=vrhadd.u8 1: vld1.64 {d0, d1}, [r1], r2 vext.8 d1, d0, d1, #1 vld1.64 {d2, d3}, [r1], r2 vext.8 d3, d2, d3, #1 pld [r1] pld [r1, r2] subs r3, r3, #2 vswp d1, d2 \vhadd q0, q0, q1 vst1.64 {d0}, [r0,:64], r2 vst1.64 {d1}, [r0,:64], r2 bne 1b bx lr .endm .macro pixels8_y2 vhadd=vrhadd.u8 vld1.64 {d0}, [r1], r2 vld1.64 {d1}, [r1], r2 1: subs r3, r3, #2 \vhadd d4, d0, d1 vld1.64 {d0}, [r1], r2 \vhadd d5, d0, d1 vld1.64 {d1}, [r1], r2 pld [r1] pld [r1, r2] vst1.64 {d4}, [r0,:64], r2 vst1.64 {d5}, [r0,:64], r2 bne 1b bx lr .endm .macro pixels8_xy2 vshrn=vrshrn.u16 no_rnd=0 vld1.64 {d0, d1}, [r1], r2 vld1.64 {d2, d3}, [r1], r2 .if \no_rnd vmov.i16 q11, #1 .endif pld [r1] pld [r1, r2] vext.8 d4, d0, d1, #1 vext.8 d6, d2, d3, #1 vaddl.u8 q8, d0, d4 vaddl.u8 q9, d2, d6 1: subs r3, r3, #2 vld1.64 {d0, d1}, [r1], r2 pld [r1] vadd.u16 q10, q8, q9 vext.8 d4, d0, d1, #1 .if \no_rnd vadd.u16 q10, q10, q11 .endif vaddl.u8 q8, d0, d4 \vshrn d5, q10, #2 vld1.64 {d2, d3}, [r1], r2 vadd.u16 q10, q8, q9 pld [r1, r2] .if \no_rnd vadd.u16 q10, q10, q11 .endif vst1.64 {d5}, [r0,:64], r2 \vshrn d7, q10, #2 vext.8 d6, d2, d3, #1 vaddl.u8 q9, d2, d6 vst1.64 {d7}, [r0,:64], r2 bgt 1b bx lr .endm .macro pixfunc pfx name suf rnd_op args:vararg function ff_\pfx\name\suf\()_neon, export=1 \name \rnd_op \args endfunc .endm .macro pixfunc2 pfx name args:vararg pixfunc \pfx \name pixfunc \pfx \name \args .endm function ff_put_h264_qpel16_mc00_neon, export=1 mov r3, #16 endfunc pixfunc put_ pixels16 pixfunc2 put_ pixels16_x2, _no_rnd, vhadd.u8 pixfunc2 put_ pixels16_y2, _no_rnd, vhadd.u8 pixfunc2 put_ pixels16_xy2, _no_rnd, vshrn.u16, 1 function ff_avg_h264_qpel16_mc00_neon, export=1 mov r3, #16 endfunc pixfunc avg_ pixels16,, 1 function ff_put_h264_qpel8_mc00_neon, export=1 mov r3, #8 endfunc pixfunc put_ pixels8 pixfunc2 put_ pixels8_x2, _no_rnd, vhadd.u8 pixfunc2 put_ pixels8_y2, _no_rnd, vhadd.u8 pixfunc2 put_ pixels8_xy2, _no_rnd, vshrn.u16, 1 function ff_avg_h264_qpel8_mc00_neon, export=1 mov r3, #8 endfunc pixfunc avg_ pixels8,, 1 function ff_put_pixels_clamped_neon, export=1 vld1.64 {d16-d19}, [r0,:128]! vqmovun.s16 d0, q8 vld1.64 {d20-d23}, [r0,:128]! vqmovun.s16 d1, q9 vld1.64 {d24-d27}, [r0,:128]! vqmovun.s16 d2, q10 vld1.64 {d28-d31}, [r0,:128]! vqmovun.s16 d3, q11 vst1.64 {d0}, [r1,:64], r2 vqmovun.s16 d4, q12 vst1.64 {d1}, [r1,:64], r2 vqmovun.s16 d5, q13 vst1.64 {d2}, [r1,:64], r2 vqmovun.s16 d6, q14 vst1.64 {d3}, [r1,:64], r2 vqmovun.s16 d7, q15 vst1.64 {d4}, [r1,:64], r2 vst1.64 {d5}, [r1,:64], r2 vst1.64 {d6}, [r1,:64], r2 vst1.64 {d7}, [r1,:64], r2 bx lr endfunc function ff_put_signed_pixels_clamped_neon, export=1 vmov.u8 d31, #128 vld1.64 {d16-d17}, [r0,:128]! vqmovn.s16 d0, q8 vld1.64 {d18-d19}, [r0,:128]! vqmovn.s16 d1, q9 vld1.64 {d16-d17}, [r0,:128]! vqmovn.s16 d2, q8 vld1.64 {d18-d19}, [r0,:128]! vadd.u8 d0, d0, d31 vld1.64 {d20-d21}, [r0,:128]! vadd.u8 d1, d1, d31 vld1.64 {d22-d23}, [r0,:128]! vadd.u8 d2, d2, d31 vst1.64 {d0}, [r1,:64], r2 vqmovn.s16 d3, q9 vst1.64 {d1}, [r1,:64], r2 vqmovn.s16 d4, q10 vst1.64 {d2}, [r1,:64], r2 vqmovn.s16 d5, q11 vld1.64 {d24-d25}, [r0,:128]! vadd.u8 d3, d3, d31 vld1.64 {d26-d27}, [r0,:128]! vadd.u8 d4, d4, d31 vadd.u8 d5, d5, d31 vst1.64 {d3}, [r1,:64], r2 vqmovn.s16 d6, q12 vst1.64 {d4}, [r1,:64], r2 vqmovn.s16 d7, q13 vst1.64 {d5}, [r1,:64], r2 vadd.u8 d6, d6, d31 vadd.u8 d7, d7, d31 vst1.64 {d6}, [r1,:64], r2 vst1.64 {d7}, [r1,:64], r2 bx lr endfunc function ff_add_pixels_clamped_neon, export=1 mov r3, r1 vld1.64 {d16}, [r1,:64], r2 vld1.64 {d0-d1}, [r0,:128]! vaddw.u8 q0, q0, d16 vld1.64 {d17}, [r1,:64], r2 vld1.64 {d2-d3}, [r0,:128]! vqmovun.s16 d0, q0 vld1.64 {d18}, [r1,:64], r2 vaddw.u8 q1, q1, d17 vld1.64 {d4-d5}, [r0,:128]! vaddw.u8 q2, q2, d18 vst1.64 {d0}, [r3,:64], r2 vqmovun.s16 d2, q1 vld1.64 {d19}, [r1,:64], r2 vld1.64 {d6-d7}, [r0,:128]! vaddw.u8 q3, q3, d19 vqmovun.s16 d4, q2 vst1.64 {d2}, [r3,:64], r2 vld1.64 {d16}, [r1,:64], r2 vqmovun.s16 d6, q3 vld1.64 {d0-d1}, [r0,:128]! vaddw.u8 q0, q0, d16 vst1.64 {d4}, [r3,:64], r2 vld1.64 {d17}, [r1,:64], r2 vld1.64 {d2-d3}, [r0,:128]! vaddw.u8 q1, q1, d17 vst1.64 {d6}, [r3,:64], r2 vqmovun.s16 d0, q0 vld1.64 {d18}, [r1,:64], r2 vld1.64 {d4-d5}, [r0,:128]! vaddw.u8 q2, q2, d18 vst1.64 {d0}, [r3,:64], r2 vqmovun.s16 d2, q1 vld1.64 {d19}, [r1,:64], r2 vqmovun.s16 d4, q2 vld1.64 {d6-d7}, [r0,:128]! vaddw.u8 q3, q3, d19 vst1.64 {d2}, [r3,:64], r2 vqmovun.s16 d6, q3 vst1.64 {d4}, [r3,:64], r2 vst1.64 {d6}, [r3,:64], r2 bx lr endfunc function ff_float_to_int16_neon, export=1 subs r2, r2, #8 vld1.64 {d0-d1}, [r1,:128]! vcvt.s32.f32 q8, q0, #16 vld1.64 {d2-d3}, [r1,:128]! vcvt.s32.f32 q9, q1, #16 beq 3f bics ip, r2, #15 beq 2f 1: subs ip, ip, #16 vshrn.s32 d4, q8, #16 vld1.64 {d0-d1}, [r1,:128]! vcvt.s32.f32 q0, q0, #16 vshrn.s32 d5, q9, #16 vld1.64 {d2-d3}, [r1,:128]! vcvt.s32.f32 q1, q1, #16 vshrn.s32 d6, q0, #16 vst1.64 {d4-d5}, [r0,:128]! vshrn.s32 d7, q1, #16 vld1.64 {d16-d17},[r1,:128]! vcvt.s32.f32 q8, q8, #16 vld1.64 {d18-d19},[r1,:128]! vcvt.s32.f32 q9, q9, #16 vst1.64 {d6-d7}, [r0,:128]! bne 1b ands r2, r2, #15 beq 3f 2: vld1.64 {d0-d1}, [r1,:128]! vshrn.s32 d4, q8, #16 vcvt.s32.f32 q0, q0, #16 vld1.64 {d2-d3}, [r1,:128]! vshrn.s32 d5, q9, #16 vcvt.s32.f32 q1, q1, #16 vshrn.s32 d6, q0, #16 vst1.64 {d4-d5}, [r0,:128]! vshrn.s32 d7, q1, #16 vst1.64 {d6-d7}, [r0,:128]! bx lr 3: vshrn.s32 d4, q8, #16 vshrn.s32 d5, q9, #16 vst1.64 {d4-d5}, [r0,:128]! bx lr endfunc function ff_float_to_int16_interleave_neon, export=1 cmp r3, #2 ldrlt r1, [r1] blt ff_float_to_int16_neon bne 4f ldr r3, [r1] ldr r1, [r1, #4] subs r2, r2, #8 vld1.64 {d0-d1}, [r3,:128]! vcvt.s32.f32 q8, q0, #16 vld1.64 {d2-d3}, [r3,:128]! vcvt.s32.f32 q9, q1, #16 vld1.64 {d20-d21},[r1,:128]! vcvt.s32.f32 q10, q10, #16 vld1.64 {d22-d23},[r1,:128]! vcvt.s32.f32 q11, q11, #16 beq 3f bics ip, r2, #15 beq 2f 1: subs ip, ip, #16 vld1.64 {d0-d1}, [r3,:128]! vcvt.s32.f32 q0, q0, #16 vsri.32 q10, q8, #16 vld1.64 {d2-d3}, [r3,:128]! vcvt.s32.f32 q1, q1, #16 vld1.64 {d24-d25},[r1,:128]! vcvt.s32.f32 q12, q12, #16 vld1.64 {d26-d27},[r1,:128]! vsri.32 q11, q9, #16 vst1.64 {d20-d21},[r0,:128]! vcvt.s32.f32 q13, q13, #16 vst1.64 {d22-d23},[r0,:128]! vsri.32 q12, q0, #16 vld1.64 {d16-d17},[r3,:128]! vsri.32 q13, q1, #16 vst1.64 {d24-d25},[r0,:128]! vcvt.s32.f32 q8, q8, #16 vld1.64 {d18-d19},[r3,:128]! vcvt.s32.f32 q9, q9, #16 vld1.64 {d20-d21},[r1,:128]! vcvt.s32.f32 q10, q10, #16 vld1.64 {d22-d23},[r1,:128]! vcvt.s32.f32 q11, q11, #16 vst1.64 {d26-d27},[r0,:128]! bne 1b ands r2, r2, #15 beq 3f 2: vsri.32 q10, q8, #16 vld1.64 {d0-d1}, [r3,:128]! vcvt.s32.f32 q0, q0, #16 vld1.64 {d2-d3}, [r3,:128]! vcvt.s32.f32 q1, q1, #16 vld1.64 {d24-d25},[r1,:128]! vcvt.s32.f32 q12, q12, #16 vsri.32 q11, q9, #16 vld1.64 {d26-d27},[r1,:128]! vcvt.s32.f32 q13, q13, #16 vst1.64 {d20-d21},[r0,:128]! vsri.32 q12, q0, #16 vst1.64 {d22-d23},[r0,:128]! vsri.32 q13, q1, #16 vst1.64 {d24-d27},[r0,:128]! bx lr 3: vsri.32 q10, q8, #16 vsri.32 q11, q9, #16 vst1.64 {d20-d23},[r0,:128]! bx lr 4: push {r4-r8,lr} cmp r3, #4 lsl ip, r3, #1 blt 4f @ 4 channels 5: ldmia r1!, {r4-r7} mov lr, r2 mov r8, r0 vld1.64 {d16-d17},[r4,:128]! vcvt.s32.f32 q8, q8, #16 vld1.64 {d18-d19},[r5,:128]! vcvt.s32.f32 q9, q9, #16 vld1.64 {d20-d21},[r6,:128]! vcvt.s32.f32 q10, q10, #16 vld1.64 {d22-d23},[r7,:128]! vcvt.s32.f32 q11, q11, #16 6: subs lr, lr, #8 vld1.64 {d0-d1}, [r4,:128]! vcvt.s32.f32 q0, q0, #16 vsri.32 q9, q8, #16 vld1.64 {d2-d3}, [r5,:128]! vcvt.s32.f32 q1, q1, #16 vsri.32 q11, q10, #16 vld1.64 {d4-d5}, [r6,:128]! vcvt.s32.f32 q2, q2, #16 vzip.32 d18, d22 vld1.64 {d6-d7}, [r7,:128]! vcvt.s32.f32 q3, q3, #16 vzip.32 d19, d23 vst1.64 {d18}, [r8], ip vsri.32 q1, q0, #16 vst1.64 {d22}, [r8], ip vsri.32 q3, q2, #16 vst1.64 {d19}, [r8], ip vzip.32 d2, d6 vst1.64 {d23}, [r8], ip vzip.32 d3, d7 beq 7f vld1.64 {d16-d17},[r4,:128]! vcvt.s32.f32 q8, q8, #16 vst1.64 {d2}, [r8], ip vld1.64 {d18-d19},[r5,:128]! vcvt.s32.f32 q9, q9, #16 vst1.64 {d6}, [r8], ip vld1.64 {d20-d21},[r6,:128]! vcvt.s32.f32 q10, q10, #16 vst1.64 {d3}, [r8], ip vld1.64 {d22-d23},[r7,:128]! vcvt.s32.f32 q11, q11, #16 vst1.64 {d7}, [r8], ip b 6b 7: vst1.64 {d2}, [r8], ip vst1.64 {d6}, [r8], ip vst1.64 {d3}, [r8], ip vst1.64 {d7}, [r8], ip subs r3, r3, #4 popeq {r4-r8,pc} cmp r3, #4 add r0, r0, #8 bge 5b @ 2 channels 4: cmp r3, #2 blt 4f ldmia r1!, {r4-r5} mov lr, r2 mov r8, r0 tst lr, #8 vld1.64 {d16-d17},[r4,:128]! vcvt.s32.f32 q8, q8, #16 vld1.64 {d18-d19},[r5,:128]! vcvt.s32.f32 q9, q9, #16 vld1.64 {d20-d21},[r4,:128]! vcvt.s32.f32 q10, q10, #16 vld1.64 {d22-d23},[r5,:128]! vcvt.s32.f32 q11, q11, #16 beq 6f subs lr, lr, #8 beq 7f vsri.32 d18, d16, #16 vsri.32 d19, d17, #16 vld1.64 {d16-d17},[r4,:128]! vcvt.s32.f32 q8, q8, #16 vst1.32 {d18[0]}, [r8], ip vsri.32 d22, d20, #16 vst1.32 {d18[1]}, [r8], ip vsri.32 d23, d21, #16 vst1.32 {d19[0]}, [r8], ip vst1.32 {d19[1]}, [r8], ip vld1.64 {d18-d19},[r5,:128]! vcvt.s32.f32 q9, q9, #16 vst1.32 {d22[0]}, [r8], ip vst1.32 {d22[1]}, [r8], ip vld1.64 {d20-d21},[r4,:128]! vcvt.s32.f32 q10, q10, #16 vst1.32 {d23[0]}, [r8], ip vst1.32 {d23[1]}, [r8], ip vld1.64 {d22-d23},[r5,:128]! vcvt.s32.f32 q11, q11, #16 6: subs lr, lr, #16 vld1.64 {d0-d1}, [r4,:128]! vcvt.s32.f32 q0, q0, #16 vsri.32 d18, d16, #16 vld1.64 {d2-d3}, [r5,:128]! vcvt.s32.f32 q1, q1, #16 vsri.32 d19, d17, #16 vld1.64 {d4-d5}, [r4,:128]! vcvt.s32.f32 q2, q2, #16 vld1.64 {d6-d7}, [r5,:128]! vcvt.s32.f32 q3, q3, #16 vst1.32 {d18[0]}, [r8], ip vsri.32 d22, d20, #16 vst1.32 {d18[1]}, [r8], ip vsri.32 d23, d21, #16 vst1.32 {d19[0]}, [r8], ip vsri.32 d2, d0, #16 vst1.32 {d19[1]}, [r8], ip vsri.32 d3, d1, #16 vst1.32 {d22[0]}, [r8], ip vsri.32 d6, d4, #16 vst1.32 {d22[1]}, [r8], ip vsri.32 d7, d5, #16 vst1.32 {d23[0]}, [r8], ip vst1.32 {d23[1]}, [r8], ip beq 6f vld1.64 {d16-d17},[r4,:128]! vcvt.s32.f32 q8, q8, #16 vst1.32 {d2[0]}, [r8], ip vst1.32 {d2[1]}, [r8], ip vld1.64 {d18-d19},[r5,:128]! vcvt.s32.f32 q9, q9, #16 vst1.32 {d3[0]}, [r8], ip vst1.32 {d3[1]}, [r8], ip vld1.64 {d20-d21},[r4,:128]! vcvt.s32.f32 q10, q10, #16 vst1.32 {d6[0]}, [r8], ip vst1.32 {d6[1]}, [r8], ip vld1.64 {d22-d23},[r5,:128]! vcvt.s32.f32 q11, q11, #16 vst1.32 {d7[0]}, [r8], ip vst1.32 {d7[1]}, [r8], ip bgt 6b 6: vst1.32 {d2[0]}, [r8], ip vst1.32 {d2[1]}, [r8], ip vst1.32 {d3[0]}, [r8], ip vst1.32 {d3[1]}, [r8], ip vst1.32 {d6[0]}, [r8], ip vst1.32 {d6[1]}, [r8], ip vst1.32 {d7[0]}, [r8], ip vst1.32 {d7[1]}, [r8], ip b 8f 7: vsri.32 d18, d16, #16 vsri.32 d19, d17, #16 vst1.32 {d18[0]}, [r8], ip vsri.32 d22, d20, #16 vst1.32 {d18[1]}, [r8], ip vsri.32 d23, d21, #16 vst1.32 {d19[0]}, [r8], ip vst1.32 {d19[1]}, [r8], ip vst1.32 {d22[0]}, [r8], ip vst1.32 {d22[1]}, [r8], ip vst1.32 {d23[0]}, [r8], ip vst1.32 {d23[1]}, [r8], ip 8: subs r3, r3, #2 add r0, r0, #4 popeq {r4-r8,pc} @ 1 channel 4: ldr r4, [r1],#4 tst r2, #8 mov lr, r2 mov r5, r0 vld1.64 {d0-d1}, [r4,:128]! vcvt.s32.f32 q0, q0, #16 vld1.64 {d2-d3}, [r4,:128]! vcvt.s32.f32 q1, q1, #16 bne 8f 6: subs lr, lr, #16 vld1.64 {d4-d5}, [r4,:128]! vcvt.s32.f32 q2, q2, #16 vld1.64 {d6-d7}, [r4,:128]! vcvt.s32.f32 q3, q3, #16 vst1.16 {d0[1]}, [r5,:16], ip vst1.16 {d0[3]}, [r5,:16], ip vst1.16 {d1[1]}, [r5,:16], ip vst1.16 {d1[3]}, [r5,:16], ip vst1.16 {d2[1]}, [r5,:16], ip vst1.16 {d2[3]}, [r5,:16], ip vst1.16 {d3[1]}, [r5,:16], ip vst1.16 {d3[3]}, [r5,:16], ip beq 7f vld1.64 {d0-d1}, [r4,:128]! vcvt.s32.f32 q0, q0, #16 vld1.64 {d2-d3}, [r4,:128]! vcvt.s32.f32 q1, q1, #16 7: vst1.16 {d4[1]}, [r5,:16], ip vst1.16 {d4[3]}, [r5,:16], ip vst1.16 {d5[1]}, [r5,:16], ip vst1.16 {d5[3]}, [r5,:16], ip vst1.16 {d6[1]}, [r5,:16], ip vst1.16 {d6[3]}, [r5,:16], ip vst1.16 {d7[1]}, [r5,:16], ip vst1.16 {d7[3]}, [r5,:16], ip bgt 6b pop {r4-r8,pc} 8: subs lr, lr, #8 vst1.16 {d0[1]}, [r5,:16], ip vst1.16 {d0[3]}, [r5,:16], ip vst1.16 {d1[1]}, [r5,:16], ip vst1.16 {d1[3]}, [r5,:16], ip vst1.16 {d2[1]}, [r5,:16], ip vst1.16 {d2[3]}, [r5,:16], ip vst1.16 {d3[1]}, [r5,:16], ip vst1.16 {d3[3]}, [r5,:16], ip popeq {r4-r8,pc} vld1.64 {d0-d1}, [r4,:128]! vcvt.s32.f32 q0, q0, #16 vld1.64 {d2-d3}, [r4,:128]! vcvt.s32.f32 q1, q1, #16 b 6b endfunc function ff_vector_fmul_neon, export=1 mov r3, r0 subs r2, r2, #8 vld1.64 {d0-d3}, [r0,:128]! vld1.64 {d4-d7}, [r1,:128]! vmul.f32 q8, q0, q2 vmul.f32 q9, q1, q3 beq 3f bics ip, r2, #15 beq 2f 1: subs ip, ip, #16 vld1.64 {d0-d1}, [r0,:128]! vld1.64 {d4-d5}, [r1,:128]! vmul.f32 q10, q0, q2 vld1.64 {d2-d3}, [r0,:128]! vld1.64 {d6-d7}, [r1,:128]! vmul.f32 q11, q1, q3 vst1.64 {d16-d19},[r3,:128]! vld1.64 {d0-d1}, [r0,:128]! vld1.64 {d4-d5}, [r1,:128]! vmul.f32 q8, q0, q2 vld1.64 {d2-d3}, [r0,:128]! vld1.64 {d6-d7}, [r1,:128]! vmul.f32 q9, q1, q3 vst1.64 {d20-d23},[r3,:128]! bne 1b ands r2, r2, #15 beq 3f 2: vld1.64 {d0-d1}, [r0,:128]! vld1.64 {d4-d5}, [r1,:128]! vst1.64 {d16-d17},[r3,:128]! vmul.f32 q8, q0, q2 vld1.64 {d2-d3}, [r0,:128]! vld1.64 {d6-d7}, [r1,:128]! vst1.64 {d18-d19},[r3,:128]! vmul.f32 q9, q1, q3 3: vst1.64 {d16-d19},[r3,:128]! bx lr endfunc function ff_vector_fmul_window_neon, export=1 VFP vdup.32 q8, d0[0] NOVFP vld1.32 {d16[],d17[]}, [sp,:32] push {r4,r5,lr} VFP ldr lr, [sp, #12] NOVFP ldr lr, [sp, #16] sub r2, r2, #8 sub r5, lr, #2 add r2, r2, r5, lsl #2 add r4, r3, r5, lsl #3 add ip, r0, r5, lsl #3 mov r5, #-16 vld1.64 {d0,d1}, [r1,:128]! vld1.64 {d2,d3}, [r2,:128], r5 vld1.64 {d4,d5}, [r3,:128]! vld1.64 {d6,d7}, [r4,:128], r5 1: subs lr, lr, #4 vmov q11, q8 vmla.f32 d22, d0, d4 vmov q10, q8 vmla.f32 d23, d1, d5 vrev64.32 q3, q3 vmla.f32 d20, d0, d7 vrev64.32 q1, q1 vmla.f32 d21, d1, d6 beq 2f vmla.f32 d22, d3, d7 vld1.64 {d0,d1}, [r1,:128]! vmla.f32 d23, d2, d6 vld1.64 {d18,d19},[r2,:128], r5 vmls.f32 d20, d3, d4 vld1.64 {d24,d25},[r3,:128]! vmls.f32 d21, d2, d5 vld1.64 {d6,d7}, [r4,:128], r5 vmov q1, q9 vrev64.32 q11, q11 vmov q2, q12 vswp d22, d23 vst1.64 {d20,d21},[r0,:128]! vst1.64 {d22,d23},[ip,:128], r5 b 1b 2: vmla.f32 d22, d3, d7 vmla.f32 d23, d2, d6 vmls.f32 d20, d3, d4 vmls.f32 d21, d2, d5 vrev64.32 q11, q11 vswp d22, d23 vst1.64 {d20,d21},[r0,:128]! vst1.64 {d22,d23},[ip,:128], r5 pop {r4,r5,pc} endfunc #if CONFIG_VORBIS_DECODER function ff_vorbis_inverse_coupling_neon, export=1 vmov.i32 q10, #1<<31 subs r2, r2, #4 mov r3, r0 mov r12, r1 beq 3f vld1.32 {d24-d25},[r1,:128]! vld1.32 {d22-d23},[r0,:128]! vcle.s32 q8, q12, #0 vand q9, q11, q10 veor q12, q12, q9 vand q2, q12, q8 vbic q3, q12, q8 vadd.f32 q12, q11, q2 vsub.f32 q11, q11, q3 1: vld1.32 {d2-d3}, [r1,:128]! vld1.32 {d0-d1}, [r0,:128]! vcle.s32 q8, q1, #0 vand q9, q0, q10 veor q1, q1, q9 vst1.32 {d24-d25},[r3, :128]! vst1.32 {d22-d23},[r12,:128]! vand q2, q1, q8 vbic q3, q1, q8 vadd.f32 q1, q0, q2 vsub.f32 q0, q0, q3 subs r2, r2, #8 ble 2f vld1.32 {d24-d25},[r1,:128]! vld1.32 {d22-d23},[r0,:128]! vcle.s32 q8, q12, #0 vand q9, q11, q10 veor q12, q12, q9 vst1.32 {d2-d3}, [r3, :128]! vst1.32 {d0-d1}, [r12,:128]! vand q2, q12, q8 vbic q3, q12, q8 vadd.f32 q12, q11, q2 vsub.f32 q11, q11, q3 b 1b 2: vst1.32 {d2-d3}, [r3, :128]! vst1.32 {d0-d1}, [r12,:128]! bxlt lr 3: vld1.32 {d2-d3}, [r1,:128] vld1.32 {d0-d1}, [r0,:128] vcle.s32 q8, q1, #0 vand q9, q0, q10 veor q1, q1, q9 vand q2, q1, q8 vbic q3, q1, q8 vadd.f32 q1, q0, q2 vsub.f32 q0, q0, q3 vst1.32 {d2-d3}, [r0,:128]! vst1.32 {d0-d1}, [r1,:128]! bx lr endfunc #endif function ff_vector_fmul_scalar_neon, export=1 VFP len .req r2 NOVFP len .req r3 VFP vdup.32 q8, d0[0] NOVFP vdup.32 q8, r2 bics r12, len, #15 beq 3f vld1.32 {q0},[r1,:128]! vld1.32 {q1},[r1,:128]! 1: vmul.f32 q0, q0, q8 vld1.32 {q2},[r1,:128]! vmul.f32 q1, q1, q8 vld1.32 {q3},[r1,:128]! vmul.f32 q2, q2, q8 vst1.32 {q0},[r0,:128]! vmul.f32 q3, q3, q8 vst1.32 {q1},[r0,:128]! subs r12, r12, #16 beq 2f vld1.32 {q0},[r1,:128]! vst1.32 {q2},[r0,:128]! vld1.32 {q1},[r1,:128]! vst1.32 {q3},[r0,:128]! b 1b 2: vst1.32 {q2},[r0,:128]! vst1.32 {q3},[r0,:128]! ands len, len, #15 bxeq lr 3: vld1.32 {q0},[r1,:128]! vmul.f32 q0, q0, q8 vst1.32 {q0},[r0,:128]! subs len, len, #4 bgt 3b bx lr .unreq len endfunc function ff_vector_fmul_sv_scalar_2_neon, export=1 VFP vdup.32 d16, d0[0] NOVFP vdup.32 d16, r3 NOVFP ldr r3, [sp] vld1.32 {d0},[r1,:64]! vld1.32 {d1},[r1,:64]! 1: subs r3, r3, #4 vmul.f32 d4, d0, d16 vmul.f32 d5, d1, d16 ldr r12, [r2], #4 vld1.32 {d2},[r12,:64] ldr r12, [r2], #4 vld1.32 {d3},[r12,:64] vmul.f32 d4, d4, d2 vmul.f32 d5, d5, d3 beq 2f vld1.32 {d0},[r1,:64]! vld1.32 {d1},[r1,:64]! vst1.32 {d4},[r0,:64]! vst1.32 {d5},[r0,:64]! b 1b 2: vst1.32 {d4},[r0,:64]! vst1.32 {d5},[r0,:64]! bx lr endfunc function ff_vector_fmul_sv_scalar_4_neon, export=1 VFP vdup.32 q10, d0[0] NOVFP vdup.32 q10, r3 NOVFP ldr r3, [sp] push {lr} bics lr, r3, #7 beq 3f vld1.32 {q0},[r1,:128]! vld1.32 {q2},[r1,:128]! 1: ldr r12, [r2], #4 vld1.32 {q1},[r12,:128] ldr r12, [r2], #4 vld1.32 {q3},[r12,:128] vmul.f32 q8, q0, q10 vmul.f32 q8, q8, q1 vmul.f32 q9, q2, q10 vmul.f32 q9, q9, q3 subs lr, lr, #8 beq 2f vld1.32 {q0},[r1,:128]! vld1.32 {q2},[r1,:128]! vst1.32 {q8},[r0,:128]! vst1.32 {q9},[r0,:128]! b 1b 2: vst1.32 {q8},[r0,:128]! vst1.32 {q9},[r0,:128]! ands r3, r3, #7 popeq {pc} 3: vld1.32 {q0},[r1,:128]! ldr r12, [r2], #4 vld1.32 {q1},[r12,:128] vmul.f32 q0, q0, q10 vmul.f32 q0, q0, q1 vst1.32 {q0},[r0,:128]! subs r3, r3, #4 bgt 3b pop {pc} endfunc function ff_sv_fmul_scalar_2_neon, export=1 VFP len .req r2 NOVFP len .req r3 VFP vdup.32 q8, d0[0] NOVFP vdup.32 q8, r2 ldr r12, [r1], #4 vld1.32 {d0},[r12,:64] ldr r12, [r1], #4 vld1.32 {d1},[r12,:64] 1: vmul.f32 q1, q0, q8 subs len, len, #4 beq 2f ldr r12, [r1], #4 vld1.32 {d0},[r12,:64] ldr r12, [r1], #4 vld1.32 {d1},[r12,:64] vst1.32 {q1},[r0,:128]! b 1b 2: vst1.32 {q1},[r0,:128]! bx lr .unreq len endfunc function ff_sv_fmul_scalar_4_neon, export=1 VFP len .req r2 NOVFP len .req r3 VFP vdup.32 q8, d0[0] NOVFP vdup.32 q8, r2 1: ldr r12, [r1], #4 vld1.32 {q0},[r12,:128] vmul.f32 q0, q0, q8 vst1.32 {q0},[r0,:128]! subs len, len, #4 bgt 1b bx lr .unreq len endfunc function ff_butterflies_float_neon, export=1 1: vld1.32 {q0},[r0,:128] vld1.32 {q1},[r1,:128] vsub.f32 q2, q0, q1 vadd.f32 q1, q0, q1 vst1.32 {q2},[r1,:128]! vst1.32 {q1},[r0,:128]! subs r2, r2, #4 bgt 1b bx lr endfunc function ff_scalarproduct_float_neon, export=1 vmov.f32 q2, #0.0 1: vld1.32 {q0},[r0,:128]! vld1.32 {q1},[r1,:128]! vmla.f32 q2, q0, q1 subs r2, r2, #4 bgt 1b vadd.f32 d0, d4, d5 vpadd.f32 d0, d0, d0 NOVFP vmov.32 r0, d0[0] bx lr endfunc function ff_int32_to_float_fmul_scalar_neon, export=1 VFP vdup.32 q0, d0[0] VFP len .req r2 NOVFP vdup.32 q0, r2 NOVFP len .req r3 vld1.32 {q1},[r1,:128]! vcvt.f32.s32 q3, q1 vld1.32 {q2},[r1,:128]! vcvt.f32.s32 q8, q2 1: subs len, len, #8 pld [r1, #16] vmul.f32 q9, q3, q0 vmul.f32 q10, q8, q0 beq 2f vld1.32 {q1},[r1,:128]! vcvt.f32.s32 q3, q1 vld1.32 {q2},[r1,:128]! vcvt.f32.s32 q8, q2 vst1.32 {q9}, [r0,:128]! vst1.32 {q10},[r0,:128]! b 1b 2: vst1.32 {q9}, [r0,:128]! vst1.32 {q10},[r0,:128]! bx lr .unreq len endfunc function ff_vector_fmul_reverse_neon, export=1 add r2, r2, r3, lsl #2 sub r2, r2, #32 mov r12, #-32 vld1.32 {q0-q1}, [r1,:128]! vld1.32 {q2-q3}, [r2,:128], r12 1: pld [r1, #32] vrev64.32 q3, q3 vmul.f32 d16, d0, d7 vmul.f32 d17, d1, d6 pld [r2, #-32] vrev64.32 q2, q2 vmul.f32 d18, d2, d5 vmul.f32 d19, d3, d4 subs r3, r3, #8 beq 2f vld1.32 {q0-q1}, [r1,:128]! vld1.32 {q2-q3}, [r2,:128], r12 vst1.32 {q8-q9}, [r0,:128]! b 1b 2: vst1.32 {q8-q9}, [r0,:128]! bx lr endfunc function ff_vector_fmul_add_neon, export=1 ldr r12, [sp] vld1.32 {q0-q1}, [r1,:128]! vld1.32 {q8-q9}, [r2,:128]! vld1.32 {q2-q3}, [r3,:128]! vmul.f32 q10, q0, q8 vmul.f32 q11, q1, q9 1: vadd.f32 q12, q2, q10 vadd.f32 q13, q3, q11 pld [r1, #16] pld [r2, #16] pld [r3, #16] subs r12, r12, #8 beq 2f vld1.32 {q0}, [r1,:128]! vld1.32 {q8}, [r2,:128]! vmul.f32 q10, q0, q8 vld1.32 {q1}, [r1,:128]! vld1.32 {q9}, [r2,:128]! vmul.f32 q11, q1, q9 vld1.32 {q2-q3}, [r3,:128]! vst1.32 {q12-q13},[r0,:128]! b 1b 2: vst1.32 {q12-q13},[r0,:128]! bx lr endfunc function ff_vector_clipf_neon, export=1 VFP vdup.32 q1, d0[1] VFP vdup.32 q0, d0[0] NOVFP vdup.32 q0, r2 NOVFP vdup.32 q1, r3 NOVFP ldr r2, [sp] vld1.f32 {q2},[r1,:128]! vmin.f32 q10, q2, q1 vld1.f32 {q3},[r1,:128]! vmin.f32 q11, q3, q1 1: vmax.f32 q8, q10, q0 vmax.f32 q9, q11, q0 subs r2, r2, #8 beq 2f vld1.f32 {q2},[r1,:128]! vmin.f32 q10, q2, q1 vld1.f32 {q3},[r1,:128]! vmin.f32 q11, q3, q1 vst1.f32 {q8},[r0,:128]! vst1.f32 {q9},[r0,:128]! b 1b 2: vst1.f32 {q8},[r0,:128]! vst1.f32 {q9},[r0,:128]! bx lr endfunc
123linslouis-android-video-cutter
jni/libavcodec/arm/dsputil_neon.S
Unix Assembly
asf20
40,788
/* * Copyright (c) 2010 Mans Rullgard <mans@mansr.com> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "asm.S" preserve8 function ff_synth_filter_float_neon, export=1 push {r3-r11,lr} ldr r4, [r2] @ synth_buf_offset add r1, r1, r4, lsl #2 @ synth_buf sub r12, r4, #32 bfc r12, #9, #23 bic r4, r4, #63 str r12, [r2] ldr r2, [sp, #12*4] @ in mov r9, r1 @ synth_buf VFP vpush {d0} bl ff_imdct_half_neon VFP vpop {d0} pop {r3} ldr r5, [sp, #9*4] @ window ldr r2, [sp, #10*4] @ out NOVFP vldr d0, [sp, #12*4] @ scale, bias add r8, r9, #12*4 mov lr, #64*4 mov r1, #4 1: add r10, r9, #16*4 @ synth_buf add r11, r8, #16*4 add r0, r5, #16*4 @ window add r6, r5, #32*4 add r7, r5, #48*4 vld1.32 {q10}, [r3,:128] @ a add r3, r3, #16*4 vld1.32 {q1}, [r3,:128] @ b vmov.f32 q2, #0.0 @ c vmov.f32 q3, #0.0 @ d mov r12, #512 2: vld1.32 {q9}, [r8, :128], lr vrev64.32 q9, q9 vld1.32 {q8}, [r5, :128], lr vmls.f32 d20, d16, d19 vld1.32 {q11}, [r0, :128], lr vmls.f32 d21, d17, d18 vld1.32 {q12}, [r9, :128], lr vmla.f32 d2, d22, d24 vld1.32 {q8}, [r6, :128], lr vmla.f32 d3, d23, d25 vld1.32 {q9}, [r10,:128], lr vmla.f32 d4, d16, d18 vld1.32 {q12}, [r11,:128], lr vmla.f32 d5, d17, d19 vrev64.32 q12, q12 vld1.32 {q11}, [r7, :128], lr vmla.f32 d6, d22, d25 vmla.f32 d7, d23, d24 subs r12, r12, #64 beq 3f cmp r12, r4 bne 2b sub r8, r8, #512*4 sub r9, r9, #512*4 sub r10, r10, #512*4 sub r11, r11, #512*4 b 2b 3: vdup.32 q8, d0[1] vdup.32 q9, d0[1] vmla.f32 q8, q10, d0[0] vmla.f32 q9, q1, d0[0] vst1.32 {q3}, [r3,:128] sub r3, r3, #16*4 vst1.32 {q2}, [r3,:128] vst1.32 {q8}, [r2,:128] add r2, r2, #16*4 vst1.32 {q9}, [r2,:128] subs r1, r1, #1 popeq {r4-r11,pc} cmp r4, #0 subeq r8, r8, #512*4 subeq r9, r9, #512*4 sub r5, r5, #512*4 sub r2, r2, #12*4 @ out add r3, r3, #4*4 @ synth_buf2 add r5, r5, #4*4 @ window add r9, r9, #4*4 @ synth_buf sub r8, r8, #4*4 @ synth_buf b 1b endfunc
123linslouis-android-video-cutter
jni/libavcodec/arm/synth_filter_neon.S
Unix Assembly
asf20
4,311
/* * Copyright (c) 2008 Mans Rullgard <mans@mansr.com> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "config.h" #ifdef __ELF__ # define ELF #else # define ELF @ #endif .macro require8, val=1 ELF .eabi_attribute 24, \val .endm .macro preserve8, val=1 ELF .eabi_attribute 25, \val .endm .macro function name, export=0 .macro endfunc ELF .size \name, . - \name .endfunc .purgem endfunc .endm .if \export .global EXTERN_ASM\name EXTERN_ASM\name: .endif ELF .type \name, %function .func \name \name: .endm .macro movrel rd, val #if HAVE_ARMV6T2 && !CONFIG_PIC movw \rd, #:lower16:\val movt \rd, #:upper16:\val #else ldr \rd, =\val #endif .endm #if HAVE_VFP_ARGS .eabi_attribute 28, 1 # define VFP # define NOVFP @ #else # define VFP @ # define NOVFP #endif #define GLUE(a, b) a ## b #define JOIN(a, b) GLUE(a, b) #define X(s) JOIN(EXTERN_ASM, s)
123linslouis-android-video-cutter
jni/libavcodec/arm/asm.S
Unix Assembly
asf20
1,790
/* * ARM optimized DSP utils * Copyright (c) 2001 Lionel Ulmer * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "libavcodec/dsputil.h" #include "dsputil_arm.h" void ff_j_rev_dct_arm(DCTELEM *data); void ff_simple_idct_arm(DCTELEM *data); /* XXX: local hack */ static void (*ff_put_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size); static void (*ff_add_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size); void ff_put_pixels8_arm(uint8_t *block, const uint8_t *pixels, int line_size, int h); void ff_put_pixels8_x2_arm(uint8_t *block, const uint8_t *pixels, int line_size, int h); void ff_put_pixels8_y2_arm(uint8_t *block, const uint8_t *pixels, int line_size, int h); void ff_put_pixels8_xy2_arm(uint8_t *block, const uint8_t *pixels, int line_size, int h); void ff_put_no_rnd_pixels8_x2_arm(uint8_t *block, const uint8_t *pixels, int line_size, int h); void ff_put_no_rnd_pixels8_y2_arm(uint8_t *block, const uint8_t *pixels, int line_size, int h); void ff_put_no_rnd_pixels8_xy2_arm(uint8_t *block, const uint8_t *pixels, int line_size, int h); void ff_put_pixels16_arm(uint8_t *block, const uint8_t *pixels, int line_size, int h); CALL_2X_PIXELS(ff_put_pixels16_x2_arm, ff_put_pixels8_x2_arm, 8) CALL_2X_PIXELS(ff_put_pixels16_y2_arm, ff_put_pixels8_y2_arm, 8) CALL_2X_PIXELS(ff_put_pixels16_xy2_arm, ff_put_pixels8_xy2_arm, 8) CALL_2X_PIXELS(ff_put_no_rnd_pixels16_x2_arm, ff_put_no_rnd_pixels8_x2_arm, 8) CALL_2X_PIXELS(ff_put_no_rnd_pixels16_y2_arm, ff_put_no_rnd_pixels8_y2_arm, 8) CALL_2X_PIXELS(ff_put_no_rnd_pixels16_xy2_arm, ff_put_no_rnd_pixels8_xy2_arm,8) void ff_add_pixels_clamped_arm(const DCTELEM *block, uint8_t *dest, int line_size); /* XXX: those functions should be suppressed ASAP when all IDCTs are converted */ static void j_rev_dct_arm_put(uint8_t *dest, int line_size, DCTELEM *block) { ff_j_rev_dct_arm (block); ff_put_pixels_clamped(block, dest, line_size); } static void j_rev_dct_arm_add(uint8_t *dest, int line_size, DCTELEM *block) { ff_j_rev_dct_arm (block); ff_add_pixels_clamped(block, dest, line_size); } static void simple_idct_arm_put(uint8_t *dest, int line_size, DCTELEM *block) { ff_simple_idct_arm (block); ff_put_pixels_clamped(block, dest, line_size); } static void simple_idct_arm_add(uint8_t *dest, int line_size, DCTELEM *block) { ff_simple_idct_arm (block); ff_add_pixels_clamped(block, dest, line_size); } int mm_support(void) { return HAVE_IWMMXT * FF_MM_IWMMXT; } void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx) { ff_put_pixels_clamped = c->put_pixels_clamped; ff_add_pixels_clamped = c->add_pixels_clamped; if (!avctx->lowres) { if(avctx->idct_algo == FF_IDCT_AUTO || avctx->idct_algo == FF_IDCT_ARM){ c->idct_put = j_rev_dct_arm_put; c->idct_add = j_rev_dct_arm_add; c->idct = ff_j_rev_dct_arm; c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM; } else if (avctx->idct_algo == FF_IDCT_SIMPLEARM){ c->idct_put = simple_idct_arm_put; c->idct_add = simple_idct_arm_add; c->idct = ff_simple_idct_arm; c->idct_permutation_type = FF_NO_IDCT_PERM; } } c->add_pixels_clamped = ff_add_pixels_clamped_arm; c->put_pixels_tab[0][0] = ff_put_pixels16_arm; c->put_pixels_tab[0][1] = ff_put_pixels16_x2_arm; c->put_pixels_tab[0][2] = ff_put_pixels16_y2_arm; c->put_pixels_tab[0][3] = ff_put_pixels16_xy2_arm; c->put_pixels_tab[1][0] = ff_put_pixels8_arm; c->put_pixels_tab[1][1] = ff_put_pixels8_x2_arm; c->put_pixels_tab[1][2] = ff_put_pixels8_y2_arm; c->put_pixels_tab[1][3] = ff_put_pixels8_xy2_arm; c->put_no_rnd_pixels_tab[0][0] = ff_put_pixels16_arm; c->put_no_rnd_pixels_tab[0][1] = ff_put_no_rnd_pixels16_x2_arm; c->put_no_rnd_pixels_tab[0][2] = ff_put_no_rnd_pixels16_y2_arm; c->put_no_rnd_pixels_tab[0][3] = ff_put_no_rnd_pixels16_xy2_arm; c->put_no_rnd_pixels_tab[1][0] = ff_put_pixels8_arm; c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_arm; c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_arm; c->put_no_rnd_pixels_tab[1][3] = ff_put_no_rnd_pixels8_xy2_arm; if (HAVE_ARMV5TE) ff_dsputil_init_armv5te(c, avctx); if (HAVE_ARMV6) ff_dsputil_init_armv6(c, avctx); if (HAVE_IWMMXT) ff_dsputil_init_iwmmxt(c, avctx); if (HAVE_ARMVFP) ff_dsputil_init_vfp(c, avctx); if (HAVE_NEON) ff_dsputil_init_neon(c, avctx); }
123linslouis-android-video-cutter
jni/libavcodec/arm/dsputil_init_arm.c
C
asf20
5,416
/* * ARM NEON optimised RDFT * Copyright (c) 2009 Mans Rullgard <mans@mansr.com> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "asm.S" preserve8 function ff_rdft_calc_neon, export=1 push {r4-r8,lr} ldr r6, [r0, #4] @ inverse mov r4, r0 mov r5, r1 lsls r6, r6, #31 bne 1f add r0, r4, #20 bl X(ff_fft_permute_neon) add r0, r4, #20 mov r1, r5 bl X(ff_fft_calc_neon) 1: ldr r12, [r4, #0] @ nbits mov r2, #1 lsl r12, r2, r12 add r0, r5, #8 add r1, r5, r12, lsl #2 lsr r12, r12, #2 ldr r2, [r4, #12] @ tcos sub r12, r12, #2 ldr r3, [r4, #16] @ tsin mov r7, r0 sub r1, r1, #8 mov lr, r1 mov r8, #-8 vld1.32 {d0}, [r0,:64]! @ d1[0,1] vld1.32 {d1}, [r1,:64], r8 @ d2[0,1] vld1.32 {d4}, [r2,:64]! @ tcos[i] vld1.32 {d5}, [r3,:64]! @ tsin[i] vmov.f32 d18, #0.5 @ k1 vdup.32 d19, r6 pld [r0, #32] veor d19, d18, d19 @ k2 vmov.i32 d16, #0 vmov.i32 d17, #1<<31 pld [r1, #-32] vtrn.32 d16, d17 pld [r2, #32] vrev64.32 d16, d16 @ d16=1,0 d17=0,1 pld [r3, #32] 2: veor q1, q0, q8 @ -d1[0],d1[1], d2[0],-d2[1] vld1.32 {d24}, [r0,:64]! @ d1[0,1] vadd.f32 d0, d0, d3 @ d1[0]+d2[0], d1[1]-d2[1] vld1.32 {d25}, [r1,:64], r8 @ d2[0,1] vadd.f32 d1, d2, d1 @ -d1[0]+d2[0], d1[1]+d2[1] veor q3, q12, q8 @ -d1[0],d1[1], d2[0],-d2[1] pld [r0, #32] vmul.f32 q10, q0, q9 @ ev.re, ev.im, od.im, od.re pld [r1, #-32] vadd.f32 d0, d24, d7 @ d1[0]+d2[0], d1[1]-d2[1] vadd.f32 d1, d6, d25 @ -d1[0]+d2[0], d1[1]+d2[1] vmul.f32 q11, q0, q9 @ ev.re, ev.im, od.im, od.re veor d7, d21, d16 @ -od.im, od.re vrev64.32 d3, d21 @ od.re, od.im veor d6, d20, d17 @ ev.re,-ev.im veor d2, d3, d16 @ -od.re, od.im vmla.f32 d20, d3, d4[1] vmla.f32 d20, d7, d5[1] vmla.f32 d6, d2, d4[1] vmla.f32 d6, d21, d5[1] vld1.32 {d4}, [r2,:64]! @ tcos[i] veor d7, d23, d16 @ -od.im, od.re vld1.32 {d5}, [r3,:64]! @ tsin[i] veor d24, d22, d17 @ ev.re,-ev.im vrev64.32 d3, d23 @ od.re, od.im pld [r2, #32] veor d2, d3, d16 @ -od.re, od.im pld [r3, #32] vmla.f32 d22, d3, d4[0] vmla.f32 d22, d7, d5[0] vmla.f32 d24, d2, d4[0] vmla.f32 d24, d23, d5[0] vld1.32 {d0}, [r0,:64]! @ d1[0,1] vld1.32 {d1}, [r1,:64], r8 @ d2[0,1] vst1.32 {d20}, [r7,:64]! vst1.32 {d6}, [lr,:64], r8 vst1.32 {d22}, [r7,:64]! vst1.32 {d24}, [lr,:64], r8 subs r12, r12, #2 bgt 2b veor q1, q0, q8 @ -d1[0],d1[1], d2[0],-d2[1] vadd.f32 d0, d0, d3 @ d1[0]+d2[0], d1[1]-d2[1] vadd.f32 d1, d2, d1 @ -d1[0]+d2[0], d1[1]+d2[1] ldr r2, [r4, #8] @ sign_convention vmul.f32 q10, q0, q9 @ ev.re, ev.im, od.im, od.re add r0, r0, #4 bfc r2, #0, #31 vld1.32 {d0[0]}, [r0,:32] veor d7, d21, d16 @ -od.im, od.re vrev64.32 d3, d21 @ od.re, od.im veor d6, d20, d17 @ ev.re,-ev.im vld1.32 {d22}, [r5,:64] vdup.32 d1, r2 vmov d23, d22 veor d2, d3, d16 @ -od.re, od.im vtrn.32 d22, d23 veor d0, d0, d1 veor d23, d23, d17 vmla.f32 d20, d3, d4[1] vmla.f32 d20, d7, d5[1] vmla.f32 d6, d2, d4[1] vmla.f32 d6, d21, d5[1] vadd.f32 d22, d22, d23 vst1.32 {d20}, [r7,:64] vst1.32 {d6}, [lr,:64] vst1.32 {d0[0]}, [r0,:32] vst1.32 {d22}, [r5,:64] cmp r6, #0 popeq {r4-r8,pc} vmul.f32 d22, d22, d18 vst1.32 {d22}, [r5,:64] add r0, r4, #20 mov r1, r5 bl X(ff_fft_permute_neon) add r0, r4, #20 mov r1, r5 pop {r4-r8,lr} b X(ff_fft_calc_neon) endfunc
123linslouis-android-video-cutter
jni/libavcodec/arm/rdft_neon.S
Unix Assembly
asf20
6,493
/* * Copyright (c) 2010 Mans Rullgard <mans@mansr.com> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <stdint.h> #include "libavcodec/dsputil.h" #include "libavcodec/h264dsp.h" void ff_h264_v_loop_filter_luma_neon(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0); void ff_h264_h_loop_filter_luma_neon(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0); void ff_h264_v_loop_filter_chroma_neon(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0); void ff_h264_h_loop_filter_chroma_neon(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0); void ff_weight_h264_pixels_16x16_neon(uint8_t *ds, int stride, int log2_den, int weight, int offset); void ff_weight_h264_pixels_16x8_neon(uint8_t *ds, int stride, int log2_den, int weight, int offset); void ff_weight_h264_pixels_8x16_neon(uint8_t *ds, int stride, int log2_den, int weight, int offset); void ff_weight_h264_pixels_8x8_neon(uint8_t *ds, int stride, int log2_den, int weight, int offset); void ff_weight_h264_pixels_8x4_neon(uint8_t *ds, int stride, int log2_den, int weight, int offset); void ff_weight_h264_pixels_4x8_neon(uint8_t *ds, int stride, int log2_den, int weight, int offset); void ff_weight_h264_pixels_4x4_neon(uint8_t *ds, int stride, int log2_den, int weight, int offset); void ff_weight_h264_pixels_4x2_neon(uint8_t *ds, int stride, int log2_den, int weight, int offset); void ff_biweight_h264_pixels_16x16_neon(uint8_t *dst, uint8_t *src, int stride, int log2_den, int weightd, int weights, int offset); void ff_biweight_h264_pixels_16x8_neon(uint8_t *dst, uint8_t *src, int stride, int log2_den, int weightd, int weights, int offset); void ff_biweight_h264_pixels_8x16_neon(uint8_t *dst, uint8_t *src, int stride, int log2_den, int weightd, int weights, int offset); void ff_biweight_h264_pixels_8x8_neon(uint8_t *dst, uint8_t *src, int stride, int log2_den, int weightd, int weights, int offset); void ff_biweight_h264_pixels_8x4_neon(uint8_t *dst, uint8_t *src, int stride, int log2_den, int weightd, int weights, int offset); void ff_biweight_h264_pixels_4x8_neon(uint8_t *dst, uint8_t *src, int stride, int log2_den, int weightd, int weights, int offset); void ff_biweight_h264_pixels_4x4_neon(uint8_t *dst, uint8_t *src, int stride, int log2_den, int weightd, int weights, int offset); void ff_biweight_h264_pixels_4x2_neon(uint8_t *dst, uint8_t *src, int stride, int log2_den, int weightd, int weights, int offset); void ff_h264_idct_add_neon(uint8_t *dst, DCTELEM *block, int stride); void ff_h264_idct_dc_add_neon(uint8_t *dst, DCTELEM *block, int stride); void ff_h264_idct_add16_neon(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]); void ff_h264_idct_add16intra_neon(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]); void ff_h264_idct_add8_neon(uint8_t **dest, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]); #if HAVE_NEON static void ff_h264dsp_init_neon(H264DSPContext *c) { c->h264_v_loop_filter_luma = ff_h264_v_loop_filter_luma_neon; c->h264_h_loop_filter_luma = ff_h264_h_loop_filter_luma_neon; c->h264_v_loop_filter_chroma = ff_h264_v_loop_filter_chroma_neon; c->h264_h_loop_filter_chroma = ff_h264_h_loop_filter_chroma_neon; c->weight_h264_pixels_tab[0] = ff_weight_h264_pixels_16x16_neon; c->weight_h264_pixels_tab[1] = ff_weight_h264_pixels_16x8_neon; c->weight_h264_pixels_tab[2] = ff_weight_h264_pixels_8x16_neon; c->weight_h264_pixels_tab[3] = ff_weight_h264_pixels_8x8_neon; c->weight_h264_pixels_tab[4] = ff_weight_h264_pixels_8x4_neon; c->weight_h264_pixels_tab[5] = ff_weight_h264_pixels_4x8_neon; c->weight_h264_pixels_tab[6] = ff_weight_h264_pixels_4x4_neon; c->weight_h264_pixels_tab[7] = ff_weight_h264_pixels_4x2_neon; c->biweight_h264_pixels_tab[0] = ff_biweight_h264_pixels_16x16_neon; c->biweight_h264_pixels_tab[1] = ff_biweight_h264_pixels_16x8_neon; c->biweight_h264_pixels_tab[2] = ff_biweight_h264_pixels_8x16_neon; c->biweight_h264_pixels_tab[3] = ff_biweight_h264_pixels_8x8_neon; c->biweight_h264_pixels_tab[4] = ff_biweight_h264_pixels_8x4_neon; c->biweight_h264_pixels_tab[5] = ff_biweight_h264_pixels_4x8_neon; c->biweight_h264_pixels_tab[6] = ff_biweight_h264_pixels_4x4_neon; c->biweight_h264_pixels_tab[7] = ff_biweight_h264_pixels_4x2_neon; c->h264_idct_add = ff_h264_idct_add_neon; c->h264_idct_dc_add = ff_h264_idct_dc_add_neon; c->h264_idct_add16 = ff_h264_idct_add16_neon; c->h264_idct_add16intra = ff_h264_idct_add16intra_neon; c->h264_idct_add8 = ff_h264_idct_add8_neon; } #endif void ff_h264dsp_init_arm(H264DSPContext *c) { if (HAVE_NEON) ff_h264dsp_init_neon(c); }
123linslouis-android-video-cutter
jni/libavcodec/arm/h264dsp_init_arm.c
C
asf20
6,758
OBJS-$(CONFIG_DCA_DECODER) += arm/dcadsp_init_arm.o \ OBJS-$(CONFIG_VP5_DECODER) += arm/vp56dsp_init_arm.o OBJS-$(CONFIG_VP6_DECODER) += arm/vp56dsp_init_arm.o OBJS-$(CONFIG_H264DSP) += arm/h264dsp_init_arm.o \ arm/h264pred_init_arm.o \ OBJS += arm/dsputil_init_arm.o \ arm/dsputil_arm.o \ arm/fft_init_arm.o \ arm/jrevdct_arm.o \ arm/mpegvideo_arm.o \ arm/simple_idct_arm.o \ OBJS-$(HAVE_ARMV5TE) += arm/dsputil_init_armv5te.o \ arm/mpegvideo_armv5te.o \ arm/mpegvideo_armv5te_s.o \ arm/simple_idct_armv5te.o \ OBJS-$(HAVE_ARMV6) += arm/dsputil_init_armv6.o \ arm/dsputil_armv6.o \ arm/simple_idct_armv6.o \ OBJS-$(HAVE_ARMVFP) += arm/dsputil_vfp.o \ arm/dsputil_init_vfp.o \ OBJS-$(HAVE_IWMMXT) += arm/dsputil_iwmmxt.o \ arm/mpegvideo_iwmmxt.o \ NEON-OBJS-$(CONFIG_FFT) += arm/fft_neon.o \ NEON-OBJS-$(CONFIG_MDCT) += arm/mdct_neon.o \ NEON-OBJS-$(CONFIG_RDFT) += arm/rdft_neon.o \ NEON-OBJS-$(CONFIG_H264DSP) += arm/h264dsp_neon.o \ arm/h264idct_neon.o \ arm/h264pred_neon.o \ NEON-OBJS-$(CONFIG_DCA_DECODER) += arm/dcadsp_neon.o \ arm/synth_filter_neon.o \ NEON-OBJS-$(CONFIG_VP3_DECODER) += arm/vp3dsp_neon.o NEON-OBJS-$(CONFIG_VP5_DECODER) += arm/vp56dsp_neon.o NEON-OBJS-$(CONFIG_VP6_DECODER) += arm/vp56dsp_neon.o OBJS-$(HAVE_NEON) += arm/dsputil_init_neon.o \ arm/dsputil_neon.o \ arm/int_neon.o \ arm/simple_idct_neon.o \ $(NEON-OBJS-yes)
123linslouis-android-video-cutter
jni/libavcodec/arm/Makefile
Makefile
asf20
2,754
/* * iWMMXt optimized DSP utils * copyright (c) 2004 AGAWA Koji * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ void DEF(put, pixels8)(uint8_t *block, const uint8_t *pixels, const int line_size, int h) { int stride = line_size; __asm__ volatile ( "and r12, %[pixels], #7 \n\t" "bic %[pixels], %[pixels], #7 \n\t" "tmcr wcgr1, r12 \n\t" "add r4, %[pixels], %[line_size] \n\t" "add r5, %[block], %[line_size] \n\t" "mov %[line_size], %[line_size], lsl #1 \n\t" "1: \n\t" "wldrd wr0, [%[pixels]] \n\t" "subs %[h], %[h], #2 \n\t" "wldrd wr1, [%[pixels], #8] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "wldrd wr3, [r4] \n\t" "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "wldrd wr4, [r4, #8] \n\t" "add r4, r4, %[line_size] \n\t" "walignr1 wr8, wr0, wr1 \n\t" "pld [r4] \n\t" "pld [r4, #32] \n\t" "walignr1 wr10, wr3, wr4 \n\t" "wstrd wr8, [%[block]] \n\t" "add %[block], %[block], %[line_size] \n\t" "wstrd wr10, [r5] \n\t" "add r5, r5, %[line_size] \n\t" "bne 1b \n\t" : [block]"+r"(block), [pixels]"+r"(pixels), [line_size]"+r"(stride), [h]"+r"(h) : : "memory", "r4", "r5", "r12"); } void DEF(avg, pixels8)(uint8_t *block, const uint8_t *pixels, const int line_size, int h) { int stride = line_size; __asm__ volatile ( "and r12, %[pixels], #7 \n\t" "bic %[pixels], %[pixels], #7 \n\t" "tmcr wcgr1, r12 \n\t" "add r4, %[pixels], %[line_size] \n\t" "add r5, %[block], %[line_size] \n\t" "mov %[line_size], %[line_size], lsl #1 \n\t" "1: \n\t" "wldrd wr0, [%[pixels]] \n\t" "subs %[h], %[h], #2 \n\t" "wldrd wr1, [%[pixels], #8] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "wldrd wr3, [r4] \n\t" "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "wldrd wr4, [r4, #8] \n\t" "add r4, r4, %[line_size] \n\t" "walignr1 wr8, wr0, wr1 \n\t" "wldrd wr0, [%[block]] \n\t" "wldrd wr2, [r5] \n\t" "pld [r4] \n\t" "pld [r4, #32] \n\t" "walignr1 wr10, wr3, wr4 \n\t" WAVG2B" wr8, wr8, wr0 \n\t" WAVG2B" wr10, wr10, wr2 \n\t" "wstrd wr8, [%[block]] \n\t" "add %[block], %[block], %[line_size] \n\t" "wstrd wr10, [r5] \n\t" "pld [%[block]] \n\t" "pld [%[block], #32] \n\t" "add r5, r5, %[line_size] \n\t" "pld [r5] \n\t" "pld [r5, #32] \n\t" "bne 1b \n\t" : [block]"+r"(block), [pixels]"+r"(pixels), [line_size]"+r"(stride), [h]"+r"(h) : : "memory", "r4", "r5", "r12"); } void DEF(put, pixels16)(uint8_t *block, const uint8_t *pixels, const int line_size, int h) { int stride = line_size; __asm__ volatile ( "and r12, %[pixels], #7 \n\t" "bic %[pixels], %[pixels], #7 \n\t" "tmcr wcgr1, r12 \n\t" "add r4, %[pixels], %[line_size] \n\t" "add r5, %[block], %[line_size] \n\t" "mov %[line_size], %[line_size], lsl #1 \n\t" "1: \n\t" "wldrd wr0, [%[pixels]] \n\t" "wldrd wr1, [%[pixels], #8] \n\t" "subs %[h], %[h], #2 \n\t" "wldrd wr2, [%[pixels], #16] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "wldrd wr3, [r4] \n\t" "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "walignr1 wr8, wr0, wr1 \n\t" "wldrd wr4, [r4, #8] \n\t" "walignr1 wr9, wr1, wr2 \n\t" "wldrd wr5, [r4, #16] \n\t" "add r4, r4, %[line_size] \n\t" "pld [r4] \n\t" "pld [r4, #32] \n\t" "walignr1 wr10, wr3, wr4 \n\t" "wstrd wr8, [%[block]] \n\t" "walignr1 wr11, wr4, wr5 \n\t" "wstrd wr9, [%[block], #8] \n\t" "add %[block], %[block], %[line_size] \n\t" "wstrd wr10, [r5] \n\t" "wstrd wr11, [r5, #8] \n\t" "add r5, r5, %[line_size] \n\t" "bne 1b \n\t" : [block]"+r"(block), [pixels]"+r"(pixels), [line_size]"+r"(stride), [h]"+r"(h) : : "memory", "r4", "r5", "r12"); } void DEF(avg, pixels16)(uint8_t *block, const uint8_t *pixels, const int line_size, int h) { int stride = line_size; __asm__ volatile ( "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "pld [%[block]] \n\t" "pld [%[block], #32] \n\t" "and r12, %[pixels], #7 \n\t" "bic %[pixels], %[pixels], #7 \n\t" "tmcr wcgr1, r12 \n\t" "add r4, %[pixels], %[line_size]\n\t" "add r5, %[block], %[line_size] \n\t" "mov %[line_size], %[line_size], lsl #1 \n\t" "1: \n\t" "wldrd wr0, [%[pixels]] \n\t" "wldrd wr1, [%[pixels], #8] \n\t" "subs %[h], %[h], #2 \n\t" "wldrd wr2, [%[pixels], #16] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "wldrd wr3, [r4] \n\t" "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "walignr1 wr8, wr0, wr1 \n\t" "wldrd wr4, [r4, #8] \n\t" "walignr1 wr9, wr1, wr2 \n\t" "wldrd wr5, [r4, #16] \n\t" "add r4, r4, %[line_size] \n\t" "wldrd wr0, [%[block]] \n\t" "pld [r4] \n\t" "wldrd wr1, [%[block], #8] \n\t" "pld [r4, #32] \n\t" "wldrd wr2, [r5] \n\t" "walignr1 wr10, wr3, wr4 \n\t" "wldrd wr3, [r5, #8] \n\t" WAVG2B" wr8, wr8, wr0 \n\t" WAVG2B" wr9, wr9, wr1 \n\t" WAVG2B" wr10, wr10, wr2 \n\t" "wstrd wr8, [%[block]] \n\t" "walignr1 wr11, wr4, wr5 \n\t" WAVG2B" wr11, wr11, wr3 \n\t" "wstrd wr9, [%[block], #8] \n\t" "add %[block], %[block], %[line_size] \n\t" "wstrd wr10, [r5] \n\t" "pld [%[block]] \n\t" "pld [%[block], #32] \n\t" "wstrd wr11, [r5, #8] \n\t" "add r5, r5, %[line_size] \n\t" "pld [r5] \n\t" "pld [r5, #32] \n\t" "bne 1b \n\t" : [block]"+r"(block), [pixels]"+r"(pixels), [line_size]"+r"(stride), [h]"+r"(h) : : "memory", "r4", "r5", "r12"); } void DEF(put, pixels8_x2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h) { int stride = line_size; // [wr0 wr1 wr2 wr3] for previous line // [wr4 wr5 wr6 wr7] for current line SET_RND(wr15); // =2 for rnd and =1 for no_rnd version __asm__ volatile( "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "and r12, %[pixels], #7 \n\t" "bic %[pixels], %[pixels], #7 \n\t" "tmcr wcgr1, r12 \n\t" "add r12, r12, #1 \n\t" "add r4, %[pixels], %[line_size]\n\t" "tmcr wcgr2, r12 \n\t" "add r5, %[block], %[line_size] \n\t" "mov %[line_size], %[line_size], lsl #1 \n\t" "1: \n\t" "wldrd wr10, [%[pixels]] \n\t" "cmp r12, #8 \n\t" "wldrd wr11, [%[pixels], #8] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "wldrd wr13, [r4] \n\t" "pld [%[pixels]] \n\t" "wldrd wr14, [r4, #8] \n\t" "pld [%[pixels], #32] \n\t" "add r4, r4, %[line_size] \n\t" "walignr1 wr0, wr10, wr11 \n\t" "pld [r4] \n\t" "pld [r4, #32] \n\t" "walignr1 wr2, wr13, wr14 \n\t" "wmoveq wr4, wr11 \n\t" "wmoveq wr6, wr14 \n\t" "walignr2ne wr4, wr10, wr11 \n\t" "walignr2ne wr6, wr13, wr14 \n\t" WAVG2B" wr0, wr0, wr4 \n\t" WAVG2B" wr2, wr2, wr6 \n\t" "wstrd wr0, [%[block]] \n\t" "subs %[h], %[h], #2 \n\t" "wstrd wr2, [r5] \n\t" "add %[block], %[block], %[line_size] \n\t" "add r5, r5, %[line_size] \n\t" "bne 1b \n\t" : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block), [line_size]"+r"(stride) : : "r4", "r5", "r12", "memory"); } void DEF(put, pixels16_x2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h) { int stride = line_size; // [wr0 wr1 wr2 wr3] for previous line // [wr4 wr5 wr6 wr7] for current line SET_RND(wr15); // =2 for rnd and =1 for no_rnd version __asm__ volatile( "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "and r12, %[pixels], #7 \n\t" "bic %[pixels], %[pixels], #7 \n\t" "tmcr wcgr1, r12 \n\t" "add r12, r12, #1 \n\t" "add r4, %[pixels], %[line_size]\n\t" "tmcr wcgr2, r12 \n\t" "add r5, %[block], %[line_size] \n\t" "mov %[line_size], %[line_size], lsl #1 \n\t" "1: \n\t" "wldrd wr10, [%[pixels]] \n\t" "cmp r12, #8 \n\t" "wldrd wr11, [%[pixels], #8] \n\t" "wldrd wr12, [%[pixels], #16] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "wldrd wr13, [r4] \n\t" "pld [%[pixels]] \n\t" "wldrd wr14, [r4, #8] \n\t" "pld [%[pixels], #32] \n\t" "wldrd wr15, [r4, #16] \n\t" "add r4, r4, %[line_size] \n\t" "walignr1 wr0, wr10, wr11 \n\t" "pld [r4] \n\t" "pld [r4, #32] \n\t" "walignr1 wr1, wr11, wr12 \n\t" "walignr1 wr2, wr13, wr14 \n\t" "walignr1 wr3, wr14, wr15 \n\t" "wmoveq wr4, wr11 \n\t" "wmoveq wr5, wr12 \n\t" "wmoveq wr6, wr14 \n\t" "wmoveq wr7, wr15 \n\t" "walignr2ne wr4, wr10, wr11 \n\t" "walignr2ne wr5, wr11, wr12 \n\t" "walignr2ne wr6, wr13, wr14 \n\t" "walignr2ne wr7, wr14, wr15 \n\t" WAVG2B" wr0, wr0, wr4 \n\t" WAVG2B" wr1, wr1, wr5 \n\t" "wstrd wr0, [%[block]] \n\t" WAVG2B" wr2, wr2, wr6 \n\t" "wstrd wr1, [%[block], #8] \n\t" WAVG2B" wr3, wr3, wr7 \n\t" "add %[block], %[block], %[line_size] \n\t" "wstrd wr2, [r5] \n\t" "subs %[h], %[h], #2 \n\t" "wstrd wr3, [r5, #8] \n\t" "add r5, r5, %[line_size] \n\t" "bne 1b \n\t" : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block), [line_size]"+r"(stride) : : "r4", "r5", "r12", "memory"); } void DEF(avg, pixels8_x2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h) { int stride = line_size; // [wr0 wr1 wr2 wr3] for previous line // [wr4 wr5 wr6 wr7] for current line SET_RND(wr15); // =2 for rnd and =1 for no_rnd version __asm__ volatile( "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "pld [%[block]] \n\t" "pld [%[block], #32] \n\t" "and r12, %[pixels], #7 \n\t" "bic %[pixels], %[pixels], #7 \n\t" "tmcr wcgr1, r12 \n\t" "add r12, r12, #1 \n\t" "add r4, %[pixels], %[line_size]\n\t" "tmcr wcgr2, r12 \n\t" "add r5, %[block], %[line_size] \n\t" "mov %[line_size], %[line_size], lsl #1 \n\t" "pld [r5] \n\t" "pld [r5, #32] \n\t" "1: \n\t" "wldrd wr10, [%[pixels]] \n\t" "cmp r12, #8 \n\t" "wldrd wr11, [%[pixels], #8] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "wldrd wr13, [r4] \n\t" "pld [%[pixels]] \n\t" "wldrd wr14, [r4, #8] \n\t" "pld [%[pixels], #32] \n\t" "add r4, r4, %[line_size] \n\t" "walignr1 wr0, wr10, wr11 \n\t" "pld [r4] \n\t" "pld [r4, #32] \n\t" "walignr1 wr2, wr13, wr14 \n\t" "wmoveq wr4, wr11 \n\t" "wmoveq wr6, wr14 \n\t" "walignr2ne wr4, wr10, wr11 \n\t" "wldrd wr10, [%[block]] \n\t" "walignr2ne wr6, wr13, wr14 \n\t" "wldrd wr12, [r5] \n\t" WAVG2B" wr0, wr0, wr4 \n\t" WAVG2B" wr2, wr2, wr6 \n\t" WAVG2B" wr0, wr0, wr10 \n\t" WAVG2B" wr2, wr2, wr12 \n\t" "wstrd wr0, [%[block]] \n\t" "subs %[h], %[h], #2 \n\t" "wstrd wr2, [r5] \n\t" "add %[block], %[block], %[line_size] \n\t" "add r5, r5, %[line_size] \n\t" "pld [%[block]] \n\t" "pld [%[block], #32] \n\t" "pld [r5] \n\t" "pld [r5, #32] \n\t" "bne 1b \n\t" : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block), [line_size]"+r"(stride) : : "r4", "r5", "r12", "memory"); } void DEF(avg, pixels16_x2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h) { int stride = line_size; // [wr0 wr1 wr2 wr3] for previous line // [wr4 wr5 wr6 wr7] for current line SET_RND(wr15); // =2 for rnd and =1 for no_rnd version __asm__ volatile( "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "pld [%[block]] \n\t" "pld [%[block], #32] \n\t" "and r12, %[pixels], #7 \n\t" "bic %[pixels], %[pixels], #7 \n\t" "tmcr wcgr1, r12 \n\t" "add r12, r12, #1 \n\t" "add r4, %[pixels], %[line_size]\n\t" "tmcr wcgr2, r12 \n\t" "add r5, %[block], %[line_size] \n\t" "mov %[line_size], %[line_size], lsl #1 \n\t" "pld [r5] \n\t" "pld [r5, #32] \n\t" "1: \n\t" "wldrd wr10, [%[pixels]] \n\t" "cmp r12, #8 \n\t" "wldrd wr11, [%[pixels], #8] \n\t" "wldrd wr12, [%[pixels], #16] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "wldrd wr13, [r4] \n\t" "pld [%[pixels]] \n\t" "wldrd wr14, [r4, #8] \n\t" "pld [%[pixels], #32] \n\t" "wldrd wr15, [r4, #16] \n\t" "add r4, r4, %[line_size] \n\t" "walignr1 wr0, wr10, wr11 \n\t" "pld [r4] \n\t" "pld [r4, #32] \n\t" "walignr1 wr1, wr11, wr12 \n\t" "walignr1 wr2, wr13, wr14 \n\t" "walignr1 wr3, wr14, wr15 \n\t" "wmoveq wr4, wr11 \n\t" "wmoveq wr5, wr12 \n\t" "wmoveq wr6, wr14 \n\t" "wmoveq wr7, wr15 \n\t" "walignr2ne wr4, wr10, wr11 \n\t" "walignr2ne wr5, wr11, wr12 \n\t" "walignr2ne wr6, wr13, wr14 \n\t" "walignr2ne wr7, wr14, wr15 \n\t" "wldrd wr10, [%[block]] \n\t" WAVG2B" wr0, wr0, wr4 \n\t" "wldrd wr11, [%[block], #8] \n\t" WAVG2B" wr1, wr1, wr5 \n\t" "wldrd wr12, [r5] \n\t" WAVG2B" wr2, wr2, wr6 \n\t" "wldrd wr13, [r5, #8] \n\t" WAVG2B" wr3, wr3, wr7 \n\t" WAVG2B" wr0, wr0, wr10 \n\t" WAVG2B" wr1, wr1, wr11 \n\t" WAVG2B" wr2, wr2, wr12 \n\t" WAVG2B" wr3, wr3, wr13 \n\t" "wstrd wr0, [%[block]] \n\t" "subs %[h], %[h], #2 \n\t" "wstrd wr1, [%[block], #8] \n\t" "add %[block], %[block], %[line_size] \n\t" "wstrd wr2, [r5] \n\t" "pld [%[block]] \n\t" "wstrd wr3, [r5, #8] \n\t" "add r5, r5, %[line_size] \n\t" "pld [%[block], #32] \n\t" "pld [r5] \n\t" "pld [r5, #32] \n\t" "bne 1b \n\t" : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block), [line_size]"+r"(stride) : :"r4", "r5", "r12", "memory"); } void DEF(avg, pixels8_y2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h) { int stride = line_size; // [wr0 wr1 wr2 wr3] for previous line // [wr4 wr5 wr6 wr7] for current line __asm__ volatile( "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "and r12, %[pixels], #7 \n\t" "tmcr wcgr1, r12 \n\t" "bic %[pixels], %[pixels], #7 \n\t" "wldrd wr10, [%[pixels]] \n\t" "wldrd wr11, [%[pixels], #8] \n\t" "pld [%[block]] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "walignr1 wr0, wr10, wr11 \n\t" "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "1: \n\t" "wldrd wr10, [%[pixels]] \n\t" "wldrd wr11, [%[pixels], #8] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "walignr1 wr4, wr10, wr11 \n\t" "wldrd wr10, [%[block]] \n\t" WAVG2B" wr8, wr0, wr4 \n\t" WAVG2B" wr8, wr8, wr10 \n\t" "wstrd wr8, [%[block]] \n\t" "add %[block], %[block], %[line_size] \n\t" "wldrd wr10, [%[pixels]] \n\t" "wldrd wr11, [%[pixels], #8] \n\t" "pld [%[block]] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "walignr1 wr0, wr10, wr11 \n\t" "wldrd wr10, [%[block]] \n\t" WAVG2B" wr8, wr0, wr4 \n\t" WAVG2B" wr8, wr8, wr10 \n\t" "wstrd wr8, [%[block]] \n\t" "add %[block], %[block], %[line_size] \n\t" "subs %[h], %[h], #2 \n\t" "pld [%[block]] \n\t" "bne 1b \n\t" : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block), [line_size]"+r"(stride) : : "cc", "memory", "r12"); } void DEF(put, pixels16_y2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h) { int stride = line_size; // [wr0 wr1 wr2 wr3] for previous line // [wr4 wr5 wr6 wr7] for current line __asm__ volatile( "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "and r12, %[pixels], #7 \n\t" "tmcr wcgr1, r12 \n\t" "bic %[pixels], %[pixels], #7 \n\t" "wldrd wr10, [%[pixels]] \n\t" "wldrd wr11, [%[pixels], #8] \n\t" "wldrd wr12, [%[pixels], #16] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "walignr1 wr0, wr10, wr11 \n\t" "walignr1 wr1, wr11, wr12 \n\t" "1: \n\t" "wldrd wr10, [%[pixels]] \n\t" "wldrd wr11, [%[pixels], #8] \n\t" "wldrd wr12, [%[pixels], #16] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "walignr1 wr4, wr10, wr11 \n\t" "walignr1 wr5, wr11, wr12 \n\t" WAVG2B" wr8, wr0, wr4 \n\t" WAVG2B" wr9, wr1, wr5 \n\t" "wstrd wr8, [%[block]] \n\t" "wstrd wr9, [%[block], #8] \n\t" "add %[block], %[block], %[line_size] \n\t" "wldrd wr10, [%[pixels]] \n\t" "wldrd wr11, [%[pixels], #8] \n\t" "wldrd wr12, [%[pixels], #16] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "walignr1 wr0, wr10, wr11 \n\t" "walignr1 wr1, wr11, wr12 \n\t" WAVG2B" wr8, wr0, wr4 \n\t" WAVG2B" wr9, wr1, wr5 \n\t" "wstrd wr8, [%[block]] \n\t" "wstrd wr9, [%[block], #8] \n\t" "add %[block], %[block], %[line_size] \n\t" "subs %[h], %[h], #2 \n\t" "bne 1b \n\t" : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block), [line_size]"+r"(stride) : : "r4", "r5", "r12", "memory"); } void DEF(avg, pixels16_y2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h) { int stride = line_size; // [wr0 wr1 wr2 wr3] for previous line // [wr4 wr5 wr6 wr7] for current line __asm__ volatile( "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "and r12, %[pixels], #7 \n\t" "tmcr wcgr1, r12 \n\t" "bic %[pixels], %[pixels], #7 \n\t" "wldrd wr10, [%[pixels]] \n\t" "wldrd wr11, [%[pixels], #8] \n\t" "pld [%[block]] \n\t" "wldrd wr12, [%[pixels], #16] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "walignr1 wr0, wr10, wr11 \n\t" "walignr1 wr1, wr11, wr12 \n\t" "1: \n\t" "wldrd wr10, [%[pixels]] \n\t" "wldrd wr11, [%[pixels], #8] \n\t" "wldrd wr12, [%[pixels], #16] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "walignr1 wr4, wr10, wr11 \n\t" "walignr1 wr5, wr11, wr12 \n\t" "wldrd wr10, [%[block]] \n\t" "wldrd wr11, [%[block], #8] \n\t" WAVG2B" wr8, wr0, wr4 \n\t" WAVG2B" wr9, wr1, wr5 \n\t" WAVG2B" wr8, wr8, wr10 \n\t" WAVG2B" wr9, wr9, wr11 \n\t" "wstrd wr8, [%[block]] \n\t" "wstrd wr9, [%[block], #8] \n\t" "add %[block], %[block], %[line_size] \n\t" "wldrd wr10, [%[pixels]] \n\t" "wldrd wr11, [%[pixels], #8] \n\t" "pld [%[block]] \n\t" "wldrd wr12, [%[pixels], #16] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "walignr1 wr0, wr10, wr11 \n\t" "walignr1 wr1, wr11, wr12 \n\t" "wldrd wr10, [%[block]] \n\t" "wldrd wr11, [%[block], #8] \n\t" WAVG2B" wr8, wr0, wr4 \n\t" WAVG2B" wr9, wr1, wr5 \n\t" WAVG2B" wr8, wr8, wr10 \n\t" WAVG2B" wr9, wr9, wr11 \n\t" "wstrd wr8, [%[block]] \n\t" "wstrd wr9, [%[block], #8] \n\t" "add %[block], %[block], %[line_size] \n\t" "subs %[h], %[h], #2 \n\t" "pld [%[block]] \n\t" "bne 1b \n\t" : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block), [line_size]"+r"(stride) : : "r4", "r5", "r12", "memory"); } void DEF(put, pixels8_xy2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h) { // [wr0 wr1 wr2 wr3] for previous line // [wr4 wr5 wr6 wr7] for current line SET_RND(wr15); // =2 for rnd and =1 for no_rnd version __asm__ volatile( "pld [%[pixels]] \n\t" "mov r12, #2 \n\t" "pld [%[pixels], #32] \n\t" "tmcr wcgr0, r12 \n\t" /* for shift value */ "and r12, %[pixels], #7 \n\t" "bic %[pixels], %[pixels], #7 \n\t" "tmcr wcgr1, r12 \n\t" // [wr0 wr1 wr2 wr3] <= * // [wr4 wr5 wr6 wr7] "wldrd wr12, [%[pixels]] \n\t" "add r12, r12, #1 \n\t" "wldrd wr13, [%[pixels], #8] \n\t" "tmcr wcgr2, r12 \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "cmp r12, #8 \n\t" "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "walignr1 wr2, wr12, wr13 \n\t" "wmoveq wr10, wr13 \n\t" "walignr2ne wr10, wr12, wr13 \n\t" "wunpckelub wr0, wr2 \n\t" "wunpckehub wr1, wr2 \n\t" "wunpckelub wr8, wr10 \n\t" "wunpckehub wr9, wr10 \n\t" "waddhus wr0, wr0, wr8 \n\t" "waddhus wr1, wr1, wr9 \n\t" "1: \n\t" // [wr0 wr1 wr2 wr3] // [wr4 wr5 wr6 wr7] <= * "wldrd wr12, [%[pixels]] \n\t" "cmp r12, #8 \n\t" "wldrd wr13, [%[pixels], #8] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "walignr1 wr6, wr12, wr13 \n\t" "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "wmoveq wr10, wr13 \n\t" "walignr2ne wr10, wr12, wr13 \n\t" "wunpckelub wr4, wr6 \n\t" "wunpckehub wr5, wr6 \n\t" "wunpckelub wr8, wr10 \n\t" "wunpckehub wr9, wr10 \n\t" "waddhus wr4, wr4, wr8 \n\t" "waddhus wr5, wr5, wr9 \n\t" "waddhus wr8, wr0, wr4 \n\t" "waddhus wr9, wr1, wr5 \n\t" "waddhus wr8, wr8, wr15 \n\t" "waddhus wr9, wr9, wr15 \n\t" "wsrlhg wr8, wr8, wcgr0 \n\t" "wsrlhg wr9, wr9, wcgr0 \n\t" "wpackhus wr8, wr8, wr9 \n\t" "wstrd wr8, [%[block]] \n\t" "add %[block], %[block], %[line_size] \n\t" // [wr0 wr1 wr2 wr3] <= * // [wr4 wr5 wr6 wr7] "wldrd wr12, [%[pixels]] \n\t" "wldrd wr13, [%[pixels], #8] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "walignr1 wr2, wr12, wr13 \n\t" "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "wmoveq wr10, wr13 \n\t" "walignr2ne wr10, wr12, wr13 \n\t" "wunpckelub wr0, wr2 \n\t" "wunpckehub wr1, wr2 \n\t" "wunpckelub wr8, wr10 \n\t" "wunpckehub wr9, wr10 \n\t" "waddhus wr0, wr0, wr8 \n\t" "waddhus wr1, wr1, wr9 \n\t" "waddhus wr8, wr0, wr4 \n\t" "waddhus wr9, wr1, wr5 \n\t" "waddhus wr8, wr8, wr15 \n\t" "waddhus wr9, wr9, wr15 \n\t" "wsrlhg wr8, wr8, wcgr0 \n\t" "wsrlhg wr9, wr9, wcgr0 \n\t" "wpackhus wr8, wr8, wr9 \n\t" "subs %[h], %[h], #2 \n\t" "wstrd wr8, [%[block]] \n\t" "add %[block], %[block], %[line_size] \n\t" "bne 1b \n\t" : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block) : [line_size]"r"(line_size) : "r12", "memory"); } void DEF(put, pixels16_xy2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h) { // [wr0 wr1 wr2 wr3] for previous line // [wr4 wr5 wr6 wr7] for current line SET_RND(wr15); // =2 for rnd and =1 for no_rnd version __asm__ volatile( "pld [%[pixels]] \n\t" "mov r12, #2 \n\t" "pld [%[pixels], #32] \n\t" "tmcr wcgr0, r12 \n\t" /* for shift value */ /* alignment */ "and r12, %[pixels], #7 \n\t" "bic %[pixels], %[pixels], #7 \n\t" "tmcr wcgr1, r12 \n\t" "add r12, r12, #1 \n\t" "tmcr wcgr2, r12 \n\t" // [wr0 wr1 wr2 wr3] <= * // [wr4 wr5 wr6 wr7] "wldrd wr12, [%[pixels]] \n\t" "cmp r12, #8 \n\t" "wldrd wr13, [%[pixels], #8] \n\t" "wldrd wr14, [%[pixels], #16] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "pld [%[pixels]] \n\t" "walignr1 wr2, wr12, wr13 \n\t" "pld [%[pixels], #32] \n\t" "walignr1 wr3, wr13, wr14 \n\t" "wmoveq wr10, wr13 \n\t" "wmoveq wr11, wr14 \n\t" "walignr2ne wr10, wr12, wr13 \n\t" "walignr2ne wr11, wr13, wr14 \n\t" "wunpckelub wr0, wr2 \n\t" "wunpckehub wr1, wr2 \n\t" "wunpckelub wr2, wr3 \n\t" "wunpckehub wr3, wr3 \n\t" "wunpckelub wr8, wr10 \n\t" "wunpckehub wr9, wr10 \n\t" "wunpckelub wr10, wr11 \n\t" "wunpckehub wr11, wr11 \n\t" "waddhus wr0, wr0, wr8 \n\t" "waddhus wr1, wr1, wr9 \n\t" "waddhus wr2, wr2, wr10 \n\t" "waddhus wr3, wr3, wr11 \n\t" "1: \n\t" // [wr0 wr1 wr2 wr3] // [wr4 wr5 wr6 wr7] <= * "wldrd wr12, [%[pixels]] \n\t" "cmp r12, #8 \n\t" "wldrd wr13, [%[pixels], #8] \n\t" "wldrd wr14, [%[pixels], #16] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "walignr1 wr6, wr12, wr13 \n\t" "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "walignr1 wr7, wr13, wr14 \n\t" "wmoveq wr10, wr13 \n\t" "wmoveq wr11, wr14 \n\t" "walignr2ne wr10, wr12, wr13 \n\t" "walignr2ne wr11, wr13, wr14 \n\t" "wunpckelub wr4, wr6 \n\t" "wunpckehub wr5, wr6 \n\t" "wunpckelub wr6, wr7 \n\t" "wunpckehub wr7, wr7 \n\t" "wunpckelub wr8, wr10 \n\t" "wunpckehub wr9, wr10 \n\t" "wunpckelub wr10, wr11 \n\t" "wunpckehub wr11, wr11 \n\t" "waddhus wr4, wr4, wr8 \n\t" "waddhus wr5, wr5, wr9 \n\t" "waddhus wr6, wr6, wr10 \n\t" "waddhus wr7, wr7, wr11 \n\t" "waddhus wr8, wr0, wr4 \n\t" "waddhus wr9, wr1, wr5 \n\t" "waddhus wr10, wr2, wr6 \n\t" "waddhus wr11, wr3, wr7 \n\t" "waddhus wr8, wr8, wr15 \n\t" "waddhus wr9, wr9, wr15 \n\t" "waddhus wr10, wr10, wr15 \n\t" "waddhus wr11, wr11, wr15 \n\t" "wsrlhg wr8, wr8, wcgr0 \n\t" "wsrlhg wr9, wr9, wcgr0 \n\t" "wsrlhg wr10, wr10, wcgr0 \n\t" "wsrlhg wr11, wr11, wcgr0 \n\t" "wpackhus wr8, wr8, wr9 \n\t" "wpackhus wr9, wr10, wr11 \n\t" "wstrd wr8, [%[block]] \n\t" "wstrd wr9, [%[block], #8] \n\t" "add %[block], %[block], %[line_size] \n\t" // [wr0 wr1 wr2 wr3] <= * // [wr4 wr5 wr6 wr7] "wldrd wr12, [%[pixels]] \n\t" "wldrd wr13, [%[pixels], #8] \n\t" "wldrd wr14, [%[pixels], #16] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "walignr1 wr2, wr12, wr13 \n\t" "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "walignr1 wr3, wr13, wr14 \n\t" "wmoveq wr10, wr13 \n\t" "wmoveq wr11, wr14 \n\t" "walignr2ne wr10, wr12, wr13 \n\t" "walignr2ne wr11, wr13, wr14 \n\t" "wunpckelub wr0, wr2 \n\t" "wunpckehub wr1, wr2 \n\t" "wunpckelub wr2, wr3 \n\t" "wunpckehub wr3, wr3 \n\t" "wunpckelub wr8, wr10 \n\t" "wunpckehub wr9, wr10 \n\t" "wunpckelub wr10, wr11 \n\t" "wunpckehub wr11, wr11 \n\t" "waddhus wr0, wr0, wr8 \n\t" "waddhus wr1, wr1, wr9 \n\t" "waddhus wr2, wr2, wr10 \n\t" "waddhus wr3, wr3, wr11 \n\t" "waddhus wr8, wr0, wr4 \n\t" "waddhus wr9, wr1, wr5 \n\t" "waddhus wr10, wr2, wr6 \n\t" "waddhus wr11, wr3, wr7 \n\t" "waddhus wr8, wr8, wr15 \n\t" "waddhus wr9, wr9, wr15 \n\t" "waddhus wr10, wr10, wr15 \n\t" "waddhus wr11, wr11, wr15 \n\t" "wsrlhg wr8, wr8, wcgr0 \n\t" "wsrlhg wr9, wr9, wcgr0 \n\t" "wsrlhg wr10, wr10, wcgr0 \n\t" "wsrlhg wr11, wr11, wcgr0 \n\t" "wpackhus wr8, wr8, wr9 \n\t" "wpackhus wr9, wr10, wr11 \n\t" "wstrd wr8, [%[block]] \n\t" "wstrd wr9, [%[block], #8] \n\t" "add %[block], %[block], %[line_size] \n\t" "subs %[h], %[h], #2 \n\t" "bne 1b \n\t" : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block) : [line_size]"r"(line_size) : "r12", "memory"); } void DEF(avg, pixels8_xy2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h) { // [wr0 wr1 wr2 wr3] for previous line // [wr4 wr5 wr6 wr7] for current line SET_RND(wr15); // =2 for rnd and =1 for no_rnd version __asm__ volatile( "pld [%[block]] \n\t" "pld [%[block], #32] \n\t" "pld [%[pixels]] \n\t" "mov r12, #2 \n\t" "pld [%[pixels], #32] \n\t" "tmcr wcgr0, r12 \n\t" /* for shift value */ "and r12, %[pixels], #7 \n\t" "bic %[pixels], %[pixels], #7 \n\t" "tmcr wcgr1, r12 \n\t" // [wr0 wr1 wr2 wr3] <= * // [wr4 wr5 wr6 wr7] "wldrd wr12, [%[pixels]] \n\t" "add r12, r12, #1 \n\t" "wldrd wr13, [%[pixels], #8] \n\t" "tmcr wcgr2, r12 \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "cmp r12, #8 \n\t" "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "walignr1 wr2, wr12, wr13 \n\t" "wmoveq wr10, wr13 \n\t" "walignr2ne wr10, wr12, wr13 \n\t" "wunpckelub wr0, wr2 \n\t" "wunpckehub wr1, wr2 \n\t" "wunpckelub wr8, wr10 \n\t" "wunpckehub wr9, wr10 \n\t" "waddhus wr0, wr0, wr8 \n\t" "waddhus wr1, wr1, wr9 \n\t" "1: \n\t" // [wr0 wr1 wr2 wr3] // [wr4 wr5 wr6 wr7] <= * "wldrd wr12, [%[pixels]] \n\t" "cmp r12, #8 \n\t" "wldrd wr13, [%[pixels], #8] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "walignr1 wr6, wr12, wr13 \n\t" "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "wmoveq wr10, wr13 \n\t" "walignr2ne wr10, wr12, wr13 \n\t" "wunpckelub wr4, wr6 \n\t" "wunpckehub wr5, wr6 \n\t" "wunpckelub wr8, wr10 \n\t" "wunpckehub wr9, wr10 \n\t" "waddhus wr4, wr4, wr8 \n\t" "waddhus wr5, wr5, wr9 \n\t" "waddhus wr8, wr0, wr4 \n\t" "waddhus wr9, wr1, wr5 \n\t" "waddhus wr8, wr8, wr15 \n\t" "waddhus wr9, wr9, wr15 \n\t" "wldrd wr12, [%[block]] \n\t" "wsrlhg wr8, wr8, wcgr0 \n\t" "wsrlhg wr9, wr9, wcgr0 \n\t" "wpackhus wr8, wr8, wr9 \n\t" WAVG2B" wr8, wr8, wr12 \n\t" "wstrd wr8, [%[block]] \n\t" "add %[block], %[block], %[line_size] \n\t" "wldrd wr12, [%[pixels]] \n\t" "pld [%[block]] \n\t" "pld [%[block], #32] \n\t" // [wr0 wr1 wr2 wr3] <= * // [wr4 wr5 wr6 wr7] "wldrd wr13, [%[pixels], #8] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "walignr1 wr2, wr12, wr13 \n\t" "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "wmoveq wr10, wr13 \n\t" "walignr2ne wr10, wr12, wr13 \n\t" "wunpckelub wr0, wr2 \n\t" "wunpckehub wr1, wr2 \n\t" "wunpckelub wr8, wr10 \n\t" "wunpckehub wr9, wr10 \n\t" "waddhus wr0, wr0, wr8 \n\t" "waddhus wr1, wr1, wr9 \n\t" "waddhus wr8, wr0, wr4 \n\t" "waddhus wr9, wr1, wr5 \n\t" "waddhus wr8, wr8, wr15 \n\t" "waddhus wr9, wr9, wr15 \n\t" "wldrd wr12, [%[block]] \n\t" "wsrlhg wr8, wr8, wcgr0 \n\t" "wsrlhg wr9, wr9, wcgr0 \n\t" "wpackhus wr8, wr8, wr9 \n\t" "subs %[h], %[h], #2 \n\t" WAVG2B" wr8, wr8, wr12 \n\t" "wstrd wr8, [%[block]] \n\t" "add %[block], %[block], %[line_size] \n\t" "pld [%[block]] \n\t" "pld [%[block], #32] \n\t" "bne 1b \n\t" : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block) : [line_size]"r"(line_size) : "r12", "memory"); } void DEF(avg, pixels16_xy2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h) { // [wr0 wr1 wr2 wr3] for previous line // [wr4 wr5 wr6 wr7] for current line SET_RND(wr15); // =2 for rnd and =1 for no_rnd version __asm__ volatile( "pld [%[block]] \n\t" "pld [%[block], #32] \n\t" "pld [%[pixels]] \n\t" "mov r12, #2 \n\t" "pld [%[pixels], #32] \n\t" "tmcr wcgr0, r12 \n\t" /* for shift value */ /* alignment */ "and r12, %[pixels], #7 \n\t" "bic %[pixels], %[pixels], #7 \n\t" "tmcr wcgr1, r12 \n\t" "add r12, r12, #1 \n\t" "tmcr wcgr2, r12 \n\t" // [wr0 wr1 wr2 wr3] <= * // [wr4 wr5 wr6 wr7] "wldrd wr12, [%[pixels]] \n\t" "cmp r12, #8 \n\t" "wldrd wr13, [%[pixels], #8] \n\t" "wldrd wr14, [%[pixels], #16] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "pld [%[pixels]] \n\t" "walignr1 wr2, wr12, wr13 \n\t" "pld [%[pixels], #32] \n\t" "walignr1 wr3, wr13, wr14 \n\t" "wmoveq wr10, wr13 \n\t" "wmoveq wr11, wr14 \n\t" "walignr2ne wr10, wr12, wr13 \n\t" "walignr2ne wr11, wr13, wr14 \n\t" "wunpckelub wr0, wr2 \n\t" "wunpckehub wr1, wr2 \n\t" "wunpckelub wr2, wr3 \n\t" "wunpckehub wr3, wr3 \n\t" "wunpckelub wr8, wr10 \n\t" "wunpckehub wr9, wr10 \n\t" "wunpckelub wr10, wr11 \n\t" "wunpckehub wr11, wr11 \n\t" "waddhus wr0, wr0, wr8 \n\t" "waddhus wr1, wr1, wr9 \n\t" "waddhus wr2, wr2, wr10 \n\t" "waddhus wr3, wr3, wr11 \n\t" "1: \n\t" // [wr0 wr1 wr2 wr3] // [wr4 wr5 wr6 wr7] <= * "wldrd wr12, [%[pixels]] \n\t" "cmp r12, #8 \n\t" "wldrd wr13, [%[pixels], #8] \n\t" "wldrd wr14, [%[pixels], #16] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "walignr1 wr6, wr12, wr13 \n\t" "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "walignr1 wr7, wr13, wr14 \n\t" "wmoveq wr10, wr13 \n\t" "wmoveq wr11, wr14 \n\t" "walignr2ne wr10, wr12, wr13 \n\t" "walignr2ne wr11, wr13, wr14 \n\t" "wunpckelub wr4, wr6 \n\t" "wunpckehub wr5, wr6 \n\t" "wunpckelub wr6, wr7 \n\t" "wunpckehub wr7, wr7 \n\t" "wunpckelub wr8, wr10 \n\t" "wunpckehub wr9, wr10 \n\t" "wunpckelub wr10, wr11 \n\t" "wunpckehub wr11, wr11 \n\t" "waddhus wr4, wr4, wr8 \n\t" "waddhus wr5, wr5, wr9 \n\t" "waddhus wr6, wr6, wr10 \n\t" "waddhus wr7, wr7, wr11 \n\t" "waddhus wr8, wr0, wr4 \n\t" "waddhus wr9, wr1, wr5 \n\t" "waddhus wr10, wr2, wr6 \n\t" "waddhus wr11, wr3, wr7 \n\t" "waddhus wr8, wr8, wr15 \n\t" "waddhus wr9, wr9, wr15 \n\t" "waddhus wr10, wr10, wr15 \n\t" "waddhus wr11, wr11, wr15 \n\t" "wsrlhg wr8, wr8, wcgr0 \n\t" "wsrlhg wr9, wr9, wcgr0 \n\t" "wldrd wr12, [%[block]] \n\t" "wldrd wr13, [%[block], #8] \n\t" "wsrlhg wr10, wr10, wcgr0 \n\t" "wsrlhg wr11, wr11, wcgr0 \n\t" "wpackhus wr8, wr8, wr9 \n\t" "wpackhus wr9, wr10, wr11 \n\t" WAVG2B" wr8, wr8, wr12 \n\t" WAVG2B" wr9, wr9, wr13 \n\t" "wstrd wr8, [%[block]] \n\t" "wstrd wr9, [%[block], #8] \n\t" "add %[block], %[block], %[line_size] \n\t" // [wr0 wr1 wr2 wr3] <= * // [wr4 wr5 wr6 wr7] "wldrd wr12, [%[pixels]] \n\t" "pld [%[block]] \n\t" "wldrd wr13, [%[pixels], #8] \n\t" "pld [%[block], #32] \n\t" "wldrd wr14, [%[pixels], #16] \n\t" "add %[pixels], %[pixels], %[line_size] \n\t" "walignr1 wr2, wr12, wr13 \n\t" "pld [%[pixels]] \n\t" "pld [%[pixels], #32] \n\t" "walignr1 wr3, wr13, wr14 \n\t" "wmoveq wr10, wr13 \n\t" "wmoveq wr11, wr14 \n\t" "walignr2ne wr10, wr12, wr13 \n\t" "walignr2ne wr11, wr13, wr14 \n\t" "wunpckelub wr0, wr2 \n\t" "wunpckehub wr1, wr2 \n\t" "wunpckelub wr2, wr3 \n\t" "wunpckehub wr3, wr3 \n\t" "wunpckelub wr8, wr10 \n\t" "wunpckehub wr9, wr10 \n\t" "wunpckelub wr10, wr11 \n\t" "wunpckehub wr11, wr11 \n\t" "waddhus wr0, wr0, wr8 \n\t" "waddhus wr1, wr1, wr9 \n\t" "waddhus wr2, wr2, wr10 \n\t" "waddhus wr3, wr3, wr11 \n\t" "waddhus wr8, wr0, wr4 \n\t" "waddhus wr9, wr1, wr5 \n\t" "waddhus wr10, wr2, wr6 \n\t" "waddhus wr11, wr3, wr7 \n\t" "waddhus wr8, wr8, wr15 \n\t" "waddhus wr9, wr9, wr15 \n\t" "waddhus wr10, wr10, wr15 \n\t" "waddhus wr11, wr11, wr15 \n\t" "wsrlhg wr8, wr8, wcgr0 \n\t" "wsrlhg wr9, wr9, wcgr0 \n\t" "wldrd wr12, [%[block]] \n\t" "wldrd wr13, [%[block], #8] \n\t" "wsrlhg wr10, wr10, wcgr0 \n\t" "wsrlhg wr11, wr11, wcgr0 \n\t" "wpackhus wr8, wr8, wr9 \n\t" "wpackhus wr9, wr10, wr11 \n\t" WAVG2B" wr8, wr8, wr12 \n\t" WAVG2B" wr9, wr9, wr13 \n\t" "wstrd wr8, [%[block]] \n\t" "wstrd wr9, [%[block], #8] \n\t" "add %[block], %[block], %[line_size] \n\t" "subs %[h], %[h], #2 \n\t" "pld [%[block]] \n\t" "pld [%[block], #32] \n\t" "bne 1b \n\t" : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block) : [line_size]"r"(line_size) : "r12", "memory"); }
123linslouis-android-video-cutter
jni/libavcodec/arm/dsputil_iwmmxt_rnd_template.c
C
asf20
48,168