Fix h264 frame size error

This commit is contained in:
dijunkun
2023-12-05 15:09:25 +08:00
parent 62f85bb333
commit 936348ba9e
3 changed files with 10 additions and 9 deletions

View File

@@ -50,6 +50,10 @@ int NvidiaVideoDecoder::Decode(
return -1;
}
if (SAVE_DECODER_STREAM) {
fwrite((unsigned char *)data, 1, size, file_);
}
if ((*(data + 4) & 0x1f) == 0x07) {
// LOG_WARN("Receive key frame");
}
@@ -67,10 +71,6 @@ int NvidiaVideoDecoder::Decode(
data, decoder->GetWidth() * decoder->GetHeight() * 3 / 2,
decoder->GetWidth(), decoder->GetHeight());
on_receive_decoded_frame(decoded_frame);
if (SAVE_DECODER_STREAM) {
fwrite((unsigned char *)decoded_frame.Buffer(), 1,
decoded_frame.Size(), file_);
}
}
}
}

View File

@@ -152,6 +152,10 @@ int OpenH264Decoder::Decode(
fwrite((unsigned char *)data, 1, size, h264_stream_);
}
if ((*(data + 4) & 0x1f) == 0x07) {
// LOG_WARN("Receive key frame");
}
SBufferInfo sDstBufInfo = {0};
memset(&sDstBufInfo, 0, sizeof(SBufferInfo));

View File

@@ -55,7 +55,7 @@ void RtpVideoReceiver::InsertRtpPacket(RtpPacket& rtp_packet) {
if (RtpPacket::PAYLOAD_TYPE::H264 == rtp_packet.PayloadType()) {
if (RtpPacket::NAL_UNIT_TYPE::NALU == rtp_packet.NalUnitType()) {
compelete_video_frame_queue_.push(
VideoFrame(rtp_packet.Payload(), rtp_packet.Size()));
VideoFrame(rtp_packet.Payload(), rtp_packet.PayloadSize()));
} else if (RtpPacket::NAL_UNIT_TYPE::FU_A == rtp_packet.NalUnitType()) {
incomplete_frame_list_[rtp_packet.SequenceNumber()] = rtp_packet;
bool complete = CheckIsFrameCompleted(rtp_packet);
@@ -65,7 +65,7 @@ void RtpVideoReceiver::InsertRtpPacket(RtpPacket& rtp_packet) {
if (RtpPacket::PAYLOAD_TYPE::H264 == rtp_packet.PayloadType()) {
if (RtpPacket::NAL_UNIT_TYPE::NALU == rtp_packet.NalUnitType()) {
compelete_video_frame_queue_.push(
VideoFrame(rtp_packet.Payload(), rtp_packet.Size()));
VideoFrame(rtp_packet.Payload(), rtp_packet.PayloadSize()));
} else if (RtpPacket::NAL_UNIT_TYPE::FU_A == rtp_packet.NalUnitType()) {
incomplete_frame_list_[rtp_packet.SequenceNumber()] = rtp_packet;
bool complete = CheckIsFrameCompleted(rtp_packet);
@@ -165,7 +165,6 @@ void RtpVideoReceiver::InsertRtpPacket(RtpPacket& rtp_packet) {
bool RtpVideoReceiver::CheckIsFrameCompleted(RtpPacket& rtp_packet) {
if (rtp_packet.FuAEnd()) {
size_t complete_frame_size = 0;
uint16_t end_seq = rtp_packet.SequenceNumber();
if (incomplete_frame_list_.size() == end_seq) {
return true;
@@ -179,10 +178,8 @@ bool RtpVideoReceiver::CheckIsFrameCompleted(RtpPacket& rtp_packet) {
// repaired using FEC
return false;
} else if (!it->second.FuAStart()) {
complete_frame_size += it->second.PayloadSize();
continue;
} else if (it->second.FuAStart()) {
complete_frame_size += it->second.PayloadSize();
if (!nv12_data_) {
nv12_data_ = new uint8_t[NV12_BUFFER_SIZE];
}