[FFmpeg-devel] [PATCH] vorbisdec: Simplify, do no calculate same value twice.
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Wed Apr 11 21:12:07 CEST 2012
The 0 assignment is just for paranoia reasons, the function
is only called from init and we should bail out directly
on failure.
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
---
libavcodec/vorbisdec.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c
index ddc79fc..9c5c4ae 100644
--- a/libavcodec/vorbisdec.c
+++ b/libavcodec/vorbisdec.c
@@ -685,10 +685,12 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc)
res_setup->begin = get_bits(gb, 24);
res_setup->end = get_bits(gb, 24);
res_setup->partition_size = get_bits(gb, 24) + 1;
+ res_setup->ptns_to_read =
+ (res_setup->end - res_setup->begin) / res_setup->partition_size;
/* Validations to prevent a buffer overflow later. */
if (res_setup->begin>res_setup->end ||
res_setup->end > (res_setup->type == 2 ? vc->audio_channels : 1) * vc->blocksize[1] / 2 ||
- (res_setup->end-res_setup->begin) / res_setup->partition_size > V_MAX_PARTITIONS) {
+ res_setup->ptns_to_read > V_MAX_PARTITIONS) {
av_log(vc->avccontext, AV_LOG_ERROR,
"partition out of bounds: type, begin, end, size, blocksize: %"PRIu16", %"PRIu32", %"PRIu32", %u, %"PRIu32"\n",
res_setup->type, res_setup->begin, res_setup->end,
@@ -699,8 +701,6 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc)
res_setup->classifications = get_bits(gb, 6) + 1;
GET_VALIDATED_INDEX(res_setup->classbook, 8, vc->codebook_count)
- res_setup->ptns_to_read =
- (res_setup->end - res_setup->begin) / res_setup->partition_size;
res_setup->classifs = av_malloc(res_setup->ptns_to_read *
vc->audio_channels *
sizeof(*res_setup->classifs));
--
1.7.9.5
More information about the ffmpeg-devel
mailing list