|
|
|
@ -352,7 +352,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); |
|
|
|
@ -375,7 +375,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; |
|
|
|
@ -397,7 +397,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; |
|
|
|
@ -405,7 +405,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; |
|
|
|
@ -420,7 +420,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; |
|
|
|
@ -430,7 +430,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] + |
|
|
|
@ -1445,7 +1445,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; |
|
|
|
@ -1642,7 +1642,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) |
|
|
|
@ -1660,7 +1660,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) |
|
|
|
@ -1678,7 +1678,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) |
|
|
|
@ -1756,7 +1756,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 |
|
|
|
@ -1773,7 +1774,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). */ |
|
|
|
|