[FFmpeg-devel] [PATCH] Fix NV12/NV21 planarCopy()

Michael Niedermayer michaelni
Sun Feb 21 21:27:57 CET 2010


On Sun, Feb 21, 2010 at 10:40:07AM +0100, Gwenole Beauchesne wrote:
> Hi,
>
> NV12/NV21 has only two planes, but this causes several problems in 
> planarCopy():
> - If the user doesn't set src[2-3] and dst[2-3] components to NULL, the 
> application will crash
> - We are copying the Y plane only because the GRAY8 test was incomplete
> - We are copying half of the UV plane since length is assumed to match YV12 
> semantics in the copy loop
>
> The attached patch fixed the last two problems and makes it possible to do 
> NV12->NV12 copies.
>
> Regards,
> Gwenole.
>

>  swscale.c          |    8 ++++++--
>  swscale_internal.h |    4 ++++
>  2 files changed, 10 insertions(+), 2 deletions(-)
> 8328188d2d3bb291984af049d1dcf4cd8ce5052d  swscale.nv12.planarCopy.patch
> Index: swscale.c
> ===================================================================
> --- swscale.c	(r?vision 30677)
> +++ swscale.c	(copie de travail)
> @@ -1613,8 +1613,8 @@
>  
>          if (!dst[plane]) continue;
>          // ignore palette for GRAY8
> -        if (plane == 1 && !dst[2]) continue;
> -        if (!src[plane] || (plane == 1 && !src[2])) {
> +        if (c->dstFormat == PIX_FMT_GRAY8 && plane == 1 && !dst[2]) continue;
> +        if (!src[plane] || (c->srcFormat == PIX_FMT_GRAY8 && plane == 1 && !src[2])) {

a check based on isInterleavedUV() or usePal() seems better to me

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100221/e14a14b9/attachment.pgp>



More information about the ffmpeg-devel mailing list