diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2010-12-14 14:52:25 +0000 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2010-12-14 14:52:25 +0000 |
commit | 99ca4f73f0a2085d8b3c7636f4734825894c42dc (patch) | |
tree | d2ec3859394b59001b393a79037d5595615c4c60 /libavcodec/ac3enc.c | |
parent | 1607db0a95a1e07b6f7e51fc7db6456b65059860 (diff) | |
download | ffmpeg-99ca4f73f0a2085d8b3c7636f4734825894c42dc.tar.gz |
Don't use nested loops to iterate valid sample rates.
Eliminates a goto and mirrors the bitrate validation.
Originally committed as revision 25980 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/ac3enc.c')
-rw-r--r-- | libavcodec/ac3enc.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index aa95327ae7..0cc22526ad 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -1252,7 +1252,7 @@ static av_cold int set_channel_info(AC3EncodeContext *s, int channels, static av_cold int validate_options(AVCodecContext *avctx, AC3EncodeContext *s) { - int i, j; + int i; if (!avctx->channel_layout) { av_log(avctx, AV_LOG_WARNING, "No channel layout specified. The " @@ -1265,16 +1265,16 @@ static av_cold int validate_options(AVCodecContext *avctx, AC3EncodeContext *s) } /* frequency */ - for (i = 0; i < 3; i++) { - for (j = 0; j < 3; j++) - if ((ff_ac3_sample_rate_tab[j] >> i) == avctx->sample_rate) - goto found; + for (i = 0; i < 9; i++) { + if ((ff_ac3_sample_rate_tab[i / 3] >> (i % 3)) == avctx->sample_rate) + break; } + if (i == 9) { return -1; - found: + } s->sample_rate = avctx->sample_rate; - s->bit_alloc.sr_shift = i; - s->bit_alloc.sr_code = j; + s->bit_alloc.sr_shift = i % 3; + s->bit_alloc.sr_code = i / 3; s->bitstream_id = 8 + s->bit_alloc.sr_shift; s->bitstream_mode = 0; /* complete main audio service */ |