Parent Directory
|
Revision Log
Revision 937 - (view) (download)
1 : | edgomez | 851 | /****************************************************************************** |
2 : | * * | ||
3 : | * This file is part of XviD, a free MPEG-4 video encoder/decoder * | ||
4 : | * * | ||
5 : | * XviD is an implementation of a part of one or more MPEG-4 Video tools * | ||
6 : | * as specified in ISO/IEC 14496-2 standard. Those intending to use this * | ||
7 : | * software module in hardware or software products are advised that its * | ||
8 : | * use may infringe existing patents or copyrights, and any such use * | ||
9 : | * would be at such party's own risk. The original developer of this * | ||
10 : | * software module and his/her company, and subsequent editors and their * | ||
11 : | * companies, will have no liability for use of this software or * | ||
12 : | * modifications or derivatives thereof. * | ||
13 : | * * | ||
14 : | * XviD is free software; you can redistribute it and/or modify it * | ||
15 : | * under the terms of the GNU General Public License as published by * | ||
16 : | * the Free Software Foundation; either version 2 of the License, or * | ||
17 : | * (at your option) any later version. * | ||
18 : | * * | ||
19 : | * XviD is distributed in the hope that it will be useful, but * | ||
20 : | * WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
21 : | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
22 : | * GNU General Public License for more details. * | ||
23 : | * * | ||
24 : | * You should have received a copy of the GNU General Public License * | ||
25 : | * along with this program; if not, write to the Free Software * | ||
26 : | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * | ||
27 : | * * | ||
28 : | ******************************************************************************/ | ||
29 : | Isibaar | 3 | |
30 : | edgomez | 851 | /****************************************************************************** |
31 : | * * | ||
32 : | * mbtransquant.c * | ||
33 : | * * | ||
34 : | * Copyright (C) 2001 - Peter Ross <pross@cs.rmit.edu.au> * | ||
35 : | * Copyright (C) 2001 - Michael Militzer <isibaar@xvid.org> * | ||
36 : | * * | ||
37 : | * For more information visit the XviD homepage: http://www.xvid.org * | ||
38 : | * * | ||
39 : | ******************************************************************************/ | ||
40 : | |||
41 : | /****************************************************************************** | ||
42 : | * * | ||
43 : | * Revision history: * | ||
44 : | * * | ||
45 : | * 29.03.2002 interlacing speedup - used transfer strides instead of * | ||
46 : | * manual field-to-frame conversion * | ||
47 : | * 26.03.2002 interlacing support - moved transfers outside loops * | ||
48 : | * 22.12.2001 get_dc_scaler() moved to common.h * | ||
49 : | * 19.11.2001 introduced coefficient thresholding (Isibaar) * | ||
50 : | * 17.11.2001 initial version * | ||
51 : | * * | ||
52 : | ******************************************************************************/ | ||
53 : | |||
54 : | edgomez | 78 | #include <string.h> |
55 : | |||
56 : | Isibaar | 3 | #include "../portab.h" |
57 : | #include "mbfunctions.h" | ||
58 : | |||
59 : | #include "../global.h" | ||
60 : | #include "mem_transfer.h" | ||
61 : | #include "timer.h" | ||
62 : | #include "../dct/fdct.h" | ||
63 : | #include "../dct/idct.h" | ||
64 : | #include "../quant/quant_mpeg4.h" | ||
65 : | #include "../quant/quant_h263.h" | ||
66 : | #include "../encoder.h" | ||
67 : | |||
68 : | edgomez | 851 | #include "../image/reduced.h" |
69 : | Isibaar | 3 | |
70 : | edgomez | 851 | MBFIELDTEST_PTR MBFieldTest; |
71 : | Isibaar | 3 | |
72 : | edgomez | 851 | #define TOOSMALL_LIMIT 1 /* skip blocks having a coefficient sum below this value */ |
73 : | Isibaar | 3 | |
74 : | syskin | 937 | static __inline void |
75 : | MBfDCT(int16_t data[6 * 64]) | ||
76 : | { | ||
77 : | start_timer(); | ||
78 : | fdct(&data[0 * 64]); | ||
79 : | fdct(&data[1 * 64]); | ||
80 : | fdct(&data[2 * 64]); | ||
81 : | fdct(&data[3 * 64]); | ||
82 : | fdct(&data[4 * 64]); | ||
83 : | fdct(&data[5 * 64]); | ||
84 : | stop_dct_timer(); | ||
85 : | } | ||
86 : | |||
87 : | |||
88 : | static __inline uint32_t | ||
89 : | QuantizeInterBlock( int16_t qcoeff[64], | ||
90 : | const int16_t data[64], | ||
91 : | const uint32_t iQuant, | ||
92 : | const uint32_t quant_type) | ||
93 : | { | ||
94 : | uint32_t sum; | ||
95 : | |||
96 : | start_timer(); | ||
97 : | if (quant_type == H263_QUANT) | ||
98 : | sum = quant_inter(qcoeff, data, iQuant); | ||
99 : | else | ||
100 : | sum = quant4_inter(qcoeff, data, iQuant); | ||
101 : | |||
102 : | stop_quant_timer(); | ||
103 : | return sum; | ||
104 : | } | ||
105 : | |||
106 : | edgomez | 195 | void |
107 : | syskin | 937 | MBTransQuantIntra(const MBParam * const pParam, |
108 : | FRAMEINFO * const frame, | ||
109 : | MACROBLOCK * const pMB, | ||
110 : | const uint32_t x_pos, | ||
111 : | const uint32_t y_pos, | ||
112 : | int16_t data[6 * 64], | ||
113 : | int16_t qcoeff[6 * 64]) | ||
114 : | Isibaar | 3 | { |
115 : | edgomez | 78 | |
116 : | h | 82 | uint32_t stride = pParam->edged_width; |
117 : | syskin | 937 | const uint32_t stride2 = stride / 2; |
118 : | edgomez | 851 | uint32_t next_block = stride * ((frame->global_flags & XVID_REDUCED)?16:8); |
119 : | syskin | 937 | int i; |
120 : | const uint32_t iQuant = pMB->quant; | ||
121 : | Isibaar | 3 | uint8_t *pY_Cur, *pU_Cur, *pV_Cur; |
122 : | syskin | 937 | const IMAGE * const pCurrent = &frame->image; |
123 : | Isibaar | 3 | |
124 : | edgomez | 851 | start_timer(); |
125 : | if ((frame->global_flags & XVID_REDUCED)) | ||
126 : | { | ||
127 : | pY_Cur = pCurrent->y + (y_pos << 5) * stride + (x_pos << 5); | ||
128 : | pU_Cur = pCurrent->u + (y_pos << 4) * stride2 + (x_pos << 4); | ||
129 : | pV_Cur = pCurrent->v + (y_pos << 4) * stride2 + (x_pos << 4); | ||
130 : | h | 69 | |
131 : | edgomez | 851 | filter_18x18_to_8x8(&data[0 * 64], pY_Cur, stride); |
132 : | filter_18x18_to_8x8(&data[1 * 64], pY_Cur + 16, stride); | ||
133 : | filter_18x18_to_8x8(&data[2 * 64], pY_Cur + next_block, stride); | ||
134 : | filter_18x18_to_8x8(&data[3 * 64], pY_Cur + next_block + 16, stride); | ||
135 : | filter_18x18_to_8x8(&data[4 * 64], pU_Cur, stride2); | ||
136 : | filter_18x18_to_8x8(&data[5 * 64], pV_Cur, stride2); | ||
137 : | syskin | 937 | } else { |
138 : | edgomez | 851 | pY_Cur = pCurrent->y + (y_pos << 4) * stride + (x_pos << 4); |
139 : | pU_Cur = pCurrent->u + (y_pos << 3) * stride2 + (x_pos << 3); | ||
140 : | pV_Cur = pCurrent->v + (y_pos << 3) * stride2 + (x_pos << 3); | ||
141 : | |||
142 : | transfer_8to16copy(&data[0 * 64], pY_Cur, stride); | ||
143 : | transfer_8to16copy(&data[1 * 64], pY_Cur + 8, stride); | ||
144 : | transfer_8to16copy(&data[2 * 64], pY_Cur + next_block, stride); | ||
145 : | transfer_8to16copy(&data[3 * 64], pY_Cur + next_block + 8, stride); | ||
146 : | transfer_8to16copy(&data[4 * 64], pU_Cur, stride2); | ||
147 : | transfer_8to16copy(&data[5 * 64], pV_Cur, stride2); | ||
148 : | } | ||
149 : | h | 69 | stop_transfer_timer(); |
150 : | |||
151 : | edgomez | 851 | /* XXX: rrv+interlacing is buggy */ |
152 : | h | 69 | start_timer(); |
153 : | pMB->field_dct = 0; | ||
154 : | h | 390 | if ((frame->global_flags & XVID_INTERLACING) && |
155 : | (x_pos>0) && (x_pos<pParam->mb_width-1) && | ||
156 : | (y_pos>0) && (y_pos<pParam->mb_height-1)) { | ||
157 : | h | 69 | pMB->field_dct = MBDecideFieldDCT(data); |
158 : | } | ||
159 : | stop_interlacing_timer(); | ||
160 : | |||
161 : | syskin | 937 | MBfDCT(data); |
162 : | |||
163 : | edgomez | 195 | for (i = 0; i < 6; i++) { |
164 : | syskin | 937 | const uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4); |
165 : | Isibaar | 3 | |
166 : | start_timer(); | ||
167 : | syskin | 937 | if (pParam->m_quant_type == H263_QUANT) |
168 : | edgomez | 195 | quant_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler); |
169 : | syskin | 937 | else |
170 : | edgomez | 195 | quant4_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler); |
171 : | syskin | 937 | stop_quant_timer(); |
172 : | Isibaar | 3 | |
173 : | edgomez | 851 | /* speedup: dont decode when encoding only ivops */ |
174 : | if (pParam->iMaxKeyInterval != 1 || pParam->max_bframes > 0) | ||
175 : | { | ||
176 : | syskin | 937 | start_timer(); |
177 : | if (pParam->m_quant_type == H263_QUANT) | ||
178 : | edgomez | 851 | dequant_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler); |
179 : | syskin | 937 | else |
180 : | edgomez | 851 | dequant4_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler); |
181 : | syskin | 937 | stop_iquant_timer(); |
182 : | edgomez | 851 | |
183 : | Isibaar | 3 | start_timer(); |
184 : | edgomez | 851 | idct(&data[i * 64]); |
185 : | stop_idct_timer(); | ||
186 : | Isibaar | 3 | } |
187 : | edgomez | 851 | } |
188 : | Isibaar | 3 | |
189 : | edgomez | 851 | /* speedup: dont decode when encoding only ivops */ |
190 : | if (pParam->iMaxKeyInterval != 1 || pParam->max_bframes > 0) | ||
191 : | { | ||
192 : | |||
193 : | if (pMB->field_dct) { | ||
194 : | next_block = stride; | ||
195 : | stride *= 2; | ||
196 : | } | ||
197 : | |||
198 : | Isibaar | 3 | start_timer(); |
199 : | syskin | 937 | if ((frame->global_flags & XVID_REDUCED)) { |
200 : | edgomez | 851 | copy_upsampled_8x8_16to8(pY_Cur, &data[0 * 64], stride); |
201 : | copy_upsampled_8x8_16to8(pY_Cur + 16, &data[1 * 64], stride); | ||
202 : | copy_upsampled_8x8_16to8(pY_Cur + next_block, &data[2 * 64], stride); | ||
203 : | copy_upsampled_8x8_16to8(pY_Cur + next_block + 16, &data[3 * 64], stride); | ||
204 : | copy_upsampled_8x8_16to8(pU_Cur, &data[4 * 64], stride2); | ||
205 : | copy_upsampled_8x8_16to8(pV_Cur, &data[5 * 64], stride2); | ||
206 : | syskin | 937 | } else { |
207 : | edgomez | 851 | transfer_16to8copy(pY_Cur, &data[0 * 64], stride); |
208 : | transfer_16to8copy(pY_Cur + 8, &data[1 * 64], stride); | ||
209 : | transfer_16to8copy(pY_Cur + next_block, &data[2 * 64], stride); | ||
210 : | transfer_16to8copy(pY_Cur + next_block + 8, &data[3 * 64], stride); | ||
211 : | transfer_16to8copy(pU_Cur, &data[4 * 64], stride2); | ||
212 : | transfer_16to8copy(pV_Cur, &data[5 * 64], stride2); | ||
213 : | } | ||
214 : | stop_transfer_timer(); | ||
215 : | h | 69 | } |
216 : | |||
217 : | Isibaar | 3 | } |
218 : | |||
219 : | edgomez | 195 | uint8_t |
220 : | syskin | 937 | MBTransQuantInter(const MBParam * const pParam, |
221 : | FRAMEINFO * const frame, | ||
222 : | MACROBLOCK * const pMB, | ||
223 : | const uint32_t x_pos, | ||
224 : | const uint32_t y_pos, | ||
225 : | int16_t data[6 * 64], | ||
226 : | int16_t qcoeff[6 * 64]) | ||
227 : | Isibaar | 3 | { |
228 : | h | 82 | uint32_t stride = pParam->edged_width; |
229 : | syskin | 937 | const uint32_t stride2 = stride / 2; |
230 : | edgomez | 851 | uint32_t next_block = stride * ((frame->global_flags & XVID_REDUCED)?16:8); |
231 : | syskin | 937 | int i; |
232 : | const uint32_t iQuant = pMB->quant; | ||
233 : | Isibaar | 3 | uint8_t *pY_Cur, *pU_Cur, *pV_Cur; |
234 : | syskin | 937 | int cbp = 0; |
235 : | Isibaar | 3 | uint32_t sum; |
236 : | syskin | 937 | const IMAGE * const pCurrent = &frame->image; |
237 : | edgomez | 195 | |
238 : | syskin | 937 | if ((frame->global_flags & XVID_REDUCED)) { |
239 : | edgomez | 851 | pY_Cur = pCurrent->y + (y_pos << 5) * stride + (x_pos << 5); |
240 : | pU_Cur = pCurrent->u + (y_pos << 4) * stride2 + (x_pos << 4); | ||
241 : | pV_Cur = pCurrent->v + (y_pos << 4) * stride2 + (x_pos << 4); | ||
242 : | syskin | 937 | } else { |
243 : | edgomez | 851 | pY_Cur = pCurrent->y + (y_pos << 4) * stride + (x_pos << 4); |
244 : | pU_Cur = pCurrent->u + (y_pos << 3) * stride2 + (x_pos << 3); | ||
245 : | pV_Cur = pCurrent->v + (y_pos << 3) * stride2 + (x_pos << 3); | ||
246 : | } | ||
247 : | Isibaar | 3 | |
248 : | h | 69 | start_timer(); |
249 : | pMB->field_dct = 0; | ||
250 : | h | 390 | if ((frame->global_flags & XVID_INTERLACING) && |
251 : | (x_pos>0) && (x_pos<pParam->mb_width-1) && | ||
252 : | (y_pos>0) && (y_pos<pParam->mb_height-1)) { | ||
253 : | h | 69 | pMB->field_dct = MBDecideFieldDCT(data); |
254 : | } | ||
255 : | stop_interlacing_timer(); | ||
256 : | |||
257 : | syskin | 937 | MBfDCT(data); |
258 : | edgomez | 851 | |
259 : | syskin | 937 | for (i = 0; i < 6; i++) { |
260 : | const uint32_t limit = TOOSMALL_LIMIT + ((iQuant == 1) ? 1 : 0); | ||
261 : | /* | ||
262 : | edgomez | 78 | * no need to transfer 8->16-bit |
263 : | syskin | 937 | * (this is performed already in motion compensation) |
264 : | edgomez | 78 | */ |
265 : | Isibaar | 3 | |
266 : | syskin | 937 | sum = QuantizeInterBlock(&qcoeff[i * 64], &data[i * 64], iQuant, pParam->m_quant_type); |
267 : | Isibaar | 3 | |
268 : | syskin | 937 | if (sum >= limit) { |
269 : | Isibaar | 3 | |
270 : | syskin | 937 | start_timer(); |
271 : | if (pParam->m_quant_type == H263_QUANT) | ||
272 : | edgomez | 195 | dequant_inter(&data[i * 64], &qcoeff[i * 64], iQuant); |
273 : | syskin | 937 | else |
274 : | edgomez | 195 | dequant4_inter(&data[i * 64], &qcoeff[i * 64], iQuant); |
275 : | syskin | 937 | stop_iquant_timer(); |
276 : | Isibaar | 3 | |
277 : | cbp |= 1 << (5 - i); | ||
278 : | |||
279 : | start_timer(); | ||
280 : | edgomez | 195 | idct(&data[i * 64]); |
281 : | Isibaar | 3 | stop_idct_timer(); |
282 : | } | ||
283 : | } | ||
284 : | h | 69 | |
285 : | edgomez | 195 | if (pMB->field_dct) { |
286 : | h | 82 | next_block = stride; |
287 : | stride *= 2; | ||
288 : | h | 69 | } |
289 : | |||
290 : | start_timer(); | ||
291 : | syskin | 937 | if ((frame->global_flags & XVID_REDUCED)) { |
292 : | edgomez | 851 | if (cbp & 32) |
293 : | add_upsampled_8x8_16to8(pY_Cur, &data[0 * 64], stride); | ||
294 : | if (cbp & 16) | ||
295 : | add_upsampled_8x8_16to8(pY_Cur + 16, &data[1 * 64], stride); | ||
296 : | if (cbp & 8) | ||
297 : | add_upsampled_8x8_16to8(pY_Cur + next_block, &data[2 * 64], stride); | ||
298 : | if (cbp & 4) | ||
299 : | add_upsampled_8x8_16to8(pY_Cur + 16 + next_block, &data[3 * 64], stride); | ||
300 : | if (cbp & 2) | ||
301 : | add_upsampled_8x8_16to8(pU_Cur, &data[4 * 64], stride2); | ||
302 : | if (cbp & 1) | ||
303 : | add_upsampled_8x8_16to8(pV_Cur, &data[5 * 64], stride2); | ||
304 : | syskin | 937 | } else { |
305 : | edgomez | 851 | if (cbp & 32) |
306 : | transfer_16to8add(pY_Cur, &data[0 * 64], stride); | ||
307 : | if (cbp & 16) | ||
308 : | transfer_16to8add(pY_Cur + 8, &data[1 * 64], stride); | ||
309 : | if (cbp & 8) | ||
310 : | transfer_16to8add(pY_Cur + next_block, &data[2 * 64], stride); | ||
311 : | if (cbp & 4) | ||
312 : | transfer_16to8add(pY_Cur + next_block + 8, &data[3 * 64], stride); | ||
313 : | if (cbp & 2) | ||
314 : | transfer_16to8add(pU_Cur, &data[4 * 64], stride2); | ||
315 : | if (cbp & 1) | ||
316 : | transfer_16to8add(pV_Cur, &data[5 * 64], stride2); | ||
317 : | } | ||
318 : | h | 69 | stop_transfer_timer(); |
319 : | |||
320 : | syskin | 937 | return (uint8_t) cbp; |
321 : | Isibaar | 3 | } |
322 : | h | 69 | |
323 : | chl | 368 | uint8_t |
324 : | MBTransQuantInterBVOP(const MBParam * pParam, | ||
325 : | FRAMEINFO * frame, | ||
326 : | MACROBLOCK * pMB, | ||
327 : | int16_t data[6 * 64], | ||
328 : | int16_t qcoeff[6 * 64]) | ||
329 : | { | ||
330 : | syskin | 937 | int cbp = 0; |
331 : | chl | 368 | int i; |
332 : | |||
333 : | syskin | 937 | /* there is no MBTrans for Inter block, that's done in motion compensation already */ |
334 : | chl | 368 | |
335 : | start_timer(); | ||
336 : | pMB->field_dct = 0; | ||
337 : | if ((frame->global_flags & XVID_INTERLACING)) { | ||
338 : | pMB->field_dct = MBDecideFieldDCT(data); | ||
339 : | } | ||
340 : | stop_interlacing_timer(); | ||
341 : | |||
342 : | syskin | 937 | MBfDCT(data); |
343 : | chl | 368 | |
344 : | for (i = 0; i < 6; i++) { | ||
345 : | syskin | 937 | int codedecision = 0; |
346 : | chl | 368 | |
347 : | syskin | 937 | int sum = QuantizeInterBlock(&qcoeff[i * 64], &data[i * 64], pMB->quant, pParam->m_quant_type); |
348 : | |||
349 : | if ((sum > 2) || (qcoeff[i*64+1] != 0) || (qcoeff[i*64+8] != 0) ) codedecision = 1; | ||
350 : | else { | ||
351 : | if (pMB->mode == MODE_DIRECT || pMB->mode == MODE_DIRECT_NO4V) { | ||
352 : | // dark blocks prevention for direct mode | ||
353 : | if ( (qcoeff[i*64] < -1) || (qcoeff[i*64] > 0) ) codedecision = 1; | ||
354 : | } else | ||
355 : | if (qcoeff[i*64] != 0) codedecision = 1; // not direct mode | ||
356 : | chl | 368 | } |
357 : | |||
358 : | syskin | 937 | if (codedecision) cbp |= 1 << (5 - i); |
359 : | chl | 368 | } |
360 : | |||
361 : | syskin | 937 | /* we don't have to DeQuant, iDCT and Transfer back data for B-frames if we don't reconstruct this frame */ |
362 : | /* warning: reconstruction not supported yet */ | ||
363 : | return (uint8_t) cbp; | ||
364 : | chl | 368 | } |
365 : | |||
366 : | edgomez | 851 | /* permute block and return field dct choice */ |
367 : | h | 69 | |
368 : | syskin | 937 | static uint32_t |
369 : | edgomez | 195 | MBDecideFieldDCT(int16_t data[6 * 64]) |
370 : | h | 69 | { |
371 : | syskin | 937 | const uint32_t field = MBFieldTest(data); |
372 : | if (field) MBFrameToField(data); | ||
373 : | h | 69 | |
374 : | edgomez | 851 | return field; |
375 : | } | ||
376 : | |||
377 : | /* if sum(diff between field lines) < sum(diff between frame lines), use field dct */ | ||
378 : | |||
379 : | uint32_t | ||
380 : | MBFieldTest_c(int16_t data[6 * 64]) | ||
381 : | { | ||
382 : | edgomez | 195 | const uint8_t blocks[] = |
383 : | { 0 * 64, 0 * 64, 0 * 64, 0 * 64, 2 * 64, 2 * 64, 2 * 64, 2 * 64 }; | ||
384 : | const uint8_t lines[] = { 0, 16, 32, 48, 0, 16, 32, 48 }; | ||
385 : | edgomez | 78 | |
386 : | h | 69 | int frame = 0, field = 0; |
387 : | int i, j; | ||
388 : | |||
389 : | edgomez | 195 | for (i = 0; i < 7; ++i) { |
390 : | for (j = 0; j < 8; ++j) { | ||
391 : | frame += | ||
392 : | ABS(data[0 * 64 + (i + 1) * 8 + j] - data[0 * 64 + i * 8 + j]); | ||
393 : | frame += | ||
394 : | ABS(data[1 * 64 + (i + 1) * 8 + j] - data[1 * 64 + i * 8 + j]); | ||
395 : | frame += | ||
396 : | ABS(data[2 * 64 + (i + 1) * 8 + j] - data[2 * 64 + i * 8 + j]); | ||
397 : | frame += | ||
398 : | ABS(data[3 * 64 + (i + 1) * 8 + j] - data[3 * 64 + i * 8 + j]); | ||
399 : | h | 69 | |
400 : | edgomez | 195 | field += |
401 : | ABS(data[blocks[i + 1] + lines[i + 1] + j] - | ||
402 : | data[blocks[i] + lines[i] + j]); | ||
403 : | field += | ||
404 : | ABS(data[blocks[i + 1] + lines[i + 1] + 8 + j] - | ||
405 : | data[blocks[i] + lines[i] + 8 + j]); | ||
406 : | field += | ||
407 : | ABS(data[blocks[i + 1] + 64 + lines[i + 1] + j] - | ||
408 : | data[blocks[i] + 64 + lines[i] + j]); | ||
409 : | field += | ||
410 : | ABS(data[blocks[i + 1] + 64 + lines[i + 1] + 8 + j] - | ||
411 : | data[blocks[i] + 64 + lines[i] + 8 + j]); | ||
412 : | h | 69 | } |
413 : | } | ||
414 : | |||
415 : | edgomez | 851 | return (frame >= (field + 350)); |
416 : | h | 69 | } |
417 : | |||
418 : | |||
419 : | /* deinterlace Y blocks vertically */ | ||
420 : | |||
421 : | #define MOVLINE(X,Y) memcpy(X, Y, sizeof(tmp)) | ||
422 : | edgomez | 78 | #define LINE(X,Y) &data[X*64 + Y*8] |
423 : | h | 69 | |
424 : | edgomez | 195 | void |
425 : | MBFrameToField(int16_t data[6 * 64]) | ||
426 : | h | 69 | { |
427 : | int16_t tmp[8]; | ||
428 : | |||
429 : | /* left blocks */ | ||
430 : | |||
431 : | edgomez | 851 | // 1=2, 2=4, 4=8, 8=1 |
432 : | edgomez | 195 | MOVLINE(tmp, LINE(0, 1)); |
433 : | MOVLINE(LINE(0, 1), LINE(0, 2)); | ||
434 : | MOVLINE(LINE(0, 2), LINE(0, 4)); | ||
435 : | MOVLINE(LINE(0, 4), LINE(2, 0)); | ||
436 : | MOVLINE(LINE(2, 0), tmp); | ||
437 : | h | 69 | |
438 : | edgomez | 851 | // 3=6, 6=12, 12=9, 9=3 |
439 : | edgomez | 195 | MOVLINE(tmp, LINE(0, 3)); |
440 : | MOVLINE(LINE(0, 3), LINE(0, 6)); | ||
441 : | MOVLINE(LINE(0, 6), LINE(2, 4)); | ||
442 : | MOVLINE(LINE(2, 4), LINE(2, 1)); | ||
443 : | MOVLINE(LINE(2, 1), tmp); | ||
444 : | h | 69 | |
445 : | edgomez | 851 | // 5=10, 10=5 |
446 : | edgomez | 195 | MOVLINE(tmp, LINE(0, 5)); |
447 : | MOVLINE(LINE(0, 5), LINE(2, 2)); | ||
448 : | MOVLINE(LINE(2, 2), tmp); | ||
449 : | h | 69 | |
450 : | edgomez | 851 | // 7=14, 14=13, 13=11, 11=7 |
451 : | edgomez | 195 | MOVLINE(tmp, LINE(0, 7)); |
452 : | MOVLINE(LINE(0, 7), LINE(2, 6)); | ||
453 : | MOVLINE(LINE(2, 6), LINE(2, 5)); | ||
454 : | MOVLINE(LINE(2, 5), LINE(2, 3)); | ||
455 : | MOVLINE(LINE(2, 3), tmp); | ||
456 : | h | 69 | |
457 : | /* right blocks */ | ||
458 : | |||
459 : | edgomez | 851 | // 1=2, 2=4, 4=8, 8=1 |
460 : | edgomez | 195 | MOVLINE(tmp, LINE(1, 1)); |
461 : | MOVLINE(LINE(1, 1), LINE(1, 2)); | ||
462 : | MOVLINE(LINE(1, 2), LINE(1, 4)); | ||
463 : | MOVLINE(LINE(1, 4), LINE(3, 0)); | ||
464 : | MOVLINE(LINE(3, 0), tmp); | ||
465 : | h | 69 | |
466 : | edgomez | 851 | // 3=6, 6=12, 12=9, 9=3 |
467 : | edgomez | 195 | MOVLINE(tmp, LINE(1, 3)); |
468 : | MOVLINE(LINE(1, 3), LINE(1, 6)); | ||
469 : | MOVLINE(LINE(1, 6), LINE(3, 4)); | ||
470 : | MOVLINE(LINE(3, 4), LINE(3, 1)); | ||
471 : | MOVLINE(LINE(3, 1), tmp); | ||
472 : | h | 69 | |
473 : | edgomez | 851 | // 5=10, 10=5 |
474 : | edgomez | 195 | MOVLINE(tmp, LINE(1, 5)); |
475 : | MOVLINE(LINE(1, 5), LINE(3, 2)); | ||
476 : | MOVLINE(LINE(3, 2), tmp); | ||
477 : | h | 69 | |
478 : | edgomez | 851 | // 7=14, 14=13, 13=11, 11=7 |
479 : | edgomez | 195 | MOVLINE(tmp, LINE(1, 7)); |
480 : | MOVLINE(LINE(1, 7), LINE(3, 6)); | ||
481 : | MOVLINE(LINE(3, 6), LINE(3, 5)); | ||
482 : | MOVLINE(LINE(3, 5), LINE(3, 3)); | ||
483 : | MOVLINE(LINE(3, 3), tmp); | ||
484 : | h | 69 | } |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |