[svn] / trunk / xvidcore / examples / xvid_encraw.c Repository:
ViewVC logotype

Diff of /trunk/xvidcore/examples/xvid_encraw.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1909, Sun Nov 28 15:19:07 2010 UTC revision 1932, Thu Dec 30 11:47:06 2010 UTC
# Line 22  Line 22 
22   *  along with this program; if not, write to the Free Software   *  along with this program; if not, write to the Free Software
23   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
24   *   *
25   * $Id: xvid_encraw.c,v 1.45 2010-11-28 15:19:07 Isibaar Exp $   * $Id: xvid_encraw.c,v 1.48 2010-12-30 11:46:17 Isibaar Exp $
26   *   *
27   ****************************************************************************/   ****************************************************************************/
28    
# Line 257  Line 257 
257  static  int ARG_VBVMAXRATE = 0;  static  int ARG_VBVMAXRATE = 0;
258  static  int ARG_VBVPEAKRATE = 0;  static  int ARG_VBVPEAKRATE = 0;
259  static  int ARG_THREADS = 0;  static  int ARG_THREADS = 0;
260    static  int ARG_SLICES = 1;
261  static  int ARG_VFR = 0;  static  int ARG_VFR = 0;
262  static  int ARG_PROGRESS = 0;  static  int ARG_PROGRESS = 0;
263  static  int ARG_COLORSPACE = XVID_CSP_YV12;  static  int ARG_COLORSPACE = XVID_CSP_YV12;
# Line 447  Line 448 
448                  } else if (strcmp("-threads", argv[i]) == 0 && i < argc -1) {                  } else if (strcmp("-threads", argv[i]) == 0 && i < argc -1) {
449                          i++;                          i++;
450                          ARG_THREADS = atoi(argv[i]);                          ARG_THREADS = atoi(argv[i]);
451                    } else if (strcmp("-slices", argv[i]) == 0 && i < argc -1) {
452                            i++;
453                            ARG_SLICES = atoi(argv[i]);
454                  } else if (strcmp("-bquant_ratio", argv[i]) == 0 && i < argc - 1) {                  } else if (strcmp("-bquant_ratio", argv[i]) == 0 && i < argc - 1) {
455                          i++;                          i++;
456                          ARG_BQRATIO = atoi(argv[i]);                          ARG_BQRATIO = atoi(argv[i]);
# Line 481  Line 485 
485                                  memset(&ZONES[NUM_ZONES], 0, sizeof(zone_t));                                  memset(&ZONES[NUM_ZONES], 0, sizeof(zone_t));
486    
487                                  ZONES[NUM_ZONES].frame = startframe;                                  ZONES[NUM_ZONES].frame = startframe;
488                                  ZONES[NUM_ZONES].modifier = atof(options)*100;                                  ZONES[NUM_ZONES].modifier = (int)(atof(options)*100);
489                                  if (toupper(c)=='Q')                                  if (toupper(c)=='Q')
490                                          ZONES[NUM_ZONES].mode = XVID_ZONE_QUANT;                                          ZONES[NUM_ZONES].mode = XVID_ZONE_QUANT;
491                                  else if (toupper(c)=='W')                                  else if (toupper(c)=='W')
# Line 494  Line 498 
498                                  if ((frameoptions=strchr(options, ','))!=NULL) {                                  if ((frameoptions=strchr(options, ','))!=NULL) {
499                                          int readchar=0, count;                                          int readchar=0, count;
500                                          frameoptions++;                                          frameoptions++;
501                                          while (readchar<strlen(frameoptions)) {                                          while (readchar<(int)strlen(frameoptions)) {
502                                                  if (sscanf(frameoptions+readchar, "%d%n", &(ZONES[NUM_ZONES].bvop_threshold), &count)==1) {                                                  if (sscanf(frameoptions+readchar, "%d%n", &(ZONES[NUM_ZONES].bvop_threshold), &count)==1) {
503                                                          readchar += count;                                                          readchar += count;
504                                                  }                                                  }
# Line 532  Line 536 
536                          else {                          else {
537                                  ZONES[NUM_ZONES].mode = XVID_ZONE_WEIGHT;                                  ZONES[NUM_ZONES].mode = XVID_ZONE_WEIGHT;
538                          }                          }
539                          ZONES[NUM_ZONES].modifier = atof(argv[i+2])*100;                          ZONES[NUM_ZONES].modifier = (int)(atof(argv[i+2])*100);
540                          i++;                          i++;
541              ZONES[NUM_ZONES].frame = atoi(argv[i]);              ZONES[NUM_ZONES].frame = atoi(argv[i]);
542                          i++;                          i++;
# Line 559  Line 563 
563                          int exponent;                          int exponent;
564                          i++;                          i++;
565                          ARG_FRAMERATE = (float) atof(argv[i]);                          ARG_FRAMERATE = (float) atof(argv[i]);
566                          exponent = strcspn(argv[i], ".");                          exponent = (int)strcspn(argv[i], ".");
567                          if (exponent<strlen(argv[i]))                          if (exponent<(int)strlen(argv[i]))
568                                  exponent=pow(10.0, (int)(strlen(argv[i])-1-exponent));                                  exponent=(int)pow(10.0, (int)(strlen(argv[i])-1-exponent));
569                          else                          else
570                                  exponent=1;                                  exponent=1;
571                          ARG_DWRATE = atof(argv[i])*exponent;                          ARG_DWRATE = (int)(atof(argv[i])*exponent);
572                          ARG_DWSCALE = exponent;                          ARG_DWSCALE = exponent;
573                          exponent = gcd(ARG_DWRATE, ARG_DWSCALE);                          exponent = gcd(ARG_DWRATE, ARG_DWSCALE);
574                          ARG_DWRATE /= exponent;                          ARG_DWRATE /= exponent;
# Line 896  Line 900 
900                                  temp = (unsigned char*)AVIStreamGetFrame(get_frame, 0);                                  temp = (unsigned char*)AVIStreamGetFrame(get_frame, 0);
901                                  if (temp != NULL) {                                  if (temp != NULL) {
902                                          int i;                                          int i;
903                                          for (i = 0; i < ((DWORD*)temp)[0]; i++) {                                          for (i = 0; i < (int)((DWORD*)temp)[0]; i++) {
904                                                  fprintf(stderr, "%2d ", temp[i]);                                                  fprintf(stderr, "%2d ", temp[i]);
905                                          }                                          }
906                                          fprintf(stderr, "\n");                                          fprintf(stderr, "\n");
# Line 912  Line 916 
916            if (ARG_MAXFRAMENR<0)            if (ARG_MAXFRAMENR<0)
917                          ARG_MAXFRAMENR = avi_info.dwLength-ARG_STARTFRAMENR;                          ARG_MAXFRAMENR = avi_info.dwLength-ARG_STARTFRAMENR;
918                    else                    else
919                          ARG_MAXFRAMENR = min(ARG_MAXFRAMENR, avi_info.dwLength-ARG_STARTFRAMENR);                          ARG_MAXFRAMENR = min(ARG_MAXFRAMENR, (int)(avi_info.dwLength-ARG_STARTFRAMENR));
920    
921                    XDIM = avi_info.rcFrame.right - avi_info.rcFrame.left;                    XDIM = avi_info.rcFrame.right - avi_info.rcFrame.left;
922                    YDIM = avi_info.rcFrame.bottom - avi_info.rcFrame.top;                    YDIM = avi_info.rcFrame.bottom - avi_info.rcFrame.top;
# Line 959  Line 963 
963                                  fprintf(stderr, "Parameter conflict: Do not specify both -bitrate and -size\n");                                  fprintf(stderr, "Parameter conflict: Do not specify both -bitrate and -size\n");
964                                  goto release_all;                                  goto release_all;
965                  } else                  } else
966                          ARG_BITRATE = ((ARG_TARGETSIZE * 8) / (ARG_MAXFRAMENR / ARG_FRAMERATE)) * 1024;                          ARG_BITRATE = (int)(((ARG_TARGETSIZE * 8) / (ARG_MAXFRAMENR / ARG_FRAMERATE)) * 1024);
967          }          }
968    
969                  /* Set constant quant to default if no bitrate given for single pass */                  /* Set constant quant to default if no bitrate given for single pass */
# Line 1296  Line 1300 
1300                                  temp = (unsigned char*)AVIStreamGetFrame(get_frame, 0);                                  temp = (unsigned char*)AVIStreamGetFrame(get_frame, 0);
1301                                  if (temp != NULL) {                                  if (temp != NULL) {
1302                                          int i;                                          int i;
1303                                          for (i = 0; i < ((DWORD*)temp)[0]; i++) {                                          for (i = 0; i < (int)((DWORD*)temp)[0]; i++) {
1304                                                  fprintf(stderr, "%2d ", temp[i]);                                                  fprintf(stderr, "%2d ", temp[i]);
1305                                          }                                          }
1306                                          fprintf(stderr, "\n");                                          fprintf(stderr, "\n");
# Line 1523  Line 1527 
1527   *                       Encode and decode this frame   *                       Encode and decode this frame
1528   ****************************************************************************/   ****************************************************************************/
1529    
1530                  if ((input_num+start_num) >= (unsigned int)(stop_num-1) && ARG_MAXBFRAMES) {                  if ((unsigned int)(input_num+start_num) >= (unsigned int)(stop_num-1) && ARG_MAXBFRAMES) {
1531                          stats_type = XVID_TYPE_PVOP;                          stats_type = XVID_TYPE_PVOP;
1532                  }                  }
1533                  else                  else
# Line 1898  Line 1902 
1902          fprintf(stderr, " -drop    integer               : Frame Drop Ratio (0..100) (0)\n");          fprintf(stderr, " -drop    integer               : Frame Drop Ratio (0..100) (0)\n");
1903          fprintf(stderr, " -start   integer               : Starting frame number\n");          fprintf(stderr, " -start   integer               : Starting frame number\n");
1904          fprintf(stderr, " -threads integer               : Number of threads\n");          fprintf(stderr, " -threads integer               : Number of threads\n");
1905            fprintf(stderr, " -slices  integer               : Number of slices\n");
1906          fprintf(stderr, " -progress [integer]            : Show progress updates every n frames (10)\n");          fprintf(stderr, " -progress [integer]            : Show progress updates every n frames (10)\n");
1907          fprintf(stderr, " -par     integer[:integer]     : Set Pixel Aspect Ratio.\n");          fprintf(stderr, " -par     integer[:integer]     : Set Pixel Aspect Ratio.\n");
1908          fprintf(stderr, "                                  1 = 1:1\n");          fprintf(stderr, "                                  1 = 1:1\n");
# Line 1926  Line 1931 
1931          int bytes, xsize, ysize, depth;          int bytes, xsize, ysize, depth;
1932          char dummy[2];          char dummy[2];
1933    
1934          bytes = fread(dummy, 1, 2, handle);          bytes = (int) fread(dummy, 1, 2, handle);
1935    
1936          if ((bytes < 2) || (dummy[0] != 'P') || (dummy[1] != '5'))          if ((bytes < 2) || (dummy[0] != 'P') || (dummy[1] != '5'))
1937                  return (1);                  return (1);
# Line 2265  Line 2270 
2270  #endif  #endif
2271    
2272          xvid_enc_create.num_threads = ARG_THREADS;          xvid_enc_create.num_threads = ARG_THREADS;
2273            xvid_enc_create.num_slices  = ARG_SLICES;
2274    
2275          /* Frame rate  */          /* Frame rate  */
2276          xvid_enc_create.fincr = ARG_DWSCALE;          xvid_enc_create.fincr = ARG_DWSCALE;
# Line 2585  Line 2591 
2591    
2592                  ZONES[NUM_ZONES].frame = 0;                  ZONES[NUM_ZONES].frame = 0;
2593                  ZONES[NUM_ZONES].mode = XVID_ZONE_QUANT;                  ZONES[NUM_ZONES].mode = XVID_ZONE_QUANT;
2594                  ZONES[NUM_ZONES].modifier = ARG_CQ;                  ZONES[NUM_ZONES].modifier = (int)ARG_CQ;
2595                  ZONES[NUM_ZONES].type = XVID_TYPE_AUTO;                  ZONES[NUM_ZONES].type = XVID_TYPE_AUTO;
2596                  ZONES[NUM_ZONES].greyscale = 0;                  ZONES[NUM_ZONES].greyscale = 0;
2597                  ZONES[NUM_ZONES].chroma_opt = 0;                  ZONES[NUM_ZONES].chroma_opt = 0;
# Line 2601  Line 2607 
2607          for(i = 0; i < NUM_ZONES; i++)          for(i = 0; i < NUM_ZONES; i++)
2608                  if (ZONES[i].mode == XVID_ZONE_WEIGHT) {                  if (ZONES[i].mode == XVID_ZONE_WEIGHT) {
2609                          ZONES[i].mode = XVID_ZONE_QUANT;                          ZONES[i].mode = XVID_ZONE_QUANT;
2610                          ZONES[i].modifier = (100*ARG_CQ) / ZONES[i].modifier;                          ZONES[i].modifier = (int) ((100*ARG_CQ) / ZONES[i].modifier);
2611                  }                  }
2612  }  }
2613    
# Line 2670  Line 2676 
2676          int i;          int i;
2677          char* userdata;          char* userdata;
2678    
2679          for (i=0; i <= (bufsize-sizeof(userdata_start_code)); i++) {          for (i=0; i <= (int)(bufsize-sizeof(userdata_start_code)); i++) {
2680                  if (memcmp((void*)userdata_start_code, (void*)(buf+i), strlen(userdata_start_code))==0) {                  if (memcmp((void*)userdata_start_code, (void*)(buf+i), strlen(userdata_start_code))==0) {
2681                          if ((userdata = strstr(buf+i+4, "DivX"))!=NULL) {                          if ((userdata = strstr(buf+i+4, "DivX"))!=NULL) {
2682                                  userdata[strlen(userdata)-1] = '\0';                                  userdata[strlen(userdata)-1] = '\0';

Legend:
Removed from v.1909  
changed lines
  Added in v.1932

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4