Switching to a general align function.
Review URL: https://webrtc-codereview.appspot.com/851005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2847 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
d1e7a9a90c
commit
c7ecc11571
@ -57,11 +57,12 @@ enum VideoRotationMode {
|
||||
kRotate270 = 270,
|
||||
};
|
||||
|
||||
// Align value to 64 bits.
|
||||
// Align integer values.
|
||||
// Input:
|
||||
// - value : Input value to be aligned.
|
||||
// Return value: An aligned to 64 bit form of the input value.
|
||||
int AlignTo64Bit(int value);
|
||||
// - value : Input value to be aligned.
|
||||
// - alignment : Alignment basis (power of 2).
|
||||
// Return value: An aligned form of the input value.
|
||||
int AlignInt(int value, int alignment);
|
||||
|
||||
// Calculate the required buffer size.
|
||||
// Input:
|
||||
|
@ -332,15 +332,10 @@ TEST_F(TestLibYuv, DISABLED_MirrorTest) {
|
||||
}
|
||||
|
||||
TEST_F(TestLibYuv, alignment) {
|
||||
int value = 640;
|
||||
int aligned_value = (value + 63) & ~63;
|
||||
EXPECT_EQ(AlignTo64Bit(value), aligned_value);
|
||||
value = 600;
|
||||
aligned_value = (value + 63) & ~63;
|
||||
EXPECT_EQ(AlignTo64Bit(value), aligned_value);
|
||||
value = 0;
|
||||
aligned_value = (value + 63) & ~63;
|
||||
EXPECT_EQ(AlignTo64Bit(value), aligned_value);
|
||||
int value = 0x3FF; // 1023
|
||||
EXPECT_EQ(0x400, AlignInt(value, 128)); // Low 7 bits are zero.
|
||||
EXPECT_EQ(0x400, AlignInt(value, 64)); // Low 6 bits are zero.
|
||||
EXPECT_EQ(0x400, AlignInt(value, 32)); // Low 5 bits are zero.
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -52,8 +52,9 @@ VideoType RawVideoTypeToCommonVideoVideoType(RawVideoType type) {
|
||||
return kUnknown;
|
||||
}
|
||||
|
||||
int AlignTo64Bit(int value) {
|
||||
return ((value + 63) & ~63);
|
||||
int AlignInt(int value, int alignment) {
|
||||
assert(!((alignment - 1) & alignment));
|
||||
return ((value + alignment - 1) & ~ (alignment - 1));
|
||||
}
|
||||
|
||||
int CalcBufferSize(VideoType type, int width, int height) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user