Commit 57261c19 authored by fbarchard@google.com's avatar fbarchard@google.com

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
parent 0a5da88f
Name: libyuv Name: libyuv
URL: http://code.google.com/p/libyuv/ URL: http://code.google.com/p/libyuv/
Version: 163 Version: 164
License: BSD License: BSD
License File: LICENSE License File: LICENSE
......
...@@ -16,7 +16,7 @@ namespace libyuv { ...@@ -16,7 +16,7 @@ namespace libyuv {
extern "C" { extern "C" {
#endif #endif
#define LIBYUV_VERSION 163 #define LIBYUV_VERSION 164
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
......
...@@ -10,8 +10,6 @@ ...@@ -10,8 +10,6 @@
#include "libyuv/format_conversion.h" #include "libyuv/format_conversion.h"
#include <assert.h> // For assert()
#include "libyuv/basic_types.h" #include "libyuv/basic_types.h"
#include "libyuv/cpu_id.h" #include "libyuv/cpu_id.h"
#include "libyuv/video_common.h" #include "libyuv/video_common.h"
...@@ -103,16 +101,14 @@ static uint32 GenerateSelector(int select0, int select1) { ...@@ -103,16 +101,14 @@ static uint32 GenerateSelector(int select0, int select1) {
static_cast<uint32>((select1 + 12) << 24); static_cast<uint32>((select1 + 12) << 24);
} }
static void MakeSelectors(const int blue_index, static int MakeSelectors(const int blue_index,
const int green_index, const int green_index,
const int red_index, const int red_index,
uint32 dst_fourcc_bayer, uint32 dst_fourcc_bayer,
uint32 *index_map) { uint32 *index_map) {
// Now build a lookup table containing the indices for the four pixels in each // Now build a lookup table containing the indices for the four pixels in each
// 2x2 Bayer grid. // 2x2 Bayer grid.
switch (dst_fourcc_bayer) { switch (dst_fourcc_bayer) {
default:
assert(false);
case FOURCC_BGGR: case FOURCC_BGGR:
index_map[0] = GenerateSelector(blue_index, green_index); index_map[0] = GenerateSelector(blue_index, green_index);
index_map[1] = GenerateSelector(green_index, red_index); index_map[1] = GenerateSelector(green_index, red_index);
...@@ -129,7 +125,10 @@ static void MakeSelectors(const int blue_index, ...@@ -129,7 +125,10 @@ static void MakeSelectors(const int blue_index,
index_map[0] = GenerateSelector(green_index, red_index); index_map[0] = GenerateSelector(green_index, red_index);
index_map[1] = GenerateSelector(blue_index, green_index); index_map[1] = GenerateSelector(blue_index, green_index);
break; break;
default:
return -1; // Bad FourCC
} }
return 0;
} }
// Converts 32 bit ARGB to Bayer RGB formats. // Converts 32 bit ARGB to Bayer RGB formats.
...@@ -158,8 +157,10 @@ int ARGBToBayer(const uint8* src_argb, int src_stride_argb, ...@@ -158,8 +157,10 @@ int ARGBToBayer(const uint8* src_argb, int src_stride_argb,
const int green_index = 1; const int green_index = 1;
const int red_index = 2; const int red_index = 2;
uint32 index_map[2]; uint32 index_map[2];
MakeSelectors(blue_index, green_index, red_index, if (MakeSelectors(blue_index, green_index, red_index,
dst_fourcc_bayer, index_map); dst_fourcc_bayer, index_map)) {
return -1; // Bad FourCC
}
for (int y = 0; y < height; ++y) { for (int y = 0; y < height; ++y) {
ARGBToBayerRow(src_argb, dst_bayer, index_map[y & 1], width); ARGBToBayerRow(src_argb, dst_bayer, index_map[y & 1], width);
...@@ -310,8 +311,6 @@ int BayerToARGB(const uint8* src_bayer, int src_stride_bayer, ...@@ -310,8 +311,6 @@ int BayerToARGB(const uint8* src_bayer, int src_stride_bayer,
void (*BayerRow1)(const uint8* src_bayer, int src_stride_bayer, void (*BayerRow1)(const uint8* src_bayer, int src_stride_bayer,
uint8* dst_argb, int pix); uint8* dst_argb, int pix);
switch (src_fourcc_bayer) { switch (src_fourcc_bayer) {
default:
assert(false);
case FOURCC_BGGR: case FOURCC_BGGR:
BayerRow0 = BayerRowBG; BayerRow0 = BayerRowBG;
BayerRow1 = BayerRowGR; BayerRow1 = BayerRowGR;
...@@ -328,6 +327,8 @@ int BayerToARGB(const uint8* src_bayer, int src_stride_bayer, ...@@ -328,6 +327,8 @@ int BayerToARGB(const uint8* src_bayer, int src_stride_bayer,
BayerRow0 = BayerRowRG; BayerRow0 = BayerRowRG;
BayerRow1 = BayerRowGB; BayerRow1 = BayerRowGB;
break; break;
default:
return -1; // Bad FourCC
} }
for (int y = 0; y < height - 1; y += 2) { for (int y = 0; y < height - 1; y += 2) {
...@@ -351,7 +352,7 @@ int BayerToI420(const uint8* src_bayer, int src_stride_bayer, ...@@ -351,7 +352,7 @@ int BayerToI420(const uint8* src_bayer, int src_stride_bayer,
int width, int height, int width, int height,
uint32 src_fourcc_bayer) { uint32 src_fourcc_bayer) {
if (width * 4 > kMaxStride) { if (width * 4 > kMaxStride) {
return -1; return -1; // Size too large for row buffer
} }
// Negative height means invert the image. // Negative height means invert the image.
if (height < 0) { if (height < 0) {
...@@ -393,8 +394,6 @@ int BayerToI420(const uint8* src_bayer, int src_stride_bayer, ...@@ -393,8 +394,6 @@ int BayerToI420(const uint8* src_bayer, int src_stride_bayer,
} }
switch (src_fourcc_bayer) { switch (src_fourcc_bayer) {
default:
assert(false);
case FOURCC_BGGR: case FOURCC_BGGR:
BayerRow0 = BayerRowBG; BayerRow0 = BayerRowBG;
BayerRow1 = BayerRowGR; BayerRow1 = BayerRowGR;
...@@ -411,6 +410,8 @@ int BayerToI420(const uint8* src_bayer, int src_stride_bayer, ...@@ -411,6 +410,8 @@ int BayerToI420(const uint8* src_bayer, int src_stride_bayer,
BayerRow0 = BayerRowRG; BayerRow0 = BayerRowRG;
BayerRow1 = BayerRowGB; BayerRow1 = BayerRowGB;
break; break;
default:
return -1; // Bad FourCC
} }
for (int y = 0; y < height - 1; y += 2) { for (int y = 0; y < height - 1; y += 2) {
...@@ -483,8 +484,10 @@ int I420ToBayer(const uint8* src_y, int src_stride_y, ...@@ -483,8 +484,10 @@ int I420ToBayer(const uint8* src_y, int src_stride_y,
const int green_index = 1; const int green_index = 1;
const int red_index = 2; const int red_index = 2;
uint32 index_map[2]; uint32 index_map[2];
MakeSelectors(blue_index, green_index, red_index, if (MakeSelectors(blue_index, green_index, red_index,
dst_fourcc_bayer, index_map); dst_fourcc_bayer, index_map)) {
return -1; // Bad FourCC
}
for (int y = 0; y < height; ++y) { for (int y = 0; y < height; ++y) {
FastConvertYUVToARGBRow(src_y, src_u, src_v, row, width); FastConvertYUVToARGBRow(src_y, src_u, src_v, row, width);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment