avcodec: avoid division by zero in avcodec_string

Actually time_base should not be 0/0, but the proper fix is part of
commit 7ea1b34, which can't be backported, as it changes API.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
This commit is contained in:
Andreas Cadhalpun 2015-11-26 01:15:28 +01:00
parent ae1156ef2a
commit db13758b88
1 changed files with 2 additions and 0 deletions

View File

@ -2970,6 +2970,8 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
}
if (av_log_get_level() >= AV_LOG_DEBUG) {
int g = av_gcd(enc->time_base.num, enc->time_base.den);
if (!g)
g = 1;
snprintf(buf + strlen(buf), buf_size - strlen(buf),
", %d/%d",
enc->time_base.num / g, enc->time_base.den / g);