Revision cb6247cb
libavcodec/ac3enc.c  

929  929  
930  930  
931  931 
/** 
932 
* Perform bit allocation search. 

933 
* Finds the SNR offset value that maximizes quality and fits in the specified 

934 
* frame size. Output is the SNR offset and a set of bit allocation pointers 

935 
* used to quantize the mantissas. 

932 
* Constant bitrate bit allocation search. 

933 
* Find the largest SNR offset that will allow data to fit in the frame. 

936  934 
*/ 
937 
static int compute_bit_allocation(AC3EncodeContext *s)


935 
static int cbr_bit_allocation(AC3EncodeContext *s)


938  936 
{ 
939  937 
int ch; 
940  938 
int bits_left; 
941  939 
int snr_offset; 
942  940  
943 
/* count frame bits other than exponents and mantissas */ 

944 
count_frame_bits(s); 

945  
946 
/* calculate psd and masking curve before doing bit allocation */ 

947 
bit_alloc_masking(s); 

948  
949 
/* now the big work begins : do the bit allocation. Modify the snr 

950 
offset until we can pack everything in the requested frame size */ 

951  
952  941 
bits_left = 8 * s>frame_size  (s>frame_bits + s>exponent_bits); 
953  942  
954  943 
snr_offset = s>coarse_snr_offset << 4; 
...  ...  
991  980  
992  981  
993  982 
/** 
983 
* Perform bit allocation search. 

984 
* Finds the SNR offset value that maximizes quality and fits in the specified 

985 
* frame size. Output is the SNR offset and a set of bit allocation pointers 

986 
* used to quantize the mantissas. 

987 
*/ 

988 
static int compute_bit_allocation(AC3EncodeContext *s) 

989 
{ 

990 
/* count frame bits other than exponents and mantissas */ 

991 
count_frame_bits(s); 

992  
993 
/* calculate psd and masking curve before doing bit allocation */ 

994 
bit_alloc_masking(s); 

995  
996 
return cbr_bit_allocation(s); 

997 
} 

998  
999  
1000 
/** 

994  1001 
* Symmetric quantization on 'levels' levels. 
995  1002 
*/ 
996  1003 
static inline int sym_quant(int c, int e, int levels) 
Also available in: Unified diff