Skip to content

Commit 6bd7fb7

Browse files
committed
Replacing ARGB32_Premultiplied with Format_RGBA8888_Premultiplied, which still seems to benefit from performance, but keeps the byte order the same as before. win win
1 parent 9405982 commit 6bd7fb7

File tree

9 files changed

+24
-24
lines changed

9 files changed

+24
-24
lines changed

src/CacheDisk.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ std::shared_ptr<Frame> CacheDisk::GetFrame(int64_t frame_number)
235235
image->load(frame_path);
236236

237237
// Set pixel formatimage->
238-
image = std::shared_ptr<QImage>(new QImage(image->convertToFormat(QImage::Format_ARGB32_Premultiplied)));
238+
image = std::shared_ptr<QImage>(new QImage(image->convertToFormat(QImage::Format_RGBA8888_Premultiplied)));
239239

240240
// Create frame object
241241
std::shared_ptr<Frame> frame(new Frame());

src/FFmpegReader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,7 @@ void FFmpegReader::ProcessVideoPacket(int64_t requested_frame) {
13631363
scale_mode = SWS_BICUBIC;
13641364
}
13651365
SwsContext *img_convert_ctx = sws_getContext(info.width, info.height, AV_GET_CODEC_PIXEL_FORMAT(pStream, pCodecCtx), width,
1366-
height, AV_PIX_FMT_RGB32, scale_mode, NULL, NULL, NULL);
1366+
height, PIX_FMT_RGBA, scale_mode, NULL, NULL, NULL);
13671367

