Skip to content

Commit 154d768

Browse files
committed
acap/aes67: Use swap_endianity
1 parent 756e321 commit 154d768

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/audio/capture/aes67.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151

5252
#include "audio/audio_capture.h" // for AUDIO_CAPTURE_ABI_VERSION, audio_ca...
5353
#include "audio/types.h" // for audio_frame
54+
#include "audio/utils.h"
5455
#include "host.h" // for INIT_NOERR
5556
#include "lib_common.h" // for REGISTER_MODULE, library_class
5657
#include "tv.h" // for get_time_in_ns, time_ns_t, NS_TO_US
@@ -237,17 +238,8 @@ static void aes67_rtp_worker(state_aes67_cap *s, Rtp_stream stream){
237238

238239
int sample_count = rtp_pkt.data_len / desc.bps;
239240

240-
unsigned char *src = static_cast<unsigned char *>(rtp_pkt.data);
241-
242-
const int bps = desc.bps;
243-
const int swap_count = bps / 2;
244-
for(int i = 0; i < sample_count; i++){
245-
for(int j = 0; j < swap_count; j++){
246-
unsigned char tmp = src[i * bps + j];
247-
src[i * bps + j] = src[i * bps + bps - j - 1];
248-
src[i * bps + bps - j - 1] = tmp;;
249-
}
250-
}
241+
char *src = static_cast<char *>(rtp_pkt.data);
242+
swap_endianity(src, desc.bps, sample_count);
251243

252244
size_t to_write = std::min<size_t>(s->back_frame.frame.max_size - s->back_frame.data.size(), sample_count * desc.bps);
253245
s->back_frame.data.insert(s->back_frame.data.end(), src, src + to_write);

0 commit comments

Comments
 (0)