mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-30 11:06:43 +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: ");
|
||||||
|
@ -532,10 +540,10 @@ 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
|
||||||
|
|
|
@ -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,16 +351,11 @@ void FFmpeg_Decoder::getInfo(int *samplerate, ChannelConfig *chans, SampleType *
|
||||||
|
|
||||||
if(mOutputSampleFormat != AV_SAMPLE_FMT_NONE)
|
if(mOutputSampleFormat != AV_SAMPLE_FMT_NONE)
|
||||||
{
|
{
|
||||||
// FIXME: debug output
|
|
||||||
//#if 0
|
|
||||||
printf("channel_layout: %d\n",(int)(*mStream)->codec->channel_layout);
|
|
||||||
printf("in_channels: %d\n",(*mStream)->codec->channels);
|
|
||||||
//#endif
|
|
||||||
mSwr = swr_alloc_set_opts(mSwr, // SwrContext
|
mSwr = swr_alloc_set_opts(mSwr, // SwrContext
|
||||||
(*mStream)->codec->channel_layout, // output ch layout
|
ch_layout, // output ch layout
|
||||||
mOutputSampleFormat, // output sample format
|
mOutputSampleFormat, // output sample format
|
||||||
(*mStream)->codec->sample_rate, // output sample rate
|
(*mStream)->codec->sample_rate, // output sample rate
|
||||||
(*mStream)->codec->channel_layout, // input ch layout
|
ch_layout, // input ch layout
|
||||||
(*mStream)->codec->sample_fmt, // input sample format
|
(*mStream)->codec->sample_fmt, // input sample format
|
||||||
(*mStream)->codec->sample_rate, // input sample rate
|
(*mStream)->codec->sample_rate, // input sample rate
|
||||||
0, // logging level offset
|
0, // logging level offset
|
||||||
|
|
Loading…
Reference in a new issue