Commit ab124d64 authored by Steve Lhomme's avatar Steve Lhomme Committed by Jean-Baptiste Kempf

do not check unsigned values for negative

vout_intf:
It seems the == should be a && test otherwise we may set a num/den that's 0:0
which is an invalid aspect ratio and won't be used.
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent ecd31733
......@@ -432,7 +432,7 @@ static int OpenDemux(vlc_object_t *object)
fmt.video.i_height = var_InheritInteger(object, "imem-height");
unsigned num, den;
if (!var_InheritURational(object, &num, &den, "imem-dar") && num > 0 && den > 0) {
if (fmt.video.i_width > 0 && fmt.video.i_height > 0) {
if (fmt.video.i_width != 0 && fmt.video.i_height != 0) {
fmt.video.i_sar_num = num * fmt.video.i_height;
fmt.video.i_sar_den = den * fmt.video.i_width;
}
......
......@@ -3019,7 +3019,7 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t *
info_category_AddInfo( p_cat, _("Channels"), "%s",
_( aout_FormatPrintChannels( &fmt->audio ) ) );
if( fmt->audio.i_rate > 0 )
if( fmt->audio.i_rate != 0 )
{
info_category_AddInfo( p_cat, _("Sample rate"), _("%u Hz"),
fmt->audio.i_rate );
......@@ -3028,13 +3028,13 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t *
}
unsigned int i_bitspersample = fmt->audio.i_bitspersample;
if( i_bitspersample <= 0 )
if( i_bitspersample == 0 )
i_bitspersample = aout_BitsPerSample( p_fmt_es->i_codec );
if( i_bitspersample > 0 )
if( i_bitspersample != 0 )
info_category_AddInfo( p_cat, _("Bits per sample"), "%u",
i_bitspersample );
if( fmt->i_bitrate > 0 )
if( fmt->i_bitrate != 0 )
{
info_category_AddInfo( p_cat, _("Bitrate"), _("%u kb/s"),
fmt->i_bitrate / 1000 );
......
......@@ -159,14 +159,14 @@ void vout_display_GetDefaultDisplaySize(unsigned *width, unsigned *height,
const video_format_t *source,
const vout_display_cfg_t *cfg)
{
if (cfg->display.width > 0 && cfg->display.height > 0) {
if (cfg->display.width != 0 && cfg->display.height != 0) {
*width = cfg->display.width;
*height = cfg->display.height;
} else if (cfg->display.width > 0) {
} else if (cfg->display.width != 0) {
*width = cfg->display.width;
*height = (int64_t)source->i_visible_height * source->i_sar_den * cfg->display.width * cfg->display.sar.num /
source->i_visible_width / source->i_sar_num / cfg->display.sar.den;
} else if (cfg->display.height > 0) {
} else if (cfg->display.height != 0) {
*width = (int64_t)source->i_visible_width * source->i_sar_num * cfg->display.height * cfg->display.sar.den /
source->i_visible_height / source->i_sar_den / cfg->display.sar.num;
*height = cfg->display.height;
......@@ -197,7 +197,7 @@ void vout_display_PlacePicture(vout_display_place_t *place,
{
/* */
memset(place, 0, sizeof(*place));
if (cfg->display.width <= 0 || cfg->display.height <= 0)
if (cfg->display.width == 0 || cfg->display.height == 0)
return;
/* */
......@@ -981,7 +981,7 @@ bool vout_ManageDisplay(vout_display_t *vd, bool allow_reset_pictures)
osys->ch_sar = false;
/* If a crop ratio is requested, recompute the parameters */
if (osys->crop.num > 0 && osys->crop.den > 0)
if (osys->crop.num != 0 && osys->crop.den != 0)
osys->ch_crop = true;
}
/* */
......@@ -990,7 +990,7 @@ bool vout_ManageDisplay(vout_display_t *vd, bool allow_reset_pictures)
unsigned crop_num = osys->crop.num;
unsigned crop_den = osys->crop.den;
if (crop_num > 0 && crop_den > 0) {
if (crop_num != 0 && crop_den != 0) {
video_format_t fmt = osys->source;
fmt.i_sar_num = source.i_sar_num;
fmt.i_sar_den = source.i_sar_den;
......@@ -1148,7 +1148,7 @@ void vout_SetDisplayZoom(vout_display_t *vd, unsigned num, unsigned den)
{
vout_display_owner_sys_t *osys = vd->owner.sys;
if (num > 0 && den > 0) {
if (num != 0 && den != 0) {
vlc_ureduce(&num, &den, num, den, 0);
} else {
num = 1;
......@@ -1191,7 +1191,7 @@ void vout_SetDisplayCrop(vout_display_t *vd,
if (osys->crop.left != (int)left || osys->crop.top != (int)top ||
osys->crop.right != right || osys->crop.bottom != bottom ||
(crop_num > 0 && crop_den > 0 &&
(crop_num != 0 && crop_den != 0 &&
(crop_num != osys->crop.num || crop_den != osys->crop.den))) {
osys->crop.left = left;
......
......@@ -76,8 +76,8 @@ static void VoutDestructor(vlc_object_t *);
static int VoutValidateFormat(video_format_t *dst,
const video_format_t *src)
{
if (src->i_width <= 0 || src->i_width > 8192 ||
src->i_height <= 0 || src->i_height > 8192)
if (src->i_width == 0 || src->i_width > 8192 ||
src->i_height == 0 || src->i_height > 8192)
return VLC_EGENERIC;
if (src->i_sar_num <= 0 || src->i_sar_den <= 0)
return VLC_EGENERIC;
......
......@@ -491,7 +491,7 @@ static int AspectCallback( vlc_object_t *object, char const *cmd,
unsigned num, den;
if (sscanf(newval.psz_string, "%u:%u", &num, &den) == 2 &&
(num > 0) == (den > 0))
(num != 0) == (den != 0))
vout_ControlChangeSampleAspectRatio(vout, num, den);
else if (*newval.psz_string == '\0')
vout_ControlChangeSampleAspectRatio(vout, 0, 0);
......
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