[svn] / branches / dev-api-4 / xvidcore / src / image / image.c Repository:
ViewVC logotype

Annotation of /branches/dev-api-4/xvidcore/src/image/image.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1128 - (view) (download)

1 : edgomez 851 /**************************************************************************
2 : albeu 315 *
3 : edgomez 1054 * XVID MPEG-4 VIDEO CODEC
4 :     * - Image management functions -
5 : albeu 315 *
6 : edgomez 1054 * Copyright(C) 2001-2003 Peter Ross <pross@xvid.org>
7 : albeu 315 *
8 : edgomez 1054 * This program is free software ; you can redistribute it and/or modify
9 :     * it under the terms of the GNU General Public License as published by
10 :     * the Free Software Foundation ; either version 2 of the License, or
11 :     * (at your option) any later version.
12 : albeu 315 *
13 : edgomez 1054 * This program is distributed in the hope that it will be useful,
14 :     * but WITHOUT ANY WARRANTY ; without even the implied warranty of
15 :     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 :     * GNU General Public License for more details.
17 : albeu 315 *
18 : edgomez 1054 * You should have received a copy of the GNU General Public License
19 :     * along with this program ; if not, write to the Free Software
20 :     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 : albeu 315 *
22 : edgomez 1128 * $Id: image.c,v 1.26.2.8 2003-08-25 15:01:51 edgomez Exp $
23 : albeu 315 *
24 : edgomez 1054 ****************************************************************************/
25 : albeu 315
26 :     #include <stdlib.h>
27 : edgomez 1053 #include <string.h> /* memcpy, memset */
28 : albeu 315 #include <math.h>
29 :    
30 :     #include "../portab.h"
31 : edgomez 1053 #include "../global.h"
32 :     #include "../xvid.h"
33 : albeu 315 #include "image.h"
34 :     #include "colorspace.h"
35 :     #include "interpolate8x8.h"
36 : edgomez 851 #include "reduced.h"
37 : albeu 315 #include "../utils/mem_align.h"
38 :    
39 : edgomez 1053 #include "font.h"
40 : edgomez 851
41 : albeu 315 #define SAFETY 64
42 :     #define EDGE_SIZE2 (EDGE_SIZE/2)
43 :    
44 :    
45 :     int32_t
46 :     image_create(IMAGE * image,
47 :     uint32_t edged_width,
48 :     uint32_t edged_height)
49 :     {
50 :     const uint32_t edged_width2 = edged_width / 2;
51 :     const uint32_t edged_height2 = edged_height / 2;
52 :     uint32_t i;
53 :    
54 :     image->y =
55 :     xvid_malloc(edged_width * (edged_height + 1) + SAFETY, CACHE_LINE);
56 :     if (image->y == NULL) {
57 :     return -1;
58 :     }
59 :    
60 :     for (i = 0; i < edged_width * edged_height + SAFETY; i++) {
61 :     image->y[i] = 0;
62 :     }
63 :    
64 :     image->u = xvid_malloc(edged_width2 * edged_height2 + SAFETY, CACHE_LINE);
65 :     if (image->u == NULL) {
66 :     xvid_free(image->y);
67 :     return -1;
68 :     }
69 :     image->v = xvid_malloc(edged_width2 * edged_height2 + SAFETY, CACHE_LINE);
70 :     if (image->v == NULL) {
71 :     xvid_free(image->u);
72 :     xvid_free(image->y);
73 :     return -1;
74 :     }
75 :    
76 :     image->y += EDGE_SIZE * edged_width + EDGE_SIZE;
77 :     image->u += EDGE_SIZE2 * edged_width2 + EDGE_SIZE2;
78 :     image->v += EDGE_SIZE2 * edged_width2 + EDGE_SIZE2;
79 :    
80 :     return 0;
81 :     }
82 :    
83 :    
84 :    
85 :     void
86 :     image_destroy(IMAGE * image,
87 :     uint32_t edged_width,
88 :     uint32_t edged_height)
89 :     {
90 :     const uint32_t edged_width2 = edged_width / 2;
91 :    
92 :     if (image->y) {
93 :     xvid_free(image->y - (EDGE_SIZE * edged_width + EDGE_SIZE));
94 :     }
95 :     if (image->u) {
96 :     xvid_free(image->u - (EDGE_SIZE2 * edged_width2 + EDGE_SIZE2));
97 :     }
98 :     if (image->v) {
99 :     xvid_free(image->v - (EDGE_SIZE2 * edged_width2 + EDGE_SIZE2));
100 :     }
101 :     }
102 :    
103 :    
104 :     void
105 :     image_swap(IMAGE * image1,
106 :     IMAGE * image2)
107 :     {
108 : suxen_drol 926 SWAP(uint8_t*, image1->y, image2->y);
109 :     SWAP(uint8_t*, image1->u, image2->u);
110 :     SWAP(uint8_t*, image1->v, image2->v);
111 : albeu 315 }
112 :    
113 :    
114 :     void
115 :     image_copy(IMAGE * image1,
116 :     IMAGE * image2,
117 :     uint32_t edged_width,
118 :     uint32_t height)
119 :     {
120 :     memcpy(image1->y, image2->y, edged_width * height);
121 :     memcpy(image1->u, image2->u, edged_width * height / 4);
122 :     memcpy(image1->v, image2->v, edged_width * height / 4);
123 :     }
124 :    
125 :    
126 :     void
127 :     image_setedges(IMAGE * image,
128 :     uint32_t edged_width,
129 :     uint32_t edged_height,
130 :     uint32_t width,
131 : h 541 uint32_t height)
132 : albeu 315 {
133 :     const uint32_t edged_width2 = edged_width / 2;
134 : edgomez 1128 uint32_t width2;
135 : albeu 315 uint32_t i;
136 :     uint8_t *dst;
137 :     uint8_t *src;
138 :    
139 :    
140 :     dst = image->y - (EDGE_SIZE + EDGE_SIZE * edged_width);
141 :     src = image->y;
142 :    
143 : edgomez 1128 /* According to the Standard Clause 7.6.4, padding is done starting at 16
144 :     * pixel width and height multiples */
145 :     width = (width+15)&~15;
146 :     height = (height+15)&~15;
147 :     width2 = width/2;
148 :    
149 : albeu 315 for (i = 0; i < EDGE_SIZE; i++) {
150 : edgomez 851 memset(dst, *src, EDGE_SIZE);
151 :     memcpy(dst + EDGE_SIZE, src, width);
152 :     memset(dst + edged_width - EDGE_SIZE, *(src + width - 1),
153 :     EDGE_SIZE);
154 : albeu 315 dst += edged_width;
155 :     }
156 :    
157 :     for (i = 0; i < height; i++) {
158 :     memset(dst, *src, EDGE_SIZE);
159 :     memset(dst + edged_width - EDGE_SIZE, src[width - 1], EDGE_SIZE);
160 :     dst += edged_width;
161 :     src += edged_width;
162 :     }
163 :    
164 :     src -= edged_width;
165 :     for (i = 0; i < EDGE_SIZE; i++) {
166 : edgomez 851 memset(dst, *src, EDGE_SIZE);
167 :     memcpy(dst + EDGE_SIZE, src, width);
168 :     memset(dst + edged_width - EDGE_SIZE, *(src + width - 1),
169 : albeu 315 EDGE_SIZE);
170 :     dst += edged_width;
171 :     }
172 :    
173 :    
174 : edgomez 1053 /* U */
175 : albeu 315 dst = image->u - (EDGE_SIZE2 + EDGE_SIZE2 * edged_width2);
176 :     src = image->u;
177 :    
178 :     for (i = 0; i < EDGE_SIZE2; i++) {
179 :     memset(dst, *src, EDGE_SIZE2);
180 :     memcpy(dst + EDGE_SIZE2, src, width2);
181 :     memset(dst + edged_width2 - EDGE_SIZE2, *(src + width2 - 1),
182 :     EDGE_SIZE2);
183 :     dst += edged_width2;
184 :     }
185 :    
186 :     for (i = 0; i < height / 2; i++) {
187 :     memset(dst, *src, EDGE_SIZE2);
188 :     memset(dst + edged_width2 - EDGE_SIZE2, src[width2 - 1], EDGE_SIZE2);
189 :     dst += edged_width2;
190 :     src += edged_width2;
191 :     }
192 :     src -= edged_width2;
193 :     for (i = 0; i < EDGE_SIZE2; i++) {
194 :     memset(dst, *src, EDGE_SIZE2);
195 :     memcpy(dst + EDGE_SIZE2, src, width2);
196 :     memset(dst + edged_width2 - EDGE_SIZE2, *(src + width2 - 1),
197 :     EDGE_SIZE2);
198 :     dst += edged_width2;
199 :     }
200 :    
201 :    
202 : edgomez 1053 /* V */
203 : albeu 315 dst = image->v - (EDGE_SIZE2 + EDGE_SIZE2 * edged_width2);
204 :     src = image->v;
205 :    
206 :     for (i = 0; i < EDGE_SIZE2; i++) {
207 :     memset(dst, *src, EDGE_SIZE2);
208 :     memcpy(dst + EDGE_SIZE2, src, width2);
209 :     memset(dst + edged_width2 - EDGE_SIZE2, *(src + width2 - 1),
210 :     EDGE_SIZE2);
211 :     dst += edged_width2;
212 :     }
213 :    
214 :     for (i = 0; i < height / 2; i++) {
215 :     memset(dst, *src, EDGE_SIZE2);
216 :     memset(dst + edged_width2 - EDGE_SIZE2, src[width2 - 1], EDGE_SIZE2);
217 :     dst += edged_width2;
218 :     src += edged_width2;
219 :     }
220 :     src -= edged_width2;
221 :     for (i = 0; i < EDGE_SIZE2; i++) {
222 :     memset(dst, *src, EDGE_SIZE2);
223 :     memcpy(dst + EDGE_SIZE2, src, width2);
224 :     memset(dst + edged_width2 - EDGE_SIZE2, *(src + width2 - 1),
225 :     EDGE_SIZE2);
226 :     dst += edged_width2;
227 :     }
228 :     }
229 :    
230 : edgomez 1053 /* bframe encoding requires image-based u,v interpolation */
231 : albeu 315 void
232 :     image_interpolate(const IMAGE * refn,
233 :     IMAGE * refh,
234 :     IMAGE * refv,
235 :     IMAGE * refhv,
236 :     uint32_t edged_width,
237 :     uint32_t edged_height,
238 : edgomez 851 uint32_t quarterpel,
239 : albeu 315 uint32_t rounding)
240 :     {
241 : edgomez 1053 const uint32_t offset = EDGE_SIZE2 * (edged_width + 1); /* we only interpolate half of the edge area */
242 : albeu 315 const uint32_t stride_add = 7 * edged_width;
243 : edgomez 1053 #if 0
244 : edgomez 851 const uint32_t edged_width2 = edged_width / 2;
245 :     const uint32_t edged_height2 = edged_height / 2;
246 :     const uint32_t offset2 = EDGE_SIZE2 * (edged_width2 + 1);
247 :     const uint32_t stride_add2 = 7 * edged_width2;
248 :     #endif
249 : albeu 315 uint8_t *n_ptr, *h_ptr, *v_ptr, *hv_ptr;
250 :     uint32_t x, y;
251 :    
252 :    
253 :     n_ptr = refn->y;
254 :     h_ptr = refh->y;
255 :     v_ptr = refv->y;
256 :     hv_ptr = refhv->y;
257 :    
258 :     n_ptr -= offset;
259 :     h_ptr -= offset;
260 :     v_ptr -= offset;
261 :     hv_ptr -= offset;
262 :    
263 : edgomez 851 if(quarterpel) {
264 :    
265 :     for (y = 0; y < (edged_height - EDGE_SIZE); y += 8) {
266 :     for (x = 0; x < (edged_width - EDGE_SIZE); x += 8) {
267 :     interpolate8x8_6tap_lowpass_h(h_ptr, n_ptr, edged_width, rounding);
268 :     interpolate8x8_6tap_lowpass_v(v_ptr, n_ptr, edged_width, rounding);
269 : albeu 315
270 : edgomez 851 n_ptr += 8;
271 :     h_ptr += 8;
272 :     v_ptr += 8;
273 :     }
274 :    
275 :     n_ptr += EDGE_SIZE;
276 :     h_ptr += EDGE_SIZE;
277 :     v_ptr += EDGE_SIZE;
278 :    
279 :     h_ptr += stride_add;
280 :     v_ptr += stride_add;
281 :     n_ptr += stride_add;
282 :     }
283 :    
284 :     h_ptr = refh->y;
285 :     h_ptr -= offset;
286 :    
287 :     for (y = 0; y < (edged_height - EDGE_SIZE); y = y + 8) {
288 :     for (x = 0; x < (edged_width - EDGE_SIZE); x = x + 8) {
289 :     interpolate8x8_6tap_lowpass_v(hv_ptr, h_ptr, edged_width, rounding);
290 :     hv_ptr += 8;
291 :     h_ptr += 8;
292 :     }
293 :    
294 :     hv_ptr += EDGE_SIZE;
295 :     h_ptr += EDGE_SIZE;
296 :    
297 :     hv_ptr += stride_add;
298 :     h_ptr += stride_add;
299 :     }
300 :     }
301 :     else {
302 :    
303 :     for (y = 0; y < (edged_height - EDGE_SIZE); y += 8) {
304 :     for (x = 0; x < (edged_width - EDGE_SIZE); x += 8) {
305 :     interpolate8x8_halfpel_h(h_ptr, n_ptr, edged_width, rounding);
306 :     interpolate8x8_halfpel_v(v_ptr, n_ptr, edged_width, rounding);
307 :     interpolate8x8_halfpel_hv(hv_ptr, n_ptr, edged_width, rounding);
308 :    
309 :     n_ptr += 8;
310 :     h_ptr += 8;
311 :     v_ptr += 8;
312 :     hv_ptr += 8;
313 :     }
314 :    
315 :     h_ptr += EDGE_SIZE;
316 :     v_ptr += EDGE_SIZE;
317 :     hv_ptr += EDGE_SIZE;
318 :     n_ptr += EDGE_SIZE;
319 :    
320 :     h_ptr += stride_add;
321 :     v_ptr += stride_add;
322 :     hv_ptr += stride_add;
323 :     n_ptr += stride_add;
324 :     }
325 :     }
326 :     /*
327 :     #ifdef BFRAMES
328 :     n_ptr = refn->u;
329 :     h_ptr = refh->u;
330 :     v_ptr = refv->u;
331 :     hv_ptr = refhv->u;
332 :    
333 :     n_ptr -= offset2;
334 :     h_ptr -= offset2;
335 :     v_ptr -= offset2;
336 :     hv_ptr -= offset2;
337 :    
338 :     for (y = 0; y < edged_height2; y += 8) {
339 :     for (x = 0; x < edged_width2; x += 8) {
340 :     interpolate8x8_halfpel_h(h_ptr, n_ptr, edged_width2, rounding);
341 :     interpolate8x8_halfpel_v(v_ptr, n_ptr, edged_width2, rounding);
342 :     interpolate8x8_halfpel_hv(hv_ptr, n_ptr, edged_width2, rounding);
343 :    
344 : albeu 315 n_ptr += 8;
345 :     h_ptr += 8;
346 :     v_ptr += 8;
347 :     hv_ptr += 8;
348 :     }
349 : edgomez 851 h_ptr += stride_add2;
350 :     v_ptr += stride_add2;
351 :     hv_ptr += stride_add2;
352 :     n_ptr += stride_add2;
353 : albeu 315 }
354 :    
355 : edgomez 851 n_ptr = refn->v;
356 :     h_ptr = refh->v;
357 :     v_ptr = refv->v;
358 :     hv_ptr = refhv->v;
359 :    
360 :     n_ptr -= offset2;
361 :     h_ptr -= offset2;
362 :     v_ptr -= offset2;
363 :     hv_ptr -= offset2;
364 :    
365 :     for (y = 0; y < edged_height2; y = y + 8) {
366 :     for (x = 0; x < edged_width2; x = x + 8) {
367 :     interpolate8x8_halfpel_h(h_ptr, n_ptr, edged_width2, rounding);
368 :     interpolate8x8_halfpel_v(v_ptr, n_ptr, edged_width2, rounding);
369 :     interpolate8x8_halfpel_hv(hv_ptr, n_ptr, edged_width2, rounding);
370 :    
371 :     n_ptr += 8;
372 :     h_ptr += 8;
373 :     v_ptr += 8;
374 :     hv_ptr += 8;
375 :     }
376 :     h_ptr += stride_add2;
377 :     v_ptr += stride_add2;
378 :     hv_ptr += stride_add2;
379 :     n_ptr += stride_add2;
380 :     }
381 :     #endif
382 :     */
383 : albeu 315 /*
384 :     interpolate_halfpel_h(
385 :     refh->y - offset,
386 :     refn->y - offset,
387 :     edged_width, edged_height,
388 :     rounding);
389 :    
390 :     interpolate_halfpel_v(
391 :     refv->y - offset,
392 :     refn->y - offset,
393 :     edged_width, edged_height,
394 :     rounding);
395 :    
396 :     interpolate_halfpel_hv(
397 :     refhv->y - offset,
398 :     refn->y - offset,
399 :     edged_width, edged_height,
400 :     rounding);
401 :     */
402 :    
403 :     /* uv-image-based compensation
404 :     offset = EDGE_SIZE2 * (edged_width / 2 + 1);
405 :    
406 :     interpolate_halfpel_h(
407 :     refh->u - offset,
408 :     refn->u - offset,
409 :     edged_width / 2, edged_height / 2,
410 :     rounding);
411 :    
412 :     interpolate_halfpel_v(
413 :     refv->u - offset,
414 :     refn->u - offset,
415 :     edged_width / 2, edged_height / 2,
416 :     rounding);
417 :    
418 :     interpolate_halfpel_hv(
419 :     refhv->u - offset,
420 :     refn->u - offset,
421 :     edged_width / 2, edged_height / 2,
422 :     rounding);
423 :    
424 :    
425 :     interpolate_halfpel_h(
426 :     refh->v - offset,
427 :     refn->v - offset,
428 :     edged_width / 2, edged_height / 2,
429 :     rounding);
430 :    
431 :     interpolate_halfpel_v(
432 :     refv->v - offset,
433 :     refn->v - offset,
434 :     edged_width / 2, edged_height / 2,
435 :     rounding);
436 :    
437 :     interpolate_halfpel_hv(
438 :     refhv->v - offset,
439 :     refn->v - offset,
440 :     edged_width / 2, edged_height / 2,
441 :     rounding);
442 :     */
443 :     }
444 :    
445 :    
446 : edgomez 851 /*
447 :     chroma optimize filter, invented by mf
448 :     a chroma pixel is average from the surrounding pixels, when the
449 :     correpsonding luma pixels are pure black or white.
450 :     */
451 :    
452 :     void
453 :     image_chroma_optimize(IMAGE * img, int width, int height, int edged_width)
454 :     {
455 :     int x,y;
456 :     int pixels = 0;
457 :    
458 :     for (y = 1; y < height/2 - 1; y++)
459 :     for (x = 1; x < width/2 - 1; x++)
460 :     {
461 :     #define IS_PURE(a) ((a)<=16||(a)>=235)
462 :     #define IMG_Y(Y,X) img->y[(Y)*edged_width + (X)]
463 :     #define IMG_U(Y,X) img->u[(Y)*edged_width/2 + (X)]
464 :     #define IMG_V(Y,X) img->v[(Y)*edged_width/2 + (X)]
465 :    
466 :     if (IS_PURE(IMG_Y(y*2 ,x*2 )) &&
467 :     IS_PURE(IMG_Y(y*2 ,x*2+1)) &&
468 :     IS_PURE(IMG_Y(y*2+1,x*2 )) &&
469 :     IS_PURE(IMG_Y(y*2+1,x*2+1)))
470 :     {
471 :     IMG_U(y,x) = (IMG_U(y,x-1) + IMG_U(y-1, x) + IMG_U(y, x+1) + IMG_U(y+1, x)) / 4;
472 :     IMG_V(y,x) = (IMG_V(y,x-1) + IMG_V(y-1, x) + IMG_V(y, x+1) + IMG_V(y+1, x)) / 4;
473 :     pixels++;
474 :     }
475 :    
476 :     #undef IS_PURE
477 :     #undef IMG_Y
478 :     #undef IMG_U
479 :     #undef IMG_V
480 :     }
481 :    
482 : edgomez 1038 DPRINTF(XVID_DEBUG_DEBUG,"chroma_optimized_pixels = %i/%i\n", pixels, width*height/4);
483 : edgomez 851 }
484 :    
485 :    
486 :    
487 :    
488 :    
489 :     /*
490 :     perform safe packed colorspace conversion, by splitting
491 :     the image up into an optimized area (pixel width divisible by 16),
492 :     and two unoptimized/plain-c areas (pixel width divisible by 2)
493 :     */
494 :    
495 :     static void
496 :     safe_packed_conv(uint8_t * x_ptr, int x_stride,
497 :     uint8_t * y_ptr, uint8_t * u_ptr, uint8_t * v_ptr,
498 :     int y_stride, int uv_stride,
499 :     int width, int height, int vflip,
500 :     packedFunc * func_opt, packedFunc func_c, int size)
501 :     {
502 :     int width_opt, width_c;
503 :    
504 :     if (func_opt != func_c && x_stride < size*((width+15)/16)*16)
505 :     {
506 :     width_opt = width & (~15);
507 :     width_c = width - width_opt;
508 :     }
509 :     else
510 :     {
511 :     width_opt = width;
512 :     width_c = 0;
513 :     }
514 :    
515 :     func_opt(x_ptr, x_stride,
516 :     y_ptr, u_ptr, v_ptr, y_stride, uv_stride,
517 :     width_opt, height, vflip);
518 :    
519 :     if (width_c)
520 :     {
521 :     func_c(x_ptr + size*width_opt, x_stride,
522 :     y_ptr + width_opt, u_ptr + width_opt/2, v_ptr + width_opt/2,
523 :     y_stride, uv_stride, width_c, height, vflip);
524 :     }
525 :     }
526 :    
527 :    
528 :    
529 : albeu 315 int
530 :     image_input(IMAGE * image,
531 :     uint32_t width,
532 :     int height,
533 :     uint32_t edged_width,
534 : suxen_drol 890 uint8_t * src[4],
535 :     int src_stride[4],
536 : edgomez 851 int csp,
537 :     int interlacing)
538 : albeu 315 {
539 : edgomez 851 const int edged_width2 = edged_width/2;
540 :     const int width2 = width/2;
541 :     const int height2 = height/2;
542 : edgomez 1053 #if 0
543 :     const int height_signed = (csp & XVID_CSP_VFLIP) ? -height : height;
544 :     #endif
545 : albeu 315
546 :     switch (csp & ~XVID_CSP_VFLIP) {
547 :     case XVID_CSP_RGB555:
548 : edgomez 851 safe_packed_conv(
549 : suxen_drol 890 src[0], src_stride[0], image->y, image->u, image->v,
550 : edgomez 851 edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
551 :     interlacing?rgb555i_to_yv12 :rgb555_to_yv12,
552 :     interlacing?rgb555i_to_yv12_c:rgb555_to_yv12_c, 2);
553 :     break;
554 : albeu 315
555 :     case XVID_CSP_RGB565:
556 : edgomez 851 safe_packed_conv(
557 : suxen_drol 890 src[0], src_stride[0], image->y, image->u, image->v,
558 : edgomez 851 edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
559 :     interlacing?rgb565i_to_yv12 :rgb565_to_yv12,
560 :     interlacing?rgb565i_to_yv12_c:rgb565_to_yv12_c, 2);
561 :     break;
562 : albeu 315
563 :    
564 : suxen_drol 890 case XVID_CSP_BGR:
565 : edgomez 851 safe_packed_conv(
566 : suxen_drol 890 src[0], src_stride[0], image->y, image->u, image->v,
567 : edgomez 851 edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
568 :     interlacing?bgri_to_yv12 :bgr_to_yv12,
569 :     interlacing?bgri_to_yv12_c:bgr_to_yv12_c, 3);
570 :     break;
571 : albeu 315
572 : suxen_drol 890 case XVID_CSP_BGRA:
573 : edgomez 851 safe_packed_conv(
574 : suxen_drol 890 src[0], src_stride[0], image->y, image->u, image->v,
575 : edgomez 851 edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
576 :     interlacing?bgrai_to_yv12 :bgra_to_yv12,
577 :     interlacing?bgrai_to_yv12_c:bgra_to_yv12_c, 4);
578 :     break;
579 : albeu 315
580 : edgomez 851 case XVID_CSP_ABGR :
581 :     safe_packed_conv(
582 : suxen_drol 890 src[0], src_stride[0], image->y, image->u, image->v,
583 : edgomez 851 edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
584 :     interlacing?abgri_to_yv12 :abgr_to_yv12,
585 :     interlacing?abgri_to_yv12_c:abgr_to_yv12_c, 4);
586 :     break;
587 : albeu 315
588 : edgomez 851 case XVID_CSP_RGBA :
589 :     safe_packed_conv(
590 : suxen_drol 890 src[0], src_stride[0], image->y, image->u, image->v,
591 : edgomez 851 edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
592 :     interlacing?rgbai_to_yv12 :rgba_to_yv12,
593 :     interlacing?rgbai_to_yv12_c:rgba_to_yv12_c, 4);
594 :     break;
595 : albeu 315
596 :     case XVID_CSP_YUY2:
597 : edgomez 851 safe_packed_conv(
598 : suxen_drol 890 src[0], src_stride[0], image->y, image->u, image->v,
599 : edgomez 851 edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
600 :     interlacing?yuyvi_to_yv12 :yuyv_to_yv12,
601 :     interlacing?yuyvi_to_yv12_c:yuyv_to_yv12_c, 2);
602 :     break;
603 : albeu 315
604 :     case XVID_CSP_YVYU: /* u/v swapped */
605 : edgomez 851 safe_packed_conv(
606 : suxen_drol 890 src[0], src_stride[0], image->y, image->v, image->y,
607 : edgomez 851 edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
608 :     interlacing?yuyvi_to_yv12 :yuyv_to_yv12,
609 :     interlacing?yuyvi_to_yv12_c:yuyv_to_yv12_c, 2);
610 :     break;
611 : albeu 315
612 :     case XVID_CSP_UYVY:
613 : edgomez 851 safe_packed_conv(
614 : suxen_drol 890 src[0], src_stride[0], image->y, image->u, image->v,
615 : edgomez 851 edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
616 :     interlacing?uyvyi_to_yv12 :uyvy_to_yv12,
617 :     interlacing?uyvyi_to_yv12_c:uyvy_to_yv12_c, 2);
618 :     break;
619 : albeu 315
620 : edgomez 851 case XVID_CSP_I420:
621 :     yv12_to_yv12(image->y, image->u, image->v, edged_width, edged_width2,
622 : suxen_drol 890 src[0], src[0] + src_stride[0]*height, src[0] + src_stride[0]*height + (src_stride[0]/2)*height2,
623 :     src_stride[0], src_stride[0]/2, width, height, (csp & XVID_CSP_VFLIP));
624 : edgomez 851 break
625 :     ;
626 :     case XVID_CSP_YV12: /* u/v swapped */
627 :     yv12_to_yv12(image->y, image->v, image->u, edged_width, edged_width2,
628 : suxen_drol 890 src[0], src[0] + src_stride[0]*height, src[0] + src_stride[0]*height + (src_stride[0]/2)*height2,
629 :     src_stride[0], src_stride[0]/2, width, height, (csp & XVID_CSP_VFLIP));
630 : edgomez 851 break;
631 :    
632 : albeu 315 case XVID_CSP_USER:
633 : suxen_drol 890 /*XXX: support for different u & v strides */
634 :     yv12_to_yv12(image->y, image->u, image->v, edged_width, edged_width2,
635 :     src[0], src[1], src[2], src_stride[0], src_stride[1],
636 :     width, height, (csp & XVID_CSP_VFLIP));
637 : edgomez 851 break;
638 : albeu 315
639 :     case XVID_CSP_NULL:
640 :     break;
641 :    
642 : edgomez 851 default :
643 :     return -1;
644 : albeu 315 }
645 :    
646 : edgomez 851
647 :     /* pad out image when the width and/or height is not a multiple of 16 */
648 :    
649 :     if (width & 15)
650 :     {
651 :     int i;
652 :     int pad_width = 16 - (width&15);
653 :     for (i = 0; i < height; i++)
654 :     {
655 :     memset(image->y + i*edged_width + width,
656 :     *(image->y + i*edged_width + width - 1), pad_width);
657 :     }
658 :     for (i = 0; i < height/2; i++)
659 :     {
660 :     memset(image->u + i*edged_width2 + width2,
661 :     *(image->u + i*edged_width2 + width2 - 1),pad_width/2);
662 :     memset(image->v + i*edged_width2 + width2,
663 :     *(image->v + i*edged_width2 + width2 - 1),pad_width/2);
664 :     }
665 :     }
666 :    
667 :     if (height & 15)
668 :     {
669 :     int pad_height = 16 - (height&15);
670 :     int length = ((width+15)/16)*16;
671 :     int i;
672 :     for (i = 0; i < pad_height; i++)
673 :     {
674 :     memcpy(image->y + (height+i)*edged_width,
675 :     image->y + (height-1)*edged_width,length);
676 :     }
677 :    
678 :     for (i = 0; i < pad_height/2; i++)
679 :     {
680 :     memcpy(image->u + (height2+i)*edged_width2,
681 :     image->u + (height2-1)*edged_width2,length/2);
682 :     memcpy(image->v + (height2+i)*edged_width2,
683 :     image->v + (height2-1)*edged_width2,length/2);
684 :     }
685 :     }
686 :    
687 :     /*
688 :     if (interlacing)
689 :     image_printf(image, edged_width, height, 5,5, "[i]");
690 :     image_dump_yuvpgm(image, edged_width, ((width+15)/16)*16, ((height+15)/16)*16, "\\encode.pgm");
691 :     */
692 :     return 0;
693 : albeu 315 }
694 :    
695 :    
696 :    
697 :     int
698 :     image_output(IMAGE * image,
699 :     uint32_t width,
700 :     int height,
701 :     uint32_t edged_width,
702 : suxen_drol 890 uint8_t * dst[4],
703 :     uint32_t dst_stride[4],
704 : edgomez 851 int csp,
705 :     int interlacing)
706 : albeu 315 {
707 : edgomez 851 const int edged_width2 = edged_width/2;
708 :     int height2 = height/2;
709 :    
710 :     /*
711 :     if (interlacing)
712 :     image_printf(image, edged_width, height, 5,100, "[i]=%i,%i",width,height);
713 :     image_dump_yuvpgm(image, edged_width, width, height, "\\decode.pgm");
714 :     */
715 :    
716 : albeu 315 switch (csp & ~XVID_CSP_VFLIP) {
717 :     case XVID_CSP_RGB555:
718 : edgomez 851 safe_packed_conv(
719 : suxen_drol 890 dst[0], dst_stride[0], image->y, image->u, image->v,
720 : edgomez 851 edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
721 :     interlacing?yv12_to_rgb555i :yv12_to_rgb555,
722 :     interlacing?yv12_to_rgb555i_c:yv12_to_rgb555_c, 2);
723 : albeu 315 return 0;
724 :    
725 :     case XVID_CSP_RGB565:
726 : edgomez 851 safe_packed_conv(
727 : suxen_drol 890 dst[0], dst_stride[0], image->y, image->u, image->v,
728 : edgomez 851 edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
729 :     interlacing?yv12_to_rgb565i :yv12_to_rgb565,
730 :     interlacing?yv12_to_rgb565i_c:yv12_to_rgb565_c, 2);
731 : albeu 315 return 0;
732 :    
733 : suxen_drol 890 case XVID_CSP_BGR:
734 : edgomez 851 safe_packed_conv(
735 : suxen_drol 890 dst[0], dst_stride[0], image->y, image->u, image->v,
736 : edgomez 851 edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
737 :     interlacing?yv12_to_bgri :yv12_to_bgr,
738 :     interlacing?yv12_to_bgri_c:yv12_to_bgr_c, 3);
739 : albeu 315 return 0;
740 :    
741 : suxen_drol 890 case XVID_CSP_BGRA:
742 : edgomez 851 safe_packed_conv(
743 : suxen_drol 890 dst[0], dst_stride[0], image->y, image->u, image->v,
744 : edgomez 851 edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
745 :     interlacing?yv12_to_bgrai :yv12_to_bgra,
746 :     interlacing?yv12_to_bgrai_c:yv12_to_bgra_c, 4);
747 : albeu 315 return 0;
748 :    
749 : edgomez 851 case XVID_CSP_ABGR:
750 :     safe_packed_conv(
751 : suxen_drol 890 dst[0], dst_stride[0], image->y, image->u, image->v,
752 : edgomez 851 edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
753 :     interlacing?yv12_to_abgri :yv12_to_abgr,
754 :     interlacing?yv12_to_abgri_c:yv12_to_abgr_c, 4);
755 : albeu 315 return 0;
756 :    
757 : edgomez 851 case XVID_CSP_RGBA:
758 :     safe_packed_conv(
759 : suxen_drol 890 dst[0], dst_stride[0], image->y, image->u, image->v,
760 : edgomez 851 edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
761 :     interlacing?yv12_to_rgbai :yv12_to_rgba,
762 :     interlacing?yv12_to_rgbai_c:yv12_to_rgba_c, 4);
763 : albeu 315 return 0;
764 :    
765 :     case XVID_CSP_YUY2:
766 : edgomez 851 safe_packed_conv(
767 : suxen_drol 890 dst[0], dst_stride[0], image->y, image->u, image->v,
768 : edgomez 851 edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
769 :     interlacing?yv12_to_yuyvi :yv12_to_yuyv,
770 :     interlacing?yv12_to_yuyvi_c:yv12_to_yuyv_c, 2);
771 : albeu 315 return 0;
772 :    
773 : edgomez 1053 case XVID_CSP_YVYU: /* u,v swapped */
774 : edgomez 851 safe_packed_conv(
775 : suxen_drol 890 dst[0], dst_stride[0], image->y, image->v, image->u,
776 : edgomez 851 edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
777 :     interlacing?yv12_to_yuyvi :yv12_to_yuyv,
778 :     interlacing?yv12_to_yuyvi_c:yv12_to_yuyv_c, 2);
779 : albeu 315 return 0;
780 :    
781 :     case XVID_CSP_UYVY:
782 : edgomez 851 safe_packed_conv(
783 : suxen_drol 890 dst[0], dst_stride[0], image->y, image->u, image->v,
784 : edgomez 851 edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
785 :     interlacing?yv12_to_uyvyi :yv12_to_uyvy,
786 :     interlacing?yv12_to_uyvyi_c:yv12_to_uyvy_c, 2);
787 : albeu 315 return 0;
788 :    
789 : edgomez 851 case XVID_CSP_I420:
790 : suxen_drol 890 yv12_to_yv12(dst[0], dst[0] + dst_stride[0]*height, dst[0] + dst_stride[0]*height + (dst_stride[0]/2)*height2,
791 :     dst_stride[0], dst_stride[0]/2,
792 : edgomez 851 image->y, image->u, image->v, edged_width, edged_width2,
793 :     width, height, (csp & XVID_CSP_VFLIP));
794 :     return 0;
795 :    
796 : edgomez 1053 case XVID_CSP_YV12: /* u,v swapped */
797 : suxen_drol 890 yv12_to_yv12(dst[0], dst[0] + dst_stride[0]*height, dst[0] + dst_stride[0]*height + (dst_stride[0]/2)*height2,
798 :     dst_stride[0], dst_stride[0]/2,
799 : edgomez 851 image->y, image->v, image->u, edged_width, edged_width2,
800 :     width, height, (csp & XVID_CSP_VFLIP));
801 :     return 0;
802 :    
803 : edgomez 1053 case XVID_CSP_USER : /* u,v swapped */
804 : suxen_drol 890 yv12_to_yv12(dst[0], dst[1], dst[2],
805 :     dst_stride[0], dst_stride[1], /* v: dst_stride[2] */
806 :     image->y, image->v, image->u, edged_width, edged_width2,
807 :     width, height, (csp & XVID_CSP_VFLIP));
808 : albeu 315 return 0;
809 :    
810 : suxen_drol 890 case XVID_CSP_INTERNAL :
811 :     dst[0] = image->y;
812 :     dst[1] = image->u;
813 :     dst[2] = image->v;
814 :     dst_stride[0] = edged_width;
815 :     dst_stride[1] = edged_width/2;
816 :     dst_stride[2] = edged_width/2;
817 :     return 0;
818 :    
819 : albeu 315 case XVID_CSP_NULL:
820 : suxen_drol 890 case XVID_CSP_SLICE:
821 : albeu 315 return 0;
822 :    
823 :     }
824 :    
825 :     return -1;
826 :     }
827 :    
828 :     float
829 :     image_psnr(IMAGE * orig_image,
830 :     IMAGE * recon_image,
831 :     uint16_t stride,
832 :     uint16_t width,
833 :     uint16_t height)
834 :     {
835 :     int32_t diff, x, y, quad = 0;
836 :     uint8_t *orig = orig_image->y;
837 :     uint8_t *recon = recon_image->y;
838 :     float psnr_y;
839 :    
840 :     for (y = 0; y < height; y++) {
841 :     for (x = 0; x < width; x++) {
842 :     diff = *(orig + x) - *(recon + x);
843 :     quad += diff * diff;
844 :     }
845 :     orig += stride;
846 :     recon += stride;
847 :     }
848 :    
849 :     psnr_y = (float) quad / (float) (width * height);
850 :    
851 :     if (psnr_y) {
852 :     psnr_y = (float) (255 * 255) / psnr_y;
853 :     psnr_y = 10 * (float) log10(psnr_y);
854 :     } else
855 :     psnr_y = (float) 99.99;
856 :    
857 :     return psnr_y;
858 :     }
859 :    
860 :    
861 : edgomez 851 float sse_to_PSNR(long sse, int pixels)
862 :     {
863 :     if (sse==0)
864 :     return 99.99F;
865 :    
866 : edgomez 1053 return 48.131F - 10*(float)log10((float)sse/(float)(pixels)); /* log10(255*255)=4.8131 */
867 : edgomez 851
868 :     }
869 :    
870 :     long plane_sse(uint8_t * orig,
871 :     uint8_t * recon,
872 :     uint16_t stride,
873 :     uint16_t width,
874 :     uint16_t height)
875 :     {
876 :     int diff, x, y;
877 :     long sse=0;
878 :    
879 :     for (y = 0; y < height; y++) {
880 :     for (x = 0; x < width; x++) {
881 :     diff = *(orig + x) - *(recon + x);
882 :     sse += diff * diff;
883 :     }
884 :     orig += stride;
885 :     recon += stride;
886 :     }
887 :     return sse;
888 :     }
889 :    
890 : edgomez 1053 #if 0
891 : edgomez 851
892 : albeu 315 #include <stdio.h>
893 :     #include <string.h>
894 :    
895 :     int image_dump_pgm(uint8_t * bmp, uint32_t width, uint32_t height, char * filename)
896 :     {
897 :     FILE * f;
898 :     char hdr[1024];
899 :    
900 :     f = fopen(filename, "wb");
901 :     if ( f == NULL)
902 :     {
903 :     return -1;
904 :     }
905 :     sprintf(hdr, "P5\n#xvid\n%i %i\n255\n", width, height);
906 :     fwrite(hdr, strlen(hdr), 1, f);
907 :     fwrite(bmp, width, height, f);
908 :     fclose(f);
909 :    
910 :     return 0;
911 :     }
912 :    
913 :    
914 : edgomez 1053 /* dump image+edges to yuv pgm files */
915 : albeu 315
916 :     int image_dump(IMAGE * image, uint32_t edged_width, uint32_t edged_height, char * path, int number)
917 :     {
918 :     char filename[1024];
919 :    
920 :     sprintf(filename, "%s_%i_%c.pgm", path, number, 'y');
921 :     image_dump_pgm(
922 :     image->y - (EDGE_SIZE * edged_width + EDGE_SIZE),
923 :     edged_width, edged_height, filename);
924 :    
925 :     sprintf(filename, "%s_%i_%c.pgm", path, number, 'u');
926 :     image_dump_pgm(
927 :     image->u - (EDGE_SIZE2 * edged_width / 2 + EDGE_SIZE2),
928 :     edged_width / 2, edged_height / 2, filename);
929 :    
930 :     sprintf(filename, "%s_%i_%c.pgm", path, number, 'v');
931 :     image_dump_pgm(
932 :     image->v - (EDGE_SIZE2 * edged_width / 2 + EDGE_SIZE2),
933 :     edged_width / 2, edged_height / 2, filename);
934 :    
935 :     return 0;
936 :     }
937 : edgomez 1053 #endif
938 : albeu 315
939 :    
940 :    
941 :     /* dump image to yuvpgm file */
942 :    
943 :     #include <stdio.h>
944 :    
945 :     int
946 :     image_dump_yuvpgm(const IMAGE * image,
947 :     const uint32_t edged_width,
948 :     const uint32_t width,
949 :     const uint32_t height,
950 :     char *filename)
951 :     {
952 :     FILE *f;
953 :     char hdr[1024];
954 :     uint32_t i;
955 :     uint8_t *bmp1;
956 :     uint8_t *bmp2;
957 :    
958 :    
959 :     f = fopen(filename, "wb");
960 :     if (f == NULL) {
961 :     return -1;
962 :     }
963 :     sprintf(hdr, "P5\n#xvid\n%i %i\n255\n", width, (3 * height) / 2);
964 :     fwrite(hdr, strlen(hdr), 1, f);
965 :    
966 :     bmp1 = image->y;
967 :     for (i = 0; i < height; i++) {
968 :     fwrite(bmp1, width, 1, f);
969 :     bmp1 += edged_width;
970 :     }
971 :    
972 :     bmp1 = image->u;
973 :     bmp2 = image->v;
974 :     for (i = 0; i < height / 2; i++) {
975 :     fwrite(bmp1, width / 2, 1, f);
976 :     fwrite(bmp2, width / 2, 1, f);
977 :     bmp1 += edged_width / 2;
978 :     bmp2 += edged_width / 2;
979 :     }
980 :    
981 :     fclose(f);
982 :     return 0;
983 :     }
984 :    
985 :    
986 :     float
987 :     image_mad(const IMAGE * img1,
988 :     const IMAGE * img2,
989 :     uint32_t stride,
990 :     uint32_t width,
991 :     uint32_t height)
992 :     {
993 :     const uint32_t stride2 = stride / 2;
994 :     const uint32_t width2 = width / 2;
995 :     const uint32_t height2 = height / 2;
996 :    
997 :     uint32_t x, y;
998 :     uint32_t sum = 0;
999 :    
1000 :     for (y = 0; y < height; y++)
1001 :     for (x = 0; x < width; x++)
1002 : edgomez 982 sum += abs(img1->y[x + y * stride] - img2->y[x + y * stride]);
1003 : albeu 315
1004 :     for (y = 0; y < height2; y++)
1005 :     for (x = 0; x < width2; x++)
1006 : edgomez 982 sum += abs(img1->u[x + y * stride2] - img2->u[x + y * stride2]);
1007 : albeu 315
1008 :     for (y = 0; y < height2; y++)
1009 :     for (x = 0; x < width2; x++)
1010 : edgomez 982 sum += abs(img1->v[x + y * stride2] - img2->v[x + y * stride2]);
1011 : albeu 315
1012 :     return (float) sum / (width * height * 3 / 2);
1013 :     }
1014 :    
1015 :     void
1016 : suxen_drol 890 output_slice(IMAGE * cur, int std, int width, xvid_image_t* out_frm, int mbx, int mby,int mbl) {
1017 : albeu 315 uint8_t *dY,*dU,*dV,*sY,*sU,*sV;
1018 :     int std2 = std >> 1;
1019 :     int w = mbl << 4, w2,i;
1020 :    
1021 :     if(w > width)
1022 :     w = width;
1023 :     w2 = w >> 1;
1024 : suxen_drol 323
1025 : suxen_drol 890 dY = (uint8_t*)out_frm->plane[0] + (mby << 4) * out_frm->stride[0] + (mbx << 4);
1026 :     dU = (uint8_t*)out_frm->plane[1] + (mby << 3) * out_frm->stride[1] + (mbx << 3);
1027 :     dV = (uint8_t*)out_frm->plane[2] + (mby << 3) * out_frm->stride[2] + (mbx << 3);
1028 : albeu 315 sY = cur->y + (mby << 4) * std + (mbx << 4);
1029 :     sU = cur->u + (mby << 3) * std2 + (mbx << 3);
1030 :     sV = cur->v + (mby << 3) * std2 + (mbx << 3);
1031 :    
1032 :     for(i = 0 ; i < 16 ; i++) {
1033 :     memcpy(dY,sY,w);
1034 : suxen_drol 890 dY += out_frm->stride[0];
1035 : suxen_drol 323 sY += std;
1036 :     }
1037 : albeu 315 for(i = 0 ; i < 8 ; i++) {
1038 :     memcpy(dU,sU,w2);
1039 : suxen_drol 890 dU += out_frm->stride[1];
1040 : albeu 315 sU += std2;
1041 :     }
1042 :     for(i = 0 ; i < 8 ; i++) {
1043 :     memcpy(dV,sV,w2);
1044 : suxen_drol 890 dV += out_frm->stride[2];
1045 : albeu 315 sV += std2;
1046 :     }
1047 :     }
1048 : edgomez 851
1049 :    
1050 :     void
1051 :     image_clear(IMAGE * img, int width, int height, int edged_width,
1052 :     int y, int u, int v)
1053 :     {
1054 :     uint8_t * p;
1055 :     int i;
1056 :    
1057 :     p = img->y;
1058 :     for (i = 0; i < height; i++) {
1059 :     memset(p, y, width);
1060 :     p += edged_width;
1061 :     }
1062 :    
1063 :     p = img->u;
1064 :     for (i = 0; i < height/2; i++) {
1065 :     memset(p, u, width/2);
1066 :     p += edged_width/2;
1067 :     }
1068 :    
1069 :     p = img->v;
1070 :     for (i = 0; i < height/2; i++) {
1071 :     memset(p, v, width/2);
1072 :     p += edged_width/2;
1073 :     }
1074 :     }
1075 :    
1076 :    
1077 :     /* reduced resolution deblocking filter
1078 :     block = block size (16=rrv, 8=full resolution)
1079 :     flags = XVID_DEC_YDEBLOCK|XVID_DEC_UVDEBLOCK
1080 :     */
1081 :     void
1082 :     image_deblock_rrv(IMAGE * img, int edged_width,
1083 :     const MACROBLOCK * mbs, int mb_width, int mb_height, int mb_stride,
1084 :     int block, int flags)
1085 :     {
1086 :     const int edged_width2 = edged_width /2;
1087 :     const int nblocks = block / 8; /* skals code uses 8pixel block uints */
1088 :     int i,j;
1089 :    
1090 :     /* luma: j,i in block units */
1091 : suxen_drol 890
1092 : edgomez 851 for (j = 1; j < mb_height*2; j++) /* horizontal deblocking */
1093 :     for (i = 0; i < mb_width*2; i++)
1094 :     {
1095 :     if (mbs[(j-1)/2*mb_stride + (i/2)].mode != MODE_NOT_CODED ||
1096 :     mbs[(j+0)/2*mb_stride + (i/2)].mode != MODE_NOT_CODED)
1097 :     {
1098 :     hfilter_31(img->y + (j*block - 1)*edged_width + i*block,
1099 :     img->y + (j*block + 0)*edged_width + i*block, nblocks);
1100 :     }
1101 :     }
1102 :    
1103 :     for (j = 0; j < mb_height*2; j++) /* vertical deblocking */
1104 :     for (i = 1; i < mb_width*2; i++)
1105 :     {
1106 :     if (mbs[(j/2)*mb_stride + (i-1)/2].mode != MODE_NOT_CODED ||
1107 :     mbs[(j/2)*mb_stride + (i+0)/2].mode != MODE_NOT_CODED)
1108 :     {
1109 :     vfilter_31(img->y + (j*block)*edged_width + i*block - 1,
1110 :     img->y + (j*block)*edged_width + i*block + 0,
1111 :     edged_width, nblocks);
1112 :     }
1113 :     }
1114 :    
1115 :    
1116 : suxen_drol 890
1117 : edgomez 851 /* chroma */
1118 : suxen_drol 890
1119 : edgomez 851 for (j = 1; j < mb_height; j++) /* horizontal deblocking */
1120 :     for (i = 0; i < mb_width; i++)
1121 :     {
1122 :     if (mbs[(j-1)*mb_stride + i].mode != MODE_NOT_CODED ||
1123 :     mbs[(j+0)*mb_stride + i].mode != MODE_NOT_CODED)
1124 :     {
1125 :     hfilter_31(img->u + (j*block - 1)*edged_width2 + i*block,
1126 :     img->u + (j*block + 0)*edged_width2 + i*block, nblocks);
1127 :     hfilter_31(img->v + (j*block - 1)*edged_width2 + i*block,
1128 :     img->v + (j*block + 0)*edged_width2 + i*block, nblocks);
1129 :     }
1130 :     }
1131 :    
1132 :     for (j = 0; j < mb_height; j++) /* vertical deblocking */
1133 :     for (i = 1; i < mb_width; i++)
1134 :     {
1135 :     if (mbs[j*mb_stride + i - 1].mode != MODE_NOT_CODED ||
1136 :     mbs[j*mb_stride + i + 0].mode != MODE_NOT_CODED)
1137 :     {
1138 :     vfilter_31(img->u + (j*block)*edged_width2 + i*block - 1,
1139 :     img->u + (j*block)*edged_width2 + i*block + 0,
1140 :     edged_width2, nblocks);
1141 :     vfilter_31(img->v + (j*block)*edged_width2 + i*block - 1,
1142 :     img->v + (j*block)*edged_width2 + i*block + 0,
1143 :     edged_width2, nblocks);
1144 :     }
1145 :     }
1146 :    
1147 : suxen_drol 890
1148 : edgomez 851 }
1149 :    

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4