Ticket #5923: ycc.diff

File ycc.diff, 4.5 KB (added by Carl Eugen Hoyos, 7 years ago)

Photocd YCC->RGB colorspace conversion: Patch by Kenneth Vermeirsch, kavermei at gmail

  • libavutil/pixdesc.c

     
    646646        },
    647647        .flags = PIX_FMT_BE,
    648648    },
     649    [PIX_FMT_YCC420P] = {
     650        .name = "ycc420p",
     651        .nb_components= 3,
     652        .log2_chroma_w= 1,
     653        .log2_chroma_h= 1,
     654        .comp = {
     655            {0,0,1,0,7},        /* Y */
     656            {1,0,1,0,7},        /* U */
     657            {2,0,1,0,7},        /* V */
     658        },
     659    },
    649660};
    650661
    651662int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
  • libavutil/pixfmt.h

     
    124124    PIX_FMT_YUV444P16LE,  ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
    125125    PIX_FMT_YUV444P16BE,  ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
    126126    PIX_FMT_VDPAU_MPEG4,  ///< MPEG4 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
     127
     128    PIX_FMT_YCC420P,   ///< planar YCC 4:2:0, 12bpp (close to YUV420P but with a different colorspace conversion)
    127129    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
    128130};
    129131
  • libswscale/yuv2rgb.c

     
    3838extern const uint8_t dither_8x8_73[8][8];
    3939extern const uint8_t dither_8x8_220[8][8];
    4040
    41 const int32_t ff_yuv2rgb_coeffs[8][4] = {
     41const int32_t ff_yuv2rgb_coeffs[9][4] = {
    4242    {117504, 138453, 13954, 34903}, /* no sequence_display_extension */
    4343    {117504, 138453, 13954, 34903}, /* ITU-R Rec. 709 (1990) */
    4444    {104597, 132201, 25675, 53279}, /* unspecified */
     
    4646    {104448, 132798, 24759, 53109}, /* FCC */
    4747    {104597, 132201, 25675, 53279}, /* ITU-R Rec. 624-4 System B, G */
    4848    {104597, 132201, 25675, 53279}, /* SMPTE 170M */
    49     {117579, 136230, 16907, 35559}  /* SMPTE 240M (1987) */
     49    {117579, 136230, 16907, 35559}, /* SMPTE 240M (1987) */
     50    {119374, 145352, 28198, 73984}, /* Kodak PhotoCD YCC */
    5051};
    5152
    5253#define LOADCHROMA(i)                               \
  • libswscale/swscale.c

     
    156156        || (x)==PIX_FMT_YUV420P16BE   \
    157157        || (x)==PIX_FMT_YUV422P16BE   \
    158158        || (x)==PIX_FMT_YUV444P16BE   \
     159        || (x)==PIX_FMT_YCC420P     \
    159160    )
    160161
    161162int sws_isSupportedInput(enum PixelFormat pix_fmt)
     
    24062407    int usesVFilter, usesHFilter;
    24072408    int unscaled, needsDither;
    24082409    int srcRange, dstRange;
     2410    int srcColorspace;
    24092411    SwsFilter dummyFilter= {NULL, NULL, NULL, NULL};
    24102412#if ARCH_X86
    24112413    if (flags & SWS_CPU_CAPS_MMX)
     
    24342436        && (fmt_depth(dstFormat))<24
    24352437        && ((fmt_depth(dstFormat))<(fmt_depth(srcFormat)) || (!(isRGB(srcFormat) || isBGR(srcFormat))));
    24362438
     2439    switch (srcFormat) {
     2440    case PIX_FMT_YCC420P:
     2441        srcFormat == PIX_FMT_YUV420P;
     2442        srcColorspace = SWS_CS_KODAKPHOTOYCC;
     2443        break;
     2444    default:
     2445        srcColorspace = SWS_CS_DEFAULT;
     2446        break;
     2447    }
     2448
    24372449    srcRange = handle_jpeg(&srcFormat);
    24382450    dstRange = handle_jpeg(&dstFormat);
    24392451
     
    25322544    c->chrDstW= -((-dstW) >> c->chrDstHSubSample);
    25332545    c->chrDstH= -((-dstH) >> c->chrDstVSubSample);
    25342546
    2535     sws_setColorspaceDetails(c, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT], srcRange, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT] /* FIXME*/, dstRange, 0, 1<<16, 1<<16);
     2547    sws_setColorspaceDetails(c, ff_yuv2rgb_coeffs[srcColorspace], srcRange, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT] /* FIXME*/, dstRange, 0, 1<<16, 1<<16);
    25362548
    25372549    /* unscaled special cases */
    25382550    if (unscaled && !usesHFilter && !usesVFilter && (srcRange == dstRange || isBGR(dstFormat) || isRGB(dstFormat))) {
  • libswscale/swscale.h

     
    101101#define SWS_CS_ITU624         5
    102102#define SWS_CS_SMPTE170M      5
    103103#define SWS_CS_SMPTE240M      7
     104#define SWS_CS_KODAKPHOTOYCC  8
    104105#define SWS_CS_DEFAULT        5
    105106
    106107