]> Creatis software - gdcm.git/blobdiff - src/gdcmmpeg2/src/mpeg2dec/subspic.c
> // Don't waste time checking tags where VM is OB and OW, since we know
[gdcm.git] / src / gdcmmpeg2 / src / mpeg2dec / subspic.c
index 702b9beb94c2b624121ea847ebcf6c8f563f75fc..a8dde34771e700e07054df4ce55118a01bc5220c 100644 (file)
  *
  */
 
-//#include <fcntl.h>
-
 #include "config.h"
 #include "global.h"
 
 /* private prototypes*/
-static void Read_Frame _ANSI_ARGS_((char *filename, 
+static void Read_Frame _ANSI_ARGS_((const char *filename, 
   unsigned char *frame_buffer[], int framenum));
 static void Copy_Frame _ANSI_ARGS_((unsigned char *src, unsigned char *dst, 
   int width, int height, int parity, int incr));
-static int Read_Components _ANSI_ARGS_ ((char *filename, 
+static int Read_Components _ANSI_ARGS_ ((const char *filename, 
   unsigned char *frame[3], int framenum));
 static int Read_Component _ANSI_ARGS_ ((char *fname, unsigned char *frame, 
   int width, int height));
-static int Extract_Components _ANSI_ARGS_ ((char *filename,
+static int Extract_Components _ANSI_ARGS_ ((const char *filename,
   unsigned char *frame[3], int framenum));
 
 
@@ -150,7 +148,7 @@ int sequence_framenum;
 /* Note: fields are only read to serve as the same-frame reference for 
    a second field */
 static void Read_Frame(fname,frame,framenum)
-char *fname;
+const char *fname;
 unsigned char *frame[];
 int framenum;
 {
@@ -210,7 +208,7 @@ int framenum;
 
 
 static int Read_Components(filename, frame, framenum) 
-char *filename;
+const char *filename;
 unsigned char *frame[3];
 int framenum;
 {
@@ -243,7 +241,7 @@ int Height;
 {
   int Size;
   int Bytes_Read;
-  int Infile;
+  istream Infile;
 
   Size = Width*Height;
 
@@ -251,14 +249,14 @@ int Height;
   my_printf("SUBS: reading %s\n", filename);
 #endif
 
-  if(!(Infile=my_open(Filename))<0)
+  if(!my_fopenr(Filename, "rb", &Infile))
   {
     my_printf("ERROR: unable to open reference filename (%s)\n", Filename);
     return(-1);
   }
 
   /*abort();*/
-  Bytes_Read = read(Infile, Frame, Size);
+  Bytes_Read = my_fread(Frame, Size, 1, &Infile);
   
   if(Bytes_Read!=Size)
   {
@@ -266,7 +264,7 @@ int Height;
       Bytes_Read, Size, Filename);
   }
  
-  close(Infile); 
+  my_fcloser(&Infile); 
   return(0);
 }
 
@@ -278,19 +276,18 @@ int Height;
    MPEG Committee's syntax validation and conformance ad-hoc groups from 
    the year 1993 until 1995 */
 static int Extract_Components(filename, frame, framenum) 
-char *filename;
+const char *filename;
 unsigned char *frame[3];
 int framenum;
 {
 /*  int err = 0; */
-  //FILE *fd;
-  ostream *fd;
+  istream fd;
   int line;
   int size, offset;
   /*abort();*/
 
 
-  if (!(fd = my_fopen(filename,"rb")))
+  if (!my_fopenr(filename,"rb", &fd))
   {
     my_sprintf(Error_Text,"Couldn't open %s\n",filename);
     return(-1);
@@ -320,28 +317,28 @@ int framenum;
   /* 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 */
-  my_fseek(fd, offset, SEEK_SET);
+  my_fseekr(&fd, offset, SEEK_SET);
 
   /* Y  */
   for (line=0; line<Coded_Picture_Height; line++)
   {
-    my_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++)
   {
-    my_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++)
   {
-    my_fread(frame[2]+(line*Chroma_Width),1,Chroma_Width,fd);
+    my_fread(frame[2]+(line*Chroma_Width),1,Chroma_Width,&fd);
   }
 
 
-  my_fclose(fd);
+  my_fcloser(&fd);
   return(0);
 }