annotate libmpeg2/header.c @ 404:6b6650381723

libmpeg2 codec ctrl removed
author arpi_esp
date Sat, 14 Apr 2001 16:01:33 +0000
parents 727b1337f951
children a0d4fa6b9435
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
2 * slice.c
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
3 * Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
4 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
6 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
7 * mpeg2dec is free software; you can redistribute it and/or modify
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 * (at your option) any later version.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12 * mpeg2dec is distributed in the hope that it will be useful,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15 * GNU General Public License for more details.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22 #include "config.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24 #include <inttypes.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 #include "mpeg2_internal.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 #include "attributes.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
29 /* default intra quant matrix, in zig-zag order */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30 static uint8_t default_intra_quantizer_matrix[64] ATTR_ALIGN(16) = {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31 8,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32 16, 16,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33 19, 16, 19,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34 22, 22, 22, 22,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35 22, 22, 26, 24, 26,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 27, 27, 27, 26, 26, 26,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37 26, 27, 27, 27, 29, 29, 29,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38 34, 34, 34, 29, 29, 29, 27, 27,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39 29, 29, 32, 32, 34, 34, 37,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 38, 37, 35, 35, 34, 35,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41 38, 38, 40, 40, 40,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42 48, 48, 46, 46,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43 56, 56, 58,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44 69, 69,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45 83
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48 uint8_t scan_norm[64] ATTR_ALIGN(16) =
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49 {
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
50 /* Zig-Zag scan pattern */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51 0, 1, 8,16, 9, 2, 3,10,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52 17,24,32,25,18,11, 4, 5,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 12,19,26,33,40,48,41,34,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 27,20,13, 6, 7,14,21,28,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 35,42,49,56,57,50,43,36,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 29,22,15,23,30,37,44,51,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 58,59,52,45,38,31,39,46,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 53,60,61,54,47,55,62,63
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 uint8_t scan_alt[64] ATTR_ALIGN(16) =
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62 {
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
63 /* Alternate scan pattern */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 0,8,16,24,1,9,2,10,17,25,32,40,48,56,57,49,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 41,33,26,18,3,11,4,12,19,27,34,42,50,58,35,43,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66 51,59,20,28,5,13,6,14,21,29,36,44,52,60,37,45,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 53,61,22,30,7,15,23,31,38,46,54,62,39,47,55,63
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 void header_state_init (picture_t * picture)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 picture->scan = scan_norm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 int header_process_sequence_header (picture_t * picture, uint8_t * buffer)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 {
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
77 int width, height;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80 if ((buffer[6] & 0x20) != 0x20)
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
81 return 1; /* missing marker_bit */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
83 height = (buffer[0] << 16) | (buffer[1] << 8) | buffer[2];
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
85 picture->display_picture_width = (height >> 12);
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
86 picture->display_picture_height = (height & 0xfff);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
88 width = ((height >> 12) + 15) & ~15;
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
89 height = ((height & 0xfff) + 15) & ~15;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
91 if ((width > 768) || (height > 576))
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
92 return 1; /* size restrictions for MP@ML or MPEG1 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
94 picture->coded_picture_width = width;
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
95 picture->coded_picture_height = height;
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
96
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
97 /* this is not used by the decoder */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 picture->aspect_ratio_information = buffer[3] >> 4;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
99 picture->frame_rate_code = buffer[3] & 15;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
100 picture->bitrate = (buffer[4]<<10)|(buffer[5]<<2)|(buffer[6]>>6);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
101
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
102 if (buffer[7] & 2) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
103 for (i = 0; i < 64; i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
104 picture->intra_quantizer_matrix[scan_norm[i]] =
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105 (buffer[i+7] << 7) | (buffer[i+8] >> 1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106 buffer += 64;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108 for (i = 0; i < 64; i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
109 picture->intra_quantizer_matrix[scan_norm[i]] =
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
110 default_intra_quantizer_matrix [i];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
111 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
112
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
113 if (buffer[7] & 1) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
114 for (i = 0; i < 64; i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115 picture->non_intra_quantizer_matrix[scan_norm[i]] =
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
116 buffer[i+8];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
117 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
118 for (i = 0; i < 64; i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
119 picture->non_intra_quantizer_matrix[i] = 16;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
120 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
121
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
122 /* MPEG1 - for testing only */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
123 picture->mpeg1 = 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
124 picture->intra_dc_precision = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
125 picture->frame_pred_frame_dct = 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
126 picture->q_scale_type = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
127 picture->concealment_motion_vectors = 0;
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
128 /* picture->alternate_scan = 0; */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
129 picture->picture_structure = FRAME_PICTURE;
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
130 /* picture->second_field = 0; */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
133 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
134
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
135 static int header_process_sequence_extension (picture_t * picture,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136 uint8_t * buffer)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
137 {
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
138 /* check chroma format, size extensions, marker bit */
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
139 if (((buffer[1] & 0x07) != 0x02) || (buffer[2] & 0xe0) ||
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
140 ((buffer[3] & 0x01) != 0x01))
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
141 return 1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
142
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
143 /* this is not used by the decoder */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144 picture->progressive_sequence = (buffer[1] >> 3) & 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
145
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146 if (picture->progressive_sequence)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
147 picture->coded_picture_height =
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148 (picture->coded_picture_height + 31) & ~31;
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
149
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
150 /* MPEG1 - for testing only */
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
151 picture->mpeg1 = 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
152
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
154 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
155
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
156 static int header_process_quant_matrix_extension (picture_t * picture,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157 uint8_t * buffer)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
158 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
161 if (buffer[0] & 8) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
162 for (i = 0; i < 64; i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
163 picture->intra_quantizer_matrix[scan_norm[i]] =
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164 (buffer[i] << 5) | (buffer[i+1] >> 3);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165 buffer += 64;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168 if (buffer[0] & 4) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169 for (i = 0; i < 64; i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 picture->non_intra_quantizer_matrix[scan_norm[i]] =
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171 (buffer[i] << 6) | (buffer[i+1] >> 2);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
173
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177 static int header_process_picture_coding_extension (picture_t * picture, uint8_t * buffer)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178 {
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
179 /* pre subtract 1 for use later in compute_motion_vector */
49
727b1337f951 updated to libmpeg2-0.2.1-CVS
arpi_esp
parents: 36
diff changeset
180 picture->f_motion.f_code[0] = (buffer[0] & 15) - 1;
727b1337f951 updated to libmpeg2-0.2.1-CVS
arpi_esp
parents: 36
diff changeset
181 picture->f_motion.f_code[1] = (buffer[1] >> 4) - 1;
727b1337f951 updated to libmpeg2-0.2.1-CVS
arpi_esp
parents: 36
diff changeset
182 picture->b_motion.f_code[0] = (buffer[1] & 15) - 1;
727b1337f951 updated to libmpeg2-0.2.1-CVS
arpi_esp
parents: 36
diff changeset
183 picture->b_motion.f_code[1] = (buffer[2] >> 4) - 1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
184
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
185 picture->intra_dc_precision = (buffer[2] >> 2) & 3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
186 picture->picture_structure = buffer[2] & 3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187 picture->frame_pred_frame_dct = (buffer[3] >> 6) & 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
188 picture->concealment_motion_vectors = (buffer[3] >> 5) & 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
189 picture->q_scale_type = (buffer[3] >> 4) & 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
190 picture->intra_vlc_format = (buffer[3] >> 3) & 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
192 if (buffer[3] & 4) /* alternate_scan */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193 picture->scan = scan_alt;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
194 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195 picture->scan = scan_norm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
197 /* these are not used by the decoder */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
198 picture->top_field_first = buffer[3] >> 7;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
199 picture->repeat_first_field = (buffer[3] >> 1) & 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200 picture->progressive_frame = buffer[4] >> 7;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202 // repeat_first implementation by A'rpi/ESP-team, based on libmpeg3:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
203 if(picture->repeat_count>=100) picture->repeat_count=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
204 if(picture->repeat_first_field){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205 if(picture->progressive_sequence){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206 if(picture->top_field_first)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
207 picture->repeat_count+=200;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
209 picture->repeat_count+=100;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
210 } else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211 if(picture->progressive_frame){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
212 picture->repeat_count+=50;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
213 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
214 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
215
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
216 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
217 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
218
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
219 int header_process_extension (picture_t * picture, uint8_t * buffer)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
220 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
221 switch (buffer[0] & 0xf0) {
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
222 case 0x10: /* sequence extension */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
223 return header_process_sequence_extension (picture, buffer);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
224
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
225 case 0x30: /* quant matrix extension */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226 return header_process_quant_matrix_extension (picture, buffer);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
228 case 0x80: /* picture coding extension */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
229 return header_process_picture_coding_extension (picture, buffer);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235 int header_process_picture_header (picture_t *picture, uint8_t * buffer)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237 picture->picture_coding_type = (buffer [1] >> 3) & 7;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
239 /* forward_f_code and backward_f_code - used in mpeg1 only */
49
727b1337f951 updated to libmpeg2-0.2.1-CVS
arpi_esp
parents: 36
diff changeset
240 picture->f_motion.f_code[1] = (buffer[3] >> 2) & 1;
727b1337f951 updated to libmpeg2-0.2.1-CVS
arpi_esp
parents: 36
diff changeset
241 picture->f_motion.f_code[0] =
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
242 (((buffer[3] << 1) | (buffer[4] >> 7)) & 7) - 1;
49
727b1337f951 updated to libmpeg2-0.2.1-CVS
arpi_esp
parents: 36
diff changeset
243 picture->b_motion.f_code[1] = (buffer[4] >> 6) & 1;
727b1337f951 updated to libmpeg2-0.2.1-CVS
arpi_esp
parents: 36
diff changeset
244 picture->b_motion.f_code[0] = ((buffer[4] >> 3) & 7) - 1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
245
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
246 /* move in header_process_picture_header */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
247 picture->second_field =
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
248 (picture->picture_structure != FRAME_PICTURE) &&
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
249 !(picture->second_field);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
250
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
251 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
252 }