Removing some TODO's from libyuv

BUG=1996
R=henrik.lundin@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/2146004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4668 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
mikhal@webrtc.org 2013-09-03 20:06:18 +00:00
parent 2b810bf77b
commit 635b2b88e4
5 changed files with 14 additions and 81 deletions

View File

@ -172,17 +172,6 @@ double I420PSNR(const I420VideoFrame* ref_frame,
// Compute SSIM for an I420 frame (all planes).
double I420SSIM(const I420VideoFrame* ref_frame,
const I420VideoFrame* test_frame);
// TODO(mikhal): Remove these functions and keep only the above functionality.
// Compute PSNR for an I420 buffer (all planes).
// Returns the PSNR in decibel, to a maximum of kInfinitePSNR.
double I420PSNR(const uint8_t* ref_frame,
const uint8_t* test_frame,
int width, int height);
// Compute SSIM for an I420 buffer (all planes).
double I420SSIM(const uint8_t* ref_frame,
const uint8_t* test_frame,
int width, int height);
}
#endif // WEBRTC_COMMON_VIDEO_LIBYUV_INCLUDE_WEBRTC_LIBYUV_H_

View File

@ -211,7 +211,9 @@ TEST_F(TestLibYuv, ConvertTest) {
return;
}
psnr = I420PSNR(orig_buffer_.get(), res_i420_buffer.get(), width_, height_);
ConvertToI420(kI420, res_i420_buffer.get(), 0, 0,
width_, height_, 0, kRotateNone, &res_i420_frame);
psnr = I420PSNR(&orig_frame_, &res_i420_frame);
EXPECT_EQ(48.0, psnr);
j++;

View File

