aarch64: Add assembly support for -fsanitize=hwaddress tagged globals.
[libav.git] / libavcodec / ratecontrol.h
blob7c289c6fbe6d94c17b3cd26d53e93825b920479e
1 /*
2 * Ratecontrol
3 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
4 * Copyright (c) 2002-2004 Michael Niedermayer
6 * This file is part of Libav.
8 * Libav 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.
13 * Libav 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.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with Libav; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #ifndef AVCODEC_RATECONTROL_H
24 #define AVCODEC_RATECONTROL_H
26 /**
27 * @file
28 * ratecontrol header.
31 #include <stdio.h>
32 #include <stdint.h>
33 #include "libavutil/eval.h"
35 typedef struct Predictor{
36 double coeff;
37 double count;
38 double decay;
39 } Predictor;
41 typedef struct RateControlEntry{
42 int pict_type;
43 float qscale;
44 int mv_bits;
45 int i_tex_bits;
46 int p_tex_bits;
47 int misc_bits;
48 int header_bits;
49 uint64_t expected_bits;
50 int new_pict_type;
51 float new_qscale;
52 int mc_mb_var_sum;
53 int mb_var_sum;
54 int i_count;
55 int skip_count;
56 int f_code;
57 int b_code;
58 }RateControlEntry;
60 /**
61 * rate control context.
63 typedef struct RateControlContext{
64 int num_entries; ///< number of RateControlEntries
65 RateControlEntry *entry;
66 double buffer_index; ///< amount of bits in the video/audio buffer
67 Predictor pred[5];
68 double short_term_qsum; ///< sum of recent qscales
69 double short_term_qcount; ///< count of recent qscales
70 double pass1_rc_eq_output_sum;///< sum of the output of the rc equation, this is used for normalization
71 double pass1_wanted_bits; ///< bits which should have been output by the pass1 code (including complexity init)
72 double last_qscale;
73 double last_qscale_for[5]; ///< last qscale for a specific pict type, used for max_diff & ipb factor stuff
74 int last_mc_mb_var_sum;
75 int last_mb_var_sum;
76 uint64_t i_cplx_sum[5];
77 uint64_t p_cplx_sum[5];
78 uint64_t mv_bits_sum[5];
79 uint64_t qscale_sum[5];
80 int frame_count[5];
81 int last_non_b_pict_type;
82 AVExpr * rc_eq_eval;
83 }RateControlContext;
85 struct MpegEncContext;
87 /* rate control */
88 int ff_rate_control_init(struct MpegEncContext *s);
89 float ff_rate_estimate_qscale(struct MpegEncContext *s, int dry_run);
90 void ff_rate_control_uninit(struct MpegEncContext *s);
91 int ff_vbv_update(struct MpegEncContext *s, int frame_size);
92 void ff_get_2pass_fcode(struct MpegEncContext *s);
94 #endif /* AVCODEC_RATECONTROL_H */