Fix in-place audio format conversion issues

memcpy_by_audio_format() corner case of same format in-place.
memcpy_to_p24_from_i16() for the first sample in buffer for in-place.

Update memcpy_by_audio_format() documentation.

Test: added native unit test format_tests
Bug: 78598192
Change-Id: I9e538ed4ef233b319b846f4a91c27a86eb605a20
diff --git a/audio_utils/primitives.c b/audio_utils/primitives.c
index d88d701..594f1c5 100644
--- a/audio_utils/primitives.c
+++ b/audio_utils/primitives.c
@@ -138,14 +138,15 @@
     src += count;
     for (; count > 0; --count) {
         dst -= 3;
+        const int16_t sample = *--src;
 #if HAVE_BIG_ENDIAN
-        dst[0] = *--src >> 8;
-        dst[1] = *src;
+        dst[0] = sample >> 8;
+        dst[1] = sample;
         dst[2] = 0;
 #else
         dst[0] = 0;
-        dst[1] = *--src;
-        dst[2] = *src >> 8;
+        dst[1] = sample;
+        dst[2] = sample >> 8;
 #endif
     }
 }