diff --git a/src/libavcodec/to_lavc_vid_conv.c b/src/libavcodec/to_lavc_vid_conv.c index 7b0bf0b43..672e8d6ee 100644 --- a/src/libavcodec/to_lavc_vid_conv.c +++ b/src/libavcodec/to_lavc_vid_conv.c @@ -1872,7 +1872,7 @@ struct AVFrame *to_lavc_vid_conv(struct to_lavc_vid_conv *s, char *in_data) { time_ns_t t2 = get_time_in_ns(); MSG(DEBUG2, "duration uv pixfmt change: %f ms, av format change: %f ms\n", - (t1 - t0) / NS_IN_MS_DBL, (t2 - t1) / NS_IN_MS_DBL); + NS_TO_MS((double) (t1 - t0)), NS_TO_MS((double) (t2 - t1))); return frame; }; diff --git a/src/tv.h b/src/tv.h index 619c226e8..29a5c6fc7 100644 --- a/src/tv.h +++ b/src/tv.h @@ -89,8 +89,6 @@ typedef long long time_ns_t; #define US_IN_SEC 1000000LL #define US_IN_NS 1000LL #define US_IN_SEC_DBL ((double) US_IN_SEC) -#define NS_IN_MS 1000000LL -#define NS_IN_MS_DBL 1E6 #define NS_IN_SEC 1000000000LL #define NS_IN_SEC_DBL ((double) NS_IN_SEC) #define NS_IN_US (NS_IN_SEC/US_IN_SEC) @@ -98,6 +96,7 @@ typedef long long time_ns_t; #define US_TO_MS(val_us) ((val_us) / 1000) #define MS_TO_US(val_ms) ((val_ms) * 1000) #define NS_TO_MS(val_ns) ((val_ns) / 1000 / 1000) +#define MS_TO_NS(val_ms) ((val_ms) * 1000) static inline time_ns_t get_time_in_ns() { #ifdef HAVE_TIMESPEC_GET diff --git a/src/video_capture/syphon.m b/src/video_capture/syphon.m index 9c56ad208..0edce8cb9 100644 --- a/src/video_capture/syphon.m +++ b/src/video_capture/syphon.m @@ -513,7 +513,7 @@ static struct video_frame *vidcap_syphon_grab(void *state, struct audio_frame ** struct timespec ts; timespec_get(&ts, TIME_UTC); - ts_add_nsec(&ts, 100 * NS_IN_MS); + ts_add_nsec(&ts, MS_TO_NS(100LL)); pthread_mutex_lock(&s->lock); while (simple_linked_list_size(s->q) == 0) { if (pthread_cond_timedwait(&s->frame_ready_cv, &s->lock, &ts) != 0) { diff --git a/src/video_compress/libavcodec.cpp b/src/video_compress/libavcodec.cpp index aa6d605ba..eff669615 100644 --- a/src/video_compress/libavcodec.cpp +++ b/src/video_compress/libavcodec.cpp @@ -1284,8 +1284,12 @@ static void check_duration(struct state_video_compress_libav *s, time_ns_t dur_p bool src_rgb = codec_is_a_rgb(s->saved_desc.color_spec); bool dst_rgb = av_pix_fmt_desc_get(s->codec_ctx->pix_fmt)->flags & AV_PIX_FMT_FLAG_RGB; if (src_rgb != dst_rgb && dur_pixfmt_change_ns / NS_IN_SEC_DBL > s->mov_avg_comp_duration / 4) { - LOG(LOG_LEVEL_WARNING) << MOD_NAME "Also pixfmt change of last frame took " << dur_pixfmt_change_ns / NS_IN_MS_DBL << " ms.\n" - "Consider adding \"--conv-policy cds\" to prevent color space conversion.\n"; + LOG(LOG_LEVEL_WARNING) + << MOD_NAME "Also pixfmt change of last frame took " + << NS_TO_MS((double) dur_pixfmt_change_ns) + << " ms.\n" + "Consider adding \"--conv-policy cds\" to prevent color " + "space conversion.\n"; } } diff --git a/src/video_decompress/libavcodec.c b/src/video_decompress/libavcodec.c index 087cc079f..93b0a095b 100644 --- a/src/video_decompress/libavcodec.c +++ b/src/video_decompress/libavcodec.c @@ -1082,7 +1082,7 @@ static decompress_status libavcodec_decompress(void *state, unsigned char *dst, } time_ns_t t2 = get_time_in_ns(); log_msg(LOG_LEVEL_DEBUG, MOD_NAME "Decompressing %c frame took %f ms, pixfmt change %f ms.\n", av_get_picture_type_char(s->frame->pict_type), - (t1 - t0) / NS_IN_MS_DBL, (t2 - t1) / NS_IN_MS_DBL); + NS_TO_MS((double) (t1 - t0)), NS_TO_MS((double) (t2 - t1))); check_duration(s, (t2 - t0) / NS_IN_SEC_DBL, (t2 - t1) / NS_IN_SEC_DBL); if (s->out_codec == VIDEO_CODEC_NONE) { diff --git a/src/video_display/caca.c b/src/video_display/caca.c index bbd014230..c6973110f 100644 --- a/src/video_display/caca.c +++ b/src/video_display/caca.c @@ -245,7 +245,7 @@ static void *worker(void *arg) struct video_frame *f = NULL; struct timespec ts; timespec_get(&ts, TIME_UTC); - ts_add_nsec(&ts, 200 * NS_IN_MS); // 200 ms + ts_add_nsec(&ts, MS_TO_NS(200LL)); // 200 ms pthread_mutex_lock(&s->lock); while (!s->f && !s->should_exit) { pthread_cond_timedwait(&s->frame_ready_cv, &s->lock, &ts);