[vlc-devel] [PATCH] avcodec: avoid division by zero
Ilkka Ollakka
ileoo at videolan.org
Fri May 3 09:39:38 CEST 2013
Hi,
On Fri, May 03, 2013 at 02:31:49AM -0400, Tristan Matthews wrote:
> Setting align to 0 to get default behaviour only works as of libavutil 51.27.2
> See libav commit 0109a09dc3850eb5dbff84a7bb50eb252a5a8f22
> Fixes #8508.
This patch assumes that same functionality is in ffmpeg from 51.0.0
onwards, which seems to be wrong. LIBAVUTIL_VERSION_CHECK is used to
check both ffmpeg and libav at the same time in vlc code. You can see
the LIBAVUTIL_VERSION_CHECK macro in avcommon.h file.
> ---
> modules/codec/avcodec/encoder.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
> diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
> index 5c06385..80bce30 100644
> --- a/modules/codec/avcodec/encoder.c
> +++ b/modules/codec/avcodec/encoder.c
> @@ -1120,6 +1120,11 @@ static block_t *EncodeAudio( encoder_t *p_enc, block_t *p_aout_buf )
> {
> //How much we need to copy from new packet
> const int leftover = leftover_samples * p_enc->fmt_in.audio.i_channels * p_sys->i_sample_bytes;
> +#if LIBAVUTIL_VERSION_CHECK( 51,27,2,0,0 )
> + const int align = 0;
> +#else
> + const int align = 1;
> +#endif
> AVPacket packet = {0};
> avcodec_get_frame_defaults( p_sys->frame );
> @@ -1146,7 +1151,7 @@ static block_t *EncodeAudio( encoder_t *p_enc, block_t *p_aout_buf )
> if( avcodec_fill_audio_frame( p_sys->frame, p_enc->fmt_in.audio.i_channels,
> p_sys->p_context->sample_fmt, p_sys->p_buffer,
> leftover + buffer_delay,
> - 0) < 0 )
> + align) < 0 )
> msg_Err( p_enc, "filling error on fillup" );
> buffer_delay = 0;
> @@ -1210,6 +1215,11 @@ static block_t *EncodeAudio( encoder_t *p_enc, block_t *p_aout_buf )
> ( p_sys->b_variable && p_aout_buf->i_nb_samples ) )
> {
> AVPacket packet = {0};
> +#if LIBAVUTIL_VERSION_CHECK( 51,27,2,0,0 )
> + const int align = 0;
> +#else
> + const int align = 1;
> +#endif
> if( unlikely( p_aout_buf->i_pts > VLC_TS_INVALID &&
> p_aout_buf->i_pts != date_Get( &p_sys->buffer_date ) ) )
> @@ -1234,7 +1244,7 @@ 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_buffer : p_aout_buf->p_buffer,
> __MIN(p_sys->i_buffer_out, p_aout_buf->i_buffer),
> - 0) < 0 )
> + align) < 0 )
> msg_Err( p_enc, "filling error on encode" );
> p_aout_buf->p_buffer += (p_sys->frame->nb_samples * p_enc->fmt_in.audio.i_channels * p_sys->i_sample_bytes);
--
Ilkka Ollakka
Think of prototypes as a funny markup language--the interpretation is
left up to the rendering engine.
-- Larry Wall in <199710221710.KAA24242 at wall.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20130503/07d48055/attachment.sig>
More information about the vlc-devel
mailing list