Re: [PATCH v4] media: Add AV1 uAPI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/3/23 16:48, Daniel Almeida wrote:
> This patch adds the  AOMedia Video 1 (AV1) kernel uAPI.
> 
> This design is based on currently available AV1 API implementations and
> aims to support the development of AV1 stateless video codecs
> on Linux.
> 
> Signed-off-by: Daniel Almeida <daniel.almeida@xxxxxxxxxxxxx>
> Signed-off-by: Nicolas Dufresne <nicolas.dufresne@xxxxxxxxxxxxx>
> Co-Developed-by: Nicolas Dufresne <nicolas.dufresne@xxxxxxxxxxxxx>


> diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c
> index 29169170880a..1752e56ed594 100644
> --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c
> +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c
> @@ -350,6 +350,19 @@ void v4l2_ctrl_type_op_log(const struct v4l2_ctrl *ctrl)
>  	case V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS:
>  		pr_cont("HEVC_DECODE_PARAMS");
>  		break;
> +	case V4L2_CTRL_TYPE_AV1_SEQUENCE:
> +		pr_cont("AV1_SEQUENCE");
> +		break;
> +	case V4L2_CTRL_TYPE_AV1_TILE_GROUP_ENTRY:
> +		pr_cont("AV1_TILE_GROUP_ENTRY");
> +		break;
> +	case V4L2_CTRL_TYPE_AV1_FRAME:
> +		pr_cont("AV1_FRAME");
> +		break;
> +	case V4L2_CTRL_TYPE_AV1_FILM_GRAIN:
> +		pr_cont("AV1_FILM_GRAIN");
> +		break;
> +
>  	default:
>  		pr_cont("unknown type %d", ctrl->type);
>  		break;
> @@ -547,6 +560,233 @@ validate_vp9_frame(struct v4l2_ctrl_vp9_frame *frame)
>  	return 0;
>  }
>  
> +static int validate_av1_quantization(struct v4l2_av1_quantization *q)
> +{
> +	if (q->flags > GENMASK(2, 0))
> +		return -EINVAL;
> +
> +	if (q->delta_q_y_dc < -64 || q->delta_q_y_dc > 63 ||
> +	    q->delta_q_u_dc < -64 || q->delta_q_u_dc > 63 ||
> +	    q->delta_q_v_dc < -64 || q->delta_q_v_dc > 63 ||
> +	    q->delta_q_u_ac < -64 || q->delta_q_u_ac > 63 ||
> +	    q->delta_q_v_ac < -64 || q->delta_q_v_ac > 63 ||
> +	    q->delta_q_res > GENMASK(1, 0))
> +		return -EINVAL;
> +
> +	if (q->qm_y > GENMASK(3, 0) ||
> +	    q->qm_u > GENMASK(3, 0) ||
> +	    q->qm_v > GENMASK(3, 0))
> +		return -EINVAL;
> +
> +	return 0;
> +}
> +
> +static int validate_av1_segmentation(struct v4l2_av1_segmentation *s)
> +{
> +	u32 i;
> +	u32 j;
> +	s32 limit;
> +
> +	if (s->flags > GENMASK(4, 0))
> +		return -EINVAL;
> +
> +	for (i = 0; i < ARRAY_SIZE(s->feature_data); i++) {
> +		const int segmentation_feature_signed[] = { 1, 1, 1, 1, 1, 0, 0, 0 };
> +		const int segmentation_feature_max[] = { 255, 63, 63, 63, 63, 7, 0, 0};
> +
> +		for (j = 0; j < ARRAY_SIZE(s->feature_data[j]); j++) {
> +			if (segmentation_feature_signed[j]) {
> +				limit = segmentation_feature_max[j];
> +
> +				if (s->feature_data[i][j] < -limit ||
> +				    s->feature_data[i][j] > limit)
> +					return -EINVAL;
> +			} else {
> +				if (s->feature_data[i][j] > limit)
> +					return -EINVAL;

I'm getting this compiler warning:

In function 'validate_av1_segmentation',
    inlined from 'validate_av1_frame' at drivers/media/v4l2-core/v4l2-ctrls-core.c:711:8,
    inlined from 'std_validate_compound' at drivers/media/v4l2-core/v4l2-ctrls-core.c:1155:10,
    inlined from 'std_validate_elem' at drivers/media/v4l2-core/v4l2-ctrls-core.c:1243:10,
    inlined from 'v4l2_ctrl_type_op_validate' at drivers/media/v4l2-core/v4l2-ctrls-core.c:1274:9:
drivers/media/v4l2-core/v4l2-ctrls-core.c:605:36: warning: 'limit' may be used uninitialized [-Wmaybe-uninitialized]
  605 |                                 if (s->feature_data[i][j] > limit)
      |                                    ^
drivers/media/v4l2-core/v4l2-ctrls-core.c: In function 'v4l2_ctrl_type_op_validate':
drivers/media/v4l2-core/v4l2-ctrls-core.c:588:13: note: 'limit' was declared here
  588 |         s32 limit;
      |             ^~~~~

> +			}
> +		}
> +	}
> +
> +	return 0;
> +}

Regards,

	Hans




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux