mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2025-12-07 01:06:46 +08:00
psnr tool accept jpeg files as well as raw YUV
BUG=339 TESTED=psnr.exe feet.jpg bluechicken.jpg R=harryjin@google.com Review URL: https://webrtc-codereview.appspot.com/12839006 git-svn-id: http://libyuv.googlecode.com/svn/trunk@1021 16f28f9a-4ce2-e073-06de-1de4eb20be90
This commit is contained in:
parent
81ba94f58a
commit
f939fb7661
@ -1,6 +1,6 @@
|
|||||||
Name: libyuv
|
Name: libyuv
|
||||||
URL: http://code.google.com/p/libyuv/
|
URL: http://code.google.com/p/libyuv/
|
||||||
Version: 1020
|
Version: 1021
|
||||||
License: BSD
|
License: BSD
|
||||||
License File: LICENSE
|
License File: LICENSE
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,6 @@
|
|||||||
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
|
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
|
||||||
#define INCLUDE_LIBYUV_VERSION_H_
|
#define INCLUDE_LIBYUV_VERSION_H_
|
||||||
|
|
||||||
#define LIBYUV_VERSION 1020
|
#define LIBYUV_VERSION 1021
|
||||||
|
|
||||||
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
|
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
|
||||||
|
|||||||
@ -116,7 +116,15 @@
|
|||||||
'LIBYUV_DISABLE_NEON'
|
'LIBYUV_DISABLE_NEON'
|
||||||
],
|
],
|
||||||
}],
|
}],
|
||||||
|
[ 'OS != "ios"', {
|
||||||
|
'defines': [
|
||||||
|
'HAVE_JPEG',
|
||||||
|
],
|
||||||
|
}],
|
||||||
], # conditions
|
], # conditions
|
||||||
|
'dependencies': [
|
||||||
|
'libyuv.gyp:libyuv',
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'target_name': 'cpuid',
|
'target_name': 'cpuid',
|
||||||
|
|||||||
@ -32,6 +32,9 @@
|
|||||||
|
|
||||||
#include "./psnr.h"
|
#include "./psnr.h"
|
||||||
#include "./ssim.h"
|
#include "./ssim.h"
|
||||||
|
#ifdef HAVE_JPEG
|
||||||
|
#include "libyuv/convert.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
struct metric {
|
struct metric {
|
||||||
double y, u, v, all;
|
double y, u, v, all;
|
||||||
@ -75,6 +78,29 @@ bool ExtractResolutionFromFilename(const char* name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_JPEG
|
||||||
|
// Try parsing file as a jpeg.
|
||||||
|
FILE* const file_org = fopen(name, "rb");
|
||||||
|
if (file_org == NULL) {
|
||||||
|
fprintf(stderr, "Cannot open %s\n", name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
fseek(file_org, 0, SEEK_END);
|
||||||
|
size_t total_size = ftell(file_org);
|
||||||
|
fseek(file_org, 0, SEEK_SET);
|
||||||
|
uint8* const ch_org = new uint8[total_size];
|
||||||
|
memset(ch_org, 0, total_size);
|
||||||
|
size_t bytes_org = fread(ch_org, sizeof(uint8), total_size, file_org);
|
||||||
|
fclose(file_org);
|
||||||
|
if (bytes_org == total_size) {
|
||||||
|
if (0 == libyuv::MJPGSize(ch_org, total_size, width_ptr, height_ptr)) {
|
||||||
|
delete[] ch_org;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete[] ch_org;
|
||||||
|
#endif // HAVE_JPEG
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,14 +412,50 @@ int main(int argc, const char* argv[]) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
size_t bytes_org = fread(ch_org, sizeof(uint8), total_size, file_org);
|
size_t bytes_org = fread(ch_org, sizeof(uint8), total_size, file_org);
|
||||||
if (bytes_org < total_size)
|
if (bytes_org < total_size) {
|
||||||
|
#ifdef HAVE_JPEG
|
||||||
|
// Try parsing file as a jpeg.
|
||||||
|
uint8* const ch_jpeg = new uint8[bytes_org];
|
||||||
|
memcpy(ch_jpeg, ch_org, bytes_org);
|
||||||
|
|
||||||
|
if (0 != libyuv::MJPGToI420(ch_jpeg, bytes_org,
|
||||||
|
ch_org, image_width,
|
||||||
|
ch_org + y_size, image_width / 2,
|
||||||
|
ch_org + y_size + uv_size, image_width / 2,
|
||||||
|
image_width, image_height,
|
||||||
|
image_width, image_height)) {
|
||||||
|
delete[] ch_jpeg;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
delete[] ch_jpeg;
|
||||||
|
#else
|
||||||
break;
|
break;
|
||||||
|
#endif // HAVE_JPEG
|
||||||
|
}
|
||||||
|
|
||||||
for (int cur_rec = 0; cur_rec < num_rec; ++cur_rec) {
|
for (int cur_rec = 0; cur_rec < num_rec; ++cur_rec) {
|
||||||
size_t bytes_rec = fread(ch_rec, sizeof(uint8),
|
size_t bytes_rec = fread(ch_rec, sizeof(uint8),
|
||||||
total_size, file_rec[cur_rec]);
|
total_size, file_rec[cur_rec]);
|
||||||
if (bytes_rec < total_size)
|
if (bytes_rec < total_size) {
|
||||||
|
#ifdef HAVE_JPEG
|
||||||
|
// Try parsing file as a jpeg.
|
||||||
|
uint8* const ch_jpeg = new uint8[bytes_rec];
|
||||||
|
memcpy(ch_jpeg, ch_rec, bytes_rec);
|
||||||
|
|
||||||
|
if (0 != libyuv::MJPGToI420(ch_jpeg, bytes_rec,
|
||||||
|
ch_rec, image_width,
|
||||||
|
ch_rec + y_size, image_width / 2,
|
||||||
|
ch_rec + y_size + uv_size, image_width / 2,
|
||||||
|
image_width, image_height,
|
||||||
|
image_width, image_height)) {
|
||||||
|
delete[] ch_jpeg;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
delete[] ch_jpeg;
|
||||||
|
#else
|
||||||
break;
|
break;
|
||||||
|
#endif // HAVE_JPEG
|
||||||
|
}
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
printf("%5d", number_of_frames);
|
printf("%5d", number_of_frames);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user