oiiodecoder: implemented workaround for oiio stride bug in versions < 2.1.12

This commit is contained in:
itsmattkc
2020-05-01 01:38:31 +10:00
parent a9208294a0
commit 472030f8f0
2 changed files with 27 additions and 4 deletions
+24 -4
View File
@@ -192,8 +192,7 @@ FramePtr OIIODecoder::RetrieveVideo(const rational &timecode, const int& divider
if (divider == 1) {
// Just a simple copy
buffer_->get_pixels(OIIO::ROI(), buffer_->spec().format, frame->data(), OIIO::AutoStride, frame->linesize_bytes());
BufferToFrame(buffer_, frame);
} else {
@@ -204,8 +203,7 @@ FramePtr OIIODecoder::RetrieveVideo(const rational &timecode, const int& divider
qWarning() << "OIIO resize failed";
}
// Just a simple copy
dst.get_pixels(OIIO::ROI(), dst.spec().format, frame->data(), OIIO::AutoStride, frame->linesize_bytes());
BufferToFrame(&dst, frame);
}
@@ -233,6 +231,28 @@ QString OIIODecoder::GetIndexFilename()
return QString();
}
void OIIODecoder::BufferToFrame(OIIO::ImageBuf *buf, FramePtr frame)
{
#if OIIO_VERSION < 20112
//
// Workaround for OIIO bug that ignores destination stride in versions OLDER than 2.1.12
//
// See more: https://github.com/OpenImageIO/oiio/pull/2487
//
for (int i=0;i<buf->spec().height;i++) {
memcpy(frame->data() + i * frame->linesize_bytes(),
reinterpret_cast<const char*>(buf->localpixels()) + i * buf->scanline_stride(),
frame->width() * PixelFormat::BytesPerPixel(frame->format()));
}
#else
buf->get_pixels(OIIO::ROI(),
buf->spec().format,
frame->data(),
OIIO::AutoStride,
frame->linesize_bytes());
#endif
}
bool OIIODecoder::FileTypeIsSupported(const QString& fn)
{
// We prioritize OIIO over FFmpeg to pick up still images more effectively, but some OIIO decoders (notably OpenJPEG)