aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-04-22 17:48:06 +0200
committerAnton Khirnov <anton@khirnov.net>2013-11-04 11:02:12 +0100
commita5d36f1da159977449ba5d94522b9ca7384292fe (patch)
tree7debf238f7c8a88af9702eca454453f7ef394fb4
parent988aa395866c8e0ab8dafdecea964684ac425a8d (diff)
libav decoder plugin: declare variables at the beginning of the block
-rw-r--r--src/decoder/libav_decoder_plugin.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/decoder/libav_decoder_plugin.c b/src/decoder/libav_decoder_plugin.c
index 39fda6e3..d0b8fa3d 100644
--- a/src/decoder/libav_decoder_plugin.c
+++ b/src/decoder/libav_decoder_plugin.c
@@ -240,23 +240,24 @@ copy_interleave_frame(const AVCodecContext *codec_context,
return data_size;
}
+#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)
{
- if (packet->pts != (int64_t)AV_NOPTS_VALUE)
- decoder_timestamp(decoder,
- time_from_libav(packet->pts, *time_base));
-
AVPacket packet2 = *packet;
-
-#define AVCODEC_MAX_AUDIO_FRAME_SIZE 50000
uint8_t aligned_buffer[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2 + 16];
const size_t buffer_size = sizeof(aligned_buffer);
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));
+
while (
packet2.size > 0 &&
cmd == DECODE_COMMAND_NONE) {
@@ -317,7 +318,11 @@ static void libav_decode(struct decoder *decoder, struct input_stream *input)
{
LibavDecContext s = { .decoder = decoder };
AVCodecContext *dec = NULL;
- int ret;
+ const AVCodec *codec;
+ struct audio_format audio_format;
+ enum decoder_command cmd;
+ GError *error = NULL;
+ int ret, total_time;
ret = libav_open(&s, input);
if (ret < 0)
@@ -327,15 +332,13 @@ static void libav_decode(struct decoder *decoder, struct input_stream *input)
if (dec->codec_name[0] != 0)
g_debug("codec '%s'", dec->codec_name);
- AVCodec *codec = avcodec_find_decoder(dec->codec_id);
+ codec = avcodec_find_decoder(dec->codec_id);
if (!codec) {
g_warning("Unsupported audio codec\n");
goto finish;
}
- GError *error = NULL;
- struct audio_format audio_format;
if (!audio_format_init_checked(&audio_format,
dec->sample_rate,
libav_sample_format(dec),
@@ -350,19 +353,18 @@ static void libav_decode(struct decoder *decoder, struct input_stream *input)
values into AVCodecContext.channels - a change that will be
reverted later by avcodec_decode_audio3() */
- const int open_result = avcodec_open2(dec, codec, NULL);
- if (open_result < 0) {
+ ret = avcodec_open2(dec, codec, NULL);
+ if (ret < 0) {
g_warning("Could not open codec\n");
goto finish;
}
- int total_time = s.fmt_ctx->duration != (int64_t)AV_NOPTS_VALUE ?
- s.fmt_ctx->duration / AV_TIME_BASE : 0;
+ total_time = s.fmt_ctx->duration != (int64_t)AV_NOPTS_VALUE ?
+ s.fmt_ctx->duration / AV_TIME_BASE : 0;
decoder_initialized(decoder, &audio_format,
input->seekable, total_time);
- enum decoder_command cmd;
do {
AVPacket packet;
if (av_read_frame(s.fmt_ctx, &packet) < 0)