## ffmpeg / libavcodec / ratecontrol.h @ 7a886063

History | View | Annotate | Download (3.26 KB)

1 | 0de9926f | Panagiotis Issaris | ```
/*
``` |
---|---|---|---|

2 | ```
* Ratecontrol
``` |
||

3 | ```
* Copyright (c) 2000, 2001, 2002 Fabrice Bellard.
``` |
||

4 | ```
* Copyright (c) 2002-2004 Michael Niedermayer
``` |
||

5 | ```
*
``` |
||

6 | b78e7197 | Diego Biurrun | ```
* This file is part of FFmpeg.
``` |

7 | ```
*
``` |
||

8 | ```
* FFmpeg is free software; you can redistribute it and/or
``` |
||

9 | 0de9926f | Panagiotis Issaris | ```
* modify it under the terms of the GNU Lesser General Public
``` |

10 | ```
* License as published by the Free Software Foundation; either
``` |
||

11 | b78e7197 | Diego Biurrun | ```
* version 2.1 of the License, or (at your option) any later version.
``` |

12 | 0de9926f | Panagiotis Issaris | ```
*
``` |

13 | b78e7197 | Diego Biurrun | ```
* FFmpeg is distributed in the hope that it will be useful,
``` |

14 | 0de9926f | Panagiotis Issaris | ```
* 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 | b78e7197 | Diego Biurrun | ```
* License along with FFmpeg; if not, write to the Free Software
``` |

20 | 0de9926f | Panagiotis Issaris | ```
* 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 ratecontrol.h
``` |
||

28 | ```
* ratecontrol header.
``` |
||

29 | ```
*/
``` |
||

30 | |||

31 | bb0f1ea7 | Oded Shimon | #include "eval.h" |

32 | |||

33 | 0de9926f | Panagiotis Issaris | 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 mv_bits;
``` |
||

43 | ```
int i_tex_bits;
``` |
||

44 | ```
int p_tex_bits;
``` |
||

45 | ```
int misc_bits;
``` |
||

46 | ```
int header_bits;
``` |
||

47 | uint64_t expected_bits; |
||

48 | ```
int new_pict_type;
``` |
||

49 | ```
float new_qscale;
``` |
||

50 | ```
int mc_mb_var_sum;
``` |
||

51 | ```
int mb_var_sum;
``` |
||

52 | ```
int i_count;
``` |
||

53 | ```
int skip_count;
``` |
||

54 | ```
int f_code;
``` |
||

55 | ```
int b_code;
``` |
||

56 | }RateControlEntry; |
||

57 | |||

58 | ```
/**
``` |
||

59 | ```
* rate control context.
``` |
||

60 | ```
*/
``` |
||

61 | typedef struct RateControlContext{ |
||

62 | FILE *stats_file; |
||

63 | int num_entries; ///< number of RateControlEntries |
||

64 | RateControlEntry *entry; |
||

65 | double buffer_index; ///< amount of bits in the video/audio buffer |
||

66 | ```
Predictor pred[5];
``` |
||

67 | double short_term_qsum; ///< sum of recent qscales |
||

68 | double short_term_qcount; ///< count of recent qscales |
||

69 | double pass1_rc_eq_output_sum;///< sum of the output of the rc equation, this is used for normalization |
||

70 | double pass1_wanted_bits; ///< bits which should have been outputed by the pass1 code (including complexity init) |
||

71 | ```
double last_qscale;
``` |
||

72 | double last_qscale_for[5]; ///< last qscale for a specific pict type, used for max_diff & ipb factor stuff |
||

73 | ```
int last_mc_mb_var_sum;
``` |
||

74 | ```
int last_mb_var_sum;
``` |
||

75 | ```
uint64_t i_cplx_sum[5];
``` |
||

76 | ```
uint64_t p_cplx_sum[5];
``` |
||

77 | ```
uint64_t mv_bits_sum[5];
``` |
||

78 | ```
uint64_t qscale_sum[5];
``` |
||

79 | int frame_count[5]; |
||

80 | ```
int last_non_b_pict_type;
``` |
||

81 | |||

82 | void *non_lavc_opaque; ///< context for non lavc rc code (for example xvid) |
||

83 | float dry_run_qscale; ///< for xvid rc |
||

84 | int last_picture_number; ///< for xvid rc |
||

85 | bb0f1ea7 | Oded Shimon | AVEvalExpr * rc_eq_eval; |

86 | 0de9926f | Panagiotis Issaris | }RateControlContext; |

87 | |||

88 | ```
struct MpegEncContext;
``` |
||

89 | |||

90 | ```
/* rate control */
``` |
||

91 | int ff_rate_control_init(struct MpegEncContext *s); |
||

92 | float ff_rate_estimate_qscale(struct MpegEncContext *s, int dry_run); |
||

93 | void ff_write_pass1_stats(struct MpegEncContext *s); |
||

94 | void ff_rate_control_uninit(struct MpegEncContext *s); |
||

95 | int ff_vbv_update(struct MpegEncContext *s, int frame_size); |
||

96 | void ff_get_2pass_fcode(struct MpegEncContext *s); |
||

97 | |||

98 | int ff_xvid_rate_control_init(struct MpegEncContext *s); |
||

99 | void ff_xvid_rate_control_uninit(struct MpegEncContext *s); |
||

100 | float ff_xvid_rate_estimate_qscale(struct MpegEncContext *s, int dry_run); |
||

101 | |||

102 | #endif /* AVCODEC_RATECONTROL_H */ |