diff options
author | Janne Grunau <janne-libav@jannau.net> | 2011-12-16 00:44:26 +0100 |
---|---|---|
committer | Janne Grunau <janne-libav@jannau.net> | 2011-12-16 01:41:33 +0100 |
commit | 72cb904453ccb8c42f93a4a02ce9ba9915688722 (patch) | |
tree | 4955fef4ac9fdc6e452edc3354970b67c8ce6c07 | |
parent | d3b8bde2f14f78109a892e57f544bf840cf6d4fc (diff) | |
download | ffmpeg-72cb904453ccb8c42f93a4a02ce9ba9915688722.tar.gz |
swscale: add unscaled packed 16 bit per component endianess conversion
-rw-r--r-- | libswscale/swscale_unscaled.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c index 86bc5acda6..ec8f1bb552 100644 --- a/libswscale/swscale_unscaled.c +++ b/libswscale/swscale_unscaled.c @@ -252,6 +252,27 @@ static void gray8aToPacked24(const uint8_t *src, uint8_t *dst, int num_pixels, c } } +static int packed_16bpc_bswap(SwsContext *c, const uint8_t* src[], + int srcStride[], int srcSliceY, int srcSliceH, + uint8_t* dst[], int dstStride[]) +{ + int i, j; + int srcstr = srcStride[0] >> 1; + int dststr = dstStride[0] >> 1; + uint16_t *dstPtr = (uint16_t *)dst[0]; + const uint16_t *srcPtr = (const uint16_t *)src[0]; + + for (i = 0; i < srcSliceH; i++) { + for (j = 0; j < srcstr; j++) { + dstPtr[j] = av_bswap16(srcPtr[j]); + } + srcPtr += srcstr; + dstPtr += dststr; + } + + return srcSliceH; +} + static int palToRgbWrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]) { @@ -697,6 +718,15 @@ void ff_get_unscaled_swscale(SwsContext *c) if (srcFormat==PIX_FMT_BGR24 && (dstFormat==PIX_FMT_YUV420P || dstFormat==PIX_FMT_YUVA420P) && !(flags & SWS_ACCURATE_RND)) c->swScale= bgr24ToYv12Wrapper; + /* bswap 16 bits per component packed formats */ + if ((srcFormat == PIX_FMT_RGB48LE && dstFormat == PIX_FMT_RGB48BE) || + (srcFormat == PIX_FMT_RGB48BE && dstFormat == PIX_FMT_RGB48LE) || + (srcFormat == PIX_FMT_BGR48LE && dstFormat == PIX_FMT_BGR48BE) || + (srcFormat == PIX_FMT_BGR48BE && dstFormat == PIX_FMT_BGR48LE) || + (srcFormat == PIX_FMT_GRAY16LE && dstFormat == PIX_FMT_GRAY16BE) || + (srcFormat == PIX_FMT_GRAY16BE && dstFormat == PIX_FMT_GRAY16LE)) + c->swScale = packed_16bpc_bswap; + /* RGB/BGR -> RGB/BGR (no dither needed forms) */ if ( isAnyRGB(srcFormat) && isAnyRGB(dstFormat) |