comparison libmpcodecs/native/svq1.c @ 6510:4f23a6c3cda4

use libavcodec's optimized MC functions
author arpi
date Sat, 22 Jun 2002 23:58:15 +0000
parents e3a166f8e81f
children a2086150099b
comparison
equal deleted inserted replaced
6509:762d3cf8da36 6510:4f23a6c3cda4
23 #include <stdio.h> 23 #include <stdio.h>
24 #include <stdlib.h> 24 #include <stdlib.h>
25 #include <string.h> 25 #include <string.h>
26 #include <unistd.h> 26 #include <unistd.h>
27 27
28 #include "../../config.h"
28 #include "bswap.h" 29 #include "bswap.h"
29 30
30 /* variable length (bit) code */ 31 /* variable length (bit) code */
31 typedef struct vlc_code_s { 32 typedef struct vlc_code_s {
32 int16_t value :10, 33 int16_t value :10,
37 38
38 #define MEDIAN(a,b,c) ((a < b != b >= c) ? b : ((a < c != c > b) ? c : a)) 39 #define MEDIAN(a,b,c) ((a < b != b >= c) ? b : ((a < c != c > b) ? c : a))
39 40
40 #include "svq1.h" 41 #include "svq1.h"
41 #include "svq1_cb.h" 42 #include "svq1_cb.h"
43
44 #ifdef USE_LIBAVCODEC
45 typedef void (*op_pixels_func)(unsigned char *block, const unsigned char *pixels, int line_size, int h);
46 extern op_pixels_func put_pixels_tab[4];
47 extern op_pixels_func put_no_rnd_pixels_tab[4];
48 #endif
42 49
43 /* memory bit stream */ 50 /* memory bit stream */
44 typedef struct bit_buffer_s { 51 typedef struct bit_buffer_s {
45 uint8_t *buffer; 52 uint8_t *buffer;
46 uint32_t bitpos; 53 uint32_t bitpos;
337 motion[(x / 8) + 3].y = mv.y; 344 motion[(x / 8) + 3].y = mv.y;
338 345
339 src = &previous[(x + (mv.x >> 1)) + (y + (mv.y >> 1))*pitch]; 346 src = &previous[(x + (mv.x >> 1)) + (y + (mv.y >> 1))*pitch];
340 dst = current; 347 dst = current;
341 348
349 #ifdef USE_LIBAVCODEC
350 put_pixels_tab[((mv.y & 1) << 1) | (mv.x & 1)](dst,src,pitch,16);
351 put_pixels_tab[((mv.y & 1) << 1) | (mv.x & 1)](dst+8,src+8,pitch,16);
352 #else
342 /* form prediction */ 353 /* form prediction */
343 if (mv.y & 0x1) { 354 if (mv.y & 0x1) {
344 if (mv.x & 0x1) { 355 if (mv.x & 0x1) {
345 for (sy=0; sy < 16; sy++) { 356 for (sy=0; sy < 16; sy++) {
346 for (sx=0; sx < 16; sx++) { 357 for (sx=0; sx < 16; sx++) {
373 src += pitch; 384 src += pitch;
374 dst += pitch; 385 dst += pitch;
375 } 386 }
376 } 387 }
377 } 388 }
389 #endif
378 390
379 return 0; 391 return 0;
380 } 392 }
381 393
382 static int motion_inter_4v_block (bit_buffer_t *bitbuf, 394 static int motion_inter_4v_block (bit_buffer_t *bitbuf,
439 /* form predictions */ 451 /* form predictions */
440 for (i=0; i < 4; i++) { 452 for (i=0; i < 4; i++) {
441 src = &previous[(x + (pmv[i]->x >> 1)) + (y + (pmv[i]->y >> 1))*pitch]; 453 src = &previous[(x + (pmv[i]->x >> 1)) + (y + (pmv[i]->y >> 1))*pitch];
442 dst = current; 454 dst = current;
443 455
456 #ifdef USE_LIBAVCODEC
457 put_pixels_tab[((pmv[i]->y & 1) << 1) | (pmv[i]->x & 1)](dst,src,pitch,8);
458 #else
444 if (pmv[i]->y & 0x1) { 459 if (pmv[i]->y & 0x1) {
445 if (pmv[i]->x & 0x1) { 460 if (pmv[i]->x & 0x1) {
446 for (sy=0; sy < 8; sy++) { 461 for (sy=0; sy < 8; sy++) {
447 for (sx=0; sx < 8; sx++) { 462 for (sx=0; sx < 8; sx++) {
448 dst[sx] = (src[sx] + src[sx + 1] + src[sx + pitch] + src[sx + pitch + 1] + 2) >> 2; 463 dst[sx] = (src[sx] + src[sx + 1] + src[sx + pitch] + src[sx + pitch + 1] + 2) >> 2;
474 src += pitch; 489 src += pitch;
475 dst += pitch; 490 dst += pitch;
476 } 491 }
477 } 492 }
478 } 493 }
494 #endif
479 495
480 /* select next block */ 496 /* select next block */
481 if (i & 1) { 497 if (i & 1) {
482 current += 8*(pitch - 1); 498 current += 8*(pitch - 1);
483 previous += 8*(pitch - 1); 499 previous += 8*(pitch - 1);