Revision bae76dc3

View differences:

libswscale/swscale_internal.h
273 273
                   int xInc, const int16_t *filter, const int16_t *filterPos,
274 274
                   long filterSize);
275 275

  
276
    void (*lumConvertRange)(uint16_t *dst, int width); ///< Color range conversion function for luma plane if needed.
277
    void (*chrConvertRange)(uint16_t *dst, int width); ///< Color range conversion function for chroma planes if needed.
278

  
276 279
    int lumSrcOffset; ///< Offset given to luma src pointers passed to horizontal input functions.
277 280
    int chrSrcOffset; ///< Offset given to chroma src pointers passed to horizontal input functions.
278 281
    int alpSrcOffset; ///< Offset given to alpha src pointers passed to horizontal input functions.
libswscale/swscale_template.c
2219 2219
#endif /* COMPILE_MMX */
2220 2220
}
2221 2221

  
2222
//FIXME all pal and rgb srcFormats could do this convertion as well
2223
//FIXME all scalers more complex than bilinear could do half of this transform
2224
static void RENAME(chrRangeToJpeg)(uint16_t *dst, int width)
2225
{
2226
    int i;
2227
    for (i = 0; i < width; i++) {
2228
        dst[i     ] = (FFMIN(dst[i     ],30775)*4663 - 9289992)>>12; //-264
2229
        dst[i+VOFW] = (FFMIN(dst[i+VOFW],30775)*4663 - 9289992)>>12; //-264
2230
    }
2231
}
2232
static void RENAME(chrRangeFromJpeg)(uint16_t *dst, int width)
2233
{
2234
    int i;
2235
    for (i = 0; i < width; i++) {
2236
        dst[i     ] = (dst[i     ]*1799 + 4081085)>>11; //1469
2237
        dst[i+VOFW] = (dst[i+VOFW]*1799 + 4081085)>>11; //1469
2238
    }
2239
}
2240
static void RENAME(lumRangeToJpeg)(uint16_t *dst, int width)
2241
{
2242
    int i;
2243
    for (i = 0; i < width; i++)
2244
        dst[i] = (FFMIN(dst[i],30189)*19077 - 39057361)>>14;
2245
}
2246
static void RENAME(lumRangeFromJpeg)(uint16_t *dst, int width)
2247
{
2248
    int i;
2249
    for (i = 0; i < width; i++)
2250
        dst[i] = (dst[i]*14071 + 33561947)>>14;
2251
}
2252

  
2222 2253
#define FAST_BILINEAR_X86 \
2223 2254
    "subl    %%edi, %%esi    \n\t" /*  src[xx+1] - src[xx] */                   \
2224 2255
    "imull   %%ecx, %%esi    \n\t" /* (src[xx+1] - src[xx])*xalpha */           \
......
2253 2284
    int     av_unused canMMX2BeUsed  = c->canMMX2BeUsed;
2254 2285
    void    av_unused *mmx2FilterCode= c->lumMmx2FilterCode;
2255 2286
    void (*internal_func)(uint8_t *, const uint8_t *, long, uint32_t *) = isAlpha ? c->hascale_internal : c->hyscale_internal;
2287
    void (*convertRange)(uint16_t *, int) = isAlpha ? NULL : c->lumConvertRange;
2256 2288

  
2257 2289
    src += isAlpha ? c->alpSrcOffset : c->lumSrcOffset;
2258 2290

  
......
2377 2409
#endif /* ARCH_X86 */
2378 2410
    }
2379 2411

  
2380
    if(!isAlpha && c->srcRange != c->dstRange && !(isRGB(c->dstFormat) || isBGR(c->dstFormat))) {
2381
        int i;
2382
        //FIXME all pal and rgb srcFormats could do this convertion as well
2383
        //FIXME all scalers more complex than bilinear could do half of this transform
2384
        if(c->srcRange) {
2385
            for (i=0; i<dstWidth; i++)
2386
                dst[i]= (dst[i]*14071 + 33561947)>>14;
2387
        } else {
2388
            for (i=0; i<dstWidth; i++)
2389
                dst[i]= (FFMIN(dst[i],30189)*19077 - 39057361)>>14;
2390
        }
2391
    }
2412
    if (convertRange)
2413
        convertRange(dst, dstWidth);
2392 2414
}
2393 2415

  
2394 2416
static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst,
......
2543 2565
        c->hcscale_fast(c, dst, dstWidth, src1, src2, srcW, xInc);
2544 2566
#endif /* ARCH_X86 */
2545 2567
    }
2546
    if(c->srcRange != c->dstRange && !(isRGB(c->dstFormat) || isBGR(c->dstFormat))) {
2547
        int i;
2548
        //FIXME all pal and rgb srcFormats could do this convertion as well
2549
        //FIXME all scalers more complex than bilinear could do half of this transform
2550
        if(c->srcRange) {
2551
            for (i=0; i<dstWidth; i++) {
2552
                dst[i     ]= (dst[i     ]*1799 + 4081085)>>11; //1469
2553
                dst[i+VOFW]= (dst[i+VOFW]*1799 + 4081085)>>11; //1469
2554
            }
2555
        } else {
2556
            for (i=0; i<dstWidth; i++) {
2557
                dst[i     ]= (FFMIN(dst[i     ],30775)*4663 - 9289992)>>12; //-264
2558
                dst[i+VOFW]= (FFMIN(dst[i+VOFW],30775)*4663 - 9289992)>>12; //-264
2559
            }
2560
        }
2561
    }
2568

  
2569
    if (c->chrConvertRange)
2570
        c->chrConvertRange(dst, dstWidth);
2562 2571
}
2563 2572

  
2564 2573
#define DEBUG_SWSCALE_BUFFERS 0
......
3050 3059
        c->alpSrcOffset = 1;
3051 3060
        break;
3052 3061
    }
3062

  
3063
    if (c->srcRange != c->dstRange && !(isRGB(c->dstFormat) || isBGR(c->dstFormat))) {
3064
        if (c->srcRange) {
3065
            c->lumConvertRange = RENAME(lumRangeFromJpeg);
3066
            c->chrConvertRange = RENAME(chrRangeFromJpeg);
3067
        } else {
3068
            c->lumConvertRange = RENAME(lumRangeToJpeg);
3069
            c->chrConvertRange = RENAME(chrRangeToJpeg);
3070
        }
3071
    }
3053 3072
}

Also available in: Unified diff