Fix cases of failing to get second packet in de-interlacing

This commit is contained in:
Isaac Connor 2021-05-07 14:03:36 -04:00
parent 5ca5ce32e9
commit 9c6d3989d3
1 changed files with 14 additions and 9 deletions

View File

@ -2634,6 +2634,7 @@ bool Monitor::Decode() {
ZMPacket *packet = packet_lock->packet_;
packetqueue.increment_it(decoder_it);
if (packet->codec_type != AVMEDIA_TYPE_VIDEO) {
Debug(4, "Not video");
packetqueue.unlock(packet_lock);
return true; // Don't need decode
}
@ -2695,6 +2696,7 @@ bool Monitor::Decode() {
/* Deinterlacing */
if (deinterlacing_value) {
Debug(1, "Doing deinterlacing");
if (deinterlacing_value == 1) {
capture_image->Deinterlace_Discard();
} else if (deinterlacing_value == 2) {
@ -2705,7 +2707,10 @@ bool Monitor::Decode() {
ZMLockedPacket *deinterlace_packet_lock = nullptr;
while (!zm_terminate) {
ZMLockedPacket *second_packet_lock = packetqueue.get_packet(decoder_it);
if (!second_packet_lock) return false;
if (!second_packet_lock) {
packetqueue.unlock(packet_lock);
return false;
}
if (second_packet_lock->packet_->codec_type == packet->codec_type) {
deinterlace_packet_lock = second_packet_lock;
break;
@ -2715,7 +2720,7 @@ bool Monitor::Decode() {
}
if (zm_terminate) return false;
capture_image->Deinterlace_4Field(deinterlace_packet_lock->packet_->image, (deinterlacing>>8)&0xff);
delete deinterlace_packet_lock;
packetqueue.unlock(deinterlace_packet_lock);
} else if (deinterlacing_value == 5) {
capture_image->Deinterlace_Blend_CustomRatio((deinterlacing>>8)&0xff);
}