Commit 87fdea89 authored by Loren Merritt's avatar Loren Merritt

adjust bitstream buffer sizes for very large frames


git-svn-id: svn://svn.videolan.org/x264/trunk@635 df754926-b1dd-0310-bc7b-ec298dee348c
parent 8b37cc6a
......@@ -676,9 +676,9 @@ x264_t *x264_encoder_open ( x264_param_t *param )
param->cpu&X264_CPU_ALTIVEC ? "Altivec " : "" );
h->out.i_nal = 0;
h->out.i_bitstream = X264_MAX( 1000000, h->param.i_width * h->param.i_height * 1.7
* ( h->param.rc.i_rc_method == X264_RC_ABR ? pow( 0.5, h->param.rc.i_qp_min )
: pow( 0.5, h->param.rc.i_qp_constant ) * X264_MAX( 1, h->param.rc.f_ip_factor )));
h->out.i_bitstream = X264_MAX( 1000000, h->param.i_width * h->param.i_height * 4
* ( h->param.rc.i_rc_method == X264_RC_ABR ? pow( 0.95, h->param.rc.i_qp_min )
: pow( 0.95, h->param.rc.i_qp_constant ) * X264_MAX( 1, h->param.rc.f_ip_factor )));
h->thread[0] = h;
h->i_thread_num = 0;
......
......@@ -46,8 +46,8 @@
#include "x264.h"
#include "muxers.h"
#define DATA_MAX 3000000
uint8_t data[DATA_MAX];
uint8_t *mux_buffer = NULL;
int mux_buffer_size = 0;
/* Ctrl-C handler */
static int b_ctrl_c = 0;
......@@ -729,17 +729,17 @@ static int Encode_frame( x264_t *h, hnd_t hout, x264_picture_t *pic )
for( i = 0; i < i_nal; i++ )
{
int i_size;
int i_data;
i_data = DATA_MAX;
if( ( i_size = x264_nal_encode( data, &i_data, 1, &nal[i] ) ) > 0 )
if( mux_buffer_size < nal[i].i_payload * 3/2 + 4 )
{
i_file += p_write_nalu( hout, data, i_size );
}
else if( i_size < 0 )
{
fprintf( stderr, "x264 [error]: need to increase buffer size (size=%d)\n", -i_size );
mux_buffer_size = nal[i].i_payload * 2 + 4;
x264_free( mux_buffer );
mux_buffer = x264_malloc( mux_buffer_size );
}
i_size = mux_buffer_size;
x264_nal_encode( mux_buffer, &i_size, 1, &nal[i] );
i_file += p_write_nalu( hout, mux_buffer, i_size );
}
if (i_nal)
p_set_eop( hout, &pic_out );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment