annotate libmpeg2/slice.c @ 12973:093afb92e4d5

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