Delete unused code in webrtc_libyuv.cc.

Delete unused ConvertFromYV12, and dead prototypes ConvertRGB24ToARGB
ConvertNV12ToRGB565. Move Calc16ByteAlignedStride to the test file
where it is used.

BUG=

Review-Url: https://codereview.webrtc.org/2021843002
Cr-Commit-Position: refs/heads/master@{#13003}
This commit is contained in:
nisse 2016-06-02 00:58:35 -07:00 committed by Commit bot
parent 18f9da0286
commit 69adc9c7c0
5 changed files with 18 additions and 115 deletions

View File

@ -51,22 +51,6 @@ const double kPerfectPSNR = 48.0f;
// TODO(wu): Consolidate types into one type throughout WebRtc.
VideoType RawVideoTypeToCommonVideoVideoType(RawVideoType type);
// Align integer values.
// Input:
// - 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);
// Align stride values for I420 Video frames.
// Input:
// - width : Image width.
// - stride_y : Pointer to the stride of the y plane.
// - stride_uv: Pointer to the stride of the u and v planes (setting identical
// values for both).
// Setting 16 byte alignment.
void Calc16ByteAlignedStride(int width, int* stride_y, int* stride_uv);
// Calculate the required buffer size.
// Input:
// - type :The type of the designated video frame.
@ -128,24 +112,6 @@ int ConvertFromI420(const VideoFrame& src_frame,
VideoType dst_video_type,
int dst_sample_size,
uint8_t* dst_frame);
// ConvertFrom YV12.
// Interface - same as above.
int ConvertFromYV12(const VideoFrame& src_frame,
VideoType dst_video_type,
int dst_sample_size,
uint8_t* dst_frame);
// The following list describes designated conversion functions which
// are not covered by the previous general functions.
// Input and output descriptions mostly match the above descriptions, and are
// therefore omitted.
int ConvertRGB24ToARGB(const uint8_t* src_frame,
uint8_t* dst_frame,
int width, int height,
int dst_stride);
int ConvertNV12ToRGB565(const uint8_t* src_frame,
uint8_t* dst_frame,
int width, int height);
// Compute PSNR for an I420 frame (all planes).
// Returns the PSNR in decibel, to a maximum of kInfinitePSNR.

View File

@ -20,6 +20,14 @@
namespace webrtc {
namespace {
void Calc16ByteAlignedStride(int width, int* stride_y, int* stride_uv) {
*stride_y = 16 * ((width + 15) / 16);
*stride_uv = 16 * ((width + 31) / 32);
}
} // Anonymous namespace
class TestLibYuv : public ::testing::Test {
protected:
TestLibYuv();
@ -139,29 +147,6 @@ TEST_F(TestLibYuv, ConvertTest) {
}
j++;
printf("\nConvert #%d I420 <-> YV12\n", j);
std::unique_ptr<uint8_t[]> outYV120Buffer(new uint8_t[frame_length_]);
std::unique_ptr<uint8_t[]> res_i420_buffer(new uint8_t[frame_length_]);
VideoFrame yv12_frame;
EXPECT_EQ(0, ConvertFromI420(orig_frame_, kYV12, 0, outYV120Buffer.get()));
yv12_frame.CreateFrame(outYV120Buffer.get(),
outYV120Buffer.get() + size_y_,
outYV120Buffer.get() + size_y_ + size_uv_,
width_, height_,
width_, (width_ + 1) / 2, (width_ + 1) / 2,
kVideoRotation_0);
EXPECT_EQ(0, ConvertFromYV12(yv12_frame, kI420, 0, res_i420_buffer.get()));
if (fwrite(res_i420_buffer.get(), 1, frame_length_, output_file) !=
frame_length_) {
return;
}
ConvertToI420(kI420, res_i420_buffer.get(), 0, 0, width_, height_, 0,
kVideoRotation_0, &res_i420_frame);
psnr = I420PSNR(&orig_frame_, &res_i420_frame);
EXPECT_EQ(48.0, psnr);
j++;
printf("\nConvert #%d I420 <-> YUY2\n", j);
std::unique_ptr<uint8_t[]> out_yuy2_buffer(new uint8_t[width_ * height_ * 2]);
EXPECT_EQ(0, ConvertFromI420(orig_frame_, kYUY2, 0, out_yuy2_buffer.get()));
@ -269,28 +254,4 @@ TEST_F(TestLibYuv, RotateTest) {
0, kVideoRotation_180, &rotated_res_i420_frame));
}
TEST_F(TestLibYuv, alignment) {
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.
}
TEST_F(TestLibYuv, StrideAlignment) {
int stride_y = 0;
int stride_uv = 0;
int width = 52;
Calc16ByteAlignedStride(width, &stride_y, &stride_uv);
EXPECT_EQ(64, stride_y);
EXPECT_EQ(32, stride_uv);
width = 128;
Calc16ByteAlignedStride(width, &stride_y, &stride_uv);
EXPECT_EQ(128, stride_y);
EXPECT_EQ(64, stride_uv);
width = 127;
Calc16ByteAlignedStride(width, &stride_y, &stride_uv);
EXPECT_EQ(128, stride_y);
EXPECT_EQ(64, stride_uv);
}
} // namespace webrtc

