[svn] / branches / dev-api-4 / xvidcore / examples / xvid_encraw.c Repository:
ViewVC logotype

Diff of /branches/dev-api-4/xvidcore/examples/xvid_encraw.c

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

revision 942, Tue Mar 25 11:01:48 2003 UTC revision 944, Tue Mar 25 22:53:57 2003 UTC
# Line 19  Line 19 
19   *  along with this program; if not, write to the Free Software   *  along with this program; if not, write to the Free Software
20   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21   *   *
22   * $Id: xvid_encraw.c,v 1.11.2.12 2003-03-25 11:01:48 suxen_drol Exp $   * $Id: xvid_encraw.c,v 1.11.2.13 2003-03-25 22:53:57 edgomez Exp $
23   *   *
24   ****************************************************************************/   ****************************************************************************/
25    
# Line 56  Line 56 
56          PMV_HALFPELREFINE16,          PMV_HALFPELREFINE16,
57          PMV_HALFPELREFINE16,          PMV_HALFPELREFINE16,
58          PMV_HALFPELREFINE16 | PMV_HALFPELREFINE8,          PMV_HALFPELREFINE16 | PMV_HALFPELREFINE8,
59          PMV_HALFPELREFINE16 | PMV_HALFPELREFINE8 | PMV_EXTSEARCH16 | PMV_USESQUARES16,          PMV_HALFPELREFINE16 | PMV_HALFPELREFINE8 | PMV_EXTSEARCH16 |
60          PMV_HALFPELREFINE16 | PMV_HALFPELREFINE8 | PMV_EXTSEARCH16 | PMV_USESQUARES16 | PMV_CHROMA16 | PMV_CHROMA8,                  PMV_USESQUARES16,
61            PMV_HALFPELREFINE16 | PMV_HALFPELREFINE8 | PMV_EXTSEARCH16 |
62                    PMV_USESQUARES16 | PMV_CHROMA16 | PMV_CHROMA8,
63  };  };
64    
65  static xvid_vol_t const vol_presets[] = {  static xvid_vol_t const vol_presets[] = {
# Line 75  Line 77 
77          XVID_DYNAMIC_BFRAMES | XVID_HALFPEL,          XVID_DYNAMIC_BFRAMES | XVID_HALFPEL,
78          XVID_DYNAMIC_BFRAMES | XVID_HALFPEL | XVID_INTER4V,          XVID_DYNAMIC_BFRAMES | XVID_HALFPEL | XVID_INTER4V,
79          XVID_DYNAMIC_BFRAMES | XVID_HALFPEL | XVID_INTER4V | XVID_HQACPRED,          XVID_DYNAMIC_BFRAMES | XVID_HALFPEL | XVID_INTER4V | XVID_HQACPRED,
80          XVID_DYNAMIC_BFRAMES | XVID_HALFPEL | XVID_HQACPRED | XVID_MODEDECISION_BITS          XVID_DYNAMIC_BFRAMES | XVID_HALFPEL | XVID_HQACPRED |
81                    XVID_MODEDECISION_BITS
82  };  };
83    
84  /*****************************************************************************  /*****************************************************************************
# Line 91  Line 94 
94  static int ARG_BITRATE = 0;  static int ARG_BITRATE = 0;
95  static char * ARG_PASS1 = 0;  static char * ARG_PASS1 = 0;
96  static char * ARG_PASS2 = 0;  static char * ARG_PASS2 = 0;
97  static int ARG_QUANTI = 0;  static float ARG_QUANTI = 0.0f;
98  static int ARG_QUALITY = 5;  static int ARG_QUALITY = 5;
99  static float ARG_FRAMERATE = 25.00f;  static float ARG_FRAMERATE = 25.00f;
100  static int ARG_MAXFRAMENR = ABS_MAXFRAMENR;  static int ARG_MAXFRAMENR = ABS_MAXFRAMENR;
# Line 250  Line 253 
253                          ARG_MAXFRAMENR = atoi(argv[i]);                          ARG_MAXFRAMENR = atoi(argv[i]);
254                  } else if (strcmp("-quant", argv[i]) == 0 && i < argc - 1) {                  } else if (strcmp("-quant", argv[i]) == 0 && i < argc - 1) {
255                          i++;                          i++;
256                          ARG_QUANTI = atoi(argv[i]);                          ARG_QUANTI = (float) atof(argv[i]);
257                  } else if (strcmp("-save", argv[i]) == 0) {                  } else if (strcmp("-save", argv[i]) == 0) {
258                          ARG_SAVEMPEGSTREAM = 1;                          ARG_SAVEMPEGSTREAM = 1;
259                  } else if (strcmp("-debug", argv[i]) == 0) {                  } else if (strcmp("-debug", argv[i]) == 0) {
# Line 390  Line 393 
393    
394                  /* Write the Frame statistics */                  /* Write the Frame statistics */
395    
396                  printf("%5d: key=%i, time=%6.0f, length=%7d",                  printf("%5d: key=%i, time=%6.0f, length=%7d", !result ? input_num : -1,
397                             !result ? input_num : -1,                             key, (float) enctime, (int) m4v_size);
                            key,  
                            (float) enctime,  
                            (int) m4v_size);  
