Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 16th, 2010  |  syntax: C++  |  size: 1.76 KB  |  views: 212  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. void RenderEnginePixo::video_init_params(x264_param_t* params) {
  2.     ZeroMemory(&x264_params, sizeof(x264_params));
  3.     if(x264_param_default_preset(params, "veryfast", "zerolatency")) {
  4.         x264Error::throw_("x264_param_default_preset() failed");
  5.     }
  6.     const char* parms[] = {
  7.         "vbv-maxrate", "500",
  8.         "vbv-bufsize", "1666",
  9.         "intra-refresh", NULL,
  10.         //"fps", "30",
  11.         "slice-max-size", "1500",
  12.         "bitrate", "500",
  13.         0,0
  14.     };
  15.     const char** p = parms;
  16.     while(p[0]) {
  17.         if(x264_param_parse(params, p[0], p[1])) {
  18.             x264Error::throw_("x264_param_parse(\"%s\", \"%s\") failed", p[0], p[1]);
  19.         }
  20.         p += 2;
  21.     }
  22. }
  23.  
  24. ...
  25.  
  26.     if(!x264_encoder) {
  27.         first_frame = true;
  28.         video_init_params(&x264_params);
  29.         x264_params.i_width = (buffer->BufferWidth+1)&~1;
  30.         x264_params.i_height = (buffer->BufferHeight+1)&~1;
  31.         x264_params.i_timebase_num = 1000;
  32.         x264_params.i_timebase_den = 15000;
  33.  
  34. ...
  35.  
  36.     if(first_frame) {
  37.         video_encode_starttime = systemTimeProvider.getCurrentTime();
  38.         x264_picture.i_pts = 0;
  39.     } else {
  40.         //unsigned long millis = systemTimeProvider.getCurrentTime() - video_encode_starttime;
  41.         //x264_picture.i_pts += millis;
  42.         //x264_picture.i_pts += 10;
  43.         x264_picture.i_pts += 1;
  44.     }
  45.     x264_picture.i_type = X264_TYPE_AUTO;
  46.     x264_picture.i_qpplus1 = 0;
  47.  
  48.     x264_nal_t* nals;
  49.     int num_nals;
  50.     x264_picture_t pic_out;
  51.     int n = x264_encoder_encode(x264_encoder, &nals, &num_nals, &x264_picture, &pic_out);
  52.     //LOG("encoded: %d %d", n, num_nals);
  53.     if(n<0) {
  54.         x264Error::throw_("x264_encoder_encode() failed");
  55.     }
  56.     write_nals(nals, num_nals, x264_file);