Showing the changes to libavcodec (1 of 1 file). Show all
Unified · Split
| @@ -56,20 +56,25 @@ void ff_write_pass1_stats(MpegEncContext *s) · 55 unmodified lines | ||
| 56 | 56 | s->header_bits); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | −static double get_fps(AVCodecContext *avctx) | |
| 59 | +static AVRational get_fpsQ(AVCodecContext *avctx) | |
| 60 | 60 | { |
| 61 | 61 | if (avctx->framerate.num > 0 && avctx->framerate.den > 0) |
| 62 | − return av_q2d(avctx->framerate); | |
| 62 | + return avctx->framerate; | |
| 63 | 63 | |
| 64 | 64 | FF_DISABLE_DEPRECATION_WARNINGS |
| 65 | − return 1.0 / av_q2d(avctx->time_base) | |
| 66 | 65 | #if FF_API_TICKS_PER_FRAME |
| 67 | − / FFMAX(avctx->ticks_per_frame, 1) | |
| 66 | + return av_div_q((AVRational){1, FFMAX(avctx->ticks_per_frame, 1)}, avctx->time_base); | |
| 67 | +#else | |
| 68 | + return av_inv_q(avctx->time_base); | |
| 68 | 69 | #endif |
| 69 | − ; | |
| 70 | 70 | FF_ENABLE_DEPRECATION_WARNINGS |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | +static double get_fps(AVCodecContext *avctx) | |
| 74 | +{ | |
| 75 | + return av_q2d(get_fpsQ(avctx)); | |
| 76 | +} | |
| 77 | + | |
| 73 | 78 | static inline double qp2bits(const RateControlEntry *rce, double qp) |
| 74 | 79 | { |
| 75 | 80 | if (qp <= 0.0) { |
| @@ -332,12 +337,13 @@ static int init_pass2(MpegEncContext *s) · 256 unmodified lines | ||
| 332 | 337 | RateControlContext *rcc = &s->rc_context; |
| 333 | 338 | AVCodecContext *a = s->avctx; |
| 334 | 339 | int i, toobig; |
| 335 | − double fps = get_fps(s->avctx); | |
| 340 | + AVRational fps = get_fpsQ(s->avctx); | |
| 336 | 341 | double complexity[5] = { 0 }; // approximate bits at quant=1 |
| 337 | 342 | uint64_t const_bits[5] = { 0 }; // quantizer independent bits |
| 338 | 343 | uint64_t all_const_bits; |
| 339 | − uint64_t all_available_bits = (uint64_t)(s->bit_rate * | |
| 340 | − (double)rcc->num_entries / fps); | |
| 344 | + uint64_t all_available_bits = av_rescale_q(s->bit_rate, | |
| 345 | + (AVRational){rcc->num_entries,1}, | |
| 346 | + fps); | |
| 341 | 347 | double rate_factor = 0; |
| 342 | 348 | double step; |
| 343 | 349 | const int filter_size = (int)(a->qblur * 4) | 1; |