Browse code

intreadwrite: Add AV_COPYxxU macros for copying to/from unaligned addresses

Diego Biurrun authored on 2012/10/23 20:27:05
Showing 1 changed files
... ...
@@ -462,6 +462,33 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
462 462
 #   define AV_WN64A(p, v) AV_WNA(64, p, v)
463 463
 #endif
464 464
 
465
+/*
466
+ * The AV_COPYxxU macros are suitable for copying data to/from unaligned
467
+ * memory locations.
468
+ */
469
+
470
+#define AV_COPYU(n, d, s) AV_WN##n(d, AV_RN##n(s));
471
+
472
+#ifndef AV_COPY16U
473
+#   define AV_COPY16U(d, s) AV_COPYU(16, d, s)
474
+#endif
475
+
476
+#ifndef AV_COPY32U
477
+#   define AV_COPY32U(d, s) AV_COPYU(32, d, s)
478
+#endif
479
+
480
+#ifndef AV_COPY64U
481
+#   define AV_COPY64U(d, s) AV_COPYU(64, d, s)
482
+#endif
483
+
484
+#ifndef AV_COPY128U
485
+#   define AV_COPY128U(d, s)                                    \
486
+    do {                                                        \
487
+        AV_COPY64U(d, s);                                       \
488
+        AV_COPY64U((char *)(d) + 8, (const char *)(s) + 8);     \
489
+    } while(0)
490
+#endif
491
+
465 492
 /* Parameters for AV_COPY*, AV_SWAP*, AV_ZERO* must be
466 493
  * naturally aligned. They may be implemented using MMX,
467 494
  * so emms_c() must be called before using any float code