[FFmpeg-cvslog] Merge commit '5edded9df31bc4712a023f89941b4c278f1bd6f5'
James Almer
git at videolan.org
Wed Nov 1 19:26:30 EET 2017
ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Wed Nov 1 14:13:04 2017 -0300| [bc98788dd262aacf017fb27d3e1de03f9009839f] | committer: James Almer
Merge commit '5edded9df31bc4712a023f89941b4c278f1bd6f5'
* commit '5edded9df31bc4712a023f89941b4c278f1bd6f5':
smacker: Improve error handling
See c1947015b2eec65c7fbd702e1d8c22248be511e8
Merged-by: James Almer <jamrial at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bc98788dd262aacf017fb27d3e1de03f9009839f
---
libavcodec/smacker.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
index 3a7067e7d5..dad899c791 100644
--- a/libavcodec/smacker.c
+++ b/libavcodec/smacker.c
@@ -279,8 +279,9 @@ static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int
goto error;
}
- if (smacker_decode_bigtree(gb, &huff, &ctx, 0) < 0)
- err = -1;
+ res = smacker_decode_bigtree(gb, &huff, &ctx, 0);
+ if (res < 0)
+ err = res;
skip_bits1(gb);
if(ctx.last[0] == -1) ctx.last[0] = huff.current++;
if(ctx.last[1] == -1) ctx.last[1] = huff.current++;
@@ -600,7 +601,7 @@ static av_cold int smka_decode_init(AVCodecContext *avctx)
{
if (avctx->channels < 1 || avctx->channels > 2) {
av_log(avctx, AV_LOG_ERROR, "invalid number of channels\n");
- return AVERROR(EINVAL);
+ return AVERROR_INVALIDDATA;
}
avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
avctx->sample_fmt = avctx->bits_per_coded_sample == 8 ? AV_SAMPLE_FMT_U8 : AV_SAMPLE_FMT_S16;
@@ -630,7 +631,7 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data,
if (buf_size <= 4) {
av_log(avctx, AV_LOG_ERROR, "packet is too small\n");
- return AVERROR(EINVAL);
+ return AVERROR_INVALIDDATA;
}
unp_size = AV_RL32(buf);
@@ -652,11 +653,11 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data,
bits = get_bits1(&gb);
if (stereo ^ (avctx->channels != 1)) {
av_log(avctx, AV_LOG_ERROR, "channels mismatch\n");
- return AVERROR(EINVAL);
+ return AVERROR_INVALIDDATA;
}
if (bits == (avctx->sample_fmt == AV_SAMPLE_FMT_U8)) {
av_log(avctx, AV_LOG_ERROR, "sample format mismatch\n");
- return AVERROR(EINVAL);
+ return AVERROR_INVALIDDATA;
}
/* get output buffer */
@@ -664,7 +665,7 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data,
if (unp_size % (avctx->channels * (bits + 1))) {
av_log(avctx, AV_LOG_ERROR,
"The buffer does not contain an integer number of samples\n");
- return AVERROR(EINVAL);
+ return AVERROR_INVALIDDATA;
}
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
======================================================================
diff --cc libavcodec/smacker.c
index 3a7067e7d5,0e057a1c2a..dad899c791
--- a/libavcodec/smacker.c
+++ b/libavcodec/smacker.c
@@@ -279,9 -264,9 +279,10 @@@ static int smacker_decode_header_tree(S
goto error;
}
- if (smacker_decode_bigtree(gb, &huff, &ctx, 0) < 0)
- err = -1;
- if ((res = smacker_decode_bigtree(bc, &huff, &ctx)) < 0)
++ res = smacker_decode_bigtree(gb, &huff, &ctx, 0);
++ if (res < 0)
+ err = res;
- bitstream_skip(bc, 1);
+ skip_bits1(gb);
if(ctx.last[0] == -1) ctx.last[0] = huff.current++;
if(ctx.last[1] == -1) ctx.last[1] = huff.current++;
if(ctx.last[2] == -1) ctx.last[2] = huff.current++;
@@@ -648,26 -627,28 +649,26 @@@ static int smka_decode_frame(AVCodecCon
*got_frame_ptr = 0;
return 1;
}
- stereo = bitstream_read_bit(&bc);
- bits = bitstream_read_bit(&bc);
+ stereo = get_bits1(&gb);
+ bits = get_bits1(&gb);
if (stereo ^ (avctx->channels != 1)) {
av_log(avctx, AV_LOG_ERROR, "channels mismatch\n");
- return AVERROR(EINVAL);
+ return AVERROR_INVALIDDATA;
}
- if (bits && avctx->sample_fmt == AV_SAMPLE_FMT_U8) {
+ if (bits == (avctx->sample_fmt == AV_SAMPLE_FMT_U8)) {
av_log(avctx, AV_LOG_ERROR, "sample format mismatch\n");
- return AVERROR(EINVAL);
+ return AVERROR_INVALIDDATA;
}
+
+ /* get output buffer */
+ frame->nb_samples = unp_size / (avctx->channels * (bits + 1));
if (unp_size % (avctx->channels * (bits + 1))) {
av_log(avctx, AV_LOG_ERROR,
"The buffer does not contain an integer number of samples\n");
- return AVERROR(EINVAL);
+ return AVERROR_INVALIDDATA;
}
-
- /* get output buffer */
- frame->nb_samples = unp_size / (avctx->channels * (bits + 1));
- if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
- }
samples = (int16_t *)frame->data[0];
samples8 = frame->data[0];
More information about the ffmpeg-cvslog
mailing list