[PATCH 2/2] Implement bgr4 and rgb4 bitstream input support.
Stefano Sabatini
stefano.sabatini-lala
Fri May 14 00:40:44 CEST 2010
---
swscale.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
swscale_template.c | 4 ++++
utils.c | 2 ++
3 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/swscale.c b/swscale.c
index 2b02dd3..c612d68 100644
--- a/swscale.c
+++ b/swscale.c
@@ -1149,6 +1149,50 @@ static inline void monoblack2Y(uint8_t *dst, const uint8_t *src, long width, uin
}
}
+static const uint8_t rgb4ToYUV_table[3][16] = {
+ { 16, 81, 58, 124, 101, 167, 144, 210, 40, 106, 83, 149, 126, 192, 169, 234 },
+ { 128, 239, 96, 208, 65, 177, 34, 146, 109, 221, 78, 190, 47, 159, 15, 127 },
+ { 128, 90, 103, 65, 78, 40, 53, 15, 239, 202, 215, 177, 190, 152, 165, 127 }
+};
+
+static const uint8_t bgr4ToYUV_table[3][16] = {
+ { 16, 40, 58, 83, 101, 126, 144, 169, 81, 106, 124, 149, 167, 192, 210, 234 },
+ { 128, 109, 96, 78, 65, 47, 34, 15, 239, 221, 208, 190, 177, 159, 146, 127 },
+ { 128, 239, 103, 215, 78, 190, 53, 165, 90, 202, 65, 177, 40, 152, 15, 127 }
+};
+
+#define DEFINE_XGX4_TO_YUV(xgx4) \
+static inline void xgx4##ToY(uint8_t *dst, const uint8_t *src, \
+ long width, uint32_t *unused) \
+{ \
+ int d, i; \
+ \
+ for (i=0; i<width/2; i++) { \
+ d = src[i] >> 4; \
+ dst[2*i] = xgx4##ToYUV_table[0][d]; \
+ d = src[i] & 0x0F; \
+ dst[2*i+1] = xgx4##ToYUV_table[0][d]; \
+ } \
+} \
+static inline void xgx4##ToUV(uint8_t *dstU, uint8_t *dstV, \
+ const uint8_t *src1, const uint8_t *src2, \
+ long width, uint32_t *pal) \
+{ \
+ int d, i; \
+ assert(src1 == src2); \
+ for (i=0; i<width/2; i++) { \
+ d = src1[i] >> 4; \
+ dstU[2*i] = xgx4##ToYUV_table[1][d]; \
+ dstV[2*i] = xgx4##ToYUV_table[2][d]; \
+ d = src1[i] & 0x0F; \
+ dstU[2*i+1] = xgx4##ToYUV_table[1][d]; \
+ dstV[2*i+1] = xgx4##ToYUV_table[2][d]; \
+ } \
+}
+
+DEFINE_XGX4_TO_YUV(rgb4);
+DEFINE_XGX4_TO_YUV(bgr4);
+
//Note: we have C, MMX, MMX2, 3DNOW versions, there is no 3DNOW+MMX2 one
//Plain C versions
#if (!HAVE_MMX && !HAVE_ALTIVEC) || CONFIG_RUNTIME_CPUDETECT
diff --git a/swscale_template.c b/swscale_template.c
index 0d259ed..09c0e02 100644
--- a/swscale_template.c
+++ b/swscale_template.c
@@ -2952,6 +2952,8 @@ static void RENAME(sws_init_swScale)(SwsContext *c)
case PIX_FMT_PAL8 :
case PIX_FMT_BGR4_BYTE:
case PIX_FMT_RGB4_BYTE: c->chrToYV12 = palToUV; break;
+ case PIX_FMT_RGB4 : c->chrToYV12 = rgb4ToUV; break;
+ case PIX_FMT_BGR4 : c->chrToYV12 = bgr4ToUV; break;
case PIX_FMT_YUV420P16BE:
case PIX_FMT_YUV422P16BE:
case PIX_FMT_YUV444P16BE: c->chrToYV12 = RENAME(BEToUV); break;
@@ -3010,6 +3012,8 @@ static void RENAME(sws_init_swScale)(SwsContext *c)
case PIX_FMT_RGB24 : c->lumToYV12 = RENAME(rgb24ToY); break;
case PIX_FMT_RGB565 : c->lumToYV12 = rgb16ToY; break;
case PIX_FMT_RGB555 : c->lumToYV12 = rgb15ToY; break;
+ case PIX_FMT_RGB4 : c->lumToYV12 = rgb4ToY; break;
+ case PIX_FMT_BGR4 : c->lumToYV12 = bgr4ToY; break;
case PIX_FMT_RGB8 :
case PIX_FMT_BGR8 :
case PIX_FMT_PAL8 :
diff --git a/utils.c b/utils.c
index d7a6ea2..32f3cf2 100644
--- a/utils.c
+++ b/utils.c
@@ -96,6 +96,8 @@ const char *swscale_license(void)
|| (x)==PIX_FMT_PAL8 \
|| (x)==PIX_FMT_BGR8 \
|| (x)==PIX_FMT_RGB8 \
+ || (x)==PIX_FMT_BGR4 \
+ || (x)==PIX_FMT_RGB4 \
|| (x)==PIX_FMT_BGR4_BYTE \
|| (x)==PIX_FMT_RGB4_BYTE \
|| (x)==PIX_FMT_YUV440P \
--
1.7.0
--NzB8fVQJ5HfG6fxh--
More information about the ffmpeg-devel
mailing list