-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Frame: Fix interlaced AddImage #418
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
|
@@ -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()); | ||
Comment on lines
845
to
+847
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is where things really break. The way that loop was previously written, it would go through every other row (odd or even) in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Oh, yeah — the telltale cast on |
||
} | ||
|
||
// Update height and width | ||
width = image->width(); | ||
height = image->height(); | ||
width = image->width(); | ||
has_image_data = true; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const
s are nice and all, when appropriate, but when you're modifying the pixels in the buffer I'm pretty sure we're not supposed to useconstBits()
since it suppresses Qt's copy-on-write handling for sharedQImage
buffers.