[vlc-commits] sout: sdi: refactor v210 conversion

Francois Cartegnie git at videolan.org
Mon May 6 20:31:45 CEST 2019


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon May  6 10:03:40 2019 +0200| [9d9d1d0afdc2213a375009ccdc6a32fc52f50edd] | committer: Francois Cartegnie

sout: sdi: refactor v210 conversion

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

 modules/stream_out/sdi/Ancillary.cpp | 15 +++------------
 modules/stream_out/sdi/V210.cpp      | 12 ++++++++++++
 modules/stream_out/sdi/V210.hpp      |  2 ++
 3 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/modules/stream_out/sdi/Ancillary.cpp b/modules/stream_out/sdi/Ancillary.cpp
index d4528b3f06..cbb4e16b20 100644
--- a/modules/stream_out/sdi/Ancillary.cpp
+++ b/modules/stream_out/sdi/Ancillary.cpp
@@ -23,6 +23,7 @@
 #endif
 
 #include "Ancillary.hpp"
+#include "V210.hpp"
 #include <cassert>
 
 using namespace sdi;
@@ -92,12 +93,7 @@ void AFD::FillBuffer(uint8_t *p_buf, size_t i_buf)
         afd[i] = 0x040;
 
     /* convert to v210 and write into VANC */
-    for (size_t w = 0; w < s / 6 ; w++) {
-        put_le32(&p_buf, afd[w*6+0] << 10);
-        put_le32(&p_buf, afd[w*6+1] | (afd[w*6+2] << 20));
-        put_le32(&p_buf, afd[w*6+3] << 10);
-        put_le32(&p_buf, afd[w*6+4] | (afd[w*6+5] << 20));
-    }
+    V210::Convert(afd, s, p_buf);
 }
 
 Captions::Captions(const uint8_t *p, size_t s,
@@ -213,12 +209,7 @@ void Captions::FillBuffer(uint8_t *p_buf, size_t i_buf)
         cdp[i] = 0x040;
 
     /* convert to v210 and write into VBI line 15 of VANC */
-    for (size_t w = 0; w < s / 6 ; w++) {
-        put_le32(&p_buf, cdp[w*6+0] << 10);
-        put_le32(&p_buf, cdp[w*6+1] | (cdp[w*6+2] << 20));
-        put_le32(&p_buf, cdp[w*6+3] << 10);
-        put_le32(&p_buf, cdp[w*6+4] | (cdp[w*6+5] << 20));
-    }
+    V210::Convert(cdp, s, p_buf);
 
     delete[] cdp;
 }
diff --git a/modules/stream_out/sdi/V210.cpp b/modules/stream_out/sdi/V210.cpp
index 1cc6c90d5c..872c40a61f 100644
--- a/modules/stream_out/sdi/V210.cpp
+++ b/modules/stream_out/sdi/V210.cpp
@@ -94,3 +94,15 @@ void V210::Convert(const picture_t *pic, unsigned dst_stride, void *frame_bytes)
         v += pic->p[2].i_pitch / 2 - width / 2;
     }
 }
+
+void V210::Convert(const uint16_t *src, size_t srccount, void *out)
+{
+    uint8_t *dst = reinterpret_cast<uint8_t *>(out);
+    for (size_t i = 0; i < srccount / 6; i++)
+    {
+        put_le32(&dst, src[i*6+0] << 10);
+        put_le32(&dst, src[i*6+1] | (src[i*6+2] << 20));
+        put_le32(&dst, src[i*6+3] << 10);
+        put_le32(&dst, src[i*6+4] | (src[i*6+5] << 20));
+    }
+}
diff --git a/modules/stream_out/sdi/V210.hpp b/modules/stream_out/sdi/V210.hpp
index 5a192cbd41..f0c801e354 100644
--- a/modules/stream_out/sdi/V210.hpp
+++ b/modules/stream_out/sdi/V210.hpp
@@ -29,7 +29,9 @@ namespace sdi
     class V210
     {
         public:
+            static const int ALIGNMENT_U16 = 6;
             static void Convert(const picture_t *, unsigned, void *);
+            static void Convert(const uint16_t *, size_t, void *);
     };
 
 }



More information about the vlc-commits mailing list