Feature: use local variable

pull/221/head
xufuji456 2 years ago
parent d3025ca4ca
commit 1ad8783ff7
  1. 15
      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 sps[100];
uint8_t pps[100]; uint8_t pps[100];
for (int i = 0; i < pi_nal; ++i) { for (int i = 0; i < pi_nal; ++i) {
if (pp_nal[i].i_type == NAL_SPS) { x264_nal_t nal = pp_nal[i];
sps_len = pp_nal[i].i_payload - 4; if (nal.i_type == NAL_SPS) {
memcpy(sps, pp_nal[i].p_payload + 4, static_cast<size_t>(sps_len)); sps_len = nal.i_payload - 4;
} else if (pp_nal[i].i_type == NAL_PPS) { memcpy(sps, nal.p_payload + 4, static_cast<size_t>(sps_len));
pps_len = pp_nal[i].i_payload - 4; } else if (nal.i_type == NAL_PPS) {
memcpy(pps, pp_nal[i].p_payload + 4, static_cast<size_t>(pps_len)); pps_len = nal.i_payload - 4;
memcpy(pps, nal.p_payload + 4, static_cast<size_t>(pps_len));
sendSpsPps(sps, pps, sps_len, pps_len); sendSpsPps(sps, pps, sps_len, pps_len);
} else { } 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);
} }
} }
} }

Loading…
Cancel
Save