summaryrefslogtreecommitdiff
path: root/libavcodec/wmavoice.c
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2013-06-29 03:02:02 +0200
committerLuca Barbato <lu_zero@gentoo.org>2013-07-10 15:49:51 +0200
commit04e9853a210e07b1a150aa2b8e9af0aa3601ff21 (patch)
treefbaceff0d7586f04259680ed0c44ec0dbe913129 /libavcodec/wmavoice.c
parent7d65e960c72f36b73ae7fe84f8e427d758e61da9 (diff)
wmavoice: return meaningful error codes
Diffstat (limited to 'libavcodec/wmavoice.c')
-rw-r--r--libavcodec/wmavoice.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c
index b9a4ad9f4a..ae19b3f877 100644
--- a/libavcodec/wmavoice.c
+++ b/libavcodec/wmavoice.c
@@ -354,7 +354,7 @@ static av_cold int wmavoice_decode_init(AVCodecContext *ctx)
av_log(ctx, AV_LOG_ERROR,
"Invalid extradata size %d (should be 46)\n",
ctx->extradata_size);
- return -1;
+ return AVERROR_INVALIDDATA;
}
flags = AV_RL32(ctx->extradata + 18);
s->spillover_bitsize = 3 + av_ceil_log2(ctx->block_align);
@@ -377,7 +377,7 @@ static av_cold int wmavoice_decode_init(AVCodecContext *ctx)
av_log(ctx, AV_LOG_ERROR,
"Invalid denoise filter strength %d (max=11)\n",
s->denoise_strength);
- return -1;
+ return AVERROR_INVALIDDATA;
}
s->denoise_tilt_corr = !!(flags & 0x40);
s->dc_level = (flags >> 7) & 0xF;
@@ -399,7 +399,7 @@ static av_cold int wmavoice_decode_init(AVCodecContext *ctx)
init_get_bits(&s->gb, ctx->extradata + 22, (ctx->extradata_size - 22) << 3);
if (decode_vbmtree(&s->gb, s->vbm_tree) < 0) {
av_log(ctx, AV_LOG_ERROR, "Invalid VBM tree; broken extradata?\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
s->min_pitch_val = ((ctx->sample_rate << 8) / 400 + 50) >> 8;
@@ -407,7 +407,7 @@ static av_cold int wmavoice_decode_init(AVCodecContext *ctx)
pitch_range = s->max_pitch_val - s->min_pitch_val;
if (pitch_range <= 0) {
av_log(ctx, AV_LOG_ERROR, "Invalid pitch range; broken extradata?\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
s->pitch_nbits = av_ceil_log2(pitch_range);
s->last_pitch_val = 40;
@@ -422,7 +422,7 @@ static av_cold int wmavoice_decode_init(AVCodecContext *ctx)
"Unsupported samplerate %d (min=%d, max=%d)\n",
ctx->sample_rate, min_sr, max_sr); // 322-22097 Hz
- return -1;
+ return AVERROR(ENOSYS);
}
s->block_conv_table[0] = s->min_pitch_val;
@@ -432,7 +432,7 @@ static av_cold int wmavoice_decode_init(AVCodecContext *ctx)
s->block_delta_pitch_hrange = (pitch_range >> 3) & ~0xF;
if (s->block_delta_pitch_hrange <= 0) {
av_log(ctx, AV_LOG_ERROR, "Invalid delta pitch hrange; broken extradata?\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
s->block_delta_pitch_nbits = 1 + av_ceil_log2(s->block_delta_pitch_hrange);
s->block_pitch_range = s->block_conv_table[2] +
@@ -1447,7 +1447,7 @@ static int synth_frame(AVCodecContext *ctx, GetBitContext *gb, int frame_idx,
if (bd_idx < 0) {
av_log(ctx, AV_LOG_ERROR,
"Invalid frame type VLC code, skipping\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
block_nsamples = MAX_FRAMESIZE / frame_descs[bd_idx].n_blocks;
@@ -1644,7 +1644,7 @@ static void stabilize_lsps(double *lsps, int num)
* does not modify the state of the bitreader; it
* only uses it to copy the current stream position
* @param s WMA Voice decoding context private data
- * @return -1 if unsupported, 1 on not enough bits or 0 if OK.
+ * @return < 0 on error, 1 on not enough bits or 0 if OK.
*/
static int check_bits_for_superframe(GetBitContext *orig_gb,
WMAVoiceContext *s)
@@ -1662,7 +1662,7 @@ static int check_bits_for_superframe(GetBitContext *orig_gb,
if (get_bits_left(gb) < 14)
return 1;
if (!get_bits1(gb))
- return -1; // WMAPro-in-WMAVoice superframe
+ return AVERROR(ENOSYS); // WMAPro-in-WMAVoice superframe
if (get_bits1(gb)) skip_bits(gb, 12); // number of samples in superframe
if (s->has_residual_lsps) { // residual LSPs (for all frames)
if (get_bits_left(gb) < s->sframe_lsp_bitsize)
@@ -1680,7 +1680,7 @@ static int check_bits_for_superframe(GetBitContext *orig_gb,
}
bd_idx = s->vbm_tree[get_vlc2(gb, frame_type_vlc.table, 6, 3)];
if (bd_idx < 0)
- return -1; // invalid frame type VLC code
+ return AVERROR_INVALIDDATA; // invalid frame type VLC code
frame_desc = &frame_descs[bd_idx];
if (frame_desc->acb_type == ACB_TYPE_ASYMMETRIC) {
if (get_bits_left(gb) < s->pitch_nbits)
@@ -1758,7 +1758,8 @@ static int synth_superframe(AVCodecContext *ctx, AVFrame *frame,
if ((res = check_bits_for_superframe(gb, s)) == 1) {
*got_frame_ptr = 0;
return 1;
- }
+ } else if (res < 0)
+ return res;
/* First bit is speech/music bit, it differentiates between WMAVoice
* speech samples (the actual codec) and WMAVoice music samples, which
@@ -1775,7 +1776,7 @@ static int synth_superframe(AVCodecContext *ctx, AVFrame *frame,
av_log(ctx, AV_LOG_ERROR,
"Superframe encodes >480 samples (%d), not allowed\n",
n_samples);
- return -1;
+ return AVERROR_INVALIDDATA;
}
}
/* Parse LSPs, if global for the superframe (can also be per-frame). */