mirror of https://github.com/mgba-emu/mgba.git
FFmpeg: Force lower sample rate for codecs not supporting high rates (fixes #2869)
This commit is contained in:
parent
b68c714455
commit
dfb6055ae4
1
CHANGES
1
CHANGES
|
@ -17,6 +17,7 @@ Emulation fixes:
|
||||||
- GBA Video: Disable BG target 1 blending when OBJ blending (fixes mgba.io/i/2722)
|
- GBA Video: Disable BG target 1 blending when OBJ blending (fixes mgba.io/i/2722)
|
||||||
Other fixes:
|
Other fixes:
|
||||||
- Core: Allow sending thread requests to a crashed core (fixes mgba.io/i/2784)
|
- Core: Allow sending thread requests to a crashed core (fixes mgba.io/i/2784)
|
||||||
|
- FFmpeg: Force lower sample rate for codecs not supporting high rates (fixes mgba.io/i/2869)
|
||||||
- Qt: Fix crash when attempting to use OpenGL 2.1 to 3.1 (fixes mgba.io/i/2794)
|
- Qt: Fix crash when attempting to use OpenGL 2.1 to 3.1 (fixes mgba.io/i/2794)
|
||||||
- Qt: Disable sync while running scripts from main thread (fixes mgba.io/i/2738)
|
- Qt: Disable sync while running scripts from main thread (fixes mgba.io/i/2738)
|
||||||
- Qt: Fix savestate preview sizes with different scales (fixes mgba.io/i/2560)
|
- Qt: Fix savestate preview sizes with different scales (fixes mgba.io/i/2560)
|
||||||
|
|
|
@ -154,19 +154,35 @@ bool FFmpegEncoderSetAudio(struct FFmpegEncoder* encoder, const char* acodec, un
|
||||||
}
|
}
|
||||||
encoder->sampleRate = encoder->isampleRate;
|
encoder->sampleRate = encoder->isampleRate;
|
||||||
if (codec->supported_samplerates) {
|
if (codec->supported_samplerates) {
|
||||||
|
bool gotSampleRate = false;
|
||||||
|
int highestSampleRate = 0;
|
||||||
for (i = 0; codec->supported_samplerates[i]; ++i) {
|
for (i = 0; codec->supported_samplerates[i]; ++i) {
|
||||||
|
if (codec->supported_samplerates[i] > highestSampleRate) {
|
||||||
|
highestSampleRate = codec->supported_samplerates[i];
|
||||||
|
}
|
||||||
if (codec->supported_samplerates[i] < encoder->isampleRate) {
|
if (codec->supported_samplerates[i] < encoder->isampleRate) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (encoder->sampleRate == encoder->isampleRate || encoder->sampleRate > codec->supported_samplerates[i]) {
|
if (!gotSampleRate || encoder->sampleRate > codec->supported_samplerates[i]) {
|
||||||
encoder->sampleRate = codec->supported_samplerates[i];
|
encoder->sampleRate = codec->supported_samplerates[i];
|
||||||
|
gotSampleRate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!gotSampleRate) {
|
||||||
|
// There are no available sample rates that are higher than the input sample rate
|
||||||
|
// Let's use the highest available instead
|
||||||
|
encoder->sampleRate = highestSampleRate;
|
||||||
|
}
|
||||||
} else if (codec->id == AV_CODEC_ID_FLAC) {
|
} else if (codec->id == AV_CODEC_ID_FLAC) {
|
||||||
// HACK: FLAC doesn't support > 65535Hz unless it's divisible by 10
|
// HACK: FLAC doesn't support > 65535Hz unless it's divisible by 10
|
||||||
if (encoder->sampleRate >= 65535) {
|
if (encoder->sampleRate >= 65535) {
|
||||||
encoder->sampleRate -= encoder->isampleRate % 10;
|
encoder->sampleRate -= encoder->isampleRate % 10;
|
||||||
}
|
}
|
||||||
|
} else if (codec->id == AV_CODEC_ID_VORBIS) {
|
||||||
|
// HACK: FLAC doesn't support > 48000Hz but doesn't tell us
|
||||||
|
if (encoder->sampleRate > 48000) {
|
||||||
|
encoder->sampleRate = 48000;
|
||||||
|
}
|
||||||
} else if (codec->id == AV_CODEC_ID_AAC) {
|
} else if (codec->id == AV_CODEC_ID_AAC) {
|
||||||
// HACK: AAC doesn't support 32768Hz (it rounds to 32000), but libfaac doesn't tell us that
|
// HACK: AAC doesn't support 32768Hz (it rounds to 32000), but libfaac doesn't tell us that
|
||||||
encoder->sampleRate = 48000;
|
encoder->sampleRate = 48000;
|
||||||
|
|
Loading…
Reference in New Issue