Re: [spice v6] server: Provide a framerate estimate based on the initial frames

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 10 Dec 2015, Victor Toso wrote:
[...]
> > > +    drawable->creation_time = drawable->first_frame_time =red_get_monotonic_time();
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
> need extra space!

Yes. I fixed it locally but I'm hesitant to resubmit just for that.
In the worst case it will be fixed with the rename to 
spice_get_monotonic_ns().


[...]
> > > +    /* Provide an fps estimate the video encoder can use when initializing
> > > +     * based on the frames that lead to the creation of the stream. Round to
> > > +     * the nearest integer, for instance 24 for 23.976.
> > > +     */
> > > +    uint64_t duration = drawable->creation_time - drawable->first_frame_time;
> > > +    if (duration > (uint64_t)drawable->frames_count * 1000 * 1000 * 1000 / MAX_FPS) {
> > > +        stream->input_fps = ((uint64_t)drawable->frames_count * 1000 * 1000 * 1000 + duration / 2) / duration;
> 
> Why + (duration/2) ? This would be the same as [ x/2 + 1/2 ] so I'm
> guessing it is for the rounding, right?

Yes, it's to round to the nearest integer.
The general principle is that if your division truncates, then 
round_to_nearest( ((double)x) / n ) = (x + n/2) / n

I'll also note that this is a case where we want the most accurate 
estimate of the fps so round to nearest makes sense.

-- 
Francois Gouget <fgouget@xxxxxxxxxxxxxxx>
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]