From d36d2606fc7c9d719190676740b4d7b0cc53942f Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Mon, 10 Jun 2013 21:16:31 +0000 Subject: [PATCH] Add -attenuate option to convert util BUG=246 TEST=convert on an unattenuated image R=johannkoenig@google.com Review URL: https://webrtc-codereview.appspot.com/1640005 git-svn-id: http://libyuv.googlecode.com/svn/trunk@723 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- README.chromium | 2 +- include/libyuv/version.h | 2 +- util/convert.cc | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README.chromium b/README.chromium index 8a708a5cd..edc5d82ba 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 721 +Version: 723 License: BSD License File: LICENSE diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 15ece343a..31cf78fc5 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 721 +#define LIBYUV_VERSION 723 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/util/convert.cc b/util/convert.cc index 4780bd4dc..18316ef8e 100644 --- a/util/convert.cc +++ b/util/convert.cc @@ -21,10 +21,13 @@ #include #include "libyuv/convert.h" +#include "libyuv/planar_functions.h" #include "libyuv/scale_argb.h" // options bool verbose = false; +bool attenuate = false; +bool unattenuate = false; int image_width = 0, image_height = 0; // original width and height int dst_width = 0, dst_height = 0; // new width and height int fileindex_org = 0; // argv argument contains the original file name. @@ -67,6 +70,8 @@ void PrintHelp(const char * program) { printf(" -f ............ 0 = point, 1 = bilinear (default).\n"); printf(" -skip ....... Number of frame to skip of src_argb\n"); printf(" -frames .......... Number of frames to convert\n"); + printf(" -attenuate ............. Attenuate the ARGB image\n"); + printf(" -unattenuate ........... Unattenuate the ARGB image\n"); printf(" -v ..................... verbose\n"); printf(" -h ..................... this help\n"); exit(0); @@ -77,6 +82,10 @@ void ParseOptions(int argc, const char* argv[]) { for (int c = 1; c < argc; ++c) { if (!strcmp(argv[c], "-v")) { verbose = true; + } else if (!strcmp(argv[c], "-attenuate")) { + attenuate = true; + } else if (!strcmp(argv[c], "-unattenuate")) { + unattenuate = true; } else if (!strcmp(argv[c], "-h") || !strcmp(argv[c], "-help")) { PrintHelp(argv[0]); } else if (!strcmp(argv[c], "-s") && c + 2 < argc) { @@ -262,6 +271,16 @@ int main(int argc, const char* argv[]) { if (bytes_org < static_cast(org_size)) break; + // TODO(fbarchard): Attenuate doesnt need to know dimensions. + // ARGB attenuate frame + if (org_is_argb && attenuate) { + libyuv::ARGBAttenuate(ch_org, 0, ch_org, 0, org_size / 4, 1); + } + // ARGB unattenuate frame + if (org_is_argb && unattenuate) { + libyuv::ARGBUnattenuate(ch_org, 0, ch_org, 0, org_size / 4, 1); + } + for (int cur_rec = 0; cur_rec < num_rec; ++cur_rec) { // Scale YUV or ARGB frame. if (org_is_yuv) {