if (avctx->level <= 0 && s->version == 2) {
s->version = 3;
}
- if (avctx->level >= 0 && avctx->level <= 4)
- s->version = FFMAX(s->version, avctx->level);
+ if (avctx->level >= 0 && avctx->level <= 4) {
+ if (avctx->level < s->version) {
+ av_log(avctx, AV_LOG_ERROR, "Version %d needed for requested features but %d requested\n", s->version, avctx->level);
+ return AVERROR(EINVAL);
+ }
+ s->version = avctx->level;
+ }
if (s->ec < 0) {
s->ec = (s->version >= 3);
int x = fs->slice_x;
int y = fs->slice_y;
const AVFrame *const p = f->picture.f;
- const int ps = av_pix_fmt_desc_get(c->pix_fmt)->comp[0].step_minus1 + 1;
+ const int ps = av_pix_fmt_desc_get(c->pix_fmt)->comp[0].step;
int ret;
RangeCoder c_bak = fs->c;
const uint8_t *planes[3] = {p->data[0] + ps*x + y*p->linesize[0],