Revision 9990e426

View differences:

libswscale/swscale.c
22 22
 */
23 23

  
24 24
/*
25
  supported Input formats: YV12, I420/IYUV, YUY2, UYVY, BGR32, BGR24, BGR16, BGR15, RGB32, RGB24, Y8/Y800, YVU9/IF09, PAL8
25
  supported Input formats: YV12, I420/IYUV, YUY2, UYVY, BGR32, BGR32_1, BGR24, BGR16, BGR15, RGB32, RGB32_1, RGB24, Y8/Y800, YVU9/IF09, PAL8
26 26
  supported output formats: YV12, I420/IYUV, YUY2, UYVY, {BGR,RGB}{1,4,8,15,16,24,32}, Y8/Y800, YVU9/IF09
27 27
  {BGR,RGB}{1,4,8,15,16} support dithering
28 28

  
......
104 104
        || (x)==PIX_FMT_YUYV422     \
105 105
        || (x)==PIX_FMT_UYVY422     \
106 106
        || (x)==PIX_FMT_RGB32       \
107
        || (x)==PIX_FMT_RGB32_1     \
107 108
        || (x)==PIX_FMT_BGR24       \
108 109
        || (x)==PIX_FMT_BGR565      \
109 110
        || (x)==PIX_FMT_BGR555      \
110 111
        || (x)==PIX_FMT_BGR32       \
112
        || (x)==PIX_FMT_BGR32_1     \
111 113
        || (x)==PIX_FMT_RGB24       \
112 114
        || (x)==PIX_FMT_RGB565      \
113 115
        || (x)==PIX_FMT_RGB555      \
......
498 500
    {\
499 501
    case PIX_FMT_RGB32:\
500 502
    case PIX_FMT_BGR32:\
503
    case PIX_FMT_RGB32_1:\
504
    case PIX_FMT_BGR32_1:\
501 505
        func(uint32_t)\
502 506
            ((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1];\
503 507
            ((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2];\
......
680 684
    {
681 685
    case PIX_FMT_BGR32:
682 686
    case PIX_FMT_RGB32:
687
    case PIX_FMT_BGR32_1:
688
    case PIX_FMT_RGB32_1:
683 689
        YSCALE_YUV_2_RGBX_C(uint32_t)
684 690
            ((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1];
685 691
            ((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2];
......
1573 1579
    return srcSliceH;
1574 1580
}
1575 1581

  
1576
/* {RGB,BGR}{15,16,24,32} -> {RGB,BGR}{15,16,24,32} */
1582
/* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */
1577 1583
static int rgb2rgbWrapper(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
1578 1584
                          int srcSliceH, uint8_t* dst[], int dstStride[]){
1579 1585
    const int srcFormat= c->srcFormat;
......
1632 1638

  
1633 1639
    if(conv)
1634 1640
    {
1641
        uint8_t *srcPtr= src[0];
1642
        if(srcFormat == PIX_FMT_RGB32_1 || srcFormat == PIX_FMT_BGR32_1)
1643
            srcPtr += ALT32_CORR;
1644

  
1635 1645
        if (dstStride[0]*srcBpp == srcStride[0]*dstBpp && srcStride[0] > 0)
1636
            conv(src[0], dst[0] + dstStride[0]*srcSliceY, srcSliceH*srcStride[0]);
1646
            conv(srcPtr, dst[0] + dstStride[0]*srcSliceY, srcSliceH*srcStride[0]);
1637 1647
        else
1638 1648
        {
1639 1649
            int i;
1640
            uint8_t *srcPtr= src[0];
1641 1650
            uint8_t *dstPtr= dst[0] + dstStride[0]*srcSliceY;
1642 1651

  
1643 1652
            for (i=0; i<srcSliceH; i++)
......
2150 2159
           && srcFormat != PIX_FMT_BGR4_BYTE && dstFormat != PIX_FMT_BGR4_BYTE
2151 2160
           && srcFormat != PIX_FMT_RGB4_BYTE && dstFormat != PIX_FMT_RGB4_BYTE
2152 2161
           && srcFormat != PIX_FMT_MONOBLACK && dstFormat != PIX_FMT_MONOBLACK
2162
                                             && dstFormat != PIX_FMT_RGB32_1
2163
                                             && dstFormat != PIX_FMT_BGR32_1
2153 2164
           && !needsDither)
2154 2165
             c->swScale= rgb2rgbWrapper;
2155 2166

  
libswscale/swscale_internal.h
34 34
#define VOFW 2048
35 35
#define VOF  (VOFW*2)
36 36

  
37
#ifdef WORDS_BIGENDIAN
38
#define ALT32_CORR (-1)
39
#else
40
#define ALT32_CORR   1
41
#endif
42

  
37 43
typedef int (*SwsFunc)(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
38 44
             int srcSliceH, uint8_t* dst[], int dstStride[]);
39 45

  
......
222 228
    )
223 229
#define isRGB(x)        (           \
224 230
           (x)==PIX_FMT_RGB32       \
231
        || (x)==PIX_FMT_RGB32_1     \
225 232
        || (x)==PIX_FMT_RGB24       \
226 233
        || (x)==PIX_FMT_RGB565      \
227 234
        || (x)==PIX_FMT_RGB555      \
......
232 239
    )
233 240
#define isBGR(x)        (           \
234 241
           (x)==PIX_FMT_BGR32       \
242
        || (x)==PIX_FMT_BGR32_1     \
