aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-04-22 18:03:07 +0200
committerAnton Khirnov <anton@khirnov.net>2013-11-04 11:02:13 +0100
commita29e3b78c9aa84d2c6b6a73865be1afc310579d2 (patch)
tree00bb811ce703e6c8b2b79b030e4da5223f809861
parentbd8e9260147c5086ea0c9c1abdd27d1a41945c89 (diff)
libav decoder plugin: cosmetics, reformat
-rw-r--r--src/decoder/libav_decoder_plugin.c87
1 files changed, 36 insertions, 51 deletions
diff --git a/src/decoder/libav_decoder_plugin.c b/src/decoder/libav_decoder_plugin.c
index ad0abe85..cb2c91cb 100644
--- a/src/decoder/libav_decoder_plugin.c
+++ b/src/decoder/libav_decoder_plugin.c
@@ -54,8 +54,7 @@ typedef struct LibavDecContext {
AVStream *ast;
} LibavDecContext;
-static GLogLevelFlags
-level_libav_to_glib(int level)
+static GLogLevelFlags level_libav_to_glib(int level)
{
if (level <= AV_LOG_FATAL)
return G_LOG_LEVEL_CRITICAL;
@@ -69,9 +68,8 @@ level_libav_to_glib(int level)
return G_LOG_LEVEL_DEBUG;
}
-static void
-mpd_libav_log_callback(G_GNUC_UNUSED void *ptr, int level,
- const char *fmt, va_list vl)
+static void mpd_libav_log_callback(G_GNUC_UNUSED void *ptr, int level,
+ const char *fmt, va_list vl)
{
const AVClass * cls = NULL;
@@ -85,8 +83,7 @@ mpd_libav_log_callback(G_GNUC_UNUSED void *ptr, int level,
}
}
-static int
-mpd_libav_stream_read(void *opaque, uint8_t *buf, int size)
+static int mpd_libav_stream_read(void *opaque, uint8_t *buf, int size)
{
LibavDecContext *stream = opaque;
@@ -94,8 +91,7 @@ mpd_libav_stream_read(void *opaque, uint8_t *buf, int size)
(void *)buf, size);
}
-static int64_t
-mpd_libav_stream_seek(void *opaque, int64_t pos, int whence)
+static int64_t mpd_libav_stream_seek(void *opaque, int64_t pos, int whence)
{
LibavDecContext *stream = opaque;
@@ -189,31 +185,24 @@ libav_init(G_GNUC_UNUSED const struct config_param *param)
return true;
}
-G_GNUC_CONST
-static double
-time_from_libav(int64_t t, const AVRational time_base)
+G_GNUC_CONST static double time_from_libav(int64_t t, const AVRational time_base)
{
assert(t != (int64_t)AV_NOPTS_VALUE);
- return (double)av_rescale_q(t, time_base, (AVRational){1, 1024})
- / (double)1024;
+ return (double)av_rescale_q(t, time_base, (AVRational){1, 1024}) / (double)1024;
}
-G_GNUC_CONST
-static int64_t
-time_to_libav(double t, const AVRational time_base)
+G_GNUC_CONST static int64_t time_to_libav(double t, const AVRational time_base)
{
- return av_rescale_q((int64_t)(t * 1024), (AVRational){1, 1024},
- time_base);
+ return av_rescale_q((int64_t)(t * 1024), (AVRational){1, 1024}, time_base);
}
/**
* Copy PCM data from a AVFrame to an interleaved buffer.
*/
-static int
-copy_interleave_frame(const AVCodecContext *codec_context,
- const AVFrame *frame,
- uint8_t *buffer, size_t buffer_size)
+static int copy_interleave_frame(const AVCodecContext *codec_context,
+ const AVFrame *frame,
+ uint8_t *buffer, size_t buffer_size)
{
int plane_size;
const int data_size =
@@ -242,11 +231,11 @@ copy_interleave_frame(const AVCodecContext *codec_context,
#define AVCODEC_MAX_AUDIO_FRAME_SIZE 50000
-static enum decoder_command
-libav_send_packet(struct decoder *decoder, struct input_stream *is,
- const AVPacket *packet,
- AVCodecContext *codec_context,
- const AVRational *time_base)
+static enum decoder_command libav_send_packet(struct decoder *decoder,
+ struct input_stream *is,
+ const AVPacket *packet,
+ AVCodecContext *codec_context,
+ const AVRational *time_base)
{
AVPacket packet2 = *packet;
uint8_t aligned_buffer[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2 + 16];
@@ -255,23 +244,21 @@ libav_send_packet(struct decoder *decoder, struct input_stream *is,
enum decoder_command cmd = DECODE_COMMAND_NONE;
if (packet->pts != (int64_t)AV_NOPTS_VALUE)
- decoder_timestamp(decoder,
- time_from_libav(packet->pts, *time_base));
+ decoder_timestamp(decoder, time_from_libav(packet->pts, *time_base));
- while (
- packet2.size > 0 &&
+ while (packet2.size > 0 &&
cmd == DECODE_COMMAND_NONE) {
int audio_size = buffer_size;
AVFrame frame;
int got_frame = 0;
int len = avcodec_decode_audio4(codec_context,
- &frame, &got_frame,
- &packet2);
+ &frame, &got_frame,
+ &packet2);
if (len >= 0 && got_frame) {
audio_size = copy_interleave_frame(codec_context,
- &frame,
- aligned_buffer,
- buffer_size);
+ &frame,
+ aligned_buffer,
+ buffer_size);
if (audio_size < 0)
len = audio_size;
} else if (len >= 0)
@@ -290,14 +277,13 @@ libav_send_packet(struct decoder *decoder, struct input_stream *is,
continue;
cmd = decoder_data(decoder, is,
- aligned_buffer, audio_size,
- codec_context->bit_rate / 1000);
+ aligned_buffer, audio_size,
+ codec_context->bit_rate / 1000);
}
return cmd;
}
-static enum sample_format
-libav_sample_format(G_GNUC_UNUSED const AVCodecContext *codec_context)
+static enum sample_format libav_sample_format(G_GNUC_UNUSED const AVCodecContext *codec_context)
{
switch (codec_context->sample_fmt) {
case AV_SAMPLE_FMT_S16:
@@ -337,9 +323,9 @@ static void libav_decode(struct decoder *decoder, struct input_stream *input)
g_debug("Selected audio decoder %s\n", codec->name);
if (!audio_format_init_checked(&audio_format,
- dec->sample_rate,
- libav_sample_format(dec),
- dec->channels, &error)) {
+ dec->sample_rate,
+ libav_sample_format(dec),
+ dec->channels, &error)) {
g_warning("%s", error->message);
g_error_free(error);
goto finish;
@@ -360,7 +346,7 @@ static void libav_decode(struct decoder *decoder, struct input_stream *input)
s.fmt_ctx->duration / AV_TIME_BASE : 0;
decoder_initialized(decoder, &audio_format,
- input->seekable, total_time);
+ input->seekable, total_time);
do {
AVPacket packet;
@@ -370,20 +356,19 @@ static void libav_decode(struct decoder *decoder, struct input_stream *input)
if (packet.stream_index == s.ast->index)
cmd = libav_send_packet(decoder, input,
- &packet, dec,
- &s.ast->time_base);
+ &packet, dec,
+ &s.ast->time_base);
else
cmd = decoder_get_command(decoder);
av_free_packet(&packet);
if (cmd == DECODE_COMMAND_SEEK) {
- int64_t where =
- time_to_libav(decoder_seek_where(decoder),
- s.ast->time_base);
+ int64_t where = time_to_libav(decoder_seek_where(decoder),
+ s.ast->time_base);
if (av_seek_frame(s.fmt_ctx, s.ast->index, where,
- AV_TIME_BASE) < 0)
+ AV_TIME_BASE) < 0)
decoder_seek_error(decoder);
else {
avcodec_flush_buffers(dec);