Revision 42239ced

View differences:

libavcodec/utils.c
136 136
    case PIX_FMT_YUVJ440P:
137 137
    case PIX_FMT_YUVJ444P:
138 138
    case PIX_FMT_YUVA420P:
139
    case PIX_FMT_YUV420P9LE:
140
    case PIX_FMT_YUV420P9BE:
141
    case PIX_FMT_YUV420P10LE:
142
    case PIX_FMT_YUV420P10BE:
139 143
        w_align= 16; //FIXME check for non mpeg style codecs and use less alignment
140 144
        h_align= 16;
141 145
        if(s->codec_id == CODEC_ID_MPEG2VIDEO || s->codec_id == CODEC_ID_MJPEG || s->codec_id == CODEC_ID_AMV || s->codec_id == CODEC_ID_THP || s->codec_id == CODEC_ID_H264)
libavutil/pixdesc.c
740 740
        .log2_chroma_h = 1,
741 741
        .flags = PIX_FMT_HWACCEL,
742 742
    },
743
    [PIX_FMT_YUV420P9LE] = {
744
        .name = "yuv420p9le",
745
        .nb_components= 3,
746
        .log2_chroma_w= 1,
747
        .log2_chroma_h= 1,
748
        .comp = {
749
            {0,1,1,0,8},        /* Y */
750
            {1,1,1,0,8},        /* U */
751
            {2,1,1,0,8},        /* V */
752
        },
753
    },
754
    [PIX_FMT_YUV420P9BE] = {
755
        .name = "yuv420p9be",
756
        .nb_components= 3,
757
        .log2_chroma_w= 1,
758
        .log2_chroma_h= 1,
759
        .comp = {
760
            {0,1,1,0,8},        /* Y */
761
            {1,1,1,0,8},        /* U */
762
            {2,1,1,0,8},        /* V */
763
        },
764
        .flags = PIX_FMT_BE,
765
    },
766
    [PIX_FMT_YUV420P10LE] = {
767
        .name = "yuv420p10le",
768
        .nb_components= 3,
769
        .log2_chroma_w= 1,
770
        .log2_chroma_h= 1,
771
        .comp = {
772
            {0,1,1,0,9},        /* Y */
773
            {1,1,1,0,9},        /* U */
774
            {2,1,1,0,9},        /* V */
775
        },
776
    },
777
    [PIX_FMT_YUV420P10BE] = {
778
        .name = "yuv420p10be",
779
        .nb_components= 3,
780
        .log2_chroma_w= 1,
781
        .log2_chroma_h= 1,
782
        .comp = {
783
            {0,1,1,0,9},        /* Y */
784
            {1,1,1,0,9},        /* U */
785
            {2,1,1,0,9},        /* V */
786
        },
787
        .flags = PIX_FMT_BE,
788
    },
743 789
    [PIX_FMT_YUV420P16LE] = {
744 790
        .name = "yuv420p16le",
745 791
        .nb_components= 3,
libavutil/pixfmt.h
135 135
    PIX_FMT_Y400A,     ///< 8bit gray, 8bit alpha
136 136
    PIX_FMT_BGR48BE,   ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big-endian
137 137
    PIX_FMT_BGR48LE,   ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as little-endian
138
    PIX_FMT_YUV420P9BE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
139
    PIX_FMT_YUV420P9LE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
140
    PIX_FMT_YUV420P10BE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
141
    PIX_FMT_YUV420P10LE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
138 142
    PIX_FMT_NB,        ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions
139 143
};
140 144

  
......
159 163
#define PIX_FMT_BGR555 PIX_FMT_NE(BGR555BE, BGR555LE)
160 164
#define PIX_FMT_BGR444 PIX_FMT_NE(BGR444BE, BGR444LE)
161 165

  
166
#define PIX_FMT_YUV420P9  PIX_FMT_NE(YUV420P9BE , YUV420P9LE)
167
#define PIX_FMT_YUV420P10 PIX_FMT_NE(YUV420P10BE, YUV420P10LE)
162 168
#define PIX_FMT_YUV420P16 PIX_FMT_NE(YUV420P16BE, YUV420P16LE)
163 169
#define PIX_FMT_YUV422P16 PIX_FMT_NE(YUV422P16BE, YUV422P16LE)
164 170
#define PIX_FMT_YUV444P16 PIX_FMT_NE(YUV444P16BE, YUV444P16LE)
libswscale/swscale.c
1669 1669
                length*=2;
