[FFmpeg-devel] [PATCH v4] Add 2 timestamp print formats

Ulf Zibis Ulf.Zibis at CoSoCo.de
Wed Jul 3 20:09:02 EEST 2019


Am 03.07.19 um 16:49 schrieb Ulf Zibis:
> Am 03.07.19 um 10:52 schrieb Michael Niedermayer:
>>>>> -#define av_ts2timestr(ts, tb) av_ts_make_time_string((char[AV_TS_MAX_STRING_SIZE]){0}, ts, tb)
>>>>> +#define av_ts2timestr(ts, tb) av_ts_make_time_string((char[AV_TS_MAX_STRING_SIZE]){'\0'}, ts, tb)
>>>>> +
>>>>> +/**
>>>>> + * Fill the provided buffer with a string containing a timestamp time
>>>>> + * representation in minutes and seconds.
>>>>> + *
>>>>> + * @param buf a buffer with size in bytes of at least AV_TS_MAX_STRING_SIZE
>>>>> + * @param ts the timestamp to represent
>>>>> + * @param tb the timebase of the timestamp
>>>>> + * @return the buffer in input
>>>>> + */
>>>>> +static inline char *av_ts_make_minute_string(char *buf, int64_t ts, AVRational *tb)
>>>>> +{
>>>>> +    if (ts == AV_NOPTS_VALUE) snprintf(buf, AV_TS_MAX_STRING_SIZE, "NOPTS");
>>>>> +    else {
>>>>> +        double time = av_q2d(*tb) * ts;
>>>> If this could be done without float/double that would be preferred as it
>>>> avoids inaccuracies / slight differences between platforms
>>> I too thought on that, but the existing functions too rely on
>>> float/double. Should I anyway provide a solution with integer arithmetic?
>> its indepedant of your patch but i think all these should use integers
>> unless its too messy
> Thanks for you opinion.
>
> Here comes a new patch.

I missed to mark the big integer literal with 'L' and add "must be less
than 2**63/1,000,000/tb->num" to all 3 functions. So I attach a correction.

-Ulf

-------------- next part --------------
A non-text attachment was scrubbed...
Name: timestamp_4.patch
Type: text/x-patch
Size: 3559 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20190703/84676c75/attachment.bin>


More information about the ffmpeg-devel mailing list