various: pixel optimizations

Several things are accomplished in this commit, including:

- Use OIIO instead of our own functions for pixel format conversions
  (cleaner code/less for us to maintain)

- Fold all PixelService functions into the PixelFormat class
  (cleaner code)

- Moved OpenGL pixel definitions to OpenGL classes and out of the
  global classes.

- Add support for RGB buffers as well as RGBA (optimization)
This commit is contained in:
itsmattkc
2020-02-27 13:54:38 +11:00
parent 0624184b18
commit 02ce48d0c6
27 changed files with 491 additions and 564 deletions
+14 -5
View File
@@ -40,7 +40,7 @@ extern "C" {
#include "common/timecodefunctions.h"
#include "ffmpegcommon.h"
#include "render/diskmanager.h"
#include "render/pixelservice.h"
#include "render/pixelformat.h"
FFmpegDecoder::FFmpegDecoder() :
fmt_ctx_(nullptr),
@@ -154,11 +154,20 @@ bool FFmpegDecoder::Open()
// Determine which Olive native pixel format we retrieved
// Note that FFmpeg doesn't support float formats
if (ideal_pix_fmt_ == AV_PIX_FMT_RGBA) {
switch (ideal_pix_fmt_) {
case AV_PIX_FMT_RGB24:
native_pix_fmt_ = PixelFormat::PIX_FMT_RGB8;
break;
case AV_PIX_FMT_RGBA:
native_pix_fmt_ = PixelFormat::PIX_FMT_RGBA8;
} else if (ideal_pix_fmt_ == AV_PIX_FMT_RGBA64) {
break;
case AV_PIX_FMT_RGB48:
native_pix_fmt_ = PixelFormat::PIX_FMT_RGB16U;
break;
case AV_PIX_FMT_RGBA64:
native_pix_fmt_ = PixelFormat::PIX_FMT_RGBA16U;
} else {
break;
default:
// We should never get here, but just in case...
qFatal("Invalid output format");
}
@@ -378,7 +387,7 @@ FramePtr FFmpegDecoder::RetrieveVideo(const rational &timecode)
// Convert frame to RGBA for the rest of the pipeline
uint8_t* output_data = reinterpret_cast<uint8_t*>(working_frame_converted->data());
int output_linesize = working_frame_converted->width() * kRGBAChannels * PixelService::BytesPerChannel(native_pix_fmt_);
int output_linesize = working_frame_converted->width() * PixelFormat::ChannelCount(native_pix_fmt_) * PixelFormat::BytesPerChannel(native_pix_fmt_);
sws_scale(scale_ctx_,
working_frame->data,