[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 1729, Wed Oct 11 13:52:06 2006 UTC revision 1769, Tue Jan 9 20:08:53 2007 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.28 2006-10-11 13:52:06 Skal Exp $   * $Id: xvid_encraw.c,v 1.34 2007-01-09 20:08:53 Isibaar 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 = 0;  static  int ARG_SSIM = -1;
169  static  char* ARG_SSIM_PATH = NULL;  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;
# Line 391  Line 391 
391                  } else if (strcmp("-h", argv[i]) == 0 && i < argc - 1) {                  } else if (strcmp("-h", argv[i]) == 0 && i < argc - 1) {
392                          i++;                          i++;
393                          YDIM = atoi(argv[i]);                          YDIM = atoi(argv[i]);
394                    } else if (strcmp("-csp",argv[i]) == 0 && i < argc - 1) {
395                            i++;
396                            if (strcmp(argv[i],"i420") == 0){
397                                    ARG_COLORSPACE = XVID_CSP_I420;
398                            } else if(strcmp(argv[i],"yv12") == 0){
399                                    ARG_COLORSPACE = XVID_CSP_YV12;
400                            } else {
401                                    printf("Invalid colorspace\n");
402                                    return 0;
403                            }
404          } else if (strcmp("-bitrate", argv[i]) == 0) {          } else if (strcmp("-bitrate", argv[i]) == 0) {
405                          if (i < argc - 1)                          if (i < argc - 1)
406                                  ARG_BITRATE = atoi(argv[i+1]);                                  ARG_BITRATE = atoi(argv[i+1]);
# Line 581  Line 591 
591                  } else if (strcmp("-stats", argv[i]) == 0) {                  } else if (strcmp("-stats", argv[i]) == 0) {
592                          ARG_STATS = 1;                          ARG_STATS = 1;
593                  } else if (strcmp("-ssim", argv[i]) == 0) {                  } else if (strcmp("-ssim", argv[i]) == 0) {
594                          ARG_SSIM = 1;                          ARG_SSIM = 2;
595                            if ((i < argc - 1) && (*argv[i+1] != '-')) {
596                                    i++;
597                                    ARG_SSIM = atoi(argv[i]);
598                            }
599                  } else if (strcmp("-ssim_file", argv[i]) == 0 && i < argc -1) {                  } else if (strcmp("-ssim_file", argv[i]) == 0 && i < argc -1) {
600                          i++;                          i++;
601                          ARG_SSIM_PATH = argv[i];                          ARG_SSIM_PATH = argv[i];
# Line 1197  Line 1211 
1211                                  framestats[5].size += stats_length;                                  framestats[5].size += stats_length;
1212                          }                          }
1213    
1214    #define SSE2PSNR(sse, width, height) ((!(sse))?0.0f : 48.131f - 10*(float)log10((float)(sse)/((float)((width)*(height)))))
1215    
1216                          if (ARG_PROGRESS == 0) {                          if (ARG_PROGRESS == 0) {
1217                                  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 1204  Line 1219 
1219                                  printf(" | type=%s, quant= %2d, len= %7d", type, stats_quant,                                  printf(" | type=%s, quant= %2d, len= %7d", type, stats_quant,
1220                                     stats_length);                                     stats_length);
1221    
 #define SSE2PSNR(sse, width, height) ((!(sse))?0.0f : 48.131f - 10*(float)log10((float)(sse)/((float)((width)*(height)))))  
1222    
1223                                  if (ARG_STATS) {                                  if (ARG_STATS) {
1224                                          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",
1225                                                  SSE2PSNR(sse[0], XDIM, YDIM), SSE2PSNR(sse[1], XDIM / 2,                                                  SSE2PSNR(sse[0], XDIM, YDIM), SSE2PSNR(sse[1], XDIM / 2, YDIM / 2),
                                                                                                                                 YDIM / 2),  
1226                                                  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);  
1227                                  }                                  }
1228                                  printf("\n");                                  printf("\n");
1229                          } else {                          } else {
# Line 1231  Line 1240 
1240                                  }                                  }
1241                          }                          }
1242    
1243                            if (ARG_STATS) {
1244                                    totalPSNR[0] += SSE2PSNR(sse[0], XDIM, YDIM);
1245                                    totalPSNR[1] += SSE2PSNR(sse[1], XDIM/2, YDIM/2);
1246                                    totalPSNR[2] += SSE2PSNR(sse[2], XDIM/2, YDIM/2);
1247                  }                  }
1248  #undef SSE2PSNR  #undef SSE2PSNR
1249                    }
1250    
1251                  if (m4v_size < 0)                  if (m4v_size < 0)
1252                          break;                          break;
# Line 1505  Line 1519 
1519  #endif  #endif
1520          fprintf(stderr, " -w      integer: frame width ([1.2048])\n");          fprintf(stderr, " -w      integer: frame width ([1.2048])\n");
1521          fprintf(stderr, " -h      integer: frame height ([1.2048])\n");          fprintf(stderr, " -h      integer: frame height ([1.2048])\n");
1522            fprintf(stderr, " -csp    string : colorspace of raw input file i420, yv12 (default)\n");
1523          fprintf(stderr, " -frames integer: number of frames to encode\n");          fprintf(stderr, " -frames integer: number of frames to encode\n");
1524          fprintf(stderr, "\n");          fprintf(stderr, "\n");
1525          fprintf(stderr, "Output options:\n");          fprintf(stderr, "Output options:\n");
# Line 1568  Line 1583 
1583          fprintf(stderr, " -noclosed_gop                  : Disable closed GOP mode\n");          fprintf(stderr, " -noclosed_gop                  : Disable closed GOP mode\n");
1584          fprintf(stderr, " -lumimasking                   : use lumimasking algorithm\n");          fprintf(stderr, " -lumimasking                   : use lumimasking algorithm\n");
1585          fprintf(stderr, " -stats                         : print stats about encoded frames\n");          fprintf(stderr, " -stats                         : print stats about encoded frames\n");
1586          fprintf(stderr, " -ssim                          : prints the ssim stats for every encoded frame (slow!)\n");          fprintf(stderr, " -ssim [integer]                : prints ssim for every frame (accurate: 0 fast: 4) (2)\n");
1587          fprintf(stderr, " -ssim_file filename            : outputs the ssim stats into a file\n");          fprintf(stderr, " -ssim_file filename            : outputs the ssim stats into a file\n");
1588          fprintf(stderr, " -debug                         : activates xvidcore internal debugging output\n");          fprintf(stderr, " -debug                         : activates xvidcore internal debugging output\n");
1589          fprintf(stderr, " -vop_debug                     : print some info directly into encoded frames\n");          fprintf(stderr, " -vop_debug                     : print some info directly into encoded frames\n");
# Line 1903  Line 1918 
1918                  xvid_enc_create.num_plugins++;                  xvid_enc_create.num_plugins++;
1919          }          }
1920    
1921  #ifndef WIN32          if (ARG_SSIM>=0 || ARG_SSIM_PATH != NULL) {
         if (ARG_SSIM) {  
1922                  plugins[xvid_enc_create.num_plugins].func = xvid_plugin_ssim;                  plugins[xvid_enc_create.num_plugins].func = xvid_plugin_ssim;
1923    
1924                    if( ARG_SSIM >=0){
1925                  ssim.b_printstat = 1;                  ssim.b_printstat = 1;
1926                            ssim.acc = ARG_SSIM;
1927                    } else {
1928                            ssim.b_printstat = 0;
1929                            ssim.acc = 2;
1930                    }
1931    
1932                    if(ARG_SSIM_PATH != NULL){
1933                  ssim.stat_path = ARG_SSIM_PATH;                  ssim.stat_path = ARG_SSIM_PATH;
1934                    }
1935    
1936                  ssim.b_visualize = 0;                  ssim.b_visualize = 0;
1937                  plugins[xvid_enc_create.num_plugins].param = &ssim;                  plugins[xvid_enc_create.num_plugins].param = &ssim;
1938                  xvid_enc_create.num_plugins++;                  xvid_enc_create.num_plugins++;
1939          }          }
 #endif  
1940    
1941  #if 0  #if 0
1942          if (ARG_DEBUG) {          if (ARG_DEBUG) {
# Line 2052  Line 2076 
2076          if (image) {          if (image) {
2077                  xvid_enc_frame.input.plane[0] = image;                  xvid_enc_frame.input.plane[0] = image;
2078  #ifndef READ_PNM  #ifndef READ_PNM
                 if (ARG_INPUTTYPE==2)  
2079                          xvid_enc_frame.input.csp = ARG_COLORSPACE;                          xvid_enc_frame.input.csp = ARG_COLORSPACE;
                 else  
                         xvid_enc_frame.input.csp = XVID_CSP_I420;  
2080                  xvid_enc_frame.input.stride[0] = XDIM;                  xvid_enc_frame.input.stride[0] = XDIM;
2081  #else  #else
2082                  xvid_enc_frame.input.csp = XVID_CSP_BGR;                  xvid_enc_frame.input.csp = XVID_CSP_BGR;

Legend:
Removed from v.1729  
changed lines
  Added in v.1769

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