[vlc-commits] chroma: copy: rename YUV420 copy functions

Thomas Guillem git at videolan.org
Wed Nov 15 13:24:42 CET 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Nov 15 09:36:39 2017 +0100| [a7762313fd64f4ef4921f9e209771e96f02d22e3] | committer: Thomas Guillem

chroma: copy: rename YUV420 copy functions

Use more generic functions name that can work with more than one chroma. For
example, CopyFromYv12ToYv12 is renamed to Copy420_P_to_P (planar to planar).

Add picture_SwapUV(): just swap U, V planes of a tri-planar picture.

Remove CopyFromNv12ToYv12 (replaced by Copy420_SP_to_P() and picture_SwapUV()).

Add const qualifiers to all sources parameters in all functions.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a7762313fd64f4ef4921f9e209771e96f02d22e3
---

 modules/codec/omxil/utils.c          |   9 +--
 modules/hw/vaapi/chroma.c            |  25 +++----
 modules/video_chroma/copy.c          | 127 ++++++++++++++---------------------
 modules/video_chroma/copy.h          |  44 ++++++++----
 modules/video_chroma/d3d11_surface.c |  24 ++++---
 modules/video_chroma/dxa9.c          |  24 +++----
 modules/video_chroma/i420_10_p010.c  |   4 +-
 modules/video_chroma/i420_nv12.c     |  10 +--
 8 files changed, 129 insertions(+), 138 deletions(-)

diff --git a/modules/codec/omxil/utils.c b/modules/codec/omxil/utils.c
index 2b34c5b9ac..bdb8e445ce 100644
--- a/modules/codec/omxil/utils.c
+++ b/modules/codec/omxil/utils.c
@@ -221,10 +221,11 @@ void CopyOmxPicture( int i_color_format, picture_t *p_pic,
         && vlc_CPU_SSE2() && p_architecture_specific && p_architecture_specific->data )
     {
         copy_cache_t *p_surface_cache = (copy_cache_t*)p_architecture_specific->data;
-        uint8_t *ppi_src_pointers[2] = { p_src, p_src + i_src_stride * i_slice_height };
-        size_t pi_src_strides[2] = { i_src_stride, i_src_stride };
-        CopyFromNv12ToYv12( p_pic, ppi_src_pointers, pi_src_strides,
-                            i_slice_height, p_surface_cache );
+        const uint8_t *ppi_src_pointers[2] = { p_src, p_src + i_src_stride * i_slice_height };
+        const size_t pi_src_strides[2] = { i_src_stride, i_src_stride };
+        Copy420_SP_to_P( p_pic, ppi_src_pointers, pi_src_strides,
+                         i_slice_height, p_surface_cache );
+        picture_SwapUV( p_pic );
         return;
     }
 #endif
