comparison libswscale/swscale.c @ 30393:db62840d27ae

Use isAnyRGB() where possible
author michael
date Tue, 26 Jan 2010 08:03:28 +0000
parents 2a33c1c37e6b
children ef221b7526c5
comparison
equal deleted inserted replaced
30392:8d89e0052f84 30393:db62840d27ae
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 || isRGBinInt(x) \ 93 || isAnyRGB(x) \
94 || isBGRinInt(x) \
95 ) 94 )
96 #define usePal(x) (av_pix_fmt_descriptors[x].flags & PIX_FMT_PAL) 95 #define usePal(x) (av_pix_fmt_descriptors[x].flags & PIX_FMT_PAL)
97 96
98 #define RGB2YUV_SHIFT 15 97 #define RGB2YUV_SHIFT 15
99 #define BY ( (int)(0.114*219/255*(1<<RGB2YUV_SHIFT)+0.5)) 98 #define BY ( (int)(0.114*219/255*(1<<RGB2YUV_SHIFT)+0.5))
1658 const enum PixelFormat dstFormat = c->dstFormat; 1657 const enum PixelFormat dstFormat = c->dstFormat;
1659 const int flags = c->flags; 1658 const int flags = c->flags;
1660 const int dstH = c->dstH; 1659 const int dstH = c->dstH;
1661 int needsDither; 1660 int needsDither;
1662 1661
1663 needsDither= (isBGRinInt(dstFormat) || isRGBinInt(dstFormat)) 1662 needsDither= isAnyRGB(dstFormat)
1664 && c->dstFormatBpp < 24 1663 && c->dstFormatBpp < 24
1665 && (c->dstFormatBpp < c->srcFormatBpp || (!(isRGBinInt(srcFormat) || isBGRinInt(srcFormat)))); 1664 && (c->dstFormatBpp < c->srcFormatBpp || (!isAnyRGB(srcFormat)));
1666 1665
1667 /* yv12_to_nv12 */ 1666 /* yv12_to_nv12 */
1668 if ((srcFormat == PIX_FMT_YUV420P || srcFormat == PIX_FMT_YUVA420P) && (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21)) { 1667 if ((srcFormat == PIX_FMT_YUV420P || srcFormat == PIX_FMT_YUVA420P) && (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21)) {
1669 c->swScale= PlanarToNV12Wrapper; 1668 c->swScale= PlanarToNV12Wrapper;
1670 } 1669 }
1671 /* yuv2bgr */ 1670 /* yuv2bgr */
1672 if ((srcFormat==PIX_FMT_YUV420P || srcFormat==PIX_FMT_YUV422P || srcFormat==PIX_FMT_YUVA420P) && (isBGRinInt(dstFormat) || isRGBinInt(dstFormat)) 1671 if ((srcFormat==PIX_FMT_YUV420P || srcFormat==PIX_FMT_YUV422P || srcFormat==PIX_FMT_YUVA420P) && isAnyRGB(dstFormat)
1673 && !(flags & SWS_ACCURATE_RND) && !(dstH&1)) { 1672 && !(flags & SWS_ACCURATE_RND) && !(dstH&1)) {
1674 c->swScale= ff_yuv2rgb_get_func_ptr(c); 1673 c->swScale= ff_yuv2rgb_get_func_ptr(c);
1675 } 1674 }
1676 1675
1677 if (srcFormat==PIX_FMT_YUV410P && (dstFormat==PIX_FMT_YUV420P || dstFormat==PIX_FMT_YUVA420P) && !(flags & SWS_BITEXACT)) { 1676 if (srcFormat==PIX_FMT_YUV410P && (dstFormat==PIX_FMT_YUV420P || dstFormat==PIX_FMT_YUVA420P) && !(flags & SWS_BITEXACT)) {
1681 /* bgr24toYV12 */ 1680 /* bgr24toYV12 */
1682 if (srcFormat==PIX_FMT_BGR24 && (dstFormat==PIX_FMT_YUV420P || dstFormat==PIX_FMT_YUVA420P) && !(flags & SWS_ACCURATE_RND)) 1681 if (srcFormat==PIX_FMT_BGR24 && (dstFormat==PIX_FMT_YUV420P || dstFormat==PIX_FMT_YUVA420P) && !(flags & SWS_ACCURATE_RND))
1683 c->swScale= bgr24toyv12Wrapper; 1682 c->swScale= bgr24toyv12Wrapper;
1684 1683
1685 /* RGB/BGR -> RGB/BGR (no dither needed forms) */ 1684 /* RGB/BGR -> RGB/BGR (no dither needed forms) */
1686 if ( (isBGRinInt(srcFormat) || isRGBinInt(srcFormat)) 1685 if ( isAnyRGB(srcFormat)
1687 && (isBGRinInt(dstFormat) || isRGBinInt(dstFormat)) 1686 && isAnyRGB(dstFormat)
1688 && srcFormat != PIX_FMT_BGR8 && dstFormat != PIX_FMT_BGR8 1687 && srcFormat != PIX_FMT_BGR8 && dstFormat != PIX_FMT_BGR8
1689 && srcFormat != PIX_FMT_RGB8 && dstFormat != PIX_FMT_RGB8 1688 && srcFormat != PIX_FMT_RGB8 && dstFormat != PIX_FMT_RGB8
1690 && srcFormat != PIX_FMT_BGR4 && dstFormat != PIX_FMT_BGR4 1689 && srcFormat != PIX_FMT_BGR4 && dstFormat != PIX_FMT_BGR4
1691 && srcFormat != PIX_FMT_RGB4 && dstFormat != PIX_FMT_RGB4 1690 && srcFormat != PIX_FMT_RGB4 && dstFormat != PIX_FMT_RGB4
1692 && srcFormat != PIX_FMT_BGR4_BYTE && dstFormat != PIX_FMT_BGR4_BYTE 1691 && srcFormat != PIX_FMT_BGR4_BYTE && dstFormat != PIX_FMT_BGR4_BYTE