mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1194058 (Part 1) - Add Deinterlacer to allow Downscaler to work with interlaced images. r=tn
This commit is contained in:
parent
0351948a6f
commit
e014eaa3c1
@ -281,5 +281,36 @@ Downscaler::DownscaleInputLine()
|
||||
}
|
||||
}
|
||||
|
||||
Deinterlacer::Deinterlacer(const nsIntSize& aImageSize)
|
||||
: mImageSize(aImageSize)
|
||||
, mBuffer(MakeUnique<uint8_t[]>(mImageSize.width *
|
||||
mImageSize.height *
|
||||
sizeof(uint32_t)))
|
||||
{ }
|
||||
|
||||
uint32_t
|
||||
Deinterlacer::RowSize() const
|
||||
{
|
||||
return mImageSize.width * sizeof(uint32_t);
|
||||
}
|
||||
|
||||
uint8_t*
|
||||
Deinterlacer::RowBuffer(uint32_t aRow)
|
||||
{
|
||||
uint32_t offset = aRow * RowSize();
|
||||
MOZ_ASSERT(offset < mImageSize.width * mImageSize.height * sizeof(uint32_t),
|
||||
"Row is outside of image");
|
||||
return mBuffer.get() + offset;
|
||||
}
|
||||
|
||||
void
|
||||
Deinterlacer::PropagatePassToDownscaler(Downscaler& aDownscaler)
|
||||
{
|
||||
for (int32_t row = 0 ; row < mImageSize.height ; ++row) {
|
||||
memcpy(aDownscaler.RowBuffer(), RowBuffer(row), RowSize());
|
||||
aDownscaler.CommitRow();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace image
|
||||
} // namespace mozilla
|
||||
|
@ -162,6 +162,34 @@ public:
|
||||
|
||||
#endif // MOZ_ENABLE_SKIA
|
||||
|
||||
/**
|
||||
* Deinterlacer is a utility class to allow Downscaler to work with interlaced
|
||||
* images.
|
||||
|
||||
* Since Downscaler needs to receive rows in top-to-bottom or
|
||||
* bottom-to-top order, it can't natively handle interlaced images, in which the
|
||||
* rows arrive in an interleaved order. Deinterlacer solves this problem by
|
||||
* acting as an intermediate buffer that records decoded rows. Unlike
|
||||
* Downscaler, it allows the rows to be written in arbitrary order. After each
|
||||
* pass, calling PropagatePassToDownscaler() will downscale every buffered row
|
||||
* in a single operation. The rows remain in the buffer, so rows that were
|
||||
* written in one pass will be included in subsequent passes.
|
||||
*/
|
||||
class Deinterlacer
|
||||
{
|
||||
public:
|
||||
explicit Deinterlacer(const nsIntSize& aImageSize);
|
||||
|
||||
uint8_t* RowBuffer(uint32_t aRow);
|
||||
void PropagatePassToDownscaler(Downscaler& aDownscaler);
|
||||
|
||||
private:
|
||||
uint32_t RowSize() const;
|
||||
|
||||
nsIntSize mImageSize;
|
||||
UniquePtr<uint8_t[]> mBuffer;
|
||||
};
|
||||
|
||||
} // namespace image
|
||||
} // namespace mozilla
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user