Skip to content

Commit

Permalink
Fix channel layout change
Browse files Browse the repository at this point in the history
  • Loading branch information
dmorn committed Nov 14, 2023
1 parent f0bd8db commit 3532959
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 1 addition & 2 deletions c_src/decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ int decoder_alloc(Decoder **ctx, DecoderOpts opts) {
ictx->codec_ctx = codec_ctx;
if (!(ictx->output.ch_layout = malloc(sizeof(AVChannelLayout))))
return AVERROR(ENOMEM);
av_channel_layout_default(ictx->output.ch_layout, opts.output.nb_channels);

av_channel_layout_copy(ictx->output.ch_layout, &codec_ctx->ch_layout);
ictx->output.ch_layout->nb_channels = opts.output.nb_channels;
ictx->output.sample_rate = opts.output.sample_rate;
// Planar formats are not supported as they require a different procedure to
// lay down the plain bits contained in their frames.
Expand Down
5 changes: 3 additions & 2 deletions test/avx/decoder_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ defmodule AVx.DecoderTest do
end

test "decodes into a different format" do
{:ok, demuxer} = Demuxer.new_from_file(List.first(@inputs))
# We use this file for testing as it is stereo, sample rate 97_000, format fltp
{:ok, demuxer} = Demuxer.new_from_file("test/data/packed.aac")
[aac] = Demuxer.read_streams(demuxer)
packets = Demuxer.consume_packets(demuxer, [aac.stream_index])

Expand All @@ -53,7 +54,7 @@ defmodule AVx.DecoderTest do
|> Decoder.decode_frames(decoder)
|> Enum.count()

assert frame_count == 564
assert frame_count == 283
end

defp assert_frames(packets, decoder, expected_frames, ext) do
Expand Down

0 comments on commit 3532959

Please sign in to comment.