annotate ratecontrol.h @ 9024:2bf694251330 libavcodec

Add ff_h263_find_resync_marker() to find the bit position of the next resync_marker, if any. patch by Gwenole Beauchesne gbeauchesne splitted-desktopcom based on suggested implementation by me
author michael
date Tue, 24 Feb 2009 16:12:47 +0000
parents e9d9d946f213
children e22a96273dc4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
1 /*
3789
730ad999e379 Move the ratecontrol related code from mpegvideo.h to a separate header file.
takis
parents: 3786
diff changeset
2 * Ratecontrol
8629
04423b2f6e0b cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents: 7760
diff changeset
3 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
1739
07a484280a82 copyright year update of the files i touched and remembered, things look annoyingly unmaintained otherwise
michael
parents: 1719
diff changeset
4 * Copyright (c) 2002-2004 Michael Niedermayer
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
5 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3789
diff changeset
6 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3789
diff changeset
7 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3789
diff changeset
8 * FFmpeg is free software; you can redistribute it and/or
429
718a22dc121f license/copyright change
glantau
parents: 411
diff changeset
9 * modify it under the terms of the GNU Lesser General Public
718a22dc121f license/copyright change
glantau
parents: 411
diff changeset
10 * License as published by the Free Software Foundation; either
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3789
diff changeset
11 * version 2.1 of the License, or (at your option) any later version.
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
12 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3789
diff changeset
13 * FFmpeg is distributed in the hope that it will be useful,
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
429
718a22dc121f license/copyright change
glantau
parents: 411
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
718a22dc121f license/copyright change
glantau
parents: 411
diff changeset
16 * Lesser General Public License for more details.
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
17 *
429
718a22dc121f license/copyright change
glantau
parents: 411
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3789
diff changeset
19 * License along with FFmpeg; if not, write to the Free Software
3036
0b546eab515d Update licensing information: The FSF changed postal address.
diego
parents: 2997
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
21 */
986e461dc072 Initial revision
glantau
parents:
diff changeset
22
7760
c4a4495715dd Globally rename the header inclusion guard names.
stefano
parents: 5830
diff changeset
23 #ifndef AVCODEC_RATECONTROL_H
c4a4495715dd Globally rename the header inclusion guard names.
stefano
parents: 5830
diff changeset
24 #define AVCODEC_RATECONTROL_H
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
25
3789
730ad999e379 Move the ratecontrol related code from mpegvideo.h to a separate header file.
takis
parents: 3786
diff changeset
26 /**
8718
e9d9d946f213 Use full internal pathname in doxygen @file directives.
diego
parents: 8629
diff changeset
27 * @file libavcodec/ratecontrol.h
3789
730ad999e379 Move the ratecontrol related code from mpegvideo.h to a separate header file.
takis
parents: 3786
diff changeset
28 * ratecontrol header.
730ad999e379 Move the ratecontrol related code from mpegvideo.h to a separate header file.
takis
parents: 3786
diff changeset
29 */
3068
9aa8d8587bea fixing bframe strategy 2
michael
parents: 3066
diff changeset
30
5162
4394344397d8 include all prerequisites in header files
mru
parents: 4084
diff changeset
31 #include <stdio.h>
4394344397d8 include all prerequisites in header files
mru
parents: 4084
diff changeset
32 #include <stdint.h>
4084
90e848a24c70 update ratecontrol to new ff_eval API
ods15
parents: 3947
diff changeset
33 #include "eval.h"
90e848a24c70 update ratecontrol to new ff_eval API
ods15
parents: 3947
diff changeset
34
268
09ae29b27ed9 hopefully better bitrate controll
michaelni
parents: 266
diff changeset
35 typedef struct Predictor{
09ae29b27ed9 hopefully better bitrate controll
michaelni
parents: 266
diff changeset
36 double coeff;
09ae29b27ed9 hopefully better bitrate controll
michaelni
parents: 266
diff changeset
37 double count;
09ae29b27ed9 hopefully better bitrate controll
michaelni
parents: 266
diff changeset
38 double decay;
09ae29b27ed9 hopefully better bitrate controll
michaelni
parents: 266
diff changeset
39 } Predictor;
09ae29b27ed9 hopefully better bitrate controll
michaelni
parents: 266
diff changeset
40
329
5cc47d0ba53e fixed ratecontrol & b-frames
michaelni
parents: 327
diff changeset
41 typedef struct RateControlEntry{
5cc47d0ba53e fixed ratecontrol & b-frames
michaelni
parents: 327
diff changeset
42 int pict_type;
690
a1c69cb685b3 adaptive quantization (lumi/temporal & spatial complexity masking)
michaelni
parents: 680
diff changeset
43 float qscale;
329
5cc47d0ba53e fixed ratecontrol & b-frames
michaelni
parents: 327
diff changeset
44 int mv_bits;
5cc47d0ba53e fixed ratecontrol & b-frames
michaelni
parents: 327
diff changeset
45 int i_tex_bits;
5cc47d0ba53e fixed ratecontrol & b-frames
michaelni
parents: 327
diff changeset
46 int p_tex_bits;
5cc47d0ba53e fixed ratecontrol & b-frames
michaelni
parents: 327
diff changeset
47 int misc_bits;
3064
a5e0b58b4471 xvid ratecontrol support
michael
parents: 3036
diff changeset
48 int header_bits;
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
49 uint64_t expected_bits;
329
5cc47d0ba53e fixed ratecontrol & b-frames
michaelni
parents: 327
diff changeset
50 int new_pict_type;
5cc47d0ba53e fixed ratecontrol & b-frames
michaelni
parents: 327
diff changeset
51 float new_qscale;
612
c0005de2be59 new ratecontrol code
michaelni
parents: 608
diff changeset
52 int mc_mb_var_sum;
c0005de2be59 new ratecontrol code
michaelni
parents: 608
diff changeset
53 int mb_var_sum;
c0005de2be59 new ratecontrol code
michaelni
parents: 608
diff changeset
54 int i_count;
3064
a5e0b58b4471 xvid ratecontrol support
michael
parents: 3036
diff changeset
55 int skip_count;
612
c0005de2be59 new ratecontrol code
michaelni
parents: 608
diff changeset
56 int f_code;
c0005de2be59 new ratecontrol code
michaelni
parents: 608
diff changeset
57 int b_code;
329
5cc47d0ba53e fixed ratecontrol & b-frames
michaelni
parents: 327
diff changeset
58 }RateControlEntry;
5cc47d0ba53e fixed ratecontrol & b-frames
michaelni
parents: 327
diff changeset
59
1110
d4096635b7b9 doxy / cosmetics
michaelni
parents: 1106
diff changeset
60 /**
d4096635b7b9 doxy / cosmetics
michaelni
parents: 1106
diff changeset
61 * rate control context.
d4096635b7b9 doxy / cosmetics
michaelni
parents: 1106
diff changeset
62 */
329
5cc47d0ba53e fixed ratecontrol & b-frames
michaelni
parents: 327
diff changeset
63 typedef struct RateControlContext{
5cc47d0ba53e fixed ratecontrol & b-frames
michaelni
parents: 327
diff changeset
64 FILE *stats_file;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2805
diff changeset
65 int num_entries; ///< number of RateControlEntries
329
5cc47d0ba53e fixed ratecontrol & b-frames
michaelni
parents: 327
diff changeset
66 RateControlEntry *entry;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2805
diff changeset
67 double buffer_index; ///< amount of bits in the video/audio buffer
612
c0005de2be59 new ratecontrol code
michaelni
parents: 608
diff changeset
68 Predictor pred[5];
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2805
diff changeset
69 double short_term_qsum; ///< sum of recent qscales
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2805
diff changeset
70 double short_term_qcount; ///< count of recent qscales
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2805
diff changeset
71 double pass1_rc_eq_output_sum;///< sum of the output of the rc equation, this is used for normalization
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2805
diff changeset
72 double pass1_wanted_bits; ///< bits which should have been outputed by the pass1 code (including complexity init)
612
c0005de2be59 new ratecontrol code
michaelni
parents: 608
diff changeset
73 double last_qscale;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2805
diff changeset
74 double last_qscale_for[5]; ///< last qscale for a specific pict type, used for max_diff & ipb factor stuff
612
c0005de2be59 new ratecontrol code
michaelni
parents: 608
diff changeset
75 int last_mc_mb_var_sum;
c0005de2be59 new ratecontrol code
michaelni
parents: 608
diff changeset
76 int last_mb_var_sum;
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
77 uint64_t i_cplx_sum[5];
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
78 uint64_t p_cplx_sum[5];
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
79 uint64_t mv_bits_sum[5];
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
80 uint64_t qscale_sum[5];
612
c0005de2be59 new ratecontrol code
michaelni
parents: 608
diff changeset
81 int frame_count[5];
680
79393a88c6e4 10l (forgot to commit)
michaelni
parents: 676
diff changeset
82 int last_non_b_pict_type;
3064
a5e0b58b4471 xvid ratecontrol support
michael
parents: 3036
diff changeset
83
a5e0b58b4471 xvid ratecontrol support
michael
parents: 3036
diff changeset
84 void *non_lavc_opaque; ///< context for non lavc rc code (for example xvid)
a5e0b58b4471 xvid ratecontrol support
michael
parents: 3036
diff changeset
85 float dry_run_qscale; ///< for xvid rc
3204
5fc631919a98 various fixes for xvid_rc
michael
parents: 3089
diff changeset
86 int last_picture_number; ///< for xvid rc
4084
90e848a24c70 update ratecontrol to new ff_eval API
ods15
parents: 3947
diff changeset
87 AVEvalExpr * rc_eq_eval;
329
5cc47d0ba53e fixed ratecontrol & b-frames
michaelni
parents: 327
diff changeset
88 }RateControlContext;
5cc47d0ba53e fixed ratecontrol & b-frames
michaelni
parents: 327
diff changeset
89
936
caa77cd960c0 qpel encoding
michaelni
parents: 930
diff changeset
90 struct MpegEncContext;
caa77cd960c0 qpel encoding
michaelni
parents: 930
diff changeset
91
3789
730ad999e379 Move the ratecontrol related code from mpegvideo.h to a separate header file.
takis
parents: 3786
diff changeset
92 /* rate control */
730ad999e379 Move the ratecontrol related code from mpegvideo.h to a separate header file.
takis
parents: 3786
diff changeset
93 int ff_rate_control_init(struct MpegEncContext *s);
730ad999e379 Move the ratecontrol related code from mpegvideo.h to a separate header file.
takis
parents: 3786
diff changeset
94 float ff_rate_estimate_qscale(struct MpegEncContext *s, int dry_run);
730ad999e379 Move the ratecontrol related code from mpegvideo.h to a separate header file.
takis
parents: 3786
diff changeset
95 void ff_write_pass1_stats(struct MpegEncContext *s);
730ad999e379 Move the ratecontrol related code from mpegvideo.h to a separate header file.
takis
parents: 3786
diff changeset
96 void ff_rate_control_uninit(struct MpegEncContext *s);
730ad999e379 Move the ratecontrol related code from mpegvideo.h to a separate header file.
takis
parents: 3786
diff changeset
97 int ff_vbv_update(struct MpegEncContext *s, int frame_size);
730ad999e379 Move the ratecontrol related code from mpegvideo.h to a separate header file.
takis
parents: 3786
diff changeset
98 void ff_get_2pass_fcode(struct MpegEncContext *s);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2805
diff changeset
99
3789
730ad999e379 Move the ratecontrol related code from mpegvideo.h to a separate header file.
takis
parents: 3786
diff changeset
100 int ff_xvid_rate_control_init(struct MpegEncContext *s);
730ad999e379 Move the ratecontrol related code from mpegvideo.h to a separate header file.
takis
parents: 3786
diff changeset
101 void ff_xvid_rate_control_uninit(struct MpegEncContext *s);
730ad999e379 Move the ratecontrol related code from mpegvideo.h to a separate header file.
takis
parents: 3786
diff changeset
102 float ff_xvid_rate_estimate_qscale(struct MpegEncContext *s, int dry_run);
930
6bcb214d6a17 more debug output
michaelni
parents: 925
diff changeset
103
7760
c4a4495715dd Globally rename the header inclusion guard names.
stefano
parents: 5830
diff changeset
104 #endif /* AVCODEC_RATECONTROL_H */
1652
834922115010 cleanup
michael
parents: 1649
diff changeset
105