diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2009-06-02 12:28:49 +0000 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2009-06-02 12:28:49 +0000 |
commit | e8417235d0e0a70d8a932edb68ab90f360aefc1a (patch) | |
tree | 2cf020909b1a72fbd6183df3c14a52623d1da9fc | |
parent | b2984add8077ecc9d3cdf0d9294fb323f2001511 (diff) | |
download | ffmpeg-e8417235d0e0a70d8a932edb68ab90f360aefc1a.tar.gz |
Partial (low bits ignored, no direct transcoding into other RGB formats) support
for inputting RGB48BE/LE.
Originally committed as revision 29341 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale
-rw-r--r-- | libswscale/swscale.c | 44 | ||||
-rw-r--r-- | libswscale/swscale_internal.h | 4 | ||||
-rw-r--r-- | libswscale/swscale_template.c | 14 |
3 files changed, 61 insertions, 1 deletions
diff --git a/libswscale/swscale.c b/libswscale/swscale.c index b9adc83e55..921eb2db3a 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -108,6 +108,8 @@ unsigned swscale_version(void) || (x)==PIX_FMT_YUVA420P \ || (x)==PIX_FMT_YUYV422 \ || (x)==PIX_FMT_UYVY422 \ + || (x)==PIX_FMT_RGB48BE \ + || (x)==PIX_FMT_RGB48LE \ || (x)==PIX_FMT_RGB32 \ || (x)==PIX_FMT_RGB32_1 \ || (x)==PIX_FMT_BGR24 \ @@ -1122,6 +1124,48 @@ static void fillPlane(uint8_t* plane, int stride, int width, int height, int y, } } +static inline void rgb48ToY(uint8_t *dst, const uint8_t *src, int width) +{ + int i; + for (i = 0; i < width; i++) { + int r = src[i*6+0]; + int g = src[i*6+2]; + int b = src[i*6+4]; + + dst[i] = (RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; + } +} + +static inline void rgb48ToUV(uint8_t *dstU, uint8_t *dstV, + uint8_t *src1, uint8_t *src2, int width) +{ + int i; + assert(src1==src2); + for (i = 0; i < width; i++) { + int r = src1[6*i + 0]; + int g = src1[6*i + 2]; + int b = src1[6*i + 4]; + + dstU[i] = (RU*r + GU*g + BU*b + (257<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; + dstV[i] = (RV*r + GV*g + BV*b + (257<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; + } +} + +static inline void rgb48ToUV_half(uint8_t *dstU, uint8_t *dstV, + uint8_t *src1, uint8_t *src2, int width) +{ + int i; + assert(src1==src2); + for (i = 0; i < width; i++) { + int r= src1[12*i + 0] + src1[12*i + 6]; + int g= src1[12*i + 2] + src1[12*i + 8]; + int b= src1[12*i + 4] + src1[12*i + 10]; + + dstU[i]= (RU*r + GU*g + BU*b + (257<<RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT+1); + dstV[i]= (RV*r + GV*g + BV*b + (257<<RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT+1); + } +} + #define BGR2Y(type, name, shr, shg, shb, maskr, maskg, maskb, RY, GY, BY, S)\ static inline void name(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused)\ {\ diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index 18a79cac54..8f47fc00c7 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -344,7 +344,9 @@ const char *sws_format_name(int format); || (x)==PIX_FMT_GRAY16LE \ ) #define isRGB(x) ( \ - (x)==PIX_FMT_RGB32 \ + (x)==PIX_FMT_RGB48BE \ + || (x)==PIX_FMT_RGB48LE \ + || (x)==PIX_FMT_RGB32 \ || (x)==PIX_FMT_RGB32_1 \ || (x)==PIX_FMT_RGB24 \ || (x)==PIX_FMT_RGB565 \ diff --git a/libswscale/swscale_template.c b/libswscale/swscale_template.c index 1bb0e1dbb6..05d10590b0 100644 --- a/libswscale/swscale_template.c +++ b/libswscale/swscale_template.c @@ -2235,6 +2235,9 @@ static inline void RENAME(hyscale)(SwsContext *c, uint16_t *dst, long dstWidth, src += ALT32_CORR; } + if (srcFormat == PIX_FMT_RGB48LE) + src++; + if (internal_func) { internal_func(formatConvBuffer, src, srcW, pal); src= formatConvBuffer; @@ -2424,6 +2427,11 @@ inline static void RENAME(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth, src2 += ALT32_CORR; } + if (srcFormat==PIX_FMT_RGB48LE) { + src1++; + src2++; + } + if (c->hcscale_internal) { c->hcscale_internal(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal); src1= formatConvBuffer; @@ -3047,6 +3055,8 @@ static void RENAME(sws_init_swScale)(SwsContext *c) } if (c->chrSrcHSubSample) { switch(srcFormat) { + case PIX_FMT_RGB48BE: + case PIX_FMT_RGB48LE: c->hcscale_internal = rgb48ToUV_half; break; case PIX_FMT_RGB32 : case PIX_FMT_RGB32_1: c->hcscale_internal = bgr32ToUV_half; break; case PIX_FMT_BGR24 : c->hcscale_internal = RENAME(bgr24ToUV_half); break; @@ -3060,6 +3070,8 @@ static void RENAME(sws_init_swScale)(SwsContext *c) } } else { switch(srcFormat) { + case PIX_FMT_RGB48BE: + case PIX_FMT_RGB48LE: c->hcscale_internal = rgb48ToUV; break; case PIX_FMT_RGB32 : case PIX_FMT_RGB32_1: c->hcscale_internal = bgr32ToUV; break; case PIX_FMT_BGR24 : c->hcscale_internal = RENAME(bgr24ToUV); break; @@ -3103,6 +3115,8 @@ static void RENAME(sws_init_swScale)(SwsContext *c) case PIX_FMT_RGB32_1: c->hyscale_internal = bgr32ToY; break; case PIX_FMT_BGR32 : case PIX_FMT_BGR32_1: c->hyscale_internal = rgb32ToY; break; + case PIX_FMT_RGB48BE: + case PIX_FMT_RGB48LE: c->hyscale_internal = rgb48ToY; break; } if (c->alpPixBuf) { switch (srcFormat) { |