[vlc-devel] [PATCH 28/28] do not test vlc_rational_t for negative values
Steve Lhomme
robux4 at videolabs.io
Mon Apr 3 11:39:04 CEST 2017
--
replaces https://patches.videolan.org/patch/16246/
- more tests on decklink, rawvid, video_output
replaces https://patches.videolan.org/patch/16275/
- fix inverted check in rawvid, video_output
---
lib/media_player.c | 2 +-
modules/access/decklink.cpp | 2 +-
modules/codec/avcodec/d3d11va.c | 2 +-
modules/codec/avcodec/video.c | 2 +-
modules/codec/daala.c | 2 +-
modules/codec/dmo/dmo.c | 4 ++--
modules/codec/libmpeg2.c | 4 ++--
modules/codec/theora.c | 2 +-
modules/codec/vpx.c | 2 +-
modules/codec/x264.c | 4 ++--
modules/demux/mkv/mkv.cpp | 2 +-
modules/demux/rawvid.c | 2 +-
modules/mux/asf.c | 2 +-
modules/mux/mp4/libmp4mux.c | 6 +++---
modules/packetizer/h264.c | 2 +-
modules/packetizer/mpeg4video.c | 4 ++--
modules/video_output/android/display.c | 2 +-
src/video_output/display.c | 2 +-
src/video_output/video_output.c | 2 +-
19 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/lib/media_player.c b/lib/media_player.c
index 7cd7bf88f6..289c3a722d 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -1685,7 +1685,7 @@ float libvlc_media_player_get_fps( libvlc_media_player_t *p_mi )
{
const es_format_t *fmt = item->es[i];
- if( fmt->i_cat == VIDEO_ES && fmt->video.frame_rate.den > 0 )
+ if( fmt->i_cat == VIDEO_ES && fmt->video.frame_rate.den != 0 )
fps = (float)fmt->video.frame_rate.num
/ (float)fmt->video.frame_rate.den;
}
diff --git a/modules/access/decklink.cpp b/modules/access/decklink.cpp
index 41a811eb46..4505eb6d55 100644
--- a/modules/access/decklink.cpp
+++ b/modules/access/decklink.cpp
@@ -198,7 +198,7 @@ static es_format_t GetModeSettings(demux_t *demux, IDeckLinkDisplayMode *m)
vlc_rational_t aspect;
if (!var_InheritURational(demux, &aspect, "decklink-aspect-ratio") &&
- aspect.num > 0 && aspect.den > 0) {
+ aspect.num != 0 && aspect.den != 0) {
video_fmt.video.sar.num = aspect.num * video_fmt.video.i_height;
video_fmt.video.sar.den = aspect.den * video_fmt.video.i_width;
}
diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index c3da9ab7b9..13cc680804 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -795,7 +795,7 @@ static bool SetupProcessor(vlc_va_t *va, const video_format_t *fmt)
D3D11_VIDEO_PROCESSOR_CONTENT_DESC processorDesc = {
.InputFrameFormat = D3D11_VIDEO_FRAME_FORMAT_PROGRESSIVE, /* TODO */
.InputFrameRate = {
- .Numerator = fmt->frame_rate.den > 0 ? fmt->frame_rate.num : 0,
+ .Numerator = fmt->frame_rate.den != 0 ? fmt->frame_rate.num : 0,
.Denominator = fmt->frame_rate.den,
},
.InputWidth = fmt->i_width,
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index d0f923e5ae..78318b5237 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -159,7 +159,7 @@ static int lavc_GetVideoFormat(decoder_t *dec, video_format_t *restrict fmt,
fmt->i_visible_height = ctx->height;
/* If an aspect-ratio was specified in the input format then force it */
- if (dec->fmt_in.video.sar.num > 0 && dec->fmt_in.video.sar.den > 0)
+ if (dec->fmt_in.video.sar.num != 0 && dec->fmt_in.video.sar.den != 0)
{
fmt->sar= dec->fmt_in.video.sar;
}
diff --git a/modules/codec/daala.c b/modules/codec/daala.c
index 4123c2f31a..0fca7fb75f 100644
--- a/modules/codec/daala.c
+++ b/modules/codec/daala.c
@@ -668,7 +668,7 @@ static int OpenEncoder( vlc_object_t *p_this )
p_sys->di.timebase_denominator = p_enc->fmt_in.video.frame_rate.den;
}
- if( p_enc->fmt_in.video.sar.num > 0 && p_enc->fmt_in.video.sar.den > 0 )
+ if( p_enc->fmt_in.video.sar.num != 0 && p_enc->fmt_in.video.sar.den != 0 )
{
unsigned i_dst_num, i_dst_den;
vlc_ureduce( &i_dst_num, &i_dst_den,
diff --git a/modules/codec/dmo/dmo.c b/modules/codec/dmo/dmo.c
index e90dbbc8a8..9de15dea52 100644
--- a/modules/codec/dmo/dmo.c
+++ b/modules/codec/dmo/dmo.c
@@ -510,8 +510,8 @@ static int DecOpen( decoder_t *p_dec )
p_dec->fmt_out.video.i_bits_per_pixel = i_bpp;
/* If an aspect-ratio was specified in the input format then force it */
- if( p_dec->fmt_in.video.sar.num > 0 &&
- p_dec->fmt_in.video.sar.den > 0 )
+ if( p_dec->fmt_in.video.sar.num != 0 &&
+ p_dec->fmt_in.video.sar.den != 0 )
{
p_dec->fmt_out.video.sar= p_dec->fmt_in.video.sar;
}
diff --git a/modules/codec/libmpeg2.c b/modules/codec/libmpeg2.c
index 8f4eef8543..ab7ee19e39 100644
--- a/modules/codec/libmpeg2.c
+++ b/modules/codec/libmpeg2.c
@@ -713,8 +713,8 @@ static void GetAR( decoder_t *p_dec )
vlc_rational_t old_sar = p_sys->sar;
/* Check whether the input gave a particular aspect ratio */
- if( p_dec->fmt_in.video.sar.num > 0 &&
- p_dec->fmt_in.video.sar.den > 0 )
+ if( p_dec->fmt_in.video.sar.num != 0 &&
+ p_dec->fmt_in.video.sar.den != 0 )
{
p_sys->sar = p_dec->fmt_in.video.sar;
}
diff --git a/modules/codec/theora.c b/modules/codec/theora.c
index 947b991fba..b6e2e46a02 100644
--- a/modules/codec/theora.c
+++ b/modules/codec/theora.c
@@ -743,7 +743,7 @@ static int OpenEncoder( vlc_object_t *p_this )
p_sys->ti.fps_denominator = p_enc->fmt_in.video.frame_rate.den;
}
- if( p_enc->fmt_in.video.sar.num > 0 && p_enc->fmt_in.video.sar.den > 0 )
+ if( p_enc->fmt_in.video.sar.num != 0 && p_enc->fmt_in.video.sar.den != 0 )
{
unsigned i_dst_num, i_dst_den;
vlc_ureduce( &i_dst_num, &i_dst_den,
diff --git a/modules/codec/vpx.c b/modules/codec/vpx.c
index 9180b4889d..1368958749 100644
--- a/modules/codec/vpx.c
+++ b/modules/codec/vpx.c
@@ -327,7 +327,7 @@ static int OpenDecoder(vlc_object_t *p_this)
dec->fmt_out.video.i_width = dec->fmt_in.video.i_width;
dec->fmt_out.video.i_height = dec->fmt_in.video.i_height;
- if (dec->fmt_in.video.sar.num > 0 && dec->fmt_in.video.sar.den > 0) {
+ if (dec->fmt_in.video.sar.num != 0 && dec->fmt_in.video.sar.den != 0) {
dec->fmt_out.video.sar = dec->fmt_in.video.sar;
}
diff --git a/modules/codec/x264.c b/modules/codec/x264.c
index d512af2112..188836c572 100644
--- a/modules/codec/x264.c
+++ b/modules/codec/x264.c
@@ -1320,8 +1320,8 @@ static int Open ( vlc_object_t *p_this )
p_sys->param.analyse.b_transform_8x8 = var_GetBool( p_enc,
SOUT_CFG_PREFIX "8x8dct" );
- if( p_enc->fmt_in.video.sar.num > 0 &&
- p_enc->fmt_in.video.sar.den > 0 )
+ if( p_enc->fmt_in.video.sar.num != 0 &&
+ p_enc->fmt_in.video.sar.den != 0 )
{
unsigned int i_dst_num, i_dst_den;
vlc_ureduce( &i_dst_num, &i_dst_den,
diff --git a/modules/demux/mkv/mkv.cpp b/modules/demux/mkv/mkv.cpp
index 32f51f6974..35b04c8219 100644
--- a/modules/demux/mkv/mkv.cpp
+++ b/modules/demux/mkv/mkv.cpp
@@ -422,7 +422,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
{
tracks_map_t::mapped_type const& track = it->second;
- if( track.fmt.i_cat == VIDEO_ES && track.fmt.video.frame_rate.den > 0 )
+ if( track.fmt.i_cat == VIDEO_ES && track.fmt.video.frame_rate.den != 0 )
{
*pf = (double)track.fmt.video.frame_rate.num / track.fmt.video.frame_rate.den;
break;
diff --git a/modules/demux/rawvid.c b/modules/demux/rawvid.c
index 3772076931..b1f30bf4c5 100644
--- a/modules/demux/rawvid.c
+++ b/modules/demux/rawvid.c
@@ -320,7 +320,7 @@ valid:
}
/* fixup anything missing with sensible assumptions */
- if( sar.num <= 0 || sar.den <= 0 )
+ if( sar.num == 0 || sar.den == 0 )
{
/* assume 1:1 sar */
sar.num = 1;
diff --git a/modules/mux/asf.c b/modules/mux/asf.c
index 50adc0768d..0941018106 100644
--- a/modules/mux/asf.c
+++ b/modules/mux/asf.c
@@ -961,7 +961,7 @@ static block_t *asf_header_create( sout_mux_t *p_mux, bool b_broadcast )
uint64_t i_avg_duration = 0;
if( p_fmt->i_cat == VIDEO_ES &&
- p_fmt->video.frame_rate.num > 0 && p_fmt->video.frame_rate.den > 0 )
+ p_fmt->video.frame_rate.num != 0 && p_fmt->video.frame_rate.den != 0 )
i_avg_duration = ( INT64_C(10000000) * p_fmt->video.frame_rate.den +
p_fmt->video.frame_rate.num/2 ) / p_fmt->video.frame_rate.num;
diff --git a/modules/mux/mp4/libmp4mux.c b/modules/mux/mp4/libmp4mux.c
index 00cf468f2f..801ab7efc6 100644
--- a/modules/mux/mp4/libmp4mux.c
+++ b/modules/mux/mp4/libmp4mux.c
@@ -1609,7 +1609,7 @@ bo_t * mp4mux_GetMoovBox(vlc_object_t *p_obj, mp4mux_trackinfo_t **pp_tracks, un
bo_add_32be(tkhd, 0); // height(presentation)
} else if (p_stream->fmt.i_cat == VIDEO_ES) {
int i_width = p_stream->fmt.video.i_width << 16;
- if (p_stream->fmt.video.sar.num > 0 && p_stream->fmt.video.sar.den > 0) {
+ if (p_stream->fmt.video.sar.num != 0 && p_stream->fmt.video.sar.den != 0) {
i_width = (int64_t)p_stream->fmt.video.sar.num *
((int64_t)p_stream->fmt.video.i_width << 16) /
p_stream->fmt.video.sar.den;
@@ -1624,8 +1624,8 @@ bo_t * mp4mux_GetMoovBox(vlc_object_t *p_obj, mp4mux_trackinfo_t **pp_tracks, un
for (unsigned int i = 0; i < i_tracks; i++) {
mp4mux_trackinfo_t *tk = pp_tracks[i];
if (tk->fmt.i_cat == VIDEO_ES) {
- if (tk->fmt.video.sar.num > 0 &&
- tk->fmt.video.sar.den > 0)
+ if (tk->fmt.video.sar.num != 0 &&
+ tk->fmt.video.sar.den != 0)
i_width = (int64_t)tk->fmt.video.sar.num *
((int64_t)tk->fmt.video.i_width << 16) /
tk->fmt.video.sar.den;
diff --git a/modules/packetizer/h264.c b/modules/packetizer/h264.c
index ed28bbbfc3..793957e0ec 100644
--- a/modules/packetizer/h264.c
+++ b/modules/packetizer/h264.c
@@ -349,7 +349,7 @@ static int Open( vlc_object_t *p_this )
p_dec->fmt_out.i_codec = VLC_CODEC_H264;
p_dec->fmt_out.b_packetized = true;
- if( p_dec->fmt_in.video.frame_rate.den > 0 )
+ if( p_dec->fmt_in.video.frame_rate.den != 0 )
{
date_Change( &p_sys->dts, p_dec->fmt_in.video.frame_rate.num * 2,
p_dec->fmt_in.video.frame_rate.den );
diff --git a/modules/packetizer/mpeg4video.c b/modules/packetizer/mpeg4video.c
index f002d7a860..4291839115 100644
--- a/modules/packetizer/mpeg4video.c
+++ b/modules/packetizer/mpeg4video.c
@@ -544,8 +544,8 @@ static int ParseVOP( decoder_t *p_dec, block_t *p_vop )
#endif
if( p_dec->p_sys->fps.num < 5 && /* Work-around buggy streams */
- p_dec->fmt_in.video.frame_rate.num > 0 &&
- p_dec->fmt_in.video.frame_rate.den > 0 )
+ p_dec->fmt_in.video.frame_rate.num != 0 &&
+ p_dec->fmt_in.video.frame_rate.den != 0 )
{
p_sys->i_interpolated_pts += CLOCK_FREQ *
p_dec->fmt_in.video.frame_rate.den /
diff --git a/modules/video_output/android/display.c b/modules/video_output/android/display.c
index 625a8b7c84..6ff4c9ef62 100644
--- a/modules/video_output/android/display.c
+++ b/modules/video_output/android/display.c
@@ -244,7 +244,7 @@ static void FixSubtitleFormat(vout_display_sys_t *sys)
i_video_height = fmt.i_visible_height;
}
- if (fmt.sar.num > 0 && fmt.sar.den > 0) {
+ if (fmt.sar.num != 0 && fmt.sar.den != 0) {
if (fmt.sar.num >= fmt.sar.den)
i_video_width = i_video_width * fmt.sar.num / fmt.sar.den;
else
diff --git a/src/video_output/display.c b/src/video_output/display.c
index b8c8a13ae9..9f9f6ad2b8 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -944,7 +944,7 @@ bool vout_ManageDisplay(vout_display_t *vd, bool allow_reset_pictures)
if (osys->ch_sar) {
video_format_t source = vd->source;
- if (osys->sar.num > 0 && osys->sar.den > 0) {
+ if (osys->sar.num != 0 && osys->sar.den != 0) {
source.sar = osys->sar;
} else {
source.sar = osys->source.sar;
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index a30da09933..39f7ca2b59 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1493,7 +1493,7 @@ static int ThreadReinit(vout_thread_t *vout,
/* FIXME current vout "variables" are not in sync here anymore
* and I am not sure what to do */
- if (state.cfg.display.sar.num <= 0 || state.cfg.display.sar.den <= 0) {
+ if (state.cfg.display.sar.num == 0 || state.cfg.display.sar.den == 0) {
state.cfg.display.sar.num = 1;
state.cfg.display.sar.den = 1;
}
--
2.11.1
More information about the vlc-devel
mailing list