On Mon, 30 Jan 2017, Peter Große wrote:
On Sun, 29 Jan 2017 22:49:51 +0200 (EET)
Martin Storsjö <[email protected]> wrote:
+ if (!os->bit_rate) {
+ // calculate average bitrate of first segment
+ double bitrate = (int)( (double) range_length * 8.0 *
AV_TIME_BASE / (double)(os->max_pts - os->start_pts) );
Sorry for not pointing it out in the last round, but promoting this to
double feels a bit superfluous. Just cast to int64_t instead, that should
be just fine for this use case. (Floats can end up rounded differently on
different platforms, and even though it doesn't really matter here, having
it completely determinisic when easily possible is desireable.)
Which of the 3 mentions of "double" do you mean?
All of them - I don't see the point in using floats at all here.
The last one "max_pts-start_pts" shouldn't be necessary then, because both are
already of type int64_t.
So something like this?
int64_t bitrate = ( (int64_t) range_length * 8 * AV_TIME_BASE / (os->max_pts -
os->start_pts) );
Yes, that should be fine
But then the range check below that code doesn't make sense.
Well, you can probably keep just a bitrate >= 0 check, while the other one
doesn't make sense.
Overflows/wraparounds for signed integers are undefined (and since in this
case, range_length is an int, the multiplications can't overflow), so the
only way you can actually end up negative is if range_length is negative
or if the ptses are wrong.
// Martin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel