~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Open Mash Cross Reference
mash/codec/tmndec/gethdr.c

Component: ~ [ mash ] ~ [ apps ] ~ [ gsm ] ~ [ lib ] ~ [ otcl ] ~ [ srm ] ~ [ tcl8.3 ] ~ [ tclcl ] ~ [ tk8.3 ] ~ [ tutorials ] ~

  1 /************************************************************************
  2  *
  3  *  gethdr.c, header decoding for tmndecode (H.263 decoder)
  4  *  Copyright (C) 1995, 1996  Telenor R&D, Norway
  5  *
  6  *  Contacts:
  7  *  Robert Danielsen                  <Robert.Danielsen@nta.no>
  8  *
  9  *  Telenor Research and Development  http://www.nta.no/brukere/DVC/
 10  *  P.O.Box 83                        tel.:   +47 63 84 84 00
 11  *  N-2007 Kjeller, Norway            fax.:   +47 63 81 00 76
 12  *
 13  *  Copyright (C) 1997  University of BC, Canada
 14  *  Modified by: Michael Gallant <mikeg@ee.ubc.ca>
 15  *               Guy Cote <guyc@ee.ubc.ca>
 16  *               Berna Erol <bernae@ee.ubc.ca>
 17  *
 18  *  Contacts:
 19  *  Michael Gallant                   <mikeg@ee.ubc.ca>
 20  *
 21  *  UBC Image Processing Laboratory   http://www.ee.ubc.ca/image
 22  *  2356 Main Mall                    tel.: +1 604 822 4051
 23  *  Vancouver BC Canada V6T1Z4        fax.: +1 604 822 5949
 24  *
 25  ************************************************************************/
 26 
 27 /* Disclaimer of Warranty
 28  * 
 29  * These software programs are available to the user without any license fee
 30  * or royalty on an "as is" basis. The University of British Columbia
 31  * disclaims any and all warranties, whether express, implied, or
 32  * statuary, including any implied warranties or merchantability or of
 33  * fitness for a particular purpose.  In no event shall the
 34  * copyright-holder be liable for any incidental, punitive, or
 35  * consequential damages of any kind whatsoever arising from the use of
 36  * these programs.
 37  * 
 38  * This disclaimer of warranty extends to the user of these programs and
 39  * user's customers, employees, agents, transferees, successors, and
 40  * assigns.
 41  * 
 42  * The University of British Columbia does not represent or warrant that the
 43  * programs furnished hereunder are free of infringement of any
 44  * third-party patents.
 45  * 
 46  * Commercial implementations of H.263, including shareware, are subject to
 47  * royalty fees to patent holders.  Many of these patents are general
 48  * enough such that they are unavoidable regardless of implementation
 49  * design.
 50  * 
 51  */
 52 
 53 
 54 /* modified to support annex O true B frames, mikeg@ee.ubc.ca
 55  * 
 56  * modified to support general H.263+ syntax, bernae@ee.ubc.ca
 57  * 
 58  * based on mpeg2decode, (C) 1994, MPEG Software Simulation Group and
 59  * mpeg2play, (C) 1994 Stefan Eckart <stefan@lis.e-technik.tu-muenchen.de> */
 60 
 61 
 62 #include <stdio.h>
 63 #include <stdlib.h>
 64 
 65 #include "config.h"
 66 #include "tmndec.h"
 67 #include "global.h"
 68 
 69 /* private prototypes */
 70 static void getpicturehdr _ANSI_ARGS_ ((void));
 71 
 72 /* decode headers from one input stream until an End of Sequence or
 73  * picture start code is found */
 74 
 75 int getheader ()
 76 {
 77   unsigned int code, gob;
 78 
 79   /* look for startcode */
 80   startcode ();
 81   code = getbits (PSC_LENGTH);
 82   gob = getbits (5);
 83   if (gob == SE_CODE)
 84     return 0;
 85   if (gob == 0)
 86   {
 87     if (trace)
 88     {
 89 
 90       fprintf (trace_file, "\nPSC: ");
 91       printbits ((code << 5 + gob), 22, 22);
 92     }
 93     getpicturehdr ();
 94     if (syntax_arith_coding)    /* reset decoder after receiving */
 95       decoder_reset ();         /* fixed length PSC string */
 96   } 
 97   else
 98   {
 99     if (trace)
100     {
101 
102       fprintf (trace_file, "\nGBSC: ");
103       printbits ((code << 5 + gob), 22, 22);
104     }
105   }
106   return gob + 1;
107 }
108 
109 
110 /* align to start of next startcode */
111 
112 void startcode ()
113 {
114   /* search for new picture start code */
115   while (showbits (PSC_LENGTH) != 1l)
116     flushbits (1);
117 }
118 
119 /* decode picture header */
120 
121 static void getpicturehdr ()
122 {
123   int pos, pei, tmp;
124   int UFEP = 0;
125   int BCI = 0;
126   int clock_conversion_code = 0;
127   int clock_divisor = 0;
128   int extended_temporal_reference = 0;
129   int prev_plus_P_temp_ref = 0;
130 
131   pos = ld->bitcnt;
132 
133   prev_plus_P_temp_ref = temp_ref;
134   temp_ref = getbits (8);
135   if (trace)
136   {
137     fprintf (trace_file, "\nTR: ");
138     printbits (temp_ref, 8, 8);
139   }
140   if (trd < 0)
141     trd += 256;
142 
143   tmp = getbits (1);            /* always "1" */
144   if (trace)
145     fprintf (trace_file, "\nSpare: %d", tmp);
146   if (!tmp)
147     if (!quiet)
148       printf ("warning: spare in picture header should be \"1\"\n");
149   tmp = getbits (1);            /* always "" */
150   if (trace)
151     fprintf (trace_file, "\nH.261 distinction bit: %d", tmp);
152   if (tmp)
153     if (!quiet)
154       printf ("warning: H.261 distinction bit should be \"\"\n");
155   tmp = getbits (1);            /* split_screen_indicator */
156   if (trace)
157     fprintf (trace_file, "\nsplit_screen_indicator: %d", tmp);
158   if (tmp)
159   {
160     if (!quiet)
161       printf ("error: split-screen not supported in this version\n");
162     exit (-1);
163   }
164   tmp = getbits (1);            /* document_camera_indicator */
165   if (trace)
166     fprintf (trace_file, "\ndocument_camera_indicator: %d", tmp);
167   if (tmp)
168     if (!quiet)
169       printf ("warning: document camera indicator not supported in this version\n");
170 
171   tmp = getbits (1);            /* freeze_picture_release */
172   if (trace)
173     fprintf (trace_file, "\nfreeze_picture_release: %d", tmp);
174   if (tmp)
175     if (!quiet)
176       printf ("warning: frozen picture not supported in this version\n");
177   tmp = getbits (3);
178   if (trace)
179   {
180     fprintf (trace_file, "\nsource_format: ");
181     printbits (tmp, 3, 3);
182   }
183 
184   if (tmp == EXTENDED_PTYPE)
185   {
186     if (trace)
187       fprintf (trace_file, "\n----------EXTENDED_PTYPE----------");
188     plus_type = 1;
189     UFEP = getbits (3);
190     if (trace)
191     {
192       fprintf (trace_file, "\nUFEP: ");
193       printbits (UFEP, 3, 3);
194     }
195     if (UFEP == 1)
196     {                           /* OPPTYPE */
197       if (trace)
198         fprintf (trace_file, "\n----------OPTIONAL PLUS PTYPE----------");
199       source_format_old = source_format;
200       source_format = getbits (3);
201       if (trace)
202       {
203         fprintf (trace_file, "\nsource_format: ");
204         printbits (source_format, 3, 3);
205       }
206     
207       /* optional custom picture clock frequency */
208       optional_custom_PCF = getbits (1);
209       if (trace)
210       {
211         fprintf (trace_file, "\noptional_custom_PCF: ");
212         printbits (optional_custom_PCF, 1, 1);
213       }
214       if (optional_custom_PCF)
215       {
216         if (!quiet)
217           printf ("error: Optional custom picture clock frequency is not supported in this version\n");
218         exit (-1);
219       }
220       mv_outside_frame = getbits (1);
221       if (trace)
222       {
223         fprintf (trace_file, "\nmv_outside_frame: ");
224         printbits (mv_outside_frame, 1, 1);
225       }
226       long_vectors = (mv_outside_frame ? 1 : 0);
227       syntax_arith_coding = getbits (1);
228       if (trace)
229       {
230         fprintf (trace_file, "\nsyntax_arith_coding: ");
231         printbits (syntax_arith_coding, 1, 1);
232       }
233       adv_pred_mode = getbits (1);
234       if (trace)
235       {
236         fprintf (trace_file, "\nadv_pred_mode: ");
237         printbits (adv_pred_mode, 1, 1);
238       }
239       mv_outside_frame = (adv_pred_mode ? 1 : mv_outside_frame);
240       overlapping_MC = (adv_pred_mode ? 1 : 0);
241       use_4mv = (adv_pred_mode ? 1 : 0);
242       pb_frame = 0;
243       advanced_intra_coding = getbits (1);
244       if (trace)
245       {
246         fprintf (trace_file, "\nadvanced_intra_coding: ");
247         printbits (advanced_intra_coding, 1, 1);
248       }
249       deblocking_filter_mode = getbits (1);
250       if (trace)
251       {
252         fprintf (trace_file, "\ndeblocking_filter_mode: ");
253         printbits (deblocking_filter_mode, 1, 1);
254       }
255       mv_outside_frame = (deblocking_filter_mode ? 1 : mv_outside_frame);
256       use_4mv = (deblocking_filter_mode ? 1 : use_4mv);
257 
258       slice_structured_mode = getbits (1);
259       if (trace)
260       {
261         fprintf (trace_file, "\nslice_structured_mode: ");
262         printbits (slice_structured_mode, 1, 1);
263       }
264       if (slice_structured_mode)
265       {
266         if (!quiet)
267           printf ("error: Slice structured mode is not supported in this version\n");
268         exit (-1);
269       }
270       reference_picture_selection_mode = getbits (1);
271       if (trace)
272       {
273         fprintf (trace_file, "\nreference_picture_selection_mode: ");
274         printbits (reference_picture_selection_mode, 1, 1);
275       }
276 #if 0
277       if (reference_picture_selection_mode)
278       {
279         if (!quiet)
280           printf ("error: Reference picture selection mode is not supported in this version\n");
281         exit (-1);
282       }
283 #endif
284       independently_segmented_decoding_mode = getbits (1);
285       if (trace)
286       {
287         fprintf (trace_file, "\nindependently_segmented_decoding_mode: ");
288         printbits (independently_segmented_decoding_mode, 1, 1);
289       }
290       if (independently_segmented_decoding_mode)
291       {
292         if (!quiet)
293           printf ("error: Independently segmented decoding mode is not supported in this version\n");
294         exit (-1);
295       }
296       alternative_inter_VLC_mode = getbits (1);
297       if (trace)
298       {
299         fprintf (trace_file, "\nalternative_inter_VLC_mode: ");
300         printbits (alternative_inter_VLC_mode, 1, 1);
301       }
302       modified_quantization_mode = getbits (1);
303       if (trace)
304       {
305         fprintf (trace_file, "\nmodified_quantization_mode: ");
306         printbits (modified_quantization_mode, 1, 1);
307       }
308       tmp = getbits (4);
309       if (trace)
310       {
311         fprintf (trace_file, "\nspare, reserve, reserve, reserve: ");
312         printbits (tmp, 4, 4);
313       }
314       if (tmp != 8)
315       {                         /* OPPTYPE : bit15=1, bit16,bit17,bit18=0 */
316         if (!quiet)
317           printf ("error: The last 4 bits of OPPTYPE is expected to be 1000\n");
318         exit (-1);
319       }
320     }
321     if ((UFEP == 1) || (UFEP == 0))
322     {
323       if (UFEP == 0)
324       {
325         if (scalability_mode >= 3)
326         {
327           horizontal_size = lines[base_source_format];
328           vertical_size = pels[base_source_format];
329 
330           mb_width = horizontal_size / 16;
331           mb_height = vertical_size / 16;
332 
333           /* Need to store previous (reference layer) values 
334            * for interpolation purposes, as the new values, 
335            * i.e. of the spatially scaled layer, depend on 
336            * the type of spatial scalability in use. */
337           ref_coded_picture_width = coded_picture_width = horizontal_size;
338           ref_coded_picture_height = coded_picture_height = vertical_size;
339           ref_chrom_width = chrom_width = coded_picture_width >> 1;
340           ref_chrom_height = chrom_height = coded_picture_height >> 1;
341 
342           source_format = base_source_format;
343         }
344       }
345 
346       /* MMPTYPE */
347       if (trace)
348         fprintf (trace_file, "\n----------MANDATORY PLUS PTYPE----------");
349       pict_type = getbits (3);
350       if (trace)
351       {
352         fprintf (trace_file, "\npict_type: ");
353         printbits (pict_type, 3, 3);
354       }
355       if (pict_type == PCT_IPB)
356         pb_frame = IM_PB_FRAMES;
357       else
358         pb_frame = 0;
359 
360       if (PCT_B == pict_type)
361       {
362         true_B_frame = ON;
363         /* Allow motion over picture boundaries, regardless of whether or
364          * not UMV is turned on. */
365         mv_outside_frame = 1;
366         true_b_trb = temp_ref - prev_non_disposable_temp_ref;
367       } else
368       {
369         true_B_frame = OFF;
370         prev_non_disposable_temp_ref = next_non_disposable_temp_ref;
371         next_non_disposable_temp_ref = temp_ref;
372         trd = temp_ref - prev_non_disposable_temp_ref;
373       }
374 
375       reference_picture_resampling_mode = getbits (1);
376       if (trace)
377       {
378         fprintf (trace_file, "\nreference_picture_resampling_mode: ");
379         printbits (reference_picture_resampling_mode, 1, 1);
380       }
381       if (reference_picture_resampling_mode)
382       {
383         if (!quiet)
384           printf ("error: Reference picture resampling mode is not supported in this version\n");
385         exit (-1);
386       }
387       reduced_resolution_update_mode = getbits (1);
388       if (trace)
389       {
390         fprintf (trace_file, "\nreduced_resolution_update_mode: ");
391         printbits (reduced_resolution_update_mode, 1, 1);
392       }
393       if (reduced_resolution_update_mode)
394       {
395         if (!quiet)
396           printf ("error: Reduced resolution update mode is not supported in this version\n");
397         exit (-1);
398       }
399       rtype = getbits (1);      /* rounding type */
400       if (trace)
401       {
402         fprintf (trace_file, "\nrounding_type: ");
403         printbits (rtype, 1, 1);
404       }
405       if (trace)
406       {
407         fprintf (trace_file, "\nrtype: ");
408         printbits (rtype, 1, 1);
409       }
410       tmp = getbits (3);
411       if (trace)
412       {
413         fprintf (trace_file, "\nreserve, reserve, spare: ");
414         printbits (tmp, 3, 3);
415       }
416       if (tmp != 1)
417       {                         /* MPPTYPE : bit7,bit8=0  bit9=1 */
418         if (!quiet)
419           exit (-1);
420       }
421     } else
422     {
423       /* UFEP is neither 001 nor 000 */
424       if (!quiet)
425         printf ("error: UFEP should be either 001 or 000.\n");
426       exit (-1);
427     }
428 
429     tmp = getbits (1);
430     if (trace)
431     {
432       fprintf (trace_file, "\nCPM: ");
433       printbits (tmp, 5, 5);
434     }
435     if (tmp)
436     {
437       if (!quiet)
438         printf ("error: CPM not supported in this version\n");
439       exit (-1);
440     }
441   
442     if (UFEP && (source_format == SF_CUSTOM))
443     {
444       /* Read custom picture format */
445       if (trace)
446         fprintf (trace_file, "\ncustom picture format \n");
447       CP_PAR_code = getbits (4);
448       if (trace)
449       {
450         fprintf (trace_file, "\nCP_PAR_code: ");
451         printbits (CP_PAR_code, 4, 4);
452       }
453       if (CP_PAR_code != PAR_CIF)
454       {
455         if (!quiet)
456         {
457           printf ("error: only 12:11 pixel aspect ratio supported ");
458         }
459         exit(-1);
460       }
461       tmp=getbits (9);
462       horizontal_size = (tmp + 1 ) * 4;
463       if (trace)
464       {
465         fprintf (trace_file, "\nCP_picture_width_indication: ");
466         printbits (tmp, 9, 9);
467       }
468       tmp = getbits (1);
469       if (trace)
470       {
471         fprintf (trace_file, "\nspare: ");
472         printbits (tmp, 1, 1);
473       }
474       if (!tmp)
475       {
476         if (!quiet)
477           printf ("error: The 14th bit of Custom Picture Format(CPFMT) should be 1\n");
478         exit (-1);
479       }
480       tmp = getbits (8);
481       vertical_size = tmp * 4;
482       if (trace)
483       {
484         fprintf (trace_file, "\nCP_picture_height_indication: ");
485         printbits (tmp, 8, 8);
486       }
487       if ((horizontal_size%16) || (vertical_size%16))
488       {
489         if(!quiet)
490         {
491           printf ("error: only factor of 16 custom source format supported\n");
492         }
493         exit (-1);
494       }
495 
496       if (CP_PAR_code == EXTENDED_PAR)
497       {
498         PAR_width = getbits (8);
499         PAR_height = getbits (8);
500       }
501     }
502 
503     if (source_format != SF_CUSTOM)
504     {
505         horizontal_size = lines[source_format];
506         vertical_size = pels[source_format];
507 
508     }
509     
510     mb_width = horizontal_size / 16;
511     mb_height = vertical_size / 16;
512 
513    /* Need to store previous (reference layer) values 
514     * for interpolation purposes, as the new values, 
515     * i.e. of the spatially scaled layer, depend on 
516     * the type of spatial scalability in use. */
517     ref_coded_picture_width = coded_picture_width;
518     coded_picture_width = horizontal_size;
519 
520     ref_coded_picture_height = coded_picture_height;
521     coded_picture_height = vertical_size;
522 
523     ref_chrom_width = chrom_width; 
524     chrom_width = coded_picture_width >> 1;
525 
526     ref_chrom_height = chrom_height;
527     chrom_height = coded_picture_height >> 1;
528     
529     if (optional_custom_PCF)
530     {
531       if (trace)
532         fprintf (trace_file, "\noptional_custom_PCF \n");
533       if (UFEP)
534       {
535         clock_conversion_code = getbits (1);
536         if (trace)
537         {
538           fprintf (trace_file, "\nclock_conversion_code: ");
539           printbits (clock_conversion_code, 1, 1);
540         }
541         clock_divisor = getbits (7);
542         if (trace)
543         {
544           fprintf (trace_file, "\nclock_divisor: ");
545           printbits (clock_divisor, 7, 7);
546         }
547         CP_clock_frequency = (int) (1800 / ((float) clock_divisor * (8 + clock_conversion_code)) * 1000);
548       }
549       /* regardless of the value of UFEP */
550       extended_temporal_reference = getbits (2);
551       if (trace)
552       {
553         fprintf (trace_file, "\nextended_temporal_reference: ");
554         printbits (extended_temporal_reference, 2, 2);
555       }
556       temp_ref = extended_temporal_reference << 8 + temp_ref;
557 
558       if (PCT_B == pict_type)
559       {
560         true_b_trb = temp_ref - prev_non_disposable_temp_ref;
561       } else
562       {
563         trd = temp_ref - prev_non_disposable_temp_ref;
564       }
565 
566       if (trd < 0)
567         trd += 1024;
568     }
569     if (UFEP && slice_structured_mode)
570     {
571       SSS_rectangular_slices = getbits (1);
572       if (trace)
573       {
574         fprintf (trace_file, "\nSSS_rectangular_slices: ");
575         printbits (SSS_rectangular_slices, 1, 1);
576       }
577       SSS_arbitary_slice_ordering = getbits (1);
578       if (trace)
579       {
580         fprintf (trace_file, "\nSSS_arbitary_slice_ordering: ");
581         printbits (SSS_arbitary_slice_ordering, 1, 1);
582       }
583     }
584 
585     if ((pict_type == PCT_B) || (pict_type == PCT_EI) || (pict_type == PCT_EP))
586     {
587       /* optional temporal, SNR and spatial scalability mode in use */
588       enhancement_layer_num = getbits (4);
589       if (trace)
590       {
591         fprintf (trace_file, "\nenhancement_layer_num: ");
592         printbits (enhancement_layer_num, 4, 4);
593       }
594       if (UFEP)
595       {
596         reference_layer_number = getbits (4);
597         if (trace)
598         {
599           fprintf (trace_file, "\nreference_layer_number: ");
600           printbits (reference_layer_number, 4, 4);
601         }
602       }
603       if (1 != enhancement_layer_num)
604       {
605         if (source_format != source_format_old)
606         {
607           if (source_format != SF_CUSTOM)
608           {
609             scalability_mode = SPATIAL_SCALABILITY_HV;
610           }
611           else if (coded_picture_width != ref_coded_picture_width)
612           {
613             scalability_mode = SPATIAL_SCALABILITY_H;
614           }
615           else 
616           {
617             scalability_mode = SPATIAL_SCALABILITY_V;
618           }
619         }
620         else
621         {
622           scalability_mode = SNR_SCALABILITY;
623         }
624       }   
625     }
626     else
627     {
628       enhancement_layer_num = reference_layer_number = 1;
629     }
630 
631     if (reference_picture_selection_mode)
632     {
633       if (UFEP)
634       {
635         MF_of_reference_picture_selection = getbits (3);
636         if (trace)
637         {
638           fprintf (trace_file, "\nMF_of_reference_picture_selection: ");
639           printbits (MF_of_reference_picture_selection, 3, 3);
640         }
641       }
642       TRPI = getbits (1);
643       if (trace)
644       {
645         fprintf (trace_file, "\nTRPI: ");
646         printbits (TRPI, 1, 1);
647       }
648       if (TRPI)
649       {
650         /* temporal reference for prediction exists */
651         temporal_reference_for_prediction = getbits (10);
652         if (trace)
653         {
654           fprintf (trace_file, "\ntemporal_reference_for_prediction: ");
655           printbits (temporal_reference_for_prediction, 10, 10);
656         }
657       }
658       /* draft20: 1=yes, 01=no */
659       BCI = getbits (1);
660       if (!BCI) getbits(1);
661       if (trace)
662       {
663         fprintf (trace_file, "\nBCI: ");
664         printbits (BCI, 1, 1);
665       }
666       if (BCI)
667       {
668         /* backward channel message exists */
669         /* BCM(backward channel message) is not implemented */
670         if (!quiet)
671           printf ("error: BCM(backward channel message) is not implemented in this version\n");
672         exit (-1);
673       }
674     }
675     if (reference_picture_resampling_mode) {
676       /* reading RPRP info is not implemented */
677       if (!quiet)
678         printf ("error: RPRP reading is not implemented in this version\n");
679       exit (-1);
680     }
681 
682     pic_quant = getbits (5);
683     quant = pic_quant;
684 
685     if (trace)
686     {
687       fprintf (trace_file, "\nquant: ");
688       printbits (quant, 5, 5);
689     }
690   } 
691   else
692   {
693     plus_type = 0;
694     source_format = tmp;
695     enhancement_layer_num = reference_layer_number = 1;
696 
697     horizontal_size = lines[source_format];
698     vertical_size = pels[source_format];
699 
700     mb_width = horizontal_size / 16;
701     mb_height = vertical_size / 16;
702 
703     /* Need to store previous (reference layer) values 
704      * for interpolation purposes, as the new values, 
705      * i.e. of the spatially scaled layer, depend on 
706      * the type of spatial scalability in use. */
707     ref_coded_picture_width = coded_picture_width = horizontal_size;
708     ref_coded_picture_height = coded_picture_height = vertical_size;
709     ref_chrom_width = chrom_width = coded_picture_width >> 1;
710     ref_chrom_height = chrom_height = coded_picture_height >> 1;
711 
712     trd = temp_ref - prev_plus_P_temp_ref;
713 
714     pict_type = getbits (1);
715     if (trace)
716     {
717       fprintf (trace_file, "\npict_type: ");
718       printbits (pict_type, 1, 1);
719     }
720     mv_outside_frame = getbits (1);
721     if (trace)
722     {
723       fprintf (trace_file, "\nmv_outside_frame: ");
724       printbits (mv_outside_frame, 1, 1);
725     }
726     long_vectors = (mv_outside_frame ? 1 : 0);
727     syntax_arith_coding = getbits (1);
728     if (trace)
729     {
730       fprintf (trace_file, "\nsyntax_arith_coding: ");
731       printbits (syntax_arith_coding, 1, 1);
732     }
733     adv_pred_mode = getbits (1);
734     if (trace)
735     {
736       fprintf (trace_file, "\nadv_pred_mode: ");
737       printbits (adv_pred_mode, 1, 1);
738     }
739     mv_outside_frame = (adv_pred_mode ? 1 : mv_outside_frame);
740     overlapping_MC = (adv_pred_mode ? 1 : 0);
741     use_4mv = (adv_pred_mode ? 1 : 0);
742     pb_frame = getbits (1);
743     if (trace)
744     {
745       fprintf (trace_file, "\npb_frame: ");
746       printbits (pb_frame, 1, 1);
747     }
748    
749     pic_quant = getbits (5);
750     quant = pic_quant;
751 
752     if (trace)
753     {
754       fprintf (trace_file, "\nquant: ");
755       printbits (quant, 5, 5);
756     }
757 
758     tmp = getbits (1);
759     if (trace)
760     {
761       fprintf (trace_file, "\nCPM: ");
762       printbits (tmp, 5, 5);
763     }
764     if (tmp)
765     {
766       if (!quiet)
767         printf ("error: CPM not supported in this version\n");
768       exit (-1);
769     }
770   }
771 
772   if (pb_frame)
773   {
774     if (optional_custom_PCF)
775     {
776       trb = getbits (5);
777       if (trace)
778       {
779         fprintf (trace_file, "\ntrb: ");
780         printbits (trb, 5, 5);
781       }
782     } else
783     {
784       trb = getbits (3);
785       if (trace)
786       {
787         fprintf (trace_file, "\ntrb: ");
788         printbits (trb, 3, 3);
789       }
790     }
791 
792     bquant = getbits (2);
793     if (trace)
794     {
795       fprintf (trace_file, "\nbquant: ");
796       printbits (bquant, 2, 2);
797     }
798   } else
799   {
800     trb = 0;
801   }
802 
803 #ifdef USE_TIME
804   if (framerate > 0 && trd > 0)
805     doframerate (0);
806 #endif
807 
808   pei = getbits (1);
809   if (trace)
810   {
811     fprintf (trace_file, "\npei: ");
812     printbits (pei, 1, 1);
813   }
814 
815 pspare:
816   if (pei)
817   {
818     /* extra info for possible future backward compatible additions */
819     getbits (8);                /* not used */
820     pei = getbits (1);
821     if (pei)
822       goto pspare;              /* keep on reading pspare until pei=0 */
823   }
824   if (verbose > 0)
825   {
826     /* $printf("picture header (byte %d)\n",(pos>>3)-4);$ */
827     if (verbose > 1)
828     {
829       printf ("  temp_ref=%d\n", temp_ref);
830       /* $printf("  pict_type=%d\n",pict_type); printf("
831        * source_format=%d\n", source_format); printf("
832        * quant=%d\n",quant); if (syntax_arith_coding) printf("  SAC coding
833        * mode used \n"); if (mv_outside_frame) printf("  unrestricted
834        * motion vector mode used\n"); if (adv_pred_mode) printf("
835        * advanced prediction mode used\n");$ */
836       if (pb_frame)
837       {
838         /* $printf("  pb-frames mode used\n");$ */
839         printf ("  trb=%d\n", trb);
840         /* $printf("  bquant=%d\n", bquant);$ */
841       }
842     }
843   }
844   if (trace)
845   {
846     fprintf (trace_file, "\n--------------------------------------------------------\n");
847   }
848 }
849 
850 void initoptions ()
851 {
852   mv_outside_frame = 0;
853   syntax_arith_coding = 0;
854   adv_pred_mode = 0;
855   pb_frame = 0;
856   long_vectors = 0;
857 
858   plus_type = 0;
859   optional_custom_PCF = 0;
860   advanced_intra_coding = 0;
861   deblocking_filter_mode = 0;
862   slice_structured_mode = 0;
863   reference_picture_selection_mode = 0;
864   independently_segmented_decoding_mode = 0;
865   alternative_inter_VLC_mode = 0;
866   modified_quantization_mode = 0;
867   reduced_resolution_update_mode = 0;
868   reference_picture_resampling_mode = 0;
869   rtype = 0;
870 }
871 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.