aviio.cpp: Massive code cleanup

- Use multibyte.h functions and std::swap
- Turn most macro constants into enums and move them down into classes
- Change comments to C++ style
This commit is contained in:
AJR 2023-09-17 13:51:23 -04:00
parent 7e4ca3b49c
commit 01040b1e0c
3 changed files with 534 additions and 769 deletions

File diff suppressed because it is too large Load Diff

View File

@ -19,20 +19,13 @@
/*************************************************************************** /***************************************************************************
MACROS INLINE FUNCTIONS
***************************************************************************/ ***************************************************************************/
#define AVI_FOURCC(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24)) inline constexpr std::uint32_t AVI_FOURCC(char a, char b, char c, char d)
{
#define FORMAT_UYVY AVI_FOURCC('U','Y','V','Y') return std::uint32_t(a) | (std::uint32_t(b) << 8) | (std::uint32_t(c) << 16) | (std::uint32_t(d) << 24);
#define FORMAT_VYUY AVI_FOURCC('V','Y','U','Y') }
#define FORMAT_YUY2 AVI_FOURCC('Y','U','Y','2')
#define FORMAT_HFYU AVI_FOURCC('H','F','Y','U')
#define FORMAT_I420 AVI_FOURCC('I','4','2','0')
#define FORMAT_DIB AVI_FOURCC('D','I','B',' ')
#define FORMAT_RGB AVI_FOURCC('R','G','B',' ')
#define FORMAT_RAW AVI_FOURCC('R','A','W',' ')
#define FORMAT_UNCOMPRESSED 0x00000000
class avi_file class avi_file
@ -43,6 +36,19 @@ public:
CONSTANTS CONSTANTS
***********************************************************************/ ***********************************************************************/
enum : std::uint32_t
{
FORMAT_UYVY = AVI_FOURCC('U','Y','V','Y'),
FORMAT_VYUY = AVI_FOURCC('V','Y','U','Y'),
FORMAT_YUY2 = AVI_FOURCC('Y','U','Y','2'),
FORMAT_HFYU = AVI_FOURCC('H','F','Y','U'),
FORMAT_I420 = AVI_FOURCC('I','4','2','0'),
FORMAT_DIB = AVI_FOURCC('D','I','B',' '),
FORMAT_RGB = AVI_FOURCC('R','G','B',' '),
FORMAT_RAW = AVI_FOURCC('R','A','W',' '),
FORMAT_UNCOMPRESSED = 0x00000000
};
enum class error enum class error
{ {
NONE = 0, NONE = 0,

View File

@ -120,7 +120,7 @@ const int MODE_GDI = 2;
typedef std::unordered_map<std::string, std::string *> parameters_map; typedef std::unordered_map<std::string, std::string *> parameters_map;
template <typename Format, typename... Params> static void report_error(int error, Format &&fmt, Params &&...args); template <typename Format, typename... Params> [[noreturn]] static void report_error(int error, Format &&fmt, Params &&...args);
static void do_info(parameters_map &params); static void do_info(parameters_map &params);
static void do_verify(parameters_map &params); static void do_verify(parameters_map &params);
static void do_create_raw(parameters_map &params); static void do_create_raw(parameters_map &params);
@ -2869,7 +2869,7 @@ static void do_extract_ld(parameters_map &params)
// build up the movie info // build up the movie info
avi_file::movie_info info; avi_file::movie_info info;
info.video_format = FORMAT_YUY2; info.video_format = avi_file::FORMAT_YUY2;
info.video_timescale = fps_times_1million / interlace_factor; info.video_timescale = fps_times_1million / interlace_factor;
info.video_sampletime = 1000000; info.video_sampletime = 1000000;
info.video_width = width; info.video_width = width;