13681368
// Resize / Convert to RGB
13691369
sws_scale(img_convert_ctx, my_frame->data, my_frame->linesize, 0,
@@ -1373,7 +1373,7 @@ void FFmpegReader::ProcessVideoPacket(int64_t requested_frame) {
13731373
std::shared_ptr<Frame> f = CreateFrame(current_frame);
13741374

13751375
// Add Image data to frame
1376-
f->AddImage(width, height, 4, QImage::Format_ARGB32_Premultiplied, buffer);
1376+
f->AddImage(width, height, 4, QImage::Format_RGBA8888_Premultiplied, buffer);
13771377

13781378
// Update working cache
13791379
working_cache.Add(f);

src/Frame.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ std::shared_ptr<QImage> Frame::GetWaveform(int width, int height, int Red, int G
231231
}
232232

233233
// Create blank image
234-
wave_image = std::shared_ptr<QImage>(new QImage(total_width, total_height, QImage::Format_ARGB32_Premultiplied));
234+
wave_image = std::shared_ptr<QImage>(new QImage(total_width, total_height, QImage::Format_RGBA8888_Premultiplied));
235235
wave_image->fill(QColor(0,0,0,0));
236236

237237
// Load QPainter with wave_image device
@@ -262,7 +262,7 @@ std::shared_ptr<QImage> Frame::GetWaveform(int width, int height, int Red, int G
262262
else
263263
{
264264
// No audio samples present
265-
wave_image = std::shared_ptr<QImage>(new QImage(width, height, QImage::Format_ARGB32_Premultiplied));
265+
wave_image = std::shared_ptr<QImage>(new QImage(width, height, QImage::Format_RGBA8888_Premultiplied));
266266
wave_image->fill(QColor(QString::fromStdString("#000000")));
267267
}
268268

@@ -618,7 +618,7 @@ void Frame::Thumbnail(std::string path, int new_width, int new_height, std::stri
618618
std::string background_color, bool ignore_aspect, std::string format, int quality, float rotate) {
619619

620620
// Create blank thumbnail image & fill background color
621-
std::shared_ptr<QImage> thumbnail = std::shared_ptr<QImage>(new QImage(new_width, new_height, QImage::Format_ARGB32_Premultiplied));
621+
std::shared_ptr<QImage> thumbnail = std::shared_ptr<QImage>(new QImage(new_width, new_height, QImage::Format_RGBA8888_Premultiplied));
622622
thumbnail->fill(QColor(QString::fromStdString(background_color)));
623623

624624
// Create painter
@@ -673,7 +673,7 @@ void Frame::Thumbnail(std::string path, int new_width, int new_height, std::stri
673673
overlay->load(QString::fromStdString(overlay_path));
674674

675675
// Set pixel format
676-
overlay = std::shared_ptr<QImage>(new QImage(overlay->convertToFormat(QImage::Format_ARGB32_Premultiplied)));
676+
overlay = std::shared_ptr<QImage>(new QImage(overlay->convertToFormat(QImage::Format_RGBA8888_Premultiplied)));
677677

678678
// Resize to fit
679679
overlay = std::shared_ptr<QImage>(new QImage(overlay->scaled(new_width, new_height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)));
@@ -691,7 +691,7 @@ void Frame::Thumbnail(std::string path, int new_width, int new_height, std::stri
691691
mask->load(QString::fromStdString(mask_path));
692692

693693
// Set pixel format
694-
mask = std::shared_ptr<QImage>(new QImage(mask->convertToFormat(QImage::Format_ARGB32_Premultiplied)));
694+
mask = std::shared_ptr<QImage>(new QImage(mask->convertToFormat(QImage::Format_RGBA8888_Premultiplied)));
695695

696696
// Resize to fit
697697
mask = std::shared_ptr<QImage>(new QImage(mask->scaled(new_width, new_height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)));
@@ -747,7 +747,7 @@ void Frame::AddColor(int new_width, int new_height, std::string new_color)
747747
const GenericScopedLock<juce::CriticalSection> lock(addingImageSection);
748748
#pragma omp critical (AddImage)
749749
{
750-
image = std::shared_ptr<QImage>(new QImage(new_width, new_height, QImage::Format_ARGB32_Premultiplied));
750+
image = std::shared_ptr<QImage>(new QImage(new_width, new_height, QImage::Format_RGBA8888_Premultiplied));
751751

752752
// Fill with solid color
753753
image->fill(QColor(QString::fromStdString(color)));
@@ -775,8 +775,8 @@ void Frame::AddImage(int new_width, int new_height, int bytes_per_pixel, QImage:
775775
image = std::shared_ptr<QImage>(new QImage(qbuffer, new_width, new_height, new_width * bytes_per_pixel, type, (QImageCleanupFunction) &openshot::Frame::cleanUpBuffer, (void*) qbuffer));
776776

777777
// Always convert to RGBA8888 (if different)
778-
if (image->format() != QImage::Format_ARGB32_Premultiplied)
779-
*image = image->convertToFormat(QImage::Format_ARGB32_Premultiplied);
778+
if (image->format() != QImage::Format_RGBA8888_Premultiplied)
779+
*image = image->convertToFormat(QImage::Format_RGBA8888_Premultiplied);
780780

781781
// Update height and width
782782
width = image->width();
@@ -798,9 +798,9 @@ void Frame::AddImage(std::shared_ptr<QImage> new_image)
798798
{
799799
image = new_image;
800800

801-
// Always convert to Format_ARGB32_Premultiplied (if different)
802-
if (image->format() != QImage::Format_ARGB32_Premultiplied)
803-
*image = image->convertToFormat(QImage::Format_ARGB32_Premultiplied);
801+
// Always convert to Format_RGBA8888_Premultiplied (if different)
802+
if (image->format() != QImage::Format_RGBA8888_Premultiplied)
803+
*image = image->convertToFormat(QImage::Format_RGBA8888_Premultiplied);
804804

805805
// Update height and width
806806
width = image->width();
@@ -830,8 +830,8 @@ void Frame::AddImage(std::shared_ptr<QImage> new_image, bool only_odd_lines)
830830
if (image == new_image || image->size() != new_image->size()) {
831831
ret = true;
832832
}
833-
else if (new_image->format() != QImage::Format_ARGB32_Premultiplied) {
834-
new_image = std::shared_ptr<QImage>(new QImage(new_image->convertToFormat(QImage::Format_ARGB32_Premultiplied)));
833+
else if (new_image->format() != QImage::Format_RGBA8888_Premultiplied) {
834+
new_image = std::shared_ptr<QImage>(new QImage(new_image->convertToFormat(QImage::Format_RGBA8888_Premultiplied)));
835835
}
836836
}
837837
if (ret) {
@@ -970,7 +970,7 @@ void Frame::AddMagickImage(std::shared_ptr<Magick::Image> new_image)
970970
MagickCore::ExportImagePixels(new_image->constImage(), 0, 0, new_image->columns(), new_image->rows(), "RGBA", Magick::CharPixel, buffer, &exception);
971971

972972
// Create QImage of frame data
973-
image = std::shared_ptr<QImage>(new QImage(qbuffer, width, height, width * BPP, QImage::Format_ARGB32_Premultiplied, (QImageCleanupFunction) &cleanUpBuffer, (void*) qbuffer));
973+
image = std::shared_ptr<QImage>(new QImage(qbuffer, width, height, width * BPP, QImage::Format_RGBA8888_Premultiplied, (QImageCleanupFunction) &cleanUpBuffer, (void*) qbuffer));
974974

975975
// Update height and width
976976
width = image->width();

src/QtHtmlReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void QtHtmlReader::Open()
6262
if (!is_open)
6363
{
6464
// create image
65-
image = std::shared_ptr<QImage>(new QImage(width, height, QImage::Format_ARGB32_Premultiplied));
65+
image = std::shared_ptr<QImage>(new QImage(width, height, QImage::Format_RGBA8888_Premultiplied));
6666
image->fill(QColor(background_color.c_str()));
6767

6868
//start painting

src/QtImageReader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void QtImageReader::Open()
8282
ResvgRenderer renderer(path);
8383
if (renderer.isValid()) {
8484

85-
image = std::shared_ptr<QImage>(new QImage(renderer.defaultSize(), QImage::Format_ARGB32_Premultiplied));
85+
image = std::shared_ptr<QImage>(new QImage(renderer.defaultSize(), QImage::Format_RGBA8888_Premultiplied));
8686
image->fill(Qt::transparent);
8787

8888
QPainter p(image.get());
@@ -236,7 +236,7 @@ std::shared_ptr<Frame> QtImageReader::GetFrame(int64_t requested_frame)
236236
svg_size.scale(max_width, max_height, Qt::KeepAspectRatio);
237237

238238
// Create empty QImage
239-
cached_image = std::shared_ptr<QImage>(new QImage(QSize(svg_size.width(), svg_size.height()), QImage::Format_ARGB32_Premultiplied));
239+
cached_image = std::shared_ptr<QImage>(new QImage(QSize(svg_size.width(), svg_size.height()), QImage::Format_RGBA8888_Premultiplied));
240240
cached_image->fill(Qt::transparent);
241241

242242
// Render SVG into QImage

src/QtTextReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void QtTextReader::Open()
6767
if (!is_open)
6868
{
6969
// create image
70-
image = std::shared_ptr<QImage>(new QImage(width, height, QImage::Format_ARGB32_Premultiplied));
70+
image = std::shared_ptr<QImage>(new QImage(width, height, QImage::Format_RGBA8888_Premultiplied));
7171
image->fill(QColor(background_color.c_str()));
7272

7373
QPainter painter;

src/effects/Bars.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ std::shared_ptr<Frame> Bars::GetFrame(std::shared_ptr<Frame> frame, int64_t fram
6868
std::shared_ptr<QImage> frame_image = frame->GetImage();
6969

7070
// Get bar color (and create small color image)
71-
std::shared_ptr<QImage> tempColor = std::shared_ptr<QImage>(new QImage(frame_image->width(), 1, QImage::Format_ARGB32_Premultiplied));
71+
std::shared_ptr<QImage> tempColor = std::shared_ptr<QImage>(new QImage(frame_image->width(), 1, QImage::Format_RGBA8888_Premultiplied));
7272
tempColor->fill(QColor(QString::fromStdString(color.GetColorHex(frame_number))));
7373

7474
// Get current keyframe values

src/effects/Crop.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ std::shared_ptr<Frame> Crop::GetFrame(std::shared_ptr<Frame> frame, int64_t fram
6868
std::shared_ptr<QImage> frame_image = frame->GetImage();
6969

7070
// Get transparent color (and create small transparent image)
71-
std::shared_ptr<QImage> tempColor = std::shared_ptr<QImage>(new QImage(frame_image->width(), 1, QImage::Format_ARGB32_Premultiplied));
71+
std::shared_ptr<QImage> tempColor = std::shared_ptr<QImage>(new QImage(frame_image->width(), 1, QImage::Format_RGBA8888_Premultiplied));
7272
tempColor->fill(QColor(QString::fromStdString("transparent")));
7373

7474
// Get current keyframe values

src/effects/Deinterlace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ std::shared_ptr<Frame> Deinterlace::GetFrame(std::shared_ptr<Frame> frame, int64
7373
const unsigned char* pixels = image->bits();
7474

7575
// Create a smaller, new image
76-
QImage deinterlaced_image(image->width(), image->height() / 2, QImage::Format_ARGB32_Premultiplied);
76+
QImage deinterlaced_image(image->width(), image->height() / 2, QImage::Format_RGBA8888_Premultiplied);
7777
const unsigned char* deinterlaced_pixels = deinterlaced_image.bits();
7878

7979
// Loop through the scanlines of the image (even or odd)

0 commit comments

Comments
 (0)