Skip to content

Commit

Permalink
fix text not rendering in transition vqm
Browse files Browse the repository at this point in the history
  • Loading branch information
ddennedy committed Oct 18, 2024
1 parent dfa87f2 commit 965dd49
Showing 1 changed file with 20 additions and 54 deletions.
74 changes: 20 additions & 54 deletions src/modules/qt/transition_vqm.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* transition_vqm.c -- video quality measurement
* Copyright (c) 2012 Dan Dennedy <[email protected]>
* Copyright (c) 2012-2024 Dan Dennedy <[email protected]>
* Core psnr and ssim routines based on code from
* qsnr (C) 2010 E. Oriani, ema <AT> fastwebnet <DOT> it
*
Expand Down Expand Up @@ -148,76 +148,42 @@ static int get_image(mlt_frame a_frame,
mlt_frame_get_image(a_frame, image, format, width, height, 1);

// convert mlt image to qimage
QImage img(*width, *height, QImage::Format_ARGB32);
int y = *height + 1;
uint8_t *src = *image;
while (--y) {
QRgb *dst = (QRgb *) img.scanLine(*height - y);
int x = *width + 1;
while (--x) {
*dst++ = qRgba(src[0], src[1], src[2], 255);
src += 4;
}
}
QImage img;
convert_mlt_to_qimage_rgba(*image, &img, *width, *height);

// setup Qt drawing
QPainter painter;
painter.begin(&img);
QPainter painter(&img);
painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
| QPainter::HighQualityAntialiasing
#endif
);
// draw some stuff with Qt
QPalette palette;
QFont font;
QString s;
font.setBold(true);
font.setPointSize(30 * *height / 1080);
painter.setPen(QColor("black"));
painter.setPen(Qt::black);
painter.drawLine(0, *height / 2 + 1, *width, *height / 2);
painter.setPen(QColor("white"));
painter.setPen(Qt::white);
painter.drawLine(0, *height / 2 - 1, *width, *height / 2);
painter.setFont(font);
s.asprintf("Frame: %05d\nPSNR: %05.2f (Y) %05.2f (Cb) %05.2f (Cr)\nSSIM: %5.3f (Y) %5.3f "
"(Cb) %5.3f (Cr)",
mlt_frame_get_position(a_frame),
psnr[0],
psnr[1],
psnr[2],
ssim[0],
ssim[1],
ssim[2]);
painter.setPen(QColor("black"));
painter.drawText(52, *height * 8 / 10 + 2, *width, *height, 0, s);
painter.setPen(QColor("white"));
painter.drawText(50, *height * 8 / 10, *width, *height, 0, s);
auto s = QString::asprintf("Frame: %05d\nPSNR: %05.2f (Y) %05.2f (Cb) %05.2f (Cr)\nSSIM: "
"%5.3f (Y) %5.3f (Cb) %5.3f (Cr)",
mlt_frame_get_position(a_frame),
psnr[0],
psnr[1],
psnr[2],
ssim[0],
ssim[1],
ssim[2]);
painter.setPen(Qt::black);
painter.drawText(52, *height * 8 / 10 + 2, s);
painter.setPen(Qt::white);
painter.drawText(50, *height * 8 / 10, s);

// finish Qt drawing
painter.end();
window_size = mlt_image_format_size(*format, *width, *height, NULL);
uint8_t *dst = (uint8_t *) mlt_pool_alloc(window_size);
mlt_properties_set_data(MLT_FRAME_PROPERTIES(a_frame),
"image",
dst,
window_size,
mlt_pool_release,
NULL);
*image = dst;

// convert qimage to mlt
y = *height + 1;
while (--y) {
QRgb *src = (QRgb *) img.scanLine(*height - y);
int x = *width + 1;
while (--x) {
*dst++ = qRed(*src);
*dst++ = qGreen(*src);
*dst++ = qBlue(*src);
*dst++ = qAlpha(*src);
src++;
}
}
convert_qimage_to_mlt_rgba(&img, *image, *width, *height);

return 0;
}
Expand Down

0 comments on commit 965dd49

Please sign in to comment.