Mercurial > libavcodec.hg
comparison oggvorbis.c @ 3058:8936371f5a5c libavcodec
Implement audio cutoff frequency to the vorbis encoder.
Patch by Justin Ruggles jruggle earthlink net.
author | banan |
---|---|
date | Sat, 21 Jan 2006 17:09:23 +0000 |
parents | bfabfdf9ce55 |
children | c537a97eec66 |
comparison
equal
deleted
inserted
replaced
3057:8f78b00d1252 | 3058:8936371f5a5c |
---|---|
27 ogg_packet op; | 27 ogg_packet op; |
28 } OggVorbisContext ; | 28 } OggVorbisContext ; |
29 | 29 |
30 | 30 |
31 static int oggvorbis_init_encoder(vorbis_info *vi, AVCodecContext *avccontext) { | 31 static int oggvorbis_init_encoder(vorbis_info *vi, AVCodecContext *avccontext) { |
32 double cfreq; | |
32 | 33 |
33 if(avccontext->flags & CODEC_FLAG_QSCALE) { | 34 if(avccontext->flags & CODEC_FLAG_QSCALE) { |
34 return vorbis_encode_init_vbr(vi, avccontext->channels, | 35 /* variable bitrate */ |
36 if(vorbis_encode_setup_vbr(vi, avccontext->channels, | |
35 avccontext->sample_rate, | 37 avccontext->sample_rate, |
36 avccontext->global_quality / (float)FF_QP2LAMBDA); | 38 avccontext->global_quality / (float)FF_QP2LAMBDA)) |
37 } | 39 return -1; |
40 } else { | |
41 /* constant bitrate */ | |
42 if(vorbis_encode_setup_managed(vi, avccontext->channels, | |
43 avccontext->sample_rate, -1, avccontext->bit_rate, -1)) | |
44 return -1; | |
45 | |
38 #ifdef OGGVORBIS_VBR_BY_ESTIMATE | 46 #ifdef OGGVORBIS_VBR_BY_ESTIMATE |
39 /* variable bitrate by estimate */ | 47 /* variable bitrate by estimate */ |
40 | 48 if(vorbis_encode_ctl(vi, OV_ECTL_RATEMANAGE_AVG, NULL)) |
41 return (vorbis_encode_setup_managed(vi, avccontext->channels, | 49 return -1; |
42 avccontext->sample_rate, -1, avccontext->bit_rate, -1) || | |
43 vorbis_encode_ctl(vi, OV_ECTL_RATEMANAGE_AVG, NULL) || | |
44 vorbis_encode_setup_init(vi)) ; | |
45 #else | |
46 /* constant bitrate */ | |
47 | |
48 return vorbis_encode_init(vi, avccontext->channels, | |
49 avccontext->sample_rate, -1, avccontext->bit_rate, -1) ; | |
50 #endif | 50 #endif |
51 } | |
52 | |
53 /* cutoff frequency */ | |
54 if(avccontext->cutoff > 0) { | |
55 cfreq = avccontext->cutoff / 1000.0; | |
56 if(vorbis_encode_ctl(vi, OV_ECTL_LOWPASS_SET, &cfreq)) | |
57 return -1; | |
58 } | |
59 | |
60 return vorbis_encode_setup_init(vi); | |
51 } | 61 } |
52 | 62 |
53 static int oggvorbis_encode_init(AVCodecContext *avccontext) { | 63 static int oggvorbis_encode_init(AVCodecContext *avccontext) { |
54 OggVorbisContext *context = avccontext->priv_data ; | 64 OggVorbisContext *context = avccontext->priv_data ; |
55 ogg_packet header, header_comm, header_code; | 65 ogg_packet header, header_comm, header_code; |