aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/ffmpeg_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-11-10 17:11:34 +0100
committerMax Kellermann <max@duempel.org>2009-12-02 22:29:50 +0100
commitc412d6251e9cd3abe735b7622af4003502e54f72 (patch)
tree7344c13f62e4cc788c830c05d21bb7b5b47f5866 /src/decoder/ffmpeg_plugin.c
parent68c2cfbb4067b2292e1ff1d4e7716ff370903f84 (diff)
downloadmpd-c412d6251e9cd3abe735b7622af4003502e54f72.tar.gz
mpd-c412d6251e9cd3abe735b7622af4003502e54f72.tar.xz
mpd-c412d6251e9cd3abe735b7622af4003502e54f72.zip
audio_format: changed "bits" to "enum sample_format"
This patch prepares support for floating point samples (and probably other formats). It changes the meaning of the "bits" attribute from a bit count to a symbolic value.
Diffstat (limited to 'src/decoder/ffmpeg_plugin.c')
-rw-r--r--src/decoder/ffmpeg_plugin.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/decoder/ffmpeg_plugin.c b/src/decoder/ffmpeg_plugin.c
index 9b025153b..af9320322 100644
--- a/src/decoder/ffmpeg_plugin.c
+++ b/src/decoder/ffmpeg_plugin.c
@@ -277,6 +277,26 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
return cmd;
}
+static enum sample_format
+ffmpeg_sample_format(G_GNUC_UNUSED const AVCodecContext *codec_context)
+{
+#if LIBAVCODEC_VERSION_INT >= ((51<<16)+(41<<8)+0)
+ int bits = (uint8_t) av_get_bits_per_sample_format(codec_context->sample_fmt);
+
+ /* XXX implement & test other sample formats */
+
+ switch (bits) {
+ case 16:
+ return SAMPLE_FORMAT_S16;
+ }
+
+ return SAMPLE_FORMAT_UNDEFINED;
+#else
+ /* XXX fixme 16-bit for older ffmpeg (13 Aug 2007) */
+ return SAMPLE_FORMAT_S16;
+#endif
+}
+
static bool
ffmpeg_decode_internal(struct ffmpeg_context *ctx)
{
@@ -288,7 +308,6 @@ ffmpeg_decode_internal(struct ffmpeg_context *ctx)
struct audio_format audio_format;
enum decoder_command cmd;
int total_time;
- uint8_t bits;
total_time = 0;
@@ -296,14 +315,9 @@ ffmpeg_decode_internal(struct ffmpeg_context *ctx)
codec_context->channels = 2;
}
-#if LIBAVCODEC_VERSION_INT >= ((51<<16)+(41<<8)+0)
- bits = (uint8_t) av_get_bits_per_sample_format(codec_context->sample_fmt);
-#else
- /* XXX fixme 16-bit for older ffmpeg (13 Aug 2007) */
- bits = (uint8_t) 16;
-#endif
if (!audio_format_init_checked(&audio_format,
- codec_context->sample_rate, bits,
+ codec_context->sample_rate,
+ ffmpeg_sample_format(codec_context),
codec_context->channels, &error)) {
g_warning("%s", error->message);
g_error_free(error);