Skip to content

Commit

Permalink
Preserve output ch layout
Browse files Browse the repository at this point in the history
  • Loading branch information
dmorn committed Nov 2, 2023
1 parent 2e12c70 commit 07f4744
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
7 changes: 3 additions & 4 deletions c_src/decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ int alloc_resampler(Decoder *ctx, FormatOpts output_opts) {

output_layout = malloc(sizeof(AVChannelLayout));
av_channel_layout_copy(output_layout, &ctx->codec_ctx->ch_layout);
output_layout->nb_channels = output_opts.channels;

// TODO
// free(output_layout);
ctx->output_ch_layout = output_layout;

output_layout->nb_channels = output_opts.channels;
output_opts.sample_format =
av_get_packed_sample_fmt(output_opts.sample_format);

Expand Down Expand Up @@ -89,7 +88,7 @@ int decoder_read_frame(Decoder *ctx, AVFrame *frame) {
AVFrame *resampled_frame;
resampled_frame = av_frame_alloc();
resampled_frame->nb_samples = frame->nb_samples;
resampled_frame->ch_layout = frame->ch_layout;
resampled_frame->ch_layout = *ctx->output_ch_layout;
resampled_frame->sample_rate = frame->sample_rate;
resampled_frame->format = ctx->output_fmt->sample_format;

Expand Down
1 change: 1 addition & 0 deletions c_src/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ typedef struct {
SwrContext *resampler_ctx;

FormatOpts *output_fmt;
AVChannelLayout *output_ch_layout;
} Decoder;

typedef struct {
Expand Down

0 comments on commit 07f4744

Please sign in to comment.