[FFmpeg-devel] [PATCH] avformat/utils: improve get duration

Carl Eugen Hoyos cehoyos at ag.or.at
Thu May 30 18:19:38 CEST 2013


Ping Kai <pingkai010 <at> gmail.com> writes:

> improve the accuracy of getting
> duration from bit rate.

Could you provide a sample that gets an 
improved duration by your patch?

> +    int64_t *sample_bit_rate_sum = av_malloc(ic->nb_streams * 
> sizeof(int64_t));
> +    int *sample_count = av_malloc(ic->nb_streams * sizeof(int));
> 
> +    if (sample_bit_rate_sum == NULL || sample_count == NULL)

> +        return AVERROR_INVALIDDATA;

AVERROR(ENOMEM)

> +    memset(sample_bit_rate_sum ,0 ,ic->nb_streams * sizeof(int64_t));
> +    memset(sample_count,0 ,ic->nb_streams * sizeof(int));

If you use av_mallocz, the memset should not be 
necessary.

> -

Do not remove the empty line, same below.

Carl Eugen



More information about the ffmpeg-devel mailing list