[x265] Changes in class definitions and headers
Amit M
wjl239423sdjl at yahoo.com
Fri Aug 21 11:45:42 CEST 2020
Hello all,
I'm new to x265 lib. I had a brief look in source and header files. I looked into classes in sao.h, encoder.h, x265.h, x265cli.h
You had used lot of 'int' type objects. Currently, C++ offers a header, cstdint. https://en.cppreference.com/w/cpp/header/cstdint
Instead of 'int', I suggest that you use 'int32_t'. I think it is available in many ISO C++ compilers. We can change objects defined as 'int' to 'int32_t'. There are some differences between int and int32_t in some implementations for different CPU's so this can be discussed later in detail.
You had also used plain C-style enums as:
enum SAOType
{
SAO_EO_0 = 0,
SAO_EO_1,
SAO_EO_2,
SAO_EO_3,
SAO_BO,
MAX_NUM_SAO_TYPE
};
This is in sao.h
Plain enums are deprecated (which means not used anymore) in C++14 and beyond. If you think it is necessary, we can change it to a enum class as:
enum class SAOType
{
SAO_EO_0,
SAO_EO_1,
SAO_EO_2,
SAO_EO_3,
SAO_BO,
MAX_NUM_SAO_TYPE
};
Each entry in the enum is accessed with the operator '::' such as
SAOType::SAO_E0_0, SAOType::SAO_E0_1 etc.
This is better and easily readable. Regarding providing C-style interface for previous users of x264, I think we can think of leaving some plain enums in main interface layers of the API. Some plain enums can be changed to enum classes or constexpr constants. Objects of type enum defined as typedef enum { } can also be changed to enum classes or constexpr int32_t or std::size_t type constants. These are a few suggestions.
Best regards,
Amit
More information about the x265-devel
mailing list