mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-21 14:40:22 +00:00
tv.h (+others): get rid of NS_IN_MS[_DBL]
Use rather the more comprehensible NS_TO_MS and NS_TO_MS function-like macros (obvious from what to what the conversion is performed).
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
3
src/tv.h
3
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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user