<div dir="ltr">1On Wed, Apr 2, 2014 at 3:18 AM, Rafaël Carré <span dir="ltr"><<a href="mailto:funman@videolan.org" target="_blank">funman@videolan.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<div class=""><br>
On 04/02/14 08:25, Tristan Matthews wrote:<br>
> Defaulting to 3 bytes broke the buffer allocation for BMP with ffmpeg, which<br>
> defaults to RGBA.<br>
><br>
> Fixes #9687<br>
> ---<br>
>  modules/codec/avcodec/encoder.c | 6 +++++-<br>
>  1 file changed, 5 insertions(+), 1 deletion(-)<br>
><br>
> diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c<br>
> index df77340..9bfe238 100644<br>
> --- a/modules/codec/avcodec/encoder.c<br>
> +++ b/modules/codec/avcodec/encoder.c<br>
<br>
</div>OK<br>
<div class=""><br>
> @@ -1017,7 +1017,11 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )<br>
<br>
</div>    /* Initialize the video output buffer the first time.<br>
     * This is done here instead of OpenEncoder() because we need the actual<br>
<div class=""><br>
>       * bits_per_pixel value, without having to assume anything.<br>
>       */<br>
<br>
</div>Can we use that value in OpenEncoder?<br></blockquote><div><br></div><div>p_context->bits_per_coded sample gets set by avcodec_open2, which happens in OpenEncoder. However, p_enc->fmt_out.video.i_bits_per_pixel is not usable until EncodeVideo so I wouldn't want to break cases that depend on it.<br>
<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class=""><br>
>      const int bytesPerPixel = p_enc->fmt_out.video.i_bits_per_pixel ?<br>
> -                         p_enc->fmt_out.video.i_bits_per_pixel / 8 : 3;<br>
> +                         p_enc->fmt_out.video.i_bits_per_pixel / 8 :<br>
> +                         p_sys->p_context->bits_per_coded_sample ?<br>
> +                         p_sys->p_context->bits_per_coded_sample / 8 :<br>
> +                         3;<br>
> +<br>
>      const int blocksize = __MAX( FF_MIN_BUFFER_SIZE,bytesPerPixel * p_sys->p_context->height * p_sys->p_context->width + 200 );<br>
>      block_t *p_block = block_Alloc( blocksize );<br>
>      if( unlikely(p_block == NULL) )<br>
><br>
</div>_______________________________________________<br>
vlc-devel mailing list<br>
To unsubscribe or modify your subscription options:<br>
<a href="https://mailman.videolan.org/listinfo/vlc-devel" target="_blank">https://mailman.videolan.org/listinfo/vlc-devel</a><br>
</blockquote></div><br></div></div>