#include <stdlib.h>
#include <ctype.h>
#include <fcntl.h>
-#include <unistd.h> // for lseek
#define GLOBAL
#include "config.h"
/* private prototypes */
static int video_sequence _ANSI_ARGS_((int *framenum));
-static int Decode_Bitstream _ANSI_ARGS_((void));
+static int Decode_Bitstream _ANSI_ARGS_((void));
static int Headers _ANSI_ARGS_((void));
static void Initialize_Sequence _ANSI_ARGS_((void));
static void Initialize_Decoder _ANSI_ARGS_((void));
static void Print_Options();
#endif
+int my_open(char *filename)
+{
+ return open(filename,O_RDONLY|O_BINARY);
+}
+off_t my_seek(int infile, off_t offset,int whence)
+{
+ return lseek(infile, offset, whence);
+}
+ssize_t my_read(int infile,void *buf,size_t count)
+{
+ return read(infile,buf,count);
+}
+int my_close(int infile)
+{
+ return close(infile);
+}
+
+
+
+#ifdef GDCM_BUILD_MPEG2DEC
int main(argc,argv)
int argc;
char *argv[];
{
int ret, code;
+ base.open_stream = my_open;
+ base.seek_stream = my_seek;
+ base.read_stream = my_read;
+ base.close_stream = my_close;
Clear_Options();
/* open MPEG base layer bitstream file(s) */
/* NOTE: this is either a base layer stream or a spatial enhancement stream */
- if ((base.Infile=open(Main_Bitstream_Filename,O_RDONLY|O_BINARY))<0)
+/* if ((base.Infile=open(Main_Bitstream_Filename,O_RDONLY|O_BINARY))<0) */
+ base.Infile = ld->open_stream(Main_Bitstream_Filename);
+ if( base.Infile < 0 )
{
fprintf(stderr,"Base layer input file %s not found\n", Main_Bitstream_Filename);
exit(1);
break;
}
- lseek(base.Infile, 0l, 0);
+ /*lseek(base.Infile, 0l, SEEK_SET);*/
+ ld->seek_stream(base.Infile,0l,SEEK_SET);
Initialize_Buffer();
}
if(base.Infile!=0)
{
- lseek(base.Infile, 0l, 0);
+ /*lseek(base.Infile, 0l, SEEK_SET);*/
+ ld->seek_stream(base.Infile,0l,SEEK_SET);
}
Initialize_Buffer();
{
ld = &enhan; /* select enhancement layer context */
- if ((enhan.Infile = open(Enhancement_Layer_Bitstream_Filename,O_RDONLY|O_BINARY))<0)
+ /*if ((enhan.Infile = open(Enhancement_Layer_Bitstream_Filename,O_RDONLY|O_BINARY))<0)*/
+ enhan.Infile = ld->open_stream(Enhancement_Layer_Bitstream_Filename);
+ if (enhan.Infile<0)
{
sprintf(Error_Text,"enhancment layer bitstream file %s not found\n",
Enhancement_Layer_Bitstream_Filename);
ret = Decode_Bitstream();
- close(base.Infile);
+ /*close(base.Infile);*/
+ ld->close_stream(base.Infile);
if (Two_Streams)
- close(enhan.Infile);
+ /*close(enhan.Infile);*/
+ ld->close_stream(enhan.Infile);
- return 0;
+ return ret;
}
+#endif /*GDCM_BUILD_MPEG2DEC*/
-/* IMPLEMENTAION specific rouintes */
+/* IMPLEMENTATION specific routines */
static void Initialize_Decoder()
{
int i;
if (argc<2)
{
printf("\n%s, %s\n",Version,Author);
- printf("Usage: mpeg2decode {options}\n\
-Options: -b file main bitstream (base or spatial enhancement layer)\n\
- -cn file conformance report (n: level)\n\
- -e file enhancement layer bitstream (SNR or Data Partitioning)\n\
- -f store/display interlaced video in frame format\n\
- -g concatenated file format for substitution method (-x)\n\
- -in file information & statistics report (n: level)\n\
- -l file file name pattern for lower layer sequence\n\
- (for spatial scalability)\n\
- -on file output format (0:YUV 1:SIF 2:TGA 3:PPM 4:X11 5:X11HiQ)\n\
- -q disable warnings to stderr\n\
- -r use double precision reference IDCT\n\
- -t enable low level tracing to stdout\n\
- -u file print user_data to stdio or file\n\
- -vn verbose output (n: level)\n\
- -x file filename pattern of picture substitution sequence\n\n\
-File patterns: for sequential filenames, \"printf\" style, e.g. rec%%d\n\
- or rec%%d%%c for fieldwise storage\n\
-Levels: 0:none 1:sequence 2:picture 3:slice 4:macroblock 5:block\n\n\
-Example: mpeg2decode -b bitstream.mpg -f -r -o0 rec%%d\n\
- \n");
+ printf("Usage: mpeg2decode {options}\n"
+"Options: -b file main bitstream (base or spatial enhancement layer)\n"
+" -cn file conformance report (n: level)\n"
+" -e file enhancement layer bitstream (SNR or Data Partitioning)\n"
+" -f store/display interlaced video in frame format\n"
+" -g concatenated file format for substitution method (-x)\n"
+" -in file information & statistics report (n: level)\n"
+" -l file file name pattern for lower layer sequence\n"
+" (for spatial scalability)\n"
+" -on file output format (0:YUV 1:SIF 2:TGA 3:PPM 4:X11 5:X11HiQ)\n"
+" -q disable warnings to stderr\n"
+" -r use double precision reference IDCT\n"
+" -t enable low level tracing to stdout\n"
+" -u file print user_data to stdio or file\n"
+" -vn verbose output (n: level)\n"
+" -x file filename pattern of picture substitution sequence\n\n"
+"File patterns: for sequential filenames, \"printf\" style, e.g. rec%%d\n"
+" or rec%%d%%c for fieldwise storage\n"
+"Levels: 0:none 1:sequence 2:picture 3:slice 4:macroblock 5:block\n\n"
+"Example: mpeg2decode -b bitstream.mpg -f -r -o0 rec%%d\n"
+" \n");
exit(0);
}
}
#endif
+