diff libmpeg2/header.c @ 36:846535ace7a2

libmpeg2-0.2.0 merge
author arpi_esp
date Sun, 04 Mar 2001 21:01:54 +0000
parents 3b5f5d1c5041
children 727b1337f951
line wrap: on
line diff
--- a/libmpeg2/header.c	Sun Mar 04 14:12:58 2001 +0000
+++ b/libmpeg2/header.c	Sun Mar 04 21:01:54 2001 +0000
@@ -1,6 +1,6 @@
 /*
  * slice.c
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
+ * Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
  *
  * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
  *
@@ -26,7 +26,7 @@
 #include "mpeg2_internal.h"
 #include "attributes.h"
 
-// default intra quant matrix, in zig-zag order
+/* default intra quant matrix, in zig-zag order */
 static uint8_t default_intra_quantizer_matrix[64] ATTR_ALIGN(16) = {
     8,
     16, 16,
@@ -47,7 +47,7 @@
 
 uint8_t scan_norm[64] ATTR_ALIGN(16) =
 {
-    // Zig-Zag scan pattern
+    /* Zig-Zag scan pattern */
      0, 1, 8,16, 9, 2, 3,10,
     17,24,32,25,18,11, 4, 5,
     12,19,26,33,40,48,41,34,
@@ -60,7 +60,7 @@
 
 uint8_t scan_alt[64] ATTR_ALIGN(16) =
 {
-    // Alternate scan pattern
+    /* Alternate scan pattern */
     0,8,16,24,1,9,2,10,17,25,32,40,48,56,57,49,
     41,33,26,18,3,11,4,12,19,27,34,42,50,58,35,43,
     51,59,20,28,5,13,6,14,21,29,36,44,52,60,37,45,
@@ -69,47 +69,34 @@
 
 void header_state_init (picture_t * picture)
 {
-    //FIXME we should set pointers to the real scan matrices here (mmx vs
-    //normal) instead of the ifdefs in header_process_picture_coding_extension
-
     picture->scan = scan_norm;
 }
 
-static const int frameratecode2framerate[16] = {
-   0, 24000*10000/1001, 24*10000,25*10000, 30000*10000/1001, 30*10000,50*10000,60000*10000/1001,
-  60*10000, 0,0,0,0,0,0,0
-};
-
 int header_process_sequence_header (picture_t * picture, uint8_t * buffer)
 {
-    unsigned int h_size;
-    unsigned int v_size;
+    int width, height;
     int i;
 
     if ((buffer[6] & 0x20) != 0x20)
-	return 1;	// missing marker_bit
-
-    v_size = (buffer[0] << 16) | (buffer[1] << 8) | buffer[2];
+	return 1;	/* missing marker_bit */
 
-    picture->display_picture_width = (v_size >> 12);
-    picture->display_picture_height = (v_size & 0xfff);
+    height = (buffer[0] << 16) | (buffer[1] << 8) | buffer[2];
 
-    h_size = ((v_size >> 12) + 15) & ~15;
-    v_size = ((v_size & 0xfff) + 15) & ~15;
+    picture->display_picture_width = (height >> 12);
+    picture->display_picture_height = (height & 0xfff);
 
-    if ((h_size > 768) || (v_size > 576))
-	return 1;	// size restrictions for MP@ML or MPEG1
+    width = ((height >> 12) + 15) & ~15;
+    height = ((height & 0xfff) + 15) & ~15;
 
-    //XXX this needs field fixups
-    picture->coded_picture_width = h_size;
-    picture->coded_picture_height = v_size;
-    picture->last_mba = ((h_size * v_size) >> 8) - 1;
+    if ((width > 768) || (height > 576))
+	return 1;	/* size restrictions for MP@ML or MPEG1 */
 
-    // this is not used by the decoder
+    picture->coded_picture_width = width;
+    picture->coded_picture_height = height;
+
+    /* this is not used by the decoder */
     picture->aspect_ratio_information = buffer[3] >> 4;
     picture->frame_rate_code = buffer[3] & 15;
-    picture->frame_rate = frameratecode2framerate[picture->frame_rate_code];
-
     picture->bitrate = (buffer[4]<<10)|(buffer[5]<<2)|(buffer[6]>>6);
 
     if (buffer[7] & 2) {
@@ -132,15 +119,15 @@
 	    picture->non_intra_quantizer_matrix[i] = 16;
     }
 
-    // MPEG1 - for testing only
+    /* MPEG1 - for testing only */
     picture->mpeg1 = 1;
     picture->intra_dc_precision = 0;
     picture->frame_pred_frame_dct = 1;
     picture->q_scale_type = 0;
     picture->concealment_motion_vectors = 0;
-    //picture->alternate_scan = 0;
+    /* picture->alternate_scan = 0; */
     picture->picture_structure = FRAME_PICTURE;
-    //picture->second_field = 0;
+    /* picture->second_field = 0; */
 
     return 0;
 }
@@ -148,28 +135,20 @@
 static int header_process_sequence_extension (picture_t * picture,
 					      uint8_t * buffer)
 {
-    // MPEG1 - for testing only
-    picture->mpeg1 = 0;
+    /* check chroma format, size extensions, marker bit */
+    if (((buffer[1] & 0x07) != 0x02) || (buffer[2] & 0xe0) ||
+	((buffer[3] & 0x01) != 0x01))
+	return 1;
 
-    // check chroma format, size extensions, marker bit
-    if(((buffer[1]>>1)&3)!=1){
-      printf("This CHROMA format not yet supported :(\n");
-      return 1;
-    }
-    if ((buffer[1] & 1) || (buffer[2] & 0xe0)){
-      printf("Big resolution video not yet supported :(\n");
-      return 1;
-    }
-    if((buffer[3] & 0x01) != 0x01) return 1; // marker bit
-
-
-    // this is not used by the decoder
+    /* this is not used by the decoder */
     picture->progressive_sequence = (buffer[1] >> 3) & 1;
 
     if (picture->progressive_sequence)
 	picture->coded_picture_height =
 	    (picture->coded_picture_height + 31) & ~31;
-    picture->bitrate>>=1; // hack
+
+    /* MPEG1 - for testing only */
+    picture->mpeg1 = 0;
 
     return 0;
 }
@@ -197,7 +176,7 @@
 
 static int header_process_picture_coding_extension (picture_t * picture, uint8_t * buffer)
 {
-    //pre subtract 1 for use later in compute_motion_vector
+    /* pre subtract 1 for use later in compute_motion_vector */
     picture->f_code[0][0] = (buffer[0] & 15) - 1;
     picture->f_code[0][1] = (buffer[1] >> 4) - 1;
     picture->f_code[1][0] = (buffer[1] & 15) - 1;
@@ -210,12 +189,12 @@
     picture->q_scale_type = (buffer[3] >> 4) & 1;
     picture->intra_vlc_format = (buffer[3] >> 3) & 1;
 
-    if (buffer[3] & 4)	// alternate_scan
+    if (buffer[3] & 4)	/* alternate_scan */
 	picture->scan = scan_alt;
     else
 	picture->scan = scan_norm;
 
-    // these are not used by the decoder
+    /* these are not used by the decoder */
     picture->top_field_first = buffer[3] >> 7;
     picture->repeat_first_field = (buffer[3] >> 1) & 1;
     picture->progressive_frame = buffer[4] >> 7;
@@ -240,13 +219,13 @@
 int header_process_extension (picture_t * picture, uint8_t * buffer)
 {
     switch (buffer[0] & 0xf0) {
-    case 0x10:	// sequence extension
+    case 0x10:	/* sequence extension */
 	return header_process_sequence_extension (picture, buffer);
 
-    case 0x30:	// quant matrix extension
+    case 0x30:	/* quant matrix extension */
 	return header_process_quant_matrix_extension (picture, buffer);
 
-    case 0x80:	// picture coding extension
+    case 0x80:	/* picture coding extension */
 	return header_process_picture_coding_extension (picture, buffer);
     }
 
@@ -257,14 +236,14 @@
 {
     picture->picture_coding_type = (buffer [1] >> 3) & 7;
 
-    // forward_f_code and backward_f_code - used in mpeg1 only
+    /* forward_f_code and backward_f_code - used in mpeg1 only */
     picture->f_code[0][1] = (buffer[3] >> 2) & 1;
     picture->f_code[0][0] =
 	(((buffer[3] << 1) | (buffer[4] >> 7)) & 7) - 1;
     picture->f_code[1][1] = (buffer[4] >> 6) & 1;
     picture->f_code[1][0] = ((buffer[4] >> 3) & 7) - 1;
 
-    // move in header_process_picture_header
+    /* move in header_process_picture_header */
         picture->second_field =
             (picture->picture_structure != FRAME_PICTURE) &&
             !(picture->second_field);