235 243
        || (x)==PIX_FMT_BGR24       \
236 244
        || (x)==PIX_FMT_BGR565      \
237 245
        || (x)==PIX_FMT_BGR555      \
libswscale/swscale_template.c
2522 2522
        RENAME(bgr32ToY)(formatConvBuffer, src, srcW);
2523 2523
        src= formatConvBuffer;
2524 2524
    }
2525
    else if (srcFormat==PIX_FMT_RGB32_1)
2526
    {
2527
        RENAME(bgr32ToY)(formatConvBuffer, src+ALT32_CORR, srcW);
2528
        src= formatConvBuffer;
2529
    }
2525 2530
    else if (srcFormat==PIX_FMT_BGR24)
2526 2531
    {
2527 2532
        RENAME(bgr24ToY)(formatConvBuffer, src, srcW);
......
2542 2547
        RENAME(rgb32ToY)(formatConvBuffer, src, srcW);
2543 2548
        src= formatConvBuffer;
2544 2549
    }
2550
    else if (srcFormat==PIX_FMT_BGR32_1)
2551
    {
2552
        RENAME(rgb32ToY)(formatConvBuffer, src+ALT32_CORR, srcW);
2553
        src= formatConvBuffer;
2554
    }
2545 2555
    else if (srcFormat==PIX_FMT_RGB24)
2546 2556
    {
2547 2557
        RENAME(rgb24ToY)(formatConvBuffer, src, srcW);
......
2727 2737
        src1= formatConvBuffer;
2728 2738
        src2= formatConvBuffer+VOFW;
2729 2739
    }
2740
    else if (srcFormat==PIX_FMT_RGB32_1)
2741
    {
2742
        RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1+ALT32_CORR, src2+ALT32_CORR, srcW);
2743
        src1= formatConvBuffer;
2744
        src2= formatConvBuffer+VOFW;
2745
    }
2730 2746
    else if (srcFormat==PIX_FMT_BGR24)
2731 2747
    {
2732 2748
        RENAME(bgr24ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW);
......
2751 2767
        src1= formatConvBuffer;
2752 2768
        src2= formatConvBuffer+VOFW;
2753 2769
    }
2770
    else if (srcFormat==PIX_FMT_BGR32_1)
2771
    {
2772
        RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1+ALT32_CORR, src2+ALT32_CORR, srcW);
2773
        src1= formatConvBuffer;
2774
        src2= formatConvBuffer+VOFW;
2775
    }
2754 2776
    else if (srcFormat==PIX_FMT_RGB24)
2755 2777
    {
2756 2778
        RENAME(rgb24ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW);
libswscale/yuv2rgb.c
644 644
    av_log(c, AV_LOG_WARNING, "No accelerated colorspace conversion found.\n");
645 645

  
646 646
    switch(c->dstFormat){
647
    case PIX_FMT_BGR32_1:
648
    case PIX_FMT_RGB32_1:
647 649
    case PIX_FMT_BGR32:
648 650
    case PIX_FMT_RGB32: return yuv2rgb_c_32;
649 651
    case PIX_FMT_RGB24: return yuv2rgb_c_24_rgb;
......
676 678
int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation)
677 679
{
678 680
    const int isRgb =      c->dstFormat==PIX_FMT_RGB32
681
                        || c->dstFormat==PIX_FMT_RGB32_1
679 682
                        || c->dstFormat==PIX_FMT_BGR24
680 683
                        || c->dstFormat==PIX_FMT_RGB565
681 684
                        || c->dstFormat==PIX_FMT_RGB555
......
684 687
                        || c->dstFormat==PIX_FMT_RGB4_BYTE
685 688
                        || c->dstFormat==PIX_FMT_MONOBLACK;
686 689
    const int bpp = fmt_depth(c->dstFormat);
687
    int i;
690
    int i, base;
688 691
    uint8_t table_Y[1024];
689 692
    uint32_t *table_32 = 0;
690 693
    uint16_t *table_16 = 0;
......
733 736
    switch (bpp) {
734 737
    case 32:
735 738
        table_start= table_32 = av_malloc ((197 + 2*682 + 256 + 132) * sizeof (uint32_t));
739
        base= (c->dstFormat == PIX_FMT_RGB32_1 || c->dstFormat == PIX_FMT_BGR32_1) ? 8 : 0;
736 740

  
737 741
        entry_size = sizeof (uint32_t);
738 742
        table_r = table_32 + 197;
......
740 744
        table_g = table_32 + 197 + 2*682;
741 745

  
742 746
        for (i = -197; i < 256+197; i++)
743
            ((uint32_t *)table_r)[i] = table_Y[i+384] << (isRgb ? 16 : 0);
747
            ((uint32_t *)table_r)[i] = table_Y[i+384] << ((isRgb ? 16 : 0) + base);
744 748
        for (i = -132; i < 256+132; i++)
745
            ((uint32_t *)table_g)[i] = table_Y[i+384] << 8;
749
            ((uint32_t *)table_g)[i] = table_Y[i+384] << (8                + base);
746 750
        for (i = -232; i < 256+232; i++)
747
            ((uint32_t *)table_b)[i] = table_Y[i+384] << (isRgb ? 0 : 16);
751
            ((uint32_t *)table_b)[i] = table_Y[i+384] << ((isRgb ? 0 : 16) + base);
748 752
        break;
749 753

  
750 754
    case 24:

Also available in: Unified diff