[SCM] libav/experimental: Split setting of bandwidth into a separate function.
siretart at users.alioth.debian.org
siretart at users.alioth.debian.org
Sun Jun 30 17:20:16 UTC 2013
The following commit has been merged in the experimental branch:
commit 282255bbd21815ef6471298ce9e3422b58984678
Author: Justin Ruggles <justin.ruggles at gmail.com>
Date: Tue Dec 14 14:52:40 2010 +0000
Split setting of bandwidth into a separate function.
Originally committed as revision 25984 to svn://svn.ffmpeg.org/ffmpeg/trunk
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 6adc11f..296c156 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -1295,12 +1295,44 @@ static av_cold int validate_options(AVCodecContext *avctx, AC3EncodeContext *s)
/**
+ * Set bandwidth for all channels.
+ * The user can optionally supply a cutoff frequency. Otherwise an appropriate
+ * default value will be used.
+ */
+static av_cold void set_bandwidth(AC3EncodeContext *s, int cutoff)
+{
+ int ch, bw_code;
+
+ if (cutoff) {
+ /* calculate bandwidth based on user-specified cutoff frequency */
+ int fbw_coeffs;
+ cutoff = av_clip(cutoff, 1, s->sample_rate >> 1);
+ fbw_coeffs = cutoff * 2 * AC3_MAX_COEFS / s->sample_rate;
+ bw_code = av_clip((fbw_coeffs - 73) / 3, 0, 60);
+ } else {
+ /* use default bandwidth setting */
+ /* XXX: should compute the bandwidth according to the frame
+ size, so that we avoid annoying high frequency artifacts */
+ bw_code = 50;
+ }
+
+ /* set number of coefficients for each channel */
+ for (ch = 0; ch < s->fbw_channels; ch++) {
+ s->bandwidth_code[ch] = bw_code;
+ s->nb_coefs[ch] = bw_code * 3 + 73;
+ }
+ if (s->lfe_on)
+ s->nb_coefs[s->lfe_channel] = 7; /* LFE channel always has 7 coefs */
+}
+
+
+/**
* Initialize the encoder.
*/
static av_cold int ac3_encode_init(AVCodecContext *avctx)
{
AC3EncodeContext *s = avctx->priv_data;
- int ch, bw_code, ret;
+ int ret;
avctx->frame_size = AC3_FRAME_SIZE;
@@ -1318,25 +1350,7 @@ static av_cold int ac3_encode_init(AVCodecContext *avctx)
s->samples_written = 0;
s->frame_size = s->frame_size_min;
- /* set bandwidth */
- if (avctx->cutoff) {
- /* calculate bandwidth based on user-specified cutoff frequency */
- int cutoff = av_clip(avctx->cutoff, 1, s->sample_rate >> 1);
- int fbw_coeffs = cutoff * 2 * AC3_MAX_COEFS / s->sample_rate;
- bw_code = av_clip((fbw_coeffs - 73) / 3, 0, 60);
- } else {
- /* use default bandwidth setting */
- /* XXX: should compute the bandwidth according to the frame
- size, so that we avoid annoying high frequency artifacts */
- bw_code = 50;
- }
- for (ch = 0; ch < s->fbw_channels; ch++) {
- /* bandwidth for each channel */
- s->bandwidth_code[ch] = bw_code;
- s->nb_coefs[ch] = bw_code * 3 + 73;
- }
- if (s->lfe_on)
- s->nb_coefs[s->lfe_channel] = 7; /* LFE channel always has 7 coefs */
+ set_bandwidth(s, avctx->cutoff);
/* initial snr offset */
s->coarse_snr_offset = 40;
--
Libav/FFmpeg packaging
More information about the pkg-multimedia-commits
mailing list