diff --git a/docs/formats.md b/docs/formats.md index 12ea9465e..b0cae5a71 100644 --- a/docs/formats.md +++ b/docs/formats.md @@ -144,13 +144,13 @@ A fourcc provided by capturer, can be thought of string, e.g. "ARGB". On little endian machines, as an int, this would have 'A' in the lowest byte. The FOURCC macro reverses the order: - #define FOURCC(a, b, c, d) (((uint32)(a)) | ((uint32)(b) << 8) | ((uint32)(c) << 16) | ((uint32)(d) << 24)) + #define FOURCC(a, b, c, d) (((uint32_t)(a)) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24)) -So the "ARGB" string, read as an uint32, is +So the "ARGB" string, read as an uint32_t, is FOURCC_ARGB = FOURCC('A', 'R', 'G', 'B') -If you were to read ARGB pixels as uint32's, the alpha would be in the high byte, and the blue in the lowest byte. In memory, these are stored little endian, so 'B' is first, then 'G', 'R' and 'A' last. +If you were to read ARGB pixels as uint32_t's, the alpha would be in the high byte, and the blue in the lowest byte. In memory, these are stored little endian, so 'B' is first, then 'G', 'R' and 'A' last. When calling conversion functions, the names match the FOURCC, so in this case it would be I420ToARGB(). diff --git a/include/libyuv/basic_types.h b/include/libyuv/basic_types.h index 1bea67f2f..c015b493b 100644 --- a/include/libyuv/basic_types.h +++ b/include/libyuv/basic_types.h @@ -11,37 +11,6 @@ #ifndef INCLUDE_LIBYUV_BASIC_TYPES_H_ #define INCLUDE_LIBYUV_BASIC_TYPES_H_ -#include // For size_t and NULL - -#if !defined(INT_TYPES_DEFINED) && !defined(GG_LONGLONG) -#define INT_TYPES_DEFINED - -#if defined(_MSC_VER) && (_MSC_VER < 1600) -#include // for uintptr_t on x86 -typedef unsigned __int64 uint64_t; -typedef __int64 int64_t; -typedef unsigned int uint32_t; -typedef int int32_t; -typedef unsigned short uint16_t; -typedef short int16_t; -typedef unsigned char uint8_t; -typedef signed char int8_t; -#else -#include // for uintptr_t and C99 types -#endif // defined(_MSC_VER) && (_MSC_VER < 1600) -// Types are deprecated. Enable this macro for legacy types. -#ifdef LIBYUV_LEGACY_TYPES -typedef uint64_t uint64; -typedef int64_t int64; -typedef uint32_t uint32; -typedef int32_t int32; -typedef uint16_t uint16; -typedef int16_t int16; -typedef uint8_t uint8; -typedef int8_t int8; -#endif // LIBYUV_LEGACY_TYPES -#endif // INT_TYPES_DEFINED - #if !defined(LIBYUV_API) #if defined(_WIN32) || defined(__CYGWIN__) #if defined(LIBYUV_BUILDING_SHARED_LIBRARY) @@ -60,9 +29,4 @@ typedef int8_t int8; #endif // __GNUC__ #endif // LIBYUV_API -// TODO(fbarchard): Remove bool macros. -#define LIBYUV_BOOL int -#define LIBYUV_FALSE 0 -#define LIBYUV_TRUE 1 - #endif // INCLUDE_LIBYUV_BASIC_TYPES_H_ diff --git a/include/libyuv/compare.h b/include/libyuv/compare.h index 3353ad71c..a8196d792 100644 --- a/include/libyuv/compare.h +++ b/include/libyuv/compare.h @@ -11,6 +11,9 @@ #ifndef INCLUDE_LIBYUV_COMPARE_H_ #define INCLUDE_LIBYUV_COMPARE_H_ +#include +#include + #include "libyuv/basic_types.h" #ifdef __cplusplus diff --git a/include/libyuv/compare_row.h b/include/libyuv/compare_row.h index a08734e90..2a79f2dbd 100644 --- a/include/libyuv/compare_row.h +++ b/include/libyuv/compare_row.h @@ -11,7 +11,9 @@ #ifndef INCLUDE_LIBYUV_COMPARE_ROW_H_ #define INCLUDE_LIBYUV_COMPARE_ROW_H_ -#include "libyuv/basic_types.h" +#include +#include + #include "libyuv/cpu_support.h" #ifdef __cplusplus diff --git a/include/libyuv/convert.h b/include/libyuv/convert.h index 4c4f8f1f9..8828db35f 100644 --- a/include/libyuv/convert.h +++ b/include/libyuv/convert.h @@ -11,6 +11,9 @@ #ifndef INCLUDE_LIBYUV_CONVERT_H_ #define INCLUDE_LIBYUV_CONVERT_H_ +#include +#include + #include "libyuv/basic_types.h" #include "libyuv/rotate.h" // For enum RotationMode. diff --git a/include/libyuv/convert_argb.h b/include/libyuv/convert_argb.h index 5b5056744..053bfde61 100644 --- a/include/libyuv/convert_argb.h +++ b/include/libyuv/convert_argb.h @@ -11,6 +11,9 @@ #ifndef INCLUDE_LIBYUV_CONVERT_ARGB_H_ #define INCLUDE_LIBYUV_CONVERT_ARGB_H_ +#include +#include + #include "libyuv/basic_types.h" #include "libyuv/rotate.h" // For enum RotationMode. diff --git a/include/libyuv/convert_from.h b/include/libyuv/convert_from.h index 32f42a633..e9aa489e8 100644 --- a/include/libyuv/convert_from.h +++ b/include/libyuv/convert_from.h @@ -11,6 +11,8 @@ #ifndef INCLUDE_LIBYUV_CONVERT_FROM_H_ #define INCLUDE_LIBYUV_CONVERT_FROM_H_ +#include + #include "libyuv/basic_types.h" #include "libyuv/rotate.h" diff --git a/include/libyuv/convert_from_argb.h b/include/libyuv/convert_from_argb.h index a2bb3750a..0928bb53f 100644 --- a/include/libyuv/convert_from_argb.h +++ b/include/libyuv/convert_from_argb.h @@ -11,6 +11,8 @@ #ifndef INCLUDE_LIBYUV_CONVERT_FROM_ARGB_H_ #define INCLUDE_LIBYUV_CONVERT_FROM_ARGB_H_ +#include + #include "libyuv/basic_types.h" #ifdef __cplusplus diff --git a/include/libyuv/cpu_id.h b/include/libyuv/cpu_id.h index c6983fb32..cda193d98 100644 --- a/include/libyuv/cpu_id.h +++ b/include/libyuv/cpu_id.h @@ -11,6 +11,8 @@ #ifndef INCLUDE_LIBYUV_CPU_ID_H_ #define INCLUDE_LIBYUV_CPU_ID_H_ +#include + #include "libyuv/basic_types.h" #ifdef __cplusplus diff --git a/include/libyuv/mjpeg_decoder.h b/include/libyuv/mjpeg_decoder.h index 275f8d4c1..3ad11ec79 100644 --- a/include/libyuv/mjpeg_decoder.h +++ b/include/libyuv/mjpeg_decoder.h @@ -11,6 +11,9 @@ #ifndef INCLUDE_LIBYUV_MJPEG_DECODER_H_ #define INCLUDE_LIBYUV_MJPEG_DECODER_H_ +#include +#include + #include "libyuv/basic_types.h" #ifdef __cplusplus @@ -26,7 +29,7 @@ namespace libyuv { extern "C" { #endif -LIBYUV_BOOL ValidateJpeg(const uint8_t* sample, size_t sample_size); +int ValidateJpeg(const uint8_t* sample, size_t sample_size); #ifdef __cplusplus } // extern "C" @@ -81,11 +84,11 @@ class LIBYUV_API MJpegDecoder { // Loads a new frame, reads its headers, and determines the uncompressed // image format. - // Returns LIBYUV_TRUE if image looks valid and format is supported. - // If return value is LIBYUV_TRUE, then the values for all the following + // Returns true if image looks valid and format is supported. + // If return value is true, then the values for all the following // getters are populated. // src_len is the size of the compressed mjpeg frame in bytes. - LIBYUV_BOOL LoadFrame(const uint8_t* src, size_t src_len); + bool LoadFrame(const uint8_t* src, size_t src_len); // Returns width of the last loaded frame in pixels. int GetWidth(); @@ -129,7 +132,7 @@ class LIBYUV_API MJpegDecoder { // Call this after LoadFrame() if you decide you don't want to decode it // after all. - LIBYUV_BOOL UnloadFrame(); + bool UnloadFrame(); // Decodes the entire image into a one-buffer-per-color-component format. // dst_width must match exactly. dst_height must be <= to image height; if @@ -138,16 +141,16 @@ class LIBYUV_API MJpegDecoder { // at least GetComponentSize(i). The pointers in planes are incremented // to point to after the end of the written data. // TODO(fbarchard): Add dst_x, dst_y to allow specific rect to be decoded. - LIBYUV_BOOL DecodeToBuffers(uint8_t** planes, int dst_width, int dst_height); + bool DecodeToBuffers(uint8_t** planes, int dst_width, int dst_height); // Decodes the entire image and passes the data via repeated calls to a // callback function. Each call will get the data for a whole number of // image scanlines. // TODO(fbarchard): Add dst_x, dst_y to allow specific rect to be decoded. - LIBYUV_BOOL DecodeToCallback(CallbackFunction fn, - void* opaque, - int dst_width, - int dst_height); + bool DecodeToCallback(CallbackFunction fn, + void* opaque, + int dst_width, + int dst_height); // The helper function which recognizes the jpeg sub-sampling type. static JpegSubsamplingType JpegSubsamplingTypeHelper( @@ -159,11 +162,11 @@ class LIBYUV_API MJpegDecoder { void AllocOutputBuffers(int num_outbufs); void DestroyOutputBuffers(); - LIBYUV_BOOL StartDecode(); - LIBYUV_BOOL FinishDecode(); + bool StartDecode(); + bool FinishDecode(); void SetScanlinePointers(uint8_t** data); - LIBYUV_BOOL DecodeImcuRow(); + bool DecodeImcuRow(); int GetComponentScanlinePadding(int component); @@ -175,9 +178,9 @@ class LIBYUV_API MJpegDecoder { jpeg_source_mgr* source_mgr_; SetJmpErrorMgr* error_mgr_; - // LIBYUV_TRUE iff at least one component has scanline padding. (i.e., + // true iff at least one component has scanline padding. (i.e., // GetComponentScanlinePadding() != 0.) - LIBYUV_BOOL has_scanline_padding_; + bool has_scanline_padding_; // Temporaries used to point to scanline outputs. int num_outbufs_; // Outermost size of all arrays below. diff --git a/include/libyuv/planar_functions.h b/include/libyuv/planar_functions.h index 20bf78198..e790699b6 100644 --- a/include/libyuv/planar_functions.h +++ b/include/libyuv/planar_functions.h @@ -11,6 +11,9 @@ #ifndef INCLUDE_LIBYUV_PLANAR_FUNCTIONS_H_ #define INCLUDE_LIBYUV_PLANAR_FUNCTIONS_H_ +#include +#include + #include "libyuv/basic_types.h" // TODO(fbarchard): Remove the following headers includes. diff --git a/include/libyuv/rotate.h b/include/libyuv/rotate.h index 37460c4ac..4b1278d4b 100644 --- a/include/libyuv/rotate.h +++ b/include/libyuv/rotate.h @@ -11,6 +11,8 @@ #ifndef INCLUDE_LIBYUV_ROTATE_H_ #define INCLUDE_LIBYUV_ROTATE_H_ +#include + #include "libyuv/basic_types.h" #ifdef __cplusplus diff --git a/include/libyuv/rotate_argb.h b/include/libyuv/rotate_argb.h index 20432949a..00f6c833c 100644 --- a/include/libyuv/rotate_argb.h +++ b/include/libyuv/rotate_argb.h @@ -11,6 +11,8 @@ #ifndef INCLUDE_LIBYUV_ROTATE_ARGB_H_ #define INCLUDE_LIBYUV_ROTATE_ARGB_H_ +#include + #include "libyuv/basic_types.h" #include "libyuv/rotate.h" // For RotationMode. diff --git a/include/libyuv/rotate_row.h b/include/libyuv/rotate_row.h index 49f8a44bf..b40a8effc 100644 --- a/include/libyuv/rotate_row.h +++ b/include/libyuv/rotate_row.h @@ -11,7 +11,9 @@ #ifndef INCLUDE_LIBYUV_ROTATE_ROW_H_ #define INCLUDE_LIBYUV_ROTATE_ROW_H_ -#include "libyuv/basic_types.h" +#include +#include + #include "libyuv/cpu_support.h" #ifdef __cplusplus diff --git a/include/libyuv/row.h b/include/libyuv/row.h index 54ba69504..9dd340fc2 100644 --- a/include/libyuv/row.h +++ b/include/libyuv/row.h @@ -12,6 +12,7 @@ #define INCLUDE_LIBYUV_ROW_H_ #include // For NULL +#include #include // For malloc #include "libyuv/basic_types.h" diff --git a/include/libyuv/scale.h b/include/libyuv/scale.h index 1a8cb3d8c..e648c370e 100644 --- a/include/libyuv/scale.h +++ b/include/libyuv/scale.h @@ -11,6 +11,8 @@ #ifndef INCLUDE_LIBYUV_SCALE_H_ #define INCLUDE_LIBYUV_SCALE_H_ +#include + #include "libyuv/basic_types.h" #ifdef __cplusplus @@ -321,11 +323,11 @@ int Scale(const uint8_t* src_y, int dst_stride_v, int dst_width, int dst_height, - LIBYUV_BOOL interpolate); + int interpolate); // For testing, allow disabling of specialized scalers. LIBYUV_API -void SetUseReferenceImpl(LIBYUV_BOOL use); +void SetUseReferenceImpl(int use); #endif // __cplusplus #ifdef __cplusplus diff --git a/include/libyuv/scale_argb.h b/include/libyuv/scale_argb.h index 7641f18e3..c0a55340f 100644 --- a/include/libyuv/scale_argb.h +++ b/include/libyuv/scale_argb.h @@ -11,6 +11,8 @@ #ifndef INCLUDE_LIBYUV_SCALE_ARGB_H_ #define INCLUDE_LIBYUV_SCALE_ARGB_H_ +#include + #include "libyuv/basic_types.h" #include "libyuv/scale.h" // For FilterMode diff --git a/include/libyuv/scale_rgb.h b/include/libyuv/scale_rgb.h index d17c39fd6..94218fe3d 100644 --- a/include/libyuv/scale_rgb.h +++ b/include/libyuv/scale_rgb.h @@ -11,6 +11,8 @@ #ifndef INCLUDE_LIBYUV_SCALE_RGB_H_ #define INCLUDE_LIBYUV_SCALE_RGB_H_ +#include + #include "libyuv/basic_types.h" #include "libyuv/scale.h" // For FilterMode diff --git a/include/libyuv/scale_row.h b/include/libyuv/scale_row.h index 99b450379..24dd9ccd5 100644 --- a/include/libyuv/scale_row.h +++ b/include/libyuv/scale_row.h @@ -11,7 +11,9 @@ #ifndef INCLUDE_LIBYUV_SCALE_ROW_H_ #define INCLUDE_LIBYUV_SCALE_ROW_H_ -#include "libyuv/basic_types.h" +#include +#include + #include "libyuv/cpu_support.h" #include "libyuv/scale.h" diff --git a/include/libyuv/scale_uv.h b/include/libyuv/scale_uv.h index 8e74e3195..f6cc8e40f 100644 --- a/include/libyuv/scale_uv.h +++ b/include/libyuv/scale_uv.h @@ -11,6 +11,8 @@ #ifndef INCLUDE_LIBYUV_SCALE_UV_H_ #define INCLUDE_LIBYUV_SCALE_UV_H_ +#include + #include "libyuv/basic_types.h" #include "libyuv/scale.h" // For FilterMode diff --git a/include/libyuv/video_common.h b/include/libyuv/video_common.h index 32b8a5210..d39e4dd0c 100644 --- a/include/libyuv/video_common.h +++ b/include/libyuv/video_common.h @@ -13,6 +13,9 @@ #ifndef INCLUDE_LIBYUV_VIDEO_COMMON_H_ #define INCLUDE_LIBYUV_VIDEO_COMMON_H_ +#include +#include + #include "libyuv/basic_types.h" #ifdef __cplusplus diff --git a/source/compare.cc b/source/compare.cc index 10023301c..636ddac5f 100644 --- a/source/compare.cc +++ b/source/compare.cc @@ -17,7 +17,6 @@ #include #endif -#include "libyuv/basic_types.h" #include "libyuv/compare_row.h" #include "libyuv/cpu_id.h" #include "libyuv/row.h" diff --git a/source/compare_common.cc b/source/compare_common.cc index d1cab8d2b..c7c4fe879 100644 --- a/source/compare_common.cc +++ b/source/compare_common.cc @@ -8,8 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "libyuv/basic_types.h" - #include "libyuv/compare_row.h" #ifdef __cplusplus diff --git a/source/compare_gcc.cc b/source/compare_gcc.cc index 33a725e58..fa8e399e0 100644 --- a/source/compare_gcc.cc +++ b/source/compare_gcc.cc @@ -8,8 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "libyuv/basic_types.h" - #include "libyuv/compare_row.h" #include "libyuv/row.h" diff --git a/source/compare_neon.cc b/source/compare_neon.cc index ee1f7b26c..67b44a1e3 100644 --- a/source/compare_neon.cc +++ b/source/compare_neon.cc @@ -8,8 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "libyuv/basic_types.h" - #include "libyuv/compare_row.h" #include "libyuv/row.h" diff --git a/source/compare_neon64.cc b/source/compare_neon64.cc index 36c5e575c..91d4c8d10 100644 --- a/source/compare_neon64.cc +++ b/source/compare_neon64.cc @@ -8,8 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "libyuv/basic_types.h" - #include "libyuv/compare_row.h" #include "libyuv/row.h" diff --git a/source/compare_win.cc b/source/compare_win.cc index 59374cd8a..447bd077f 100644 --- a/source/compare_win.cc +++ b/source/compare_win.cc @@ -8,8 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "libyuv/basic_types.h" - #include "libyuv/compare_row.h" #include "libyuv/row.h" diff --git a/source/convert.cc b/source/convert.cc index b3d6cd201..e3864eec9 100644 --- a/source/convert.cc +++ b/source/convert.cc @@ -12,7 +12,6 @@ #include -#include "libyuv/basic_types.h" #include "libyuv/convert_from_argb.h" #include "libyuv/cpu_id.h" #include "libyuv/planar_functions.h" diff --git a/source/convert_from.cc b/source/convert_from.cc index 1331699c9..bed7ddefa 100644 --- a/source/convert_from.cc +++ b/source/convert_from.cc @@ -12,7 +12,6 @@ #include -#include "libyuv/basic_types.h" #include "libyuv/convert.h" // For I420Copy #include "libyuv/cpu_id.h" #include "libyuv/planar_functions.h" diff --git a/source/convert_from_argb.cc b/source/convert_from_argb.cc index 11e54fcf1..fd5a9e1c9 100644 --- a/source/convert_from_argb.cc +++ b/source/convert_from_argb.cc @@ -13,7 +13,6 @@ #include #include // For memcpy. -#include "libyuv/basic_types.h" #include "libyuv/cpu_id.h" #include "libyuv/planar_functions.h" #include "libyuv/row.h" diff --git a/source/convert_jpeg.cc b/source/convert_jpeg.cc index d7556ee91..d9ce28a92 100644 --- a/source/convert_jpeg.cc +++ b/source/convert_jpeg.cc @@ -94,7 +94,7 @@ int MJPGSize(const uint8_t* src_mjpg, int* width, int* height) { MJpegDecoder mjpeg_decoder; - LIBYUV_BOOL ret = mjpeg_decoder.LoadFrame(src_mjpg, src_size_mjpg); + bool ret = mjpeg_decoder.LoadFrame(src_mjpg, src_size_mjpg); if (ret) { *width = mjpeg_decoder.GetWidth(); *height = mjpeg_decoder.GetHeight(); @@ -126,7 +126,7 @@ int MJPGToI420(const uint8_t* src_mjpg, // TODO(fbarchard): Port MJpeg to C. MJpegDecoder mjpeg_decoder; - LIBYUV_BOOL ret = mjpeg_decoder.LoadFrame(src_mjpg, src_size_mjpg); + bool ret = mjpeg_decoder.LoadFrame(src_mjpg, src_size_mjpg); if (ret && (mjpeg_decoder.GetWidth() != src_width || mjpeg_decoder.GetHeight() != src_height)) { // ERROR: MJPEG frame has unexpected dimensions @@ -266,7 +266,7 @@ int MJPGToNV21(const uint8_t* src_mjpg, // TODO(fbarchard): Port MJpeg to C. MJpegDecoder mjpeg_decoder; - LIBYUV_BOOL ret = mjpeg_decoder.LoadFrame(src_mjpg, src_size_mjpg); + bool ret = mjpeg_decoder.LoadFrame(src_mjpg, src_size_mjpg); if (ret && (mjpeg_decoder.GetWidth() != src_width || mjpeg_decoder.GetHeight() != src_height)) { // ERROR: MJPEG frame has unexpected dimensions @@ -399,7 +399,7 @@ int MJPGToNV12(const uint8_t* sample, // TODO(fbarchard): Port MJpeg to C. MJpegDecoder mjpeg_decoder; - LIBYUV_BOOL ret = mjpeg_decoder.LoadFrame(sample, sample_size); + bool ret = mjpeg_decoder.LoadFrame(sample, sample_size); if (ret && (mjpeg_decoder.GetWidth() != src_width || mjpeg_decoder.GetHeight() != src_height)) { // ERROR: MJPEG frame has unexpected dimensions @@ -531,7 +531,7 @@ int MJPGToARGB(const uint8_t* src_mjpg, // TODO(fbarchard): Port MJpeg to C. MJpegDecoder mjpeg_decoder; - LIBYUV_BOOL ret = mjpeg_decoder.LoadFrame(src_mjpg, src_size_mjpg); + bool ret = mjpeg_decoder.LoadFrame(src_mjpg, src_size_mjpg); if (ret && (mjpeg_decoder.GetWidth() != src_width || mjpeg_decoder.GetHeight() != src_height)) { // ERROR: MJPEG frame has unexpected dimensions diff --git a/source/convert_to_argb.cc b/source/convert_to_argb.cc index f3c4018d7..997652fe3 100644 --- a/source/convert_to_argb.cc +++ b/source/convert_to_argb.cc @@ -78,7 +78,7 @@ int ConvertToARGB(const uint8_t* sample, // and then rotate the ARGB to the final destination buffer. // For in-place conversion, if destination dst_argb is same as source sample, // also enable temporary buffer. - LIBYUV_BOOL need_buf = + int need_buf = (rotation && format != FOURCC_ARGB) || dst_argb == sample; uint8_t* dest_argb = dst_argb; int dest_dst_stride_argb = dst_stride_argb; diff --git a/source/convert_to_i420.cc b/source/convert_to_i420.cc index baa4a9494..19bfe7ca5 100644 --- a/source/convert_to_i420.cc +++ b/source/convert_to_i420.cc @@ -63,7 +63,7 @@ int ConvertToI420(const uint8_t* sample, const uint8_t* src; const uint8_t* src_uv; int r = 0; - LIBYUV_BOOL need_buf = + int need_buf = (rotation && format != FOURCC_I420 && format != FOURCC_NV12 && format != FOURCC_NV21 && format != FOURCC_YV12) || dst_y == sample; diff --git a/source/mjpeg_decoder.cc b/source/mjpeg_decoder.cc index 559e3e3a7..5388fef4e 100644 --- a/source/mjpeg_decoder.cc +++ b/source/mjpeg_decoder.cc @@ -65,7 +65,7 @@ void ErrorHandler(jpeg_common_struct* cinfo); void OutputHandler(jpeg_common_struct* cinfo); MJpegDecoder::MJpegDecoder() - : has_scanline_padding_(LIBYUV_FALSE), + : has_scanline_padding_(false), num_outbufs_(0), scanlines_(NULL), scanlines_sizes_(NULL), @@ -102,9 +102,9 @@ MJpegDecoder::~MJpegDecoder() { DestroyOutputBuffers(); } -LIBYUV_BOOL MJpegDecoder::LoadFrame(const uint8_t* src, size_t src_len) { +bool MJpegDecoder::LoadFrame(const uint8_t* src, size_t src_len) { if (!ValidateJpeg(src, src_len)) { - return LIBYUV_FALSE; + return false; } buf_.data = src; @@ -115,12 +115,12 @@ LIBYUV_BOOL MJpegDecoder::LoadFrame(const uint8_t* src, size_t src_len) { if (setjmp(error_mgr_->setjmp_buffer)) { // We called jpeg_read_header, it experienced an error, and we called // longjmp() and rewound the stack to here. Return error. - return LIBYUV_FALSE; + return false; } #endif if (jpeg_read_header(decompress_struct_, TRUE) != JPEG_HEADER_OK) { // ERROR: Bad MJPEG header - return LIBYUV_FALSE; + return false; } AllocOutputBuffers(GetNumComponents()); for (int i = 0; i < num_outbufs_; ++i) { @@ -154,10 +154,10 @@ LIBYUV_BOOL MJpegDecoder::LoadFrame(const uint8_t* src, size_t src_len) { } if (GetComponentStride(i) != GetComponentWidth(i)) { - has_scanline_padding_ = LIBYUV_TRUE; + has_scanline_padding_ = true; } } - return LIBYUV_TRUE; + return true; } static int DivideAndRoundUp(int numerator, int denominator) { @@ -234,36 +234,36 @@ int MJpegDecoder::GetComponentSize(int component) { return GetComponentWidth(component) * GetComponentHeight(component); } -LIBYUV_BOOL MJpegDecoder::UnloadFrame() { +bool MJpegDecoder::UnloadFrame() { #ifdef HAVE_SETJMP if (setjmp(error_mgr_->setjmp_buffer)) { // We called jpeg_abort_decompress, it experienced an error, and we called // longjmp() and rewound the stack to here. Return error. - return LIBYUV_FALSE; + return false; } #endif jpeg_abort_decompress(decompress_struct_); - return LIBYUV_TRUE; + return true; } // TODO(fbarchard): Allow rectangle to be specified: x, y, width, height. -LIBYUV_BOOL MJpegDecoder::DecodeToBuffers(uint8_t** planes, - int dst_width, - int dst_height) { +bool MJpegDecoder::DecodeToBuffers(uint8_t** planes, + int dst_width, + int dst_height) { if (dst_width != GetWidth() || dst_height > GetHeight()) { // ERROR: Bad dimensions - return LIBYUV_FALSE; + return false; } #ifdef HAVE_SETJMP if (setjmp(error_mgr_->setjmp_buffer)) { // We called into jpeglib, it experienced an error sometime during this // function call, and we called longjmp() and rewound the stack to here. // Return error. - return LIBYUV_FALSE; + return false; } #endif if (!StartDecode()) { - return LIBYUV_FALSE; + return false; } SetScanlinePointers(databuf_); int lines_left = dst_height; @@ -277,7 +277,7 @@ LIBYUV_BOOL MJpegDecoder::DecodeToBuffers(uint8_t** planes, while (skip >= GetImageScanlinesPerImcuRow()) { if (!DecodeImcuRow()) { FinishDecode(); - return LIBYUV_FALSE; + return false; } skip -= GetImageScanlinesPerImcuRow(); } @@ -286,7 +286,7 @@ LIBYUV_BOOL MJpegDecoder::DecodeToBuffers(uint8_t** planes, // copy the parts we want into the destination. if (!DecodeImcuRow()) { FinishDecode(); - return LIBYUV_FALSE; + return false; } for (int i = 0; i < num_outbufs_; ++i) { // TODO(fbarchard): Compute skip to avoid this @@ -309,7 +309,7 @@ LIBYUV_BOOL MJpegDecoder::DecodeToBuffers(uint8_t** planes, lines_left -= GetImageScanlinesPerImcuRow()) { if (!DecodeImcuRow()) { FinishDecode(); - return LIBYUV_FALSE; + return false; } for (int i = 0; i < num_outbufs_; ++i) { int scanlines_to_copy = GetComponentScanlinesPerImcuRow(i); @@ -323,7 +323,7 @@ LIBYUV_BOOL MJpegDecoder::DecodeToBuffers(uint8_t** planes, // Have a partial iMCU row left over to decode. if (!DecodeImcuRow()) { FinishDecode(); - return LIBYUV_FALSE; + return false; } for (int i = 0; i < num_outbufs_; ++i) { int scanlines_to_copy = @@ -336,24 +336,24 @@ LIBYUV_BOOL MJpegDecoder::DecodeToBuffers(uint8_t** planes, return FinishDecode(); } -LIBYUV_BOOL MJpegDecoder::DecodeToCallback(CallbackFunction fn, - void* opaque, - int dst_width, - int dst_height) { +bool MJpegDecoder::DecodeToCallback(CallbackFunction fn, + void* opaque, + int dst_width, + int dst_height) { if (dst_width != GetWidth() || dst_height > GetHeight()) { // ERROR: Bad dimensions - return LIBYUV_FALSE; + return false; } #ifdef HAVE_SETJMP if (setjmp(error_mgr_->setjmp_buffer)) { // We called into jpeglib, it experienced an error sometime during this // function call, and we called longjmp() and rewound the stack to here. // Return error. - return LIBYUV_FALSE; + return false; } #endif if (!StartDecode()) { - return LIBYUV_FALSE; + return false; } SetScanlinePointers(databuf_); int lines_left = dst_height; @@ -363,7 +363,7 @@ LIBYUV_BOOL MJpegDecoder::DecodeToCallback(CallbackFunction fn, while (skip >= GetImageScanlinesPerImcuRow()) { if (!DecodeImcuRow()) { FinishDecode(); - return LIBYUV_FALSE; + return false; } skip -= GetImageScanlinesPerImcuRow(); } @@ -371,7 +371,7 @@ LIBYUV_BOOL MJpegDecoder::DecodeToCallback(CallbackFunction fn, // Have a partial iMCU row left over to skip. if (!DecodeImcuRow()) { FinishDecode(); - return LIBYUV_FALSE; + return false; } for (int i = 0; i < num_outbufs_; ++i) { // TODO(fbarchard): Compute skip to avoid this @@ -398,7 +398,7 @@ LIBYUV_BOOL MJpegDecoder::DecodeToCallback(CallbackFunction fn, lines_left -= GetImageScanlinesPerImcuRow()) { if (!DecodeImcuRow()) { FinishDecode(); - return LIBYUV_FALSE; + return false; } (*fn)(opaque, databuf_, databuf_strides_, GetImageScanlinesPerImcuRow()); } @@ -406,7 +406,7 @@ LIBYUV_BOOL MJpegDecoder::DecodeToCallback(CallbackFunction fn, // Have a partial iMCU row left over to decode. if (!DecodeImcuRow()) { FinishDecode(); - return LIBYUV_FALSE; + return false; } (*fn)(opaque, databuf_, databuf_strides_, lines_left); } @@ -513,29 +513,29 @@ void MJpegDecoder::DestroyOutputBuffers() { } // JDCT_IFAST and do_block_smoothing improve performance substantially. -LIBYUV_BOOL MJpegDecoder::StartDecode() { +bool MJpegDecoder::StartDecode() { decompress_struct_->raw_data_out = TRUE; decompress_struct_->dct_method = JDCT_IFAST; // JDCT_ISLOW is default decompress_struct_->dither_mode = JDITHER_NONE; // Not applicable to 'raw': - decompress_struct_->do_fancy_upsampling = (boolean)(LIBYUV_FALSE); + decompress_struct_->do_fancy_upsampling = (boolean)(0); // Only for buffered mode: - decompress_struct_->enable_2pass_quant = (boolean)(LIBYUV_FALSE); + decompress_struct_->enable_2pass_quant = (boolean)(0); // Blocky but fast: - decompress_struct_->do_block_smoothing = (boolean)(LIBYUV_FALSE); + decompress_struct_->do_block_smoothing = (boolean)(0); if (!jpeg_start_decompress(decompress_struct_)) { // ERROR: Couldn't start JPEG decompressor"; - return LIBYUV_FALSE; + return false; } - return LIBYUV_TRUE; + return true; } -LIBYUV_BOOL MJpegDecoder::FinishDecode() { +bool MJpegDecoder::FinishDecode() { // jpeglib considers it an error if we finish without decoding the whole // image, so we call "abort" rather than "finish". jpeg_abort_decompress(decompress_struct_); - return LIBYUV_TRUE; + return true; } void MJpegDecoder::SetScanlinePointers(uint8_t** data) { @@ -548,7 +548,7 @@ void MJpegDecoder::SetScanlinePointers(uint8_t** data) { } } -inline LIBYUV_BOOL MJpegDecoder::DecodeImcuRow() { +inline bool MJpegDecoder::DecodeImcuRow() { return (unsigned int)(GetImageScanlinesPerImcuRow()) == jpeg_read_raw_data(decompress_struct_, scanlines_, GetImageScanlinesPerImcuRow()); diff --git a/source/mjpeg_validate.cc b/source/mjpeg_validate.cc index ba0a03ab9..91d62ecd5 100644 --- a/source/mjpeg_validate.cc +++ b/source/mjpeg_validate.cc @@ -18,7 +18,7 @@ extern "C" { #endif // Helper function to scan for EOI marker (0xff 0xd9). -static LIBYUV_BOOL ScanEOI(const uint8_t* src_mjpg, size_t src_size_mjpg) { +static int ScanEOI(const uint8_t* src_mjpg, size_t src_size_mjpg) { if (src_size_mjpg >= 2) { const uint8_t* end = src_mjpg + src_size_mjpg - 1; const uint8_t* it = src_mjpg; @@ -29,34 +29,34 @@ static LIBYUV_BOOL ScanEOI(const uint8_t* src_mjpg, size_t src_size_mjpg) { break; } if (it[1] == 0xd9) { - return LIBYUV_TRUE; // Success: Valid jpeg. + return 1; // Success: Valid jpeg. } ++it; // Skip over current 0xff. } } // ERROR: Invalid jpeg end code not found. Size src_size_mjpg - return LIBYUV_FALSE; + return 0; } // Helper function to validate the jpeg appears intact. -LIBYUV_BOOL ValidateJpeg(const uint8_t* src_mjpg, size_t src_size_mjpg) { +int ValidateJpeg(const uint8_t* src_mjpg, size_t src_size_mjpg) { // Maximum size that ValidateJpeg will consider valid. const size_t kMaxJpegSize = 0x7fffffffull; const size_t kBackSearchSize = 1024; if (src_size_mjpg < 64 || src_size_mjpg > kMaxJpegSize || !src_mjpg) { // ERROR: Invalid jpeg size: src_size_mjpg - return LIBYUV_FALSE; + return 0; } // SOI marker if (src_mjpg[0] != 0xff || src_mjpg[1] != 0xd8 || src_mjpg[2] != 0xff) { // ERROR: Invalid jpeg initial start code - return LIBYUV_FALSE; + return 0; } // Look for the End Of Image (EOI) marker near the end of the buffer. if (src_size_mjpg > kBackSearchSize) { if (ScanEOI(src_mjpg + src_size_mjpg - kBackSearchSize, kBackSearchSize)) { - return LIBYUV_TRUE; // Success: Valid jpeg. + return 1; // Success: Valid jpeg. } // Reduce search size for forward search. src_size_mjpg = src_size_mjpg - kBackSearchSize + 1; diff --git a/source/rotate_any.cc b/source/rotate_any.cc index 791494559..06e7461de 100644 --- a/source/rotate_any.cc +++ b/source/rotate_any.cc @@ -11,8 +11,6 @@ #include "libyuv/rotate.h" #include "libyuv/rotate_row.h" -#include "libyuv/basic_types.h" - #ifdef __cplusplus namespace libyuv { extern "C" { diff --git a/source/rotate_neon.cc b/source/rotate_neon.cc index de14c41b0..3394a10f7 100644 --- a/source/rotate_neon.cc +++ b/source/rotate_neon.cc @@ -11,8 +11,6 @@ #include "libyuv/rotate_row.h" #include "libyuv/row.h" -#include "libyuv/basic_types.h" - #ifdef __cplusplus namespace libyuv { extern "C" { diff --git a/source/rotate_neon64.cc b/source/rotate_neon64.cc index 14f31d94c..f81a419c5 100644 --- a/source/rotate_neon64.cc +++ b/source/rotate_neon64.cc @@ -11,8 +11,6 @@ #include "libyuv/rotate_row.h" #include "libyuv/row.h" -#include "libyuv/basic_types.h" - #ifdef __cplusplus namespace libyuv { extern "C" { diff --git a/source/rotate_sme.cc b/source/rotate_sme.cc index dc9ab0c3a..6cf0a1528 100644 --- a/source/rotate_sme.cc +++ b/source/rotate_sme.cc @@ -11,8 +11,6 @@ #include "libyuv/rotate_row.h" #include "libyuv/row.h" -#include "libyuv/basic_types.h" - #ifdef __cplusplus namespace libyuv { extern "C" { diff --git a/source/row_any.cc b/source/row_any.cc index ef04e9a8d..7b4c27f0c 100644 --- a/source/row_any.cc +++ b/source/row_any.cc @@ -13,8 +13,6 @@ #include #include // For memset. -#include "libyuv/basic_types.h" - #ifdef __cplusplus namespace libyuv { extern "C" { diff --git a/source/row_common.cc b/source/row_common.cc index b5c1de28a..ce302508b 100644 --- a/source/row_common.cc +++ b/source/row_common.cc @@ -13,7 +13,6 @@ #include #include // For memcpy and memset. -#include "libyuv/basic_types.h" #include "libyuv/convert_argb.h" // For kYuvI601Constants #include "libyuv/convert_from_argb.h" // For ArgbConstants diff --git a/source/scale.cc b/source/scale.cc index 6dc768918..81e5aea90 100644 --- a/source/scale.cc +++ b/source/scale.cc @@ -2688,7 +2688,7 @@ int Scale(const uint8_t* src_y, int dst_stride_v, int dst_width, int dst_height, - LIBYUV_BOOL interpolate) { + int interpolate) { return I420Scale(src_y, src_stride_y, src_u, src_stride_u, src_v, src_stride_v, src_width, src_height, dst_y, dst_stride_y, dst_u, dst_stride_u, dst_v, dst_stride_v, dst_width, diff --git a/source/scale_any.cc b/source/scale_any.cc index c93b3f084..bf7d16202 100644 --- a/source/scale_any.cc +++ b/source/scale_any.cc @@ -14,8 +14,6 @@ #include "libyuv/scale.h" #include "libyuv/scale_row.h" -#include "libyuv/basic_types.h" - #ifdef __cplusplus namespace libyuv { extern "C" { diff --git a/unit_test/basictypes_test.cc b/unit_test/basictypes_test.cc index 421b56f85..3c9068c1f 100644 --- a/unit_test/basictypes_test.cc +++ b/unit_test/basictypes_test.cc @@ -8,8 +8,9 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include + #include "../unit_test/unit_test.h" -#include "libyuv/basic_types.h" namespace libyuv { diff --git a/unit_test/color_test.cc b/unit_test/color_test.cc index 24456a524..1cd1c166e 100644 --- a/unit_test/color_test.cc +++ b/unit_test/color_test.cc @@ -11,7 +11,6 @@ #include #include "../unit_test/unit_test.h" -#include "libyuv/basic_types.h" #include "libyuv/convert.h" #include "libyuv/convert_argb.h" #include "libyuv/convert_from.h" diff --git a/unit_test/compare_test.cc b/unit_test/compare_test.cc index 8ae17f545..cf6fc8ce2 100644 --- a/unit_test/compare_test.cc +++ b/unit_test/compare_test.cc @@ -13,7 +13,6 @@ #include #include "../unit_test/unit_test.h" -#include "libyuv/basic_types.h" #include "libyuv/compare.h" #include "libyuv/cpu_id.h" #include "libyuv/video_common.h" diff --git a/unit_test/convert_argb_test.cc b/unit_test/convert_argb_test.cc index 80fc6de4e..337a8b022 100644 --- a/unit_test/convert_argb_test.cc +++ b/unit_test/convert_argb_test.cc @@ -13,7 +13,6 @@ #include #include "../unit_test/unit_test.h" -#include "libyuv/basic_types.h" #include "libyuv/compare.h" #include "libyuv/convert.h" #include "libyuv/convert_argb.h" diff --git a/unit_test/convert_test.cc b/unit_test/convert_test.cc index ecf28d6d8..848818118 100644 --- a/unit_test/convert_test.cc +++ b/unit_test/convert_test.cc @@ -12,7 +12,6 @@ #include #include -#include "libyuv/basic_types.h" #include "libyuv/compare.h" #include "libyuv/convert.h" #include "libyuv/convert_argb.h" @@ -1737,9 +1736,9 @@ TEST_F(LibYUVConvertTest, TestMJPGToARGB) { free_aligned_buffer_page_end(dst_argb); } -static int ShowJPegInfo(const uint8_t* sample, size_t sample_size) { +static bool ShowJPegInfo(const uint8_t* sample, size_t sample_size) { MJpegDecoder mjpeg_decoder; - LIBYUV_BOOL ret = mjpeg_decoder.LoadFrame(sample, sample_size); + bool ret = mjpeg_decoder.LoadFrame(sample, sample_size); int width = mjpeg_decoder.GetWidth(); int height = mjpeg_decoder.GetHeight(); @@ -1794,12 +1793,12 @@ static int ShowJPegInfo(const uint8_t* sample, size_t sample_size) { } TEST_F(LibYUVConvertTest, TestMJPGInfo) { - ASSERT_EQ(1, ShowJPegInfo(kTest0Jpg, kTest0JpgLen)); - ASSERT_EQ(1, ShowJPegInfo(kTest1Jpg, kTest1JpgLen)); - ASSERT_EQ(1, ShowJPegInfo(kTest2Jpg, kTest2JpgLen)); - ASSERT_EQ(1, ShowJPegInfo(kTest3Jpg, kTest3JpgLen)); - ASSERT_EQ(1, ShowJPegInfo(kTest4Jpg, - kTest4JpgLen)); // Valid but unsupported. + ASSERT_TRUE(ShowJPegInfo(kTest0Jpg, kTest0JpgLen)); + ASSERT_TRUE(ShowJPegInfo(kTest1Jpg, kTest1JpgLen)); + ASSERT_TRUE(ShowJPegInfo(kTest2Jpg, kTest2JpgLen)); + ASSERT_TRUE(ShowJPegInfo(kTest3Jpg, kTest3JpgLen)); + ASSERT_TRUE(ShowJPegInfo(kTest4Jpg, + kTest4JpgLen)); // Valid but unsupported. } #endif // HAVE_JPEG diff --git a/unit_test/cpu_test.cc b/unit_test/cpu_test.cc index b249e70df..cc5dfd077 100644 --- a/unit_test/cpu_test.cc +++ b/unit_test/cpu_test.cc @@ -18,7 +18,6 @@ #endif #include "../unit_test/unit_test.h" -#include "libyuv/basic_types.h" #include "libyuv/cpu_id.h" #include "libyuv/version.h" diff --git a/unit_test/math_test.cc b/unit_test/math_test.cc index 4767f8b46..1f1a6d844 100644 --- a/unit_test/math_test.cc +++ b/unit_test/math_test.cc @@ -13,7 +13,6 @@ #include #include "../unit_test/unit_test.h" -#include "libyuv/basic_types.h" #include "libyuv/cpu_id.h" #include "libyuv/scale.h" diff --git a/unit_test/unit_test.cc b/unit_test/unit_test.cc index 163e3ffdb..cd22d1996 100644 --- a/unit_test/unit_test.cc +++ b/unit_test/unit_test.cc @@ -52,18 +52,18 @@ static const int32_t FLAGS_libyuv_cpu_info = 0; // Test environment variable for disabling CPU features. Any non-zero value // to disable. Zero ignored to make it easy to set the variable on/off. #if !defined(__native_client__) && !defined(_M_ARM) -static LIBYUV_BOOL TestEnv(const char* name) { +static bool TestEnv(const char* name) { const char* var = getenv(name); if (var) { if (var[0] != '0') { - return LIBYUV_TRUE; + return true; } } - return LIBYUV_FALSE; + return false; } #else // nacl does not support getenv(). -static LIBYUV_BOOL TestEnv(const char*) { - return LIBYUV_FALSE; +static bool TestEnv(const char*) { + return false; } #endif diff --git a/unit_test/unit_test.h b/unit_test/unit_test.h index e9a55c62f..24f871f15 100644 --- a/unit_test/unit_test.h +++ b/unit_test/unit_test.h @@ -12,6 +12,7 @@ #define UNIT_TEST_UNIT_TEST_H_ #include // For NULL +#include #ifdef _WIN32 #include #elif !defined(__hexagon__) @@ -21,8 +22,6 @@ // pragma to disable warning for ASSERT_NE #include // IWYU pragma: export -#include "libyuv/basic_types.h" - #ifndef SIMD_ALIGNED #if defined(_MSC_VER) && !defined(__CLR_VER) #define SIMD_ALIGNED(var) __declspec(align(16)) var diff --git a/util/compare.cc b/util/compare.cc index a16613ee2..cd5b68dae 100644 --- a/util/compare.cc +++ b/util/compare.cc @@ -13,7 +13,6 @@ #include #include -#include "libyuv/basic_types.h" #include "libyuv/compare.h" #include "libyuv/version.h"