Skip to content

Commit 5e1ff23

Browse files
Kwiboohverkuil
authored andcommitted
media: rkvdec: h264: Support High 10 and 4:2:2 profiles
Add support and enable decoding of H264 High 10 and 4:2:2 profiles. Decoded CAPTURE buffer width is aligned to 64 pixels to accommodate HW requirement of 10-bit format buffers, fixes decoding of all the 4:2:2 and 10bit 4:2:2 flusters tests except two stream that present some visual artifacts. - Hi422FREXT17_SONY_A - Hi422FREXT19_SONY_A The get_image_fmt() ops is implemented to select an image format required for the provided SPS control, and returns RKVDEC_IMG_FMT_ANY for other controls. Signed-off-by: Jonas Karlman <[email protected]> Reviewed-by: Nicolas Dufresne <[email protected]> Tested-by: Nicolas Dufresne <[email protected]> Tested-by: Christopher Obbard <[email protected]> Signed-off-by: Nicolas Dufresne <[email protected]> Signed-off-by: Hans Verkuil <[email protected]>
1 parent d35c64e commit 5e1ff23

File tree

3 files changed

+60
-18
lines changed

3 files changed

+60
-18
lines changed

drivers/staging/media/rkvdec/rkvdec-h264.c

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,24 +1027,42 @@ static int rkvdec_h264_adjust_fmt(struct rkvdec_ctx *ctx,
10271027
return 0;
10281028
}
10291029

