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