On Fri, 13 Dec 2019 13:54:13 +0100 Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx> wrote: > +static int rkvdec_try_capture_fmt(struct file *file, void *priv, > + struct v4l2_format *f) > +{ > + struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv); > + const struct rkvdec_coded_fmt_desc *coded_desc; > + u32 fourcc, width, height; > + unsigned int i; > + > + /* > + * The codec context should point to a coded format desc, if the format > + * on the coded end has not been set yet, it should point to the > + * default value. > + */ > + coded_desc = ctx->coded_fmt_desc; > + if (WARN_ON(!coded_desc)) > + return -EINVAL; > + > + fourcc = f->fmt.pix_mp.pixelformat; > + for (i = 0; i < coded_desc->num_decoded_fmts; i++) { > + if (coded_desc->decoded_fmts[i] == fourcc) > + break; > + } > + > + if (i == coded_desc->num_decoded_fmts) > + return -EINVAL; > + > + /* Save the original width/height before aligning them. */ > + width = f->fmt.pix_mp.width; > + height = f->fmt.pix_mp.height; > + > + /* Always apply the frmsize constraint of the coded end. */ > + v4l2_apply_frmsize_constraints(&f->fmt.pix_mp.width, > + &f->fmt.pix_mp.height, > + &coded_desc->frmsize); > + > + v4l2_fill_pixfmt_mp(&f->fmt.pix_mp, fourcc, f->fmt.pix_mp.width, > + f->fmt.pix_mp.height); > + > + /* > + * Now that we have computed sizeimage and bytesperline we can restore > + * the original width/height (before macro block alignment). > + */ > + f->fmt.pix_mp.width = width; > + f->fmt.pix_mp.height = height; Looks like restoring the original width/height was a bad idea (it breaks the odd_size tests of the VP9 testsuite [1]). I'll adjust the test in validate_dec_params() [2] to align the ctrl width/height params on a superblock size (64 pixels) instead. > + > + f->fmt.pix_mp.field = V4L2_FIELD_NONE; > + > + return 0; > +} [1]https://storage.googleapis.com/downloads.webmproject.org/vp9/decoder-test-streams/Profile_0_8bit.zip [2]https://patchwork.kernel.org/patch/11290603/