2023-01-12 09:41:31

by Ming Qian

[permalink] [raw]
Subject: [PATCH v2 0/2] media: amphion: decoder add support to RealVideo

RealVideo, or also spelled as Real Video, is a suite of proprietary
video compression formats developed by RealNetworks -
the specific format changes with the version.
RealVideo codecs are identified by four-character codes.
RV30 and RV40 are RealNetworks' proprietary H.264-based codecs.

amphion decoder can support decoding RV30 and RV40 streams.

v2
- correct the format name from RealMedia to RealVideo

Ming Qian (2):
media: add RealVideo format
media: amphion: support to decode RealVideo video

.../media/v4l/pixfmt-compressed.rst | 11 +++++++++++
drivers/media/platform/amphion/vdec.c | 7 +++++++
drivers/media/platform/amphion/vpu_malone.c | 19 +++++++++++++++++++
drivers/media/platform/amphion/vpu_malone.h | 1 +
drivers/media/v4l2-core/v4l2-ioctl.c | 1 +
include/uapi/linux/videodev2.h | 1 +
6 files changed, 40 insertions(+)

--
2.38.1


2023-01-12 09:44:41

by Ming Qian

[permalink] [raw]
Subject: [PATCH v2 1/2] media: add RealVideo format

RealVideo, or also spelled as Real Video, is a suite of proprietary
video compression formats developed by RealNetworks -
the specific format changes with the version.
RealVideo codecs are identified by four-character codes.
RV10 and RV20 are the H.263-based codecs.
RV30 and RV40 are RealNetworks' proprietary H.264-based codecs.
RV60 is RealNetworks' proprietary HEVC-based codecs.

Signed-off-by: Ming Qian <[email protected]>
---
.../userspace-api/media/v4l/pixfmt-compressed.rst | 11 +++++++++++
drivers/media/v4l2-core/v4l2-ioctl.c | 1 +
include/uapi/linux/videodev2.h | 1 +
3 files changed, 13 insertions(+)

diff --git a/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst b/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst
index a0230f357680..22035d92c788 100644
--- a/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst
+++ b/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst
@@ -237,6 +237,17 @@ Compressed Formats
Metadata associated with the frame to decode is required to be passed
through the ``V4L2_CID_STATELESS_FWHT_PARAMS`` control.
See the :ref:`associated Codec Control ID <codec-stateless-fwht>`.
+ * .. _V4L2-PIX-FMT-RV:
+
+ - ``V4L2_PIX_FMT_RV``
+ - 'RV00'
+ - RealVideo, or also spelled as Real Video, is a suite of proprietary
+ video compression formats developed by RealNetworks -
+ the specific format changes with the version.
+ RealVideo codecs are identified by four-character codes.
+ RV10 and RV20 are the H.263-based codecs.
+ RV30 and RV40 are RealNetworks' proprietary H.264-based codecs.
+ RV60 is RealNetworks' proprietary HEVC-based codecs.

.. raw:: latex

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 9b5b04b8aa69..c375261d169f 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1473,6 +1473,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_PIX_FMT_FWHT: descr = "FWHT"; break; /* used in vicodec */
case V4L2_PIX_FMT_FWHT_STATELESS: descr = "FWHT Stateless"; break; /* used in vicodec */
case V4L2_PIX_FMT_SPK: descr = "Sorenson Spark"; break;
+ case V4L2_PIX_FMT_RV: descr = "RealVideo"; break;
case V4L2_PIX_FMT_CPIA1: descr = "GSPCA CPiA YUV"; break;
case V4L2_PIX_FMT_WNVA: descr = "WNVA"; break;
case V4L2_PIX_FMT_SN9C10X: descr = "GSPCA SN9C10X"; break;
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 262ef10cfa02..0a7ddb023d7c 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -740,6 +740,7 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_H264_SLICE v4l2_fourcc('S', '2', '6', '4') /* H264 parsed slices */
#define V4L2_PIX_FMT_HEVC_SLICE v4l2_fourcc('S', '2', '6', '5') /* HEVC parsed slices */
#define V4L2_PIX_FMT_SPK v4l2_fourcc('S', 'P', 'K', '0') /* Sorenson Spark */
+#define V4L2_PIX_FMT_RV v4l2_fourcc('R', 'V', '0', '0') /* RealVideo */

/* Vendor-specific formats */
#define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A') /* cpia1 YUV */
--
2.38.1

2023-01-12 10:29:26

by Ming Qian

[permalink] [raw]
Subject: [PATCH v2 2/2] media: amphion: support to decode RealVideo video

amphion decoder add support for the RealVideo video.
RV30 and RV40 are support by amphion decoder.

Signed-off-by: Ming Qian <[email protected]>
---
drivers/media/platform/amphion/vdec.c | 7 +++++++
drivers/media/platform/amphion/vpu_malone.c | 19 +++++++++++++++++++
drivers/media/platform/amphion/vpu_malone.h | 1 +
3 files changed, 27 insertions(+)

diff --git a/drivers/media/platform/amphion/vdec.c b/drivers/media/platform/amphion/vdec.c
index 09304b96f40d..7e47465ee749 100644
--- a/drivers/media/platform/amphion/vdec.c
+++ b/drivers/media/platform/amphion/vdec.c
@@ -172,6 +172,13 @@ static const struct vpu_format vdec_formats[] = {
.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
.flags = V4L2_FMT_FLAG_DYN_RESOLUTION | V4L2_FMT_FLAG_COMPRESSED
},
+ {
+ .pixfmt = V4L2_PIX_FMT_RV,
+ .mem_planes = 1,
+ .comp_planes = 1,
+ .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
+ .flags = V4L2_FMT_FLAG_DYN_RESOLUTION | V4L2_FMT_FLAG_COMPRESSED
+ },
{0, 0, 0, 0},
};

diff --git a/drivers/media/platform/amphion/vpu_malone.c b/drivers/media/platform/amphion/vpu_malone.c
index 67ba637c4c7f..6e3626b74c7a 100644
--- a/drivers/media/platform/amphion/vpu_malone.c
+++ b/drivers/media/platform/amphion/vpu_malone.c
@@ -68,6 +68,8 @@
#define STREAM_CONFIG_NUM_DBE_SET(x, y) CONFIG_SET(x, y, 30, 0x40000000)
#define STREAM_CONFIG_FS_CTRL_MODE_SET(x, y) CONFIG_SET(x, y, 31, 0x80000000)

