-//printf("sws Strides:%d %d %d -> %d %d %d\n", srcStride[0],srcStride[1],srcStride[2],
-//dstStride[0],dstStride[1],dstStride[2]);
-
- if(dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0)
- {
- static int firstTime=1; //FIXME move this into the context perhaps
- if(flags & SWS_PRINT_INFO && firstTime)
- {
- MSG_WARN("SwScaler: Warning: dstStride is not aligned!\n"
- "SwScaler: ->cannot do aligned memory acesses anymore\n");
- firstTime=0;
- }
- }
-
- /* Note the user might start scaling the picture in the middle so this will not get executed
- this is not really intended but works currently, so ppl might do it */
- if(srcSliceY ==0){
- lumBufIndex=0;
- chrBufIndex=0;
- dstY=0;
- lastInLumBuf= -1;
- lastInChrBuf= -1;
- }
-
- lastDstY= dstY;
-
- for(;dstY < dstH; dstY++){
- unsigned char *dest =dst[0]+dstStride[0]*dstY;
- const int chrDstY= dstY>>c->chrDstVSubSample;
- unsigned char *uDest=dst[1]+dstStride[1]*chrDstY;
- unsigned char *vDest=dst[2]+dstStride[2]*chrDstY;
-
- const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input
- const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as input
- const int lastLumSrcY= firstLumSrcY + vLumFilterSize -1; // Last line needed as input
- const int lastChrSrcY= firstChrSrcY + vChrFilterSize -1; // Last line needed as input
-
-//printf("dstY:%d dstH:%d firstLumSrcY:%d lastInLumBuf:%d vLumBufSize: %d vChrBufSize: %d slice: %d %d vLumFilterSize: %d firstChrSrcY: %d vChrFilterSize: %d c->chrSrcVSubSample: %d\n",
-// dstY, dstH, firstLumSrcY, lastInLumBuf, vLumBufSize, vChrBufSize, srcSliceY, srcSliceH, vLumFilterSize, firstChrSrcY, vChrFilterSize, c->chrSrcVSubSample);
- //handle holes (FAST_BILINEAR & weird filters)
- if(firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1;
- if(firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1;
-//printf("%d %d %d\n", firstChrSrcY, lastInChrBuf, vChrBufSize);
- ASSERT(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1)
- ASSERT(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1)
-
- // Do we have enough lines in this slice to output the dstY line
- if(lastLumSrcY < srcSliceY + srcSliceH && lastChrSrcY < -((-srcSliceY - srcSliceH)>>c->chrSrcVSubSample))
- {
- //Do horizontal scaling
- while(lastInLumBuf < lastLumSrcY)
- {
- uint8_t *s= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0];
- lumBufIndex++;
-// printf("%d %d %d %d\n", lumBufIndex, vLumBufSize, lastInLumBuf, lastLumSrcY);
- ASSERT(lumBufIndex < 2*vLumBufSize)
- ASSERT(lastInLumBuf + 1 - srcSliceY < srcSliceH)
- ASSERT(lastInLumBuf + 1 - srcSliceY >= 0)
-// printf("%d %d\n", lumBufIndex, vLumBufSize);
- RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc,
- flags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize,
- funnyYCode, c->srcFormat, formatConvBuffer,
- c->lumMmx2Filter, c->lumMmx2FilterPos);
- lastInLumBuf++;
- }
- while(lastInChrBuf < lastChrSrcY)
- {
- uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[1];
- uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2];
- chrBufIndex++;
- ASSERT(chrBufIndex < 2*vChrBufSize)
- ASSERT(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH))
- ASSERT(lastInChrBuf + 1 - chrSrcSliceY >= 0)
- //FIXME replace parameters through context struct (some at least)
-
- if(!(isGray(srcFormat) || isGray(dstFormat)))
- RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc,
- flags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize,
- funnyUVCode, c->srcFormat, formatConvBuffer,
- c->chrMmx2Filter, c->chrMmx2FilterPos);
- lastInChrBuf++;
- }
- //wrap buf index around to stay inside the ring buffer
- if(lumBufIndex >= vLumBufSize ) lumBufIndex-= vLumBufSize;
- if(chrBufIndex >= vChrBufSize ) chrBufIndex-= vChrBufSize;
- }
- else // not enough lines left in this slice -> load the rest in the buffer
- {
-/* printf("%d %d Last:%d %d LastInBuf:%d %d Index:%d %d Y:%d FSize: %d %d BSize: %d %d\n",
- firstChrSrcY,firstLumSrcY,lastChrSrcY,lastLumSrcY,
- lastInChrBuf,lastInLumBuf,chrBufIndex,lumBufIndex,dstY,vChrFilterSize,vLumFilterSize,
- vChrBufSize, vLumBufSize);*/
-
- //Do horizontal scaling
- while(lastInLumBuf+1 < srcSliceY + srcSliceH)
- {
- uint8_t *s= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0];
- lumBufIndex++;
- ASSERT(lumBufIndex < 2*vLumBufSize)
- ASSERT(lastInLumBuf + 1 - srcSliceY < srcSliceH)
- ASSERT(lastInLumBuf + 1 - srcSliceY >= 0)
- RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc,
- flags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize,
- funnyYCode, c->srcFormat, formatConvBuffer,
- c->lumMmx2Filter, c->lumMmx2FilterPos);
- lastInLumBuf++;
- }
- while(lastInChrBuf+1 < (chrSrcSliceY + chrSrcSliceH))
- {
- uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[1];
- uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2];
- chrBufIndex++;
- ASSERT(chrBufIndex < 2*vChrBufSize)
- ASSERT(lastInChrBuf + 1 - chrSrcSliceY < chrSrcSliceH)
- ASSERT(lastInChrBuf + 1 - chrSrcSliceY >= 0)
-
- if(!(isGray(srcFormat) || isGray(dstFormat)))
- RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc,
- flags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize,
- funnyUVCode, c->srcFormat, formatConvBuffer,
- c->chrMmx2Filter, c->chrMmx2FilterPos);
- lastInChrBuf++;
- }
- //wrap buf index around to stay inside the ring buffer
- if(lumBufIndex >= vLumBufSize ) lumBufIndex-= vLumBufSize;
- if(chrBufIndex >= vChrBufSize ) chrBufIndex-= vChrBufSize;
- break; //we can't output a dstY line so let's try with the next slice
- }
+ //printf("sws Strides:%d %d %d -> %d %d %d\n", srcStride[0],srcStride[1],srcStride[2],
+ //dstStride[0],dstStride[1],dstStride[2]);
+
+ if (dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0)
+ {
+ static int firstTime=1; //FIXME move this into the context perhaps
+ if (flags & SWS_PRINT_INFO && firstTime)
+ {
+ av_log(c, AV_LOG_WARNING, "SwScaler: Warning: dstStride is not aligned!\n"
+ "SwScaler: ->cannot do aligned memory acesses anymore\n");
+ firstTime=0;
+ }
+ }
+
+ /* Note the user might start scaling the picture in the middle so this will not get executed
+ this is not really intended but works currently, so ppl might do it */
+ if (srcSliceY ==0){
+ lumBufIndex=0;
+ chrBufIndex=0;
+ dstY=0;
+ lastInLumBuf= -1;
+ lastInChrBuf= -1;
+ }
+
+ lastDstY= dstY;
+
+ for (;dstY < dstH; dstY++){
+ unsigned char *dest =dst[0]+dstStride[0]*dstY;
+ const int chrDstY= dstY>>c->chrDstVSubSample;
+ unsigned char *uDest=dst[1]+dstStride[1]*chrDstY;
+ unsigned char *vDest=dst[2]+dstStride[2]*chrDstY;
+
+ const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input
+ const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as input
+ const int lastLumSrcY= firstLumSrcY + vLumFilterSize -1; // Last line needed as input
+ const int lastChrSrcY= firstChrSrcY + vChrFilterSize -1; // Last line needed as input
+
+ //printf("dstY:%d dstH:%d firstLumSrcY:%d lastInLumBuf:%d vLumBufSize: %d vChrBufSize: %d slice: %d %d vLumFilterSize: %d firstChrSrcY: %d vChrFilterSize: %d c->chrSrcVSubSample: %d\n",
+ // dstY, dstH, firstLumSrcY, lastInLumBuf, vLumBufSize, vChrBufSize, srcSliceY, srcSliceH, vLumFilterSize, firstChrSrcY, vChrFilterSize, c->chrSrcVSubSample);
+ //handle holes (FAST_BILINEAR & weird filters)
+ if (firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1;
+ if (firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1;
+ //printf("%d %d %d\n", firstChrSrcY, lastInChrBuf, vChrBufSize);
+ ASSERT(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1)
+ ASSERT(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1)
+
+ // Do we have enough lines in this slice to output the dstY line
+ if (lastLumSrcY < srcSliceY + srcSliceH && lastChrSrcY < -((-srcSliceY - srcSliceH)>>c->chrSrcVSubSample))
+ {
+ //Do horizontal scaling
+ while(lastInLumBuf < lastLumSrcY)
+ {
+ uint8_t *s= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0];
+ lumBufIndex++;
+ //printf("%d %d %d %d\n", lumBufIndex, vLumBufSize, lastInLumBuf, lastLumSrcY);
+ ASSERT(lumBufIndex < 2*vLumBufSize)
+ ASSERT(lastInLumBuf + 1 - srcSliceY < srcSliceH)
+ ASSERT(lastInLumBuf + 1 - srcSliceY >= 0)
+ //printf("%d %d\n", lumBufIndex, vLumBufSize);
+ RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc,
+ flags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize,
+ funnyYCode, c->srcFormat, formatConvBuffer,
+ c->lumMmx2Filter, c->lumMmx2FilterPos, pal);
+ lastInLumBuf++;
+ }
+ while(lastInChrBuf < lastChrSrcY)
+ {
+ uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[1];
+ uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2];
+ chrBufIndex++;
+ ASSERT(chrBufIndex < 2*vChrBufSize)
+ ASSERT(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH))
+ ASSERT(lastInChrBuf + 1 - chrSrcSliceY >= 0)
+ //FIXME replace parameters through context struct (some at least)
+
+ if (!(isGray(srcFormat) || isGray(dstFormat)))
+ RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc,
+ flags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize,
+ funnyUVCode, c->srcFormat, formatConvBuffer,
+ c->chrMmx2Filter, c->chrMmx2FilterPos, pal);
+ lastInChrBuf++;
+ }
+ //wrap buf index around to stay inside the ring buffer
+ if (lumBufIndex >= vLumBufSize ) lumBufIndex-= vLumBufSize;
+ if (chrBufIndex >= vChrBufSize ) chrBufIndex-= vChrBufSize;
+ }
+ else // not enough lines left in this slice -> load the rest in the buffer
+ {
+ /* printf("%d %d Last:%d %d LastInBuf:%d %d Index:%d %d Y:%d FSize: %d %d BSize: %d %d\n",
+ firstChrSrcY,firstLumSrcY,lastChrSrcY,lastLumSrcY,
+ lastInChrBuf,lastInLumBuf,chrBufIndex,lumBufIndex,dstY,vChrFilterSize,vLumFilterSize,
+ vChrBufSize, vLumBufSize);*/
+
+ //Do horizontal scaling
+ while(lastInLumBuf+1 < srcSliceY + srcSliceH)
+ {
+ uint8_t *s= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0];
+ lumBufIndex++;
+ ASSERT(lumBufIndex < 2*vLumBufSize)
+ ASSERT(lastInLumBuf + 1 - srcSliceY < srcSliceH)
+ ASSERT(lastInLumBuf + 1 - srcSliceY >= 0)
+ RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc,
+ flags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize,
+ funnyYCode, c->srcFormat, formatConvBuffer,
+ c->lumMmx2Filter, c->lumMmx2FilterPos, pal);
+ lastInLumBuf++;
+ }
+ while(lastInChrBuf+1 < (chrSrcSliceY + chrSrcSliceH))
+ {
+ uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[1];
+ uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2];
+ chrBufIndex++;
+ ASSERT(chrBufIndex < 2*vChrBufSize)
+ ASSERT(lastInChrBuf + 1 - chrSrcSliceY < chrSrcSliceH)
+ ASSERT(lastInChrBuf + 1 - chrSrcSliceY >= 0)
+
+ if (!(isGray(srcFormat) || isGray(dstFormat)))
+ RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc,
+ flags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize,
+ funnyUVCode, c->srcFormat, formatConvBuffer,
+ c->chrMmx2Filter, c->chrMmx2FilterPos, pal);
+ lastInChrBuf++;
+ }
+ //wrap buf index around to stay inside the ring buffer
+ if (lumBufIndex >= vLumBufSize ) lumBufIndex-= vLumBufSize;
+ if (chrBufIndex >= vChrBufSize ) chrBufIndex-= vChrBufSize;
+ break; //we can't output a dstY line so let's try with the next slice
+ }