|
|
|
@ -248,8 +248,11 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (channels < 1 || channels > FLAC_MAX_CHANNELS) |
|
|
|
|
return -1; |
|
|
|
|
if (channels < 1 || channels > FLAC_MAX_CHANNELS) { |
|
|
|
|
av_log(avctx, AV_LOG_ERROR, "%d channels not supported (max %d)\n", |
|
|
|
|
channels, FLAC_MAX_CHANNELS); |
|
|
|
|
return AVERROR(EINVAL); |
|
|
|
|
} |
|
|
|
|
s->channels = channels; |
|
|
|
|
|
|
|
|
|
/* find samplerate in table */ |
|
|
|
@ -275,7 +278,8 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) |
|
|
|
|
s->sr_code[0] = 13; |
|
|
|
|
s->sr_code[1] = freq; |
|
|
|
|
} else { |
|
|
|
|
return -1; |
|
|
|
|
av_log(avctx, AV_LOG_ERROR, "%d Hz not supported\n", freq); |
|
|
|
|
return AVERROR(EINVAL); |
|
|
|
|
} |
|
|
|
|
s->samplerate = freq; |
|
|
|
|
} |
|
|
|
@ -290,7 +294,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) |
|
|
|
|
if (level > 12) { |
|
|
|
|
av_log(avctx, AV_LOG_ERROR, "invalid compression level: %d\n", |
|
|
|
|
s->options.compression_level); |
|
|
|
|
return -1; |
|
|
|
|
return AVERROR(EINVAL); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
s->options.block_time_ms = ((int[]){ 27, 27, 27,105,105,105,105,105,105,105,105,105,105})[level]; |
|
|
|
@ -329,13 +333,13 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) |
|
|
|
|
if (avctx->min_prediction_order > MAX_FIXED_ORDER) { |
|
|
|
|
av_log(avctx, AV_LOG_ERROR, "invalid min prediction order: %d\n", |
|
|
|
|
avctx->min_prediction_order); |
|
|
|
|
return -1; |
|
|
|
|
return AVERROR(EINVAL); |
|
|
|
|
} |
|
|
|
|
} else if (avctx->min_prediction_order < MIN_LPC_ORDER || |
|
|
|
|
avctx->min_prediction_order > MAX_LPC_ORDER) { |
|
|
|
|
av_log(avctx, AV_LOG_ERROR, "invalid min prediction order: %d\n", |
|
|
|
|
avctx->min_prediction_order); |
|
|
|
|
return -1; |
|
|
|
|
return AVERROR(EINVAL); |
|
|
|
|
} |
|
|
|
|
s->options.min_prediction_order = avctx->min_prediction_order; |
|
|
|
|
} |
|
|
|
@ -346,20 +350,20 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) |
|
|
|
|
if (avctx->max_prediction_order > MAX_FIXED_ORDER) { |
|
|
|
|
av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n", |
|
|
|
|
avctx->max_prediction_order); |
|
|
|
|
return -1; |
|
|
|
|
return AVERROR(EINVAL); |
|
|
|
|
} |
|
|
|
|
} else if (avctx->max_prediction_order < MIN_LPC_ORDER || |
|
|
|
|
avctx->max_prediction_order > MAX_LPC_ORDER) { |
|
|
|
|
av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n", |
|
|
|
|
avctx->max_prediction_order); |
|
|
|
|
return -1; |
|
|
|
|
return AVERROR(EINVAL); |
|
|
|
|
} |
|
|
|
|
s->options.max_prediction_order = avctx->max_prediction_order; |
|
|
|
|
} |
|
|
|
|
if (s->options.max_prediction_order < s->options.min_prediction_order) { |
|
|
|
|
av_log(avctx, AV_LOG_ERROR, "invalid prediction orders: min=%d max=%d\n", |
|
|
|
|
s->options.min_prediction_order, s->options.max_prediction_order); |
|
|
|
|
return -1; |
|
|
|
|
return AVERROR(EINVAL); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (avctx->frame_size > 0) { |
|
|
|
@ -367,7 +371,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) |
|
|
|
|
avctx->frame_size > FLAC_MAX_BLOCKSIZE) { |
|
|
|
|
av_log(avctx, AV_LOG_ERROR, "invalid block size: %d\n", |
|
|
|
|
avctx->frame_size); |
|
|
|
|
return -1; |
|
|
|
|
return AVERROR(EINVAL); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
s->avctx->frame_size = select_blocksize(s->samplerate, s->options.block_time_ms); |
|
|
|
|