[vlc-commits] [Git][videolan/vlc][3.0.x] avcodec: fill audio frame channel field

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Wed Sep 15 12:45:15 UTC 2021



Jean-Baptiste Kempf pushed to branch 3.0.x at VideoLAN / VLC


Commits:
9e48d340 by Alaric Senat at 2021-09-13T18:29:52+02:00
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 321a29b0a234c946fa3328caf2b5345d316704b8)

- - - - -


1 changed file:

- modules/codec/avcodec/encoder.c


Changes:

=====================================
modules/codec/avcodec/encoder.c
=====================================
@@ -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;
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/9e48d340d4177fefc0bf2edefe462d7baf88e586

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/9e48d340d4177fefc0bf2edefe462d7baf88e586
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list