annotate libmpeg2/slice.c @ 14093:3bf74bf969ff

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