1670 1670
            fillPlane(dst[plane], dstStride[plane], length, height, y, (plane==3) ? 255 : 128);
1671 1671
        } else {
1672
            if(is16BPS(c->srcFormat) && !is16BPS(c->dstFormat)) {
1672
            if(isNBPS(c->srcFormat)) {
1673
                const int depth = av_pix_fmt_descriptors[c->srcFormat].comp[plane].depth_minus1+1;
1674
                uint16_t *srcPtr2 = (uint16_t*)srcPtr;
1675

  
1676
                if (is16BPS(c->dstFormat)) {
1677
                    uint16_t *dstPtr2 = (uint16_t*)dstPtr;
1678
                    for (i = 0; i < height; i++) {
1679
                        for (j = 0; j < length; j++)
1680
                            dstPtr2[j] = (srcPtr2[j]<<(16-depth)) | (srcPtr2[j]>>(2*depth-16));
1681
                        dstPtr2 += dstStride[plane]/2;
1682
                        srcPtr2 += srcStride[plane]/2;
1683
                    }
1684
                } else {
1685
                    // FIXME Maybe dither instead.
1686
                    for (i = 0; i < height; i++) {
1687
                        for (j = 0; j < length; j++)
1688
                            dstPtr[j] = srcPtr2[j]>>(depth-8);
1689
                        dstPtr  += dstStride[plane];
1690
                        srcPtr2 += srcStride[plane]/2;
1691
                    }
1692
                }
1693
            } else if(is16BPS(c->srcFormat) && !is16BPS(c->dstFormat)) {
1673 1694
                if (!isBE(c->srcFormat)) srcPtr++;
1674 1695
                for (i=0; i<height; i++) {
1675 1696
                    for (j=0; j<length; j++) dstPtr[j] = srcPtr[j<<1];
libswscale/swscale_internal.h
354 354
        || (x)==PIX_FMT_YUV422P16BE \
355 355
        || (x)==PIX_FMT_YUV444P16BE \
356 356
    )
357
#define isNBPS(x)       (           \
358
           (x)==PIX_FMT_YUV420P9LE  \
359
        || (x)==PIX_FMT_YUV420P9BE  \
360
        || (x)==PIX_FMT_YUV420P10LE \
361
        || (x)==PIX_FMT_YUV420P10BE \
362
    )
357 363
#define isBE(x) ((x)&1)
358 364
#define isPlanar8YUV(x) (           \
359 365
           (x)==PIX_FMT_YUV410P     \
......
368 374
    )
369 375
#define isPlanarYUV(x)  (           \
370 376
        isPlanar8YUV(x)             \
377
        || (x)==PIX_FMT_YUV420P9LE  \
378
        || (x)==PIX_FMT_YUV420P10LE \
371 379
        || (x)==PIX_FMT_YUV420P16LE \
372 380
        || (x)==PIX_FMT_YUV422P16LE \
373 381
        || (x)==PIX_FMT_YUV444P16LE \
382
        || (x)==PIX_FMT_YUV420P9BE  \
383
        || (x)==PIX_FMT_YUV420P10BE \
374 384
        || (x)==PIX_FMT_YUV420P16BE \
375 385
        || (x)==PIX_FMT_YUV422P16BE \
376 386
        || (x)==PIX_FMT_YUV444P16BE \
libswscale/swscale_template.c
225 225
    nvXXtoUV_c(dstV, dstU, src1, width);
226 226
}
227 227

  
228
// FIXME Maybe dither instead.
229
#define YUV_NBPS(depth) \
230
static inline void yuv ## depth ## ToUV_c(uint8_t *dstU, uint8_t *dstV, \
231
                                          const uint8_t *_srcU, const uint8_t *_srcV, \
