comparison vorbis_dec.c @ 10347:93abbe76b5cc libavcodec

Add vorbis channel layout support according to those defined in the Vorbis I specification
author superdump
date Fri, 02 Oct 2009 12:59:37 +0000
parents 7bfcc66f807d
children 24a069f83049
comparison
equal deleted inserted replaced
10346:f12b7ea2df2a 10347:93abbe76b5cc
1010 av_log(avccontext, AV_LOG_ERROR, "Setup header corrupt.\n"); 1010 av_log(avccontext, AV_LOG_ERROR, "Setup header corrupt.\n");
1011 vorbis_free(vc); 1011 vorbis_free(vc);
1012 return -1; 1012 return -1;
1013 } 1013 }
1014 1014
1015 if (vc->audio_channels > 6)
1016 avccontext->channel_layout = 0;
1017 else
1018 avccontext->channel_layout = ff_vorbis_channel_layouts[vc->audio_channels - 1];
1019
1015 avccontext->channels = vc->audio_channels; 1020 avccontext->channels = vc->audio_channels;
1016 avccontext->sample_rate = vc->audio_samplerate; 1021 avccontext->sample_rate = vc->audio_samplerate;
1017 avccontext->frame_size = FFMIN(vc->blocksize[0], vc->blocksize[1]) >> 2; 1022 avccontext->frame_size = FFMIN(vc->blocksize[0], vc->blocksize[1]) >> 2;
1018 avccontext->sample_fmt = SAMPLE_FMT_S16; 1023 avccontext->sample_fmt = SAMPLE_FMT_S16;
1019 1024
1641 return buf_size ; 1646 return buf_size ;
1642 } 1647 }
1643 1648
1644 AV_DEBUG("parsed %d bytes %d bits, returned %d samples (*ch*bits) \n", get_bits_count(gb)/8, get_bits_count(gb)%8, len); 1649 AV_DEBUG("parsed %d bytes %d bits, returned %d samples (*ch*bits) \n", get_bits_count(gb)/8, get_bits_count(gb)%8, len);
1645 1650
1651 if (vc->audio_channels > 6) {
1646 for (i = 0; i < vc->audio_channels; i++) 1652 for (i = 0; i < vc->audio_channels; i++)
1647 channel_ptrs[i] = vc->channel_floors + i * len; 1653 channel_ptrs[i] = vc->channel_floors + i * len;
1654 } else {
1655 for (i = 0; i < vc->audio_channels; i++)
1656 channel_ptrs[i] = vc->channel_floors +
1657 len * ff_vorbis_channel_layout_offsets[vc->audio_channels - 1][i];
1658 }
1659
1648 vc->dsp.float_to_int16_interleave(data, channel_ptrs, len, vc->audio_channels); 1660 vc->dsp.float_to_int16_interleave(data, channel_ptrs, len, vc->audio_channels);
1649 *data_size = len * 2 * vc->audio_channels; 1661 *data_size = len * 2 * vc->audio_channels;
1650 1662
1651 return buf_size ; 1663 return buf_size ;
1652 } 1664 }
1670 vorbis_decode_init, 1682 vorbis_decode_init,
1671 NULL, 1683 NULL,
1672 vorbis_decode_close, 1684 vorbis_decode_close,
1673 vorbis_decode_frame, 1685 vorbis_decode_frame,
1674 .long_name = NULL_IF_CONFIG_SMALL("Vorbis"), 1686 .long_name = NULL_IF_CONFIG_SMALL("Vorbis"),
1687 .channel_layouts = ff_vorbis_channel_layouts,
1675 }; 1688 };
1676 1689