mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
Add vorbis channel layout support according to those defined in the Vorbis I
specification Originally committed as revision 20148 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
e654b7c29e
commit
53a71e1ba4
@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
extern const float ff_vorbis_floor1_inverse_db_table[256];
|
extern const float ff_vorbis_floor1_inverse_db_table[256];
|
||||||
extern const float * const ff_vorbis_vwin[8];
|
extern const float * const ff_vorbis_vwin[8];
|
||||||
|
extern const uint8_t ff_vorbis_channel_layout_offsets[6][6];
|
||||||
|
extern const int64_t ff_vorbis_channel_layouts[7];
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint_fast16_t x;
|
uint_fast16_t x;
|
||||||
|
@ -21,6 +21,25 @@
|
|||||||
#include "dsputil.h"
|
#include "dsputil.h"
|
||||||
#include "vorbis.h"
|
#include "vorbis.h"
|
||||||
|
|
||||||
|
const uint8_t ff_vorbis_channel_layout_offsets[6][6] = {
|
||||||
|
{ 0, },
|
||||||
|
{ 0, 1, },
|
||||||
|
{ 0, 2, 1, },
|
||||||
|
{ 0, 1, 2, 3, },
|
||||||
|
{ 0, 2, 1, 3, 4, },
|
||||||
|
{ 0, 2, 1, 5, 3, 4, }
|
||||||
|
};
|
||||||
|
|
||||||
|
const int64_t ff_vorbis_channel_layouts[7] = {
|
||||||
|
CH_LAYOUT_MONO,
|
||||||
|
CH_LAYOUT_STEREO,
|
||||||
|
CH_LAYOUT_SURROUND,
|
||||||
|
CH_LAYOUT_QUAD,
|
||||||
|
CH_LAYOUT_5POINT0_BACK,
|
||||||
|
CH_LAYOUT_5POINT1_BACK,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
DECLARE_ALIGNED_16(static const float, vwin64[32]) = {
|
DECLARE_ALIGNED_16(static const float, vwin64[32]) = {
|
||||||
0.0009460463F, 0.0085006468F, 0.0235352254F, 0.0458950567F,
|
0.0009460463F, 0.0085006468F, 0.0235352254F, 0.0458950567F,
|
||||||
0.0753351908F, 0.1115073077F, 0.1539457973F, 0.2020557475F,
|
0.0753351908F, 0.1115073077F, 0.1539457973F, 0.2020557475F,
|
||||||
|
@ -1012,6 +1012,11 @@ static av_cold int vorbis_decode_init(AVCodecContext *avccontext)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (vc->audio_channels > 6)
|
||||||
|
avccontext->channel_layout = 0;
|
||||||
|
else
|
||||||
|
avccontext->channel_layout = ff_vorbis_channel_layouts[vc->audio_channels - 1];
|
||||||
|
|
||||||
avccontext->channels = vc->audio_channels;
|
avccontext->channels = vc->audio_channels;
|
||||||
avccontext->sample_rate = vc->audio_samplerate;
|
avccontext->sample_rate = vc->audio_samplerate;
|
||||||
avccontext->frame_size = FFMIN(vc->blocksize[0], vc->blocksize[1]) >> 2;
|
avccontext->frame_size = FFMIN(vc->blocksize[0], vc->blocksize[1]) >> 2;
|
||||||
@ -1643,8 +1648,15 @@ static int vorbis_decode_frame(AVCodecContext *avccontext,
|
|||||||
|
|
||||||
AV_DEBUG("parsed %d bytes %d bits, returned %d samples (*ch*bits) \n", get_bits_count(gb)/8, get_bits_count(gb)%8, len);
|
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 > 6) {
|
||||||
for (i = 0; i < vc->audio_channels; i++)
|
for (i = 0; i < vc->audio_channels; i++)
|
||||||
channel_ptrs[i] = vc->channel_floors + i * len;
|
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);
|
vc->dsp.float_to_int16_interleave(data, channel_ptrs, len, vc->audio_channels);
|
||||||
*data_size = len * 2 * vc->audio_channels;
|
*data_size = len * 2 * vc->audio_channels;
|
||||||
|
|
||||||
@ -1672,5 +1684,6 @@ AVCodec vorbis_decoder = {
|
|||||||
vorbis_decode_close,
|
vorbis_decode_close,
|
||||||
vorbis_decode_frame,
|
vorbis_decode_frame,
|
||||||
.long_name = NULL_IF_CONFIG_SMALL("Vorbis"),
|
.long_name = NULL_IF_CONFIG_SMALL("Vorbis"),
|
||||||
|
.channel_layouts = ff_vorbis_channel_layouts,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user