* 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
AV_DEBUG(" Codebooks: %d \n", vc->codebook_count);
- vc->codebooks=(vorbis_codebook *)av_mallocz(vc->codebook_count * sizeof(vorbis_codebook));
- tmp_vlc_bits=(uint8_t *)av_mallocz(V_MAX_VLCS * sizeof(uint8_t));
- tmp_vlc_codes=(uint32_t *)av_mallocz(V_MAX_VLCS * sizeof(uint32_t));
+ 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];
}
// Weed out unused vlcs and build codevector vector
- codebook_setup->codevectors=(float *)av_mallocz(used_entries*codebook_setup->dimensions * sizeof(float));
+ 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;
vc->floor_count=get_bits(gb, 6)+1;
- vc->floors=(vorbis_floor *)av_mallocz(vc->floor_count * sizeof(vorbis_floor));
+ 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->data.t1.x_list_dim+=floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]];
}
- floor_setup->data.t1.list=(floor1_entry_t *)av_mallocz(floor_setup->data.t1.x_list_dim * sizeof(floor1_entry_t));
+ floor_setup->data.t1.list=av_mallocz(floor_setup->data.t1.x_list_dim * sizeof(floor1_entry_t));
rangebits=get_bits(gb, 4);
uint_fast8_t i, j, k;
vc->residue_count=get_bits(gb, 6)+1;
- vc->residues=(vorbis_residue *)av_mallocz(vc->residue_count * sizeof(vorbis_residue));
+ vc->residues=av_mallocz(vc->residue_count * sizeof(vorbis_residue));
AV_DEBUG(" There are %d residues. \n", vc->residue_count);
uint_fast8_t i, j;
vc->mapping_count=get_bits(gb, 6)+1;
- vc->mappings=(vorbis_mapping *)av_mallocz(vc->mapping_count * sizeof(vorbis_mapping));
+ vc->mappings=av_mallocz(vc->mapping_count * sizeof(vorbis_mapping));
AV_DEBUG(" There are %d mappings. \n", vc->mapping_count);
if (get_bits1(gb)) {
mapping_setup->coupling_steps=get_bits(gb, 8)+1;
- mapping_setup->magnitude=(uint_fast8_t *)av_mallocz(mapping_setup->coupling_steps * sizeof(uint_fast8_t));
- mapping_setup->angle=(uint_fast8_t *)av_mallocz(mapping_setup->coupling_steps * sizeof(uint_fast8_t));
+ 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) {
mapping_setup->magnitude[j]=get_bits(gb, ilog(vc->audio_channels-1));
mapping_setup->angle[j]=get_bits(gb, ilog(vc->audio_channels-1));
}
if (mapping_setup->submaps>1) {
- mapping_setup->mux=(uint_fast8_t *)av_mallocz(vc->audio_channels * sizeof(uint_fast8_t));
+ 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) {
- get_bits(gb, 8); // FIXME check?
+ skip_bits(gb, 8); // FIXME check?
mapping_setup->submap_floor[j]=get_bits(gb, 8);
mapping_setup->submap_residue[j]=get_bits(gb, 8);
uint_fast8_t i;
vc->mode_count=get_bits(gb, 6)+1;
- vc->modes=(vorbis_mode *)av_mallocz(vc->mode_count * sizeof(vorbis_mode));
+ 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_bits(gb, 1);
+ mode_setup->blockflag=get_bits1(gb);
mode_setup->windowtype=get_bits(gb, 16); //FIXME check
mode_setup->transformtype=get_bits(gb, 16); //FIXME check
mode_setup->mapping=get_bits(gb, 8); //FIXME check
return 2;
}
- vc->channel_residues=(float *)av_malloc((vc->blocksize[1]/2)*vc->audio_channels * sizeof(float));
- vc->channel_floors=(float *)av_malloc((vc->blocksize[1]/2)*vc->audio_channels * sizeof(float));
- vc->saved=(float *)av_malloc((vc->blocksize[1]/2)*vc->audio_channels * sizeof(float));
- vc->ret=(float *)av_malloc((vc->blocksize[1]/2)*vc->audio_channels * sizeof(float));
- vc->buf=(float *)av_malloc(vc->blocksize[1] * sizeof(float));
- vc->buf_tmp=(float *)av_malloc(vc->blocksize[1] * sizeof(float));
+ 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]/2)*vc->audio_channels * sizeof(float));
+ vc->ret = av_malloc((vc->blocksize[1]/2)*vc->audio_channels * sizeof(float));
+ vc->buf = av_malloc( vc->blocksize[1] * sizeof(float));
+ vc->buf_tmp = av_malloc( vc->blocksize[1] * sizeof(float));
vc->saved_start=0;
ff_mdct_init(&vc->mdct[0], bl0, 1);
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 );
uint_fast8_t vqclass=classifs[j_times_ptns_to_read+partition_count];
int_fast16_t vqbook=vr->books[vqclass][pass];
- if (vqbook>=0) {
+ 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