summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.cpp66
1 files changed, 47 insertions, 19 deletions
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
index b55750a..15c611f 100644
--- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp
+++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
@@ -48,10 +48,28 @@
-static inline void memcpy_rev ( void *dst, void *src, size_t len )
+/*
+ * This code relies the len be a multiply of 16bit
+ */
+static inline void memcpy_rev ( void *_dst, void *_src, size_t len )
{
- len >>= 1;
-
- ((char *) src ) += ( len << 1 );
+ /*
+ * move the source to the end
+ */
+ char *src_c = static_cast<char*>(_src) + len;
+
+ /*
+ * as we copy by 16bit and not 8bit
+ * devide the length by two
+ */
+ len >>= 1;
+
+ short int* dst = static_cast<short int*>( _dst );
+ short int* src = reinterpret_cast<short int*>( src_c );
+
+ /*
+ * Increment dst after assigning
+ * Decrement src before assigning becase we move backwards
+ */
+ while ( len-- )
+ *dst++ = *--src;
- while ( len-- )
- *((short int *) dst )++ = *--((short int *) src );
}
@@ -60,9 +78,16 @@ static inline void memcpy_rev ( void *dst, void *src, size_t len )
-static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step )
+static inline void memcpy_step ( void *_dst, void *_src, size_t len, size_t step )
{
- len >>= 1;
- while ( len-- ) {
- *((short int *) dst )++ = *((short int *) src );
- ((char *) src ) += step;
- }
+ short int *dst = static_cast<short int*>( _dst );
+ short int *src = static_cast<short int*>( _src );
+
+ len >>= 1;
+
+ /*
+ * Copy 16bit from src to dst and move to the next address
+ */
+ while ( len-- ) {
+ *dst++ = *src;
+ src = reinterpret_cast<short int*>(reinterpret_cast<char*>(src)+step);
+ }
}
@@ -71,12 +96,15 @@ static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step )
-static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step )
+static inline void memcpy_step_rev ( void *_dst, void *_src, size_t len, size_t step )
{
- len >>= 1;
+ len >>= 1;
- ((char *) src ) += ( len * step );
+ char *src_c = static_cast<char*>( _src ) + (len*step);
+ short int* dst = static_cast<short int*>( _dst );
+ short int* src = reinterpret_cast<short int*>( src_c );
- while ( len-- ) {
- ((char *) src ) -= step;
- *((short int *) dst )++ = *((short int *) src );
- }
+ while ( len-- ) {
+ src_c -= step;
+ src = reinterpret_cast<short int*>( src_c );
+ *dst++ = *src;
+ }
}