clib/libmpeg2/slice.c

filter: Statementstmt 0.0% 0 / 936 Branchbran 0.0% 0 / 866 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 1802 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« clib/libmpeg2/motion_comp_mmx.c ↑ Summary clib/libmpeg2/src/dump_state.c »
1 /*
2 * slice.c
3 * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
4 * Copyright (C) 2003 Peter Gubanov <peter@elecard.net.ru>
5 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
6 *
7 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
8 * See http://libmpeg2.sourceforge.net/ for updates.
9 *
10 * mpeg2dec is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * mpeg2dec is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24  
25 #include "config.h"
26  
27 #include <inttypes.h>
28  
29 #include "mpeg2.h"
30 #include "attributes.h"
31 #include "mpeg2_internal.h"
32  
33 extern mpeg2_mc_t mpeg2_mc;
34 extern void (* mpeg2_idct_copy) (int16_t * block, uint8_t * dest, int stride);
35 extern void (* mpeg2_idct_add) (int last, int16_t * block,
36 uint8_t * dest, int stride);
37 extern void (* mpeg2_cpu_state_save) (cpu_state_t * state);
38 extern void (* mpeg2_cpu_state_restore) (cpu_state_t * state);
39  
40 #include "vlc.h"
41  
42 0 static inline int get_macroblock_modes (mpeg2_decoder_t * const decoder)
43 {
44 #define bit_buf (decoder->bitstream_buf)
45 #define bits (decoder->bitstream_bits)
46 #define bit_ptr (decoder->bitstream_ptr)
47 int macroblock_modes;
48 const MBtab * tab;
49  
50 0 switch (decoder->coding_type) {
51 0 case I_TYPE:
52  
53 0 tab = MB_I + UBITS (bit_buf, 1);
54 0 DUMPBITS (bit_buf, bits, tab->len);
55 0 macroblock_modes = tab->modes;
56  
57 0 ▶ if ((! (decoder->frame_pred_frame_dct)) &&
Branch: 1 branch
BranchTrueFalseTotal
if ((! (decoder->frame_pred_frame_dct)) && 0 0 0
58 0 ▶ (decoder->picture_structure == FRAME_PICTURE)) {
Branch: 1 branch
BranchTrueFalseTotal
(decoder->picture_structure == FRAME_PICTURE)) { 0 0 0
59 0 macroblock_modes |= UBITS (bit_buf, 1) * DCT_TYPE_INTERLACED;
60 0 DUMPBITS (bit_buf, bits, 1);
61 }
62  
63 0 return macroblock_modes;
64  
65 0 case P_TYPE:
66  
67 0 tab = MB_P + UBITS (bit_buf, 5);
68 0 DUMPBITS (bit_buf, bits, tab->len);
69 0 macroblock_modes = tab->modes;
70  
71 0 ▶ if (decoder->picture_structure != FRAME_PICTURE) {
Branch: 1 branch
BranchTrueFalseTotal
if (decoder->picture_structure != FRAME_PICTURE) { 0 0 0
72 0 ▶ if (macroblock_modes & MACROBLOCK_MOTION_FORWARD) {
Branch: 1 branch
BranchTrueFalseTotal
if (macroblock_modes & MACROBLOCK_MOTION_FORWARD) { 0 0 0
73 0 macroblock_modes |= UBITS (bit_buf, 2) << MOTION_TYPE_SHIFT;
74 0 DUMPBITS (bit_buf, bits, 2);
75 }
76 0 return macroblock_modes | MACROBLOCK_MOTION_FORWARD;
77 0 ▶ } else if (decoder->frame_pred_frame_dct) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (decoder->frame_pred_frame_dct) { 0 0 0
78 0 ▶ if (macroblock_modes & MACROBLOCK_MOTION_FORWARD)
Branch: 1 branch
BranchTrueFalseTotal
if (macroblock_modes & MACROBLOCK_MOTION_FORWARD) 0 0 0
79 0 macroblock_modes |= MC_FRAME << MOTION_TYPE_SHIFT;
80 0 return macroblock_modes | MACROBLOCK_MOTION_FORWARD;
81 } else {
82 0 ▶ if (macroblock_modes & MACROBLOCK_MOTION_FORWARD) {
Branch: 1 branch
BranchTrueFalseTotal
if (macroblock_modes & MACROBLOCK_MOTION_FORWARD) { 0 0 0
83 0 macroblock_modes |= UBITS (bit_buf, 2) << MOTION_TYPE_SHIFT;
84 0 DUMPBITS (bit_buf, bits, 2);
85 }
86 0 ▶ if (macroblock_modes & (MACROBLOCK_INTRA | MACROBLOCK_PATTERN)) {
Branch: 1 branch
BranchTrueFalseTotal
if (macroblock_modes & (MACROBLOCK_INTRA | MACROBLOCK_PATTERN)) { 0 0 0
87 0 macroblock_modes |= UBITS (bit_buf, 1) * DCT_TYPE_INTERLACED;
88 0 DUMPBITS (bit_buf, bits, 1);
89 }
90 0 return macroblock_modes | MACROBLOCK_MOTION_FORWARD;
91 }
92  
93 0 case B_TYPE:
94  
95 0 tab = MB_B + UBITS (bit_buf, 6);
96 0 DUMPBITS (bit_buf, bits, tab->len);
97 0 macroblock_modes = tab->modes;
98  
99 0 ▶ if (decoder->picture_structure != FRAME_PICTURE) {
Branch: 1 branch
BranchTrueFalseTotal
if (decoder->picture_structure != FRAME_PICTURE) { 0 0 0
100 0 ▶ if (! (macroblock_modes & MACROBLOCK_INTRA)) {
Branch: 1 branch
BranchTrueFalseTotal
if (! (macroblock_modes & MACROBLOCK_INTRA)) { 0 0 0
101 0 macroblock_modes |= UBITS (bit_buf, 2) << MOTION_TYPE_SHIFT;
102 0 DUMPBITS (bit_buf, bits, 2);
103 }
104 0 return macroblock_modes;
105 0 ▶ } else if (decoder->frame_pred_frame_dct) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (decoder->frame_pred_frame_dct) { 0 0 0
106 /* if (! (macroblock_modes & MACROBLOCK_INTRA)) */
107 0 macroblock_modes |= MC_FRAME << MOTION_TYPE_SHIFT;
108 0 return macroblock_modes;
109 } else {
110 0 ▶ if (macroblock_modes & MACROBLOCK_INTRA)
Branch: 1 branch
BranchTrueFalseTotal
if (macroblock_modes & MACROBLOCK_INTRA) 0 0 0
111 0 goto intra;
112 0 macroblock_modes |= UBITS (bit_buf, 2) << MOTION_TYPE_SHIFT;
113 0 DUMPBITS (bit_buf, bits, 2);
114 0 ▶ if (macroblock_modes & (MACROBLOCK_INTRA | MACROBLOCK_PATTERN)) {
Branch: 1 branch
BranchTrueFalseTotal
if (macroblock_modes & (MACROBLOCK_INTRA | MACROBLOCK_PATTERN)) { 0 0 0
115 0 intra:
116 0 macroblock_modes |= UBITS (bit_buf, 1) * DCT_TYPE_INTERLACED;
117 0 DUMPBITS (bit_buf, bits, 1);
118 }
119 0 return macroblock_modes;
120 }
121  
122 0 case D_TYPE:
123  
124 0 DUMPBITS (bit_buf, bits, 1);
125 0 return MACROBLOCK_INTRA;
126  
127 0 default:
128 0 return 0;
129 }
130 #undef bit_buf
131 #undef bits
132 #undef bit_ptr
133 }
134  
135 0 static inline void get_quantizer_scale (mpeg2_decoder_t * const decoder)
136 {
137 #define bit_buf (decoder->bitstream_buf)
138 #define bits (decoder->bitstream_bits)
139 #define bit_ptr (decoder->bitstream_ptr)
140  
141 int quantizer_scale_code;
142  
143 0 quantizer_scale_code = UBITS (bit_buf, 5);
144 0 DUMPBITS (bit_buf, bits, 5);
145  
146 0 decoder->quantizer_matrix[0] =
147 0 decoder->quantizer_prescale[0][quantizer_scale_code];
148 0 decoder->quantizer_matrix[1] =
149 0 decoder->quantizer_prescale[1][quantizer_scale_code];
150 0 decoder->quantizer_matrix[2] =
151 0 decoder->chroma_quantizer[0][quantizer_scale_code];
152 0 decoder->quantizer_matrix[3] =
153 0 decoder->chroma_quantizer[1][quantizer_scale_code];
154 #undef bit_buf
155 #undef bits
156 #undef bit_ptr
157 0 }
158  
159 0 static inline int get_motion_delta (mpeg2_decoder_t * const decoder,
160 const int f_code)
161 {
162 #define bit_buf (decoder->bitstream_buf)
163 #define bits (decoder->bitstream_bits)
164 #define bit_ptr (decoder->bitstream_ptr)
165  
166 int delta;
167 int sign;
168 const MVtab * tab;
169  
170 0 ▶ if (bit_buf & 0x80000000) {
Branch: 1 branch
BranchTrueFalseTotal
if (bit_buf & 0x80000000) { 0 0 0
171 0 DUMPBITS (bit_buf, bits, 1);
172 0 return 0;
173 0 ▶ } else if (bit_buf >= 0x0c000000) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (bit_buf >= 0x0c000000) { 0 0 0
174  
175 0 tab = MV_4 + UBITS (bit_buf, 4);
176 0 delta = (tab->delta << f_code) + 1;
177 0 bits += tab->len + f_code + 1;
178 0 bit_buf <<= tab->len;
179  
180 0 sign = SBITS (bit_buf, 1);
181 0 bit_buf <<= 1;
182  
183 0 ▶ if (f_code)
Branch: 1 branch
BranchTrueFalseTotal
if (f_code) 0 0 0
184 0 delta += UBITS (bit_buf, f_code);
185 0 bit_buf <<= f_code;
186  
187 0 return (delta ^ sign) - sign;
188  
189 } else {
190  
191 0 tab = MV_10 + UBITS (bit_buf, 10);
192 0 delta = (tab->delta << f_code) + 1;
193 0 bits += tab->len + 1;
194 0 bit_buf <<= tab->len;
195  
196 0 sign = SBITS (bit_buf, 1);
197 0 bit_buf <<= 1;
198  
199 0 ▶ if (f_code) {
Branch: 1 branch
BranchTrueFalseTotal
if (f_code) { 0 0 0
200 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
201 0 delta += UBITS (bit_buf, f_code);
202 0 DUMPBITS (bit_buf, bits, f_code);
203 }
204  
205 0 return (delta ^ sign) - sign;
206  
207 }
208 #undef bit_buf
209 #undef bits
210 #undef bit_ptr
211 }
212  
213 0 static inline int bound_motion_vector (const int vector, const int f_code)
214 {
215 0 return ((int32_t)vector << (27 - f_code)) >> (27 - f_code);
216 }
217  
218 0 static inline int get_dmv (mpeg2_decoder_t * const decoder)
219 {
220 #define bit_buf (decoder->bitstream_buf)
221 #define bits (decoder->bitstream_bits)
222 #define bit_ptr (decoder->bitstream_ptr)
223  
224 const DMVtab * tab;
225  
226 0 tab = DMV_2 + UBITS (bit_buf, 2);
227 0 DUMPBITS (bit_buf, bits, tab->len);
228 0 return tab->dmv;
229 #undef bit_buf
230 #undef bits
231 #undef bit_ptr
232 }
233  
234 0 static inline int get_coded_block_pattern (mpeg2_decoder_t * const decoder)
235 {
236 #define bit_buf (decoder->bitstream_buf)
237 #define bits (decoder->bitstream_bits)
238 #define bit_ptr (decoder->bitstream_ptr)
239  
240 const CBPtab * tab;
241  
242 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
243  
244 0 ▶ if (bit_buf >= 0x20000000) {
Branch: 1 branch
BranchTrueFalseTotal
if (bit_buf >= 0x20000000) { 0 0 0
245  
246 0 tab = CBP_7 + (UBITS (bit_buf, 7) - 16);
247 0 DUMPBITS (bit_buf, bits, tab->len);
248 0 return tab->cbp;
249  
250 } else {
251  
252 0 tab = CBP_9 + UBITS (bit_buf, 9);
253 0 DUMPBITS (bit_buf, bits, tab->len);
254 0 return tab->cbp;
255 }
256  
257 #undef bit_buf
258 #undef bits
259 #undef bit_ptr
260 }
261  
262 0 static inline int get_luma_dc_dct_diff (mpeg2_decoder_t * const decoder)
263 {
264 #define bit_buf (decoder->bitstream_buf)
265 #define bits (decoder->bitstream_bits)
266 #define bit_ptr (decoder->bitstream_ptr)
267 const DCtab * tab;
268 int size;
269 int dc_diff;
270  
271 0 ▶ if (bit_buf < 0xf8000000) {
Branch: 1 branch
BranchTrueFalseTotal
if (bit_buf < 0xf8000000) { 0 0 0
272 0 tab = DC_lum_5 + UBITS (bit_buf, 5);
273 0 size = tab->size;
274 0 ▶ if (size) {
Branch: 1 branch
BranchTrueFalseTotal
if (size) { 0 0 0
275 0 bits += tab->len + size;
276 0 bit_buf <<= tab->len;
277 0 dc_diff =
278 0 UBITS (bit_buf, size) - UBITS (SBITS (~bit_buf, 1), size);
279 0 bit_buf <<= size;
280 0 return dc_diff << decoder->intra_dc_precision;
281 } else {
282 0 DUMPBITS (bit_buf, bits, 3);
283 0 return 0;
284 }
285 } else {
286 0 tab = DC_long + (UBITS (bit_buf, 9) - 0x1e0);
287 0 size = tab->size;
288 0 DUMPBITS (bit_buf, bits, tab->len);
289 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
290 0 dc_diff = UBITS (bit_buf, size) - UBITS (SBITS (~bit_buf, 1), size);
291 0 DUMPBITS (bit_buf, bits, size);
292 0 return dc_diff << decoder->intra_dc_precision;
293 }
294 #undef bit_buf
295 #undef bits
296 #undef bit_ptr
297 }
298  
299 0 static inline int get_chroma_dc_dct_diff (mpeg2_decoder_t * const decoder)
300 {
301 #define bit_buf (decoder->bitstream_buf)
302 #define bits (decoder->bitstream_bits)
303 #define bit_ptr (decoder->bitstream_ptr)
304 const DCtab * tab;
305 int size;
306 int dc_diff;
307  
308 0 ▶ if (bit_buf < 0xf8000000) {
Branch: 1 branch
BranchTrueFalseTotal
if (bit_buf < 0xf8000000) { 0 0 0
309 0 tab = DC_chrom_5 + UBITS (bit_buf, 5);
310 0 size = tab->size;
311 0 ▶ if (size) {
Branch: 1 branch
BranchTrueFalseTotal
if (size) { 0 0 0
312 0 bits += tab->len + size;
313 0 bit_buf <<= tab->len;
314 0 dc_diff =
315 0 UBITS (bit_buf, size) - UBITS (SBITS (~bit_buf, 1), size);
316 0 bit_buf <<= size;
317 0 return dc_diff << decoder->intra_dc_precision;
318 } else {
319 0 DUMPBITS (bit_buf, bits, 2);
320 0 return 0;
321 }
322 } else {
323 0 tab = DC_long + (UBITS (bit_buf, 10) - 0x3e0);
324 0 size = tab->size;
325 0 DUMPBITS (bit_buf, bits, tab->len + 1);
326 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
327 0 dc_diff = UBITS (bit_buf, size) - UBITS (SBITS (~bit_buf, 1), size);
328 0 DUMPBITS (bit_buf, bits, size);
329 0 return dc_diff << decoder->intra_dc_precision;
330 }
331 #undef bit_buf
332 #undef bits
333 #undef bit_ptr
334 }
335  
336 #define SATURATE(val) \
337 do { \
338 val <<= 4; \
339 if (unlikely (val != (int16_t) val)) \
340 val = (SBITS (val, 1) ^ 2047) << 4; \
341 } while (0)
342  
343 0 static void get_intra_block_B14 (mpeg2_decoder_t * const decoder,
344 const uint16_t * const quant_matrix)
345 {
346 int i;
347 int j;
348 int val;
349 0 const uint8_t * const scan = decoder->scan;
350 int mismatch;
351 const DCTtab * tab;
352 uint32_t bit_buf;
353 int bits;
354 const uint8_t * bit_ptr;
355 0 int16_t * const dest = decoder->DCTblock;
356  
357 0 i = 0;
358 0 mismatch = ~dest[0];
359  
360 0 bit_buf = decoder->bitstream_buf;
361 0 bits = decoder->bitstream_bits;
362 0 bit_ptr = decoder->bitstream_ptr;
363  
364 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
365  
366 while (1) {
367 0 ▶ if (bit_buf >= 0x28000000) {
Branch: 1 branch
BranchTrueFalseTotal
if (bit_buf >= 0x28000000) { 0 0 0
368  
369 0 tab = DCT_B14AC_5 + (UBITS (bit_buf, 5) - 5);
370  
371 0 i += tab->run;
372 0 ▶ if (i >= 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i >= 64) 0 0 0
373 0 break; /* end of block */
374  
375 0 normal_code:
376 0 j = scan[i];
377 0 bit_buf <<= tab->len;
378 0 bits += tab->len + 1;
379 0 val = (tab->level * quant_matrix[j]) >> 4;
380  
381 /* if (bitstream_get (1)) val = -val; */
382 0 val = (val ^ SBITS (bit_buf, 1)) - SBITS (bit_buf, 1);
383  
384 0 ▶ SATURATE (val);
Branch: 1 branch
BranchTrueFalseTotal
SATURATE (val); 0 0 0
385 0 dest[j] = val;
386 0 mismatch ^= val;
387  
388 0 bit_buf <<= 1;
389 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
390  
391 0 continue;
392  
393 0 ▶ } else if (bit_buf >= 0x04000000) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (bit_buf >= 0x04000000) { 0 0 0
394  
395 0 tab = DCT_B14_8 + (UBITS (bit_buf, 8) - 4);
396  
397 0 i += tab->run;
398 0 ▶ if (i < 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i < 64) 0 0 0
399 0 goto normal_code;
400  
401 /* escape code */
402  
403 0 i += UBITS (bit_buf << 6, 6) - 64;
404 0 ▶ if (i >= 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i >= 64) 0 0 0
405 0 break; /* illegal, check needed to avoid buffer overflow */
406  
407 0 j = scan[i];
408  
409 0 DUMPBITS (bit_buf, bits, 12);
410 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
411 0 val = (SBITS (bit_buf, 12) * quant_matrix[j]) / 16;
412  
413 0 ▶ SATURATE (val);
Branch: 1 branch
BranchTrueFalseTotal
SATURATE (val); 0 0 0
414 0 dest[j] = val;
415 0 mismatch ^= val;
416  
417 0 DUMPBITS (bit_buf, bits, 12);
418 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
419  
420 0 continue;
421  
422 0 ▶ } else if (bit_buf >= 0x02000000) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (bit_buf >= 0x02000000) { 0 0 0
423 0 tab = DCT_B14_10 + (UBITS (bit_buf, 10) - 8);
424 0 i += tab->run;
425 0 ▶ if (i < 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i < 64) 0 0 0
426 0 goto normal_code;
427 0 ▶ } else if (bit_buf >= 0x00800000) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (bit_buf >= 0x00800000) { 0 0 0
428 0 tab = DCT_13 + (UBITS (bit_buf, 13) - 16);
429 0 i += tab->run;
430 0 ▶ if (i < 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i < 64) 0 0 0
431 0 goto normal_code;
432 0 ▶ } else if (bit_buf >= 0x00200000) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (bit_buf >= 0x00200000) { 0 0 0
433 0 tab = DCT_15 + (UBITS (bit_buf, 15) - 16);
434 0 i += tab->run;
435 0 ▶ if (i < 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i < 64) 0 0 0
436 0 goto normal_code;
437 } else {
438 0 tab = DCT_16 + UBITS (bit_buf, 16);
439 0 bit_buf <<= 16;
440 0 GETWORD (bit_buf, bits + 16, bit_ptr);
441 0 i += tab->run;
442 0 ▶ if (i < 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i < 64) 0 0 0
443 0 goto normal_code;
444 }
445 0 break; /* illegal, check needed to avoid buffer overflow */
446 }
447 0 dest[63] ^= mismatch & 16;
448 0 DUMPBITS (bit_buf, bits, tab->len); /* dump end of block code */
449 0 decoder->bitstream_buf = bit_buf;
450 0 decoder->bitstream_bits = bits;
451 0 decoder->bitstream_ptr = bit_ptr;
452 0 }
453  
454 0 static void get_intra_block_B15 (mpeg2_decoder_t * const decoder,
455 const uint16_t * const quant_matrix)
456 {
457 int i;
458 int j;
459 int val;
460 0 const uint8_t * const scan = decoder->scan;
461 int mismatch;
462 const DCTtab * tab;
463 uint32_t bit_buf;
464 int bits;
465 const uint8_t * bit_ptr;
466 0 int16_t * const dest = decoder->DCTblock;
467  
468 0 i = 0;
469 0 mismatch = ~dest[0];
470  
471 0 bit_buf = decoder->bitstream_buf;
472 0 bits = decoder->bitstream_bits;
473 0 bit_ptr = decoder->bitstream_ptr;
474  
475 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
476  
477 while (1) {
478 0 ▶ if (bit_buf >= 0x04000000) {
Branch: 1 branch
BranchTrueFalseTotal
if (bit_buf >= 0x04000000) { 0 0 0
479  
480 0 tab = DCT_B15_8 + (UBITS (bit_buf, 8) - 4);
481  
482 0 i += tab->run;
483 0 ▶ if (i < 64) {
Branch: 1 branch
BranchTrueFalseTotal
if (i < 64) { 0 0 0
484  
485 0 normal_code:
486 0 j = scan[i];
487 0 bit_buf <<= tab->len;
488 0 bits += tab->len + 1;
489 0 val = (tab->level * quant_matrix[j]) >> 4;
490  
491 /* if (bitstream_get (1)) val = -val; */
492 0 val = (val ^ SBITS (bit_buf, 1)) - SBITS (bit_buf, 1);
493  
494 0 ▶ SATURATE (val);
Branch: 1 branch
BranchTrueFalseTotal
SATURATE (val); 0 0 0
495 0 dest[j] = val;
496 0 mismatch ^= val;
497  
498 0 bit_buf <<= 1;
499 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
500  
501 0 continue;
502  
503 } else {
504  
505 /* end of block. I commented out this code because if we */
506 /* do not exit here we will still exit at the later test :) */
507  
508 /* if (i >= 128) break; */ /* end of block */
509  
510 /* escape code */
511  
512 0 i += UBITS (bit_buf << 6, 6) - 64;
513 0 ▶ if (i >= 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i >= 64) 0 0 0
514 0 break; /* illegal, check against buffer overflow */
515  
516 0 j = scan[i];
517  
518 0 DUMPBITS (bit_buf, bits, 12);
519 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
520 0 val = (SBITS (bit_buf, 12) * quant_matrix[j]) / 16;
521  
522 0 ▶ SATURATE (val);
Branch: 1 branch
BranchTrueFalseTotal
SATURATE (val); 0 0 0
523 0 dest[j] = val;
524 0 mismatch ^= val;
525  
526 0 DUMPBITS (bit_buf, bits, 12);
527 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
528  
529 0 continue;
530  
531 }
532 0 ▶ } else if (bit_buf >= 0x02000000) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (bit_buf >= 0x02000000) { 0 0 0
533 0 tab = DCT_B15_10 + (UBITS (bit_buf, 10) - 8);
534 0 i += tab->run;
535 0 ▶ if (i < 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i < 64) 0 0 0
536 0 goto normal_code;
537 0 ▶ } else if (bit_buf >= 0x00800000) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (bit_buf >= 0x00800000) { 0 0 0
538 0 tab = DCT_13 + (UBITS (bit_buf, 13) - 16);
539 0 i += tab->run;
540 0 ▶ if (i < 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i < 64) 0 0 0
541 0 goto normal_code;
542 0 ▶ } else if (bit_buf >= 0x00200000) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (bit_buf >= 0x00200000) { 0 0 0
543 0 tab = DCT_15 + (UBITS (bit_buf, 15) - 16);
544 0 i += tab->run;
545 0 ▶ if (i < 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i < 64) 0 0 0
546 0 goto normal_code;
547 } else {
548 0 tab = DCT_16 + UBITS (bit_buf, 16);
549 0 bit_buf <<= 16;
550 0 GETWORD (bit_buf, bits + 16, bit_ptr);
551 0 i += tab->run;
552 0 ▶ if (i < 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i < 64) 0 0 0
553 0 goto normal_code;
554 }
555 0 break; /* illegal, check needed to avoid buffer overflow */
556 }
557 0 dest[63] ^= mismatch & 16;
558 0 DUMPBITS (bit_buf, bits, tab->len); /* dump end of block code */
559 0 decoder->bitstream_buf = bit_buf;
560 0 decoder->bitstream_bits = bits;
561 0 decoder->bitstream_ptr = bit_ptr;
562 0 }
563  
564 0 static int get_non_intra_block (mpeg2_decoder_t * const decoder,
565 const uint16_t * const quant_matrix)
566 {
567 int i;
568 int j;
569 int val;
570 0 const uint8_t * const scan = decoder->scan;
571 int mismatch;
572 const DCTtab * tab;
573 uint32_t bit_buf;
574 int bits;
575 const uint8_t * bit_ptr;
576 0 int16_t * const dest = decoder->DCTblock;
577  
578 0 i = -1;
579 0 mismatch = -1;
580  
581 0 bit_buf = decoder->bitstream_buf;
582 0 bits = decoder->bitstream_bits;
583 0 bit_ptr = decoder->bitstream_ptr;
584  
585 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
586 0 ▶ if (bit_buf >= 0x28000000) {
Branch: 1 branch
BranchTrueFalseTotal
if (bit_buf >= 0x28000000) { 0 0 0
587 0 tab = DCT_B14DC_5 + (UBITS (bit_buf, 5) - 5);
588 0 goto entry_1;
589 } else
590 0 goto entry_2;
591  
592 while (1) {
593 0 ▶ if (bit_buf >= 0x28000000) {
Branch: 1 branch
BranchTrueFalseTotal
if (bit_buf >= 0x28000000) { 0 0 0
594  
595 0 tab = DCT_B14AC_5 + (UBITS (bit_buf, 5) - 5);
596  
597 0 entry_1:
598 0 i += tab->run;
599 0 ▶ if (i >= 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i >= 64) 0 0 0
600 0 break; /* end of block */
601  
602 0 normal_code:
603 0 j = scan[i];
604 0 bit_buf <<= tab->len;
605 0 bits += tab->len + 1;
606 0 val = ((2 * tab->level + 1) * quant_matrix[j]) >> 5;
607  
608 /* if (bitstream_get (1)) val = -val; */
609 0 val = (val ^ SBITS (bit_buf, 1)) - SBITS (bit_buf, 1);
610  
611 0 ▶ SATURATE (val);
Branch: 1 branch
BranchTrueFalseTotal
SATURATE (val); 0 0 0
612 0 dest[j] = val;
613 0 mismatch ^= val;
614  
615 0 bit_buf <<= 1;
616 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
617  
618 0 continue;
619  
620 }
621  
622 0 entry_2:
623 0 ▶ if (bit_buf >= 0x04000000) {
Branch: 1 branch
BranchTrueFalseTotal
if (bit_buf >= 0x04000000) { 0 0 0
624  
625 0 tab = DCT_B14_8 + (UBITS (bit_buf, 8) - 4);
626  
627 0 i += tab->run;
628 0 ▶ if (i < 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i < 64) 0 0 0
629 0 goto normal_code;
630  
631 /* escape code */
632  
633 0 i += UBITS (bit_buf << 6, 6) - 64;
634 0 ▶ if (i >= 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i >= 64) 0 0 0
635 0 break; /* illegal, check needed to avoid buffer overflow */
636  
637 0 j = scan[i];
638  
639 0 DUMPBITS (bit_buf, bits, 12);
640 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
641 0 val = 2 * (SBITS (bit_buf, 12) + SBITS (bit_buf, 1)) + 1;
642 0 val = (val * quant_matrix[j]) / 32;
643  
644 0 ▶ SATURATE (val);
Branch: 1 branch
BranchTrueFalseTotal
SATURATE (val); 0 0 0
645 0 dest[j] = val;
646 0 mismatch ^= val;
647  
648 0 DUMPBITS (bit_buf, bits, 12);
649 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
650  
651 0 continue;
652  
653 0 ▶ } else if (bit_buf >= 0x02000000) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (bit_buf >= 0x02000000) { 0 0 0
654 0 tab = DCT_B14_10 + (UBITS (bit_buf, 10) - 8);
655 0 i += tab->run;
656 0 ▶ if (i < 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i < 64) 0 0 0
657 0 goto normal_code;
658 0 ▶ } else if (bit_buf >= 0x00800000) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (bit_buf >= 0x00800000) { 0 0 0
659 0 tab = DCT_13 + (UBITS (bit_buf, 13) - 16);
660 0 i += tab->run;
661 0 ▶ if (i < 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i < 64) 0 0 0
662 0 goto normal_code;
663 0 ▶ } else if (bit_buf >= 0x00200000) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (bit_buf >= 0x00200000) { 0 0 0
664 0 tab = DCT_15 + (UBITS (bit_buf, 15) - 16);
665 0 i += tab->run;
666 0 ▶ if (i < 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i < 64) 0 0 0
667 0 goto normal_code;
668 } else {
669 0 tab = DCT_16 + UBITS (bit_buf, 16);
670 0 bit_buf <<= 16;
671 0 GETWORD (bit_buf, bits + 16, bit_ptr);
672 0 i += tab->run;
673 0 ▶ if (i < 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i < 64) 0 0 0
674 0 goto normal_code;
675 }
676 0 break; /* illegal, check needed to avoid buffer overflow */
677 }
678 0 dest[63] ^= mismatch & 16;
679 0 DUMPBITS (bit_buf, bits, tab->len); /* dump end of block code */
680 0 decoder->bitstream_buf = bit_buf;
681 0 decoder->bitstream_bits = bits;
682 0 decoder->bitstream_ptr = bit_ptr;
683 0 return i;
684 }
685  
686 0 static void get_mpeg1_intra_block (mpeg2_decoder_t * const decoder)
687 {
688 int i;
689 int j;
690 int val;
691 0 const uint8_t * const scan = decoder->scan;
692 0 const uint16_t * const quant_matrix = decoder->quantizer_matrix[0];
693 const DCTtab * tab;
694 uint32_t bit_buf;
695 int bits;
696 const uint8_t * bit_ptr;
697 0 int16_t * const dest = decoder->DCTblock;
698  
699 0 i = 0;
700  
701 0 bit_buf = decoder->bitstream_buf;
702 0 bits = decoder->bitstream_bits;
703 0 bit_ptr = decoder->bitstream_ptr;
704  
705 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
706  
707 while (1) {
708 0 ▶ if (bit_buf >= 0x28000000) {
Branch: 1 branch
BranchTrueFalseTotal
if (bit_buf >= 0x28000000) { 0 0 0
709  
710 0 tab = DCT_B14AC_5 + (UBITS (bit_buf, 5) - 5);
711  
712 0 i += tab->run;
713 0 ▶ if (i >= 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i >= 64) 0 0 0
714 0 break; /* end of block */
715  
716 0 normal_code:
717 0 j = scan[i];
718 0 bit_buf <<= tab->len;
719 0 bits += tab->len + 1;
720 0 val = (tab->level * quant_matrix[j]) >> 4;
721  
722 /* oddification */
723 0 val = (val - 1) | 1;
724  
725 /* if (bitstream_get (1)) val = -val; */
726 0 val = (val ^ SBITS (bit_buf, 1)) - SBITS (bit_buf, 1);
727  
728 0 ▶ SATURATE (val);
Branch: 1 branch
BranchTrueFalseTotal
SATURATE (val); 0 0 0
729 0 dest[j] = val;
730  
731 0 bit_buf <<= 1;
732 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
733  
734 0 continue;
735  
736 0 ▶ } else if (bit_buf >= 0x04000000) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (bit_buf >= 0x04000000) { 0 0 0
737  
738 0 tab = DCT_B14_8 + (UBITS (bit_buf, 8) - 4);
739  
740 0 i += tab->run;
741 0 ▶ if (i < 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i < 64) 0 0 0
742 0 goto normal_code;
743  
744 /* escape code */
745  
746 0 i += UBITS (bit_buf << 6, 6) - 64;
747 0 ▶ if (i >= 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i >= 64) 0 0 0
748 0 break; /* illegal, check needed to avoid buffer overflow */
749  
750 0 j = scan[i];
751  
752 0 DUMPBITS (bit_buf, bits, 12);
753 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
754 0 val = SBITS (bit_buf, 8);
755 0 ▶ if (! (val & 0x7f)) {
Branch: 1 branch
BranchTrueFalseTotal
if (! (val & 0x7f)) { 0 0 0
756 0 DUMPBITS (bit_buf, bits, 8);
757 0 val = UBITS (bit_buf, 8) + 2 * val;
758 }
759 0 val = (val * quant_matrix[j]) / 16;
760  
761 /* oddification */
762 0 val = (val + ~SBITS (val, 1)) | 1;
763  
764 0 ▶ SATURATE (val);
Branch: 1 branch
BranchTrueFalseTotal
SATURATE (val); 0 0 0
765 0 dest[j] = val;
766  
767 0 DUMPBITS (bit_buf, bits, 8);
768 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
769  
770 0 continue;
771  
772 0 ▶ } else if (bit_buf >= 0x02000000) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (bit_buf >= 0x02000000) { 0 0 0
773 0 tab = DCT_B14_10 + (UBITS (bit_buf, 10) - 8);
774 0 i += tab->run;
775 0 ▶ if (i < 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i < 64) 0 0 0
776 0 goto normal_code;
777 0 ▶ } else if (bit_buf >= 0x00800000) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (bit_buf >= 0x00800000) { 0 0 0
778 0 tab = DCT_13 + (UBITS (bit_buf, 13) - 16);
779 0 i += tab->run;
780 0 ▶ if (i < 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i < 64) 0 0 0
781 0 goto normal_code;
782 0 ▶ } else if (bit_buf >= 0x00200000) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (bit_buf >= 0x00200000) { 0 0 0
783 0 tab = DCT_15 + (UBITS (bit_buf, 15) - 16);
784 0 i += tab->run;
785 0 ▶ if (i < 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i < 64) 0 0 0
786 0 goto normal_code;
787 } else {
788 0 tab = DCT_16 + UBITS (bit_buf, 16);
789 0 bit_buf <<= 16;
790 0 GETWORD (bit_buf, bits + 16, bit_ptr);
791 0 i += tab->run;
792 0 ▶ if (i < 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i < 64) 0 0 0
793 0 goto normal_code;
794 }
795 0 break; /* illegal, check needed to avoid buffer overflow */
796 }
797 0 DUMPBITS (bit_buf, bits, tab->len); /* dump end of block code */
798 0 decoder->bitstream_buf = bit_buf;
799 0 decoder->bitstream_bits = bits;
800 0 decoder->bitstream_ptr = bit_ptr;
801 0 }
802  
803 0 static int get_mpeg1_non_intra_block (mpeg2_decoder_t * const decoder)
804 {
805 int i;
806 int j;
807 int val;
808 0 const uint8_t * const scan = decoder->scan;
809 0 const uint16_t * const quant_matrix = decoder->quantizer_matrix[1];
810 const DCTtab * tab;
811 uint32_t bit_buf;
812 int bits;
813 const uint8_t * bit_ptr;
814 0 int16_t * const dest = decoder->DCTblock;
815  
816 0 i = -1;
817  
818 0 bit_buf = decoder->bitstream_buf;
819 0 bits = decoder->bitstream_bits;
820 0 bit_ptr = decoder->bitstream_ptr;
821  
822 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
823 0 ▶ if (bit_buf >= 0x28000000) {
Branch: 1 branch
BranchTrueFalseTotal
if (bit_buf >= 0x28000000) { 0 0 0
824 0 tab = DCT_B14DC_5 + (UBITS (bit_buf, 5) - 5);
825 0 goto entry_1;
826 } else
827 0 goto entry_2;
828  
829 while (1) {
830 0 ▶ if (bit_buf >= 0x28000000) {
Branch: 1 branch
BranchTrueFalseTotal
if (bit_buf >= 0x28000000) { 0 0 0
831  
832 0 tab = DCT_B14AC_5 + (UBITS (bit_buf, 5) - 5);
833  
834 0 entry_1:
835 0 i += tab->run;
836 0 ▶ if (i >= 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i >= 64) 0 0 0
837 0 break; /* end of block */
838  
839 0 normal_code:
840 0 j = scan[i];
841 0 bit_buf <<= tab->len;
842 0 bits += tab->len + 1;
843 0 val = ((2 * tab->level + 1) * quant_matrix[j]) >> 5;
844  
845 /* oddification */
846 0 val = (val - 1) | 1;
847  
848 /* if (bitstream_get (1)) val = -val; */
849 0 val = (val ^ SBITS (bit_buf, 1)) - SBITS (bit_buf, 1);
850  
851 0 ▶ SATURATE (val);
Branch: 1 branch
BranchTrueFalseTotal
SATURATE (val); 0 0 0
852 0 dest[j] = val;
853  
854 0 bit_buf <<= 1;
855 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
856  
857 0 continue;
858  
859 }
860  
861 0 entry_2:
862 0 ▶ if (bit_buf >= 0x04000000) {
Branch: 1 branch
BranchTrueFalseTotal
if (bit_buf >= 0x04000000) { 0 0 0
863  
864 0 tab = DCT_B14_8 + (UBITS (bit_buf, 8) - 4);
865  
866 0 i += tab->run;
867 0 ▶ if (i < 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i < 64) 0 0 0
868 0 goto normal_code;
869  
870 /* escape code */
871  
872 0 i += UBITS (bit_buf << 6, 6) - 64;
873 0 ▶ if (i >= 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i >= 64) 0 0 0
874 0 break; /* illegal, check needed to avoid buffer overflow */
875  
876 0 j = scan[i];
877  
878 0 DUMPBITS (bit_buf, bits, 12);
879 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
880 0 val = SBITS (bit_buf, 8);
881 0 ▶ if (! (val & 0x7f)) {
Branch: 1 branch
BranchTrueFalseTotal
if (! (val & 0x7f)) { 0 0 0
882 0 DUMPBITS (bit_buf, bits, 8);
883 0 val = UBITS (bit_buf, 8) + 2 * val;
884 }
885 0 val = 2 * (val + SBITS (val, 1)) + 1;
886 0 val = (val * quant_matrix[j]) / 32;
887  
888 /* oddification */
889 0 val = (val + ~SBITS (val, 1)) | 1;
890  
891 0 ▶ SATURATE (val);
Branch: 1 branch
BranchTrueFalseTotal
SATURATE (val); 0 0 0
892 0 dest[j] = val;
893  
894 0 DUMPBITS (bit_buf, bits, 8);
895 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
896  
897 0 continue;
898  
899 0 ▶ } else if (bit_buf >= 0x02000000) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (bit_buf >= 0x02000000) { 0 0 0
900 0 tab = DCT_B14_10 + (UBITS (bit_buf, 10) - 8);
901 0 i += tab->run;
902 0 ▶ if (i < 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i < 64) 0 0 0
903 0 goto normal_code;
904 0 ▶ } else if (bit_buf >= 0x00800000) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (bit_buf >= 0x00800000) { 0 0 0
905 0 tab = DCT_13 + (UBITS (bit_buf, 13) - 16);
906 0 i += tab->run;
907 0 ▶ if (i < 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i < 64) 0 0 0
908 0 goto normal_code;
909 0 ▶ } else if (bit_buf >= 0x00200000) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (bit_buf >= 0x00200000) { 0 0 0
910 0 tab = DCT_15 + (UBITS (bit_buf, 15) - 16);
911 0 i += tab->run;
912 0 ▶ if (i < 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i < 64) 0 0 0
913 0 goto normal_code;
914 } else {
915 0 tab = DCT_16 + UBITS (bit_buf, 16);
916 0 bit_buf <<= 16;
917 0 GETWORD (bit_buf, bits + 16, bit_ptr);
918 0 i += tab->run;
919 0 ▶ if (i < 64)
Branch: 1 branch
BranchTrueFalseTotal
if (i < 64) 0 0 0
920 0 goto normal_code;
921 }
922 0 break; /* illegal, check needed to avoid buffer overflow */
923 }
924 0 DUMPBITS (bit_buf, bits, tab->len); /* dump end of block code */
925 0 decoder->bitstream_buf = bit_buf;
926 0 decoder->bitstream_bits = bits;
927 0 decoder->bitstream_ptr = bit_ptr;
928 0 return i;
929 }
930  
931 0 static inline void slice_intra_DCT (mpeg2_decoder_t * const decoder,
932 const int cc,
933 uint8_t * const dest, const int stride)
934 {
935 #define bit_buf (decoder->bitstream_buf)
936 #define bits (decoder->bitstream_bits)
937 #define bit_ptr (decoder->bitstream_ptr)
938 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
939 /* Get the intra DC coefficient and inverse quantize it */
940 0 ▶ if (cc == 0)
Branch: 1 branch
BranchTrueFalseTotal
if (cc == 0) 0 0 0
941 0 decoder->DCTblock[0] =
942 0 decoder->dc_dct_pred[0] += get_luma_dc_dct_diff (decoder);
943 else
944 0 decoder->DCTblock[0] =
945 0 decoder->dc_dct_pred[cc] += get_chroma_dc_dct_diff (decoder);
946  
947 0 ▶ if (decoder->mpeg1) {
Branch: 1 branch
BranchTrueFalseTotal
if (decoder->mpeg1) { 0 0 0
948 0 ▶ if (decoder->coding_type != D_TYPE)
Branch: 1 branch
BranchTrueFalseTotal
if (decoder->coding_type != D_TYPE) 0 0 0
949 0 get_mpeg1_intra_block (decoder);
950 0 ▶ } else if (decoder->intra_vlc_format)
Branch: 1 branch
BranchTrueFalseTotal
} else if (decoder->intra_vlc_format) 0 0 0
951 0 ▶ get_intra_block_B15 (decoder, decoder->quantizer_matrix[cc ? 2 : 0]);
Branch: 1 branch
BranchTrueFalseTotal
get_intra_block_B15 (decoder, decoder->quantizer_matrix[cc ? 2 : 0]); 0 0 0
952 else
953 0 ▶ get_intra_block_B14 (decoder, decoder->quantizer_matrix[cc ? 2 : 0]);
Branch: 1 branch
BranchTrueFalseTotal
get_intra_block_B14 (decoder, decoder->quantizer_matrix[cc ? 2 : 0]); 0 0 0
954 0 mpeg2_idct_copy (decoder->DCTblock, dest, stride);
955 #undef bit_buf
956 #undef bits
957 #undef bit_ptr
958 0 }
959  
960 0 static inline void slice_non_intra_DCT (mpeg2_decoder_t * const decoder,
961 const int cc,
962 uint8_t * const dest, const int stride)
963 {
964 int last;
965  
966 0 ▶ if (decoder->mpeg1)
Branch: 1 branch
BranchTrueFalseTotal
if (decoder->mpeg1) 0 0 0
967 0 last = get_mpeg1_non_intra_block (decoder);
968 else
969 0 last = get_non_intra_block (decoder,
970 0 ▶ decoder->quantizer_matrix[cc ? 3 : 1]);
Branch: 1 branch
BranchTrueFalseTotal
decoder->quantizer_matrix[cc ? 3 : 1]); 0 0 0
971 0 mpeg2_idct_add (last, decoder->DCTblock, dest, stride);
972 0 }
973  
974 #define MOTION_420(table,ref,motion_x,motion_y,size,y) \
975 pos_x = 2 * decoder->offset + motion_x; \
976 pos_y = 2 * decoder->v_offset + motion_y + 2 * y; \
977 if (unlikely (pos_x > decoder->limit_x)) { \
978 pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x; \
979 motion_x = pos_x - 2 * decoder->offset; \
980 } \
981 if (unlikely (pos_y > decoder->limit_y_ ## size)) { \
982 pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y_ ## size; \
983 motion_y = pos_y - 2 * decoder->v_offset - 2 * y; \
984 } \
985 xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
986 table[xy_half] (decoder->dest[0] + y * decoder->stride + decoder->offset, \
987 ref[0] + (pos_x >> 1) + (pos_y >> 1) * decoder->stride, \
988 decoder->stride, size); \
989 motion_x /= 2; motion_y /= 2; \
990 xy_half = ((motion_y & 1) << 1) | (motion_x & 1); \
991 offset = (((decoder->offset + motion_x) >> 1) + \
992 ((((decoder->v_offset + motion_y) >> 1) + y/2) * \
993 decoder->uv_stride)); \
994 table[4+xy_half] (decoder->dest[1] + y/2 * decoder->uv_stride + \
995 (decoder->offset >> 1), ref[1] + offset, \
996 decoder->uv_stride, size/2); \
997 table[4+xy_half] (decoder->dest[2] + y/2 * decoder->uv_stride + \
998 (decoder->offset >> 1), ref[2] + offset, \
999 decoder->uv_stride, size/2)
1000  
1001 #define MOTION_FIELD_420(table,ref,motion_x,motion_y,dest_field,op,src_field) \
1002 pos_x = 2 * decoder->offset + motion_x; \
1003 pos_y = decoder->v_offset + motion_y; \
1004 if (unlikely (pos_x > decoder->limit_x)) { \
1005 pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x; \
1006 motion_x = pos_x - 2 * decoder->offset; \
1007 } \
1008 if (unlikely (pos_y > decoder->limit_y)) { \
1009 pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y; \
1010 motion_y = pos_y - decoder->v_offset; \
1011 } \
1012 xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
1013 table[xy_half] (decoder->dest[0] + dest_field * decoder->stride + \
1014 decoder->offset, \
1015 (ref[0] + (pos_x >> 1) + \
1016 ((pos_y op) + src_field) * decoder->stride), \
1017 2 * decoder->stride, 8); \
1018 motion_x /= 2; motion_y /= 2; \
1019 xy_half = ((motion_y & 1) << 1) | (motion_x & 1); \
1020 offset = (((decoder->offset + motion_x) >> 1) + \
1021 (((decoder->v_offset >> 1) + (motion_y op) + src_field) * \
1022 decoder->uv_stride)); \
1023 table[4+xy_half] (decoder->dest[1] + dest_field * decoder->uv_stride + \
1024 (decoder->offset >> 1), ref[1] + offset, \
1025 2 * decoder->uv_stride, 4); \
1026 table[4+xy_half] (decoder->dest[2] + dest_field * decoder->uv_stride + \
1027 (decoder->offset >> 1), ref[2] + offset, \
1028 2 * decoder->uv_stride, 4)
1029  
1030 #define MOTION_DMV_420(table,ref,motion_x,motion_y) \
1031 pos_x = 2 * decoder->offset + motion_x; \
1032 pos_y = decoder->v_offset + motion_y; \
1033 if (unlikely (pos_x > decoder->limit_x)) { \
1034 pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x; \
1035 motion_x = pos_x - 2 * decoder->offset; \
1036 } \
1037 if (unlikely (pos_y > decoder->limit_y)) { \
1038 pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y; \
1039 motion_y = pos_y - decoder->v_offset; \
1040 } \
1041 xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
1042 offset = (pos_x >> 1) + (pos_y & ~1) * decoder->stride; \
1043 table[xy_half] (decoder->dest[0] + decoder->offset, \
1044 ref[0] + offset, 2 * decoder->stride, 8); \
1045 table[xy_half] (decoder->dest[0] + decoder->stride + decoder->offset, \
1046 ref[0] + decoder->stride + offset, \
1047 2 * decoder->stride, 8); \
1048 motion_x /= 2; motion_y /= 2; \
1049 xy_half = ((motion_y & 1) << 1) | (motion_x & 1); \
1050 offset = (((decoder->offset + motion_x) >> 1) + \
1051 (((decoder->v_offset >> 1) + (motion_y & ~1)) * \
1052 decoder->uv_stride)); \
1053 table[4+xy_half] (decoder->dest[1] + (decoder->offset >> 1), \
1054 ref[1] + offset, 2 * decoder->uv_stride, 4); \
1055 table[4+xy_half] (decoder->dest[1] + decoder->uv_stride + \
1056 (decoder->offset >> 1), \
1057 ref[1] + decoder->uv_stride + offset, \
1058 2 * decoder->uv_stride, 4); \
1059 table[4+xy_half] (decoder->dest[2] + (decoder->offset >> 1), \
1060 ref[2] + offset, 2 * decoder->uv_stride, 4); \
1061 table[4+xy_half] (decoder->dest[2] + decoder->uv_stride + \
1062 (decoder->offset >> 1), \
1063 ref[2] + decoder->uv_stride + offset, \
1064 2 * decoder->uv_stride, 4)
1065  
1066 #define MOTION_ZERO_420(table,ref) \
1067 table[0] (decoder->dest[0] + decoder->offset, \
1068 (ref[0] + decoder->offset + \
1069 decoder->v_offset * decoder->stride), decoder->stride, 16); \
1070 offset = ((decoder->offset >> 1) + \
1071 (decoder->v_offset >> 1) * decoder->uv_stride); \
1072 table[4] (decoder->dest[1] + (decoder->offset >> 1), \
1073 ref[1] + offset, decoder->uv_stride, 8); \
1074 table[4] (decoder->dest[2] + (decoder->offset >> 1), \
1075 ref[2] + offset, decoder->uv_stride, 8)
1076  
1077 #define MOTION_422(table,ref,motion_x,motion_y,size,y) \
1078 pos_x = 2 * decoder->offset + motion_x; \
1079 pos_y = 2 * decoder->v_offset + motion_y + 2 * y; \
1080 if (unlikely (pos_x > decoder->limit_x)) { \
1081 pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x; \
1082 motion_x = pos_x - 2 * decoder->offset; \
1083 } \
1084 if (unlikely (pos_y > decoder->limit_y_ ## size)) { \
1085 pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y_ ## size; \
1086 motion_y = pos_y - 2 * decoder->v_offset - 2 * y; \
1087 } \
1088 xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
1089 offset = (pos_x >> 1) + (pos_y >> 1) * decoder->stride; \
1090 table[xy_half] (decoder->dest[0] + y * decoder->stride + decoder->offset, \
1091 ref[0] + offset, decoder->stride, size); \
1092 offset = (offset + (motion_x & (motion_x < 0))) >> 1; \
1093 motion_x /= 2; \
1094 xy_half = ((pos_y & 1) << 1) | (motion_x & 1); \
1095 table[4+xy_half] (decoder->dest[1] + y * decoder->uv_stride + \
1096 (decoder->offset >> 1), ref[1] + offset, \
1097 decoder->uv_stride, size); \
1098 table[4+xy_half] (decoder->dest[2] + y * decoder->uv_stride + \
1099 (decoder->offset >> 1), ref[2] + offset, \
1100 decoder->uv_stride, size)
1101  
1102 #define MOTION_FIELD_422(table,ref,motion_x,motion_y,dest_field,op,src_field) \
1103 pos_x = 2 * decoder->offset + motion_x; \
1104 pos_y = decoder->v_offset + motion_y; \
1105 if (unlikely (pos_x > decoder->limit_x)) { \
1106 pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x; \
1107 motion_x = pos_x - 2 * decoder->offset; \
1108 } \
1109 if (unlikely (pos_y > decoder->limit_y)) { \
1110 pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y; \
1111 motion_y = pos_y - decoder->v_offset; \
1112 } \
1113 xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
1114 offset = (pos_x >> 1) + ((pos_y op) + src_field) * decoder->stride; \
1115 table[xy_half] (decoder->dest[0] + dest_field * decoder->stride + \
1116 decoder->offset, ref[0] + offset, \
1117 2 * decoder->stride, 8); \
1118 offset = (offset + (motion_x & (motion_x < 0))) >> 1; \
1119 motion_x /= 2; \
1120 xy_half = ((pos_y & 1) << 1) | (motion_x & 1); \
1121 table[4+xy_half] (decoder->dest[1] + dest_field * decoder->uv_stride + \
1122 (decoder->offset >> 1), ref[1] + offset, \
1123 2 * decoder->uv_stride, 8); \
1124 table[4+xy_half] (decoder->dest[2] + dest_field * decoder->uv_stride + \
1125 (decoder->offset >> 1), ref[2] + offset, \
1126 2 * decoder->uv_stride, 8)
1127  
1128 #define MOTION_DMV_422(table,ref,motion_x,motion_y) \
1129 pos_x = 2 * decoder->offset + motion_x; \
1130 pos_y = decoder->v_offset + motion_y; \
1131 if (unlikely (pos_x > decoder->limit_x)) { \
1132 pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x; \
1133 motion_x = pos_x - 2 * decoder->offset; \
1134 } \
1135 if (unlikely (pos_y > decoder->limit_y)) { \
1136 pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y; \
1137 motion_y = pos_y - decoder->v_offset; \
1138 } \
1139 xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
1140 offset = (pos_x >> 1) + (pos_y & ~1) * decoder->stride; \
1141 table[xy_half] (decoder->dest[0] + decoder->offset, \
1142 ref[0] + offset, 2 * decoder->stride, 8); \
1143 table[xy_half] (decoder->dest[0] + decoder->stride + decoder->offset, \
1144 ref[0] + decoder->stride + offset, \
1145 2 * decoder->stride, 8); \
1146 offset = (offset + (motion_x & (motion_x < 0))) >> 1; \
1147 motion_x /= 2; \
1148 xy_half = ((pos_y & 1) << 1) | (motion_x & 1); \
1149 table[4+xy_half] (decoder->dest[1] + (decoder->offset >> 1), \
1150 ref[1] + offset, 2 * decoder->uv_stride, 8); \
1151 table[4+xy_half] (decoder->dest[1] + decoder->uv_stride + \
1152 (decoder->offset >> 1), \
1153 ref[1] + decoder->uv_stride + offset, \
1154 2 * decoder->uv_stride, 8); \
1155 table[4+xy_half] (decoder->dest[2] + (decoder->offset >> 1), \
1156 ref[2] + offset, 2 * decoder->uv_stride, 8); \
1157 table[4+xy_half] (decoder->dest[2] + decoder->uv_stride + \
1158 (decoder->offset >> 1), \
1159 ref[2] + decoder->uv_stride + offset, \
1160 2 * decoder->uv_stride, 8)
1161  
1162 #define MOTION_ZERO_422(table,ref) \
1163 offset = decoder->offset + decoder->v_offset * decoder->stride; \
1164 table[0] (decoder->dest[0] + decoder->offset, \
1165 ref[0] + offset, decoder->stride, 16); \
1166 offset >>= 1; \
1167 table[4] (decoder->dest[1] + (decoder->offset >> 1), \
1168 ref[1] + offset, decoder->uv_stride, 16); \
1169 table[4] (decoder->dest[2] + (decoder->offset >> 1), \
1170 ref[2] + offset, decoder->uv_stride, 16)
1171  
1172 #define MOTION_444(table,ref,motion_x,motion_y,size,y) \
1173 pos_x = 2 * decoder->offset + motion_x; \
1174 pos_y = 2 * decoder->v_offset + motion_y + 2 * y; \
1175 if (unlikely (pos_x > decoder->limit_x)) { \
1176 pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x; \
1177 motion_x = pos_x - 2 * decoder->offset; \
1178 } \
1179 if (unlikely (pos_y > decoder->limit_y_ ## size)) { \
1180 pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y_ ## size; \
1181 motion_y = pos_y - 2 * decoder->v_offset - 2 * y; \
1182 } \
1183 xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
1184 offset = (pos_x >> 1) + (pos_y >> 1) * decoder->stride; \
1185 table[xy_half] (decoder->dest[0] + y * decoder->stride + decoder->offset, \
1186 ref[0] + offset, decoder->stride, size); \
1187 table[xy_half] (decoder->dest[1] + y * decoder->stride + decoder->offset, \
1188 ref[1] + offset, decoder->stride, size); \
1189 table[xy_half] (decoder->dest[2] + y * decoder->stride + decoder->offset, \
1190 ref[2] + offset, decoder->stride, size)
1191  
1192 #define MOTION_FIELD_444(table,ref,motion_x,motion_y,dest_field,op,src_field) \
1193 pos_x = 2 * decoder->offset + motion_x; \
1194 pos_y = decoder->v_offset + motion_y; \
1195 if (unlikely (pos_x > decoder->limit_x)) { \
1196 pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x; \
1197 motion_x = pos_x - 2 * decoder->offset; \
1198 } \
1199 if (unlikely (pos_y > decoder->limit_y)) { \
1200 pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y; \
1201 motion_y = pos_y - decoder->v_offset; \
1202 } \
1203 xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
1204 offset = (pos_x >> 1) + ((pos_y op) + src_field) * decoder->stride; \
1205 table[xy_half] (decoder->dest[0] + dest_field * decoder->stride + \
1206 decoder->offset, ref[0] + offset, \
1207 2 * decoder->stride, 8); \
1208 table[xy_half] (decoder->dest[1] + dest_field * decoder->stride + \
1209 decoder->offset, ref[1] + offset, \
1210 2 * decoder->stride, 8); \
1211 table[xy_half] (decoder->dest[2] + dest_field * decoder->stride + \
1212 decoder->offset, ref[2] + offset, \
1213 2 * decoder->stride, 8)
1214  
1215 #define MOTION_DMV_444(table,ref,motion_x,motion_y) \
1216 pos_x = 2 * decoder->offset + motion_x; \
1217 pos_y = decoder->v_offset + motion_y; \
1218 if (unlikely (pos_x > decoder->limit_x)) { \
1219 pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x; \
1220 motion_x = pos_x - 2 * decoder->offset; \
1221 } \
1222 if (unlikely (pos_y > decoder->limit_y)) { \
1223 pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y; \
1224 motion_y = pos_y - decoder->v_offset; \
1225 } \
1226 xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
1227 offset = (pos_x >> 1) + (pos_y & ~1) * decoder->stride; \
1228 table[xy_half] (decoder->dest[0] + decoder->offset, \
1229 ref[0] + offset, 2 * decoder->stride, 8); \
1230 table[xy_half] (decoder->dest[0] + decoder->stride + decoder->offset, \
1231 ref[0] + decoder->stride + offset, \
1232 2 * decoder->stride, 8); \
1233 table[xy_half] (decoder->dest[1] + decoder->offset, \
1234 ref[1] + offset, 2 * decoder->stride, 8); \
1235 table[xy_half] (decoder->dest[1] + decoder->stride + decoder->offset, \
1236 ref[1] + decoder->stride + offset, \
1237 2 * decoder->stride, 8); \
1238 table[xy_half] (decoder->dest[2] + decoder->offset, \
1239 ref[2] + offset, 2 * decoder->stride, 8); \
1240 table[xy_half] (decoder->dest[2] + decoder->stride + decoder->offset, \
1241 ref[2] + decoder->stride + offset, \
1242 2 * decoder->stride, 8)
1243  
1244 #define MOTION_ZERO_444(table,ref) \
1245 offset = decoder->offset + decoder->v_offset * decoder->stride; \
1246 table[0] (decoder->dest[0] + decoder->offset, \
1247 ref[0] + offset, decoder->stride, 16); \
1248 table[4] (decoder->dest[1] + decoder->offset, \
1249 ref[1] + offset, decoder->stride, 16); \
1250 table[4] (decoder->dest[2] + decoder->offset, \
1251 ref[2] + offset, decoder->stride, 16)
1252  
1253 #define bit_buf (decoder->bitstream_buf)
1254 #define bits (decoder->bitstream_bits)
1255 #define bit_ptr (decoder->bitstream_ptr)
1256  
1257 0 static void motion_mp1 (mpeg2_decoder_t * const decoder,
1258 motion_t * const motion,
1259 mpeg2_mc_fct * const * const table)
1260 {
1261 int motion_x, motion_y;
1262 unsigned int pos_x, pos_y, xy_half, offset;
1263  
1264 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
1265 0 motion_x = (motion->pmv[0][0] +
1266 0 (get_motion_delta (decoder,
1267 0 motion->f_code[0]) << motion->f_code[1]));
1268 0 motion_x = bound_motion_vector (motion_x,
1269 0 motion->f_code[0] + motion->f_code[1]);
1270 0 motion->pmv[0][0] = motion_x;
1271  
1272 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
1273 0 motion_y = (motion->pmv[0][1] +
1274 0 (get_motion_delta (decoder,
1275 0 motion->f_code[0]) << motion->f_code[1]));
1276 0 motion_y = bound_motion_vector (motion_y,
1277 0 motion->f_code[0] + motion->f_code[1]);
1278 0 motion->pmv[0][1] = motion_y;
1279  
1280 0 ▶ MOTION_420 (table, motion->ref[0], motion_x, motion_y, 16, 0);
Branch: 4 branches
BranchTrueFalseTotal
MOTION_420 (table, motion->ref[0], motion_x, motion_y, 16, 0); 0 0 0
MOTION_420 (table, motion->ref[0], motion_x, motion_y, 16, 0); 0 0 0
MOTION_420 (table, motion->ref[0], motion_x, motion_y, 16, 0); 0 0 0
MOTION_420 (table, motion->ref[0], motion_x, motion_y, 16, 0); 0 0 0
1281 0 }
1282  
1283 #define MOTION_FUNCTIONS(FORMAT,MOTION,MOTION_FIELD,MOTION_DMV,MOTION_ZERO) \
1284 \
1285 static void motion_fr_frame_##FORMAT (mpeg2_decoder_t * const decoder, \
1286 motion_t * const motion, \
1287 mpeg2_mc_fct * const * const table) \
1288 { \
1289 int motion_x, motion_y; \
1290 unsigned int pos_x, pos_y, xy_half, offset; \
1291 \
1292 NEEDBITS (bit_buf, bits, bit_ptr); \
1293 motion_x = motion->pmv[0][0] + get_motion_delta (decoder, \
1294 motion->f_code[0]); \
1295 motion_x = bound_motion_vector (motion_x, motion->f_code[0]); \
1296 motion->pmv[1][0] = motion->pmv[0][0] = motion_x; \
1297 \
1298 NEEDBITS (bit_buf, bits, bit_ptr); \
1299 motion_y = motion->pmv[0][1] + get_motion_delta (decoder, \
1300 motion->f_code[1]); \
1301 motion_y = bound_motion_vector (motion_y, motion->f_code[1]); \
1302 motion->pmv[1][1] = motion->pmv[0][1] = motion_y; \
1303 \
1304 MOTION (table, motion->ref[0], motion_x, motion_y, 16, 0); \
1305 } \
1306 \
1307 static void motion_fr_field_##FORMAT (mpeg2_decoder_t * const decoder, \
1308 motion_t * const motion, \
1309 mpeg2_mc_fct * const * const table) \
1310 { \
1311 int motion_x, motion_y, field; \
1312 unsigned int pos_x, pos_y, xy_half, offset; \
1313 \
1314 NEEDBITS (bit_buf, bits, bit_ptr); \
1315 field = UBITS (bit_buf, 1); \
1316 DUMPBITS (bit_buf, bits, 1); \
1317 \
1318 motion_x = motion->pmv[0][0] + get_motion_delta (decoder, \
1319 motion->f_code[0]); \
1320 motion_x = bound_motion_vector (motion_x, motion->f_code[0]); \
1321 motion->pmv[0][0] = motion_x; \
1322 \
1323 NEEDBITS (bit_buf, bits, bit_ptr); \
1324 motion_y = ((motion->pmv[0][1] >> 1) + \
1325 get_motion_delta (decoder, motion->f_code[1])); \
1326 /* motion_y = bound_motion_vector (motion_y, motion->f_code[1]); */ \
1327 motion->pmv[0][1] = motion_y << 1; \
1328 \
1329 MOTION_FIELD (table, motion->ref[0], motion_x, motion_y, 0, & ~1, field); \
1330 \
1331 NEEDBITS (bit_buf, bits, bit_ptr); \
1332 field = UBITS (bit_buf, 1); \
1333 DUMPBITS (bit_buf, bits, 1); \
1334 \
1335 motion_x = motion->pmv[1][0] + get_motion_delta (decoder, \
1336 motion->f_code[0]); \
1337 motion_x = bound_motion_vector (motion_x, motion->f_code[0]); \
1338 motion->pmv[1][0] = motion_x; \
1339 \
1340 NEEDBITS (bit_buf, bits, bit_ptr); \
1341 motion_y = ((motion->pmv[1][1] >> 1) + \
1342 get_motion_delta (decoder, motion->f_code[1])); \
1343 /* motion_y = bound_motion_vector (motion_y, motion->f_code[1]); */ \
1344 motion->pmv[1][1] = motion_y << 1; \
1345 \
1346 MOTION_FIELD (table, motion->ref[0], motion_x, motion_y, 1, & ~1, field); \
1347 } \
1348 \
1349 static void motion_fr_dmv_##FORMAT (mpeg2_decoder_t * const decoder, \
1350 motion_t * const motion, \
1351 mpeg2_mc_fct * const * const table) \
1352 { \
1353 int motion_x, motion_y, dmv_x, dmv_y, m, other_x, other_y; \
1354 unsigned int pos_x, pos_y, xy_half, offset; \
1355 \
1356 NEEDBITS (bit_buf, bits, bit_ptr); \
1357 motion_x = motion->pmv[0][0] + get_motion_delta (decoder, \
1358 motion->f_code[0]); \
1359 motion_x = bound_motion_vector (motion_x, motion->f_code[0]); \
1360 motion->pmv[1][0] = motion->pmv[0][0] = motion_x; \
1361 NEEDBITS (bit_buf, bits, bit_ptr); \
1362 dmv_x = get_dmv (decoder); \
1363 \
1364 motion_y = ((motion->pmv[0][1] >> 1) + \
1365 get_motion_delta (decoder, motion->f_code[1])); \
1366 /* motion_y = bound_motion_vector (motion_y, motion->f_code[1]); */ \
1367 motion->pmv[1][1] = motion->pmv[0][1] = motion_y << 1; \
1368 dmv_y = get_dmv (decoder); \
1369 \
1370 m = decoder->top_field_first ? 1 : 3; \
1371 other_x = ((motion_x * m + (motion_x > 0)) >> 1) + dmv_x; \
1372 other_y = ((motion_y * m + (motion_y > 0)) >> 1) + dmv_y - 1; \
1373 MOTION_FIELD (mpeg2_mc.put, motion->ref[0], other_x, other_y, 0, | 1, 0); \
1374 \
1375 m = decoder->top_field_first ? 3 : 1; \
1376 other_x = ((motion_x * m + (motion_x > 0)) >> 1) + dmv_x; \
1377 other_y = ((motion_y * m + (motion_y > 0)) >> 1) + dmv_y + 1; \
1378 MOTION_FIELD (mpeg2_mc.put, motion->ref[0], other_x, other_y, 1, & ~1, 0);\
1379 \
1380 MOTION_DMV (mpeg2_mc.avg, motion->ref[0], motion_x, motion_y); \
1381 } \
1382 \
1383 static void motion_reuse_##FORMAT (mpeg2_decoder_t * const decoder, \
1384 motion_t * const motion, \
1385 mpeg2_mc_fct * const * const table) \
1386 { \
1387 int motion_x, motion_y; \
1388 unsigned int pos_x, pos_y, xy_half, offset; \
1389 \
1390 motion_x = motion->pmv[0][0]; \
1391 motion_y = motion->pmv[0][1]; \
1392 \
1393 MOTION (table, motion->ref[0], motion_x, motion_y, 16, 0); \
1394 } \
1395 \
1396 static void motion_zero_##FORMAT (mpeg2_decoder_t * const decoder, \
1397 motion_t * const motion, \
1398 mpeg2_mc_fct * const * const table) \
1399 { \
1400 unsigned int offset; \
1401 \
1402 motion->pmv[0][0] = motion->pmv[0][1] = 0; \
1403 motion->pmv[1][0] = motion->pmv[1][1] = 0; \
1404 \
1405 MOTION_ZERO (table, motion->ref[0]); \
1406 } \
1407 \
1408 static void motion_fi_field_##FORMAT (mpeg2_decoder_t * const decoder, \
1409 motion_t * const motion, \
1410 mpeg2_mc_fct * const * const table) \
1411 { \
1412 int motion_x, motion_y; \
1413 uint8_t ** ref_field; \
1414 unsigned int pos_x, pos_y, xy_half, offset; \
1415 \
1416 NEEDBITS (bit_buf, bits, bit_ptr); \
1417 ref_field = motion->ref2[UBITS (bit_buf, 1)]; \
1418 DUMPBITS (bit_buf, bits, 1); \
1419 \
1420 motion_x = motion->pmv[0][0] + get_motion_delta (decoder, \
1421 motion->f_code[0]); \
1422 motion_x = bound_motion_vector (motion_x, motion->f_code[0]); \
1423 motion->pmv[1][0] = motion->pmv[0][0] = motion_x; \
1424 \
1425 NEEDBITS (bit_buf, bits, bit_ptr); \
1426 motion_y = motion->pmv[0][1] + get_motion_delta (decoder, \
1427 motion->f_code[1]); \
1428 motion_y = bound_motion_vector (motion_y, motion->f_code[1]); \
1429 motion->pmv[1][1] = motion->pmv[0][1] = motion_y; \
1430 \
1431 MOTION (table, ref_field, motion_x, motion_y, 16, 0); \
1432 } \
1433 \
1434 static void motion_fi_16x8_##FORMAT (mpeg2_decoder_t * const decoder, \
1435 motion_t * const motion, \
1436 mpeg2_mc_fct * const * const table) \
1437 { \
1438 int motion_x, motion_y; \
1439 uint8_t ** ref_field; \
1440 unsigned int pos_x, pos_y, xy_half, offset; \
1441 \
1442 NEEDBITS (bit_buf, bits, bit_ptr); \
1443 ref_field = motion->ref2[UBITS (bit_buf, 1)]; \
1444 DUMPBITS (bit_buf, bits, 1); \
1445 \
1446 motion_x = motion->pmv[0][0] + get_motion_delta (decoder, \
1447 motion->f_code[0]); \
1448 motion_x = bound_motion_vector (motion_x, motion->f_code[0]); \
1449 motion->pmv[0][0] = motion_x; \
1450 \
1451 NEEDBITS (bit_buf, bits, bit_ptr); \
1452 motion_y = motion->pmv[0][1] + get_motion_delta (decoder, \
1453 motion->f_code[1]); \
1454 motion_y = bound_motion_vector (motion_y, motion->f_code[1]); \
1455 motion->pmv[0][1] = motion_y; \
1456 \
1457 MOTION (table, ref_field, motion_x, motion_y, 8, 0); \
1458 \
1459 NEEDBITS (bit_buf, bits, bit_ptr); \
1460 ref_field = motion->ref2[UBITS (bit_buf, 1)]; \
1461 DUMPBITS (bit_buf, bits, 1); \
1462 \
1463 motion_x = motion->pmv[1][0] + get_motion_delta (decoder, \
1464 motion->f_code[0]); \
1465 motion_x = bound_motion_vector (motion_x, motion->f_code[0]); \
1466 motion->pmv[1][0] = motion_x; \
1467 \
1468 NEEDBITS (bit_buf, bits, bit_ptr); \
1469 motion_y = motion->pmv[1][1] + get_motion_delta (decoder, \
1470 motion->f_code[1]); \
1471 motion_y = bound_motion_vector (motion_y, motion->f_code[1]); \
1472 motion->pmv[1][1] = motion_y; \
1473 \
1474 MOTION (table, ref_field, motion_x, motion_y, 8, 8); \
1475 } \
1476 \
1477 static void motion_fi_dmv_##FORMAT (mpeg2_decoder_t * const decoder, \
1478 motion_t * const motion, \
1479 mpeg2_mc_fct * const * const table) \
1480 { \
1481 int motion_x, motion_y, other_x, other_y; \
1482 unsigned int pos_x, pos_y, xy_half, offset; \
1483 \
1484 NEEDBITS (bit_buf, bits, bit_ptr); \
1485 motion_x = motion->pmv[0][0] + get_motion_delta (decoder, \
1486 motion->f_code[0]); \
1487 motion_x = bound_motion_vector (motion_x, motion->f_code[0]); \
1488 motion->pmv[1][0] = motion->pmv[0][0] = motion_x; \
1489 NEEDBITS (bit_buf, bits, bit_ptr); \
1490 other_x = ((motion_x + (motion_x > 0)) >> 1) + get_dmv (decoder); \
1491 \
1492 motion_y = motion->pmv[0][1] + get_motion_delta (decoder, \
1493 motion->f_code[1]); \
1494 motion_y = bound_motion_vector (motion_y, motion->f_code[1]); \
1495 motion->pmv[1][1] = motion->pmv[0][1] = motion_y; \
1496 other_y = (((motion_y + (motion_y > 0)) >> 1) + get_dmv (decoder) + \
1497 decoder->dmv_offset); \
1498 \
1499 MOTION (mpeg2_mc.put, motion->ref[0], motion_x, motion_y, 16, 0); \
1500 MOTION (mpeg2_mc.avg, motion->ref[1], other_x, other_y, 16, 0); \
1501 } \
1502  
1503 0 ▶MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420,
Branch: 66 branches
BranchTrueFalseTotal
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420, 0 0 0
1504 MOTION_ZERO_420)
1505 0 ▶MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422,
Branch: 66 branches
BranchTrueFalseTotal
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422, 0 0 0
1506 MOTION_ZERO_422)
1507 0 ▶MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444,
Branch: 66 branches
BranchTrueFalseTotal
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444, 0 0 0
1508 MOTION_ZERO_444)
1509  
1510 /* like motion_frame, but parsing without actual motion compensation */
1511 0 static void motion_fr_conceal (mpeg2_decoder_t * const decoder)
1512 {
1513 int tmp;
1514  
1515 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
1516 0 tmp = (decoder->f_motion.pmv[0][0] +
1517 0 get_motion_delta (decoder, decoder->f_motion.f_code[0]));
1518 0 tmp = bound_motion_vector (tmp, decoder->f_motion.f_code[0]);
1519 0 decoder->f_motion.pmv[1][0] = decoder->f_motion.pmv[0][0] = tmp;
1520  
1521 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
1522 0 tmp = (decoder->f_motion.pmv[0][1] +
1523 0 get_motion_delta (decoder, decoder->f_motion.f_code[1]));
1524 0 tmp = bound_motion_vector (tmp, decoder->f_motion.f_code[1]);
1525 0 decoder->f_motion.pmv[1][1] = decoder->f_motion.pmv[0][1] = tmp;
1526  
1527 0 DUMPBITS (bit_buf, bits, 1); /* remove marker_bit */
1528 0 }
1529  
1530 0 static void motion_fi_conceal (mpeg2_decoder_t * const decoder)
1531 {
1532 int tmp;
1533  
1534 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
1535 0 DUMPBITS (bit_buf, bits, 1); /* remove field_select */
1536  
1537 0 tmp = (decoder->f_motion.pmv[0][0] +
1538 0 get_motion_delta (decoder, decoder->f_motion.f_code[0]));
1539 0 tmp = bound_motion_vector (tmp, decoder->f_motion.f_code[0]);
1540 0 decoder->f_motion.pmv[1][0] = decoder->f_motion.pmv[0][0] = tmp;
1541  
1542 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
1543 0 tmp = (decoder->f_motion.pmv[0][1] +
1544 0 get_motion_delta (decoder, decoder->f_motion.f_code[1]));
1545 0 tmp = bound_motion_vector (tmp, decoder->f_motion.f_code[1]);
1546 0 decoder->f_motion.pmv[1][1] = decoder->f_motion.pmv[0][1] = tmp;
1547  
1548 0 DUMPBITS (bit_buf, bits, 1); /* remove marker_bit */
1549 0 }
1550  
1551 #undef bit_buf
1552 #undef bits
1553 #undef bit_ptr
1554  
1555 #define MOTION_CALL(routine,direction) \
1556 do { \
1557 if ((direction) & MACROBLOCK_MOTION_FORWARD) \
1558 routine (decoder, &(decoder->f_motion), mpeg2_mc.put); \
1559 if ((direction) & MACROBLOCK_MOTION_BACKWARD) \
1560 routine (decoder, &(decoder->b_motion), \
1561 ((direction) & MACROBLOCK_MOTION_FORWARD ? \
1562 mpeg2_mc.avg : mpeg2_mc.put)); \
1563 } while (0)
1564  
1565 #define NEXT_MACROBLOCK \
1566 do { \
1567 decoder->offset += 16; \
1568 if (decoder->offset == decoder->width) { \
1569 do { /* just so we can use the break statement */ \
1570 if (decoder->convert) { \
1571 decoder->convert (decoder->convert_id, decoder->dest, \
1572 decoder->v_offset); \
1573 if (decoder->coding_type == B_TYPE) \
1574 break; \
1575 } \
1576 decoder->dest[0] += decoder->slice_stride; \
1577 decoder->dest[1] += decoder->slice_uv_stride; \
1578 decoder->dest[2] += decoder->slice_uv_stride; \
1579 } while (0); \
1580 decoder->v_offset += 16; \
1581 if (decoder->v_offset > decoder->limit_y) { \
1582 if (mpeg2_cpu_state_restore) \
1583 mpeg2_cpu_state_restore (&cpu_state); \
1584 return; \
1585 } \
1586 decoder->offset = 0; \
1587 } \
1588 } while (0)
1589  
1590 /**
1591 * Dummy motion decoding function, to avoid calling NULL in
1592 * case of malformed streams.
1593 */
1594 0 static void motion_dummy (mpeg2_decoder_t * const decoder,
1595 motion_t * const motion,
1596 mpeg2_mc_fct * const * const table)
1597 {
1598 0 }
1599  
1600 0 void mpeg2_init_fbuf (mpeg2_decoder_t * decoder, uint8_t * current_fbuf[3],
1601 uint8_t * forward_fbuf[3], uint8_t * backward_fbuf[3])
1602 {
1603 int offset, stride, height, bottom_field;
1604  
1605 0 stride = decoder->stride_frame;
1606 0 bottom_field = (decoder->picture_structure == BOTTOM_FIELD);
1607 0 ▶ offset = bottom_field ? stride : 0;
Branch: 1 branch
BranchTrueFalseTotal
offset = bottom_field ? stride : 0; 0 0 0
1608 0 height = decoder->height;
1609  
1610 0 decoder->picture_dest[0] = current_fbuf[0] + offset;
1611 0 decoder->picture_dest[1] = current_fbuf[1] + (offset >> 1);
1612 0 decoder->picture_dest[2] = current_fbuf[2] + (offset >> 1);
1613  
1614 0 decoder->f_motion.ref[0][0] = forward_fbuf[0] + offset;
1615 0 decoder->f_motion.ref[0][1] = forward_fbuf[1] + (offset >> 1);
1616 0 decoder->f_motion.ref[0][2] = forward_fbuf[2] + (offset >> 1);
1617  
1618 0 decoder->b_motion.ref[0][0] = backward_fbuf[0] + offset;
1619 0 decoder->b_motion.ref[0][1] = backward_fbuf[1] + (offset >> 1);
1620 0 decoder->b_motion.ref[0][2] = backward_fbuf[2] + (offset >> 1);
1621  
1622 0 ▶ if (decoder->picture_structure != FRAME_PICTURE) {
Branch: 1 branch
BranchTrueFalseTotal
if (decoder->picture_structure != FRAME_PICTURE) { 0 0 0
1623 0 ▶ decoder->dmv_offset = bottom_field ? 1 : -1;
Branch: 1 branch
BranchTrueFalseTotal
decoder->dmv_offset = bottom_field ? 1 : -1; 0 0 0
1624 0 decoder->f_motion.ref2[0] = decoder->f_motion.ref[bottom_field];
1625 0 decoder->f_motion.ref2[1] = decoder->f_motion.ref[!bottom_field];
1626 0 decoder->b_motion.ref2[0] = decoder->b_motion.ref[bottom_field];
1627 0 decoder->b_motion.ref2[1] = decoder->b_motion.ref[!bottom_field];
1628 0 offset = stride - offset;
1629  
1630 0 ▶ if (decoder->second_field && (decoder->coding_type != B_TYPE))
Branch: 2 branches
BranchTrueFalseTotal
if (decoder->second_field && (decoder->coding_type != B_TYPE)) 0 0 0
if (decoder->second_field && (decoder->coding_type != B_TYPE)) 0 0 0
1631 0 forward_fbuf = current_fbuf;
1632  
1633 0 decoder->f_motion.ref[1][0] = forward_fbuf[0] + offset;
1634 0 decoder->f_motion.ref[1][1] = forward_fbuf[1] + (offset >> 1);
1635 0 decoder->f_motion.ref[1][2] = forward_fbuf[2] + (offset >> 1);
1636  
1637 0 decoder->b_motion.ref[1][0] = backward_fbuf[0] + offset;
1638 0 decoder->b_motion.ref[1][1] = backward_fbuf[1] + (offset >> 1);
1639 0 decoder->b_motion.ref[1][2] = backward_fbuf[2] + (offset >> 1);
1640  
1641 0 stride <<= 1;
1642 0 height >>= 1;
1643 }
1644  
1645 0 decoder->stride = stride;
1646 0 decoder->uv_stride = stride >> 1;
1647 0 decoder->slice_stride = 16 * stride;
1648 0 decoder->slice_uv_stride =
1649 0 decoder->slice_stride >> (2 - decoder->chroma_format);
1650 0 decoder->limit_x = 2 * decoder->width - 32;
1651 0 decoder->limit_y_16 = 2 * height - 32;
1652 0 decoder->limit_y_8 = 2 * height - 16;
1653 0 decoder->limit_y = height - 16;
1654  
1655 0 ▶ if (decoder->mpeg1) {
Branch: 1 branch
BranchTrueFalseTotal
if (decoder->mpeg1) { 0 0 0
1656 0 decoder->motion_parser[0] = motion_zero_420;
1657 0 decoder->motion_parser[MC_FIELD] = motion_dummy;
1658 0 decoder->motion_parser[MC_FRAME] = motion_mp1;
1659 0 decoder->motion_parser[MC_DMV] = motion_dummy;
1660 0 decoder->motion_parser[4] = motion_reuse_420;
1661 0 ▶ } else if (decoder->picture_structure == FRAME_PICTURE) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (decoder->picture_structure == FRAME_PICTURE) { 0 0 0
1662 0 ▶ if (decoder->chroma_format == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (decoder->chroma_format == 0) { 0 0 0
1663 0 decoder->motion_parser[0] = motion_zero_420;
1664 0 decoder->motion_parser[MC_FIELD] = motion_fr_field_420;
1665 0 decoder->motion_parser[MC_FRAME] = motion_fr_frame_420;
1666 0 decoder->motion_parser[MC_DMV] = motion_fr_dmv_420;
1667 0 decoder->motion_parser[4] = motion_reuse_420;
1668 0 ▶ } else if (decoder->chroma_format == 1) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (decoder->chroma_format == 1) { 0 0 0
1669 0 decoder->motion_parser[0] = motion_zero_422;
1670 0 decoder->motion_parser[MC_FIELD] = motion_fr_field_422;
1671 0 decoder->motion_parser[MC_FRAME] = motion_fr_frame_422;
1672 0 decoder->motion_parser[MC_DMV] = motion_fr_dmv_422;
1673 0 decoder->motion_parser[4] = motion_reuse_422;
1674 } else {
1675 0 decoder->motion_parser[0] = motion_zero_444;
1676 0 decoder->motion_parser[MC_FIELD] = motion_fr_field_444;
1677 0 decoder->motion_parser[MC_FRAME] = motion_fr_frame_444;
1678 0 decoder->motion_parser[MC_DMV] = motion_fr_dmv_444;
1679 0 decoder->motion_parser[4] = motion_reuse_444;
1680 }
1681 } else {
1682 0 ▶ if (decoder->chroma_format == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (decoder->chroma_format == 0) { 0 0 0
1683 0 decoder->motion_parser[0] = motion_zero_420;
1684 0 decoder->motion_parser[MC_FIELD] = motion_fi_field_420;
1685 0 decoder->motion_parser[MC_16X8] = motion_fi_16x8_420;
1686 0 decoder->motion_parser[MC_DMV] = motion_fi_dmv_420;
1687 0 decoder->motion_parser[4] = motion_reuse_420;
1688 0 ▶ } else if (decoder->chroma_format == 1) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (decoder->chroma_format == 1) { 0 0 0
1689 0 decoder->motion_parser[0] = motion_zero_422;
1690 0 decoder->motion_parser[MC_FIELD] = motion_fi_field_422;
1691 0 decoder->motion_parser[MC_16X8] = motion_fi_16x8_422;
1692 0 decoder->motion_parser[MC_DMV] = motion_fi_dmv_422;
1693 0 decoder->motion_parser[4] = motion_reuse_422;
1694 } else {
1695 0 decoder->motion_parser[0] = motion_zero_444;
1696 0 decoder->motion_parser[MC_FIELD] = motion_fi_field_444;
1697 0 decoder->motion_parser[MC_16X8] = motion_fi_16x8_444;
1698 0 decoder->motion_parser[MC_DMV] = motion_fi_dmv_444;
1699 0 decoder->motion_parser[4] = motion_reuse_444;
1700 }
1701 }
1702 0 }
1703  
1704 0 static inline int slice_init (mpeg2_decoder_t * const decoder, int code)
1705 {
1706 #define bit_buf (decoder->bitstream_buf)
1707 #define bits (decoder->bitstream_bits)
1708 #define bit_ptr (decoder->bitstream_ptr)
1709 int offset;
1710 const MBAtab * mba;
1711  
1712 0 decoder->dc_dct_pred[0] = decoder->dc_dct_pred[1] =
1713 0 decoder->dc_dct_pred[2] = 16384;
1714  
1715 0 decoder->f_motion.pmv[0][0] = decoder->f_motion.pmv[0][1] = 0;
1716 0 decoder->f_motion.pmv[1][0] = decoder->f_motion.pmv[1][1] = 0;
1717 0 decoder->b_motion.pmv[0][0] = decoder->b_motion.pmv[0][1] = 0;
1718 0 decoder->b_motion.pmv[1][0] = decoder->b_motion.pmv[1][1] = 0;
1719  
1720 0 ▶ if (decoder->vertical_position_extension) {
Branch: 1 branch
BranchTrueFalseTotal
if (decoder->vertical_position_extension) { 0 0 0
1721 0 code += UBITS (bit_buf, 3) << 7;
1722 0 DUMPBITS (bit_buf, bits, 3);
1723 }
1724 0 decoder->v_offset = (code - 1) * 16;
1725 0 offset = 0;
1726 0 ▶ if (!(decoder->convert) || decoder->coding_type != B_TYPE)
Branch: 2 branches
BranchTrueFalseTotal
if (!(decoder->convert) || decoder->coding_type != B_TYPE) 0 0 0
if (!(decoder->convert) || decoder->coding_type != B_TYPE) 0 0 0
1727 0 offset = (code - 1) * decoder->slice_stride;
1728  
1729 0 decoder->dest[0] = decoder->picture_dest[0] + offset;
1730 0 offset >>= (2 - decoder->chroma_format);
1731 0 decoder->dest[1] = decoder->picture_dest[1] + offset;
1732 0 decoder->dest[2] = decoder->picture_dest[2] + offset;
1733  
1734 0 get_quantizer_scale (decoder);
1735  
1736 /* ignore intra_slice and all the extra data */
1737 0 ▶ while (bit_buf & 0x80000000) {
Branch: 1 branch
BranchTrueFalseTotal
while (bit_buf & 0x80000000) { 0 0 0
1738 0 DUMPBITS (bit_buf, bits, 9);
1739 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
1740 }
1741  
1742 /* decode initial macroblock address increment */
1743 0 offset = 0;
1744 while (1) {
1745 0 ▶ if (bit_buf >= 0x08000000) {
Branch: 1 branch
BranchTrueFalseTotal
if (bit_buf >= 0x08000000) { 0 0 0
1746 0 mba = MBA_5 + (UBITS (bit_buf, 6) - 2);
1747 0 break;
1748 0 ▶ } else if (bit_buf >= 0x01800000) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (bit_buf >= 0x01800000) { 0 0 0
1749 0 mba = MBA_11 + (UBITS (bit_buf, 12) - 24);
1750 0 break;
1751 0 } else switch (UBITS (bit_buf, 12)) {
1752 0 case 8: /* macroblock_escape */
1753 0 offset += 33;
1754 0 DUMPBITS (bit_buf, bits, 11);
1755 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
1756 0 continue;
1757 0 case 15: /* macroblock_stuffing (MPEG1 only) */
1758 0 bit_buf &= 0xfffff;
1759 0 DUMPBITS (bit_buf, bits, 11);
1760 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
1761 0 continue;
1762 0 default: /* error */
1763 0 return 1;
1764 }
1765 }
1766 0 DUMPBITS (bit_buf, bits, mba->len + 1);
1767 0 decoder->offset = (offset + mba->mba) << 4;
1768  
1769 0 ▶ while (decoder->offset - decoder->width >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
while (decoder->offset - decoder->width >= 0) { 0 0 0
1770 0 decoder->offset -= decoder->width;
1771 0 ▶ if (!(decoder->convert) || decoder->coding_type != B_TYPE) {
Branch: 2 branches
BranchTrueFalseTotal
if (!(decoder->convert) || decoder->coding_type != B_TYPE) { 0 0 0
if (!(decoder->convert) || decoder->coding_type != B_TYPE) { 0 0 0
1772 0 decoder->dest[0] += decoder->slice_stride;
1773 0 decoder->dest[1] += decoder->slice_uv_stride;
1774 0 decoder->dest[2] += decoder->slice_uv_stride;
1775 }
1776 0 decoder->v_offset += 16;
1777 }
1778 0 ▶ if (decoder->v_offset > decoder->limit_y)
Branch: 1 branch
BranchTrueFalseTotal
if (decoder->v_offset > decoder->limit_y) 0 0 0
1779 0 return 1;
1780  
1781 0 return 0;
1782 #undef bit_buf
1783 #undef bits
1784 #undef bit_ptr
1785 }
1786  
1787 0 void mpeg2_slice (mpeg2_decoder_t * const decoder, const int code,
1788 const uint8_t * const buffer)
1789 {
1790 #define bit_buf (decoder->bitstream_buf)
1791 #define bits (decoder->bitstream_bits)
1792 #define bit_ptr (decoder->bitstream_ptr)
1793 cpu_state_t cpu_state;
1794  
1795 0 bitstream_init (decoder, buffer);
1796  
1797 0 ▶ if (slice_init (decoder, code))
Branch: 1 branch
BranchTrueFalseTotal
if (slice_init (decoder, code)) 0 0 0
1798 0 return;
1799  
1800 0 ▶ if (mpeg2_cpu_state_save)
Branch: 1 branch
BranchTrueFalseTotal
if (mpeg2_cpu_state_save) 0 0 0
1801 0 mpeg2_cpu_state_save (&cpu_state);
1802  
1803 0 while (1) {
1804 int macroblock_modes;
1805 int mba_inc;
1806 const MBAtab * mba;
1807  
1808 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
1809  
1810 0 macroblock_modes = get_macroblock_modes (decoder);
1811  
1812 /* maybe integrate MACROBLOCK_QUANT test into get_macroblock_modes ? */
1813 0 ▶ if (macroblock_modes & MACROBLOCK_QUANT)
Branch: 1 branch
BranchTrueFalseTotal
if (macroblock_modes & MACROBLOCK_QUANT) 0 0 0
1814 0 get_quantizer_scale (decoder);
1815  
1816 0 ▶ if (macroblock_modes & MACROBLOCK_INTRA) {
Branch: 1 branch
BranchTrueFalseTotal
if (macroblock_modes & MACROBLOCK_INTRA) { 0 0 0
1817  
1818 int DCT_offset, DCT_stride;
1819 int offset;
1820 uint8_t * dest_y;
1821  
1822 0 ▶ if (decoder->concealment_motion_vectors) {
Branch: 1 branch
BranchTrueFalseTotal
if (decoder->concealment_motion_vectors) { 0 0 0
1823 0 ▶ if (decoder->picture_structure == FRAME_PICTURE)
Branch: 1 branch
BranchTrueFalseTotal
if (decoder->picture_structure == FRAME_PICTURE) 0 0 0
1824 0 motion_fr_conceal (decoder);
1825 else
1826 0 motion_fi_conceal (decoder);
1827 } else {
1828 0 decoder->f_motion.pmv[0][0] = decoder->f_motion.pmv[0][1] = 0;
1829 0 decoder->f_motion.pmv[1][0] = decoder->f_motion.pmv[1][1] = 0;
1830 0 decoder->b_motion.pmv[0][0] = decoder->b_motion.pmv[0][1] = 0;
1831 0 decoder->b_motion.pmv[1][0] = decoder->b_motion.pmv[1][1] = 0;
1832 }
1833  
1834 0 ▶ if (macroblock_modes & DCT_TYPE_INTERLACED) {
Branch: 1 branch
BranchTrueFalseTotal
if (macroblock_modes & DCT_TYPE_INTERLACED) { 0 0 0
1835 0 DCT_offset = decoder->stride;
1836 0 DCT_stride = decoder->stride * 2;
1837 } else {
1838 0 DCT_offset = decoder->stride * 8;
1839 0 DCT_stride = decoder->stride;
1840 }
1841  
1842 0 offset = decoder->offset;
1843 0 dest_y = decoder->dest[0] + offset;
1844 0 slice_intra_DCT (decoder, 0, dest_y, DCT_stride);
1845 0 slice_intra_DCT (decoder, 0, dest_y + 8, DCT_stride);
1846 0 slice_intra_DCT (decoder, 0, dest_y + DCT_offset, DCT_stride);
1847 0 slice_intra_DCT (decoder, 0, dest_y + DCT_offset + 8, DCT_stride);
1848 0 ▶ if (likely (decoder->chroma_format == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (likely (decoder->chroma_format == 0)) { 0 0 0
1849 0 slice_intra_DCT (decoder, 1, decoder->dest[1] + (offset >> 1),
1850 decoder->uv_stride);
1851 0 slice_intra_DCT (decoder, 2, decoder->dest[2] + (offset >> 1),
1852 decoder->uv_stride);
1853 0 ▶ if (decoder->coding_type == D_TYPE) {
Branch: 1 branch
BranchTrueFalseTotal
if (decoder->coding_type == D_TYPE) { 0 0 0
1854 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
1855 0 DUMPBITS (bit_buf, bits, 1);
1856 }
1857 0 ▶ } else if (likely (decoder->chroma_format == 1)) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (likely (decoder->chroma_format == 1)) { 0 0 0
1858 0 uint8_t * dest_u = decoder->dest[1] + (offset >> 1);
1859 0 uint8_t * dest_v = decoder->dest[2] + (offset >> 1);
1860 0 DCT_stride >>= 1;
1861 0 DCT_offset >>= 1;
1862 0 slice_intra_DCT (decoder, 1, dest_u, DCT_stride);
1863 0 slice_intra_DCT (decoder, 2, dest_v, DCT_stride);
1864 0 slice_intra_DCT (decoder, 1, dest_u + DCT_offset, DCT_stride);
1865 0 slice_intra_DCT (decoder, 2, dest_v + DCT_offset, DCT_stride);
1866 } else {
1867 0 uint8_t * dest_u = decoder->dest[1] + offset;
1868 0 uint8_t * dest_v = decoder->dest[2] + offset;
1869 0 slice_intra_DCT (decoder, 1, dest_u, DCT_stride);
1870 0 slice_intra_DCT (decoder, 2, dest_v, DCT_stride);
1871 0 slice_intra_DCT (decoder, 1, dest_u + DCT_offset, DCT_stride);
1872 0 slice_intra_DCT (decoder, 2, dest_v + DCT_offset, DCT_stride);
1873 0 slice_intra_DCT (decoder, 1, dest_u + 8, DCT_stride);
1874 0 slice_intra_DCT (decoder, 2, dest_v + 8, DCT_stride);
1875 0 slice_intra_DCT (decoder, 1, dest_u + DCT_offset + 8,
1876 DCT_stride);
1877 0 slice_intra_DCT (decoder, 2, dest_v + DCT_offset + 8,
1878 DCT_stride);
1879 }
1880 } else {
1881  
1882 motion_parser_t * parser;
1883  
1884 0 ▶ if ( ((macroblock_modes >> MOTION_TYPE_SHIFT) < 0)
Branch: 1 branch
BranchTrueFalseTotal
if ( ((macroblock_modes >> MOTION_TYPE_SHIFT) < 0) 0 0 0
1885 0 ▶ || ((macroblock_modes >> MOTION_TYPE_SHIFT) >=
Branch: 1 branch
BranchTrueFalseTotal
|| ((macroblock_modes >> MOTION_TYPE_SHIFT) >= 0 0 0
1886 (int)(sizeof(decoder->motion_parser)
1887 / sizeof(decoder->motion_parser[0])))
1888 ) {
1889 break; // Illegal !
1890 }
1891  
1892 0 parser =
1893 0 decoder->motion_parser[macroblock_modes >> MOTION_TYPE_SHIFT];
1894 0 ▶ MOTION_CALL (parser, macroblock_modes);
Branch: 3 branches
BranchTrueFalseTotal
MOTION_CALL (parser, macroblock_modes); 0 0 0
MOTION_CALL (parser, macroblock_modes); 0 0 0
MOTION_CALL (parser, macroblock_modes); 0 0 0
1895  
1896 0 ▶ if (macroblock_modes & MACROBLOCK_PATTERN) {
Branch: 1 branch
BranchTrueFalseTotal
if (macroblock_modes & MACROBLOCK_PATTERN) { 0 0 0
1897 int coded_block_pattern;
1898 int DCT_offset, DCT_stride;
1899  
1900 0 ▶ if (macroblock_modes & DCT_TYPE_INTERLACED) {
Branch: 1 branch
BranchTrueFalseTotal
if (macroblock_modes & DCT_TYPE_INTERLACED) { 0 0 0
1901 0 DCT_offset = decoder->stride;
1902 0 DCT_stride = decoder->stride * 2;
1903 } else {
1904 0 DCT_offset = decoder->stride * 8;
1905 0 DCT_stride = decoder->stride;
1906 }
1907  
1908 0 coded_block_pattern = get_coded_block_pattern (decoder);
1909  
1910 0 ▶ if (likely (decoder->chroma_format == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (likely (decoder->chroma_format == 0)) { 0 0 0
1911 0 int offset = decoder->offset;
1912 0 uint8_t * dest_y = decoder->dest[0] + offset;
1913 0 ▶ if (coded_block_pattern & 1)
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & 1) 0 0 0
1914 0 slice_non_intra_DCT (decoder, 0, dest_y, DCT_stride);
1915 0 ▶ if (coded_block_pattern & 2)
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & 2) 0 0 0
1916 0 slice_non_intra_DCT (decoder, 0, dest_y + 8,
1917 DCT_stride);
1918 0 ▶ if (coded_block_pattern & 4)
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & 4) 0 0 0
1919 0 slice_non_intra_DCT (decoder, 0, dest_y + DCT_offset,
1920 DCT_stride);
1921 0 ▶ if (coded_block_pattern & 8)
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & 8) 0 0 0
1922 0 slice_non_intra_DCT (decoder, 0,
1923 0 dest_y + DCT_offset + 8,
1924 DCT_stride);
1925 0 ▶ if (coded_block_pattern & 16)
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & 16) 0 0 0
1926 0 slice_non_intra_DCT (decoder, 1,
1927 0 decoder->dest[1] + (offset >> 1),
1928 decoder->uv_stride);
1929 0 ▶ if (coded_block_pattern & 32)
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & 32) 0 0 0
1930 0 slice_non_intra_DCT (decoder, 2,
1931 0 decoder->dest[2] + (offset >> 1),
1932 decoder->uv_stride);
1933 0 ▶ } else if (likely (decoder->chroma_format == 1)) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (likely (decoder->chroma_format == 1)) { 0 0 0
1934 int offset;
1935 uint8_t * dest_y;
1936  
1937 0 coded_block_pattern |= bit_buf & (3 << 30);
1938 0 DUMPBITS (bit_buf, bits, 2);
1939  
1940 0 offset = decoder->offset;
1941 0 dest_y = decoder->dest[0] + offset;
1942 0 ▶ if (coded_block_pattern & 1)
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & 1) 0 0 0
1943 0 slice_non_intra_DCT (decoder, 0, dest_y, DCT_stride);
1944 0 ▶ if (coded_block_pattern & 2)
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & 2) 0 0 0
1945 0 slice_non_intra_DCT (decoder, 0, dest_y + 8,
1946 DCT_stride);
1947 0 ▶ if (coded_block_pattern & 4)
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & 4) 0 0 0
1948 0 slice_non_intra_DCT (decoder, 0, dest_y + DCT_offset,
1949 DCT_stride);
1950 0 ▶ if (coded_block_pattern & 8)
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & 8) 0 0 0
1951 0 slice_non_intra_DCT (decoder, 0,
1952 0 dest_y + DCT_offset + 8,
1953 DCT_stride);
1954  
1955 0 DCT_stride >>= 1;
1956 0 DCT_offset = (DCT_offset + offset) >> 1;
1957 0 ▶ if (coded_block_pattern & 16)
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & 16) 0 0 0
1958 0 slice_non_intra_DCT (decoder, 1,
1959 0 decoder->dest[1] + (offset >> 1),
1960 DCT_stride);
1961 0 ▶ if (coded_block_pattern & 32)
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & 32) 0 0 0
1962 0 slice_non_intra_DCT (decoder, 2,
1963 0 decoder->dest[2] + (offset >> 1),
1964 DCT_stride);
1965 0 ▶ if (coded_block_pattern & (2 << 30))
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & (2 << 30)) 0 0 0
1966 0 slice_non_intra_DCT (decoder, 1,
1967 0 decoder->dest[1] + DCT_offset,
1968 DCT_stride);
1969 0 ▶ if (coded_block_pattern & (1 << 30))
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & (1 << 30)) 0 0 0
1970 0 slice_non_intra_DCT (decoder, 2,
1971 0 decoder->dest[2] + DCT_offset,
1972 DCT_stride);
1973 } else {
1974 int offset;
1975 uint8_t * dest_y, * dest_u, * dest_v;
1976  
1977 0 coded_block_pattern |= bit_buf & (63 << 26);
1978 0 DUMPBITS (bit_buf, bits, 6);
1979  
1980 0 offset = decoder->offset;
1981 0 dest_y = decoder->dest[0] + offset;
1982 0 dest_u = decoder->dest[1] + offset;
1983 0 dest_v = decoder->dest[2] + offset;
1984  
1985 0 ▶ if (coded_block_pattern & 1)
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & 1) 0 0 0
1986 0 slice_non_intra_DCT (decoder, 0, dest_y, DCT_stride);
1987 0 ▶ if (coded_block_pattern & 2)
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & 2) 0 0 0
1988 0 slice_non_intra_DCT (decoder, 0, dest_y + 8,
1989 DCT_stride);
1990 0 ▶ if (coded_block_pattern & 4)
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & 4) 0 0 0
1991 0 slice_non_intra_DCT (decoder, 0, dest_y + DCT_offset,
1992 DCT_stride);
1993 0 ▶ if (coded_block_pattern & 8)
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & 8) 0 0 0
1994 0 slice_non_intra_DCT (decoder, 0,
1995 0 dest_y + DCT_offset + 8,
1996 DCT_stride);
1997  
1998 0 ▶ if (coded_block_pattern & 16)
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & 16) 0 0 0
1999 0 slice_non_intra_DCT (decoder, 1, dest_u, DCT_stride);
2000 0 ▶ if (coded_block_pattern & 32)
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & 32) 0 0 0
2001 0 slice_non_intra_DCT (decoder, 2, dest_v, DCT_stride);
2002 0 ▶ if (coded_block_pattern & (32 << 26))
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & (32 << 26)) 0 0 0
2003 0 slice_non_intra_DCT (decoder, 1, dest_u + DCT_offset,
2004 DCT_stride);
2005 0 ▶ if (coded_block_pattern & (16 << 26))
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & (16 << 26)) 0 0 0
2006 0 slice_non_intra_DCT (decoder, 2, dest_v + DCT_offset,
2007 DCT_stride);
2008 0 ▶ if (coded_block_pattern & (8 << 26))
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & (8 << 26)) 0 0 0
2009 0 slice_non_intra_DCT (decoder, 1, dest_u + 8,
2010 DCT_stride);
2011 0 ▶ if (coded_block_pattern & (4 << 26))
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & (4 << 26)) 0 0 0
2012 0 slice_non_intra_DCT (decoder, 2, dest_v + 8,
2013 DCT_stride);
2014 0 ▶ if (coded_block_pattern & (2 << 26))
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & (2 << 26)) 0 0 0
2015 0 slice_non_intra_DCT (decoder, 1,
2016 0 dest_u + DCT_offset + 8,
2017 DCT_stride);
2018 0 ▶ if (coded_block_pattern & (1 << 26))
Branch: 1 branch
BranchTrueFalseTotal
if (coded_block_pattern & (1 << 26)) 0 0 0
2019 0 slice_non_intra_DCT (decoder, 2,
2020 0 dest_v + DCT_offset + 8,
2021 DCT_stride);
2022 }
2023 }
2024  
2025 0 decoder->dc_dct_pred[0] = decoder->dc_dct_pred[1] =
2026 0 decoder->dc_dct_pred[2] = 16384;
2027 }
2028  
2029 0 ▶ NEXT_MACROBLOCK;
Branch: 5 branches
BranchTrueFalseTotal
NEXT_MACROBLOCK; 0 0 0
NEXT_MACROBLOCK; 0 0 0
NEXT_MACROBLOCK; 0 0 0
NEXT_MACROBLOCK; 0 0 0
NEXT_MACROBLOCK; 0 0 0
2030  
2031 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
2032 0 mba_inc = 0;
2033 while (1) {
2034 0 ▶ if (bit_buf >= 0x10000000) {
Branch: 1 branch
BranchTrueFalseTotal
if (bit_buf >= 0x10000000) { 0 0 0
2035 0 mba = MBA_5 + (UBITS (bit_buf, 5) - 2);
2036 0 break;
2037 0 ▶ } else if (bit_buf >= 0x03000000) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (bit_buf >= 0x03000000) { 0 0 0
2038 0 mba = MBA_11 + (UBITS (bit_buf, 11) - 24);
2039 0 break;
2040 0 } else switch (UBITS (bit_buf, 11)) {
2041 0 case 8: /* macroblock_escape */
2042 0 mba_inc += 33;
2043 /* pass through */
2044 0 case 15: /* macroblock_stuffing (MPEG1 only) */
2045 0 DUMPBITS (bit_buf, bits, 11);
2046 0 ▶ NEEDBITS (bit_buf, bits, bit_ptr);
Branch: 1 branch
BranchTrueFalseTotal
NEEDBITS (bit_buf, bits, bit_ptr); 0 0 0
2047 0 continue;
2048 0 default: /* end of slice, or error */
2049 0 ▶ if (mpeg2_cpu_state_restore)
Branch: 1 branch
BranchTrueFalseTotal
if (mpeg2_cpu_state_restore) 0 0 0
2050 0 mpeg2_cpu_state_restore (&cpu_state);
2051 0 return;
2052 }
2053 }
2054 0 DUMPBITS (bit_buf, bits, mba->len);
2055 0 mba_inc += mba->mba;
2056  
2057 0 ▶ if (mba_inc) {
Branch: 1 branch
BranchTrueFalseTotal
if (mba_inc) { 0 0 0
2058 0 decoder->dc_dct_pred[0] = decoder->dc_dct_pred[1] =
2059 0 decoder->dc_dct_pred[2] = 16384;
2060  
2061 0 ▶ if (decoder->coding_type == P_TYPE) {
Branch: 1 branch
BranchTrueFalseTotal
if (decoder->coding_type == P_TYPE) { 0 0 0
2062 do {
2063 0 MOTION_CALL (decoder->motion_parser[0],
2064 MACROBLOCK_MOTION_FORWARD);
2065 0 ▶ NEXT_MACROBLOCK;
Branch: 5 branches
BranchTrueFalseTotal
NEXT_MACROBLOCK; 0 0 0
NEXT_MACROBLOCK; 0 0 0
NEXT_MACROBLOCK; 0 0 0
NEXT_MACROBLOCK; 0 0 0
NEXT_MACROBLOCK; 0 0 0
2066 0 ▶ } while (--mba_inc);
Branch: 1 branch
BranchTrueFalseTotal
} while (--mba_inc); 0 0 0
2067 } else {
2068 do {
2069 0 ▶ MOTION_CALL (decoder->motion_parser[4], macroblock_modes);
Branch: 3 branches
BranchTrueFalseTotal
MOTION_CALL (decoder->motion_parser[4], macroblock_modes); 0 0 0
MOTION_CALL (decoder->motion_parser[4], macroblock_modes); 0 0 0
MOTION_CALL (decoder->motion_parser[4], macroblock_modes); 0 0 0
2070 0 ▶ NEXT_MACROBLOCK;
Branch: 5 branches
BranchTrueFalseTotal
NEXT_MACROBLOCK; 0 0 0
NEXT_MACROBLOCK; 0 0 0
NEXT_MACROBLOCK; 0 0 0
NEXT_MACROBLOCK; 0 0 0
NEXT_MACROBLOCK; 0 0 0
2071 0 ▶ } while (--mba_inc);
Branch: 1 branch
BranchTrueFalseTotal
} while (--mba_inc); 0 0 0
2072 }
2073 }
2074 }
2075 #undef bit_buf
2076 #undef bits
2077 #undef bit_ptr
2078 }
« clib/libmpeg2/motion_comp_mmx.c ↑ Summary clib/libmpeg2/src/dump_state.c »