View File

@ -18,8 +18,6 @@
namespace webrtc {
const int k16ByteAlignment = 16;
VideoType RawVideoTypeToCommonVideoVideoType(RawVideoType type) {
switch (type) {
case kVideoI420:
@ -56,16 +54,6 @@ VideoType RawVideoTypeToCommonVideoVideoType(RawVideoType type) {
return kUnknown;
}
int AlignInt(int value, int alignment) {
assert(!((alignment - 1) & alignment));
return ((value + alignment - 1) & ~(alignment - 1));
}
void Calc16ByteAlignedStride(int width, int* stride_y, int* stride_uv) {
*stride_y = AlignInt(width, k16ByteAlignment);
*stride_uv = AlignInt((width + 1) / 2, k16ByteAlignment);
}
size_t CalcBufferSize(VideoType type, int width, int height) {
assert(width >= 0);
assert(height >= 0);
@ -297,24 +285,6 @@ int ConvertFromI420(const VideoFrame& src_frame,
ConvertVideoType(dst_video_type));
}
// TODO(mikhal): Create a designated VideoFrame for non I420.
int ConvertFromYV12(const VideoFrame& src_frame,
VideoType dst_video_type,
int dst_sample_size,
uint8_t* dst_frame) {
// YV12 = Y, V, U
return libyuv::ConvertFromI420(
src_frame.video_frame_buffer()->DataY(),
src_frame.video_frame_buffer()->StrideY(),
src_frame.video_frame_buffer()->DataV(),
src_frame.video_frame_buffer()->StrideV(),
src_frame.video_frame_buffer()->DataU(),
src_frame.video_frame_buffer()->StrideU(),
dst_frame, dst_sample_size,
src_frame.width(), src_frame.height(),
ConvertVideoType(dst_video_type));
}
// Compute PSNR for an I420 frame (all planes)
double I420PSNR(const VideoFrame* ref_frame, const VideoFrame* test_frame) {
if (!ref_frame || !test_frame)

View File

@ -272,8 +272,6 @@ int32_t VideoCaptureImpl::IncomingFrame(
}
}
// TODO(mikhal): Update correct aligned stride values.
//Calc16ByteAlignedStride(target_width, &stride_y, &stride_uv);
// Setting absolute height (in case it was negative).
// In Windows, the image starts bottom left, instead of top left.
// Setting a negative source height, inverts the image (within LibYuv).

View File

@ -21,6 +21,14 @@
namespace webrtc {
namespace {
void Calc16ByteAlignedStride(int width, int* stride_y, int* stride_uv) {
*stride_y = 16 * ((width + 15) / 16);
*stride_uv = 16 * ((width + 31) / 32);
}
} // Anonymous namespace
enum { kMaxWaitEncTimeMs = 100 };
enum { kMaxWaitDecTimeMs = 25 };
@ -132,8 +140,8 @@ class TestVp8Impl : public ::testing::Test {
const int kFramerate = 30;
codec_inst_.maxFramerate = kFramerate;
// Setting aligned stride values.
int stride_uv = 0;
int stride_y = 0;
int stride_uv;
int stride_y;
Calc16ByteAlignedStride(codec_inst_.width, &stride_y, &stride_uv);
EXPECT_EQ(stride_y, 176);
EXPECT_EQ(stride_uv, 96);