Remove old deinterlace code, make new code in ::decode. For 4 field, use the next image in the queue isntead of doing another capture
This commit is contained in:
parent
ba652af347
commit
e53628e0bd
|
@ -999,11 +999,6 @@ bool Monitor::connect() {
|
|||
image_buffer[i].image = new Image(width, height, camera->Colours(), camera->SubpixelOrder(), &(shared_images[i*camera->ImageSize()]));
|
||||
image_buffer[i].image->HoldBuffer(true); /* Don't release the internal buffer or replace it with another */
|
||||
}
|
||||
if (deinterlacing_value == 4) {
|
||||
/* Four field motion adaptive deinterlacing in use */
|
||||
/* Allocate a buffer for the next image */
|
||||
next_buffer.image = new Image(width, height, camera->Colours(), camera->SubpixelOrder());
|
||||
}
|
||||
|
||||
if (purpose == CAPTURE) {
|
||||
memset(mem_ptr, 0, mem_size);
|
||||
|
@ -1122,10 +1117,6 @@ Monitor::~Monitor() {
|
|||
shared_data->last_read_time = 0;
|
||||
shared_data->valid = false;
|
||||
memset(mem_ptr, 0, mem_size);
|
||||
if ( (deinterlacing & 0xff) == 4 ) {
|
||||
delete next_buffer.image;
|
||||
delete next_buffer.timestamp;
|
||||
}
|
||||
} // end if purpose != query
|
||||
disconnect();
|
||||
} // end if mem_ptr
|
||||
|
@ -2513,7 +2504,6 @@ std::vector<std::shared_ptr<Monitor>> Monitor::LoadFfmpegMonitors(const char *fi
|
|||
* Returns -1 on failure.
|
||||
*/
|
||||
int Monitor::Capture() {
|
||||
|
||||
unsigned int index = image_count % image_buffer_count;
|
||||
|
||||
ZMPacket *packet = new ZMPacket();
|
||||
|
@ -2522,28 +2512,10 @@ int Monitor::Capture() {
|
|||
gettimeofday(packet->timestamp, nullptr);
|
||||
shared_data->zmc_heartbeat_time = packet->timestamp->tv_sec;
|
||||
|
||||
int captureResult = 0;
|
||||
|
||||
if ( deinterlacing_value == 4 ) {
|
||||
static int FirstCapture = 1; // Used in de-interlacing to indicate whether this is the even or odd image
|
||||
if ( FirstCapture != 1 ) {
|
||||
/* Copy the next image into the shared memory */
|
||||
//capture_image->CopyBuffer(*(next_buffer.image));
|
||||
}
|
||||
/* Capture a new next image */
|
||||
captureResult = camera->Capture(*packet);
|
||||
// How about set shared_data->current_timestamp
|
||||
gettimeofday(packet->timestamp, nullptr);
|
||||
|
||||
if ( FirstCapture ) {
|
||||
FirstCapture = 0;
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
captureResult = camera->Capture(*packet);
|
||||
int captureResult = camera->Capture(*packet);
|
||||
Debug(4, "Back from capture result=%d image count %d", captureResult, image_count);
|
||||
|
||||
if ( captureResult < 0 ) {
|
||||
if (captureResult < 0) {
|
||||
Debug(2, "failed capture");
|
||||
// Unable to capture image
|
||||
// Fake a signal loss image
|
||||
|
@ -2625,7 +2597,6 @@ int Monitor::Capture() {
|
|||
delete packet;
|
||||
return 0;
|
||||
} // end if result
|
||||
} // end if deinterlacing
|
||||
|
||||
// Icon: I'm not sure these should be here. They have nothing to do with capturing
|
||||
if ( shared_data->action & GET_SETTINGS ) {
|
||||
|
@ -2719,7 +2690,20 @@ bool Monitor::Decode() {
|
|||
} else if ( deinterlacing_value == 3 ) {
|
||||
capture_image->Deinterlace_Blend();
|
||||
} else if ( deinterlacing_value == 4 ) {
|
||||
capture_image->Deinterlace_4Field(next_buffer.image, (deinterlacing>>8)&0xff);
|
||||
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->packet_->codec_type == packet->codec_type) {
|
||||
deinterlace_packet_lock = second_packet_lock;
|
||||
break;
|
||||
}
|
||||
packetqueue.unlock(second_packet_lock);
|
||||
packetqueue.increment_it(decoder_it);
|
||||
}
|
||||
if (zm_terminate) return false;
|
||||
capture_image->Deinterlace_4Field(deinterlace_packet_lock->packet_->image, (deinterlacing>>8)&0xff);
|
||||
delete deinterlace_packet_lock;
|
||||
} else if ( deinterlacing_value == 5 ) {
|
||||
capture_image->Deinterlace_Blend_CustomRatio((deinterlacing>>8)&0xff);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue