[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 1712, Sat Jul 8 14:19:04 2006 UTC revision 1757, Wed Nov 8 06:55:27 2006 UTC
# Line 21  Line 21 
21   *  along with this program; if not, write to the Free Software   *  along with this program; if not, write to the Free Software
22   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
23   *   *
24   * $Id: xvid_encraw.c,v 1.26 2006-07-08 14:19:04 Skal Exp $   * $Id: xvid_encraw.c,v 1.33 2006-11-08 06:55:27 Skal Exp $
25   *   *
26   ****************************************************************************/   ****************************************************************************/
27    
# Line 165  Line 165 
165  static  frame_stats_t framestats[7];  static  frame_stats_t framestats[7];
166    
167  static  int ARG_STATS = 0;  static  int ARG_STATS = 0;
168    static  int ARG_SSIM = -1;
169    static  char* ARG_SSIM_PATH = NULL;
170  static  int ARG_DUMP = 0;  static  int ARG_DUMP = 0;
171  static  int ARG_LUMIMASKING = 0;  static  int ARG_LUMIMASKING = 0;
172  static  int ARG_BITRATE = 0;  static  int ARG_BITRATE = 0;
# Line 174  Line 176 
176  static  char *ARG_PASS2 = 0;  static  char *ARG_PASS2 = 0;
177  //static int ARG_QUALITY = ME_ELEMENTS - 1;  //static int ARG_QUALITY = ME_ELEMENTS - 1;
178  static  int ARG_QUALITY = 6;  static  int ARG_QUALITY = 6;
179  static  float ARG_FRAMERATE = 0.00f;  static  float ARG_FRAMERATE = 25.00f;
180  static  int ARG_DWRATE = 25;  static  int ARG_DWRATE = 25;
181  static  int ARG_DWSCALE = 1;  static  int ARG_DWSCALE = 1;
182  static  int ARG_MAXFRAMENR = ABS_MAXFRAMENR;  static  int ARG_MAXFRAMENR = ABS_MAXFRAMENR;
# Line 578  Line 580 
580                          ARG_INPUTFILE = argv[i];                          ARG_INPUTFILE = argv[i];
581                  } else if (strcmp("-stats", argv[i]) == 0) {                  } else if (strcmp("-stats", argv[i]) == 0) {
582                          ARG_STATS = 1;                          ARG_STATS = 1;
583                    } else if (strcmp("-ssim", argv[i]) == 0) {
584                            ARG_SSIM = 2;
585                            if ((i < argc - 1) && (*argv[i+1] != '-')) {
586                                    i++;
587                                    ARG_SSIM = atoi(argv[i]);
588                            }
589                    } else if (strcmp("-ssim_file", argv[i]) == 0 && i < argc -1) {
590                            i++;
591                            ARG_SSIM_PATH = argv[i];
592                  } else if (strcmp("-timecode", argv[i]) == 0 && i < argc -1) {                  } else if (strcmp("-timecode", argv[i]) == 0 && i < argc -1) {
593                          i++;                          i++;
594                          ARG_TIMECODEFILE = argv[i];                          ARG_TIMECODEFILE = argv[i];
# Line 1190  Line 1201 
1201                                  framestats[5].size += stats_length;                                  framestats[5].size += stats_length;
1202                          }                          }
1203    
1204    #define SSE2PSNR(sse, width, height) ((!(sse))?0.0f : 48.131f - 10*(float)log10((float)(sse)/((float)((width)*(height)))))
1205    
1206                          if (ARG_PROGRESS == 0) {                          if (ARG_PROGRESS == 0) {
1207                                  printf("%5d: key=%i, time= %6.0f, len= %7d", !result ? input_num : -1,                                  printf("%5d: key=%i, time= %6.0f, len= %7d", !result ? input_num : -1,
# Line 1197  Line 1209 
1209                                  printf(" | type=%s, quant= %2d, len= %7d", type, stats_quant,                                  printf(" | type=%s, quant= %2d, len= %7d", type, stats_quant,
1210                                     stats_length);                                     stats_length);
1211    
 #define SSE2PSNR(sse, width, height) ((!(sse))?0.0f : 48.131f - 10*(float)log10((float)(sse)/((float)((width)*(height)))))  
1212    
1213                                  if (ARG_STATS) {                                  if (ARG_STATS) {
1214                                          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",
1215                                                  SSE2PSNR(sse[0], XDIM, YDIM), SSE2PSNR(sse[1], XDIM / 2,                                                  SSE2PSNR(sse[0], XDIM, YDIM), SSE2PSNR(sse[1], XDIM / 2, YDIM / 2),
                                                                                                                                 YDIM / 2),  
1216                                                  SSE2PSNR(sse[2], XDIM / 2, YDIM / 2));                                                  SSE2PSNR(sse[2], XDIM / 2, YDIM / 2));
   
                                         totalPSNR[0] += SSE2PSNR(sse[0], XDIM, YDIM);  
                                         totalPSNR[1] += SSE2PSNR(sse[1], XDIM/2, YDIM/2);  
                                         totalPSNR[2] += SSE2PSNR(sse[2], XDIM/2, YDIM/2);  
1217                                  }                                  }
1218                                  printf("\n");                                  printf("\n");
1219                          } else {                          } else {
# Line 1224  Line 1230 
1230                                  }                                  }
1231                          }                          }
1232    
1233                            if (ARG_STATS) {
1234                                    totalPSNR[0] += SSE2PSNR(sse[0], XDIM, YDIM);
1235                                    totalPSNR[1] += SSE2PSNR(sse[1], XDIM/2, YDIM/2);
1236                                    totalPSNR[2] += SSE2PSNR(sse[2], XDIM/2, YDIM/2);
1237                  }                  }
1238  #undef SSE2PSNR  #undef SSE2PSNR
1239                    }
1240    
1241                  if (m4v_size < 0)                  if (m4v_size < 0)
1242                          break;                          break;
# Line 1561  Line 1572 
1572          fprintf(stderr, " -noclosed_gop                  : Disable closed GOP mode\n");          fprintf(stderr, " -noclosed_gop                  : Disable closed GOP mode\n");
1573          fprintf(stderr, " -lumimasking                   : use lumimasking algorithm\n");          fprintf(stderr, " -lumimasking                   : use lumimasking algorithm\n");
1574          fprintf(stderr, " -stats                         : print stats about encoded frames\n");          fprintf(stderr, " -stats                         : print stats about encoded frames\n");
1575            fprintf(stderr, " -ssim [integer]                : prints ssim for every frame (accurate: 0 fast: 4) (2)\n");
1576            fprintf(stderr, " -ssim_file filename            : outputs the ssim stats into a file\n");
1577          fprintf(stderr, " -debug                         : activates xvidcore internal debugging output\n");          fprintf(stderr, " -debug                         : activates xvidcore internal debugging output\n");
1578          fprintf(stderr, " -vop_debug                     : print some info directly into encoded frames\n");          fprintf(stderr, " -vop_debug                     : print some info directly into encoded frames\n");
1579          fprintf(stderr, " -nochromame                    : Disable chroma motion estimation\n");          fprintf(stderr, " -nochromame                    : Disable chroma motion estimation\n");
# Line 1763  Line 1776 
1776      xvid_plugin_single_t single;      xvid_plugin_single_t single;
1777          xvid_plugin_2pass1_t rc2pass1;          xvid_plugin_2pass1_t rc2pass1;
1778          xvid_plugin_2pass2_t rc2pass2;          xvid_plugin_2pass2_t rc2pass2;
1779            xvid_plugin_ssim_t ssim;
1780          //xvid_plugin_fixed_t rcfixed;          //xvid_plugin_fixed_t rcfixed;
1781          xvid_enc_plugin_t plugins[7];          xvid_enc_plugin_t plugins[8];
1782          xvid_gbl_init_t xvid_gbl_init;          xvid_gbl_init_t xvid_gbl_init;
1783          xvid_enc_create_t xvid_enc_create;          xvid_enc_create_t xvid_enc_create;
1784          int i;          int i;
# Line 1893  Line 1907 
1907                  xvid_enc_create.num_plugins++;                  xvid_enc_create.num_plugins++;
1908          }          }
1909    
1910            if (ARG_SSIM>=0 || ARG_SSIM_PATH != NULL) {
1911                    plugins[xvid_enc_create.num_plugins].func = xvid_plugin_ssim;
1912                    ssim.b_printstat = 1;
1913                    ssim.stat_path = ARG_SSIM_PATH;
1914                    ssim.b_visualize = 0;
1915                    ssim.acc = (ARG_SSIM_PATH != NULL && ARG_SSIM < 0) ? 2 : ARG_SSIM;
1916                    plugins[xvid_enc_create.num_plugins].param = &ssim;
1917                    xvid_enc_create.num_plugins++;
1918            }
1919    
1920  #if 0  #if 0
1921          if (ARG_DEBUG) {          if (ARG_DEBUG) {
1922                  plugins[xvid_enc_create.num_plugins].func = rawenc_debug;                  plugins[xvid_enc_create.num_plugins].func = rawenc_debug;

Legend:
Removed from v.1712  
changed lines
  Added in v.1757

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