#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#ifndef WIN32
#include <sys/time.h>
#else
#include <time.h>
#endif
#include "xvid.h"
/*****************************************************************************
* Global vars in module and constants
****************************************************************************/
#define USE_PNM 0
#define USE_TGA 1
static int XDIM = 352;
static int YDIM = 288;
//static int XDIM = 176;
//static int YDIM = 144;
static int ARG_SAVEDECOUTPUT = 0;
static int ARG_SAVEMPEGSTREAM = 0;
static char *ARG_INPUTFILE = "tmp.m4d";
static int CSP = XVID_CSP_I420;
//static int CSP = XVID_CSP_YV12;
static int BPP = 1;
static int FORMAT = USE_PNM;
static char filepath[256] = "./";
static void *dec_handle = NULL;
#define BUFFER_SIZE (2*1024*1024)
static const int display_buffer_bytes = 0;
#define MIN_USEFUL_BYTES 1
/*****************************************************************************
* Local prototypes
****************************************************************************/
static double msecond();
static int dec_init(int use_assembler, int debug_level);
static int dec_main(unsigned char *istream,
unsigned char *ostream,
int istream_size,
xvid_dec_stats_t *xvid_dec_stats);
static int dec_stop();
static void usage();
static int write_pnm(char *filename, unsigned char *image);
static int write_tga(char *filename, unsigned char *image);
const char * type2str(int type)
{
if (type==XVID_TYPE_IVOP)
return "I";
if (type==XVID_TYPE_PVOP)
return "P";
if (type==XVID_TYPE_BVOP)
return "B";
return "S";
}
/*****************************************************************************
* Usage function
****************************************************************************/
static void usage()
{
fprintf(stderr, "Usage : xvid_decraw [OPTIONS]/n");
fprintf(stderr, "Options :/n");
fprintf(stderr, " -asm : use assembly optimizations (default=disabled)/n");
fprintf(stderr, " -debug : debug level (debug=0)/n");
fprintf(stderr, " -i string : input filename (default=stdin)/n");
fprintf(stderr, " -d : s