[FFmpeg-cvslog] r30419 - in trunk/libswscale: swscale.c swscale_internal.h utils.c yuv2rgb.c
stefano
subversion
Sun Jan 24 13:55:05 CET 2010
Author: stefano
Date: Sun Jan 24 13:55:05 2010
New Revision: 30419
Log:
Use av_get_bits_per_pixel() for computing the bits per pixel of the
source and destination format, cache those values in the newly added
SwsContext:srcFormatBpp and SwsContext:dstFormatBpp fields, and remove
the fmt_depth() function.
Modified:
trunk/libswscale/swscale.c
trunk/libswscale/swscale_internal.h
trunk/libswscale/utils.c
trunk/libswscale/yuv2rgb.c
Modified: trunk/libswscale/swscale.c
==============================================================================
--- trunk/libswscale/swscale.c Sun Jan 24 11:13:33 2010 (r30418)
+++ trunk/libswscale/swscale.c Sun Jan 24 13:55:05 2010 (r30419)
@@ -882,7 +882,7 @@ static inline void yuv2rgbXinC_full(SwsC
const int16_t **alpSrc, uint8_t *dest, int dstW, int y)
{
int i;
- int step= fmt_depth(c->dstFormat)/8;
+ int step= c->dstFormatBpp/8;
int aidx= 3;
switch(c->dstFormat) {
@@ -1430,10 +1430,10 @@ static int rgb2rgbWrapper(SwsContext *c,
{
const enum PixelFormat srcFormat= c->srcFormat;
const enum PixelFormat dstFormat= c->dstFormat;
- const int srcBpp= (fmt_depth(srcFormat) + 7) >> 3;
- const int dstBpp= (fmt_depth(dstFormat) + 7) >> 3;
- const int srcId= fmt_depth(srcFormat) >> 2; /* 1:0, 4:1, 8:2, 15:3, 16:4, 24:6, 32:8 */
- const int dstId= fmt_depth(dstFormat) >> 2;
+ const int srcBpp= (c->srcFormatBpp + 7) >> 3;
+ const int dstBpp= (c->dstFormatBpp + 7) >> 3;
+ const int srcId= c->srcFormatBpp >> 2; /* 1:0, 4:1, 8:2, 15:3, 16:4, 24:6, 32:8 */
+ const int dstId= c->dstFormatBpp >> 2;
void (*conv)(const uint8_t *src, uint8_t *dst, long src_size)=NULL;
/* BGR -> BGR */
@@ -1661,8 +1661,8 @@ void ff_get_unscaled_swscale(SwsContext
int needsDither;
needsDither= (isBGR(dstFormat) || isRGB(dstFormat))
- && (fmt_depth(dstFormat))<24
- && ((fmt_depth(dstFormat))<(fmt_depth(srcFormat)) || (!(isRGB(srcFormat) || isBGR(srcFormat))));
+ && c->srcFormatBpp < 24
+ && (c->dstFormatBpp < c->srcFormatBpp || (!(isRGB(srcFormat) || isBGR(srcFormat))));
/* yv12_to_nv12 */
if ((srcFormat == PIX_FMT_YUV420P || srcFormat == PIX_FMT_YUVA420P) && (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21)) {
Modified: trunk/libswscale/swscale_internal.h
==============================================================================
--- trunk/libswscale/swscale_internal.h Sun Jan 24 11:13:33 2010 (r30418)
+++ trunk/libswscale/swscale_internal.h Sun Jan 24 13:55:05 2010 (r30419)
@@ -86,6 +86,8 @@ typedef struct SwsContext {
int lumYInc, chrYInc;
enum PixelFormat dstFormat; ///< Destination pixel format.
enum PixelFormat srcFormat; ///< Source pixel format.
+ int dstFormatBpp; ///< Number of bits per pixel of the destination pixel format.
+ int srcFormatBpp; ///< Number of bits per pixel of the source pixel format.
int chrSrcHSubSample; ///< Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in source image.
int chrSrcVSubSample; ///< Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in source image.
int chrDstHSubSample; ///< Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in destination image.
@@ -417,44 +419,6 @@ const char *sws_format_name(enum PixelFo
|| (x)==PIX_FMT_YUVA420P \
)
-static inline int fmt_depth(enum PixelFormat fmt)
-{
- switch(fmt) {
- case PIX_FMT_RGB48BE:
- case PIX_FMT_RGB48LE:
- return 48;
- case PIX_FMT_BGRA:
- case PIX_FMT_ABGR:
- case PIX_FMT_RGBA:
- case PIX_FMT_ARGB:
- return 32;
- case PIX_FMT_BGR24:
- case PIX_FMT_RGB24:
- return 24;
- case PIX_FMT_BGR565:
- case PIX_FMT_RGB565:
- case PIX_FMT_GRAY16BE:
- case PIX_FMT_GRAY16LE:
- return 16;
- case PIX_FMT_BGR555:
- case PIX_FMT_RGB555:
- return 15;
- case PIX_FMT_BGR8:
- case PIX_FMT_RGB8:
- return 8;
- case PIX_FMT_BGR4:
- case PIX_FMT_RGB4:
- case PIX_FMT_BGR4_BYTE:
- case PIX_FMT_RGB4_BYTE:
- return 4;
- case PIX_FMT_MONOBLACK:
- case PIX_FMT_MONOWHITE:
- return 1;
- default:
- return 0;
- }
-}
-
extern const uint64_t ff_dither4[2];
extern const uint64_t ff_dither8[2];
Modified: trunk/libswscale/utils.c
==============================================================================
--- trunk/libswscale/utils.c Sun Jan 24 11:13:33 2010 (r30418)
+++ trunk/libswscale/utils.c Sun Jan 24 13:55:05 2010 (r30419)
@@ -854,6 +854,8 @@ SwsContext *sws_getContext(int srcW, int
c->flags= flags;
c->dstFormat= dstFormat;
c->srcFormat= srcFormat;
+ c->dstFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[dstFormat]);
+ c->srcFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[srcFormat]);
c->vRounder= 4* 0x0001000100010001ULL;
usesHFilter= usesVFilter= 0;
Modified: trunk/libswscale/yuv2rgb.c
==============================================================================
--- trunk/libswscale/yuv2rgb.c Sun Jan 24 11:13:33 2010 (r30418)
+++ trunk/libswscale/yuv2rgb.c Sun Jan 24 13:55:05 2010 (r30419)
@@ -595,7 +595,7 @@ av_cold int ff_yuv2rgb_c_init_tables(Sws
|| c->dstFormat==PIX_FMT_RGB4
|| c->dstFormat==PIX_FMT_RGB4_BYTE
|| c->dstFormat==PIX_FMT_MONOBLACK;
- const int bpp = fmt_depth(c->dstFormat);
+ const int bpp = c->dstFormatBpp;
uint8_t *y_table;
uint16_t *y_table16;
uint32_t *y_table32;
More information about the ffmpeg-cvslog
mailing list