[svn] / trunk / xvidcore / src / image / image.c Repository:
ViewVC logotype

Annotation of /trunk/xvidcore/src/image/image.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 541 - (view) (download)

1 : chl 433 /*****************************************************************************
2 : albeu 315 *
3 : chl 433 * XVID MPEG-4 VIDEO CODEC
4 :     * - image module -
5 : albeu 315 *
6 : chl 433 * Copyright(C) 2002 Peter Ross <pross@xvid.org>
7 : albeu 315 *
8 : chl 433 * This program is an implementation of a part of one or more MPEG-4
9 :     * Video tools as specified in ISO/IEC 14496-2 standard. Those intending
10 :     * to use this software module in hardware or software products are
11 :     * advised that its use may infringe existing patents or copyrights, and
12 :     * any such use would be at such party's own risk. The original
13 :     * developer of this software module and his/her company, and subsequent
14 :     * editors and their companies, will have no liability for use of this
15 :     * software or modifications or derivatives thereof.
16 : albeu 315 *
17 : chl 433 * This program is free software; you can redistribute it and/or modify
18 :     * it under the terms of the GNU General Public License as published by
19 :     * the Free Software Foundation; either version 2 of the License, or
20 :     * (at your option) any later version.
21 : albeu 315 *
22 : chl 433 * This program is distributed in the hope that it will be useful,
23 :     * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 :     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 :     * GNU General Public License for more details.
26 : albeu 315 *
27 : chl 433 * You should have received a copy of the GNU General Public License
28 :     * along with this program; if not, write to the Free Software
29 :     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 : albeu 315 *
31 : chl 433 ****************************************************************************/
32 : albeu 315
33 :     #include <stdlib.h>
34 :     #include <string.h> // memcpy, memset
35 :     #include <math.h>
36 :    
37 :     #include "../portab.h"
38 :     #include "../xvid.h"
39 :     #include "image.h"
40 :     #include "colorspace.h"
41 :     #include "interpolate8x8.h"
42 :     #include "../divx4.h"
43 :     #include "../utils/mem_align.h"
44 :    
45 :     #define SAFETY 64
46 :     #define EDGE_SIZE2 (EDGE_SIZE/2)
47 :    
48 :    
49 :     int32_t
50 :     image_create(IMAGE * image,
51 :     uint32_t edged_width,
52 :     uint32_t edged_height)
53 :     {
54 :     const uint32_t edged_width2 = edged_width / 2;
55 :     const uint32_t edged_height2 = edged_height / 2;
56 :     uint32_t i;
57 :    
58 :     image->y =
59 :     xvid_malloc(edged_width * (edged_height + 1) + SAFETY, CACHE_LINE);
60 :     if (image->y == NULL) {
61 :     return -1;
62 :     }
63 :    
64 :     for (i = 0; i < edged_width * edged_height + SAFETY; i++) {
65 :     image->y[i] = 0;
66 :     }
67 :    
68 :     image->u = xvid_malloc(edged_width2 * edged_height2 + SAFETY, CACHE_LINE);
69 :     if (image->u == NULL) {
70 :     xvid_free(image->y);
71 :     return -1;
72 :     }
73 :     image->v = xvid_malloc(edged_width2 * edged_height2 + SAFETY, CACHE_LINE);
74 :     if (image->v == NULL) {
75 :     xvid_free(image->u);
76 :     xvid_free(image->y);
77 :     return -1;
78 :     }
79 :    
80 :     image->y += EDGE_SIZE * edged_width + EDGE_SIZE;
81 :     image->u += EDGE_SIZE2 * edged_width2 + EDGE_SIZE2;
82 :     image->v += EDGE_SIZE2 * edged_width2 + EDGE_SIZE2;
83 :    
84 :     return 0;
85 :     }
86 :    
87 :    
88 :    
89 :     void
90 :     image_destroy(IMAGE * image,
91 :     uint32_t edged_width,
92 :     uint32_t edged_height)
93 :     {
94 :     const uint32_t edged_width2 = edged_width / 2;
95 :    
96 :     if (image->y) {
97 :     xvid_free(image->y - (EDGE_SIZE * edged_width + EDGE_SIZE));
98 :     }
99 :     if (image->u) {
100 :     xvid_free(image->u - (EDGE_SIZE2 * edged_width2 + EDGE_SIZE2));
101 :     }
102 :     if (image->v) {
103 :     xvid_free(image->v - (EDGE_SIZE2 * edged_width2 + EDGE_SIZE2));
104 :     }
105 :     }
106 :    
107 :    
108 :     void
109 :     image_swap(IMAGE * image1,
110 :     IMAGE * image2)
111 :     {
112 :     uint8_t *tmp;
113 :    
114 :     tmp = image1->y;
115 :     image1->y = image2->y;
116 :     image2->y = tmp;
117 :    
118 :     tmp = image1->u;
119 :     image1->u = image2->u;
120 :     image2->u = tmp;
121 :    
122 :     tmp = image1->v;
123 :     image1->v = image2->v;
124 :     image2->v = tmp;
125 :     }
126 :    
127 :    
128 :     void
129 :     image_copy(IMAGE * image1,
130 :     IMAGE * image2,
131 :     uint32_t edged_width,
132 :     uint32_t height)
133 :     {
134 :     memcpy(image1->y, image2->y, edged_width * height);
135 :     memcpy(image1->u, image2->u, edged_width * height / 4);
136 :     memcpy(image1->v, image2->v, edged_width * height / 4);
137 :     }
138 :    
139 :    
140 :     void
141 :     image_setedges(IMAGE * image,
142 :     uint32_t edged_width,
143 :     uint32_t edged_height,
144 :     uint32_t width,
145 : h 541 uint32_t height)
146 : albeu 315 {
147 :     const uint32_t edged_width2 = edged_width / 2;
148 :     const uint32_t width2 = width / 2;
149 :     uint32_t i;
150 :     uint8_t *dst;
151 :     uint8_t *src;
152 :    
153 :    
154 :     dst = image->y - (EDGE_SIZE + EDGE_SIZE * edged_width);
155 :     src = image->y;
156 :    
157 :     for (i = 0; i < EDGE_SIZE; i++) {
158 :     memset(dst, *src, EDGE_SIZE);
159 :     memcpy(dst + EDGE_SIZE, src, width);
160 :     memset(dst + edged_width - EDGE_SIZE, *(src + width - 1),
161 :     EDGE_SIZE);
162 :     dst += edged_width;
163 :     }
164 :    
165 :     for (i = 0; i < height; i++) {
166 :     memset(dst, *src, EDGE_SIZE);
167 :     memset(dst + edged_width - EDGE_SIZE, src[width - 1], EDGE_SIZE);
168 :     dst += edged_width;
169 :     src += edged_width;
170 :     }
171 :    
172 :     src -= edged_width;
173 :     for (i = 0; i < EDGE_SIZE; i++) {
174 :     memset(dst, *src, EDGE_SIZE);
175 :     memcpy(dst + EDGE_SIZE, src, width);
176 :     memset(dst + edged_width - EDGE_SIZE, *(src + width - 1),
177 :     EDGE_SIZE);
178 :     dst += edged_width;
179 :     }
180 :    
181 :    
182 :     //U
183 :     dst = image->u - (EDGE_SIZE2 + EDGE_SIZE2 * edged_width2);
184 :     src = image->u;
185 :    
186 :     for (i = 0; i < EDGE_SIZE2; i++) {
187 :     memset(dst, *src, EDGE_SIZE2);
188 :     memcpy(dst + EDGE_SIZE2, src, width2);
189 :     memset(dst + edged_width2 - EDGE_SIZE2, *(src + width2 - 1),
190 :     EDGE_SIZE2);
191 :     dst += edged_width2;
192 :     }
193 :    
194 :     for (i = 0; i < height / 2; i++) {
195 :     memset(dst, *src, EDGE_SIZE2);
196 :     memset(dst + edged_width2 - EDGE_SIZE2, src[width2 - 1], EDGE_SIZE2);
197 :     dst += edged_width2;
198 :     src += edged_width2;
199 :     }
200 :     src -= edged_width2;
201 :     for (i = 0; i < EDGE_SIZE2; i++) {
202 :     memset(dst, *src, EDGE_SIZE2);
203 :     memcpy(dst + EDGE_SIZE2, src, width2);
204 :     memset(dst + edged_width2 - EDGE_SIZE2, *(src + width2 - 1),
205 :     EDGE_SIZE2);
206 :     dst += edged_width2;
207 :     }
208 :    
209 :    
210 :     // V
211 :     dst = image->v - (EDGE_SIZE2 + EDGE_SIZE2 * edged_width2);
212 :     src = image->v;
213 :    
214 :     for (i = 0; i < EDGE_SIZE2; i++) {
215 :     memset(dst, *src, EDGE_SIZE2);
216 :     memcpy(dst + EDGE_SIZE2, src, width2);
217 :     memset(dst + edged_width2 - EDGE_SIZE2, *(src + width2 - 1),
218 :     EDGE_SIZE2);
219 :     dst += edged_width2;
220 :     }
221 :    
222 :     for (i = 0; i < height / 2; i++) {
223 :     memset(dst, *src, EDGE_SIZE2);
224 :     memset(dst + edged_width2 - EDGE_SIZE2, src[width2 - 1], EDGE_SIZE2);
225 :     dst += edged_width2;
226 :     src += edged_width2;
227 :     }
228 :     src -= edged_width2;
229 :     for (i = 0; i < EDGE_SIZE2; i++) {
230 :     memset(dst, *src, EDGE_SIZE2);
231 :     memcpy(dst + EDGE_SIZE2, src, width2);
232 :     memset(dst + edged_width2 - EDGE_SIZE2, *(src + width2 - 1),
233 :     EDGE_SIZE2);
234 :     dst += edged_width2;
235 :     }
236 :     }
237 :    
238 :     // bframe encoding requires image-based u,v interpolation
239 :     void
240 :     image_interpolate(const IMAGE * refn,
241 :     IMAGE * refh,
242 :     IMAGE * refv,
243 :     IMAGE * refhv,
244 :     uint32_t edged_width,
245 :     uint32_t edged_height,
246 :     uint32_t rounding)
247 :     {
248 :     const uint32_t offset = EDGE_SIZE * (edged_width + 1);
249 :     const uint32_t stride_add = 7 * edged_width;
250 :    
251 :     uint8_t *n_ptr, *h_ptr, *v_ptr, *hv_ptr;
252 :     uint32_t x, y;
253 :    
254 :    
255 :     n_ptr = refn->y;
256 :     h_ptr = refh->y;
257 :     v_ptr = refv->y;
258 :     hv_ptr = refhv->y;
259 :    
260 :     n_ptr -= offset;
261 :     h_ptr -= offset;
262 :     v_ptr -= offset;
263 :     hv_ptr -= offset;
264 :    
265 :     for (y = 0; y < edged_height; y = y + 8) {
266 :     for (x = 0; x < edged_width; x = x + 8) {
267 :     interpolate8x8_halfpel_h(h_ptr, n_ptr, edged_width, rounding);
268 :     interpolate8x8_halfpel_v(v_ptr, n_ptr, edged_width, rounding);
269 :     interpolate8x8_halfpel_hv(hv_ptr, n_ptr, edged_width, rounding);
270 :    
271 :     n_ptr += 8;
272 :     h_ptr += 8;
273 :     v_ptr += 8;
274 :     hv_ptr += 8;
275 :     }
276 :     h_ptr += stride_add;
277 :     v_ptr += stride_add;
278 :     hv_ptr += stride_add;
279 :     n_ptr += stride_add;
280 :     }
281 :    
282 :     /*
283 :     interpolate_halfpel_h(
284 :     refh->y - offset,
285 :     refn->y - offset,
286 :     edged_width, edged_height,
287 :     rounding);
288 :    
289 :     interpolate_halfpel_v(
290 :     refv->y - offset,
291 :     refn->y - offset,
292 :     edged_width, edged_height,
293 :     rounding);
294 :    
295 :     interpolate_halfpel_hv(
296 :     refhv->y - offset,
297 :     refn->y - offset,
298 :     edged_width, edged_height,
299 :     rounding);
300 :     */
301 :    
302 :     /* uv-image-based compensation
303 :     offset = EDGE_SIZE2 * (edged_width / 2 + 1);
304 :    
305 :     interpolate_halfpel_h(
306 :     refh->u - offset,
307 :     refn->u - offset,
308 :     edged_width / 2, edged_height / 2,
309 :     rounding);
310 :    
311 :     interpolate_halfpel_v(
312 :     refv->u - offset,
313 :     refn->u - offset,
314 :     edged_width / 2, edged_height / 2,
315 :     rounding);
316 :    
317 :     interpolate_halfpel_hv(
318 :     refhv->u - offset,
319 :     refn->u - offset,
320 :     edged_width / 2, edged_height / 2,
321 :     rounding);
322 :    
323 :    
324 :     interpolate_halfpel_h(
325 :     refh->v - offset,
326 :     refn->v - offset,
327 :     edged_width / 2, edged_height / 2,
328 :     rounding);
329 :    
330 :     interpolate_halfpel_v(
331 :     refv->v - offset,
332 :     refn->v - offset,
333 :     edged_width / 2, edged_height / 2,
334 :     rounding);
335 :    
336 :     interpolate_halfpel_hv(
337 :     refhv->v - offset,
338 :     refn->v - offset,
339 :     edged_width / 2, edged_height / 2,
340 :     rounding);
341 :     */
342 :     }
343 :    
344 :    
345 :     int
346 :     image_input(IMAGE * image,
347 :     uint32_t width,
348 :     int height,
349 :     uint32_t edged_width,
350 :     uint8_t * src,
351 :     int csp)
352 :     {
353 :    
354 :     /* if (csp & XVID_CSP_VFLIP)
355 :     {
356 :     height = -height;
357 :     }
358 :     */
359 :    
360 :     switch (csp & ~XVID_CSP_VFLIP) {
361 :     case XVID_CSP_RGB555:
362 :     rgb555_to_yv12(image->y, image->u, image->v, src, width, height,
363 :     edged_width);
364 :     return 0;
365 :    
366 :     case XVID_CSP_RGB565:
367 :     rgb565_to_yv12(image->y, image->u, image->v, src, width, height,
368 :     edged_width);
369 :     return 0;
370 :    
371 :    
372 :     case XVID_CSP_RGB24:
373 :     rgb24_to_yv12(image->y, image->u, image->v, src, width, height,
374 :     edged_width);
375 :     return 0;
376 :    
377 :     case XVID_CSP_RGB32:
378 :     rgb32_to_yv12(image->y, image->u, image->v, src, width, height,
379 :     edged_width);
380 :     return 0;
381 :    
382 :     case XVID_CSP_I420:
383 :     yuv_to_yv12(image->y, image->u, image->v, src, width, height,
384 :     edged_width);
385 :     return 0;
386 :    
387 :     case XVID_CSP_YV12: /* u/v swapped */
388 :     yuv_to_yv12(image->y, image->v, image->u, src, width, height,
389 :     edged_width);
390 :     return 0;
391 :    
392 :     case XVID_CSP_YUY2:
393 :     yuyv_to_yv12(image->y, image->u, image->v, src, width, height,
394 :     edged_width);
395 :     return 0;
396 :    
397 :     case XVID_CSP_YVYU: /* u/v swapped */
398 :     yuyv_to_yv12(image->y, image->v, image->u, src, width, height,
399 :     edged_width);
400 :     return 0;
401 :    
402 :     case XVID_CSP_UYVY:
403 :     uyvy_to_yv12(image->y, image->u, image->v, src, width, height,
404 :     edged_width);
405 :     return 0;
406 :    
407 :     case XVID_CSP_USER:
408 :     user_to_yuv_c(image->y, image->u, image->v, edged_width,
409 :     (DEC_PICTURE *) src, width, height);
410 :     return 0;
411 :    
412 :     case XVID_CSP_NULL:
413 :     break;
414 :    
415 :     }
416 :    
417 :     return -1;
418 :     }
419 :    
420 :    
421 :    
422 :     int
423 :     image_output(IMAGE * image,
424 :     uint32_t width,
425 :     int height,
426 :     uint32_t edged_width,
427 :     uint8_t * dst,
428 :     uint32_t dst_stride,
429 :     int csp)
430 :     {
431 :     if (csp & XVID_CSP_VFLIP) {
432 :     height = -height;
433 :     }
434 :    
435 :     switch (csp & ~XVID_CSP_VFLIP) {
436 :     case XVID_CSP_RGB555:
437 :     yv12_to_rgb555(dst, dst_stride, image->y, image->u, image->v,
438 :     edged_width, edged_width / 2, width, height);
439 :     return 0;
440 :    
441 :     case XVID_CSP_RGB565:
442 :     yv12_to_rgb565(dst, dst_stride, image->y, image->u, image->v,
443 :     edged_width, edged_width / 2, width, height);
444 :     return 0;
445 :    
446 :     case XVID_CSP_RGB24:
447 :     yv12_to_rgb24(dst, dst_stride, image->y, image->u, image->v,
448 :     edged_width, edged_width / 2, width, height);
449 :     return 0;
450 :    
451 :     case XVID_CSP_RGB32:
452 :     yv12_to_rgb32(dst, dst_stride, image->y, image->u, image->v,
453 :     edged_width, edged_width / 2, width, height);
454 :     return 0;
455 :    
456 :     case XVID_CSP_I420:
457 :     yv12_to_yuv(dst, dst_stride, image->y, image->u, image->v, edged_width,
458 :     edged_width / 2, width, height);
459 :     return 0;
460 :    
461 :     case XVID_CSP_YV12: // u,v swapped
462 :     yv12_to_yuv(dst, dst_stride, image->y, image->v, image->u, edged_width,
463 :     edged_width / 2, width, height);
464 :     return 0;
465 :    
466 :     case XVID_CSP_YUY2:
467 :     yv12_to_yuyv(dst, dst_stride, image->y, image->u, image->v,
468 :     edged_width, edged_width / 2, width, height);
469 :     return 0;
470 :    
471 :     case XVID_CSP_YVYU: // u,v swapped
472 :     yv12_to_yuyv(dst, dst_stride, image->y, image->v, image->u,
473 :     edged_width, edged_width / 2, width, height);
474 :     return 0;
475 :    
476 :     case XVID_CSP_UYVY:
477 :     yv12_to_uyvy(dst, dst_stride, image->y, image->u, image->v,
478 :     edged_width, edged_width / 2, width, height);
479 :     return 0;
480 :    
481 :     case XVID_CSP_USER:
482 :     ((DEC_PICTURE *) dst)->y = image->y;
483 :     ((DEC_PICTURE *) dst)->u = image->u;
484 :     ((DEC_PICTURE *) dst)->v = image->v;
485 :     ((DEC_PICTURE *) dst)->stride_y = edged_width;
486 :     ((DEC_PICTURE *) dst)->stride_uv = edged_width / 2;
487 :     return 0;
488 :    
489 :     case XVID_CSP_NULL:
490 :     case XVID_CSP_EXTERN:
491 :     return 0;
492 :    
493 :     }
494 :    
495 :     return -1;
496 :     }
497 :    
498 :     float
499 :     image_psnr(IMAGE * orig_image,
500 :     IMAGE * recon_image,
501 :     uint16_t stride,
502 :     uint16_t width,
503 :     uint16_t height)
504 :     {
505 :     int32_t diff, x, y, quad = 0;
506 :     uint8_t *orig = orig_image->y;
507 :     uint8_t *recon = recon_image->y;
508 :     float psnr_y;
509 :    
510 :     for (y = 0; y < height; y++) {
511 :     for (x = 0; x < width; x++) {
512 :     diff = *(orig + x) - *(recon + x);
513 :     quad += diff * diff;
514 :     }
515 :     orig += stride;
516 :     recon += stride;
517 :     }
518 :    
519 :     psnr_y = (float) quad / (float) (width * height);
520 :    
521 :     if (psnr_y) {
522 :     psnr_y = (float) (255 * 255) / psnr_y;
523 :     psnr_y = 10 * (float) log10(psnr_y);
524 :     } else
525 :     psnr_y = (float) 99.99;
526 :    
527 :     return psnr_y;
528 :     }
529 :    
530 :     /*
531 :    
532 :     #include <stdio.h>
533 :     #include <string.h>
534 :    
535 :     int image_dump_pgm(uint8_t * bmp, uint32_t width, uint32_t height, char * filename)
536 :     {
537 :     FILE * f;
538 :     char hdr[1024];
539 :    
540 :     f = fopen(filename, "wb");
541 :     if ( f == NULL)
542 :     {
543 :     return -1;
544 :     }
545 :     sprintf(hdr, "P5\n#xvid\n%i %i\n255\n", width, height);
546 :     fwrite(hdr, strlen(hdr), 1, f);
547 :     fwrite(bmp, width, height, f);
548 :     fclose(f);
549 :    
550 :     return 0;
551 :     }
552 :    
553 :    
554 :     // dump image+edges to yuv pgm files
555 :    
556 :     int image_dump(IMAGE * image, uint32_t edged_width, uint32_t edged_height, char * path, int number)
557 :     {
558 :     char filename[1024];
559 :    
560 :     sprintf(filename, "%s_%i_%c.pgm", path, number, 'y');
561 :     image_dump_pgm(
562 :     image->y - (EDGE_SIZE * edged_width + EDGE_SIZE),
563 :     edged_width, edged_height, filename);
564 :    
565 :     sprintf(filename, "%s_%i_%c.pgm", path, number, 'u');
566 :     image_dump_pgm(
567 :     image->u - (EDGE_SIZE2 * edged_width / 2 + EDGE_SIZE2),
568 :     edged_width / 2, edged_height / 2, filename);
569 :    
570 :     sprintf(filename, "%s_%i_%c.pgm", path, number, 'v');
571 :     image_dump_pgm(
572 :     image->v - (EDGE_SIZE2 * edged_width / 2 + EDGE_SIZE2),
573 :     edged_width / 2, edged_height / 2, filename);
574 :    
575 :     return 0;
576 :     }
577 :     */
578 :    
579 :    
580 :    
581 :     /* dump image to yuvpgm file */
582 :    
583 :     #include <stdio.h>
584 :    
585 :     int
586 :     image_dump_yuvpgm(const IMAGE * image,
587 :     const uint32_t edged_width,
588 :     const uint32_t width,
589 :     const uint32_t height,
590 :     char *filename)
591 :     {
592 :     FILE *f;
593 :     char hdr[1024];
594 :     uint32_t i;
595 :     uint8_t *bmp1;
596 :     uint8_t *bmp2;
597 :    
598 :    
599 :     f = fopen(filename, "wb");
600 :     if (f == NULL) {
601 :     return -1;
602 :     }
603 :     sprintf(hdr, "P5\n#xvid\n%i %i\n255\n", width, (3 * height) / 2);
604 :     fwrite(hdr, strlen(hdr), 1, f);
605 :    
606 :     bmp1 = image->y;
607 :     for (i = 0; i < height; i++) {
608 :     fwrite(bmp1, width, 1, f);
609 :     bmp1 += edged_width;
610 :     }
611 :    
612 :     bmp1 = image->u;
613 :     bmp2 = image->v;
614 :     for (i = 0; i < height / 2; i++) {
615 :     fwrite(bmp1, width / 2, 1, f);
616 :     fwrite(bmp2, width / 2, 1, f);
617 :     bmp1 += edged_width / 2;
618 :     bmp2 += edged_width / 2;
619 :     }
620 :    
621 :     fclose(f);
622 :     return 0;
623 :     }
624 :    
625 :    
626 :     #define ABS(X) (((X)>0)?(X):-(X))
627 :     float
628 :     image_mad(const IMAGE * img1,
629 :     const IMAGE * img2,
630 :     uint32_t stride,
631 :     uint32_t width,
632 :     uint32_t height)
633 :     {
634 :     const uint32_t stride2 = stride / 2;
635 :     const uint32_t width2 = width / 2;
636 :     const uint32_t height2 = height / 2;
637 :    
638 :     uint32_t x, y;
639 :     uint32_t sum = 0;
640 :    
641 :     for (y = 0; y < height; y++)
642 :     for (x = 0; x < width; x++)
643 :     sum += ABS(img1->y[x + y * stride] - img2->y[x + y * stride]);
644 :    
645 :     for (y = 0; y < height2; y++)
646 :     for (x = 0; x < width2; x++)
647 :     sum += ABS(img1->u[x + y * stride2] - img2->u[x + y * stride2]);
648 :    
649 :     for (y = 0; y < height2; y++)
650 :     for (x = 0; x < width2; x++)
651 :     sum += ABS(img1->v[x + y * stride2] - img2->v[x + y * stride2]);
652 :    
653 :     return (float) sum / (width * height * 3 / 2);
654 :     }
655 :    
656 :     void
657 :     output_slice(IMAGE * cur, int std, int width, XVID_DEC_PICTURE* out_frm, int mbx, int mby,int mbl) {
658 :     uint8_t *dY,*dU,*dV,*sY,*sU,*sV;
659 :     int std2 = std >> 1;
660 :     int w = mbl << 4, w2,i;
661 :    
662 :     if(w > width)
663 :     w = width;
664 :     w2 = w >> 1;
665 : suxen_drol 323
666 : albeu 315 dY = (uint8_t*)out_frm->y + (mby << 4) * out_frm->stride_y + (mbx << 4);
667 :     dU = (uint8_t*)out_frm->u + (mby << 3) * out_frm->stride_u + (mbx << 3);
668 :     dV = (uint8_t*)out_frm->v + (mby << 3) * out_frm->stride_v + (mbx << 3);
669 :     sY = cur->y + (mby << 4) * std + (mbx << 4);
670 :     sU = cur->u + (mby << 3) * std2 + (mbx << 3);
671 :     sV = cur->v + (mby << 3) * std2 + (mbx << 3);
672 :    
673 :     for(i = 0 ; i < 16 ; i++) {
674 :     memcpy(dY,sY,w);
675 : suxen_drol 323 dY += out_frm->stride_y;
676 :     sY += std;
677 :     }
678 : albeu 315 for(i = 0 ; i < 8 ; i++) {
679 :     memcpy(dU,sU,w2);
680 :     dU += out_frm->stride_u;
681 :     sU += std2;
682 :     }
683 :     for(i = 0 ; i < 8 ; i++) {
684 :     memcpy(dV,sV,w2);
685 :     dV += out_frm->stride_v;
686 :     sV += std2;
687 :     }
688 :     }

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