From 8663641e843db87ca01ca7e01de8c9164963b987 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Mon, 30 Dec 2013 23:16:30 +0100 Subject: [PATCH] Account for no channel_layout (resample) + add free decode frame --- src/transcode.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/transcode.c b/src/transcode.c index ee4ce7ab..9d366a7a 100644 --- a/src/transcode.c +++ b/src/transcode.c @@ -276,6 +276,9 @@ transcode(struct transcode_ctx *ctx, struct evbuffer *evbuf, int wanted) ctx->offset += processed; + if (frame) + avcodec_free_frame(&frame); + return processed; } @@ -472,7 +475,16 @@ transcode_setup(struct media_file_info *mfi, off_t *est_size, int wavhdr) if (ctx->need_resample) { - DPRINTF(E_DBG, L_XCODE, "Setting up resampling (%d@%d)\n", ctx->acodec->channels, ctx->acodec->sample_rate); + if (!ctx->acodec->channel_layout) + { + ctx->acodec->channel_layout = av_get_default_channel_layout(ctx->acodec->channels); + + DPRINTF(E_DBG, L_XCODE, "Resample requires channel_layout, but none from ffmpeg. Setting to default.\n"); + } + + DPRINTF(E_DBG, L_XCODE, "Will resample, decoded stream is: %s, %d channels (layout %" PRIu64 "), %d Hz\n", + av_get_sample_fmt_name(ctx->acodec->sample_fmt), ctx->acodec->channels, + ctx->acodec->channel_layout, ctx->acodec->sample_rate); ctx->resample_ctx = avresample_alloc_context(); if (!ctx->resample_ctx)