From 57261c1920c894d30e0938b791ba87ae8d85c399 Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Thu, 2 Feb 2012 09:18:50 +0000 Subject: [PATCH] change switch statements to return instead of assert fixing warning on missing break. BUG=none TEST=none Review URL: https://webrtc-codereview.appspot.com/382004 git-svn-id: http://libyuv.googlecode.com/svn/trunk@164 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- README.chromium | 2 +- include/libyuv/version.h | 2 +- source/format_conversion.cc | 39 ++++++++++++++++++++----------------- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/README.chromium b/README.chromium index 14b1f700e..ad3a6b338 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 163 +Version: 164 License: BSD License File: LICENSE diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 96c98b4f2..e16b170fc 100644 --- a/include/libyuv/version.h +++ b/include/libyuv/version.h @@ -16,7 +16,7 @@ namespace libyuv { extern "C" { #endif -#define LIBYUV_VERSION 163 +#define LIBYUV_VERSION 164 #ifdef __cplusplus } // extern "C" diff --git a/source/format_conversion.cc b/source/format_conversion.cc index 84d927253..e0be7a00a 100644 --- a/source/format_conversion.cc +++ b/source/format_conversion.cc @@ -10,8 +10,6 @@ #include "libyuv/format_conversion.h" -#include // For assert() - #include "libyuv/basic_types.h" #include "libyuv/cpu_id.h" #include "libyuv/video_common.h" @@ -103,16 +101,14 @@ static uint32 GenerateSelector(int select0, int select1) { static_cast((select1 + 12) << 24); } -static void MakeSelectors(const int blue_index, - const int green_index, - const int red_index, - uint32 dst_fourcc_bayer, - uint32 *index_map) { +static int MakeSelectors(const int blue_index, + const int green_index, + const int red_index, + uint32 dst_fourcc_bayer, + uint32 *index_map) { // Now build a lookup table containing the indices for the four pixels in each // 2x2 Bayer grid. switch (dst_fourcc_bayer) { - default: - assert(false); case FOURCC_BGGR: index_map[0] = GenerateSelector(blue_index, green_index); index_map[1] = GenerateSelector(green_index, red_index); @@ -129,7 +125,10 @@ static void MakeSelectors(const int blue_index, index_map[0] = GenerateSelector(green_index, red_index); index_map[1] = GenerateSelector(blue_index, green_index); break; + default: + return -1; // Bad FourCC } + return 0; } // Converts 32 bit ARGB to Bayer RGB formats. @@ -158,8 +157,10 @@ int ARGBToBayer(const uint8* src_argb, int src_stride_argb, const int green_index = 1; const int red_index = 2; uint32 index_map[2]; - MakeSelectors(blue_index, green_index, red_index, - dst_fourcc_bayer, index_map); + if (MakeSelectors(blue_index, green_index, red_index, + dst_fourcc_bayer, index_map)) { + return -1; // Bad FourCC + } for (int y = 0; y < height; ++y) { ARGBToBayerRow(src_argb, dst_bayer, index_map[y & 1], width); @@ -310,8 +311,6 @@ int BayerToARGB(const uint8* src_bayer, int src_stride_bayer, void (*BayerRow1)(const uint8* src_bayer, int src_stride_bayer, uint8* dst_argb, int pix); switch (src_fourcc_bayer) { - default: - assert(false); case FOURCC_BGGR: BayerRow0 = BayerRowBG; BayerRow1 = BayerRowGR; @@ -328,6 +327,8 @@ int BayerToARGB(const uint8* src_bayer, int src_stride_bayer, BayerRow0 = BayerRowRG; BayerRow1 = BayerRowGB; break; + default: + return -1; // Bad FourCC } for (int y = 0; y < height - 1; y += 2) { @@ -351,7 +352,7 @@ int BayerToI420(const uint8* src_bayer, int src_stride_bayer, int width, int height, uint32 src_fourcc_bayer) { if (width * 4 > kMaxStride) { - return -1; + return -1; // Size too large for row buffer } // Negative height means invert the image. if (height < 0) { @@ -393,8 +394,6 @@ int BayerToI420(const uint8* src_bayer, int src_stride_bayer, } switch (src_fourcc_bayer) { - default: - assert(false); case FOURCC_BGGR: BayerRow0 = BayerRowBG; BayerRow1 = BayerRowGR; @@ -411,6 +410,8 @@ int BayerToI420(const uint8* src_bayer, int src_stride_bayer, BayerRow0 = BayerRowRG; BayerRow1 = BayerRowGB; break; + default: + return -1; // Bad FourCC } for (int y = 0; y < height - 1; y += 2) { @@ -483,8 +484,10 @@ int I420ToBayer(const uint8* src_y, int src_stride_y, const int green_index = 1; const int red_index = 2; uint32 index_map[2]; - MakeSelectors(blue_index, green_index, red_index, - dst_fourcc_bayer, index_map); + if (MakeSelectors(blue_index, green_index, red_index, + dst_fourcc_bayer, index_map)) { + return -1; // Bad FourCC + } for (int y = 0; y < height; ++y) { FastConvertYUVToARGBRow(src_y, src_u, src_v, row, width);