Mercurial > libavcodec.hg
comparison mpc7.c @ 9463:d719a2711c64 libavcodec
Use new static VLC scheme in Indeo2, Musepack and WNV1 decoders
author | kostya |
---|---|
date | Fri, 17 Apr 2009 14:09:56 +0000 |
parents | 0dce4fe6e6f3 |
children | dcae1f330498 |
comparison
equal
deleted
inserted
replaced
9462:ab2daba3e200 | 9463:d719a2711c64 |
---|---|
38 #define SAMPLES_PER_BAND 36 | 38 #define SAMPLES_PER_BAND 36 |
39 #define MPC_FRAME_SIZE (BANDS * SAMPLES_PER_BAND) | 39 #define MPC_FRAME_SIZE (BANDS * SAMPLES_PER_BAND) |
40 | 40 |
41 static VLC scfi_vlc, dscf_vlc, hdr_vlc, quant_vlc[MPC7_QUANT_VLC_TABLES][2]; | 41 static VLC scfi_vlc, dscf_vlc, hdr_vlc, quant_vlc[MPC7_QUANT_VLC_TABLES][2]; |
42 | 42 |
43 static uint16_t quant_offsets[MPC7_QUANT_VLC_TABLES*2 + 1] = | |
44 { | |
45 0, 512, 1024, 1536, 2052, 2564, 3076, 3588, 4100, 4612, 5124, | |
46 5636, 6164, 6676, 7224 | |
47 }; | |
48 | |
49 | |
43 static av_cold int mpc7_decode_init(AVCodecContext * avctx) | 50 static av_cold int mpc7_decode_init(AVCodecContext * avctx) |
44 { | 51 { |
45 int i, j; | 52 int i, j; |
46 MPCContext *c = avctx->priv_data; | 53 MPCContext *c = avctx->priv_data; |
47 GetBitContext gb; | 54 GetBitContext gb; |
48 uint8_t buf[16]; | 55 uint8_t buf[16]; |
49 static int vlc_initialized = 0; | 56 static int vlc_initialized = 0; |
57 | |
58 static VLC_TYPE scfi_table[1 << MPC7_SCFI_BITS][2]; | |
59 static VLC_TYPE dscf_table[1 << MPC7_DSCF_BITS][2]; | |
60 static VLC_TYPE hdr_table[1 << MPC7_HDR_BITS][2]; | |
61 static VLC_TYPE quant_tables[7224][2]; | |
50 | 62 |
51 if(avctx->extradata_size < 16){ | 63 if(avctx->extradata_size < 16){ |
52 av_log(avctx, AV_LOG_ERROR, "Too small extradata size (%i)!\n", avctx->extradata_size); | 64 av_log(avctx, AV_LOG_ERROR, "Too small extradata size (%i)!\n", avctx->extradata_size); |
53 return -1; | 65 return -1; |
54 } | 66 } |
73 c->IS, c->MSS, c->gapless, c->lastframelen, c->maxbands); | 85 c->IS, c->MSS, c->gapless, c->lastframelen, c->maxbands); |
74 c->frames_to_skip = 0; | 86 c->frames_to_skip = 0; |
75 | 87 |
76 if(vlc_initialized) return 0; | 88 if(vlc_initialized) return 0; |
77 av_log(avctx, AV_LOG_DEBUG, "Initing VLC\n"); | 89 av_log(avctx, AV_LOG_DEBUG, "Initing VLC\n"); |
90 scfi_vlc.table = scfi_table; | |
91 scfi_vlc.table_allocated = 1 << MPC7_SCFI_BITS; | |
78 if(init_vlc(&scfi_vlc, MPC7_SCFI_BITS, MPC7_SCFI_SIZE, | 92 if(init_vlc(&scfi_vlc, MPC7_SCFI_BITS, MPC7_SCFI_SIZE, |
79 &mpc7_scfi[1], 2, 1, | 93 &mpc7_scfi[1], 2, 1, |
80 &mpc7_scfi[0], 2, 1, INIT_VLC_USE_STATIC)){ | 94 &mpc7_scfi[0], 2, 1, INIT_VLC_USE_NEW_STATIC)){ |
81 av_log(avctx, AV_LOG_ERROR, "Cannot init SCFI VLC\n"); | 95 av_log(avctx, AV_LOG_ERROR, "Cannot init SCFI VLC\n"); |
82 return -1; | 96 return -1; |
83 } | 97 } |
98 dscf_vlc.table = dscf_table; | |
99 dscf_vlc.table_allocated = 1 << MPC7_DSCF_BITS; | |
84 if(init_vlc(&dscf_vlc, MPC7_DSCF_BITS, MPC7_DSCF_SIZE, | 100 if(init_vlc(&dscf_vlc, MPC7_DSCF_BITS, MPC7_DSCF_SIZE, |
85 &mpc7_dscf[1], 2, 1, | 101 &mpc7_dscf[1], 2, 1, |
86 &mpc7_dscf[0], 2, 1, INIT_VLC_USE_STATIC)){ | 102 &mpc7_dscf[0], 2, 1, INIT_VLC_USE_NEW_STATIC)){ |
87 av_log(avctx, AV_LOG_ERROR, "Cannot init DSCF VLC\n"); | 103 av_log(avctx, AV_LOG_ERROR, "Cannot init DSCF VLC\n"); |
88 return -1; | 104 return -1; |
89 } | 105 } |
106 hdr_vlc.table = hdr_table; | |
107 hdr_vlc.table_allocated = 1 << MPC7_HDR_BITS; | |
90 if(init_vlc(&hdr_vlc, MPC7_HDR_BITS, MPC7_HDR_SIZE, | 108 if(init_vlc(&hdr_vlc, MPC7_HDR_BITS, MPC7_HDR_SIZE, |
91 &mpc7_hdr[1], 2, 1, | 109 &mpc7_hdr[1], 2, 1, |
92 &mpc7_hdr[0], 2, 1, INIT_VLC_USE_STATIC)){ | 110 &mpc7_hdr[0], 2, 1, INIT_VLC_USE_NEW_STATIC)){ |
93 av_log(avctx, AV_LOG_ERROR, "Cannot init HDR VLC\n"); | 111 av_log(avctx, AV_LOG_ERROR, "Cannot init HDR VLC\n"); |
94 return -1; | 112 return -1; |
95 } | 113 } |
96 for(i = 0; i < MPC7_QUANT_VLC_TABLES; i++){ | 114 for(i = 0; i < MPC7_QUANT_VLC_TABLES; i++){ |
97 for(j = 0; j < 2; j++){ | 115 for(j = 0; j < 2; j++){ |
116 quant_vlc[i][j].table = &quant_tables[quant_offsets[i*2 + j]]; | |
117 quant_vlc[i][j].table_allocated = quant_offsets[i*2 + j + 1] - quant_offsets[i*2 + j]; | |
98 if(init_vlc(&quant_vlc[i][j], 9, mpc7_quant_vlc_sizes[i], | 118 if(init_vlc(&quant_vlc[i][j], 9, mpc7_quant_vlc_sizes[i], |
99 &mpc7_quant_vlc[i][j][1], 4, 2, | 119 &mpc7_quant_vlc[i][j][1], 4, 2, |
100 &mpc7_quant_vlc[i][j][0], 4, 2, INIT_VLC_USE_STATIC)){ | 120 &mpc7_quant_vlc[i][j][0], 4, 2, INIT_VLC_USE_NEW_STATIC)){ |
101 av_log(avctx, AV_LOG_ERROR, "Cannot init QUANT VLC %i,%i\n",i,j); | 121 av_log(avctx, AV_LOG_ERROR, "Cannot init QUANT VLC %i,%i\n",i,j); |
102 return -1; | 122 return -1; |
103 } | 123 } |
104 } | 124 } |
105 } | 125 } |