forked from classilla/tenfourfox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeinterlacer.cpp
More file actions
55 lines (45 loc) · 1.41 KB
/
Deinterlacer.cpp
File metadata and controls
55 lines (45 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "Downscaler.h"
#include "mozilla/UniquePtrExtensions.h"
namespace mozilla {
namespace image {
Deinterlacer::Deinterlacer(const nsIntSize& aImageSize)
: mImageSize(aImageSize)
{
CheckedInt<size_t> bufferSize = mImageSize.width;
bufferSize *= mImageSize.height;
bufferSize *= sizeof(uint32_t);
if (!bufferSize.isValid()) {
return;
}
mBuffer = MakeUniqueFallible<uint8_t[]>(bufferSize.value());
}
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(IsValid(), "Deinterlacer in invalid state");
MOZ_ASSERT(offset < mImageSize.width * mImageSize.height * sizeof(uint32_t),
"Row is outside of image");
return mBuffer.get() + offset;
}
void
Deinterlacer::PropagatePassToDownscaler(Downscaler& aDownscaler)
{
MOZ_ASSERT(IsValid(), "Deinterlacer in invalid state");
for (int32_t row = 0 ; row < mImageSize.height ; ++row) {
memcpy(aDownscaler.RowBuffer(), RowBuffer(row), RowSize());
aDownscaler.CommitRow();
}
}
} // namespace image
} // namespace mozilla