xref: /aosp_15_r20/external/openscreen/cast/standalone_sender/streaming_encoder_util.cc (revision 3f982cf4871df8771c9d4abe6e9a6f8d829b2736)
1 // Copyright 2021 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "cast/standalone_sender/streaming_encoder_util.h"
6 
7 #include <string.h>
8 
9 #include <algorithm>
10 
11 namespace openscreen {
12 namespace cast {
CopyPlane(const uint8_t * src,int src_stride,int num_rows,uint8_t * dst,int dst_stride)13 void CopyPlane(const uint8_t* src,
14                int src_stride,
15                int num_rows,
16                uint8_t* dst,
17                int dst_stride) {
18   if (src_stride == dst_stride) {
19     memcpy(dst, src, src_stride * num_rows);
20     return;
21   }
22   const int bytes_per_row = std::min(src_stride, dst_stride);
23   while (--num_rows >= 0) {
24     memcpy(dst, src, bytes_per_row);
25     dst += dst_stride;
26     src += src_stride;
27   }
28 }
29 }  // namespace cast
30 }  // namespace openscreen
31