@ -55,7 +55,6 @@ int Scaler::Scale(const I420VideoFrame& src_frame,
// Making sure that destination frame is of sufficient size.
// Aligning stride values based on width.
dst_frame->CreateEmptyFrame(dst_width_, dst_height_,
dst_width_, (dst_width_ + 1) / 2,
(dst_width_ + 1) / 2);
@ -77,7 +76,6 @@ int Scaler::Scale(const I420VideoFrame& src_frame,
libyuv::FilterMode(method_));
}
// TODO(mikhal): Add support for more types.
bool Scaler::SupportedVideoType(VideoType src_video_type,
VideoType dst_video_type) {
if (src_video_type != dst_video_type)

View File

@ -29,9 +29,6 @@ class TestScaler : public ::testing::Test {
FILE* source_file, std::string out_name,
int src_width, int src_height,
int dst_width, int dst_height);
// TODO(mikhal): add a sequence reader to libyuv.
// Computes the sequence average PSNR between an input sequence in
// |input_file| and an output sequence with filename |out_name|. |width| and
// |height| are the frame sizes of both sequences.
@ -163,7 +160,7 @@ TEST_F(TestScaler, DISABLED_ON_ANDROID(PointScaleTest)) {
source_file_, out_name,
width_, height_,
400, 300);
// Dowsample to odd size frame and scale back up.
// Down-sample to odd size frame and scale back up.
out_name = webrtc::test::OutputPath() + "LibYuvTest_PointScale_282_231.yuv";
ScaleSequence(method,
source_file_, out_name,
@ -183,7 +180,7 @@ TEST_F(TestScaler, DISABLED_ON_ANDROID(PointScaleTest)) {
// average PSNR under same conditions.
ASSERT_GT(avg_psnr, 25.8);
ASSERT_EQ(0, fclose(source_file2));
// Upsample to odd size frame and scale back down.
// Up-sample to odd size frame and scale back down.
out_name = webrtc::test::OutputPath() + "LibYuvTest_PointScale_699_531.yuv";
ScaleSequence(method,
source_file_, out_name,
@ -215,7 +212,7 @@ TEST_F(TestScaler, DISABLED_ON_ANDROID(BiLinearScaleTest)) {
source_file_, out_name,
width_, height_,
width_ / 2, height_ / 2);
// Upsample back up and check PSNR.
// Up-sample back up and check PSNR.
source_file2 = fopen(out_name.c_str(), "rb");
out_name = webrtc::test::OutputPath() + "LibYuvTest_BilinearScale_352_288_"
"upfrom_176_144.yuv";
@ -255,7 +252,7 @@ TEST_F(TestScaler, DISABLED_ON_ANDROID(BiLinearScaleTest)) {
source_file_, out_name,
width_, height_,
400, 300);
// Downsample to odd size frame and scale back up.
// Down-sample to odd size frame and scale back up.
out_name = webrtc::test::OutputPath() +
"LibYuvTest_BilinearScale_282_231.yuv";
ScaleSequence(method,
@ -309,7 +306,7 @@ TEST_F(TestScaler, DISABLED_ON_ANDROID(BoxScaleTest)) {
source_file_, out_name,
width_, height_,
width_ / 2, height_ / 2);
// Upsample back up and check PSNR.
// Up-sample back up and check PSNR.
source_file2 = fopen(out_name.c_str(), "rb");
out_name = webrtc::test::OutputPath() + "LibYuvTest_BoxScale_352_288_"
"upfrom_176_144.yuv";
@ -344,7 +341,7 @@ TEST_F(TestScaler, DISABLED_ON_ANDROID(BoxScaleTest)) {
source_file_, out_name,
width_, height_,
400, 300);
// Downsample to odd size frame and scale back up.
// Down-sample to odd size frame and scale back up.
out_name = webrtc::test::OutputPath() + "LibYuvTest_BoxScale_282_231.yuv";
ScaleSequence(method,
source_file_, out_name,
@ -364,7 +361,7 @@ TEST_F(TestScaler, DISABLED_ON_ANDROID(BoxScaleTest)) {
// average PSNR under same conditions.
ASSERT_GT(avg_psnr, 29.7);
ASSERT_EQ(0, fclose(source_file2));
// Upsample to odd size frame and scale back down.
// Up-sample to odd size frame and scale back down.
out_name = webrtc::test::OutputPath() + "LibYuvTest_BoxScale_699_531.yuv";
ScaleSequence(method,
source_file_, out_name,
@ -401,6 +398,7 @@ double TestScaler::ComputeAvgSequencePSNR(FILE* input_file,
int frame_count = 0;
double avg_psnr = 0;
I420VideoFrame in_frame, out_frame;
while (feof(input_file) == 0) {
if ((size_t)required_size !=
fread(input_buffer, 1, required_size, input_file)) {
@ -411,7 +409,9 @@ double TestScaler::ComputeAvgSequencePSNR(FILE* input_file,
break;
}
frame_count++;
double psnr = I420PSNR(input_buffer, output_buffer, width, height);
ConvertFromI420(in_frame, kI420, 0, input_buffer);
ConvertFromI420(out_frame, kI420, 0, output_buffer);
double psnr = I420PSNR(&in_frame, &out_frame);
avg_psnr += psnr;
}
avg_psnr = avg_psnr / frame_count;

View File

@ -383,60 +383,4 @@ double I420SSIM(const I420VideoFrame* ref_frame,
test_frame->stride(kVPlane),
test_frame->width(), test_frame->height());
}
// Compute PSNR for an I420 frame (all planes)
double I420PSNR(const uint8_t* ref_frame,
const uint8_t* test_frame,
int width, int height) {
if (!ref_frame || !test_frame)
return -1;
else if (height < 0 || width < 0)
return -1;
int half_width = (width + 1) >> 1;
int half_height = (height + 1) >> 1;
const uint8_t* src_y_a = ref_frame;
const uint8_t* src_u_a = src_y_a + width * height;
const uint8_t* src_v_a = src_u_a + half_width * half_height;
const uint8_t* src_y_b = test_frame;
const uint8_t* src_u_b = src_y_b + width * height;
const uint8_t* src_v_b = src_u_b + half_width * half_height;
// In the following: stride is determined by width.
double psnr = libyuv::I420Psnr(src_y_a, width,
src_u_a, half_width,
src_v_a, half_width,
src_y_b, width,
src_u_b, half_width,
src_v_b, half_width,
width, height);
// LibYuv sets the max psnr value to 128, we restrict it here.
// In case of 0 mse in one frame, 128 can skew the results significantly.
return (psnr > kPerfectPSNR) ? kPerfectPSNR : psnr;
}
// Compute SSIM for an I420 frame (all planes)
double I420SSIM(const uint8_t* ref_frame,
const uint8_t* test_frame,
int width, int height) {
if (!ref_frame || !test_frame)
return -1;
else if (height < 0 || width < 0)
return -1;
int half_width = (width + 1) >> 1;
int half_height = (height + 1) >> 1;
const uint8_t* src_y_a = ref_frame;
const uint8_t* src_u_a = src_y_a + width * height;
const uint8_t* src_v_a = src_u_a + half_width * half_height;
const uint8_t* src_y_b = test_frame;
const uint8_t* src_u_b = src_y_b + width * height;
const uint8_t* src_v_b = src_u_b + half_width * half_height;
int stride_y = width;
int stride_uv = half_width;
return libyuv::I420Ssim(src_y_a, stride_y,
src_u_a, stride_uv,
src_v_a, stride_uv,
src_y_b, stride_y,
src_u_b, stride_uv,
src_v_b, stride_uv,
width, height);
}
} // namespace webrtc