fix crashes, current status is: local camera works and can be viewed. Amazing

This commit is contained in:
Isaac Connor 2020-07-22 13:41:27 -04:00
parent 3641797500
commit cf07e0a089
2 changed files with 21 additions and 12 deletions

View File

@ -192,13 +192,13 @@ Image::Image( int p_width, int p_linesize, int p_height, int p_colours, int p_su
}
Image::Image(const AVFrame *frame) {
AVFrame *dest_frame = zm_av_frame_alloc();
text[0] = '\0';
width = frame->width;
linesize = frame->linesize[0];
height = frame->height;
pixels = width*height;
// FIXME
colours = ZM_COLOUR_RGB32;
subpixelorder = ZM_SUBPIX_ORDER_RGBA;
@ -206,10 +206,10 @@ Image::Image(const AVFrame *frame) {
buffer = 0;
holdbuffer = 0;
AllocImgBuffer(size);
this->Assign( frame );
this->Assign(frame);
}
void Image::Assign( const AVFrame *frame ) {
void Image::Assign(const AVFrame *frame) {
/* Assume the dimensions etc are correct. FIXME */
AVPixelFormat format = (AVPixelFormat)AVPixFormat();
@ -1889,9 +1889,15 @@ void Image::MaskPrivacy( const unsigned char *p_bitmask, const Rgb pixel_colour
}
/* RGB32 compatible: complete */
void Image::Annotate( const char *p_text, const Coord &coord, const unsigned int size, const Rgb fg_colour, const Rgb bg_colour )
{
void Image::Annotate(
const char *p_text,
const Coord &coord,
const unsigned int size,
const Rgb fg_colour,
const Rgb bg_colour) {
Debug(1, "text %s", p_text);
strncpy(text, p_text, sizeof(text)-1);
Debug(1, "text %s", text);
unsigned int index = 0;
unsigned int line_no = 0;
@ -2046,7 +2052,7 @@ void Image::Annotate( const char *p_text, const Coord &coord, const unsigned int
}
} else {
Panic("Annotate called with unexpected colours: %d",colours);
Error("Annotate called with unexpected colours: %d", colours);
return;
}

View File

@ -900,7 +900,7 @@ bool Monitor::connect() {
for ( int i = 0; i < image_buffer_count; i++ ) {
image_buffer[i].image_index = i;
image_buffer[i].timestamp = &(shared_timestamps[i]);
image_buffer[i].image = new Image( width, camera->LineSize(), height, camera->Colours(), camera->SubpixelOrder(), &(shared_images[i*camera->ImageSize()]) );
image_buffer[i].image = new Image(width, camera->LineSize(), 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 ) {
@ -2273,17 +2273,20 @@ int Monitor::LoadFfmpegMonitors(const char *file, Monitor **&monitors, Purpose p
int Monitor::Capture() {
static int FirstCapture = 1; // Used in de-interlacing to indicate whether this is the even or odd image
unsigned int index = 0;
//image_count % image_buffer_count;
// I think was starting to work towards not using the buffer. So only ever use the first image.
// Let's not do this for now.
unsigned int index = image_count % image_buffer_count;
ZMPacket *packet = new ZMPacket();
packet->timestamp = image_buffer[index].timestamp;
packet->image_index = image_count;
ZMPacket *packet = &image_buffer[index];
//new ZMPacket();
//packet->timestamp = image_buffer[index].timestamp;
//packet->image_index = image_count;
//&image_buffer[index];
packet->lock();
packet->reset();
Image* capture_image = packet->image;
Debug(1, "capture image: %d x %d linesize: %d", capture_image->Width(), capture_image->Height(), capture_image->LineSize());
int captureResult = 0;
if ( deinterlacing_value == 4 ) {