From 95c29d53f2db1d2076a7028fde7e156ac221368e Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Tue, 30 Apr 2013 21:37:14 +0000 Subject: [PATCH] Accept negative values to mirror BUG=220 TEST=out\Debug\convert.exe faces_1280x720_ARGB.raw -s 1280 -720 faces_640x360_P420.yuv Review URL: https://webrtc-codereview.appspot.com/1376004 git-svn-id: http://libyuv.googlecode.com/svn/trunk@681 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- README.chromium | 2 +- include/libyuv/version.h | 2 +- util/convert.cc | 19 ++++++++++++------- util/psnr_main.cc | 2 +- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/README.chromium b/README.chromium index 037cb37d1..ba59592ab 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 680 +Version: 681 License: BSD License File: LICENSE diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 27bc54153..1e59bc32b 100644 --- a/include/libyuv/version.h +++ b/include/libyuv/version.h @@ -11,6 +11,6 @@ #ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT #define INCLUDE_LIBYUV_VERSION_H_ -#define LIBYUV_VERSION 680 +#define LIBYUV_VERSION 681 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/util/convert.cc b/util/convert.cc index f90645df9..599ca6267 100644 --- a/util/convert.cc +++ b/util/convert.cc @@ -34,6 +34,10 @@ int num_skip_org = 0; // Number of frames to skip in original. int num_frames = 0; // Number of frames to convert. int filter = 1; // Bilinear filter for scaling. +static __inline uint32 Abs(int32 v) { + return v >= 0 ? v : -v; +} + // Parse PYUV format. ie name.1920x800_24Hz_P420.yuv bool ExtractResolutionFromFilename(const char* name, int* width_ptr, @@ -57,7 +61,8 @@ void PrintHelp(const char * program) { printf(" -s .... specify source resolution. " "Optional if name contains\n" " resolution (ie. " - "name.1920x800_24Hz_P420.yuv)\n"); + "name.1920x800_24Hz_P420.yuv)\n" + " Negative value mirrors.\n"); printf(" -d .... specify destination resolution.\n"); printf(" -f ............ 0 = point, 1 = bilinear (default).\n"); printf(" -skip ....... Number of frame to skip of src_argb\n"); @@ -118,7 +123,7 @@ void ParseOptions(int argc, const char* argv[]) { bool rec_res_avail = ExtractResolutionFromFilename(argv[fileindex_rec], &rec_width, &rec_height); - if (image_width <= 0 || image_height <= 0) { + if (image_width == 0 || image_height == 0) { if (org_res_avail) { image_width = org_width; image_height = org_height; @@ -130,13 +135,13 @@ void ParseOptions(int argc, const char* argv[]) { PrintHelp(argv[0]); } } - if (dst_width <= 0 || dst_height <= 0) { + if (dst_width == 0 || dst_height == 0) { if (rec_res_avail) { dst_width = rec_width; dst_height = rec_height; } else { - dst_width = image_width; - dst_height = image_height; + dst_width = Abs(image_width); + dst_height = Abs(image_height); } } } @@ -167,7 +172,7 @@ int main(int argc, const char* argv[]) { } } - const int org_size = image_width * image_height * 4; // ARGB + const int org_size = Abs(image_width) * Abs(image_height) * 4; // ARGB const int dst_size = dst_width * dst_height * 4; // ARGB scaled const int y_size = dst_width * dst_height; const int uv_size = (dst_width + 1) / 2 * (dst_height + 1) / 2; @@ -212,7 +217,7 @@ int main(int argc, const char* argv[]) { break; for (int cur_rec = 0; cur_rec < num_rec; ++cur_rec) { - libyuv::ARGBScale(ch_org, image_width * 4, + libyuv::ARGBScale(ch_org, Abs(image_width) * 4, image_width, image_height, ch_dst, dst_width * 4, dst_width, dst_height, diff --git a/util/psnr_main.cc b/util/psnr_main.cc index 314ec54f6..35e688086 100644 --- a/util/psnr_main.cc +++ b/util/psnr_main.cc @@ -172,7 +172,7 @@ void ParseOptions(int argc, const char* argv[]) { fprintf(stderr, "Number of frames incorrect\n"); PrintHelp(argv[0]); } - if (image_width <= 0 || image_height <= 0) { + if (image_width == 0 || image_height == 0) { int org_width, org_height; int rec_width, rec_height; bool org_res_avail = ExtractResolutionFromFilename(argv[fileindex_org],