diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-11-19 14:17:26 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2014-01-21 17:55:07 +0100 |
commit | 9047491f8bcd87673eed55fb310647a03b0981e9 (patch) | |
tree | af4ace89201f109c49f6110b05de1df2c7747c33 /libswscale/swscale_unscaled.c | |
parent | eb01a25fe1452740a7f3ae2cbaff356a5c6e7806 (diff) | |
download | ffmpeg-9047491f8bcd87673eed55fb310647a03b0981e9.tar.gz |
swscale: add nv12/nv21->yuv420 converter
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libswscale/swscale_unscaled.c')
-rw-r--r-- | libswscale/swscale_unscaled.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c index 8c207b1476..61f0d4705d 100644 --- a/libswscale/swscale_unscaled.c +++ b/libswscale/swscale_unscaled.c @@ -155,6 +155,27 @@ static int planarToNv12Wrapper(SwsContext *c, const uint8_t *src[], return srcSliceH; } +static int nv12ToPlanarWrapper(SwsContext *c, const uint8_t *src[], + int srcStride[], int srcSliceY, + int srcSliceH, uint8_t *dstParam[], + int dstStride[]) +{ + uint8_t *dst1 = dstParam[1] + dstStride[1] * srcSliceY / 2; + uint8_t *dst2 = dstParam[2] + dstStride[2] * srcSliceY / 2; + + copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->srcW, + dstParam[0], dstStride[0]); + + if (c->srcFormat == AV_PIX_FMT_NV12) + deinterleaveBytes(src[1], dst1, dst2,c->srcW / 2, srcSliceH / 2, + srcStride[1], dstStride[1], dstStride[2]); + else + deinterleaveBytes(src[1], dst2, dst1, c->srcW / 2, srcSliceH / 2, + srcStride[1], dstStride[2], dstStride[1]); + + return srcSliceH; +} + static int planarToYuy2Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[]) @@ -981,6 +1002,11 @@ void ff_get_unscaled_swscale(SwsContext *c) (dstFormat == AV_PIX_FMT_NV12 || dstFormat == AV_PIX_FMT_NV21)) { c->swscale = planarToNv12Wrapper; } + /* nv12_to_yv12 */ + if (dstFormat == AV_PIX_FMT_YUV420P && + (srcFormat == AV_PIX_FMT_NV12 || srcFormat == AV_PIX_FMT_NV21)) { + c->swscale = nv12ToPlanarWrapper; + } /* yuv2bgr */ if ((srcFormat == AV_PIX_FMT_YUV420P || srcFormat == AV_PIX_FMT_YUV422P || srcFormat == AV_PIX_FMT_YUVA420P) && isAnyRGB(dstFormat) && |