decoder/ffmpeg: move code to lib/ffmpeg/SampleFormat.hxx

This commit is contained in:
Max Kellermann
2019-03-18 10:58:42 +01:00
parent c563eb81a3
commit 0c6d22fe47
2 changed files with 62 additions and 16 deletions

View File

@@ -30,6 +30,7 @@
#include "lib/ffmpeg/Frame.hxx"
#include "lib/ffmpeg/Format.hxx"
#include "lib/ffmpeg/Codec.hxx"
#include "lib/ffmpeg/SampleFormat.hxx"
#include "../DecoderAPI.hxx"
#include "FfmpegMetaData.hxx"
#include "FfmpegIo.hxx"
@@ -361,22 +362,9 @@ gcc_const
static SampleFormat
ffmpeg_sample_format(enum AVSampleFormat sample_fmt) noexcept
{
switch (sample_fmt) {
case AV_SAMPLE_FMT_S16:
case AV_SAMPLE_FMT_S16P:
return SampleFormat::S16;
case AV_SAMPLE_FMT_S32:
case AV_SAMPLE_FMT_S32P:
return SampleFormat::S32;
case AV_SAMPLE_FMT_FLT:
case AV_SAMPLE_FMT_FLTP:
return SampleFormat::FLOAT;
default:
break;
}
const auto result = Ffmpeg::FromFfmpegSampleFormat(sample_fmt);
if (result != SampleFormat::UNDEFINED)
return result;
char buffer[64];
const char *name = av_get_sample_fmt_string(buffer, sizeof(buffer),