2011-08-26 17:38:09 +00:00
|
|
|
/*
|
2012-02-06 10:11:25 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-08-26 17:38:09 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2013-05-27 08:02:22 +00:00
|
|
|
#include "webrtc/test/testsupport/metrics/video_metrics.h"
|
2011-12-05 13:03:38 +00:00
|
|
|
|
2013-08-05 16:22:53 +00:00
|
|
|
#include <assert.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
2013-01-26 16:36:40 +00:00
|
|
|
#include <algorithm> // min_element, max_element
|
2016-03-02 03:41:34 -08:00
|
|
|
#include <memory>
|
2011-09-12 13:45:39 +00:00
|
|
|
|
2017-01-10 07:44:26 -08:00
|
|
|
#include "webrtc/api/video/i420_buffer.h"
|
|
|
|
|
#include "webrtc/api/video/video_frame.h"
|
2013-05-27 08:02:22 +00:00
|
|
|
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
2016-09-30 04:14:07 -07:00
|
|
|
#include "webrtc/test/frame_utils.h"
|
Reland of Update test code to use I420Buffer when writing pixel data. (patchset #1 id:1 of https://codereview.webrtc.org/2343083002/ )
Reason for revert:
Will fix android build failure.
Original issue's description:
> Revert of Update test code to use I420Buffer when writing pixel data. (patchset #2 id:140001 of https://codereview.webrtc.org/2342783003/ )
>
> Reason for revert:
> I was too impatient; this made android builds fail instead. See https://build.chromium.org/p/client.webrtc/builders/Linux32%20ARM/builds/585/steps/compile/logs/stdio
>
> Original issue's description:
> > Reland of Update test code to use I420Buffer when writing pixel data. (patchset #1 id:1 of https://codereview.webrtc.org/2342123003/ )
> >
> > Reason for revert:
> > Intending to fix problem and reland.
> >
> > Original issue's description:
> > > Revert of Update test code to use I420Buffer when writing pixel data. (patchset #5 id:80001 of https://codereview.webrtc.org/2333373007/ )
> > >
> > > Reason for revert:
> > > Fails 64-bit windows builds, it turns out I missed some of the needed int/size_t casts. Example https://build.chromium.org/p/client.webrtc/waterfall?builder=Win64%20Release
> > >
> > > Hope our windows try bots get back in working shape soon.
> > >
> > > Original issue's description:
> > > > Update test code to use I420Buffer when writing pixel data.
> > > >
> > > > VideoFrameBuffer and VideoFrame will become immutable.
> > > >
> > > > BUG=webrtc:5921
> > > > R=magjed@webrtc.org, phoglund@webrtc.org
> > > >
> > > > Committed: https://crrev.com/280ad1514e44bf6717e5871526dd4632f759eb3d
> > > > Cr-Commit-Position: refs/heads/master@{#14249}
> > >
> > > TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:5921
> > >
> > > Committed: https://crrev.com/fbf14607267adf03d235273283ca452a1e564861
> > > Cr-Commit-Position: refs/heads/master@{#14251}
> >
> > TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> > # Skipping CQ checks because original CL landed less than 1 days ago.
> > NOPRESUBMIT=true
> > NOTREECHECKS=true
> > NOTRY=true
> > BUG=webrtc:5921
> >
> > Committed: https://crrev.com/d21534a8cfe636bbcf3d7bb151945590abc92b2a
> > Cr-Commit-Position: refs/heads/master@{#14258}
>
> TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5921
>
> Committed: https://crrev.com/3011627142bccdd73fce9fec854abb1f6b02b5c1
> Cr-Commit-Position: refs/heads/master@{#14259}
TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
BUG=webrtc:5921
Review-Url: https://codereview.webrtc.org/2347863002
Cr-Commit-Position: refs/heads/master@{#14283}
2016-09-19 00:34:46 -07:00
|
|
|
#include "libyuv/convert.h"
|
2012-01-04 08:09:32 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
namespace test {
|
2011-09-12 13:45:39 +00:00
|
|
|
|
2012-11-29 10:08:16 +00:00
|
|
|
// Copy here so our callers won't need to include libyuv for this constant.
|
2012-12-13 10:15:06 +00:00
|
|
|
double kMetricsPerfectPSNR = kPerfectPSNR;
|
2012-11-29 10:08:16 +00:00
|
|
|
|
2012-11-02 22:36:14 +00:00
|
|
|
// Used for calculating min and max values.
|
2013-01-26 16:36:40 +00:00
|
|
|
static bool LessForFrameResultValue(const FrameResult& s1,
|
|
|
|
|
const FrameResult& s2) {
|
|
|
|
|
return s1.value < s2.value;
|
2011-09-12 13:45:39 +00:00
|
|
|
}
|
2011-08-26 17:38:09 +00:00
|
|
|
|
2012-01-04 08:09:32 +00:00
|
|
|
enum VideoMetricsType { kPSNR, kSSIM, kBoth };
|
|
|
|
|
|
|
|
|
|
// Calculates metrics for a frame and adds statistics to the result for it.
|
|
|
|
|
void CalculateFrame(VideoMetricsType video_metrics_type,
|
2017-06-01 10:02:26 -07:00
|
|
|
const I420BufferInterface& ref,
|
|
|
|
|
const I420BufferInterface& test,
|
2012-01-04 08:09:32 +00:00
|
|
|
int frame_number,
|
|
|
|
|
QualityMetricsResult* result) {
|
2012-02-21 19:46:33 +00:00
|
|
|
FrameResult frame_result = {0, 0};
|
2012-01-04 08:09:32 +00:00
|
|
|
frame_result.frame_number = frame_number;
|
|
|
|
|
switch (video_metrics_type) {
|
|
|
|
|
case kPSNR:
|
2012-11-02 22:36:14 +00:00
|
|
|
frame_result.value = I420PSNR(ref, test);
|
2012-01-04 08:09:32 +00:00
|
|
|
break;
|
|
|
|
|
case kSSIM:
|
2012-11-02 22:36:14 +00:00
|
|
|
frame_result.value = I420SSIM(ref, test);
|
2012-01-04 08:09:32 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
assert(false);
|
|
|
|
|
}
|
|
|
|
|
result->frames.push_back(frame_result);
|
2011-08-26 17:38:09 +00:00
|
|
|
}
|
|
|
|
|
|
2012-01-04 08:09:32 +00:00
|
|
|
// Calculates average, min and max values for the supplied struct, if non-NULL.
|
|
|
|
|
void CalculateStats(QualityMetricsResult* result) {
|
|
|
|
|
if (result == NULL || result->frames.size() == 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2012-11-02 22:36:14 +00:00
|
|
|
// Calculate average.
|
2012-01-04 08:09:32 +00:00
|
|
|
std::vector<FrameResult>::iterator iter;
|
|
|
|
|
double metrics_values_sum = 0.0;
|
|
|
|
|
for (iter = result->frames.begin(); iter != result->frames.end(); ++iter) {
|
|
|
|
|
metrics_values_sum += iter->value;
|
|
|
|
|
}
|
|
|
|
|
result->average = metrics_values_sum / result->frames.size();
|
|
|
|
|
|
2012-11-02 22:36:14 +00:00
|
|
|
// Calculate min/max statistics.
|
2012-02-21 19:46:33 +00:00
|
|
|
iter = std::min_element(result->frames.begin(), result->frames.end(),
|
2012-01-04 08:09:32 +00:00
|
|
|
LessForFrameResultValue);
|
|
|
|
|
result->min = iter->value;
|
|
|
|
|
result->min_frame_number = iter->frame_number;
|
2012-02-21 19:46:33 +00:00
|
|
|
iter = std::max_element(result->frames.begin(), result->frames.end(),
|
2012-01-04 08:09:32 +00:00
|
|
|
LessForFrameResultValue);
|
|
|
|
|
result->max = iter->value;
|
|
|
|
|
result->max_frame_number = iter->frame_number;
|
2011-08-26 17:38:09 +00:00
|
|
|
}
|
|
|
|
|
|
2012-01-04 08:09:32 +00:00
|
|
|
// Single method that handles all combinations of video metrics calculation, to
|
|
|
|
|
// minimize code duplication. Either psnr_result or ssim_result may be NULL,
|
|
|
|
|
// depending on which VideoMetricsType is targeted.
|
|
|
|
|
int CalculateMetrics(VideoMetricsType video_metrics_type,
|
|
|
|
|
const char* ref_filename,
|
|
|
|
|
const char* test_filename,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
QualityMetricsResult* psnr_result,
|
|
|
|
|
QualityMetricsResult* ssim_result) {
|
|
|
|
|
assert(ref_filename != NULL);
|
|
|
|
|
assert(test_filename != NULL);
|
|
|
|
|
assert(width > 0);
|
|
|
|
|
assert(height > 0);
|
|
|
|
|
|
|
|
|
|
FILE* ref_fp = fopen(ref_filename, "rb");
|
|
|
|
|
if (ref_fp == NULL) {
|
2012-11-02 22:36:14 +00:00
|
|
|
// Cannot open reference file.
|
2012-01-04 08:09:32 +00:00
|
|
|
fprintf(stderr, "Cannot open file %s\n", ref_filename);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
FILE* test_fp = fopen(test_filename, "rb");
|
|
|
|
|
if (test_fp == NULL) {
|
2012-11-02 22:36:14 +00:00
|
|
|
// Cannot open test file.
|
2012-01-04 08:09:32 +00:00
|
|
|
fprintf(stderr, "Cannot open file %s\n", test_filename);
|
|
|
|
|
fclose(ref_fp);
|
|
|
|
|
return -2;
|
|
|
|
|
}
|
|
|
|
|
int frame_number = 0;
|
|
|
|
|
|
2012-11-02 22:36:14 +00:00
|
|
|
// Read reference and test frames.
|
2016-09-30 04:14:07 -07:00
|
|
|
for (;;) {
|
|
|
|
|
rtc::scoped_refptr<I420Buffer> ref_i420_buffer(
|
|
|
|
|
test::ReadI420Buffer(width, height, ref_fp));
|
|
|
|
|
if (!ref_i420_buffer)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
rtc::scoped_refptr<I420Buffer> test_i420_buffer(
|
|
|
|
|
test::ReadI420Buffer(width, height, test_fp));
|
|
|
|
|
|
|
|
|
|
if (!test_i420_buffer)
|
|
|
|
|
break;
|
Reland of Update test code to use I420Buffer when writing pixel data. (patchset #1 id:1 of https://codereview.webrtc.org/2343083002/ )
Reason for revert:
Will fix android build failure.
Original issue's description:
> Revert of Update test code to use I420Buffer when writing pixel data. (patchset #2 id:140001 of https://codereview.webrtc.org/2342783003/ )
>
> Reason for revert:
> I was too impatient; this made android builds fail instead. See https://build.chromium.org/p/client.webrtc/builders/Linux32%20ARM/builds/585/steps/compile/logs/stdio
>
> Original issue's description:
> > Reland of Update test code to use I420Buffer when writing pixel data. (patchset #1 id:1 of https://codereview.webrtc.org/2342123003/ )
> >
> > Reason for revert:
> > Intending to fix problem and reland.
> >
> > Original issue's description:
> > > Revert of Update test code to use I420Buffer when writing pixel data. (patchset #5 id:80001 of https://codereview.webrtc.org/2333373007/ )
> > >
> > > Reason for revert:
> > > Fails 64-bit windows builds, it turns out I missed some of the needed int/size_t casts. Example https://build.chromium.org/p/client.webrtc/waterfall?builder=Win64%20Release
> > >
> > > Hope our windows try bots get back in working shape soon.
> > >
> > > Original issue's description:
> > > > Update test code to use I420Buffer when writing pixel data.
> > > >
> > > > VideoFrameBuffer and VideoFrame will become immutable.
> > > >
> > > > BUG=webrtc:5921
> > > > R=magjed@webrtc.org, phoglund@webrtc.org
> > > >
> > > > Committed: https://crrev.com/280ad1514e44bf6717e5871526dd4632f759eb3d
> > > > Cr-Commit-Position: refs/heads/master@{#14249}
> > >
> > > TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:5921
> > >
> > > Committed: https://crrev.com/fbf14607267adf03d235273283ca452a1e564861
> > > Cr-Commit-Position: refs/heads/master@{#14251}
> >
> > TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> > # Skipping CQ checks because original CL landed less than 1 days ago.
> > NOPRESUBMIT=true
> > NOTREECHECKS=true
> > NOTRY=true
> > BUG=webrtc:5921
> >
> > Committed: https://crrev.com/d21534a8cfe636bbcf3d7bb151945590abc92b2a
> > Cr-Commit-Position: refs/heads/master@{#14258}
>
> TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5921
>
> Committed: https://crrev.com/3011627142bccdd73fce9fec854abb1f6b02b5c1
> Cr-Commit-Position: refs/heads/master@{#14259}
TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
BUG=webrtc:5921
Review-Url: https://codereview.webrtc.org/2347863002
Cr-Commit-Position: refs/heads/master@{#14283}
2016-09-19 00:34:46 -07:00
|
|
|
|
2012-01-04 08:09:32 +00:00
|
|
|
switch (video_metrics_type) {
|
|
|
|
|
case kPSNR:
|
Reland of Update test code to use I420Buffer when writing pixel data. (patchset #1 id:1 of https://codereview.webrtc.org/2343083002/ )
Reason for revert:
Will fix android build failure.
Original issue's description:
> Revert of Update test code to use I420Buffer when writing pixel data. (patchset #2 id:140001 of https://codereview.webrtc.org/2342783003/ )
>
> Reason for revert:
> I was too impatient; this made android builds fail instead. See https://build.chromium.org/p/client.webrtc/builders/Linux32%20ARM/builds/585/steps/compile/logs/stdio
>
> Original issue's description:
> > Reland of Update test code to use I420Buffer when writing pixel data. (patchset #1 id:1 of https://codereview.webrtc.org/2342123003/ )
> >
> > Reason for revert:
> > Intending to fix problem and reland.
> >
> > Original issue's description:
> > > Revert of Update test code to use I420Buffer when writing pixel data. (patchset #5 id:80001 of https://codereview.webrtc.org/2333373007/ )
> > >
> > > Reason for revert:
> > > Fails 64-bit windows builds, it turns out I missed some of the needed int/size_t casts. Example https://build.chromium.org/p/client.webrtc/waterfall?builder=Win64%20Release
> > >
> > > Hope our windows try bots get back in working shape soon.
> > >
> > > Original issue's description:
> > > > Update test code to use I420Buffer when writing pixel data.
> > > >
> > > > VideoFrameBuffer and VideoFrame will become immutable.
> > > >
> > > > BUG=webrtc:5921
> > > > R=magjed@webrtc.org, phoglund@webrtc.org
> > > >
> > > > Committed: https://crrev.com/280ad1514e44bf6717e5871526dd4632f759eb3d
> > > > Cr-Commit-Position: refs/heads/master@{#14249}
> > >
> > > TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:5921
> > >
> > > Committed: https://crrev.com/fbf14607267adf03d235273283ca452a1e564861
> > > Cr-Commit-Position: refs/heads/master@{#14251}
> >
> > TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> > # Skipping CQ checks because original CL landed less than 1 days ago.
> > NOPRESUBMIT=true
> > NOTREECHECKS=true
> > NOTRY=true
> > BUG=webrtc:5921
> >
> > Committed: https://crrev.com/d21534a8cfe636bbcf3d7bb151945590abc92b2a
> > Cr-Commit-Position: refs/heads/master@{#14258}
>
> TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5921
>
> Committed: https://crrev.com/3011627142bccdd73fce9fec854abb1f6b02b5c1
> Cr-Commit-Position: refs/heads/master@{#14259}
TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
BUG=webrtc:5921
Review-Url: https://codereview.webrtc.org/2347863002
Cr-Commit-Position: refs/heads/master@{#14283}
2016-09-19 00:34:46 -07:00
|
|
|
CalculateFrame(kPSNR, *ref_i420_buffer, *test_i420_buffer, frame_number,
|
2012-01-04 08:09:32 +00:00
|
|
|
psnr_result);
|
|
|
|
|
break;
|
|
|
|
|
case kSSIM:
|
Reland of Update test code to use I420Buffer when writing pixel data. (patchset #1 id:1 of https://codereview.webrtc.org/2343083002/ )
Reason for revert:
Will fix android build failure.
Original issue's description:
> Revert of Update test code to use I420Buffer when writing pixel data. (patchset #2 id:140001 of https://codereview.webrtc.org/2342783003/ )
>
> Reason for revert:
> I was too impatient; this made android builds fail instead. See https://build.chromium.org/p/client.webrtc/builders/Linux32%20ARM/builds/585/steps/compile/logs/stdio
>
> Original issue's description:
> > Reland of Update test code to use I420Buffer when writing pixel data. (patchset #1 id:1 of https://codereview.webrtc.org/2342123003/ )
> >
> > Reason for revert:
> > Intending to fix problem and reland.
> >
> > Original issue's description:
> > > Revert of Update test code to use I420Buffer when writing pixel data. (patchset #5 id:80001 of https://codereview.webrtc.org/2333373007/ )
> > >
> > > Reason for revert:
> > > Fails 64-bit windows builds, it turns out I missed some of the needed int/size_t casts. Example https://build.chromium.org/p/client.webrtc/waterfall?builder=Win64%20Release
> > >
> > > Hope our windows try bots get back in working shape soon.
> > >
> > > Original issue's description:
> > > > Update test code to use I420Buffer when writing pixel data.
> > > >
> > > > VideoFrameBuffer and VideoFrame will become immutable.
> > > >
> > > > BUG=webrtc:5921
> > > > R=magjed@webrtc.org, phoglund@webrtc.org
> > > >
> > > > Committed: https://crrev.com/280ad1514e44bf6717e5871526dd4632f759eb3d
> > > > Cr-Commit-Position: refs/heads/master@{#14249}
> > >
> > > TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:5921
> > >
> > > Committed: https://crrev.com/fbf14607267adf03d235273283ca452a1e564861
> > > Cr-Commit-Position: refs/heads/master@{#14251}
> >
> > TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> > # Skipping CQ checks because original CL landed less than 1 days ago.
> > NOPRESUBMIT=true
> > NOTREECHECKS=true
> > NOTRY=true
> > BUG=webrtc:5921
> >
> > Committed: https://crrev.com/d21534a8cfe636bbcf3d7bb151945590abc92b2a
> > Cr-Commit-Position: refs/heads/master@{#14258}
>
> TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5921
>
> Committed: https://crrev.com/3011627142bccdd73fce9fec854abb1f6b02b5c1
> Cr-Commit-Position: refs/heads/master@{#14259}
TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
BUG=webrtc:5921
Review-Url: https://codereview.webrtc.org/2347863002
Cr-Commit-Position: refs/heads/master@{#14283}
2016-09-19 00:34:46 -07:00
|
|
|
CalculateFrame(kSSIM, *ref_i420_buffer, *test_i420_buffer, frame_number,
|
2012-01-04 08:09:32 +00:00
|
|
|
ssim_result);
|
|
|
|
|
break;
|
|
|
|
|
case kBoth:
|
Reland of Update test code to use I420Buffer when writing pixel data. (patchset #1 id:1 of https://codereview.webrtc.org/2343083002/ )
Reason for revert:
Will fix android build failure.
Original issue's description:
> Revert of Update test code to use I420Buffer when writing pixel data. (patchset #2 id:140001 of https://codereview.webrtc.org/2342783003/ )
>
> Reason for revert:
> I was too impatient; this made android builds fail instead. See https://build.chromium.org/p/client.webrtc/builders/Linux32%20ARM/builds/585/steps/compile/logs/stdio
>
> Original issue's description:
> > Reland of Update test code to use I420Buffer when writing pixel data. (patchset #1 id:1 of https://codereview.webrtc.org/2342123003/ )
> >
> > Reason for revert:
> > Intending to fix problem and reland.
> >
> > Original issue's description:
> > > Revert of Update test code to use I420Buffer when writing pixel data. (patchset #5 id:80001 of https://codereview.webrtc.org/2333373007/ )
> > >
> > > Reason for revert:
> > > Fails 64-bit windows builds, it turns out I missed some of the needed int/size_t casts. Example https://build.chromium.org/p/client.webrtc/waterfall?builder=Win64%20Release
> > >
> > > Hope our windows try bots get back in working shape soon.
> > >
> > > Original issue's description:
> > > > Update test code to use I420Buffer when writing pixel data.
> > > >
> > > > VideoFrameBuffer and VideoFrame will become immutable.
> > > >
> > > > BUG=webrtc:5921
> > > > R=magjed@webrtc.org, phoglund@webrtc.org
> > > >
> > > > Committed: https://crrev.com/280ad1514e44bf6717e5871526dd4632f759eb3d
> > > > Cr-Commit-Position: refs/heads/master@{#14249}
> > >
> > > TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:5921
> > >
> > > Committed: https://crrev.com/fbf14607267adf03d235273283ca452a1e564861
> > > Cr-Commit-Position: refs/heads/master@{#14251}
> >
> > TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> > # Skipping CQ checks because original CL landed less than 1 days ago.
> > NOPRESUBMIT=true
> > NOTREECHECKS=true
> > NOTRY=true
> > BUG=webrtc:5921
> >
> > Committed: https://crrev.com/d21534a8cfe636bbcf3d7bb151945590abc92b2a
> > Cr-Commit-Position: refs/heads/master@{#14258}
>
> TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5921
>
> Committed: https://crrev.com/3011627142bccdd73fce9fec854abb1f6b02b5c1
> Cr-Commit-Position: refs/heads/master@{#14259}
TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
BUG=webrtc:5921
Review-Url: https://codereview.webrtc.org/2347863002
Cr-Commit-Position: refs/heads/master@{#14283}
2016-09-19 00:34:46 -07:00
|
|
|
CalculateFrame(kPSNR, *ref_i420_buffer, *test_i420_buffer, frame_number,
|
2012-01-04 08:09:32 +00:00
|
|
|
psnr_result);
|
Reland of Update test code to use I420Buffer when writing pixel data. (patchset #1 id:1 of https://codereview.webrtc.org/2343083002/ )
Reason for revert:
Will fix android build failure.
Original issue's description:
> Revert of Update test code to use I420Buffer when writing pixel data. (patchset #2 id:140001 of https://codereview.webrtc.org/2342783003/ )
>
> Reason for revert:
> I was too impatient; this made android builds fail instead. See https://build.chromium.org/p/client.webrtc/builders/Linux32%20ARM/builds/585/steps/compile/logs/stdio
>
> Original issue's description:
> > Reland of Update test code to use I420Buffer when writing pixel data. (patchset #1 id:1 of https://codereview.webrtc.org/2342123003/ )
> >
> > Reason for revert:
> > Intending to fix problem and reland.
> >
> > Original issue's description:
> > > Revert of Update test code to use I420Buffer when writing pixel data. (patchset #5 id:80001 of https://codereview.webrtc.org/2333373007/ )
> > >
> > > Reason for revert:
> > > Fails 64-bit windows builds, it turns out I missed some of the needed int/size_t casts. Example https://build.chromium.org/p/client.webrtc/waterfall?builder=Win64%20Release
> > >
> > > Hope our windows try bots get back in working shape soon.
> > >
> > > Original issue's description:
> > > > Update test code to use I420Buffer when writing pixel data.
> > > >
> > > > VideoFrameBuffer and VideoFrame will become immutable.
> > > >
> > > > BUG=webrtc:5921
> > > > R=magjed@webrtc.org, phoglund@webrtc.org
> > > >
> > > > Committed: https://crrev.com/280ad1514e44bf6717e5871526dd4632f759eb3d
> > > > Cr-Commit-Position: refs/heads/master@{#14249}
> > >
> > > TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:5921
> > >
> > > Committed: https://crrev.com/fbf14607267adf03d235273283ca452a1e564861
> > > Cr-Commit-Position: refs/heads/master@{#14251}
> >
> > TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> > # Skipping CQ checks because original CL landed less than 1 days ago.
> > NOPRESUBMIT=true
> > NOTREECHECKS=true
> > NOTRY=true
> > BUG=webrtc:5921
> >
> > Committed: https://crrev.com/d21534a8cfe636bbcf3d7bb151945590abc92b2a
> > Cr-Commit-Position: refs/heads/master@{#14258}
>
> TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5921
>
> Committed: https://crrev.com/3011627142bccdd73fce9fec854abb1f6b02b5c1
> Cr-Commit-Position: refs/heads/master@{#14259}
TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
BUG=webrtc:5921
Review-Url: https://codereview.webrtc.org/2347863002
Cr-Commit-Position: refs/heads/master@{#14283}
2016-09-19 00:34:46 -07:00
|
|
|
CalculateFrame(kSSIM, *ref_i420_buffer, *test_i420_buffer, frame_number,
|
2012-01-04 08:09:32 +00:00
|
|
|
ssim_result);
|
|
|
|
|
break;
|
2011-08-26 17:38:09 +00:00
|
|
|
}
|
2012-01-04 08:09:32 +00:00
|
|
|
frame_number++;
|
|
|
|
|
}
|
|
|
|
|
int return_code = 0;
|
|
|
|
|
if (frame_number == 0) {
|
|
|
|
|
fprintf(stderr, "Tried to measure video metrics from empty files "
|
|
|
|
|
"(reference file: %s test file: %s)\n", ref_filename,
|
|
|
|
|
test_filename);
|
|
|
|
|
return_code = -3;
|
|
|
|
|
} else {
|
|
|
|
|
CalculateStats(psnr_result);
|
|
|
|
|
CalculateStats(ssim_result);
|
|
|
|
|
}
|
|
|
|
|
fclose(ref_fp);
|
|
|
|
|
fclose(test_fp);
|
|
|
|
|
return return_code;
|
2011-08-26 17:38:09 +00:00
|
|
|
}
|
|
|
|
|
|
2012-01-04 08:09:32 +00:00
|
|
|
int I420MetricsFromFiles(const char* ref_filename,
|
|
|
|
|
const char* test_filename,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
QualityMetricsResult* psnr_result,
|
|
|
|
|
QualityMetricsResult* ssim_result) {
|
|
|
|
|
assert(psnr_result != NULL);
|
|
|
|
|
assert(ssim_result != NULL);
|
|
|
|
|
return CalculateMetrics(kBoth, ref_filename, test_filename, width, height,
|
|
|
|
|
psnr_result, ssim_result);
|
2011-08-26 17:38:09 +00:00
|
|
|
}
|
|
|
|
|
|
2012-01-04 08:09:32 +00:00
|
|
|
int I420PSNRFromFiles(const char* ref_filename,
|
|
|
|
|
const char* test_filename,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
QualityMetricsResult* result) {
|
|
|
|
|
assert(result != NULL);
|
|
|
|
|
return CalculateMetrics(kPSNR, ref_filename, test_filename, width, height,
|
|
|
|
|
result, NULL);
|
2011-08-26 17:38:09 +00:00
|
|
|
}
|
|
|
|
|
|
2012-01-04 08:09:32 +00:00
|
|
|
int I420SSIMFromFiles(const char* ref_filename,
|
|
|
|
|
const char* test_filename,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
QualityMetricsResult* result) {
|
|
|
|
|
assert(result != NULL);
|
|
|
|
|
return CalculateMetrics(kSSIM, ref_filename, test_filename, width, height,
|
|
|
|
|
NULL, result);
|
2011-08-26 17:38:09 +00:00
|
|
|
}
|
2012-01-04 08:09:32 +00:00
|
|
|
|
|
|
|
|
} // namespace test
|
|
|
|
|
} // namespace webrtc
|