[vlc-commits] avcodec: set frame samples to 0 if frame fill fails in encode, this way encode_audio2 doesn't crash

Ilkka Ollakka git at videolan.org
Sun Aug 18 21:43:45 CEST 2013


vlc/vlc-2.1 | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Fri Aug 16 15:59:00 2013 +0300| [fa2871193c1d94f0edc65fbd86e1e1d542a1c4ca] | committer: Jean-Baptiste Kempf

avcodec: set frame samples to 0 if frame fill fails in encode, this way encode_audio2 doesn't crash

(cherry picked from commit 8cf359215dd9f44b0bb7648a4dcdeecd89380bdc)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.1.git/?a=commit;h=fa2871193c1d94f0edc65fbd86e1e1d542a1c4ca
---

 modules/codec/avcodec/encoder.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index 9717d09..6b32bc0 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -1157,7 +1157,10 @@ static block_t *EncodeAudio( encoder_t *p_enc, block_t *p_aout_buf )
                 p_sys->p_context->sample_fmt, p_sys->b_planar ? p_sys->p_interleave_buf : p_sys->p_buffer,
                 leftover + buffer_delay,
                 align) < 0 )
+        {
             msg_Err( p_enc, "filling error on fillup" );
+            p_sys->frame->nb_samples = 0;
+        }
 
         buffer_delay = 0;
         p_sys->i_samples_delay = 0;
@@ -1250,7 +1253,10 @@ static block_t *EncodeAudio( encoder_t *p_enc, block_t *p_aout_buf )
                                     p_sys->b_planar ? p_sys->p_buffer : p_aout_buf->p_buffer,
                                     __MIN(p_sys->i_buffer_out, p_aout_buf->i_buffer),
                                     align) < 0 )
+        {
                  msg_Err( p_enc, "filling error on encode" );
+                 p_sys->frame->nb_samples = 0;
+        }
 
         p_aout_buf->p_buffer     += (p_sys->frame->nb_samples * p_enc->fmt_in.audio.i_channels * p_sys->i_sample_bytes);
         p_aout_buf->i_buffer     -= (p_sys->frame->nb_samples * p_enc->fmt_in.audio.i_channels * p_sys->i_sample_bytes);



More information about the vlc-commits mailing list