398    
399                  if (stats_type > 0) {   /* !XVID_TYPE_NOTHING */                  if (stats_type > 0) {   /* !XVID_TYPE_NOTHING */
400    
# Line 423  Line 423 
423    
424                          if (ARG_STATS) {                          if (ARG_STATS) {
425                                  printf(", psnr y = %2.2f, psnr u = %2.2f, psnr v = %2.2f",                                  printf(", psnr y = %2.2f, psnr u = %2.2f, psnr v = %2.2f",
426                                             SSE2PSNR(sse[0], XDIM, YDIM),                                             SSE2PSNR(sse[0], XDIM, YDIM), SSE2PSNR(sse[1], XDIM / 2,
427                                             SSE2PSNR(sse[1], XDIM/2, YDIM/2),                                                                                                                            YDIM / 2),
428                                             SSE2PSNR(sse[2], XDIM/2, YDIM/2));                                             SSE2PSNR(sse[2], XDIM/2, YDIM/2));
429                          }                          }
430    
431                  }                  }
   
432  #undef SSE2PSNR  #undef SSE2PSNR
433    
434                  printf("\n");                  printf("\n");
# Line 565  Line 564 
564          fprintf(stderr, " -save    : save mpeg4 raw stream\n");          fprintf(stderr, " -save    : save mpeg4 raw stream\n");
565          fprintf(stderr, " -o string: output filename\n");          fprintf(stderr, " -o string: output filename\n");
566          fprintf(stderr, "\n");          fprintf(stderr, "\n");
567          fprintf(stderr, "Bitrate options:\n");          fprintf(stderr, "BFrames options:\n");
         fprintf(stderr, " -bitrate       integer: target bitrate (>0 | default=900kbit)\n");  
         fprintf(stderr, " -quant         integer: fixed quantizer (disables -b setting)\n");  
