# verify.c
)
-ADD_LIBRARY(gdcmmpeg2 ${GDCM_MPEG2DEC_SOURCES} mpeg2dec.c)
-IF(UNIX)
- TARGET_LINK_LIBRARIES(gdcmmpeg2 -lm)
-ENDIF(UNIX)
+#ADD_LIBRARY(gdcmmpeg2 ${GDCM_MPEG2DEC_SOURCES} mpeg2dec.c)
+#IF(UNIX)
+# TARGET_LINK_LIBRARIES(gdcmmpeg2 -lm)
+#ENDIF(UNIX)
#ADD_DEFINITIONS(-DGDCM_BUILD_MPEG2DEC)
-#ADD_EXECUTABLE(mpeg2decode mpeg2dec.c)
-#TARGET_LINK_LIBRARIES(mpeg2decode gdcmmpeg2)
+ADD_EXECUTABLE(mpeg2decode ${GDCM_MPEG2DEC_SOURCES} mpeg2dec.c)
+TARGET_LINK_LIBRARIES(mpeg2decode -lm)
*
*/
-#include <stdio.h>
-#include <stdlib.h>
-
#include "config.h"
#include "global.h"
*
*/
-#include <stdio.h>
-
#include "config.h"
#include "global.h"
*
*/
-#include <stdio.h>
-
#include "config.h"
#include "global.h"
*
*/
-#include <stdio.h>
-
#include "config.h"
#include "global.h"
*
*/
-#include <stdio.h>
-
#include "config.h"
#include "global.h"
#include "getvlc.h"
*
*/
-#include <stdio.h>
-
#include "config.h"
#include "global.h"
*
*/
-#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <fcntl.h>
static void Print_Options();
#endif
+
int my_open(char *filename)
{
return open(filename,O_RDONLY|O_BINARY);
return close(infile);
}
+ostream *my_fopen(const char *path, const char *mode)
+{
+ FILE *fd = fopen(path, mode);
+ ostream *os = (ostream*)malloc(sizeof(ostream));
+ os->Fd = fd;
+ return os;
+}
+
+int my_fseek(ostream *stream, long offset, int whence)
+{
+ return fseek(stream->Fd, offset, whence);
+}
+
+size_t my_fread(void *ptr, size_t size, size_t nmemb, ostream *stream)
+{
+ return fread(ptr, size, nmemb, stream->Fd);
+}
+
+size_t my_fwrite(const void *ptr, size_t size, size_t nmemb, ostream *stream)
+{
+ return fwrite(ptr, size, nmemb, stream->Fd);
+}
+
+int my_fclose(ostream *fp)
+{
+ FILE *fd = fp->Fd;
+ free(fp);
+ return fclose(fd);
+}
+#include <stdarg.h>
+
+int my_printf(const char *format, ...)
+{
+ //return printf(format, ...);
+ va_list argptr;
+ int ret;
+
+ va_start(argptr, format);
+ ret = vprintf(format, argptr);
+ va_end(argptr);
+
+ return ret;
+}
+
+int my_sprintf(char *str, const char *format, ...)
+{
+ //return sprintf(str, format, ...);
+ va_list argptr;
+ int ret;
+
+ va_start(argptr, format);
+ ret = vsprintf(str,format, argptr);
+ va_end(argptr);
+
+ return ret;
+}
+
+int my_fprintf(const char *format, ...)
+{
+ //return fprintf(stderr, format, ...);
+ va_list argptr;
+ int ret;
+
+ va_start(argptr, format);
+ ret = vfprintf(stderr,format, argptr);
+ va_end(argptr);
+
+ return ret;
+}
+void my_exit(int status)
+{
+ exit(status);
+}
+
+#define GDCM_BUILD_MPEG2DEC
#ifdef GDCM_BUILD_MPEG2DEC
int main(argc,argv)
#define MB_WEIGHT 32
#define MB_CLASS4 64
+#include <stdio.h>
+typedef struct
+{
+ FILE* Fd;
+} ostream;
+
+int my_open(char *filename);
+int my_printf(const char *format, ...);
+int my_fprintf(const char *format, ...);
+int my_sprintf(char *str, const char *format, ...);
+void my_exit(int status);
+ostream *my_fopen(const char *path, const char *mode);
+int my_fseek(ostream *stream, long offset, int whence);
+size_t my_fread(void *ptr, size_t size, size_t nmemb, ostream *stream);
+int my_fclose(ostream *fp);
+
*
*/
-#include <stdio.h>
-
#include "config.h"
#include "global.h"
+/* spatscal.c, ???? */
+
+/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */
+
+/*
+ * Disclaimer of Warranty
+ *
+ * These software programs are available to the user without any license fee or
+ * royalty on an "as is" basis. The MPEG Software Simulation Group disclaims
+ * any and all warranties, whether express, implied, or statuary, including any
+ * implied warranties or merchantability or of fitness for a particular
+ * purpose. In no event shall the copyright-holder be liable for any
+ * incidental, punitive, or consequential damages of any kind whatsoever
+ * arising from the use of these programs.
+ *
+ * This disclaimer of warranty extends to the user of these programs and user's
+ * customers, employees, agents, transferees, successors, and assigns.
+ *
+ * The MPEG Software Simulation Group does not represent or warrant that the
+ * programs furnished hereunder are free of infringement of any third-party
+ * patents.
+ *
+ * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware,
+ * are subject to royalty fees to patent holders. Many of these patents are
+ * general enough such that they are unavoidable regardless of implementation
+ * design.
+ *
+ */
-#include <stdio.h>
#include <string.h> /* for strcat */
-#include <stdlib.h> /* for exit */
#include "config.h"
#include "global.h"
printf("reading %s\n",fname);
#endif /* VERBOSE */
fd=fopen(fname,"rb");
- if (fd==NULL) exit(-1);
+ if (fd==NULL) my_exit(-1);
for (j=0; j<lh; j++) {
for (i=0; i<lw; i++)
llframe0[comp][lw*j+i]=getc(fd);
printf("reading %s\n",fname);
#endif /* VERBOSE */
fd=fopen(fname,"rb");
- if (fd==NULL) exit(-1);
+ if (fd==NULL) my_exit(-1);
for (j=0; j<lh; j+=lower_layer_progressive_frame?1:2)
for (i=0; i<lw; i++)
llframe0[comp][lw*j+i]=getc(fd);
printf("reading %s\n",fname);
#endif /* VERBOSE */
fd=fopen(fname,"rb");
- if (fd==NULL) exit(-1);
+ if (fd==NULL) my_exit(-1);
for (j=1; j<lh; j+=2)
for (i=0; i<lw; i++)
llframe1[comp][lw*j+i]=getc(fd);
*
*/
-#include <stdio.h>
-#include <stdlib.h>
+#include <stdlib.h> /* for malloc */
#include <fcntl.h>
#include <string.h> /* for strcat */
if (progressive_sequence || progressive_frame || Frame_Store_Flag)
{
/* progressive */
- sprintf(outname,Output_Picture_Filename,frame,'f');
+ my_sprintf(outname,Output_Picture_Filename,frame,'f');
store_one(outname,src,0,Coded_Picture_Width,vertical_size);
}
else
{
/* interlaced */
- sprintf(outname,Output_Picture_Filename,frame,'a');
+ my_sprintf(outname,Output_Picture_Filename,frame,'a');
store_one(outname,src,0,Coded_Picture_Width<<1,vertical_size>>1);
- sprintf(outname,Output_Picture_Filename,frame,'b');
+ my_sprintf(outname,Output_Picture_Filename,frame,'b');
store_one(outname,src,
Coded_Picture_Width,Coded_Picture_Width<<1,vertical_size>>1);
}
hsize = horizontal_size;
- sprintf(tmpname,"%s.Y",outname);
+ my_sprintf(tmpname,"%s.Y",outname);
store_yuv1(tmpname,src[0],offset,incr,hsize,height);
if (chroma_format!=CHROMA444)
height>>=1;
}
- sprintf(tmpname,"%s.U",outname);
+ my_sprintf(tmpname,"%s.U",outname);
store_yuv1(tmpname,src[1],offset,incr,hsize,height);
- sprintf(tmpname,"%s.V",outname);
+ my_sprintf(tmpname,"%s.V",outname);
store_yuv1(tmpname,src[2],offset,incr,hsize,height);
}
unsigned char *p;
if (!Quiet_Flag)
- fprintf(stderr,"saving %s\n",name);
+ my_fprintf("saving %s\n",name);
if ((outfile = open(name,O_CREAT|O_TRUNC|O_WRONLY|O_BINARY,0666))==-1)
{
- sprintf(Error_Text,"Couldn't create %s\n",name);
+ my_sprintf(Error_Text,"Couldn't create %s\n",name);
Error(Error_Text);
}
strcat(outname,".SIF");
if (!Quiet_Flag)
- fprintf(stderr,"saving %s\n",outname);
+ my_fprintf("saving %s\n",outname);
if ((outfile = open(outname,O_CREAT|O_TRUNC|O_WRONLY|O_BINARY,0666))==-1)
{
- sprintf(Error_Text,"Couldn't create %s\n",outname);
+ my_sprintf(Error_Text,"Couldn't create %s\n",outname);
Error(Error_Text);
}
strcat(outname,tgaflag ? ".tga" : ".ppm");
if (!Quiet_Flag)
- fprintf(stderr,"saving %s\n",outname);
+ my_fprintf("saving %s\n",outname);
if ((outfile = open(outname,O_CREAT|O_TRUNC|O_WRONLY|O_BINARY,0666))==-1)
{
- sprintf(Error_Text,"Couldn't create %s\n",outname);
+ my_sprintf(Error_Text,"Couldn't create %s\n",outname);
Error(Error_Text);
}
else
{
/* PPM header */
- sprintf(header,"P6\n%d %d\n255\n",horizontal_size,height);
+ my_sprintf(header,"P6\n%d %d\n255\n",horizontal_size,height);
for (i=0; header[i]!=0; i++)
putbyte(header[i]);
-/* #define DEBUG */
/* subspic.c, Frame buffer substitution routines */
/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */
*
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
+//#include <fcntl.h>
#include "config.h"
#include "global.h"
#ifdef DEBUG
- printf("SUB: seq fn(%d) bitfn(%d) tempref(%d) picstr(%d) type(%d)\n",
+ my_printf("SUB: seq fn(%d) bitfn(%d) tempref(%d) picstr(%d) type(%d)\n",
sequence_framenum, bitstream_framenum, temporal_reference,
picture_structure, picture_coding_type);
#endif
#ifdef DEBUG
else if((picture_coding_type!=B_TYPE)||(picture_coding_type!=D_TYPE))
{
- printf("NO SUBS FOR THIS PICTURE\n");
+ my_printf("NO SUBS FOR THIS PICTURE\n");
}
#endif
}
int field_mode;
if(framenum<0)
- printf("ERROR: framenum (%d) is less than zero\n", framenum);
+ my_printf("ERROR: framenum (%d) is less than zero\n", framenum);
if(Big_Picture_Flag)
if(rerr!=0)
{
- printf("was unable to substitute frame\n");
+ my_printf("was unable to substitute frame\n");
}
/* now copy to the appropriate buffer */
#ifdef VERBOSE
if(Verbose_Flag > NO_LAYER)
- printf("substituted %s %d\n",
+ my_printf("substituted %s %d\n",
(field_mode ? (parity?"bottom field":"bottom field"):"frame"), framenum);
#endif
}
char outname[FILENAME_LENGTH];
char name[FILENAME_LENGTH];
- sprintf(outname,filename,framenum);
+ my_sprintf(outname,filename,framenum);
- sprintf(name,"%s.Y",outname);
+ my_sprintf(name,"%s.Y",outname);
err += Read_Component(name, frame[0], Coded_Picture_Width,
Coded_Picture_Height);
- sprintf(name,"%s.U",outname);
+ my_sprintf(name,"%s.U",outname);
err += Read_Component(name, frame[1], Chroma_Width, Chroma_Height);
- sprintf(name,"%s.V",outname);
+ my_sprintf(name,"%s.V",outname);
err += Read_Component(name, frame[2], Chroma_Width, Chroma_Height);
return(err);
Size = Width*Height;
#ifdef DEBUG
- printf("SUBS: reading %s\n", filename);
+ my_printf("SUBS: reading %s\n", filename);
#endif
- if(!(Infile=open(Filename,O_RDONLY|O_BINARY))<0)
+ if(!(Infile=my_open(Filename))<0)
{
- printf("ERROR: unable to open reference filename (%s)\n", Filename);
+ my_printf("ERROR: unable to open reference filename (%s)\n", Filename);
return(-1);
}
- abort();
+ /*abort();*/
Bytes_Read = read(Infile, Frame, Size);
if(Bytes_Read!=Size)
{
- printf("was able to read only %d bytes of %d of file %s\n",
+ my_printf("was able to read only %d bytes of %d of file %s\n",
Bytes_Read, Size, Filename);
}
int framenum;
{
/* int err = 0; */
- FILE *fd;
+ //FILE *fd;
+ ostream *fd;
int line;
int size, offset;
- abort();
+ /*abort();*/
- if (!(fd = fopen(filename,"rb")))
+ if (!(fd = my_fopen(filename,"rb")))
{
- sprintf(Error_Text,"Couldn't open %s\n",filename);
+ my_sprintf(Error_Text,"Couldn't open %s\n",filename);
return(-1);
}
else if(chroma_format==CHROMA420)
size = ((size*3)>>1);
else
- printf("ERROR: chroma_format (%d) not recognized\n", chroma_format);
+ my_printf("ERROR: chroma_format (%d) not recognized\n", chroma_format);
/* compute distance into "big" file */
offset = size*framenum;
#ifdef DEBUG
- printf("EXTRACTING: frame(%d) offset(%d), size (%d) from %s\n",
+ my_printf("EXTRACTING: frame(%d) offset(%d), size (%d) from %s\n",
framenum, offset, size, filename);
#endif
/* seek to location in big file where desired frame begins */
/* note: this offset cannot exceed a few billion bytes due to the */
/* obvious limitations of 32-bit integers */
- fseek(fd, offset, SEEK_SET);
+ my_fseek(fd, offset, SEEK_SET);
/* Y */
for (line=0; line<Coded_Picture_Height; line++)
{
- fread(frame[0]+(line*Coded_Picture_Width),1,Coded_Picture_Width,fd);
+ my_fread(frame[0]+(line*Coded_Picture_Width),1,Coded_Picture_Width,fd);
}
/* Cb */
for (line=0; line<Chroma_Height; line++)
{
- fread(frame[1]+(line*Chroma_Width),1,Chroma_Width,fd);
+ my_fread(frame[1]+(line*Chroma_Width),1,Chroma_Width,fd);
}
/* Cr */
for (line=0; line<Chroma_Height; line++)
{
- fread(frame[2]+(line*Chroma_Width),1,Chroma_Width,fd);
+ my_fread(frame[2]+(line*Chroma_Width),1,Chroma_Width,fd);
}
- fclose(fd);
+ my_fclose(fd);
return(0);
}
s = d = 0;
#ifdef DEBUG
- printf("COPYING (w=%d, h=%d, parity=%d, field_mode=%d)\n",
+ my_printf("COPYING (w=%d, h=%d, parity=%d, field_mode=%d)\n",
width,height,parity,field_mode);
#endif /* DEBUG */
*
*/
-#include <stdio.h>
-#include <stdlib.h>
-
#include "config.h"
#include "global.h"
ld->Rdptr++;
code=Get_Byte(); /* parse PES_header_data_length */
ld->Rdptr+=code; /* advance pointer by PES_header_data_length */
- printf("MPEG-2 PES packet\n");
+ my_printf("MPEG-2 PES packet\n");
return;
}
else if(code==0xff)
{
if(code>=0x80)
{
- fprintf(stderr,"Error in packet header\n");
- exit(1);
+ my_fprintf("Error in packet header\n");
+ my_exit(1);
}
/* skip STD_buffer_scale */
ld->Rdptr++;
{
if(code>=0x40)
{
- fprintf(stderr,"Error in packet header\n");
- exit(1);
+ my_fprintf("Error in packet header\n");
+ my_exit(1);
}
/* skip presentation and decoding time stamps */
ld->Rdptr += 9;
}
else if(code!=0x0f)
{
- fprintf(stderr,"Error in packet header\n");
- exit(1);
+ my_fprintf("Error in packet header\n");
+ my_exit(1);
}
return;
case ISO_END_CODE: /* end */
}
else
{
- fprintf(stderr,"Unexpected startcode %08x in system layer\n",code);
- exit(1);
+ my_fprintf("Unexpected startcode %08x in system layer\n",code);
+ my_exit(1);
}
break;
}