| 275 | static int i_frame = 0; |
| 276 | |
| 277 | static int init( int width, int height ) |
| 278 | { |
| 279 | /* Get default params for preset/tuning */ |
| 280 | if( x264_param_default_preset( ¶m, "medium", NULL ) < 0 ) |
| 281 | { |
| 282 | goto x264_init_fail; |
| 283 | } |
| 284 | |
| 285 | /* Configure non-default params */ |
| 286 | param.i_bitdepth = 8; |
| 287 | param.i_csp = X264_CSP_I420; |
| 288 | param.i_width = width; |
| 289 | param.i_height = height; |
| 290 | param.b_vfr_input = 0; |
| 291 | param.b_repeat_headers = 1; |
| 292 | param.b_annexb = 1; |
| 293 | |
| 294 | /* Apply profile restrictions. */ |
| 295 | if( x264_param_apply_profile( ¶m, "high" ) < 0 ) |
| 296 | { |
| 297 | goto x264_init_fail; |
| 298 | } |
| 299 | |
| 300 | if( x264_picture_alloc( &pic, param.i_csp, param.i_width, param.i_height ) < 0 ) |
| 301 | { |
| 302 | goto x264_init_fail; |
| 303 | } |
| 304 | |
| 305 | hdl = x264_encoder_open( ¶m ); |
| 306 | if ( hdl == NULL ) |
| 307 | { |
| 308 | goto x264_init_fail; |
| 309 | } |
| 310 | i_frame = 0; |
| 311 | |
| 312 | return 0; |
| 313 | |
| 314 | x264_init_fail: |
| 315 | return -1; |
| 316 | } |
| 317 | |
| 318 | static int encode_frame( unsigned char *inBuf, int width, int height ) |
| 319 | { |