avcodec/ituh263enc: compute the temporal reference with av_rescale_rnd()

The hand written multiply and divide can overflow int64_t for a large
time_base.num; av_rescale_rnd() computes the same truncating division
exactly.
This commit is contained in:
Michael Niedermayer authored and michaelni committed 2026-09-19 18:47:12 +00:00
1 parent c8949215c9
commit 356dfc3bd1
1 file changed
+2 -2
+2 -2
View File
@@ -245,8 +245,8 @@ static int h263_encode_picture_header(MPVMainEncContext *const m)
coded_frame_rate_base= (1000+best_clock_code)*best_divisor;
put_bits(&s->pb, 22, 0x20); /* PSC */
temp_ref = s->picture_number * (int64_t)coded_frame_rate * s->c.avctx->time_base.num / //FIXME use timestamp
(coded_frame_rate_base * (int64_t)s->c.avctx->time_base.den);
temp_ref = av_rescale_rnd(s->picture_number, coded_frame_rate * (int64_t)s->c.avctx->time_base.num, //FIXME use timestamp
coded_frame_rate_base * (int64_t)s->c.avctx->time_base.den, AV_ROUND_ZERO);
put_sbits(&s->pb, 8, temp_ref); /* TemporalReference */
put_bits(&s->pb, 1, 1); /* marker */