+#define MALONE_DEC_FMT_RV_MASK BIT(21)
+
enum vpu_malone_stream_input_mode {
INVALID_MODE = 0,
FRAME_LVL,
@@ -478,6 +480,8 @@ u32 vpu_malone_get_version(struct vpu_shared_addr *shared)
{
struct malone_iface *iface = shared->iface;

+ vpu_malone_enable_format(V4L2_PIX_FMT_RV, iface->fw_version & MALONE_DEC_FMT_RV_MASK);
+
return iface->fw_version;
}

@@ -563,8 +567,21 @@ static struct malone_fmt_mapping fmt_mappings[] = {
{V4L2_PIX_FMT_JPEG, MALONE_FMT_JPG},
{V4L2_PIX_FMT_VP8, MALONE_FMT_VP8},
{V4L2_PIX_FMT_SPK, MALONE_FMT_SPK},
+ {V4L2_PIX_FMT_RV, MALONE_FMT_RV},
};

+void vpu_malone_enable_format(u32 pixelformat, int enable)
+{
+ u32 i;
+
+ for (i = 0; i < ARRAY_SIZE(fmt_mappings); i++) {
+ if (pixelformat == fmt_mappings[i].pixelformat) {
+ fmt_mappings[i].is_disabled = enable ? 0 : 1;
+ return;
+ }
+ }
+}
+
static enum vpu_malone_format vpu_malone_format_remap(u32 pixelformat)
{
u32 i;
@@ -989,6 +1006,7 @@ static const struct malone_padding_scode padding_scodes[] = {
{SCODE_PADDING_EOS, V4L2_PIX_FMT_H263, {0xb1010000, 0x0}},
{SCODE_PADDING_EOS, V4L2_PIX_FMT_VP8, {0x34010000, 0x0}},
{SCODE_PADDING_EOS, V4L2_PIX_FMT_SPK, {0x34010000, 0x0}},
+ {SCODE_PADDING_EOS, V4L2_PIX_FMT_RV, {0x34010000, 0x0}},
{SCODE_PADDING_EOS, V4L2_PIX_FMT_JPEG, {0xefff0000, 0x0}},
{SCODE_PADDING_ABORT, V4L2_PIX_FMT_H264, {0x0B010000, 0}},
{SCODE_PADDING_ABORT, V4L2_PIX_FMT_H264_MVC, {0x0B010000, 0}},
@@ -1001,6 +1019,7 @@ static const struct malone_padding_scode padding_scodes[] = {
{SCODE_PADDING_ABORT, V4L2_PIX_FMT_H263, {0xb1010000, 0x0}},
{SCODE_PADDING_ABORT, V4L2_PIX_FMT_VP8, {0x34010000, 0x0}},
{SCODE_PADDING_ABORT, V4L2_PIX_FMT_SPK, {0x34010000, 0x0}},
+ {SCODE_PADDING_ABORT, V4L2_PIX_FMT_RV, {0x34010000, 0x0}},
{SCODE_PADDING_EOS, V4L2_PIX_FMT_JPEG, {0x0, 0x0}},
{SCODE_PADDING_BUFFLUSH, V4L2_PIX_FMT_H264, {0x15010000, 0x0}},
{SCODE_PADDING_BUFFLUSH, V4L2_PIX_FMT_H264_MVC, {0x15010000, 0x0}},
diff --git a/drivers/media/platform/amphion/vpu_malone.h b/drivers/media/platform/amphion/vpu_malone.h
index 02a9d9530970..c95b53629199 100644
--- a/drivers/media/platform/amphion/vpu_malone.h
+++ b/drivers/media/platform/amphion/vpu_malone.h
@@ -41,5 +41,6 @@ int vpu_malone_post_cmd(struct vpu_shared_addr *shared, u32 instance);
int vpu_malone_init_instance(struct vpu_shared_addr *shared, u32 instance);
u32 vpu_malone_get_max_instance_count(struct vpu_shared_addr *shared);
bool vpu_malone_check_fmt(enum vpu_core_type type, u32 pixelfmt);
+void vpu_malone_enable_format(u32 pixelformat, int enable);

#endif
--
2.38.1

2023-01-12 21:49:24

by Nicolas Dufresne

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] media: add RealVideo format

Hi Ming,

Le jeudi 12 janvier 2023 à 17:18 +0800, Ming Qian a écrit :
> RealVideo, or also spelled as Real Video, is a suite of proprietary
> video compression formats developed by RealNetworks -
> the specific format changes with the version.
> RealVideo codecs are identified by four-character codes.
> RV10 and RV20 are the H.263-based codecs.
> RV30 and RV40 are RealNetworks' proprietary H.264-based codecs.
> RV60 is RealNetworks' proprietary HEVC-based codecs.
>
> Signed-off-by: Ming Qian <[email protected]>
> ---
> .../userspace-api/media/v4l/pixfmt-compressed.rst | 11 +++++++++++
> drivers/media/v4l2-core/v4l2-ioctl.c | 1 +
> include/uapi/linux/videodev2.h | 1 +
> 3 files changed, 13 insertions(+)
>
> diff --git a/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst b/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst
> index a0230f357680..22035d92c788 100644
> --- a/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst
> +++ b/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst
> @@ -237,6 +237,17 @@ Compressed Formats
> Metadata associated with the frame to decode is required to be passed
> through the ``V4L2_CID_STATELESS_FWHT_PARAMS`` control.
> See the :ref:`associated Codec Control ID <codec-stateless-fwht>`.
> + * .. _V4L2-PIX-FMT-RV:
> +
> + - ``V4L2_PIX_FMT_RV``
> + - 'RV00'
> + - RealVideo, or also spelled as Real Video, is a suite of proprietary
> + video compression formats developed by RealNetworks -
> + the specific format changes with the version.
> + RealVideo codecs are identified by four-character codes.
> + RV10 and RV20 are the H.263-based codecs.
> + RV30 and RV40 are RealNetworks' proprietary H.264-based codecs.
> + RV60 is RealNetworks' proprietary HEVC-based codecs.

Much better description. Though you haven't commented or addressed my concern of
having 4 different CODECs under the same FMT. I thinks it would make more sense
to export the four of them. Then driver can pick the set they support,
regardless if it requires special handling of not at the HW level. What do you
think ?

Even though unlikely considering the age of the CODECs, but having a single FMT
for an encoder would just increase the encoder interface complexity (could
require a control to select which actual format to encode to).
>
> .. raw:: latex
>
> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> index 9b5b04b8aa69..c375261d169f 100644
> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> @@ -1473,6 +1473,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
> case V4L2_PIX_FMT_FWHT: descr = "FWHT"; break; /* used in vicodec */
> case V4L2_PIX_FMT_FWHT_STATELESS: descr = "FWHT Stateless"; break; /* used in vicodec */
> case V4L2_PIX_FMT_SPK: descr = "Sorenson Spark"; break;
> + case V4L2_PIX_FMT_RV: descr = "RealVideo"; break;
> case V4L2_PIX_FMT_CPIA1: descr = "GSPCA CPiA YUV"; break;
> case V4L2_PIX_FMT_WNVA: descr = "WNVA"; break;
> case V4L2_PIX_FMT_SN9C10X: descr = "GSPCA SN9C10X"; break;
> diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
> index 262ef10cfa02..0a7ddb023d7c 100644
> --- a/include/uapi/linux/videodev2.h
> +++ b/include/uapi/linux/videodev2.h
> @@ -740,6 +740,7 @@ struct v4l2_pix_format {
> #define V4L2_PIX_FMT_H264_SLICE v4l2_fourcc('S', '2', '6', '4') /* H264 parsed slices */
> #define V4L2_PIX_FMT_HEVC_SLICE v4l2_fourcc('S', '2', '6', '5') /* HEVC parsed slices */
> #define V4L2_PIX_FMT_SPK v4l2_fourcc('S', 'P', 'K', '0') /* Sorenson Spark */
> +#define V4L2_PIX_FMT_RV v4l2_fourcc('R', 'V', '0', '0') /* RealVideo */
>
> /* Vendor-specific formats */
> #define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A') /* cpia1 YUV */

2023-01-13 02:04:49

by Ming Qian

[permalink] [raw]
Subject: RE: [EXT] Re: [PATCH v2 1/2] media: add RealVideo format

>From: Nicolas Dufresne <[email protected]>
>Sent: 2023年1月13日 5:30
>To: Ming Qian <[email protected]>; [email protected]; hverkuil-
>[email protected]
>Cc: [email protected]; [email protected]; [email protected];
>[email protected]; [email protected]; dl-linux-imx <linux-
>[email protected]>; X.H. Bao <[email protected]>; Eagle Zhou
><[email protected]>; Tao Jiang <[email protected]>; linux-
>[email protected]; [email protected]; linux-arm-
>[email protected]
>Subject: [EXT] Re: [PATCH v2 1/2] media: add RealVideo format
>
>Caution: EXT Email
>
>Hi Ming,
>
>Le jeudi 12 janvier 2023 à 17:18 +0800, Ming Qian a écrit :
>> RealVideo, or also spelled as Real Video, is a suite of proprietary
>> video compression formats developed by RealNetworks - the specific
>> format changes with the version.
>> RealVideo codecs are identified by four-character codes.
>> RV10 and RV20 are the H.263-based codecs.
>> RV30 and RV40 are RealNetworks' proprietary H.264-based codecs.
>> RV60 is RealNetworks' proprietary HEVC-based codecs.
>>
>> Signed-off-by: Ming Qian <[email protected]>
>> ---
>> .../userspace-api/media/v4l/pixfmt-compressed.rst | 11 +++++++++++
>> drivers/media/v4l2-core/v4l2-ioctl.c | 1 +
>> include/uapi/linux/videodev2.h | 1 +
>> 3 files changed, 13 insertions(+)
>>
>> diff --git
>> a/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst
>> b/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst
>> index a0230f357680..22035d92c788 100644
>> --- a/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst
>> +++ b/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst
>> @@ -237,6 +237,17 @@ Compressed Formats
>> Metadata associated with the frame to decode is required to be passed
>> through the ``V4L2_CID_STATELESS_FWHT_PARAMS`` control.
>> See the :ref:`associated Codec Control ID <codec-stateless-fwht>`.
>> + * .. _V4L2-PIX-FMT-RV:
>> +
>> + - ``V4L2_PIX_FMT_RV``
>> + - 'RV00'
>> + - RealVideo, or also spelled as Real Video, is a suite of proprietary
>> + video compression formats developed by RealNetworks -
>> + the specific format changes with the version.
>> + RealVideo codecs are identified by four-character codes.
>> + RV10 and RV20 are the H.263-based codecs.
>> + RV30 and RV40 are RealNetworks' proprietary H.264-based codecs.
>> + RV60 is RealNetworks' proprietary HEVC-based codecs.
>
>Much better description. Though you haven't commented or addressed my
>concern of having 4 different CODECs under the same FMT. I thinks it would
>make more sense to export the four of them. Then driver can pick the set they
>support, regardless if it requires special handling of not at the HW level. What
>do you think ?
>
>Even though unlikely considering the age of the CODECs, but having a single
>FMT for an encoder would just increase the encoder interface complexity
>(could require a control to select which actual format to encode to).

Hi Nicolas,
I agree that it's better to define 4 fourcc for encoder, I was only thinking about decoders,
I thought the fourcc of rv version is included in the sequence header of rv stream,
So the decoder can detect it and decide how to decode it.

Considering the encoder, it's indeed a problem, I'll update the patch and define 4 format in V3

Ming

>>
>> .. raw:: latex
>>
>> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c
>> b/drivers/media/v4l2-core/v4l2-ioctl.c
>> index 9b5b04b8aa69..c375261d169f 100644
>> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
>> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
>> @@ -1473,6 +1473,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc
>*fmt)
>> case V4L2_PIX_FMT_FWHT: descr = "FWHT"; break; /* used in
>vicodec */
>> case V4L2_PIX_FMT_FWHT_STATELESS: descr = "FWHT Stateless";
>break; /* used in vicodec */
>> case V4L2_PIX_FMT_SPK: descr = "Sorenson Spark"; break;
>> + case V4L2_PIX_FMT_RV: descr = "RealVideo"; break;
>> case V4L2_PIX_FMT_CPIA1: descr = "GSPCA CPiA YUV"; break;
>> case V4L2_PIX_FMT_WNVA: descr = "WNVA"; break;
>> case V4L2_PIX_FMT_SN9C10X: descr = "GSPCA SN9C10X"; break;
>> diff --git a/include/uapi/linux/videodev2.h
>> b/include/uapi/linux/videodev2.h index 262ef10cfa02..0a7ddb023d7c
>> 100644
>> --- a/include/uapi/linux/videodev2.h
>> +++ b/include/uapi/linux/videodev2.h
>> @@ -740,6 +740,7 @@ struct v4l2_pix_format { #define
>> V4L2_PIX_FMT_H264_SLICE v4l2_fourcc('S', '2', '6', '4') /* H264 parsed
>> slices */ #define V4L2_PIX_FMT_HEVC_SLICE v4l2_fourcc('S', '2', '6', '5') /*
>HEVC parsed slices */
>> #define V4L2_PIX_FMT_SPK v4l2_fourcc('S', 'P', 'K', '0') /* Sorenson Spark
>*/
>> +#define V4L2_PIX_FMT_RV v4l2_fourcc('R', 'V', '0', '0') /* RealVideo */
>>
>> /* Vendor-specific formats */
>> #define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A') /* cpia1 YUV */