Skip to content

Commit

Permalink
Frame: Fix interlaced AddImage
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdnyc committed Jan 21, 2020
1 parent 49972b2 commit 86bfa2f
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/Frame.cpp
Expand Up @@ -818,16 +818,23 @@ void Frame::AddImage(std::shared_ptr<QImage> new_image, bool only_odd_lines)
// Ignore image of different sizes or formats
bool ret=false;
#pragma omp critical (AddImage)
if (image == new_image || image->size() != image->size() || image->format() != image->format())
ret=true;
if (ret)
{
if (image == new_image || image->size() != new_image->size()) {
ret = true;
}
else if (new_image->format() != image->format()) {
new_image = std::shared_ptr<QImage>(new QImage(new_image->convertToFormat(image->format())));
}
}
if (ret) {
return;

}

// Get the frame's image
const GenericScopedLock<juce::CriticalSection> lock(addingImageSection);
#pragma omp critical (AddImage)
{
const unsigned char *pixels = image->constBits();
unsigned char *pixels = image->bits();
const unsigned char *new_pixels = new_image->constBits();

// Loop through the scanlines of the image (even or odd)
Expand All @@ -836,13 +843,13 @@ void Frame::AddImage(std::shared_ptr<QImage> new_image, bool only_odd_lines)
start = 1;

for (int row = start; row < image->height(); row += 2) {
memcpy((unsigned char *) pixels, new_pixels + (row * image->bytesPerLine()), image->bytesPerLine());
new_pixels += image->bytesPerLine();
int offset = row * image->bytesPerLine();
memcpy(pixels + offset, new_pixels + offset, image->bytesPerLine());
}

// Update height and width
width = image->width();
height = image->height();
width = image->width();
has_image_data = true;
}
}
Expand Down

0 comments on commit 86bfa2f

Please sign in to comment.