annotate ffmpeg/libavcodec/ratecontrol.h @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents 6840f77b83aa
children
rev   line source
yading@10 1 /*
yading@10 2 * Ratecontrol
yading@10 3 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
yading@10 4 * Copyright (c) 2002-2004 Michael Niedermayer
yading@10 5 *
yading@10 6 * This file is part of FFmpeg.
yading@10 7 *
yading@10 8 * FFmpeg is free software; you can redistribute it and/or
yading@10 9 * modify it under the terms of the GNU Lesser General Public
yading@10 10 * License as published by the Free Software Foundation; either
yading@10 11 * version 2.1 of the License, or (at your option) any later version.
yading@10 12 *
yading@10 13 * FFmpeg is distributed in the hope that it will be useful,
yading@10 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@10 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@10 16 * Lesser General Public License for more details.
yading@10 17 *
yading@10 18 * You should have received a copy of the GNU Lesser General Public
yading@10 19 * License along with FFmpeg; if not, write to the Free Software
yading@10 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@10 21 */
yading@10 22
yading@10 23 #ifndef AVCODEC_RATECONTROL_H
yading@10 24 #define AVCODEC_RATECONTROL_H
yading@10 25
yading@10 26 /**
yading@10 27 * @file
yading@10 28 * ratecontrol header.
yading@10 29 */
yading@10 30
yading@10 31 #include <stdio.h>
yading@10 32 #include <stdint.h>
yading@10 33 #include "libavutil/eval.h"
yading@10 34
yading@10 35 typedef struct Predictor{
yading@10 36 double coeff;
yading@10 37 double count;
yading@10 38 double decay;
yading@10 39 } Predictor;
yading@10 40
yading@10 41 typedef struct RateControlEntry{
yading@10 42 int pict_type;
yading@10 43 float qscale;
yading@10 44 int mv_bits;
yading@10 45 int i_tex_bits;
yading@10 46 int p_tex_bits;
yading@10 47 int misc_bits;
yading@10 48 int header_bits;
yading@10 49 uint64_t expected_bits;
yading@10 50 int new_pict_type;
yading@10 51 float new_qscale;
yading@10 52 int mc_mb_var_sum;
yading@10 53 int mb_var_sum;
yading@10 54 int i_count;
yading@10 55 int skip_count;
yading@10 56 int f_code;
yading@10 57 int b_code;
yading@10 58 }RateControlEntry;
yading@10 59
yading@10 60 /**
yading@10 61 * rate control context.
yading@10 62 */
yading@10 63 typedef struct RateControlContext{
yading@10 64 int num_entries; ///< number of RateControlEntries
yading@10 65 RateControlEntry *entry;
yading@10 66 double buffer_index; ///< amount of bits in the video/audio buffer
yading@10 67 Predictor pred[5];
yading@10 68 double short_term_qsum; ///< sum of recent qscales
yading@10 69 double short_term_qcount; ///< count of recent qscales
yading@10 70 double pass1_rc_eq_output_sum;///< sum of the output of the rc equation, this is used for normalization
yading@10 71 double pass1_wanted_bits; ///< bits which should have been outputed by the pass1 code (including complexity init)
yading@10 72 double last_qscale;
yading@10 73 double last_qscale_for[5]; ///< last qscale for a specific pict type, used for max_diff & ipb factor stuff
yading@10 74 int last_mc_mb_var_sum;
yading@10 75 int last_mb_var_sum;
yading@10 76 uint64_t i_cplx_sum[5];
yading@10 77 uint64_t p_cplx_sum[5];
yading@10 78 uint64_t mv_bits_sum[5];
yading@10 79 uint64_t qscale_sum[5];
yading@10 80 int frame_count[5];
yading@10 81 int last_non_b_pict_type;
yading@10 82
yading@10 83 void *non_lavc_opaque; ///< context for non lavc rc code (for example xvid)
yading@10 84 float dry_run_qscale; ///< for xvid rc
yading@10 85 int last_picture_number; ///< for xvid rc
yading@10 86 AVExpr * rc_eq_eval;
yading@10 87 }RateControlContext;
yading@10 88
yading@10 89 struct MpegEncContext;
yading@10 90
yading@10 91 /* rate control */
yading@10 92 int ff_rate_control_init(struct MpegEncContext *s);
yading@10 93 float ff_rate_estimate_qscale(struct MpegEncContext *s, int dry_run);
yading@10 94 void ff_write_pass1_stats(struct MpegEncContext *s);
yading@10 95 void ff_rate_control_uninit(struct MpegEncContext *s);
yading@10 96 int ff_vbv_update(struct MpegEncContext *s, int frame_size);
yading@10 97 void ff_get_2pass_fcode(struct MpegEncContext *s);
yading@10 98
yading@10 99 int ff_xvid_rate_control_init(struct MpegEncContext *s);
yading@10 100 void ff_xvid_rate_control_uninit(struct MpegEncContext *s);
yading@10 101 float ff_xvid_rate_estimate_qscale(struct MpegEncContext *s, int dry_run);
yading@10 102
yading@10 103 #endif /* AVCODEC_RATECONTROL_H */