[FFmpeg-cvslog] mlpdec: only calculate output size once
Justin Ruggles
git at videolan.org
Fri Oct 14 03:58:29 CEST 2011
ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Wed Sep 21 12:14:28 2011 -0400| [37b67f1bff8662219a9a837e8bdba072f14ec990] | committer: Justin Ruggles
mlpdec: only calculate output size once
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=37b67f1bff8662219a9a837e8bdba072f14ec990
---
libavcodec/mlpdec.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index 15b8de4..f39e963 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -906,6 +906,7 @@ static int output_data_internal(MLPDecodeContext *m, unsigned int substr,
{
SubStream *s = &m->substream[substr];
unsigned int i, out_ch = 0;
+ int out_size;
int32_t *data_32 = (int32_t*) data;
int16_t *data_16 = (int16_t*) data;
@@ -914,8 +915,11 @@ static int output_data_internal(MLPDecodeContext *m, unsigned int substr,
return AVERROR_INVALIDDATA;
}
- if (*data_size < m->avctx->channels * s->blockpos * (is32 ? 4 : 2))
- return -1;
+ out_size = s->blockpos * m->avctx->channels *
+ av_get_bytes_per_sample(m->avctx->sample_fmt);
+
+ if (*data_size < out_size)
+ return AVERROR(EINVAL);
for (i = 0; i < s->blockpos; i++) {
for (out_ch = 0; out_ch <= s->max_matrix_channel; out_ch++) {
@@ -928,7 +932,7 @@ static int output_data_internal(MLPDecodeContext *m, unsigned int substr,
}
}
- *data_size = i * out_ch * (is32 ? 4 : 2);
+ *data_size = out_size;
return 0;
}
More information about the ffmpeg-cvslog
mailing list