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
URL: http://code.google.com/p/libyuv/
Version: 163
Version: 164
License: BSD
License File: LICENSE
......
......@@ -16,7 +16,7 @@ namespace libyuv {
extern "C" {
#endif
#define LIBYUV_VERSION 163
#define LIBYUV_VERSION 164
#ifdef __cplusplus
} // extern "C"
......
......@@ -10,8 +10,6 @@
#include "libyuv/format_conversion.h"
#include <assert.h> // For assert()
#include "libyuv/basic_types.h"
#include "libyuv/cpu_id.h"
#include "libyuv/video_common.h"
......@@ -103,7 +101,7 @@ static uint32 GenerateSelector(int select0, int select1) {
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 red_index,
uint32 dst_fourcc_bayer,
......@@ -111,8 +109,6 @@ static void MakeSelectors(const int blue_index,
// 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);
......
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