diff --git a/modules/hw/vaapi/chroma.c b/modules/hw/vaapi/chroma.c
index 66bd7a6930..bec714efb7 100644
--- a/modules/hw/vaapi/chroma.c
+++ b/modules/hw/vaapi/chroma.c
@@ -88,9 +88,9 @@ static inline void
 FillPictureFromVAImage(picture_t *dest,
                        VAImage *src_img, uint8_t *src_buf, copy_cache_t *cache)
 {
-    uint8_t *       src_planes[2] = { src_buf + src_img->offsets[0],
+    const uint8_t * src_planes[2] = { src_buf + src_img->offsets[0],
                                       src_buf + src_img->offsets[1] };
-    size_t          src_pitches[2] = { src_img->pitches[0],
+    const size_t    src_pitches[2] = { src_img->pitches[0],
                                        src_img->pitches[1] };
 
     switch (src_img->format.fourcc)
@@ -98,15 +98,12 @@ FillPictureFromVAImage(picture_t *dest,
     case VA_FOURCC_NV12:
     {
         assert(dest->format.i_chroma == VLC_CODEC_I420);
-        CopyFromNv12ToI420(dest, src_planes, src_pitches,
-                           src_img->height, cache);
+        Copy420_SP_to_P(dest, src_planes, src_pitches, src_img->height, cache);
         break;
     }
     case VA_FOURCC_P010:
         assert(dest->format.i_chroma == VLC_CODEC_P010);
-        /* P010ToP010 is the same than Nv12ToNV12 */
-        CopyFromNv12ToNv12(dest,  src_planes, src_pitches,
-                           src_img->height, cache);
+        Copy420_SP_to_SP(dest, src_planes, src_pitches, src_img->height, cache);
         break;
     default:
         vlc_assert_unreachable();
@@ -191,10 +188,10 @@ FillVAImageFromPicture(VAImage *dest_img, uint8_t *dest_buf,
     case VLC_CODEC_I420:
     {
         assert(dest_pic->format.i_chroma == VLC_CODEC_VAAPI_420);
-        uint8_t *       src_planes[3] = { src->p[Y_PLANE].p_pixels,
+        const uint8_t * src_planes[3] = { src->p[Y_PLANE].p_pixels,
                                           src->p[U_PLANE].p_pixels,
                                           src->p[V_PLANE].p_pixels };
-        size_t          src_pitches[3] = { src->p[Y_PLANE].i_pitch,
+        const size_t    src_pitches[3] = { src->p[Y_PLANE].i_pitch,
                                            src->p[U_PLANE].i_pitch,
                                            src->p[V_PLANE].i_pitch };
         void *const     tmp[2] = { dest_pic->p[0].p_pixels,
@@ -205,7 +202,7 @@ FillVAImageFromPicture(VAImage *dest_img, uint8_t *dest_buf,
         dest_pic->p[0].i_pitch = dest_img->pitches[0];
         dest_pic->p[1].i_pitch = dest_img->pitches[1];
 
-        CopyFromI420ToNv12(dest_pic, src_planes, src_pitches,
+        Copy420_P_to_SP(dest_pic, src_planes, src_pitches,
                            src->format.i_height, cache);
 
         dest_pic->p[0].p_pixels = tmp[0];
@@ -216,12 +213,12 @@ FillVAImageFromPicture(VAImage *dest_img, uint8_t *dest_buf,
     case VLC_CODEC_P010:
     {
         assert(dest_pic->format.i_chroma == VLC_CODEC_VAAPI_420_10BPP);
-        uint8_t *       src_planes[2] = { src->p[0].p_pixels,
+        const uint8_t * src_planes[2] = { src->p[0].p_pixels,
                                           src->p[1].p_pixels };
-        size_t          src_pitches[2] = { src->p[0].i_pitch,
+        const size_t    src_pitches[2] = { src->p[0].i_pitch,
                                            src->p[1].i_pitch };
-        CopyFromNv12ToNv12(dest_pic,  src_planes, src_pitches,
-                           src->format.i_height, cache);
+        Copy420_SP_to_SP(dest_pic,  src_planes, src_pitches,
+                         src->format.i_height, cache);
         break;
     }
     default:
diff --git a/modules/video_chroma/copy.c b/modules/video_chroma/copy.c
index 6c20c132b0..6c601b17c1 100644
--- a/modules/video_chroma/copy.c
+++ b/modules/video_chroma/copy.c
@@ -399,8 +399,8 @@ static void SSE_CopyPlane(uint8_t *dst, size_t dst_pitch,
 
 static void
 SSE_InterleavePlanes(uint8_t *dst, size_t dst_pitch,
-                     uint8_t *srcu, size_t srcu_pitch,
-                     uint8_t *srcv, size_t srcv_pitch,
+                     const uint8_t *srcu, size_t srcu_pitch,
+                     const uint8_t *srcv, size_t srcv_pitch,
                      uint8_t *cache, size_t cache_size,
                      unsigned int height,
                      unsigned int cpu)
@@ -459,27 +459,9 @@ static void SSE_SplitPlanes(uint8_t *dstu, size_t dstu_pitch,
     }
 }
 
-static void SSE_CopyFromNv12ToYv12(picture_t *dst,
-                                   uint8_t *src[2], size_t src_pitch[2],
-                                   unsigned height,
-                                   copy_cache_t *cache, unsigned cpu)
-{
-    SSE_CopyPlane(dst->p[0].p_pixels, dst->p[0].i_pitch,
-                  src[0], src_pitch[0],
-                  cache->buffer, cache->size,
-                  height, cpu);
-    SSE_SplitPlanes(dst->p[2].p_pixels, dst->p[2].i_pitch,
-                    dst->p[1].p_pixels, dst->p[1].i_pitch,
-                    src[1], src_pitch[1],
-                    cache->buffer, cache->size,
-                    (height+1)/2, cpu);
-    asm volatile ("emms");
-}
-
-static void SSE_CopyFromYv12ToYv12(picture_t *dst,
-                                   uint8_t *src[3], size_t src_pitch[3],
-                                   unsigned height,
-                                   copy_cache_t *cache, unsigned cpu)
+static void SSE_Copy420_P_to_P(picture_t *dst, const uint8_t *src[static 3],
+                               const size_t src_pitch[static 3], unsigned height,
+                               const copy_cache_t *cache, unsigned cpu)
 {
     for (unsigned n = 0; n < 3; n++) {
         const unsigned d = n > 0 ? 2 : 1;
@@ -492,10 +474,9 @@ static void SSE_CopyFromYv12ToYv12(picture_t *dst,
 }
 
 
-static void SSE_CopyFromNv12ToNv12(picture_t *dst,
-                             uint8_t *src[2], size_t src_pitch[2],
-                             unsigned height,
-                             copy_cache_t *cache, unsigned cpu)
+static void SSE_Copy420_SP_to_SP(picture_t *dst, const uint8_t *src[static 2],
+                                 const size_t src_pitch[static 2], unsigned height,
+                                 const copy_cache_t *cache, unsigned cpu)
 {
     SSE_CopyPlane(dst->p[0].p_pixels, dst->p[0].i_pitch,
                   src[0], src_pitch[0],
@@ -509,9 +490,9 @@ static void SSE_CopyFromNv12ToNv12(picture_t *dst,
 }
 
 static void
-SSE_CopyFromNv12ToI420(picture_t *dest, uint8_t *src[2],
-                       size_t src_pitch[2], unsigned int height,
-                       copy_cache_t *cache, unsigned int cpu)
+SSE_Copy420_SP_to_P(picture_t *dest, const uint8_t *src[static 2],
+                    const size_t src_pitch[static 2], unsigned int height,
+                    const copy_cache_t *cache, unsigned int cpu)
 {
     SSE_CopyPlane(dest->p[0].p_pixels, dest->p[0].i_pitch,
                   src[0], src_pitch[0], cache->buffer, cache->size,
@@ -523,10 +504,10 @@ SSE_CopyFromNv12ToI420(picture_t *dest, uint8_t *src[2],
     asm volatile ("emms");
 }
 
-static void SSE_CopyFromI420ToNv12(picture_t *dst,
-                             uint8_t *src[3], size_t src_pitch[3],
-                             unsigned height,
-                             copy_cache_t *cache, unsigned cpu)
+static void SSE_Copy420_P_to_SP(picture_t *dst, const uint8_t *src[static 3],
+                                const size_t src_pitch[static 3],
+                                unsigned height, const copy_cache_t *cache,
+                                unsigned cpu)
 {
     SSE_CopyPlane(dst->p[0].p_pixels, dst->p[0].i_pitch,
                   src[0], src_pitch[0],
@@ -571,32 +552,15 @@ static void SplitPlanes(uint8_t *dstu, size_t dstu_pitch,
     }
 }
 
-void CopyFromNv12ToYv12(picture_t *dst, uint8_t *src[2], size_t src_pitch[2],
-                        unsigned height, copy_cache_t *cache)
-{
-#ifdef CAN_COMPILE_SSE2
-    unsigned cpu = vlc_CPU();
-    if (vlc_CPU_SSE2())
-        return SSE_CopyFromNv12ToYv12(dst, src, src_pitch, height, cache, cpu);
-#else
-    (void) cache;
-#endif
-
-    CopyPlane(dst->p[0].p_pixels, dst->p[0].i_pitch,
-              src[0], src_pitch[0], height);
-    SplitPlanes(dst->p[2].p_pixels, dst->p[2].i_pitch,
-                dst->p[1].p_pixels, dst->p[1].i_pitch,
-                src[1], src_pitch[1], height/2);
-}
-
-void CopyFromNv12ToNv12(picture_t *dst, uint8_t *src[2], size_t src_pitch[2],
-                  unsigned height, copy_cache_t *cache)
+void Copy420_SP_to_SP(picture_t *dst, const uint8_t *src[static 2],
+                      const size_t src_pitch[static 2], unsigned height,
+                      const copy_cache_t *cache)
 {
 #ifdef CAN_COMPILE_SSE2
     unsigned cpu = vlc_CPU();
     if (vlc_CPU_SSE2())
-        return SSE_CopyFromNv12ToNv12(dst, src, src_pitch, height,
-                                cache, cpu);
+        return SSE_Copy420_SP_to_SP(dst, src, src_pitch, height,
+                                    cache, cpu);
 #else
     (void) cache;
 #endif
@@ -607,14 +571,15 @@ void CopyFromNv12ToNv12(picture_t *dst, uint8_t *src[2], size_t src_pitch[2],
               src[1], src_pitch[1], height/2);
 }
 
-void CopyFromNv12ToI420(picture_t *dst, uint8_t *src[2], size_t src_pitch[2],
-                        unsigned height, copy_cache_t *cache)
+void Copy420_SP_to_P(picture_t *dst, const uint8_t *src[static 2],
+                     const size_t src_pitch[static 2], unsigned height,
+                     const copy_cache_t *cache)
 {
 #ifdef CAN_COMPILE_SSE2
     unsigned    cpu = vlc_CPU();
 
     if (vlc_CPU_SSE2())
-        return SSE_CopyFromNv12ToI420(dst, src, src_pitch, height, cache, cpu);
+        return SSE_Copy420_SP_to_P(dst, src, src_pitch, height, cache, cpu);
 #else
     VLC_UNUSED(cache);
 #endif
@@ -626,14 +591,14 @@ void CopyFromNv12ToI420(picture_t *dst, uint8_t *src[2], size_t src_pitch[2],
                 src[1], src_pitch[1], height/2);
 }
 
-void CopyFromI420ToNv12(picture_t *dst, uint8_t *src[3], size_t src_pitch[3],
-                        unsigned height, copy_cache_t *cache)
+void Copy420_P_to_SP(picture_t *dst, const uint8_t *src[static 3],
+                     const size_t src_pitch[static 3], unsigned height,
+                     const copy_cache_t *cache)
 {
 #ifdef CAN_COMPILE_SSE2
     unsigned cpu = vlc_CPU();
     if (vlc_CPU_SSE2())
-        return SSE_CopyFromI420ToNv12(dst, src, src_pitch, height,
-                                cache, cpu);
+        return SSE_Copy420_P_to_SP(dst, src, src_pitch, height, cache, cpu);
 #else
     (void) cache;
 #endif
@@ -649,8 +614,8 @@ void CopyFromI420ToNv12(picture_t *dst, uint8_t *src[3], size_t src_pitch[3],
     const int i_extra_pitch_v  = src_pitch[V_PLANE] - copy_pitch;
 
     uint8_t *dstUV = dst->p[1].p_pixels;
-    uint8_t *srcU  = src[U_PLANE];
-    uint8_t *srcV  = src[V_PLANE];
+    const uint8_t *srcU  = src[U_PLANE];
+    const uint8_t *srcV  = src[V_PLANE];
     for ( unsigned int line = 0; line < copy_lines; line++ )
     {
         for ( unsigned int col = 0; col < copy_pitch; col++ )
@@ -664,15 +629,16 @@ void CopyFromI420ToNv12(picture_t *dst, uint8_t *src[3], size_t src_pitch[3],
     }
 }
 
-void CopyFromI420_10ToP010(picture_t *dst, uint8_t *src[3], size_t src_pitch[3],
-                        unsigned height, copy_cache_t *cache)
+void CopyFromI420_10ToP010(picture_t *dst, const uint8_t *src[static 3],
+                           const size_t src_pitch[static 3],
+                           unsigned height, const copy_cache_t *cache)
 {
     (void) cache;
 
     const int i_extra_pitch_dst_y = (dst->p[0].i_pitch  - src_pitch[0]) / 2;
     const int i_extra_pitch_src_y = (src_pitch[Y_PLANE] - src_pitch[0]) / 2;
-    uint16_t *dstY = dst->p[0].p_pixels;
-    uint16_t *srcY = src[Y_PLANE];
+    uint16_t *dstY = (uint16_t *) dst->p[0].p_pixels;
+    const uint16_t *srcY = (const uint16_t *) src[Y_PLANE];
     for (unsigned y = 0; y < height; y++) {
         for (unsigned x = 0; x < (src_pitch[0] / 2); x++) {
             *dstY++ = *srcY++ << 6;
@@ -688,9 +654,9 @@ void CopyFromI420_10ToP010(picture_t *dst, uint8_t *src[3], size_t src_pitch[3],
     const int i_extra_pitch_u  = src_pitch[U_PLANE] / 2 - copy_pitch;
     const int i_extra_pitch_v  = src_pitch[V_PLANE] / 2 - copy_pitch;
 
-    uint16_t *dstUV = dst->p[1].p_pixels;
-    uint16_t *srcU  = src[U_PLANE];
-    uint16_t *srcV  = src[V_PLANE];
+    uint16_t *dstUV = (uint16_t *) dst->p[1].p_pixels;
+    const uint16_t *srcU  = (const uint16_t *) src[U_PLANE];
+    const uint16_t *srcV  = (const uint16_t *) src[V_PLANE];
     for ( unsigned int line = 0; line < copy_lines; line++ )
     {
         for ( unsigned int col = 0; col < copy_pitch; col++ )
@@ -704,14 +670,14 @@ void CopyFromI420_10ToP010(picture_t *dst, uint8_t *src[3], size_t src_pitch[3],
     }
 }
 
-
-void CopyFromYv12ToYv12(picture_t *dst, uint8_t *src[3], size_t src_pitch[3],
-                        unsigned height, copy_cache_t *cache)
+void Copy420_P_to_P(picture_t *dst, const uint8_t *src[static 3],
+                    const size_t src_pitch[static 3], unsigned height,
+                    const copy_cache_t *cache)
 {
 #ifdef CAN_COMPILE_SSE2
     unsigned cpu = vlc_CPU();
     if (vlc_CPU_SSE2())
-        return SSE_CopyFromYv12ToYv12(dst, src, src_pitch, height, cache, cpu);
+        return SSE_Copy420_P_to_P(dst, src, src_pitch, height, cache, cpu);
 #else
     (void) cache;
 #endif
@@ -724,6 +690,15 @@ void CopyFromYv12ToYv12(picture_t *dst, uint8_t *src[3], size_t src_pitch[3],
                src[2], src_pitch[2], height / 2);
 }
 
+void picture_SwapUV(picture_t *picture)
+{
+    assert(picture->i_planes == 3);
+
+    plane_t tmp_plane = picture->p[1];
+    picture->p[1] = picture->p[2];
+    picture->p[2] = tmp_plane;
+}
+
 int picture_UpdatePlanes(picture_t *picture, uint8_t *data, unsigned pitch)
 {
     /* fill in buffer info in first plane */
diff --git a/modules/video_chroma/copy.h b/modules/video_chroma/copy.h
index 9b9dbd1f66..77278615d5 100644
--- a/modules/video_chroma/copy.h
+++ b/modules/video_chroma/copy.h
@@ -24,6 +24,8 @@
 #ifndef VLC_VIDEOCHROMA_COPY_H_
 #define VLC_VIDEOCHROMA_COPY_H_
 
+#include <assert.h>
+
 typedef struct {
 # ifdef CAN_COMPILE_SSE2
     uint8_t *buffer;
@@ -34,24 +36,38 @@ typedef struct {
 int  CopyInitCache(copy_cache_t *cache, unsigned width);
 void CopyCleanCache(copy_cache_t *cache);
 
-/* Copy planes from NV12 to YV12 */
-void CopyFromNv12ToYv12(picture_t *dst, uint8_t *src[2], size_t src_pitch[2],
-                        unsigned height, copy_cache_t *cache);
-/* Copy planes from YV12 to YV12 */
-void CopyFromYv12ToYv12(picture_t *dst, uint8_t *src[3], size_t src_pitch[3],
-                        unsigned height, copy_cache_t *cache);
+/* Copy planes from NV12/NV21 to NV12/NV21 */
+void Copy420_SP_to_SP(picture_t *dst, const uint8_t *src[static 2],
+                      const size_t src_pitch[static 2], unsigned height,
+                      const copy_cache_t *cache);
+
+/* Copy planes from I420/YV12 to I420/YV12 */
+void Copy420_P_to_P(picture_t *dst, const uint8_t *src[static 3],
+                    const size_t src_pitch[static 3], unsigned height,
+                    const copy_cache_t *cache);
+
+/* Copy planes from I420/YV12 to NV12/NV21 */
+void Copy420_P_to_SP(picture_t *dst, const uint8_t *src[static 3],
+                     const size_t src_pitch[static 3], unsigned height,
+                     const copy_cache_t *cache);
 
-void CopyFromNv12ToNv12(picture_t *dst, uint8_t *src[2], size_t src_pitch[2],
-                        unsigned height, copy_cache_t *cache);
+/* Copy planes from NV12/NV21 to I420/YV12 */
+void Copy420_SP_to_P(picture_t *dst, const uint8_t *src[static 2],
+                     const size_t src_pitch[static 2], unsigned height,
+                     const copy_cache_t *cache);
 
-void CopyFromNv12ToI420(picture_t *dst, uint8_t *src[2], size_t src_pitch[2],
-                        unsigned height, copy_cache_t *cache);
 
-void CopyFromI420ToNv12(picture_t *dst, uint8_t *src[3], size_t src_pitch[3],
-                        unsigned height, copy_cache_t *cache);
+/* XXX: Not optimized copy (no SEE) */
+void CopyFromI420_10ToP010(picture_t *dst, const uint8_t *src[static 3],
+                           const size_t src_pitch[static 3],
+                           unsigned height, const copy_cache_t *cache);
 
-void CopyFromI420_10ToP010(picture_t *dst, uint8_t *src[3], size_t src_pitch[3],
-                        unsigned height, copy_cache_t *cache);
+/**
+ * Swap UV planes of a Tri Planars picture.
+ *
+ * It just swap the planes information without doing any copy.
+ */
+void picture_SwapUV(picture_t *picture);
 
 /**
  * This functions sets the internal plane pointers/dimensions for the given
diff --git a/modules/video_chroma/d3d11_surface.c b/modules/video_chroma/d3d11_surface.c
index d2b5ad15e4..f6b98f7fe2 100644
--- a/modules/video_chroma/d3d11_surface.c
+++ b/modules/video_chroma/d3d11_surface.c
@@ -360,32 +360,34 @@ static void D3D11_YUY2(filter_t *p_filter, picture_t *src, picture_t *dst)
     if (desc.Format == DXGI_FORMAT_YUY2) {
         size_t chroma_pitch = (lock.RowPitch / 2);
 
-        size_t pitch[3] = {
+        const size_t pitch[3] = {
             lock.RowPitch,
             chroma_pitch,
             chroma_pitch,
         };
 
-        uint8_t *plane[3] = {
+        const uint8_t *plane[3] = {
             (uint8_t*)lock.pData,
             (uint8_t*)lock.pData + pitch[0] * desc.Height,
             (uint8_t*)lock.pData + pitch[0] * desc.Height
                                  + pitch[1] * desc.Height / 2,
         };
 
-        CopyFromYv12ToYv12(dst, plane, pitch,
-                           src->format.i_visible_height + src->format.i_y_offset, &sys->cache);
+        Copy420_P_to_P(dst, plane, pitch,
+                       src->format.i_visible_height + src->format.i_y_offset,
+                       &sys->cache);
     } else if (desc.Format == DXGI_FORMAT_NV12) {
-        uint8_t *plane[2] = {
+        const uint8_t *plane[2] = {
             lock.pData,
             (uint8_t*)lock.pData + lock.RowPitch * desc.Height
         };
-        size_t  pitch[2] = {
+        const size_t  pitch[2] = {
             lock.RowPitch,
             lock.RowPitch,
         };
-        CopyFromNv12ToYv12(dst, plane, pitch,
-                           src->format.i_visible_height + src->format.i_y_offset, &sys->cache);
+        Copy420_SP_to_P(dst, plane, pitch,
+                        src->format.i_visible_height + src->format.i_y_offset, &sys->cache);
+        picture_SwapUV(dst);
     } else {
         msg_Err(p_filter, "Unsupported D3D11VA conversion from 0x%08X to YV12", desc.Format);
     }
@@ -485,7 +487,7 @@ static void D3D11_NV12(filter_t *p_filter, picture_t *src, picture_t *dst)
     ID3D11Texture2D_GetDesc(sys->staging, &desc);
 
     if (desc.Format == DXGI_FORMAT_NV12) {
-        uint8_t *plane[2] = {
+        const uint8_t *plane[2] = {
             lock.pData,
             (uint8_t*)lock.pData + lock.RowPitch * desc.Height
         };
@@ -493,8 +495,8 @@ static void D3D11_NV12(filter_t *p_filter, picture_t *src, picture_t *dst)
             lock.RowPitch,
             lock.RowPitch,
         };
-        CopyFromNv12ToNv12(dst, plane, pitch,
-                           src->format.i_visible_height + src->format.i_y_offset, &sys->cache);
+        Copy420_SP_to_SP(dst, plane, pitch,
+                          src->format.i_visible_height + src->format.i_y_offset, &sys->cache);
     } else {
         msg_Err(p_filter, "Unsupported D3D11VA conversion from 0x%08X to NV12", desc.Format);
     }
diff --git a/modules/video_chroma/dxa9.c b/modules/video_chroma/dxa9.c
index e15ea86b0b..281465ac34 100644
--- a/modules/video_chroma/dxa9.c
+++ b/modules/video_chroma/dxa9.c
@@ -89,13 +89,13 @@ static void DXA9_YV12(filter_t *p_filter, picture_t *src, picture_t *dst)
         bool imc3 = desc.Format == MAKEFOURCC('I','M','C','3');
         size_t chroma_pitch = imc3 ? lock.Pitch : (lock.Pitch / 2);
 
-        size_t pitch[3] = {
+        const size_t pitch[3] = {
             lock.Pitch,
             chroma_pitch,
             chroma_pitch,
         };
 
-        uint8_t *plane[3] = {
+        const uint8_t *plane[3] = {
             (uint8_t*)lock.pBits,
             (uint8_t*)lock.pBits + pitch[0] * desc.Height,
             (uint8_t*)lock.pBits + pitch[0] * desc.Height
@@ -103,23 +103,23 @@ static void DXA9_YV12(filter_t *p_filter, picture_t *src, picture_t *dst)
         };
 
         if (imc3) {
-            uint8_t *V = plane[1];
+            const uint8_t *V = plane[1];
             plane[1] = plane[2];
             plane[2] = V;
         }
-        CopyFromYv12ToYv12(dst, plane, pitch,
-                           src->format.i_height, p_copy_cache);
+        Copy420_P_to_P(dst, plane, pitch, src->format.i_height, p_copy_cache);
     } else if (desc.Format == MAKEFOURCC('N','V','1','2')) {
-        uint8_t *plane[2] = {
+        const uint8_t *plane[2] = {
             lock.pBits,
             (uint8_t*)lock.pBits + lock.Pitch * desc.Height
         };
-        size_t  pitch[2] = {
+        const size_t  pitch[2] = {
             lock.Pitch,
             lock.Pitch,
         };
-        CopyFromNv12ToYv12(dst, plane, pitch,
-                           src->format.i_visible_height + src->format.i_y_offset, p_copy_cache);
+        Copy420_SP_to_P(dst, plane, pitch,
+                        src->format.i_visible_height + src->format.i_y_offset, p_copy_cache);
+        picture_SwapUV(dst);
     } else {
         msg_Err(p_filter, "Unsupported DXA9 conversion from 0x%08X to YV12", desc.Format);
     }
@@ -145,7 +145,7 @@ static void DXA9_NV12(filter_t *p_filter, picture_t *src, picture_t *dst)
         return;
 
     if (desc.Format == MAKEFOURCC('N','V','1','2')) {
-        uint8_t *plane[2] = {
+        const uint8_t *plane[2] = {
             lock.pBits,
             (uint8_t*)lock.pBits + lock.Pitch * desc.Height
         };
@@ -153,8 +153,8 @@ static void DXA9_NV12(filter_t *p_filter, picture_t *src, picture_t *dst)
             lock.Pitch,
             lock.Pitch,
         };
-        CopyFromNv12ToNv12(dst, plane, pitch,
-                           src->format.i_visible_height + src->format.i_y_offset, p_copy_cache);
+        Copy420_SP_to_SP(dst, plane, pitch,
+                         src->format.i_visible_height + src->format.i_y_offset, p_copy_cache);
     } else {
         msg_Err(p_filter, "Unsupported DXA9 conversion from 0x%08X to NV12", desc.Format);
     }
diff --git a/modules/video_chroma/i420_10_p010.c b/modules/video_chroma/i420_10_p010.c
index cde4813aef..079e831bb9 100644
--- a/modules/video_chroma/i420_10_p010.c
+++ b/modules/video_chroma/i420_10_p010.c
@@ -107,13 +107,13 @@ static void I420_10_P010( filter_t *p_filter, picture_t *p_src,
     p_dst->format.i_x_offset = p_src->format.i_x_offset;
     p_dst->format.i_y_offset = p_src->format.i_y_offset;
 
-    size_t pitch[3] = {
+    const size_t pitch[3] = {
         p_src->p[Y_PLANE].i_pitch,
         p_src->p[U_PLANE].i_pitch,
         p_src->p[V_PLANE].i_pitch,
     };
 
-    uint8_t *plane[3] = {
+    const uint8_t *plane[3] = {
         (uint8_t*)p_src->p[Y_PLANE].p_pixels,
         (uint8_t*)p_src->p[U_PLANE].p_pixels,
         (uint8_t*)p_src->p[V_PLANE].p_pixels,
diff --git a/modules/video_chroma/i420_nv12.c b/modules/video_chroma/i420_nv12.c
index 4a1a606a6c..6a55616879 100644
--- a/modules/video_chroma/i420_nv12.c
+++ b/modules/video_chroma/i420_nv12.c
@@ -120,21 +120,21 @@ static void I420_YUV( filter_sys_t *p_sys, picture_t *p_src, picture_t *p_dst, b
     const size_t u_plane = invertUV ? V_PLANE : U_PLANE;
     const size_t v_plane = invertUV ? U_PLANE : V_PLANE;
 
-    size_t pitch[3] = {
+    const size_t pitch[3] = {
         p_src->p[Y_PLANE].i_pitch,
         p_src->p[u_plane].i_pitch,
         p_src->p[v_plane].i_pitch,
     };
 
-    uint8_t *plane[3] = {
+    const uint8_t *plane[3] = {
         (uint8_t*)p_src->p[Y_PLANE].p_pixels,
         (uint8_t*)p_src->p[u_plane].p_pixels,
         (uint8_t*)p_src->p[v_plane].p_pixels,
     };
 
-    CopyFromI420ToNv12( p_dst, plane, pitch,
-                        p_src->format.i_y_offset + p_src->format.i_visible_height,
-                        &p_sys->cache );
+    Copy420_P_to_SP( p_dst, plane, pitch,
+                     p_src->format.i_y_offset + p_src->format.i_visible_height,
+                     &p_sys->cache );
 }
 
 /*****************************************************************************



More information about the vlc-commits mailing list