mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-26 23:25:56 -05:00
[xcode] Fix incorrect source BPS detection + support for more audio qualities
This commit is contained in:
parent
39037c7c8b
commit
1285128b9a
@ -216,6 +216,16 @@ init_settings(struct settings_ctx *settings, enum transcode_profile profile)
|
|||||||
settings->sample_format = AV_SAMPLE_FMT_S16;
|
settings->sample_format = AV_SAMPLE_FMT_S16;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case XCODE_PCM16_96000:
|
||||||
|
settings->encode_audio = 1;
|
||||||
|
settings->format = "s16le";
|
||||||
|
settings->audio_codec = AV_CODEC_ID_PCM_S16LE;
|
||||||
|
settings->sample_rate = 96000;
|
||||||
|
settings->channel_layout = AV_CH_LAYOUT_STEREO;
|
||||||
|
settings->channels = 2;
|
||||||
|
settings->sample_format = AV_SAMPLE_FMT_S16;
|
||||||
|
break;
|
||||||
|
|
||||||
case XCODE_PCM24_44100:
|
case XCODE_PCM24_44100:
|
||||||
settings->encode_audio = 1;
|
settings->encode_audio = 1;
|
||||||
settings->format = "s24le";
|
settings->format = "s24le";
|
||||||
@ -236,6 +246,46 @@ init_settings(struct settings_ctx *settings, enum transcode_profile profile)
|
|||||||
settings->sample_format = AV_SAMPLE_FMT_S32;
|
settings->sample_format = AV_SAMPLE_FMT_S32;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case XCODE_PCM24_96000:
|
||||||
|
settings->encode_audio = 1;
|
||||||
|
settings->format = "s24le";
|
||||||
|
settings->audio_codec = AV_CODEC_ID_PCM_S24LE;
|
||||||
|
settings->sample_rate = 96000;
|
||||||
|
settings->channel_layout = AV_CH_LAYOUT_STEREO;
|
||||||
|
settings->channels = 2;
|
||||||
|
settings->sample_format = AV_SAMPLE_FMT_S32;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case XCODE_PCM32_44100:
|
||||||
|
settings->encode_audio = 1;
|
||||||
|
settings->format = "s32le";
|
||||||
|
settings->audio_codec = AV_CODEC_ID_PCM_S32LE;
|
||||||
|
settings->sample_rate = 44100;
|
||||||
|
settings->channel_layout = AV_CH_LAYOUT_STEREO;
|
||||||
|
settings->channels = 2;
|
||||||
|
settings->sample_format = AV_SAMPLE_FMT_S32;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case XCODE_PCM32_48000:
|
||||||
|
settings->encode_audio = 1;
|
||||||
|
settings->format = "s32le";
|
||||||
|
settings->audio_codec = AV_CODEC_ID_PCM_S32LE;
|
||||||
|
settings->sample_rate = 48000;
|
||||||
|
settings->channel_layout = AV_CH_LAYOUT_STEREO;
|
||||||
|
settings->channels = 2;
|
||||||
|
settings->sample_format = AV_SAMPLE_FMT_S32;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case XCODE_PCM32_96000:
|
||||||
|
settings->encode_audio = 1;
|
||||||
|
settings->format = "s32le";
|
||||||
|
settings->audio_codec = AV_CODEC_ID_PCM_S32LE;
|
||||||
|
settings->sample_rate = 96000;
|
||||||
|
settings->channel_layout = AV_CH_LAYOUT_STEREO;
|
||||||
|
settings->channels = 2;
|
||||||
|
settings->sample_format = AV_SAMPLE_FMT_S32;
|
||||||
|
break;
|
||||||
|
|
||||||
case XCODE_MP3:
|
case XCODE_MP3:
|
||||||
settings->encode_audio = 1;
|
settings->encode_audio = 1;
|
||||||
settings->format = "mp3";
|
settings->format = "mp3";
|
||||||
@ -1198,17 +1248,19 @@ transcode_encode_setup(enum transcode_profile profile, struct decode_ctx *src_ct
|
|||||||
ctx->settings.width = width;
|
ctx->settings.width = width;
|
||||||
ctx->settings.height = height;
|
ctx->settings.height = height;
|
||||||
|
|
||||||
|
// Profile does not specify a sample rate -> use same as source
|
||||||
if (!ctx->settings.sample_rate && ctx->settings.encode_audio)
|
if (!ctx->settings.sample_rate && ctx->settings.encode_audio)
|
||||||
ctx->settings.sample_rate = src_ctx->audio_stream.codec->sample_rate;
|
ctx->settings.sample_rate = src_ctx->audio_stream.codec->sample_rate;
|
||||||
|
|
||||||
|
// Profile does not specify a sample format -> use same as source
|
||||||
if (!ctx->settings.sample_format && ctx->settings.encode_audio)
|
if (!ctx->settings.sample_format && ctx->settings.encode_audio)
|
||||||
{
|
{
|
||||||
bps = av_get_bits_per_sample(src_ctx->audio_stream.codec->codec_id);
|
bps = av_get_bytes_per_sample(src_ctx->audio_stream.codec->sample_fmt);
|
||||||
if (bps >= 24)
|
if (bps == 4)
|
||||||
{
|
{
|
||||||
ctx->settings.sample_format = AV_SAMPLE_FMT_S32;
|
ctx->settings.sample_format = AV_SAMPLE_FMT_S32;
|
||||||
ctx->settings.audio_codec = AV_CODEC_ID_PCM_S24LE;
|
ctx->settings.audio_codec = AV_CODEC_ID_PCM_S32LE;
|
||||||
ctx->settings.format = "s24le";
|
ctx->settings.format = "s32le";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1582,6 +1634,10 @@ transcode_frame_new(void *data, size_t size, int nsamples, int sample_rate, int
|
|||||||
{
|
{
|
||||||
f->format = AV_SAMPLE_FMT_S32;
|
f->format = AV_SAMPLE_FMT_S32;
|
||||||
}
|
}
|
||||||
|
else if (bits_per_sample == 32)
|
||||||
|
{
|
||||||
|
f->format = AV_SAMPLE_FMT_S32;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DPRINTF(E_LOG, L_XCODE, "transcode_frame_new() called with unsupported bps (%d)\n", bits_per_sample);
|
DPRINTF(E_LOG, L_XCODE, "transcode_frame_new() called with unsupported bps (%d)\n", bits_per_sample);
|
||||||
|
@ -17,8 +17,13 @@ enum transcode_profile
|
|||||||
// Decodes/resamples the best audio stream (no wav headers)
|
// Decodes/resamples the best audio stream (no wav headers)
|
||||||
XCODE_PCM16_44100,
|
XCODE_PCM16_44100,
|
||||||
XCODE_PCM16_48000,
|
XCODE_PCM16_48000,
|
||||||
|
XCODE_PCM16_96000,
|
||||||
XCODE_PCM24_44100,
|
XCODE_PCM24_44100,
|
||||||
XCODE_PCM24_48000,
|
XCODE_PCM24_48000,
|
||||||
|
XCODE_PCM24_96000,
|
||||||
|
XCODE_PCM32_44100,
|
||||||
|
XCODE_PCM32_48000,
|
||||||
|
XCODE_PCM32_96000,
|
||||||
// Transcodes the best audio stream into MP3
|
// Transcodes the best audio stream into MP3
|
||||||
XCODE_MP3,
|
XCODE_MP3,
|
||||||
// Transcodes the best audio stream into OPUS
|
// Transcodes the best audio stream into OPUS
|
||||||
|
Loading…
Reference in New Issue
Block a user