Mercurial > libavcodec.hg
comparison imgresample.c @ 1928:0c23a5564489 libavcodec
padding support in ffmpeg patch by (Todd Kirby <doubleshot at pacbell dot net>)
author | michael |
---|---|
date | Thu, 08 Apr 2004 18:54:40 +0000 |
parents | 766a2f4edbea |
children | 37ca6f8677de |
comparison
equal
deleted
inserted
replaced
1927:d7505fbe66cb | 1928:0c23a5564489 |
---|---|
43 #define FILTER_BITS 8 | 43 #define FILTER_BITS 8 |
44 | 44 |
45 #define LINE_BUF_HEIGHT (NB_TAPS * 4) | 45 #define LINE_BUF_HEIGHT (NB_TAPS * 4) |
46 | 46 |
47 struct ImgReSampleContext { | 47 struct ImgReSampleContext { |
48 int iwidth, iheight, owidth, oheight, topBand, bottomBand, leftBand, rightBand; | 48 int iwidth, iheight, owidth, oheight; |
49 int topBand, bottomBand, leftBand, rightBand; | |
50 int padtop, padbottom, padleft, padright; | |
51 int pad_owidth, pad_oheight; | |
49 int h_incr, v_incr; | 52 int h_incr, v_incr; |
50 int16_t h_filters[NB_PHASES][NB_TAPS] __align8; /* horizontal filters */ | 53 int16_t h_filters[NB_PHASES][NB_TAPS] __align8; /* horizontal filters */ |
51 int16_t v_filters[NB_PHASES][NB_TAPS] __align8; /* vertical filters */ | 54 int16_t v_filters[NB_PHASES][NB_TAPS] __align8; /* vertical filters */ |
52 uint8_t *line_buf; | 55 uint8_t *line_buf; |
53 }; | 56 }; |
530 v_resample(output, owidth, | 533 v_resample(output, owidth, |
531 s->line_buf + (ring_y - NB_TAPS + 1) * owidth, owidth, | 534 s->line_buf + (ring_y - NB_TAPS + 1) * owidth, owidth, |
532 &s->v_filters[phase_y][0]); | 535 &s->v_filters[phase_y][0]); |
533 | 536 |
534 src_y += s->v_incr; | 537 src_y += s->v_incr; |
538 | |
535 output += owrap; | 539 output += owrap; |
536 } | 540 } |
537 } | 541 } |
538 | 542 |
539 /* XXX: the following filter is quite naive, but it seems to suffice | 543 /* XXX: the following filter is quite naive, but it seems to suffice |
570 } | 574 } |
571 | 575 |
572 ImgReSampleContext *img_resample_init(int owidth, int oheight, | 576 ImgReSampleContext *img_resample_init(int owidth, int oheight, |
573 int iwidth, int iheight) | 577 int iwidth, int iheight) |
574 { | 578 { |
575 return img_resample_full_init(owidth, oheight, iwidth, iheight, 0, 0, 0, 0); | 579 return img_resample_full_init(owidth, oheight, iwidth, iheight, |
580 0, 0, 0, 0, 0, 0, 0, 0); | |
576 } | 581 } |
577 | 582 |
578 ImgReSampleContext *img_resample_full_init(int owidth, int oheight, | 583 ImgReSampleContext *img_resample_full_init(int owidth, int oheight, |
579 int iwidth, int iheight, | 584 int iwidth, int iheight, |
580 int topBand, int bottomBand, | 585 int topBand, int bottomBand, |
581 int leftBand, int rightBand) | 586 int leftBand, int rightBand, |
587 int padtop, int padbottom, | |
588 int padleft, int padright) | |
582 { | 589 { |
583 ImgReSampleContext *s; | 590 ImgReSampleContext *s; |
584 | 591 |
585 s = av_mallocz(sizeof(ImgReSampleContext)); | 592 s = av_mallocz(sizeof(ImgReSampleContext)); |
586 if (!s) | 593 if (!s) |
591 | 598 |
592 s->owidth = owidth; | 599 s->owidth = owidth; |
593 s->oheight = oheight; | 600 s->oheight = oheight; |
594 s->iwidth = iwidth; | 601 s->iwidth = iwidth; |
595 s->iheight = iheight; | 602 s->iheight = iheight; |
603 | |
596 s->topBand = topBand; | 604 s->topBand = topBand; |
597 s->bottomBand = bottomBand; | 605 s->bottomBand = bottomBand; |
598 s->leftBand = leftBand; | 606 s->leftBand = leftBand; |
599 s->rightBand = rightBand; | 607 s->rightBand = rightBand; |
600 | 608 |
601 s->h_incr = ((iwidth - leftBand - rightBand) * POS_FRAC) / owidth; | 609 s->padtop = padtop; |
602 s->v_incr = ((iheight - topBand - bottomBand) * POS_FRAC) / oheight; | 610 s->padbottom = padbottom; |
603 | 611 s->padleft = padleft; |
604 build_filter(&s->h_filters[0][0], (float) owidth / (float) (iwidth - leftBand - rightBand)); | 612 s->padright = padright; |
605 build_filter(&s->v_filters[0][0], (float) oheight / (float) (iheight - topBand - bottomBand)); | 613 |
614 s->pad_owidth = owidth - (padleft + padright); | |
615 s->pad_oheight = oheight - (padtop + padbottom); | |
616 | |
617 s->h_incr = ((iwidth - leftBand - rightBand) * POS_FRAC) / s->pad_owidth; | |
618 s->v_incr = ((iheight - topBand - bottomBand) * POS_FRAC) / s->pad_oheight; | |
619 | |
620 build_filter(&s->h_filters[0][0], (float) s->pad_owidth / | |
621 (float) (iwidth - leftBand - rightBand)); | |
622 build_filter(&s->v_filters[0][0], (float) s->pad_oheight / | |
623 (float) (iheight - topBand - bottomBand)); | |
606 | 624 |
607 return s; | 625 return s; |
608 fail: | 626 fail: |
609 av_free(s); | 627 av_free(s); |
610 return NULL; | 628 return NULL; |
611 } | 629 } |
612 | 630 |
613 void img_resample(ImgReSampleContext *s, | 631 void img_resample(ImgReSampleContext *s, |
614 AVPicture *output, const AVPicture *input) | 632 AVPicture *output, const AVPicture *input) |
615 { | 633 { |
616 int i, shift; | 634 int i, shift; |
617 | 635 uint8_t* optr; |
618 for(i=0;i<3;i++) { | 636 |
637 for (i=0;i<3;i++) { | |
619 shift = (i == 0) ? 0 : 1; | 638 shift = (i == 0) ? 0 : 1; |
620 component_resample(s, output->data[i], output->linesize[i], | 639 |
621 s->owidth >> shift, s->oheight >> shift, | 640 optr = output->data[i] + (((output->linesize[i] * |
622 input->data[i] + (input->linesize[i] * (s->topBand >> shift)) + (s->leftBand >> shift), | 641 s->padtop) + s->padleft) >> shift); |
623 input->linesize[i], ((s->iwidth - s->leftBand - s->rightBand) >> shift), | 642 |
643 component_resample(s, optr, output->linesize[i], | |
644 s->pad_owidth >> shift, s->pad_oheight >> shift, | |
645 input->data[i] + (input->linesize[i] * | |
646 (s->topBand >> shift)) + (s->leftBand >> shift), | |
647 input->linesize[i], ((s->iwidth - s->leftBand - | |
648 s->rightBand) >> shift), | |
624 (s->iheight - s->topBand - s->bottomBand) >> shift); | 649 (s->iheight - s->topBand - s->bottomBand) >> shift); |
625 } | 650 } |
626 } | 651 } |
627 | 652 |
628 void img_resample_close(ImgReSampleContext *s) | 653 void img_resample_close(ImgReSampleContext *s) |