Skip to content
Snippets Groups Projects
Commit 9e48d340 authored by Alaric Senat's avatar Alaric Senat
Browse files

avcodec: fill audio frame channel field

Since ffmpeg 4.4 specifying channel layout or channel number is required
to call `avcodec_send_frame()` without error.
This is new requirement is due to a change in the avcodec internal API
brought by 827d6fe73d2f5472c1c2128eb14fab6a4db29032 (ffmpeg repo). They
now call `av_frame_ref` which needs the channels fields to be valid.

(cherry picked from commit 321a29b0)
parent 248a8e56
No related branches found
No related tags found
2 merge requests!3533Backport MR 3236 to 3.0.x,!615[3.0] avcodec: fill audio frame channel field
Pipeline #138414 passed with stages
in 19 minutes and 22 seconds
......@@ -1267,6 +1267,8 @@ static block_t *handle_delay_buffer( encoder_t *p_enc, encoder_sys_t *p_sys, uns
av_frame_unref( p_sys->frame );
p_sys->frame->format = p_sys->p_context->sample_fmt;
p_sys->frame->nb_samples = leftover_samples + p_sys->i_samples_delay;
p_sys->frame->channel_layout = p_sys->p_context->channel_layout;
p_sys->frame->channels = p_sys->p_context->channels;
p_sys->frame->pts = date_Get( &p_sys->buffer_date ) * p_sys->p_context->time_base.den /
CLOCK_FREQ / p_sys->p_context->time_base.num;
......@@ -1396,6 +1398,9 @@ static block_t *EncodeAudio( encoder_t *p_enc, block_t *p_aout_buf )
p_sys->frame->pts = date_Get( &p_sys->buffer_date ) * p_sys->p_context->time_base.den /
CLOCK_FREQ / p_sys->p_context->time_base.num;
p_sys->frame->channel_layout = p_sys->p_context->channel_layout;
p_sys->frame->channels = p_sys->p_context->channels;
const int in_bytes = p_sys->frame->nb_samples *
p_sys->p_context->channels * p_sys->i_sample_bytes;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment