From 1ad8783ff736b93ff9b7d59a9b5be587d710e3d2 Mon Sep 17 00:00:00 2001 From: xufuji456 Date: Thu, 22 Sep 2022 17:01:24 +0800 Subject: [PATCH] Feature: use local variable --- Live/src/main/cpp/VideoStream.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Live/src/main/cpp/VideoStream.cpp b/Live/src/main/cpp/VideoStream.cpp index 8073757..3cb107e 100644 --- a/Live/src/main/cpp/VideoStream.cpp +++ b/Live/src/main/cpp/VideoStream.cpp @@ -194,15 +194,16 @@ void VideoStream::encodeVideo(int8_t *data, int camera_type) { uint8_t sps[100]; uint8_t pps[100]; for (int i = 0; i < pi_nal; ++i) { - if (pp_nal[i].i_type == NAL_SPS) { - sps_len = pp_nal[i].i_payload - 4; - memcpy(sps, pp_nal[i].p_payload + 4, static_cast(sps_len)); - } else if (pp_nal[i].i_type == NAL_PPS) { - pps_len = pp_nal[i].i_payload - 4; - memcpy(pps, pp_nal[i].p_payload + 4, static_cast(pps_len)); + x264_nal_t nal = pp_nal[i]; + if (nal.i_type == NAL_SPS) { + sps_len = nal.i_payload - 4; + memcpy(sps, nal.p_payload + 4, static_cast(sps_len)); + } else if (nal.i_type == NAL_PPS) { + pps_len = nal.i_payload - 4; + memcpy(pps, nal.p_payload + 4, static_cast(pps_len)); sendSpsPps(sps, pps, sps_len, pps_len); } else { - sendFrame(pp_nal[i].i_type, pp_nal[i].p_payload, pp_nal[i].i_payload); + sendFrame(nal.i_type, nal.p_payload, nal.i_payload); } } }