oiiodecoder: implemented workaround for oiio stride bug in versions < 2.1.12
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -54,6 +54,9 @@ private:
|
||||
#else
|
||||
std::unique_ptr<OIIO::ImageInput> image_;
|
||||
#endif
|
||||
|
||||
static void BufferToFrame(OIIO::ImageBuf* buf, FramePtr frame);
|
||||
|
||||
static bool FileTypeIsSupported(const QString& fn);
|
||||
|
||||
static int GetImageSequenceDigitCount(const QString& filename);
|
||||
|
||||
Reference in New Issue
Block a user