568          fprintf(stderr, " -max_bframes   integer: max bframes (default=0)\n");          fprintf(stderr, " -max_bframes   integer: max bframes (default=0)\n");
569          fprintf(stderr, " -bquant_ratio  integer: bframe quantizer ratio (default=150)\n");          fprintf(stderr, " -bquant_ratio  integer: bframe quantizer ratio (default=150)\n");
570          fprintf(stderr, " -bquant_offset integer: bframe quantizer offset (default=100)\n");          fprintf(stderr, " -bquant_offset integer: bframe quantizer offset (default=100)\n");
571          fprintf(stderr, " -framerate     float  : target framerate (>0)\n");          fprintf(stderr, "\n");
572            fprintf(stderr, "Rate control options:\n");
573            fprintf(stderr, " -framerate float               : target framerate (>0 | default=25.0)\n");
574            fprintf(stderr, " -bitrate   integer             : bitrate -- for CBR/VBR pass2\n");
575            fprintf(stderr, " -quant     float               : quantizer -- for \"Fixed\" quantizer RC\n");
576      fprintf(stderr,     " -pass1 filename      : stats filename\n");      fprintf(stderr,     " -pass1 filename      : stats filename\n");
577      fprintf(stderr,     " -pass2 filename1 filename2    : stats amd scaled-stats filename\n");          fprintf(stderr, " -pass2     filename1 filename2 : first pass stats and scaled stats filename\n");
578          fprintf(stderr, "\n");          fprintf(stderr, "\n");
579          fprintf(stderr, "Other options\n");          fprintf(stderr, "Other options\n");
580          fprintf(stderr, " -asm            : use assembly optmized code\n");          fprintf(stderr, " -asm            : use assembly optmized code\n");
# Line 581  Line 582 
582          fprintf(stderr, " -packed         : packed mode\n");          fprintf(stderr, " -packed         : packed mode\n");
583          fprintf(stderr, " -lumimasking    : use lumimasking algorithm\n");          fprintf(stderr, " -lumimasking    : use lumimasking algorithm\n");
584          fprintf(stderr, " -stats          : print stats about encoded frames\n");          fprintf(stderr, " -stats          : print stats about encoded frames\n");
585          fprintf(stderr, " -debug          : print all MB quantizers\n");          fprintf(stderr, " -debug          : print all MB dquants\n");
586          fprintf(stderr, " -help           : prints this help message\n");          fprintf(stderr, " -help           : prints this help message\n");
587  }  }
588    
# Line 719  Line 720 
720      xvid_plugin_cbr_t cbr;      xvid_plugin_cbr_t cbr;
721      xvid_plugin_2pass1_t rc2pass1;      xvid_plugin_2pass1_t rc2pass1;
722      xvid_plugin_2pass2_t rc2pass2;      xvid_plugin_2pass2_t rc2pass2;
723      xvid_enc_plugin_t plugins[6];          xvid_plugin_fixed_t rcfixed;
724            xvid_enc_plugin_t plugins[7];
725          xvid_gbl_init_t xvid_gbl_init;          xvid_gbl_init_t xvid_gbl_init;
726          xvid_enc_create_t xvid_enc_create;          xvid_enc_create_t xvid_enc_create;
727    
# Line 774  Line 776 
776                  xvid_enc_create.num_plugins++;                  xvid_enc_create.num_plugins++;
777      }      }
778    
779            if (ARG_QUANTI) {
780                    rcfixed.version = XVID_VERSION;
781                    /* We will use a 1/10 precision, just to make sure it works */
782                    rcfixed.quant_base = 10;
783                    rcfixed.quant_increment = (int) (ARG_QUANTI * 10);
784    
785                    plugins[xvid_enc_create.num_plugins].func = xvid_plugin_fixed;
786                    plugins[xvid_enc_create.num_plugins].param = &rcfixed;
787                    xvid_enc_create.num_plugins++;
788            }
789    
790      if (ARG_PASS1 && ARG_PASS2) {      if (ARG_PASS1 && ARG_PASS2) {
791          rc2pass2.version = XVID_VERSION;          rc2pass2.version = XVID_VERSION;
792          memset(&rc2pass2, 0, sizeof(xvid_plugin_2pass2_t));          memset(&rc2pass2, 0, sizeof(xvid_plugin_2pass2_t));
# Line 793  Line 806 
806                  xvid_enc_create.num_plugins++;                  xvid_enc_create.num_plugins++;
807      }      }
808    
   
809      if (ARG_LUMIMASKING) {      if (ARG_LUMIMASKING) {
810                  plugins[xvid_enc_create.num_plugins].func = xvid_plugin_lumimasking;                  plugins[xvid_enc_create.num_plugins].func = xvid_plugin_lumimasking;
811                  plugins[xvid_enc_create.num_plugins].param = NULL;                  plugins[xvid_enc_create.num_plugins].param = NULL;
# Line 837  Line 849 
849    
850          /* Global encoder options */          /* Global encoder options */
851          xvid_enc_create.global = 0;          xvid_enc_create.global = 0;
852          if (ARG_PACKED) xvid_enc_create.global |=XVID_PACKED;  
853          if (ARG_STATS)  xvid_enc_create.global |=XVID_EXTRASTATS_ENABLE;          if (ARG_PACKED)
854                    xvid_enc_create.global |=XVID_PACKED;
855    
856            if (ARG_STATS)
857                    xvid_enc_create.global |=XVID_EXTRASTATS_ENABLE;
858    
859          /* I use a small value here, since will not encode whole movies, but short clips */          /* I use a small value here, since will not encode whole movies, but short clips */
860          xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL);          xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL);
# Line 905  Line 921 
921          /* Frame type -- let core decide for us */          /* Frame type -- let core decide for us */
922          xvid_enc_frame.type = XVID_TYPE_AUTO;          xvid_enc_frame.type = XVID_TYPE_AUTO;
923    
924          /* Force the right quantizer */          /* Force the right quantizer -- It is internally managed by RC plugins */
925          xvid_enc_frame.quant = ARG_QUANTI;          xvid_enc_frame.quant = 0;
926    
927          /* Set up motion estimation flags */          /* Set up motion estimation flags */
928          xvid_enc_frame.motion = motion_presets[ARG_QUALITY];          xvid_enc_frame.motion = motion_presets[ARG_QUALITY];

Legend:
Removed from v.942  
changed lines
  Added in v.944

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