mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-23 18:14:06 +00:00
Fix compiler warnings for VS2010 /W4 in config.c and encmain.c.
- Working towards issue #11. - Widened datatypes for cfg struct members that take values from atoi to full ints so that bounds checking can be done after parsing without overflow.
This commit is contained in:
parent
db3b96b90b
commit
73f5c3b80e
|
@ -130,12 +130,13 @@ static int atobool(const char *str)
|
|||
|
||||
static int parse_enum(const char *arg, const char * const *names, int8_t *dst)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; names[i]; i++)
|
||||
int8_t i;
|
||||
for (i = 0; names[i]; i++) {
|
||||
if (!strcmp(arg, names[i])) {
|
||||
*dst = i;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
22
src/config.h
22
src/config.h
|
@ -36,29 +36,29 @@ typedef struct
|
|||
char *input; /*!< \brief Pointer to input filename */
|
||||
char *output; /*!< \brief Pointer to output filename */
|
||||
char *debug; /*!< \brief Pointer to debug output */
|
||||
int8_t qp; /*!< \brief Quantization parameter */
|
||||
int16_t intra_period; /*!< \brief the period of intra frames in stream */
|
||||
int32_t qp; /*!< \brief Quantization parameter */
|
||||
int32_t intra_period; /*!< \brief the period of intra frames in stream */
|
||||
int32_t frames; /*!< \brief Number of frames to decode */
|
||||
int32_t width; /*!< \brief frame width */
|
||||
int32_t height; /*!< \brief frame height */
|
||||
int8_t deblock_enable; /*!< \brief Flag to enable deblocking filter */
|
||||
int8_t sao_enable; /*!< \brief Flag to enable sample adaptive offset filter */
|
||||
int8_t deblock_beta; /*!< \brief (deblocking) beta offset (div 2), range -6...6 */
|
||||
int8_t deblock_tc; /*!< \brief (deblocking) tc offset (div 2), range -6...6 */
|
||||
int32_t deblock_enable; /*!< \brief Flag to enable deblocking filter */
|
||||
int32_t sao_enable; /*!< \brief Flag to enable sample adaptive offset filter */
|
||||
int32_t deblock_beta; /*!< \brief (deblocking) beta offset (div 2), range -6...6 */
|
||||
int32_t deblock_tc; /*!< \brief (deblocking) tc offset (div 2), range -6...6 */
|
||||
struct
|
||||
{
|
||||
int16_t sar_width; /*!< \brief the horizontal size of the sample aspect ratio (in arbitrary units) */
|
||||
int16_t sar_height; /*!< \brief the vertical size of the sample aspect ratio (in the same arbitrary units as sar_width). */
|
||||
int32_t sar_width; /*!< \brief the horizontal size of the sample aspect ratio (in arbitrary units) */
|
||||
int32_t sar_height; /*!< \brief the vertical size of the sample aspect ratio (in the same arbitrary units as sar_width). */
|
||||
int8_t overscan; /*!< \brief Crop overscan setting */
|
||||
int8_t videoformat; /*!< \brief Video format */
|
||||
int8_t fullrange; /*!< \brief Flag to indicate full-range */
|
||||
int8_t colorprim; /*!< \brief Color primaries */
|
||||
int8_t transfer; /*!< \brief Transfer characteristics */
|
||||
int8_t colormatrix; /*!< \brief Color matrix coefficients */
|
||||
int8_t chroma_loc; /*!< \brief Chroma sample location */
|
||||
int32_t chroma_loc; /*!< \brief Chroma sample location */
|
||||
} vui;
|
||||
int8_t aud_enable; /*!< \brief Flag to use access unit delimiters */
|
||||
int8_t ref_frames; /*!< \brief number of reference frames to use */
|
||||
int32_t aud_enable; /*!< \brief Flag to use access unit delimiters */
|
||||
int32_t ref_frames; /*!< \brief number of reference frames to use */
|
||||
char * cqmfile; /*!< \brief Pointer to custom quantization matrices filename */
|
||||
} config;
|
||||
|
||||
|
|
|
@ -180,26 +180,26 @@ int main(int argc, char *argv[])
|
|||
// input init (TODO: read from commandline / config)
|
||||
encoder->bitdepth = 8;
|
||||
encoder->frame = 0;
|
||||
encoder->QP = encoder->cfg->qp;
|
||||
encoder->QP = (int8_t)encoder->cfg->qp;
|
||||
encoder->in.video_format = FORMAT_420;
|
||||
// deblocking filter
|
||||
encoder->deblock_enable = encoder->cfg->deblock_enable;
|
||||
encoder->beta_offset_div2 = encoder->cfg->deblock_beta;
|
||||
encoder->tc_offset_div2 = encoder->cfg->deblock_tc;
|
||||
encoder->deblock_enable = (int8_t)encoder->cfg->deblock_enable;
|
||||
encoder->beta_offset_div2 = (int8_t)encoder->cfg->deblock_beta;
|
||||
encoder->tc_offset_div2 = (int8_t)encoder->cfg->deblock_tc;
|
||||
// SAO
|
||||
encoder->sao_enable = encoder->cfg->sao_enable;
|
||||
encoder->sao_enable = (int8_t)encoder->cfg->sao_enable;
|
||||
// VUI
|
||||
encoder->vui.sar_width = encoder->cfg->vui.sar_width;
|
||||
encoder->vui.sar_height = encoder->cfg->vui.sar_height;
|
||||
encoder->vui.sar_width = (int16_t)encoder->cfg->vui.sar_width;
|
||||
encoder->vui.sar_height = (int16_t)encoder->cfg->vui.sar_height;
|
||||
encoder->vui.overscan = encoder->cfg->vui.overscan;
|
||||
encoder->vui.videoformat = encoder->cfg->vui.videoformat;
|
||||
encoder->vui.fullrange = encoder->cfg->vui.fullrange;
|
||||
encoder->vui.colorprim = encoder->cfg->vui.colorprim;
|
||||
encoder->vui.transfer = encoder->cfg->vui.transfer;
|
||||
encoder->vui.colormatrix = encoder->cfg->vui.colormatrix;
|
||||
encoder->vui.chroma_loc = encoder->cfg->vui.chroma_loc;
|
||||
encoder->vui.chroma_loc = (int8_t)encoder->cfg->vui.chroma_loc;
|
||||
// AUD
|
||||
encoder->aud_enable = encoder->cfg->aud_enable;
|
||||
encoder->aud_enable = (int8_t)encoder->cfg->aud_enable;
|
||||
// CQM
|
||||
cqmfile = cfg->cqmfile ? fopen(cfg->cqmfile, "rb") : NULL;
|
||||
encoder->cqmfile = cqmfile;
|
||||
|
|
|
@ -268,7 +268,7 @@ encoder_control *init_encoder_control(config *cfg)
|
|||
// input init (TODO: read from commandline / config)
|
||||
enc_c->bitdepth = 8;
|
||||
enc_c->frame = 0;
|
||||
enc_c->QP = enc_c->cfg->qp;
|
||||
enc_c->QP = (int8_t)enc_c->cfg->qp;
|
||||
enc_c->in.video_format = FORMAT_420;
|
||||
// deblocking filter
|
||||
enc_c->deblock_enable = 1;
|
||||
|
|
|
@ -141,8 +141,8 @@ typedef struct picture_struct
|
|||
typedef struct
|
||||
{
|
||||
picture** pics; //!< \brief Pointer to array of picture pointers.
|
||||
unsigned int size; //!< \brief Array size.
|
||||
unsigned int used_size;
|
||||
int32_t size; //!< \brief Array size.
|
||||
int32_t used_size;
|
||||
} picture_list;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue