OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2001-2003 Michael Niedermayer <michaelni@gmx.at> | 2 * Copyright (C) 2001-2003 Michael Niedermayer <michaelni@gmx.at> |
3 * | 3 * |
4 * This file is part of FFmpeg. | 4 * This file is part of FFmpeg. |
5 * | 5 * |
6 * FFmpeg is free software; you can redistribute it and/or modify | 6 * FFmpeg is free software; you can redistribute it and/or modify |
7 * it under the terms of the GNU General Public License as published by | 7 * it under the terms of the GNU General Public License as published by |
8 * the Free Software Foundation; either version 2 of the License, or | 8 * the Free Software Foundation; either version 2 of the License, or |
9 * (at your option) any later version. | 9 * (at your option) any later version. |
10 * | 10 * |
(...skipping 2633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2644 lastDstY= dstY; | 2644 lastDstY= dstY; |
2645 | 2645 |
2646 for (;dstY < dstH; dstY++) { | 2646 for (;dstY < dstH; dstY++) { |
2647 unsigned char *dest =dst[0]+dstStride[0]*dstY; | 2647 unsigned char *dest =dst[0]+dstStride[0]*dstY; |
2648 const int chrDstY= dstY>>c->chrDstVSubSample; | 2648 const int chrDstY= dstY>>c->chrDstVSubSample; |
2649 unsigned char *uDest=dst[1]+dstStride[1]*chrDstY; | 2649 unsigned char *uDest=dst[1]+dstStride[1]*chrDstY; |
2650 unsigned char *vDest=dst[2]+dstStride[2]*chrDstY; | 2650 unsigned char *vDest=dst[2]+dstStride[2]*chrDstY; |
2651 unsigned char *aDest=(CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3]+dstStr
ide[3]*dstY : NULL; | 2651 unsigned char *aDest=(CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3]+dstStr
ide[3]*dstY : NULL; |
2652 | 2652 |
2653 const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as inpu
t | 2653 const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as inpu
t |
| 2654 const int firstLumSrcY2= vLumFilterPos[FFMIN(dstY | ((1<<c->chrDstVSubSa
mple) - 1), dstH-1)]; |
2654 const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as i
nput | 2655 const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as i
nput |
2655 int lastLumSrcY= firstLumSrcY + vLumFilterSize -1; // Last line needed a
s input | 2656 int lastLumSrcY= firstLumSrcY + vLumFilterSize -1; // Last line needed a
s input |
| 2657 int lastLumSrcY2=firstLumSrcY2+ vLumFilterSize -1; // Last line needed a
s input |
2656 int lastChrSrcY= firstChrSrcY + vChrFilterSize -1; // Last line needed a
s input | 2658 int lastChrSrcY= firstChrSrcY + vChrFilterSize -1; // Last line needed a
s input |
2657 int enough_lines; | 2659 int enough_lines; |
2658 | 2660 |
2659 //handle holes (FAST_BILINEAR & weird filters) | 2661 //handle holes (FAST_BILINEAR & weird filters) |
2660 if (firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1; | 2662 if (firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1; |
2661 if (firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1; | 2663 if (firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1; |
2662 assert(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1); | 2664 assert(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1); |
2663 assert(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1); | 2665 assert(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1); |
2664 | 2666 |
2665 // Do we have enough lines in this slice to output the dstY line | |
2666 enough_lines = lastLumSrcY < srcSliceY + srcSliceH && lastChrSrcY < -((-
srcSliceY - srcSliceH)>>c->chrSrcVSubSample); | |
2667 if (!enough_lines) { | |
2668 lastLumSrcY = srcSliceY + srcSliceH - 1; | |
2669 lastChrSrcY = chrSrcSliceY + chrSrcSliceH - 1; | |
2670 } | |
2671 | |
2672 DEBUG_BUFFERS("dstY: %d\n", dstY); | 2667 DEBUG_BUFFERS("dstY: %d\n", dstY); |
2673 DEBUG_BUFFERS("\tfirstLumSrcY: %d lastLumSrcY: %d lastInLumBuf: %d\n", | 2668 DEBUG_BUFFERS("\tfirstLumSrcY: %d lastLumSrcY: %d lastInLumBuf: %d\n", |
2674 firstLumSrcY, lastLumSrcY, lastInLumBuf); | 2669 firstLumSrcY, lastLumSrcY, lastInLumBuf); |
2675 DEBUG_BUFFERS("\tfirstChrSrcY: %d lastChrSrcY: %d lastInChrBuf: %d\n", | 2670 DEBUG_BUFFERS("\tfirstChrSrcY: %d lastChrSrcY: %d lastInChrBuf: %d\n", |
2676 firstChrSrcY, lastChrSrcY, lastInChrBuf); | 2671 firstChrSrcY, lastChrSrcY, lastInChrBuf); |
2677 | 2672 |
| 2673 // Do we have enough lines in this slice to output the dstY line |
| 2674 enough_lines = lastLumSrcY2 < srcSliceY + srcSliceH && lastChrSrcY < -((
-srcSliceY - srcSliceH)>>c->chrSrcVSubSample); |
| 2675 |
| 2676 if (!enough_lines) { |
| 2677 lastLumSrcY = srcSliceY + srcSliceH - 1; |
| 2678 lastChrSrcY = chrSrcSliceY + chrSrcSliceH - 1; |
| 2679 DEBUG_BUFFERS("buffering slice: lastLumSrcY %d lastChrSrcY %d\n", |
| 2680 lastLumSrcY, lastChrSrcY); |
| 2681 } |
| 2682 |
2678 //Do horizontal scaling | 2683 //Do horizontal scaling |
2679 while(lastInLumBuf < lastLumSrcY) { | 2684 while(lastInLumBuf < lastLumSrcY) { |
2680 const uint8_t *src1= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride
[0]; | 2685 const uint8_t *src1= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride
[0]; |
2681 const uint8_t *src2= src[3]+(lastInLumBuf + 1 - srcSliceY)*srcStride
[3]; | 2686 const uint8_t *src2= src[3]+(lastInLumBuf + 1 - srcSliceY)*srcStride
[3]; |
2682 lumBufIndex++; | 2687 lumBufIndex++; |
2683 DEBUG_BUFFERS("\t\tlumBufIndex %d: lastInLumBuf: %d\n", | |
2684 lumBufIndex, lastInLumBuf); | |
2685 assert(lumBufIndex < 2*vLumBufSize); | 2688 assert(lumBufIndex < 2*vLumBufSize); |
2686 assert(lastInLumBuf + 1 - srcSliceY < srcSliceH); | 2689 assert(lastInLumBuf + 1 - srcSliceY < srcSliceH); |
2687 assert(lastInLumBuf + 1 - srcSliceY >= 0); | 2690 assert(lastInLumBuf + 1 - srcSliceY >= 0); |
2688 RENAME(hyscale)(c, lumPixBuf[ lumBufIndex ], dstW, src1, srcW, lumXI
nc, | 2691 RENAME(hyscale)(c, lumPixBuf[ lumBufIndex ], dstW, src1, srcW, lumXI
nc, |
2689 hLumFilter, hLumFilterPos, hLumFilterSize, | 2692 hLumFilter, hLumFilterPos, hLumFilterSize, |
2690 formatConvBuffer, | 2693 formatConvBuffer, |
2691 pal, 0); | 2694 pal, 0); |
2692 if (CONFIG_SWSCALE_ALPHA && alpPixBuf) | 2695 if (CONFIG_SWSCALE_ALPHA && alpPixBuf) |
2693 RENAME(hyscale)(c, alpPixBuf[ lumBufIndex ], dstW, src2, srcW, l
umXInc, | 2696 RENAME(hyscale)(c, alpPixBuf[ lumBufIndex ], dstW, src2, srcW, l
umXInc, |
2694 hLumFilter, hLumFilterPos, hLumFilterSize, | 2697 hLumFilter, hLumFilterPos, hLumFilterSize, |
2695 formatConvBuffer, | 2698 formatConvBuffer, |
2696 pal, 1); | 2699 pal, 1); |
2697 lastInLumBuf++; | 2700 lastInLumBuf++; |
| 2701 DEBUG_BUFFERS("\t\tlumBufIndex %d: lastInLumBuf: %d\n", |
| 2702 lumBufIndex, lastInLumBuf); |
2698 } | 2703 } |
2699 while(lastInChrBuf < lastChrSrcY) { | 2704 while(lastInChrBuf < lastChrSrcY) { |
2700 const uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStr
ide[1]; | 2705 const uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStr
ide[1]; |
2701 const uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStr
ide[2]; | 2706 const uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStr
ide[2]; |
2702 chrBufIndex++; | 2707 chrBufIndex++; |
2703 DEBUG_BUFFERS("\t\tchrBufIndex %d: lastInChrBuf: %d\n", | |
2704 chrBufIndex, lastInChrBuf); | |
2705 assert(chrBufIndex < 2*vChrBufSize); | 2708 assert(chrBufIndex < 2*vChrBufSize); |
2706 assert(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH)); | 2709 assert(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH)); |
2707 assert(lastInChrBuf + 1 - chrSrcSliceY >= 0); | 2710 assert(lastInChrBuf + 1 - chrSrcSliceY >= 0); |
2708 //FIXME replace parameters through context struct (some at least) | 2711 //FIXME replace parameters through context struct (some at least) |
2709 | 2712 |
2710 if (c->needs_hcscale) | 2713 if (c->needs_hcscale) |
2711 RENAME(hcscale)(c, chrPixBuf[ chrBufIndex ], chrDstW, src1, src2
, chrSrcW, chrXInc, | 2714 RENAME(hcscale)(c, chrPixBuf[ chrBufIndex ], chrDstW, src1, src2
, chrSrcW, chrXInc, |
2712 hChrFilter, hChrFilterPos, hChrFilterSize, | 2715 hChrFilter, hChrFilterPos, hChrFilterSize, |
2713 formatConvBuffer, | 2716 formatConvBuffer, |
2714 pal); | 2717 pal); |
2715 lastInChrBuf++; | 2718 lastInChrBuf++; |
| 2719 DEBUG_BUFFERS("\t\tchrBufIndex %d: lastInChrBuf: %d\n", |
| 2720 chrBufIndex, lastInChrBuf); |
2716 } | 2721 } |
2717 //wrap buf index around to stay inside the ring buffer | 2722 //wrap buf index around to stay inside the ring buffer |
2718 if (lumBufIndex >= vLumBufSize) lumBufIndex-= vLumBufSize; | 2723 if (lumBufIndex >= vLumBufSize) lumBufIndex-= vLumBufSize; |
2719 if (chrBufIndex >= vChrBufSize) chrBufIndex-= vChrBufSize; | 2724 if (chrBufIndex >= vChrBufSize) chrBufIndex-= vChrBufSize; |
2720 if (!enough_lines) | 2725 if (!enough_lines) |
2721 break; //we can't output a dstY line so let's try with the next slic
e | 2726 break; //we can't output a dstY line so let's try with the next slic
e |
2722 | 2727 |
2723 #if COMPILE_TEMPLATE_MMX | 2728 #if COMPILE_TEMPLATE_MMX |
2724 c->blueDither= ff_dither8[dstY&1]; | 2729 c->blueDither= ff_dither8[dstY&1]; |
2725 if (c->dstFormat == PIX_FMT_RGB555 || c->dstFormat == PIX_FMT_BGR555) | 2730 if (c->dstFormat == PIX_FMT_RGB555 || c->dstFormat == PIX_FMT_BGR555) |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3041 c->lumSrcOffset = ALT32_CORR; | 3046 c->lumSrcOffset = ALT32_CORR; |
3042 c->chrSrcOffset = ALT32_CORR; | 3047 c->chrSrcOffset = ALT32_CORR; |
3043 break; | 3048 break; |
3044 case PIX_FMT_RGB48LE: | 3049 case PIX_FMT_RGB48LE: |
3045 c->lumSrcOffset = 1; | 3050 c->lumSrcOffset = 1; |
3046 c->chrSrcOffset = 1; | 3051 c->chrSrcOffset = 1; |
3047 c->alpSrcOffset = 1; | 3052 c->alpSrcOffset = 1; |
3048 break; | 3053 break; |
3049 } | 3054 } |
3050 | 3055 |
3051 if (c->srcRange != c->dstRange && !(isRGB(c->dstFormat) || isBGR(c->dstForma
t))) { | 3056 if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) { |
3052 if (c->srcRange) { | 3057 if (c->srcRange) { |
3053 c->lumConvertRange = RENAME(lumRangeFromJpeg); | 3058 c->lumConvertRange = RENAME(lumRangeFromJpeg); |
3054 c->chrConvertRange = RENAME(chrRangeFromJpeg); | 3059 c->chrConvertRange = RENAME(chrRangeFromJpeg); |
3055 } else { | 3060 } else { |
3056 c->lumConvertRange = RENAME(lumRangeToJpeg); | 3061 c->lumConvertRange = RENAME(lumRangeToJpeg); |
3057 c->chrConvertRange = RENAME(chrRangeToJpeg); | 3062 c->chrConvertRange = RENAME(chrRangeToJpeg); |
3058 } | 3063 } |
3059 } | 3064 } |
3060 | 3065 |
3061 if (!(isGray(srcFormat) || isGray(c->dstFormat) || | 3066 if (!(isGray(srcFormat) || isGray(c->dstFormat) || |
3062 srcFormat == PIX_FMT_MONOBLACK || srcFormat == PIX_FMT_MONOWHITE)) | 3067 srcFormat == PIX_FMT_MONOBLACK || srcFormat == PIX_FMT_MONOWHITE)) |
3063 c->needs_hcscale = 1; | 3068 c->needs_hcscale = 1; |
3064 } | 3069 } |
OLD | NEW |