232
                                          long width, uint32_t *unused) \
233
{ \
234
    int i; \
235
    const uint16_t *srcU = (const uint16_t*)_srcU; \
236
    const uint16_t *srcV = (const uint16_t*)_srcV; \
237
    for (i = 0; i < width; i++) { \
238
        dstU[i] = srcU[i]>>(depth-8); \
239
        dstV[i] = srcV[i]>>(depth-8); \
240
    } \
241
} \
242
\
243
static inline void yuv ## depth ## ToY_c(uint8_t *dstY, const uint8_t *_srcY, long width, uint32_t *unused) \
244
{ \
245
    int i; \
246
    const uint16_t *srcY = (const uint16_t*)_srcY; \
247
    for (i = 0; i < width; i++) \
248
        dstY[i] = srcY[i]>>(depth-8); \
249
} \
250

  
251
YUV_NBPS( 9)
252
YUV_NBPS(10)
253

  
228 254
static inline void bgr24ToY_c(uint8_t *dst, const uint8_t *src,
229 255
                              long width, uint32_t *unused)
230 256
{
......
790 816
        case PIX_FMT_PAL8     :
791 817
        case PIX_FMT_BGR4_BYTE:
792 818
        case PIX_FMT_RGB4_BYTE: c->chrToYV12 = palToUV; break;
819
        case PIX_FMT_YUV420P9BE:
820
        case PIX_FMT_YUV420P9LE: c->chrToYV12 = yuv9ToUV_c; break;
821
        case PIX_FMT_YUV420P10BE:
822
        case PIX_FMT_YUV420P10LE: c->chrToYV12 = yuv10ToUV_c; break;
793 823
        case PIX_FMT_YUV420P16BE:
794 824
        case PIX_FMT_YUV422P16BE:
795 825
        case PIX_FMT_YUV444P16BE: c->chrToYV12 = BEToUV_c; break;
......
836 866
    c->lumToYV12 = NULL;
837 867
    c->alpToYV12 = NULL;
838 868
    switch (srcFormat) {
869
    case PIX_FMT_YUV420P9BE:
870
    case PIX_FMT_YUV420P9LE: c->lumToYV12 = yuv9ToY_c; break;
871
    case PIX_FMT_YUV420P10BE:
872
    case PIX_FMT_YUV420P10LE: c->lumToYV12 = yuv10ToY_c; break;
839 873
    case PIX_FMT_YUYV422  :
840 874
    case PIX_FMT_YUV420P16BE:
841 875
    case PIX_FMT_YUV422P16BE:
libswscale/utils.c
106 106
        || (x)==PIX_FMT_YUV440P     \
107 107
        || (x)==PIX_FMT_MONOWHITE   \
108 108
        || (x)==PIX_FMT_MONOBLACK   \
109
        || (x)==PIX_FMT_YUV420P9LE    \
110
        || (x)==PIX_FMT_YUV420P10LE   \
109 111
        || (x)==PIX_FMT_YUV420P16LE   \
110 112
        || (x)==PIX_FMT_YUV422P16LE   \
111 113
        || (x)==PIX_FMT_YUV444P16LE   \
114
        || (x)==PIX_FMT_YUV420P9BE    \
115
        || (x)==PIX_FMT_YUV420P10BE   \
112 116
        || (x)==PIX_FMT_YUV420P16BE   \
113 117
        || (x)==PIX_FMT_YUV422P16BE   \
114 118
        || (x)==PIX_FMT_YUV444P16BE   \

Also available in: Unified diff