]> Creatis software - gdcm.git/blob - src/gdcmmpeg2/src/mpeg2dec/mpeg2dec.c
5211f3f702f3ae1718f9397954cd235084ee3aa2
[gdcm.git] / src / gdcmmpeg2 / src / mpeg2dec / mpeg2dec.c
1
2 /* mpeg2dec.c, main(), initialization, option processing                    */
3
4 /* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */
5
6 /*
7  * Disclaimer of Warranty
8  *
9  * These software programs are available to the user without any license fee or
10  * royalty on an "as is" basis.  The MPEG Software Simulation Group disclaims
11  * any and all warranties, whether express, implied, or statuary, including any
12  * implied warranties or merchantability or of fitness for a particular
13  * purpose.  In no event shall the copyright-holder be liable for any
14  * incidental, punitive, or consequential damages of any kind whatsoever
15  * arising from the use of these programs.
16  *
17  * This disclaimer of warranty extends to the user of these programs and user's
18  * customers, employees, agents, transferees, successors, and assigns.
19  *
20  * The MPEG Software Simulation Group does not represent or warrant that the
21  * programs furnished hereunder are free of infringement of any third-party
22  * patents.
23  *
24  * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware,
25  * are subject to royalty fees to patent holders.  Many of these patents are
26  * general enough such that they are unavoidable regardless of implementation
27  * design.
28  *
29  */
30
31 #include <stdlib.h>
32 #include <ctype.h>
33 #include <fcntl.h>
34
35 #define GLOBAL
36 #include "config.h"
37 #include "global.h"
38
39 /* private prototypes */
40 static int  video_sequence _ANSI_ARGS_((int *framenum));
41 static int  Decode_Bitstream _ANSI_ARGS_((void));
42 static int  Headers _ANSI_ARGS_((void));
43 static void Initialize_Sequence _ANSI_ARGS_((void));
44 static void Initialize_Decoder _ANSI_ARGS_((void));
45 static void DeInitialize_Decoder _ANSI_ARGS_((void));
46 static void Deinitialize_Sequence _ANSI_ARGS_((void));
47 static void Process_Options _ANSI_ARGS_((int argc, char *argv[]));
48
49
50 #if OLD
51 static int  Get_Val _ANSI_ARGS_((char *argv[]));
52 #endif
53
54 /* #define DEBUG */
55
56 static void Clear_Options();
57 #ifdef DEBUG
58 static void Print_Options();
59 #endif
60
61
62 int my_open(char *filename)
63 {
64   return open(filename,O_RDONLY|O_BINARY);
65 }
66
67 off_t my_seek(int infile, off_t offset,int whence)
68 {
69   return lseek(infile, offset, whence);
70 }
71 ssize_t my_read(int infile,void *buf,size_t count)
72 {
73   return read(infile,buf,count);
74 }
75 int my_close(int infile)
76 {
77   return close(infile);
78 }
79
80 int my_fopenr(const char *path, const char *mode, istream *os)
81 {
82   FILE *fd = fopen(path, mode);
83   if(fd)
84     {
85     os->InFd = fd;
86     return 1; /*success*/
87     }
88   else
89     os->InFd = NULL;
90   return 0;
91 }
92
93 int my_fopen(const char *path, const char *mode, ostream *os)
94 {
95   FILE *fd = fopen(path, mode);
96   if(fd)
97     {
98     os->OutFd = fd;
99     return 1; /*success*/
100     }
101   else
102     os->OutFd = NULL;
103   return 0;
104 }
105
106 int my_fseek(ostream *stream, long offset, int whence)
107 {
108   return fseek(stream->OutFd, offset, whence);
109 }
110 int my_fseekr(istream *stream, long offset, int whence)
111 {
112   return fseek(stream->InFd, offset, whence);
113 }
114
115 size_t my_fread(void *ptr, size_t size, size_t nmemb, istream *stream)
116 {
117   return fread(ptr, size, nmemb, stream->InFd);
118 }
119
120 size_t my_fwrite(const void *ptr, size_t size, size_t nmemb, ostream *stream)
121 {
122   return fwrite(ptr, size, nmemb, stream->OutFd);
123 }
124
125 int my_fcloser(istream *fp)
126 {
127   return fclose(fp->InFd);
128 }
129 int my_fclose(ostream *fp)
130 {
131   return fclose(fp->OutFd);
132 }
133 #include <stdarg.h>
134
135 int my_printf(const char *format, ...)
136 {
137   va_list argptr;
138   int ret;
139
140   va_start(argptr, format);
141   ret = vprintf(format, argptr);
142   va_end(argptr);
143
144   return ret;
145 }
146
147 int my_sprintf(char *str, const char *format, ...)
148 {
149   va_list argptr;
150   int ret;
151
152   va_start(argptr, format);
153   ret = vsprintf(str,format, argptr);
154   va_end(argptr);
155
156   return ret;
157 }
158
159 int my_fprintf(const char *format, ...)
160 {
161   va_list argptr;
162   int ret;
163
164   va_start(argptr, format);
165   ret = vfprintf(stderr,format, argptr);
166   va_end(argptr);
167
168   return ret;
169 }
170 void my_exit(int status)
171 {
172   exit(status);
173 }
174
175
176 #define GDCM_BUILD_MPEG2DEC
177
178 #ifdef GDCM_BUILD_MPEG2DEC
179 int main(argc,argv)
180 int argc;
181 char *argv[];
182 {
183   int ret, code;
184   base.open_stream = my_open;
185   base.seek_stream = my_seek;
186   base.read_stream = my_read;
187   base.close_stream = my_close;
188
189   Clear_Options();
190
191   /* decode command line arguments */
192   Process_Options(argc,argv);
193
194 #ifdef DEBUG
195   Print_Options();
196 #endif
197
198   ld = &base; /* select base layer context */
199
200   /* open MPEG base layer bitstream file(s) */
201   /* NOTE: this is either a base layer stream or a spatial enhancement stream */
202 /*  if ((base.Infile=open(Main_Bitstream_Filename,O_RDONLY|O_BINARY))<0) */
203   base.Infile = ld->open_stream(Main_Bitstream_Filename);
204   if( base.Infile < 0 )
205   {
206     fprintf(stderr,"Base layer input file %s not found\n", Main_Bitstream_Filename);
207     exit(1);
208   }
209
210
211   if(base.Infile != 0)
212   {
213     Initialize_Buffer(); 
214   
215     if(Show_Bits(8)==0x47)
216     {
217       sprintf(Error_Text,"Decoder currently does not parse transport streams\n");
218       Error(Error_Text);
219     }
220
221     next_start_code();
222     code = Show_Bits(32);
223
224     switch(code)
225     {
226     case SEQUENCE_HEADER_CODE:
227       break;
228     case PACK_START_CODE:
229       System_Stream_Flag = 1;
230     case VIDEO_ELEMENTARY_STREAM:
231       System_Stream_Flag = 1;
232       break;
233     default:
234       sprintf(Error_Text,"Unable to recognize stream type\n");
235       Error(Error_Text);
236       break;
237     }
238
239     /*lseek(base.Infile, 0l, SEEK_SET);*/
240     ld->seek_stream(base.Infile,0l,SEEK_SET);
241     Initialize_Buffer(); 
242   }
243
244   if(base.Infile!=0)
245   {
246     /*lseek(base.Infile, 0l, SEEK_SET);*/
247     ld->seek_stream(base.Infile,0l,SEEK_SET);
248   }
249
250   Initialize_Buffer(); 
251
252   if(Two_Streams)
253   {
254     ld = &enhan; /* select enhancement layer context */
255
256     /*if ((enhan.Infile = open(Enhancement_Layer_Bitstream_Filename,O_RDONLY|O_BINARY))<0)*/
257     enhan.Infile = ld->open_stream(Enhancement_Layer_Bitstream_Filename);
258     if (enhan.Infile<0)
259     {
260       sprintf(Error_Text,"enhancment layer bitstream file %s not found\n",
261         Enhancement_Layer_Bitstream_Filename);
262
263       Error(Error_Text);
264     }
265
266     Initialize_Buffer();
267     ld = &base;
268   }
269
270   Initialize_Decoder();
271
272   ret = Decode_Bitstream();
273
274   /*close(base.Infile);*/
275   ld->close_stream(base.Infile);
276
277   if (Two_Streams)
278     /*close(enhan.Infile);*/
279     ld->close_stream(enhan.Infile);
280
281   DeInitialize_Decoder();
282
283   return ret;
284 }
285 #endif /*GDCM_BUILD_MPEG2DEC*/
286
287 /* IMPLEMENTATION specific routines */
288 static void Initialize_Decoder()
289 {
290   int i;
291
292   /* Clip table */
293   if (!(Clip=(unsigned char *)malloc(1024)))
294     Error("Clip[] malloc failed\n");
295
296   Clip += 384;
297
298   for (i=-384; i<640; i++)
299     Clip[i] = (i<0) ? 0 : ((i>255) ? 255 : i);
300
301   /* IDCT */
302   if (Reference_IDCT_Flag)
303     Initialize_Reference_IDCT();
304   else
305     Initialize_Fast_IDCT();
306
307 }
308
309 static void DeInitialize_Decoder()
310 {
311   free(Clip-384); /* I love magic number */
312 }
313
314 /* mostly IMPLEMENTAION specific routines */
315 static void Initialize_Sequence()
316 {
317   int cc, size;
318   static int Table_6_20[3] = {6,8,12};
319
320   /* check scalability mode of enhancement layer */
321   if (Two_Streams && (enhan.scalable_mode!=SC_SNR) && (base.scalable_mode!=SC_DP))
322     Error("unsupported scalability mode\n");
323
324   /* force MPEG-1 parameters for proper decoder behavior */
325   /* see ISO/IEC 13818-2 section D.9.14 */
326   if (!base.MPEG2_Flag)
327   {
328     progressive_sequence = 1;
329     progressive_frame = 1;
330     picture_structure = FRAME_PICTURE;
331     frame_pred_frame_dct = 1;
332     chroma_format = CHROMA420;
333     matrix_coefficients = 5;
334   }
335
336   /* round to nearest multiple of coded macroblocks */
337   /* ISO/IEC 13818-2 section 6.3.3 sequence_header() */
338   mb_width = (horizontal_size+15)/16;
339   mb_height = (base.MPEG2_Flag && !progressive_sequence) ? 2*((vertical_size+31)/32)
340                                         : (vertical_size+15)/16;
341
342   Coded_Picture_Width = 16*mb_width;
343   Coded_Picture_Height = 16*mb_height;
344
345   /* ISO/IEC 13818-2 sections 6.1.1.8, 6.1.1.9, and 6.1.1.10 */
346   Chroma_Width = (chroma_format==CHROMA444) ? Coded_Picture_Width
347                                            : Coded_Picture_Width>>1;
348   Chroma_Height = (chroma_format!=CHROMA420) ? Coded_Picture_Height
349                                             : Coded_Picture_Height>>1;
350   
351   /* derived based on Table 6-20 in ISO/IEC 13818-2 section 6.3.17 */
352   block_count = Table_6_20[chroma_format-1];
353
354   for (cc=0; cc<3; cc++)
355   {
356     if (cc==0)
357       size = Coded_Picture_Width*Coded_Picture_Height;
358     else
359       size = Chroma_Width*Chroma_Height;
360
361     if (!(backward_reference_frame[cc] = (unsigned char *)malloc(size)))
362       Error("backward_reference_frame[] malloc failed\n");
363
364     if (!(forward_reference_frame[cc] = (unsigned char *)malloc(size)))
365       Error("forward_reference_frame[] malloc failed\n");
366
367     if (!(auxframe[cc] = (unsigned char *)malloc(size)))
368       Error("auxframe[] malloc failed\n");
369
370     if(Ersatz_Flag)
371       if (!(substitute_frame[cc] = (unsigned char *)malloc(size)))
372         Error("substitute_frame[] malloc failed\n");
373
374
375     if (base.scalable_mode==SC_SPAT)
376     {
377       /* this assumes lower layer is 4:2:0 */
378       if (!(llframe0[cc] = (unsigned char *)malloc((lower_layer_prediction_horizontal_size*lower_layer_prediction_vertical_size)/(cc?4:1))))
379         Error("llframe0 malloc failed\n");
380       if (!(llframe1[cc] = (unsigned char *)malloc((lower_layer_prediction_horizontal_size*lower_layer_prediction_vertical_size)/(cc?4:1))))
381         Error("llframe1 malloc failed\n");
382     }
383   }
384
385   /* SCALABILITY: Spatial */
386   if (base.scalable_mode==SC_SPAT)
387   {
388     if (!(lltmp = (short *)malloc(lower_layer_prediction_horizontal_size*((lower_layer_prediction_vertical_size*vertical_subsampling_factor_n)/vertical_subsampling_factor_m)*sizeof(short))))
389       Error("lltmp malloc failed\n");
390   }
391
392 #ifdef DISPLAY
393   if (Output_Type==T_X11)
394   {
395     Initialize_Display_Process("");
396     Initialize_Dither_Matrix();
397   }
398 #endif /* DISPLAY */
399
400 }
401
402 void Error(text)
403 char *text;
404 {
405   fprintf(stderr,text);
406   exit(1);
407 }
408
409 /* Trace_Flag output */
410 void Print_Bits(code,bits,len)
411 int code,bits,len;
412 {
413   int i;
414   for (i=0; i<len; i++)
415     printf("%d",(code>>(bits-1-i))&1);
416 }
417
418
419
420 /* option processing */
421 static void Process_Options(argc,argv)
422 int argc;                  /* argument count  */
423 char *argv[];              /* argument vector */
424 {
425   int i, LastArg, NextArg;
426
427   /* at least one argument should be present */
428   if (argc<2)
429   {
430     printf("\n%s, %s\n",Version,Author);
431     printf("Usage:  mpeg2decode {options}\n"
432 "Options: -b  file  main bitstream (base or spatial enhancement layer)\n"
433 "         -cn file  conformance report (n: level)\n"
434 "         -e  file  enhancement layer bitstream (SNR or Data Partitioning)\n"
435 "         -f        store/display interlaced video in frame format\n"
436 "         -g        concatenated file format for substitution method (-x)\n"
437 "         -in file  information & statistics report  (n: level)\n"
438 "         -l  file  file name pattern for lower layer sequence\n");
439 printf("                   (for spatial scalability)\n"
440 "         -on file  output format (0:YUV 1:SIF 2:TGA 3:PPM 4:X11 5:X11HiQ)\n"
441 "         -q        disable warnings to stderr\n"
442 "         -r        use double precision reference IDCT\n"
443 "         -t        enable low level tracing to stdout\n"
444 "         -u  file  print user_data to stdio or file\n"
445 "         -vn       verbose output (n: level)\n"
446 "         -x  file  filename pattern of picture substitution sequence\n\n");
447 printf("File patterns:  for sequential filenames, \"printf\" style, e.g. rec%%d\n"
448 "                 or rec%%d%%c for fieldwise storage\n"
449 "Levels:        0:none 1:sequence 2:picture 3:slice 4:macroblock 5:block\n\n"
450 "Example:       mpeg2decode -b bitstream.mpg -f -r -o0 rec%%d\n"
451 "         \n");
452     exit(0);
453   }
454
455
456   Output_Type = -1;
457   i = 1;
458
459   /* command-line options are proceeded by '-' */
460
461   while(i < argc)
462   {
463     /* check if this is the last argument */
464     LastArg = ((argc-i)==1);
465
466     /* parse ahead to see if another flag immediately follows current
467        argument (this is used to tell if a filename is missing) */
468     if(!LastArg)
469       NextArg = (argv[i+1][0]=='-');
470     else
471       NextArg = 0;
472
473     /* second character, [1], after '-' is the switch */
474     if(argv[i][0]=='-')
475     {
476       switch(toupper(argv[i][1]))
477       {
478         /* third character. [2], is the value */
479       case 'B':
480         Main_Bitstream_Flag = 1;
481
482         if(NextArg || LastArg)
483         {
484           printf("ERROR: -b must be followed the main bitstream filename\n");
485         }
486         else
487           Main_Bitstream_Filename = argv[++i]; 
488
489         break;
490
491
492       case 'C':
493
494 #ifdef VERIFY
495         Verify_Flag = atoi(&argv[i][2]); 
496
497         if((Verify_Flag < NO_LAYER) || (Verify_Flag > ALL_LAYERS))
498         {
499           printf("ERROR: -c level (%d) out of range [%d,%d]\n",
500             Verify_Flag, NO_LAYER, ALL_LAYERS);
501           exit(ERROR);
502         }
503 #else  /* VERIFY */
504         printf("This program not compiled for Verify_Flag option\n");
505 #endif /* VERIFY */
506         break;
507
508       case 'E':
509         Two_Streams = 1; /* either Data Partitioning (DP) or SNR Scalability enhancment */
510                    
511         if(NextArg || LastArg)
512         {
513           printf("ERROR: -e must be followed by filename\n");
514           exit(ERROR);
515         }
516         else
517           Enhancement_Layer_Bitstream_Filename = argv[++i]; 
518
519         break;
520
521
522       case 'F':
523         Frame_Store_Flag = 1;
524         break;
525
526       case 'G':
527         Big_Picture_Flag = 1;
528         break;
529
530
531       case 'I':
532 #ifdef VERIFY
533         Stats_Flag = atoi(&argv[i][2]); 
534 #else /* VERIFY */
535         printf("WARNING: This program not compiled for -i option\n");
536 #endif /* VERIFY */     
537         break;
538     
539       case 'L':  /* spatial scalability flag */
540         Spatial_Flag = 1;
541
542        if(NextArg || LastArg)
543        {
544          printf("ERROR: -l must be followed by filename\n");
545          exit(ERROR);
546        }
547        else
548          Lower_Layer_Picture_Filename = argv[++i]; 
549
550         break;
551
552       case 'O':
553   
554         Output_Type = atoi(&argv[i][2]); 
555   
556         if((Output_Type==4) || (Output_Type==5))
557           Output_Picture_Filename = "";  /* no need of filename */
558         else if(NextArg || LastArg)  
559         {
560           printf("ERROR: -o must be followed by filename\n");
561           exit(ERROR);
562         }
563         else
564         /* filename is separated by space, so it becomes the next argument */
565           Output_Picture_Filename = argv[++i]; 
566
567 #ifdef DISPLAY
568         if (Output_Type==T_X11HIQ)
569         {
570           hiQdither = 1;
571           Output_Type=T_X11;
572         }
573 #endif /* DISPLAY */
574         break;
575
576       case 'Q':
577         Quiet_Flag = 1;
578         break;
579
580       case 'R':
581         Reference_IDCT_Flag = 1;
582         break;
583     
584       case 'T':
585 #ifdef TRACE
586         Trace_Flag = 1;
587 #else /* TRACE */
588         printf("WARNING: This program not compiled for -t option\n");
589 #endif /* TRACE */
590         break;
591
592       case 'U':
593         User_Data_Flag = 1;
594
595       case 'V':
596 #ifdef VERBOSE
597         Verbose_Flag = atoi(&argv[i][2]); 
598 #else /* VERBOSE */
599         printf("This program not compiled for -v option\n");
600 #endif /* VERBOSE */
601         break;
602
603
604       case 'X':
605         Ersatz_Flag = 1;
606
607        if(NextArg || LastArg)
608        {
609          printf("ERROR: -x must be followed by filename\n"); 
610          exit(ERROR);
611        }
612        else
613         Substitute_Picture_Filename = argv[++i]; 
614
615         break;
616
617
618
619       default:
620         fprintf(stderr,"undefined option -%c ignored. Exiting program\n", 
621           argv[i][1]);
622
623         exit(ERROR);
624     
625       } /* switch() */
626     } /* if argv[i][0] == '-' */
627     
628     i++;
629
630     /* check for bitstream filename argument (there must always be one, at the very end
631      of the command line arguments */
632
633   } /* while() */
634
635
636   /* options sense checking */
637
638   if(Main_Bitstream_Flag!=1)
639   {
640     printf("There must be a main bitstream specified (-b filename)\n");
641   }
642
643   /* force display process to show frame pictures */
644   if((Output_Type==4 || Output_Type==5) && Frame_Store_Flag)
645     Display_Progressive_Flag = 1;
646   else
647     Display_Progressive_Flag = 0;
648
649 #ifdef VERIFY
650   /* parse the bitstream, do not actually decode it completely */
651   
652
653 #if 0
654   if(Output_Type==-1)
655   {
656     Decode_Layer = Verify_Flag;
657     printf("FYI: Decoding bitstream elements up to: %s\n", 
658       Layer_Table[Decode_Layer]);
659   }
660   else
661 #endif
662     Decode_Layer = ALL_LAYERS;
663
664 #endif /* VERIFY */
665
666   /* no output type specified */
667   if(Output_Type==-1)
668   {
669     Output_Type = 9; 
670     Output_Picture_Filename = "";
671   }
672
673
674 #ifdef DISPLAY
675   if (Output_Type==T_X11)
676   {
677     if(Frame_Store_Flag)
678       Display_Progressive_Flag = 1;
679     else
680       Display_Progressive_Flag = 0;
681
682     Frame_Store_Flag = 1; /* to avoid calling dither() twice */
683   }
684 #endif
685
686
687 }
688
689
690 #ifdef OLD
691 /* 
692    this is an old routine used to convert command line arguments
693    into integers 
694 */
695 static int Get_Val(argv)
696 char *argv[];
697 {
698   int val;
699
700   if (sscanf(argv[1]+2,"%d",&val)!=1)
701     return 0;
702
703   while (isdigit(argv[1][2]))
704     argv[1]++;
705
706   return val;
707 }
708 #endif
709
710
711
712 static int Headers()
713 {
714   int ret;
715
716   ld = &base;
717   
718
719   /* return when end of sequence (0) or picture
720      header has been parsed (1) */
721
722   ret = Get_Hdr();
723
724
725   if (Two_Streams)
726   {
727     ld = &enhan;
728     if (Get_Hdr()!=ret && !Quiet_Flag)
729       fprintf(stderr,"streams out of sync\n");
730     ld = &base;
731   }
732
733   return ret;
734 }
735
736
737
738 static int Decode_Bitstream()
739 {
740   int ret;
741   int Bitstream_Framenum;
742
743   Bitstream_Framenum = 0;
744
745   for(;;)
746   {
747
748 #ifdef VERIFY
749     Clear_Verify_Headers();
750 #endif /* VERIFY */
751
752     ret = Headers();
753     
754     if(ret==1)
755     {
756       ret = video_sequence(&Bitstream_Framenum);
757     }
758     else
759       return(ret);
760   }
761
762 }
763
764
765 static void Deinitialize_Sequence()
766 {
767   int i;
768
769   /* First cleanup the static buffer in store.c */
770   FreeStaticBuffer();
771
772   /* clear flags */
773   base.MPEG2_Flag=0;
774
775   for(i=0;i<3;i++)
776   {
777     free(backward_reference_frame[i]);
778     free(forward_reference_frame[i]);
779     free(auxframe[i]);
780
781     if (base.scalable_mode==SC_SPAT)
782     {
783      free(llframe0[i]);
784      free(llframe1[i]);
785     }
786   }
787
788   if (base.scalable_mode==SC_SPAT)
789     free(lltmp);
790
791 #ifdef DISPLAY
792   if (Output_Type==T_X11) 
793     Terminate_Display_Process();
794 #endif
795 }
796
797
798 static int video_sequence(Bitstream_Framenumber)
799 int *Bitstream_Framenumber;
800 {
801   int Bitstream_Framenum;
802   int Sequence_Framenum;
803   int Return_Value;
804
805   Bitstream_Framenum = *Bitstream_Framenumber;
806   Sequence_Framenum=0;
807
808   Initialize_Sequence();
809
810   /* decode picture whose header has already been parsed in 
811      Decode_Bitstream() */
812
813
814   Decode_Picture(Bitstream_Framenum, Sequence_Framenum);
815
816   /* update picture numbers */
817   if (!Second_Field)
818   {
819     Bitstream_Framenum++;
820     Sequence_Framenum++;
821   }
822
823   /* loop through the rest of the pictures in the sequence */
824   while ((Return_Value=Headers()))
825   {
826     Decode_Picture(Bitstream_Framenum, Sequence_Framenum);
827
828     if (!Second_Field)
829     {
830       Bitstream_Framenum++;
831       Sequence_Framenum++;
832     }
833   }
834
835   /* put last frame */
836   if (Sequence_Framenum!=0)
837   {
838     Output_Last_Frame_of_Sequence(Bitstream_Framenum);
839   }
840
841   Deinitialize_Sequence();
842
843 #ifdef VERIFY
844     Clear_Verify_Headers();
845 #endif /* VERIFY */
846
847   *Bitstream_Framenumber = Bitstream_Framenum;
848   return(Return_Value);
849 }
850
851
852
853 static void Clear_Options()
854 {
855   Verbose_Flag = 0;
856   Output_Type = 0;
857   Output_Picture_Filename = " ";
858   hiQdither  = 0;
859   Output_Type = 0;
860   Frame_Store_Flag = 0;
861   Spatial_Flag = 0;
862   Lower_Layer_Picture_Filename = " ";
863   Reference_IDCT_Flag = 0;
864   Trace_Flag = 0;
865   Quiet_Flag = 0;
866   Ersatz_Flag = 0;
867   Substitute_Picture_Filename  = " ";
868   Two_Streams = 0;
869   Enhancement_Layer_Bitstream_Filename = " ";
870   Big_Picture_Flag = 0;
871   Main_Bitstream_Flag = 0;
872   Main_Bitstream_Filename = " ";
873   Verify_Flag = 0;
874   Stats_Flag  = 0;
875   User_Data_Flag = 0; 
876 }
877
878
879 #ifdef DEBUG
880 static void Print_Options()
881 {
882   
883   printf("Verbose_Flag                         = %d\n", Verbose_Flag);
884   printf("Output_Type                          = %d\n", Output_Type);
885   printf("Output_Picture_Filename              = %s\n", Output_Picture_Filename);
886   printf("hiQdither                            = %d\n", hiQdither);
887   printf("Output_Type                          = %d\n", Output_Type);
888   printf("Frame_Store_Flag                     = %d\n", Frame_Store_Flag);
889   printf("Spatial_Flag                         = %d\n", Spatial_Flag);
890   printf("Lower_Layer_Picture_Filename         = %s\n", Lower_Layer_Picture_Filename);
891   printf("Reference_IDCT_Flag                  = %d\n", Reference_IDCT_Flag);
892   printf("Trace_Flag                           = %d\n", Trace_Flag);
893   printf("Quiet_Flag                           = %d\n", Quiet_Flag);
894   printf("Ersatz_Flag                          = %d\n", Ersatz_Flag);
895   printf("Substitute_Picture_Filename          = %s\n", Substitute_Picture_Filename);
896   printf("Two_Streams                          = %d\n", Two_Streams);
897   printf("Enhancement_Layer_Bitstream_Filename = %s\n", Enhancement_Layer_Bitstream_Filename);
898   printf("Big_Picture_Flag                     = %d\n", Big_Picture_Flag);
899   printf("Main_Bitstream_Flag                  = %d\n", Main_Bitstream_Flag);
900   printf("Main_Bitstream_Filename              = %s\n", Main_Bitstream_Filename);
901   printf("Verify_Flag                          = %d\n", Verify_Flag);
902   printf("Stats_Flag                           = %d\n", Stats_Flag);
903   printf("User_Data_Flag                       = %d\n", User_Data_Flag);
904
905 }
906 #endif
907