comparison libswscale/swscale.c @ 30391:2a33c1c37e6b

Rename isRGB() and isBGR() as their meaning is confusing.
author michael
date Tue, 26 Jan 2010 07:40:14 +0000
parents da75265e5b6f
children db62840d27ae
comparison
equal deleted inserted replaced
30390:e1326b55f7f9 30391:2a33c1c37e6b
88 88
89 #define isPacked(x) ( \ 89 #define isPacked(x) ( \
90 (x)==PIX_FMT_PAL8 \ 90 (x)==PIX_FMT_PAL8 \
91 || (x)==PIX_FMT_YUYV422 \ 91 || (x)==PIX_FMT_YUYV422 \
92 || (x)==PIX_FMT_UYVY422 \ 92 || (x)==PIX_FMT_UYVY422 \
93 || isRGB(x) \ 93 || isRGBinInt(x) \
94 || isBGR(x) \ 94 || isBGRinInt(x) \
95 ) 95 )
96 #define usePal(x) (av_pix_fmt_descriptors[x].flags & PIX_FMT_PAL) 96 #define usePal(x) (av_pix_fmt_descriptors[x].flags & PIX_FMT_PAL)
97 97
98 #define RGB2YUV_SHIFT 15 98 #define RGB2YUV_SHIFT 15
99 #define BY ( (int)(0.114*219/255*(1<<RGB2YUV_SHIFT)+0.5)) 99 #define BY ( (int)(0.114*219/255*(1<<RGB2YUV_SHIFT)+0.5))
1435 const int srcId= c->srcFormatBpp >> 2; /* 1:0, 4:1, 8:2, 15:3, 16:4, 24:6, 32:8 */ 1435 const int srcId= c->srcFormatBpp >> 2; /* 1:0, 4:1, 8:2, 15:3, 16:4, 24:6, 32:8 */
1436 const int dstId= c->dstFormatBpp >> 2; 1436 const int dstId= c->dstFormatBpp >> 2;
1437 void (*conv)(const uint8_t *src, uint8_t *dst, long src_size)=NULL; 1437 void (*conv)(const uint8_t *src, uint8_t *dst, long src_size)=NULL;
1438 1438
1439 /* BGR -> BGR */ 1439 /* BGR -> BGR */
1440 if ( (isBGR(srcFormat) && isBGR(dstFormat)) 1440 if ( (isBGRinInt(srcFormat) && isBGRinInt(dstFormat))
1441 || (isRGB(srcFormat) && isRGB(dstFormat))) { 1441 || (isRGBinInt(srcFormat) && isRGBinInt(dstFormat))) {
1442 switch(srcId | (dstId<<4)) { 1442 switch(srcId | (dstId<<4)) {
1443 case 0x34: conv= rgb16to15; break; 1443 case 0x34: conv= rgb16to15; break;
1444 case 0x36: conv= rgb24to15; break; 1444 case 0x36: conv= rgb24to15; break;
1445 case 0x38: conv= rgb32to15; break; 1445 case 0x38: conv= rgb32to15; break;
1446 case 0x43: conv= rgb15to16; break; 1446 case 0x43: conv= rgb15to16; break;
1451 case 0x68: conv= rgb32to24; break; 1451 case 0x68: conv= rgb32to24; break;
1452 case 0x83: conv= rgb15to32; break; 1452 case 0x83: conv= rgb15to32; break;
1453 case 0x84: conv= rgb16to32; break; 1453 case 0x84: conv= rgb16to32; break;
1454 case 0x86: conv= rgb24to32; break; 1454 case 0x86: conv= rgb24to32; break;
1455 } 1455 }
1456 } else if ( (isBGR(srcFormat) && isRGB(dstFormat)) 1456 } else if ( (isBGRinInt(srcFormat) && isRGBinInt(dstFormat))
1457 || (isRGB(srcFormat) && isBGR(dstFormat))) { 1457 || (isRGBinInt(srcFormat) && isBGRinInt(dstFormat))) {
1458 switch(srcId | (dstId<<4)) { 1458 switch(srcId | (dstId<<4)) {
1459 case 0x33: conv= rgb15tobgr15; break; 1459 case 0x33: conv= rgb15tobgr15; break;
1460 case 0x34: conv= rgb16tobgr15; break; 1460 case 0x34: conv= rgb16tobgr15; break;
1461 case 0x36: conv= rgb24tobgr15; break; 1461 case 0x36: conv= rgb24tobgr15; break;
1462 case 0x38: conv= rgb32tobgr15; break; 1462 case 0x38: conv= rgb32tobgr15; break;
1658 const enum PixelFormat dstFormat = c->dstFormat; 1658 const enum PixelFormat dstFormat = c->dstFormat;
1659 const int flags = c->flags; 1659 const int flags = c->flags;
1660 const int dstH = c->dstH; 1660 const int dstH = c->dstH;
1661 int needsDither; 1661 int needsDither;
1662 1662
1663 needsDither= (isBGR(dstFormat) || isRGB(dstFormat)) 1663 needsDither= (isBGRinInt(dstFormat) || isRGBinInt(dstFormat))
1664 && c->dstFormatBpp < 24 1664 && c->dstFormatBpp < 24
1665 && (c->dstFormatBpp < c->srcFormatBpp || (!(isRGB(srcFormat) || isBGR(srcFormat)))); 1665 && (c->dstFormatBpp < c->srcFormatBpp || (!(isRGBinInt(srcFormat) || isBGRinInt(srcFormat))));
1666 1666
1667 /* yv12_to_nv12 */ 1667 /* yv12_to_nv12 */
1668 if ((srcFormat == PIX_FMT_YUV420P || srcFormat == PIX_FMT_YUVA420P) && (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21)) { 1668 if ((srcFormat == PIX_FMT_YUV420P || srcFormat == PIX_FMT_YUVA420P) && (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21)) {
1669 c->swScale= PlanarToNV12Wrapper; 1669 c->swScale= PlanarToNV12Wrapper;
1670 } 1670 }
1671 /* yuv2bgr */ 1671 /* yuv2bgr */
1672 if ((srcFormat==PIX_FMT_YUV420P || srcFormat==PIX_FMT_YUV422P || srcFormat==PIX_FMT_YUVA420P) && (isBGR(dstFormat) || isRGB(dstFormat)) 1672 if ((srcFormat==PIX_FMT_YUV420P || srcFormat==PIX_FMT_YUV422P || srcFormat==PIX_FMT_YUVA420P) && (isBGRinInt(dstFormat) || isRGBinInt(dstFormat))
1673 && !(flags & SWS_ACCURATE_RND) && !(dstH&1)) { 1673 && !(flags & SWS_ACCURATE_RND) && !(dstH&1)) {
1674 c->swScale= ff_yuv2rgb_get_func_ptr(c); 1674 c->swScale= ff_yuv2rgb_get_func_ptr(c);
1675 } 1675 }
1676 1676
1677 if (srcFormat==PIX_FMT_YUV410P && (dstFormat==PIX_FMT_YUV420P || dstFormat==PIX_FMT_YUVA420P) && !(flags & SWS_BITEXACT)) { 1677 if (srcFormat==PIX_FMT_YUV410P && (dstFormat==PIX_FMT_YUV420P || dstFormat==PIX_FMT_YUVA420P) && !(flags & SWS_BITEXACT)) {
1681 /* bgr24toYV12 */ 1681 /* bgr24toYV12 */
1682 if (srcFormat==PIX_FMT_BGR24 && (dstFormat==PIX_FMT_YUV420P || dstFormat==PIX_FMT_YUVA420P) && !(flags & SWS_ACCURATE_RND)) 1682 if (srcFormat==PIX_FMT_BGR24 && (dstFormat==PIX_FMT_YUV420P || dstFormat==PIX_FMT_YUVA420P) && !(flags & SWS_ACCURATE_RND))
1683 c->swScale= bgr24toyv12Wrapper; 1683 c->swScale= bgr24toyv12Wrapper;
1684 1684
1685 /* RGB/BGR -> RGB/BGR (no dither needed forms) */ 1685 /* RGB/BGR -> RGB/BGR (no dither needed forms) */
1686 if ( (isBGR(srcFormat) || isRGB(srcFormat)) 1686 if ( (isBGRinInt(srcFormat) || isRGBinInt(srcFormat))
1687 && (isBGR(dstFormat) || isRGB(dstFormat)) 1687 && (isBGRinInt(dstFormat) || isRGBinInt(dstFormat))
1688 && srcFormat != PIX_FMT_BGR8 && dstFormat != PIX_FMT_BGR8 1688 && srcFormat != PIX_FMT_BGR8 && dstFormat != PIX_FMT_BGR8
1689 && srcFormat != PIX_FMT_RGB8 && dstFormat != PIX_FMT_RGB8 1689 && srcFormat != PIX_FMT_RGB8 && dstFormat != PIX_FMT_RGB8
1690 && srcFormat != PIX_FMT_BGR4 && dstFormat != PIX_FMT_BGR4 1690 && srcFormat != PIX_FMT_BGR4 && dstFormat != PIX_FMT_BGR4
1691 && srcFormat != PIX_FMT_RGB4 && dstFormat != PIX_FMT_RGB4 1691 && srcFormat != PIX_FMT_RGB4 && dstFormat != PIX_FMT_RGB4
1692 && srcFormat != PIX_FMT_BGR4_BYTE && dstFormat != PIX_FMT_BGR4_BYTE 1692 && srcFormat != PIX_FMT_BGR4_BYTE && dstFormat != PIX_FMT_BGR4_BYTE