1030+
static enum rkvdec_image_fmt rkvdec_h264_get_image_fmt(struct rkvdec_ctx *ctx,
1031+
struct v4l2_ctrl *ctrl)
1032+
{
1033+
const struct v4l2_ctrl_h264_sps *sps = ctrl->p_new.p_h264_sps;
1034+
1035+
if (ctrl->id != V4L2_CID_STATELESS_H264_SPS)
1036+
return RKVDEC_IMG_FMT_ANY;
1037+
1038+
if (sps->bit_depth_luma_minus8 == 0) {
1039+
if (sps->chroma_format_idc == 2)
1040+
return RKVDEC_IMG_FMT_422_8BIT;
1041+
else
1042+
return RKVDEC_IMG_FMT_420_8BIT;
1043+
} else if (sps->bit_depth_luma_minus8 == 2) {
1044+
if (sps->chroma_format_idc == 2)
1045+
return RKVDEC_IMG_FMT_422_10BIT;
1046+
else
1047+
return RKVDEC_IMG_FMT_420_10BIT;
1048+
}
1049+
1050+
return RKVDEC_IMG_FMT_ANY;
1051+
}
1052+
10301053
static int rkvdec_h264_validate_sps(struct rkvdec_ctx *ctx,
10311054
const struct v4l2_ctrl_h264_sps *sps)
10321055
{
10331056
unsigned int width, height;
10341057

1035-
/*
1036-
* TODO: The hardware supports 10-bit and 4:2:2 profiles,
1037-
* but it's currently broken in the driver.
1038-
* Reject them for now, until it's fixed.
1039-
*/
1040-
if (sps->chroma_format_idc > 1)
1041-
/* Only 4:0:0 and 4:2:0 are supported */
1058+
if (sps->chroma_format_idc > 2)
1059+
/* Only 4:0:0, 4:2:0 and 4:2:2 are supported */
10421060
return -EINVAL;
10431061
if (sps->bit_depth_luma_minus8 != sps->bit_depth_chroma_minus8)
10441062
/* Luma and chroma bit depth mismatch */
10451063
return -EINVAL;
1046-
if (sps->bit_depth_luma_minus8 != 0)
1047-
/* Only 8-bit is supported */
1064+
if (sps->bit_depth_luma_minus8 != 0 && sps->bit_depth_luma_minus8 != 2)
1065+
/* Only 8-bit and 10-bit is supported */
10481066
return -EINVAL;
10491067

10501068
width = (sps->pic_width_in_mbs_minus1 + 1) * 16;
@@ -1190,4 +1208,5 @@ const struct rkvdec_coded_fmt_ops rkvdec_h264_fmt_ops = {
11901208
.stop = rkvdec_h264_stop,
11911209
.run = rkvdec_h264_run,
11921210
.try_ctrl = rkvdec_h264_try_ctrl,
1211+
.get_image_fmt = rkvdec_h264_get_image_fmt,
11931212
};

drivers/staging/media/rkvdec/rkvdec.c

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,10 @@ static const struct rkvdec_ctrl_desc rkvdec_h264_ctrl_descs[] = {
186186
{
187187
.cfg.id = V4L2_CID_MPEG_VIDEO_H264_PROFILE,
188188
.cfg.min = V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE,
189-
.cfg.max = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH,
189+
.cfg.max = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_422_INTRA,
190190
.cfg.menu_skip_mask =
191-
BIT(V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED),
191+
BIT(V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED) |
192+
BIT(V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_444_PREDICTIVE),
192193
.cfg.def = V4L2_MPEG_VIDEO_H264_PROFILE_MAIN,
193194
},
194195
{
@@ -203,11 +204,23 @@ static const struct rkvdec_ctrls rkvdec_h264_ctrls = {
203204
.num_ctrls = ARRAY_SIZE(rkvdec_h264_ctrl_descs),
204205
};
205206

206-
static const struct rkvdec_decoded_fmt_desc rkvdec_h264_vp9_decoded_fmts[] = {
207+
static const struct rkvdec_decoded_fmt_desc rkvdec_h264_decoded_fmts[] = {
207208
{
208209
.fourcc = V4L2_PIX_FMT_NV12,
209210
.image_fmt = RKVDEC_IMG_FMT_420_8BIT,
210211
},
212+
{
213+
.fourcc = V4L2_PIX_FMT_NV15,
214+
.image_fmt = RKVDEC_IMG_FMT_420_10BIT,
215+
},
216+
{
217+
.fourcc = V4L2_PIX_FMT_NV16,
218+
.image_fmt = RKVDEC_IMG_FMT_422_8BIT,
219+
},
220+
{
221+
.fourcc = V4L2_PIX_FMT_NV20,
222+
.image_fmt = RKVDEC_IMG_FMT_422_10BIT,
223+
},
211224
};
212225

213226
static const struct rkvdec_ctrl_desc rkvdec_vp9_ctrl_descs[] = {
@@ -230,21 +243,28 @@ static const struct rkvdec_ctrls rkvdec_vp9_ctrls = {
230243
.num_ctrls = ARRAY_SIZE(rkvdec_vp9_ctrl_descs),
231244
};
232245

246+
static const struct rkvdec_decoded_fmt_desc rkvdec_vp9_decoded_fmts[] = {
247+
{
248+
.fourcc = V4L2_PIX_FMT_NV12,
249+
.image_fmt = RKVDEC_IMG_FMT_420_8BIT,
250+
},
251+
};
252+
233253
static const struct rkvdec_coded_fmt_desc rkvdec_coded_fmts[] = {
234254
{
235255
.fourcc = V4L2_PIX_FMT_H264_SLICE,
236256
.frmsize = {
237-
.min_width = 48,
257+
.min_width = 64,
238258
.max_width = 4096,
239-
.step_width = 16,
259+
.step_width = 64,
240260
.min_height = 48,
241261
.max_height = 2560,
242262
.step_height = 16,
243263
},
244264
.ctrls = &rkvdec_h264_ctrls,
245265
.ops = &rkvdec_h264_fmt_ops,
246-
.num_decoded_fmts = ARRAY_SIZE(rkvdec_h264_vp9_decoded_fmts),
247-
.decoded_fmts = rkvdec_h264_vp9_decoded_fmts,
266+
.num_decoded_fmts = ARRAY_SIZE(rkvdec_h264_decoded_fmts),
267+
.decoded_fmts = rkvdec_h264_decoded_fmts,
248268
.subsystem_flags = VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF,
249269
},
250270
{
@@ -259,8 +279,8 @@ static const struct rkvdec_coded_fmt_desc rkvdec_coded_fmts[] = {
259279
},
260280
.ctrls = &rkvdec_vp9_ctrls,
261281
.ops = &rkvdec_vp9_fmt_ops,
262-
.num_decoded_fmts = ARRAY_SIZE(rkvdec_h264_vp9_decoded_fmts),
263-
.decoded_fmts = rkvdec_h264_vp9_decoded_fmts,
282+
.num_decoded_fmts = ARRAY_SIZE(rkvdec_vp9_decoded_fmts),
283+
.decoded_fmts = rkvdec_vp9_decoded_fmts,
264284
}
265285
};
266286

drivers/staging/media/rkvdec/rkvdec.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ struct rkvdec_coded_fmt_ops {
8080
enum rkvdec_image_fmt {
8181
RKVDEC_IMG_FMT_ANY = 0,
8282
RKVDEC_IMG_FMT_420_8BIT,
83+
RKVDEC_IMG_FMT_420_10BIT,
84+
RKVDEC_IMG_FMT_422_8BIT,
85+
RKVDEC_IMG_FMT_422_10BIT,
8386
};
8487

8588
struct rkvdec_decoded_fmt_desc {

0 commit comments

Comments
 (0)