FFmpeg
ratecontrol.h
Go to the documentation of this file.
1 /*
2  * Ratecontrol
3  * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
4  * Copyright (c) 2002-2004 Michael Niedermayer
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #ifndef AVCODEC_RATECONTROL_H
24 #define AVCODEC_RATECONTROL_H
25 
26 /**
27  * @file
28  * ratecontrol header.
29  */
30 
31 #include <stdint.h>
32 
33 typedef struct Predictor{
34  double coeff;
35  double count;
36  double decay;
37 } Predictor;
38 
39 typedef struct RateControlEntry{
40  int pict_type;
41  float qscale;
42  int i_count;
43  int f_code;
44  int b_code;
45  int mv_bits;
48  int misc_bits;
50  uint64_t expected_bits;
52  float new_qscale;
56 
57 /**
58  * rate control context.
59  */
60 typedef struct RateControlContext{
61  int num_entries; ///< number of RateControlEntries
63  double buffer_index; ///< amount of bits in the video/audio buffer
65  double short_term_qsum; ///< sum of recent qscales
66  double short_term_qcount; ///< count of recent qscales
67  double pass1_rc_eq_output_sum;///< sum of the output of the rc equation, this is used for normalization
68  double pass1_wanted_bits; ///< bits which should have been output by the pass1 code (including complexity init)
69  double last_qscale;
70  double last_qscale_for[5]; ///< last qscale for a specific pict type, used for max_diff & ipb factor stuff
73  uint64_t i_cplx_sum[5];
74  uint64_t p_cplx_sum[5];
75  uint64_t mv_bits_sum[5];
76  uint64_t qscale_sum[5];
77  int frame_count[5];
79 
80  struct AVExpr *rc_eq_eval;
82 
83 struct MpegEncContext;
84 
85 /* rate control */
87 float ff_rate_estimate_qscale(struct MpegEncContext *s, int dry_run);
89 int ff_vbv_update(struct MpegEncContext *s, int frame_size);
90 void ff_get_2pass_fcode(struct MpegEncContext *s);
92 
93 #endif /* AVCODEC_RATECONTROL_H */
RateControlContext::last_mb_var_sum
int64_t last_mb_var_sum
Definition: ratecontrol.h:72
Predictor
Predictor
Definition: huffyuv.h:52
int64_t
long long int64_t
Definition: coverity.c:34
RateControlEntry
Definition: ratecontrol.h:39
RateControlEntry::i_count
int i_count
Definition: ratecontrol.h:42
RateControlContext::rc_eq_eval
struct AVExpr * rc_eq_eval
Definition: ratecontrol.h:80
RateControlEntry::f_code
int f_code
Definition: ratecontrol.h:43
RateControlEntry::p_tex_bits
int p_tex_bits
Definition: ratecontrol.h:47
RateControlContext::short_term_qcount
double short_term_qcount
count of recent qscales
Definition: ratecontrol.h:66
ff_get_2pass_fcode
void ff_get_2pass_fcode(struct MpegEncContext *s)
Definition: ratecontrol.c:884
RateControlContext::pred
Predictor pred[5]
Definition: ratecontrol.h:64
RateControlContext
rate control context.
Definition: ratecontrol.h:60
RateControlContext::num_entries
int num_entries
number of RateControlEntries
Definition: ratecontrol.h:61
s
#define s(width, name)
Definition: cbs_vp9.c:198
frame_size
int frame_size
Definition: mxfenc.c:2424
RateControlContext::pass1_wanted_bits
double pass1_wanted_bits
bits which should have been output by the pass1 code (including complexity init)
Definition: ratecontrol.h:68
RateControlEntry::misc_bits
int misc_bits
Definition: ratecontrol.h:48
Predictor::coeff
double coeff
Definition: ratecontrol.h:34
RateControlEntry::new_pict_type
int new_pict_type
Definition: ratecontrol.h:51
AVExpr
Definition: eval.c:158
Predictor::count
double count
Definition: ratecontrol.h:35
RateControlEntry::b_code
int b_code
Definition: ratecontrol.h:44
RateControlEntry::pict_type
int pict_type
Definition: ratecontrol.h:40
RateControlEntry::header_bits
int header_bits
Definition: ratecontrol.h:49
RateControlContext::qscale_sum
uint64_t qscale_sum[5]
Definition: ratecontrol.h:76
RateControlEntry::new_qscale
float new_qscale
Definition: ratecontrol.h:52
ff_rate_control_uninit
void ff_rate_control_uninit(RateControlContext *rcc)
Definition: ratecontrol.c:700
RateControlContext::mv_bits_sum
uint64_t mv_bits_sum[5]
Definition: ratecontrol.h:75
ff_rate_control_init
int ff_rate_control_init(struct MpegEncContext *s)
Definition: ratecontrol.c:497
Predictor::decay
double decay
Definition: ratecontrol.h:36
ff_vbv_update
int ff_vbv_update(struct MpegEncContext *s, int frame_size)
Definition: ratecontrol.c:709
Predictor
Definition: ratecontrol.h:33
RateControlContext::pass1_rc_eq_output_sum
double pass1_rc_eq_output_sum
sum of the output of the rc equation, this is used for normalization
Definition: ratecontrol.h:67
RateControlEntry::qscale
float qscale
Definition: ratecontrol.h:41
RateControlEntry::mv_bits
int mv_bits
Definition: ratecontrol.h:45
RateControlContext::last_mc_mb_var_sum
int64_t last_mc_mb_var_sum
Definition: ratecontrol.h:71
RateControlContext::frame_count
int frame_count[5]
Definition: ratecontrol.h:77
ff_rate_estimate_qscale
float ff_rate_estimate_qscale(struct MpegEncContext *s, int dry_run)
Definition: ratecontrol.c:895
RateControlContext::buffer_index
double buffer_index
amount of bits in the video/audio buffer
Definition: ratecontrol.h:63
RateControlContext::last_non_b_pict_type
int last_non_b_pict_type
Definition: ratecontrol.h:78
RateControlContext::last_qscale_for
double last_qscale_for[5]
last qscale for a specific pict type, used for max_diff & ipb factor stuff
Definition: ratecontrol.h:70
RateControlContext::i_cplx_sum
uint64_t i_cplx_sum[5]
Definition: ratecontrol.h:73
RateControlEntry::mc_mb_var_sum
int64_t mc_mb_var_sum
Definition: ratecontrol.h:53
RateControlContext::short_term_qsum
double short_term_qsum
sum of recent qscales
Definition: ratecontrol.h:65
RateControlContext::p_cplx_sum
uint64_t p_cplx_sum[5]
Definition: ratecontrol.h:74
RateControlEntry::expected_bits
uint64_t expected_bits
Definition: ratecontrol.h:50
RateControlEntry::i_tex_bits
int i_tex_bits
Definition: ratecontrol.h:46
RateControlEntry::mb_var_sum
int64_t mb_var_sum
Definition: ratecontrol.h:54
RateControlContext::last_qscale
double last_qscale
Definition: ratecontrol.h:69
MpegEncContext
MpegEncContext.
Definition: mpegvideo.h:73
RateControlContext::entry
RateControlEntry * entry
Definition: ratecontrol.h:62
ff_write_pass1_stats
void ff_write_pass1_stats(struct MpegEncContext *s)
Definition: ratecontrol.c:38