aboutsummaryrefslogtreecommitdiffstats
path: root/libswscale/swscale_unscaled.c
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2012-10-29 19:07:01 +0100
committerLuca Barbato <lu_zero@gentoo.org>2012-10-30 12:02:41 +0100
commit26b5ad2543305f0b148e5b91e9773b6a9a185922 (patch)
treec045719e016118a600ee6c0b6fa77d6b2e608b92 /libswscale/swscale_unscaled.c
parentf454e879238ce317c6d905d187e7608c461a7087 (diff)
downloadffmpeg-26b5ad2543305f0b148e5b91e9773b6a9a185922.tar.gz
swscale: support gray to 9bit and 10bit formats
With the input of Kostya and Ronald.
Diffstat (limited to 'libswscale/swscale_unscaled.c')
-rw-r--r--libswscale/swscale_unscaled.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c
index 5efc647b08..9b919f8aa4 100644
--- a/libswscale/swscale_unscaled.c
+++ b/libswscale/swscale_unscaled.c
@@ -98,6 +98,27 @@ static void fillPlane(uint8_t *plane, int stride, int width, int height, int y,
}
}
+static void fill_plane9or10(uint8_t *plane, int stride, int width,
+ int height, int y, uint8_t val,
+ const int dst_depth, const int big_endian)
+{
+ int i, j;
+ uint16_t *dst = (uint16_t *) (plane + stride * y);
+#define FILL8TO9_OR_10(wfunc) \
+ for (i = 0; i < height; i++) { \
+ for (j = 0; j < width; j++) { \
+ wfunc(&dst[j], (val << (dst_depth - 8)) | \
+ (val >> (16 - dst_depth))); \
+ } \
+ dst += stride / 2; \
+ }
+ if (big_endian) {
+ FILL8TO9_OR_10(AV_WB16);
+ } else {
+ FILL8TO9_OR_10(AV_WL16);
+ }
+}
+
static void copyPlane(const uint8_t *src, int srcStride,
int srcSliceY, int srcSliceH, int width,
uint8_t *dst, int dstStride)
@@ -677,10 +698,17 @@ static int planarCopyWrapper(SwsContext *c, const uint8_t *src[],
// ignore palette for GRAY8
if (plane == 1 && !dst[2]) continue;
if (!src[plane] || (plane == 1 && !src[2])) {
+ int val = (plane == 3) ? 255 : 128;
if (is16BPS(c->dstFormat))
length *= 2;
- fillPlane(dst[plane], dstStride[plane], length, height, y,
- (plane == 3) ? 255 : 128);
+ if (is9_OR_10BPS(c->dstFormat)) {
+ fill_plane9or10(dst[plane], dstStride[plane],
+ length, height, y, val,
+ desc_dst->comp[plane].depth_minus1 + 1,
+ isBE(c->dstFormat));
+ } else
+ fillPlane(dst[plane], dstStride[plane], length, height, y,
+ val);
} else {
if (is9_OR_10BPS(c->srcFormat)) {
const int src_depth = desc_src->comp[plane].depth_minus1 + 1;