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