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;
#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;
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 );