1 /********************************************************************
3 * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
5 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
6 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
9 * by the XIPHOPHORUS Company http://www.xiph.org/ *
11 ********************************************************************
13 function: bitrate tracking and management
14 last mod: $Id: bitrate.h,v 1.3 2001/12/19 07:33:51 xiphmont Exp $
16 ********************************************************************/
21 #include "vorbis/codec.h"
22 #include "codec_internal.h"
25 /* encode side bitrate tracking */
26 #define BITTRACK_DIVISOR 16
27 typedef struct bitrate_manager_state {
28 ogg_uint32_t *queue_binned;
29 ogg_uint32_t *queue_actual;
38 ogg_uint32_t avg_centeracc;
39 ogg_uint32_t avg_sampleacc;
40 ogg_uint32_t avg_sampledesired;
41 ogg_uint32_t avg_centerdesired;
43 long *minmax_binstack;
44 long *minmax_posstack;
45 long *minmax_limitstack;
50 ogg_uint32_t minmax_sampleacc;
51 ogg_uint32_t minmax_sampledesired;
58 long noisetrigger_postpone;
59 double noisetrigger_request;
61 /* unfortunately, we need to hold queued packet data somewhere */
62 oggpack_buffer *queue_packet_buffers;
63 ogg_packet *queue_packets;
65 } bitrate_manager_state;
67 typedef struct bitrate_manager_info{
68 /* detailed bitrate management setup */
69 double queue_avg_time;
70 double queue_avg_center;
71 double queue_minmax_time;
77 double avgfloat_initial; /* set by mode */
78 double avgfloat_minimum; /* set by mode */
79 double avgfloat_downslew_max;
80 double avgfloat_upslew_max;
81 double avgfloat_downhyst;
82 double avgfloat_uphyst;
83 double avgfloat_noise_lowtrigger;
84 double avgfloat_noise_hightrigger;
85 double avgfloat_noise_minval;
86 double avgfloat_noise_maxval;
87 } bitrate_manager_info;
89 extern void vorbis_bitrate_init(vorbis_info *vi,bitrate_manager_state *bs);
90 extern void vorbis_bitrate_clear(bitrate_manager_state *bs);
91 extern int vorbis_bitrate_managed(vorbis_block *vb);
92 extern int vorbis_bitrate_maxmarkers(void);
93 extern int vorbis_bitrate_addblock(vorbis_block *vb);
94 extern int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd, ogg_packet *op);