mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-20 20:53:53 +00:00
Workaround incorrectly reported channel_layout
This commit is contained in:
parent
675d11c0e5
commit
1107156334
2 changed files with 34 additions and 23 deletions
|
@ -488,6 +488,8 @@ public:
|
||||||
fail(std::string("Unsupported sample format: ")+
|
fail(std::string("Unsupported sample format: ")+
|
||||||
av_get_sample_fmt_name(mAVStream->codec->sample_fmt));
|
av_get_sample_fmt_name(mAVStream->codec->sample_fmt));
|
||||||
|
|
||||||
|
int64_t ch_layout = mAVStream->codec->channel_layout;
|
||||||
|
|
||||||
if(mAVStream->codec->channel_layout == AV_CH_LAYOUT_MONO)
|
if(mAVStream->codec->channel_layout == AV_CH_LAYOUT_MONO)
|
||||||
*chans = MWSound::ChannelConfig_Mono;
|
*chans = MWSound::ChannelConfig_Mono;
|
||||||
else if(mAVStream->codec->channel_layout == AV_CH_LAYOUT_STEREO)
|
else if(mAVStream->codec->channel_layout == AV_CH_LAYOUT_STEREO)
|
||||||
|
@ -502,9 +504,15 @@ public:
|
||||||
{
|
{
|
||||||
/* Unknown channel layout. Try to guess. */
|
/* Unknown channel layout. Try to guess. */
|
||||||
if(mAVStream->codec->channels == 1)
|
if(mAVStream->codec->channels == 1)
|
||||||
|
{
|
||||||
*chans = MWSound::ChannelConfig_Mono;
|
*chans = MWSound::ChannelConfig_Mono;
|
||||||
|
ch_layout = AV_CH_LAYOUT_MONO;
|
||||||
|
}
|
||||||
else if(mAVStream->codec->channels == 2)
|
else if(mAVStream->codec->channels == 2)
|
||||||
|
{
|
||||||
*chans = MWSound::ChannelConfig_Stereo;
|
*chans = MWSound::ChannelConfig_Stereo;
|
||||||
|
ch_layout = AV_CH_LAYOUT_STEREO;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::stringstream sstr("Unsupported raw channel count: ");
|
std::stringstream sstr("Unsupported raw channel count: ");
|
||||||
|
@ -531,15 +539,15 @@ public:
|
||||||
|
|
||||||
if(mOutputSampleFormat != AV_SAMPLE_FMT_NONE)
|
if(mOutputSampleFormat != AV_SAMPLE_FMT_NONE)
|
||||||
{
|
{
|
||||||
mSwr = swr_alloc_set_opts(mSwr, // SwrContext
|
mSwr = swr_alloc_set_opts(mSwr, // SwrContext
|
||||||
mAVStream->codec->channel_layout, // output ch layout
|
ch_layout, // output ch layout
|
||||||
mOutputSampleFormat, // output sample format
|
mOutputSampleFormat, // output sample format
|
||||||
mAVStream->codec->sample_rate, // output sample rate
|
mAVStream->codec->sample_rate, // output sample rate
|
||||||
mAVStream->codec->channel_layout, // input ch layout
|
ch_layout, // input ch layout
|
||||||
mAVStream->codec->sample_fmt, // input sample format
|
mAVStream->codec->sample_fmt, // input sample format
|
||||||
mAVStream->codec->sample_rate, // input sample rate
|
mAVStream->codec->sample_rate, // input sample rate
|
||||||
0, // logging level offset
|
0, // logging level offset
|
||||||
NULL); // log context
|
NULL); // log context
|
||||||
if(!mSwr)
|
if(!mSwr)
|
||||||
fail(std::string("Couldn't allocate SwrContext"));
|
fail(std::string("Couldn't allocate SwrContext"));
|
||||||
if(swr_init(mSwr) < 0)
|
if(swr_init(mSwr) < 0)
|
||||||
|
|
|
@ -300,6 +300,8 @@ void FFmpeg_Decoder::getInfo(int *samplerate, ChannelConfig *chans, SampleType *
|
||||||
fail(std::string("Unsupported sample format: ")+
|
fail(std::string("Unsupported sample format: ")+
|
||||||
av_get_sample_fmt_name((*mStream)->codec->sample_fmt));
|
av_get_sample_fmt_name((*mStream)->codec->sample_fmt));
|
||||||
|
|
||||||
|
int64_t ch_layout = (*mStream)->codec->channel_layout;
|
||||||
|
|
||||||
if((*mStream)->codec->channel_layout == AV_CH_LAYOUT_MONO)
|
if((*mStream)->codec->channel_layout == AV_CH_LAYOUT_MONO)
|
||||||
*chans = ChannelConfig_Mono;
|
*chans = ChannelConfig_Mono;
|
||||||
else if((*mStream)->codec->channel_layout == AV_CH_LAYOUT_STEREO)
|
else if((*mStream)->codec->channel_layout == AV_CH_LAYOUT_STEREO)
|
||||||
|
@ -314,9 +316,15 @@ void FFmpeg_Decoder::getInfo(int *samplerate, ChannelConfig *chans, SampleType *
|
||||||
{
|
{
|
||||||
/* Unknown channel layout. Try to guess. */
|
/* Unknown channel layout. Try to guess. */
|
||||||
if((*mStream)->codec->channels == 1)
|
if((*mStream)->codec->channels == 1)
|
||||||
|
{
|
||||||
*chans = ChannelConfig_Mono;
|
*chans = ChannelConfig_Mono;
|
||||||
|
ch_layout = AV_CH_LAYOUT_MONO;
|
||||||
|
}
|
||||||
else if((*mStream)->codec->channels == 2)
|
else if((*mStream)->codec->channels == 2)
|
||||||
|
{
|
||||||
*chans = ChannelConfig_Stereo;
|
*chans = ChannelConfig_Stereo;
|
||||||
|
ch_layout = AV_CH_LAYOUT_STEREO;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::stringstream sstr("Unsupported raw channel count: ");
|
std::stringstream sstr("Unsupported raw channel count: ");
|
||||||
|
@ -343,20 +351,15 @@ void FFmpeg_Decoder::getInfo(int *samplerate, ChannelConfig *chans, SampleType *
|
||||||
|
|
||||||
if(mOutputSampleFormat != AV_SAMPLE_FMT_NONE)
|
if(mOutputSampleFormat != AV_SAMPLE_FMT_NONE)
|
||||||
{
|
{
|
||||||
// FIXME: debug output
|
mSwr = swr_alloc_set_opts(mSwr, // SwrContext
|
||||||
//#if 0
|
ch_layout, // output ch layout
|
||||||
printf("channel_layout: %d\n",(int)(*mStream)->codec->channel_layout);
|
mOutputSampleFormat, // output sample format
|
||||||
printf("in_channels: %d\n",(*mStream)->codec->channels);
|
(*mStream)->codec->sample_rate, // output sample rate
|
||||||
//#endif
|
ch_layout, // input ch layout
|
||||||
mSwr = swr_alloc_set_opts(mSwr, // SwrContext
|
(*mStream)->codec->sample_fmt, // input sample format
|
||||||
(*mStream)->codec->channel_layout, // output ch layout
|
(*mStream)->codec->sample_rate, // input sample rate
|
||||||
mOutputSampleFormat, // output sample format
|
0, // logging level offset
|
||||||
(*mStream)->codec->sample_rate, // output sample rate
|
NULL); // log context
|
||||||
(*mStream)->codec->channel_layout, // input ch layout
|
|
||||||
(*mStream)->codec->sample_fmt, // input sample format
|
|
||||||
(*mStream)->codec->sample_rate, // input sample rate
|
|
||||||
0, // logging level offset
|
|
||||||
NULL); // log context
|
|
||||||
if(!mSwr)
|
if(!mSwr)
|
||||||
fail(std::string("Couldn't allocate SwrContext"));
|
fail(std::string("Couldn't allocate SwrContext"));
|
||||||
if(swr_init(mSwr) < 0)
|
if(swr_init(mSwr) < 0)
|
||||||
|
|
Loading…
Reference in a new issue