+ /* Initialize the video output buffer the first time.
+ * This is done here instead of OpenEncoder() because we need the actual
+ * bits_per_pixel value, without having to assume anything.
+ */
+ if ( p_sys->p_buffer_out == NULL )
+ {
+ int bytesPerPixel = p_enc->fmt_out.video.i_bits_per_pixel ?
+ p_enc->fmt_out.video.i_bits_per_pixel / 8 : 3;
+
+ p_sys->i_buffer_out = p_sys->p_context->height * p_sys->p_context->width
+ * bytesPerPixel + 200; /* some room for potential headers (such as BMP) */
+
+ if( p_sys->i_buffer_out < FF_MIN_BUFFER_SIZE )
+ p_sys->i_buffer_out = FF_MIN_BUFFER_SIZE;
+ p_sys->p_buffer_out = malloc( p_sys->i_buffer_out );
+ }