annotate libmpeg2/slice.c @ 6961:201b25a9b939

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