Mercurial > libavcodec.hg
comparison dsputil.c @ 6445:2b553c57ec51 libavcodec
move ff_emulated_edge_mc() to dsputil
author | aurel |
---|---|
date | Tue, 04 Mar 2008 23:10:47 +0000 |
parents | e1dd408a7864 |
children | c32be43b52b2 |
comparison
equal
deleted
inserted
replaced
6444:3572cc5bc8ff | 6445:2b553c57ec51 |
---|---|
452 for(i=0;i<w;i++) { | 452 for(i=0;i<w;i++) { |
453 memset(buf - (i + 1) * wrap - w, buf[0], w); /* top left */ | 453 memset(buf - (i + 1) * wrap - w, buf[0], w); /* top left */ |
454 memset(buf - (i + 1) * wrap + width, buf[width-1], w); /* top right */ | 454 memset(buf - (i + 1) * wrap + width, buf[width-1], w); /* top right */ |
455 memset(last_line + (i + 1) * wrap - w, last_line[0], w); /* top left */ | 455 memset(last_line + (i + 1) * wrap - w, last_line[0], w); /* top left */ |
456 memset(last_line + (i + 1) * wrap + width, last_line[width-1], w); /* top right */ | 456 memset(last_line + (i + 1) * wrap + width, last_line[width-1], w); /* top right */ |
457 } | |
458 } | |
459 | |
460 /** | |
461 * Copies a rectangular area of samples to a temporary buffer and replicates the boarder samples. | |
462 * @param buf destination buffer | |
463 * @param src source buffer | |
464 * @param linesize number of bytes between 2 vertically adjacent samples in both the source and destination buffers | |
465 * @param block_w width of block | |
466 * @param block_h height of block | |
467 * @param src_x x coordinate of the top left sample of the block in the source buffer | |
468 * @param src_y y coordinate of the top left sample of the block in the source buffer | |
469 * @param w width of the source buffer | |
470 * @param h height of the source buffer | |
471 */ | |
472 void ff_emulated_edge_mc(uint8_t *buf, uint8_t *src, int linesize, int block_w, int block_h, | |
473 int src_x, int src_y, int w, int h){ | |
474 int x, y; | |
475 int start_y, start_x, end_y, end_x; | |
476 | |
477 if(src_y>= h){ | |
478 src+= (h-1-src_y)*linesize; | |
479 src_y=h-1; | |
480 }else if(src_y<=-block_h){ | |
481 src+= (1-block_h-src_y)*linesize; | |
482 src_y=1-block_h; | |
483 } | |
484 if(src_x>= w){ | |
485 src+= (w-1-src_x); | |
486 src_x=w-1; | |
487 }else if(src_x<=-block_w){ | |
488 src+= (1-block_w-src_x); | |
489 src_x=1-block_w; | |
490 } | |
491 | |
492 start_y= FFMAX(0, -src_y); | |
493 start_x= FFMAX(0, -src_x); | |
494 end_y= FFMIN(block_h, h-src_y); | |
495 end_x= FFMIN(block_w, w-src_x); | |
496 | |
497 // copy existing part | |
498 for(y=start_y; y<end_y; y++){ | |
499 for(x=start_x; x<end_x; x++){ | |
500 buf[x + y*linesize]= src[x + y*linesize]; | |
501 } | |
502 } | |
503 | |
504 //top | |
505 for(y=0; y<start_y; y++){ | |
506 for(x=start_x; x<end_x; x++){ | |
507 buf[x + y*linesize]= buf[x + start_y*linesize]; | |
508 } | |
509 } | |
510 | |
511 //bottom | |
512 for(y=end_y; y<block_h; y++){ | |
513 for(x=start_x; x<end_x; x++){ | |
514 buf[x + y*linesize]= buf[x + (end_y-1)*linesize]; | |
515 } | |
516 } | |
517 | |
518 for(y=0; y<block_h; y++){ | |
519 //left | |
520 for(x=0; x<start_x; x++){ | |
521 buf[x + y*linesize]= buf[start_x + y*linesize]; | |
522 } | |
523 | |
524 //right | |
525 for(x=end_x; x<block_w; x++){ | |
526 buf[x + y*linesize]= buf[end_x - 1 + y*linesize]; | |
527 } | |
457 } | 528 } |
458 } | 529 } |
459 | 530 |
460 static void get_pixels_c(DCTELEM *restrict block, const uint8_t *pixels, int line_size) | 531 static void get_pixels_c(DCTELEM *restrict block, const uint8_t *pixels, int line_size) |
461 { | 532 { |