[FFmpeg-devel,PATCHv4,3/4] libavcodec: v4l2: add codec formats

Submitted by Jorge Ramirez-Ortiz on Aug. 8, 2017, 4:07 p.m.

Details

Message ID 1502208428-17267-4-git-send-email-jorge.ramirez-ortiz@linaro.org
State Superseded
Headers show

Commit Message

Jorge Ramirez-Ortiz Aug. 8, 2017, 4:07 p.m.
In addition, enable the multi planar raw formats.

Reviewed-by: Jorge Ramirez <jorge.ramirez-ortiz@linaro.org>
Tested-by: Jorge Ramirez <jorge.ramirez-ortiz@linaro.org>
---
 libavcodec/v4l2_fmt.c | 38 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer Aug. 9, 2017, 1:37 a.m.
On Tue, Aug 08, 2017 at 06:07:07PM +0200, Jorge Ramirez-Ortiz wrote:
> In addition, enable the multi planar raw formats.
> 
> Reviewed-by: Jorge Ramirez <jorge.ramirez-ortiz@linaro.org>
> Tested-by: Jorge Ramirez <jorge.ramirez-ortiz@linaro.org>
> ---
>  libavcodec/v4l2_fmt.c | 38 +++++++++++++++++++++++++++++++++++++-
>  1 file changed, 37 insertions(+), 1 deletion(-)
[...]

> +    { AV_PIX_FMT_NONE,    AV_CODEC_ID_NONE,     0,                      , 0                    },

This looks odd and doesnt build

[...]
Jorge Ramirez-Ortiz Aug. 9, 2017, 5:51 a.m.
On 08/09/2017 03:37 AM, Michael Niedermayer wrote:
> On Tue, Aug 08, 2017 at 06:07:07PM +0200, Jorge Ramirez-Ortiz wrote:
>> In addition, enable the multi planar raw formats.
>>
>> Reviewed-by: Jorge Ramirez<jorge.ramirez-ortiz@linaro.org>
>> Tested-by: Jorge Ramirez<jorge.ramirez-ortiz@linaro.org>
>> ---
>>   libavcodec/v4l2_fmt.c | 38 +++++++++++++++++++++++++++++++++++++-
>>   1 file changed, 37 insertions(+), 1 deletion(-)
> [...]
>
>> +    { AV_PIX_FMT_NONE,    AV_CODEC_ID_NONE,     0,                      , 0                    },
> This looks odd and doesnt build

The previous version was missing the last field which would have left it 
un-initialized (so just added a null flag since I assume this was simply 
an error case that would not be processed?) I will fix it in v5 and 
enable the two flags for clarity then.

um, so sorry about the build.
what machine are you building on please? (ie, kernel? or maybe if you 
can its /usr/include/linux/videodev2.h API so I can try to reproduce?

Things do obviously build on my end - fate tests pass and so does 
encoding/decoding so I think we are back to the issue that you 
originally flagged when building on relatively old kernels.

This addition to configure would have prevented the build error on your 
v3 kernel that you last shared with me in last time btw.
*check_code cc linux/videodev2.h "int i = V4L2_CAP_VIDEO_M2M_MPLANE | 
V4L2_CAP_VIDEO_M2M | V4L2_BUF_FLAG_LAST;" || disable v4l2_m2m*


These are v4l2 checks that allow enabling/disable codecs depending on 
them being present on the API.

# check V4L2 codecs available in the API
check_header linux/fb.h
check_header linux/videodev.h
check_header linux/videodev2.h
check_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; 
vfse.discrete.width = 0;" && enable_safe struct_v4l2_frmivalenum_discrete
check_code cc linux/videodev2.h "int i = V4L2_CAP_VIDEO_M2M_MPLANE | 
V4L2_CAP_VIDEO_M2M | V4L2_BUF_FLAG_LAST;" || disable v4l2_m2m
check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_VC1_ANNEX_G;" && 
enable vc1_v4l2_m2m
check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG1;" && enable 
mpeg1_v4l2_m2m
check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG2;" && enable 
mpeg2_v4l2_m2m
check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG4;" && enable 
mpeg4_v4l2_m2m
check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_HEVC;" && enable 
hevc_v4l2_m2m
check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_H263;" && enable 
h263_v4l2_m2m
check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_H264;" && enable 
h264_v4l2_m2m
check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_VP8;" && enable 
vp8_v4l2_m2m
check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_VP9;" && enable 
vp9_v4l2_m2m
Jorge Ramirez-Ortiz Aug. 9, 2017, 7:39 a.m.
On 08/09/2017 07:51 AM, Jorge Ramirez wrote:
> On 08/09/2017 03:37 AM, Michael Niedermayer wrote:
>> On Tue, Aug 08, 2017 at 06:07:07PM +0200, Jorge Ramirez-Ortiz wrote:
>>> In addition, enable the multi planar raw formats.
>>>
>>> Reviewed-by: Jorge Ramirez<jorge.ramirez-ortiz@linaro.org>
>>> Tested-by: Jorge Ramirez<jorge.ramirez-ortiz@linaro.org>
>>> ---
>>>   libavcodec/v4l2_fmt.c | 38 +++++++++++++++++++++++++++++++++++++-
>>>   1 file changed, 37 insertions(+), 1 deletion(-)
>> [...]
>>
>>> +    { AV_PIX_FMT_NONE,    AV_CODEC_ID_NONE,     0,                      , 0                    },
>> This looks odd and doesnt build
>
> The previous version was missing the last field which would have left 
> it un-initialized (so just added a null flag since I assume this was 
> simply an error case that would not be processed?) I will fix it in v5 
> and enable the two flags for clarity then.
>
> um, so sorry about the build.
> what machine are you building on please? (ie, kernel? or maybe if you 
> can its /usr/include/linux/videodev2.h API so I can try to reproduce?

um, I just tried v3.2.91 (oldest longterm I could find) and it builds 
fine (configure just disables the v4l2_m2m support); any data from your 
particular build will be very welcome.

again sorry about this.


>
> Things do obviously build on my end - fate tests pass and so does 
> encoding/decoding so I think we are back to the issue that you 
> originally flagged when building on relatively old kernels.
>
> This addition to configure would have prevented the build error on 
> your v3 kernel that you last shared with me in last time btw.
> *check_code cc linux/videodev2.h "int i = V4L2_CAP_VIDEO_M2M_MPLANE | 
> V4L2_CAP_VIDEO_M2M | V4L2_BUF_FLAG_LAST;" || disable v4l2_m2m*
>
>
> These are v4l2 checks that allow enabling/disable codecs depending on 
> them being present on the API.
>
> # check V4L2 codecs available in the API
> check_header linux/fb.h
> check_header linux/videodev.h
> check_header linux/videodev2.h
> check_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; 
> vfse.discrete.width = 0;" && enable_safe struct_v4l2_frmivalenum_discrete
> check_code cc linux/videodev2.h "int i = V4L2_CAP_VIDEO_M2M_MPLANE | 
> V4L2_CAP_VIDEO_M2M | V4L2_BUF_FLAG_LAST;" || disable v4l2_m2m
> check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_VC1_ANNEX_G;" && 
> enable vc1_v4l2_m2m
> check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG1;" && 
> enable mpeg1_v4l2_m2m
> check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG2;" && 
> enable mpeg2_v4l2_m2m
> check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG4;" && 
> enable mpeg4_v4l2_m2m
> check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_HEVC;" && enable 
> hevc_v4l2_m2m
> check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_H263;" && enable 
> h263_v4l2_m2m
> check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_H264;" && enable 
> h264_v4l2_m2m
> check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_VP8;" && enable 
> vp8_v4l2_m2m
> check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_VP9;" && enable 
> vp9_v4l2_m2m
>
Jorge Ramirez-Ortiz Aug. 9, 2017, 9:08 a.m.
On 08/09/2017 09:39 AM, Jorge Ramirez wrote:
>>
>> The previous version was missing the last field which would have left 
>> it un-initialized (so just added a null flag since I assume this was 
>> simply an error case that would not be processed?) I will fix it in 
>> v5 and enable the two flags for clarity then.
>>
>> um, so sorry about the build.
>> what machine are you building on please? (ie, kernel? or maybe if you 
>> can its /usr/include/linux/videodev2.h API so I can try to reproduce?
>
> um, I just tried v3.2.91 (oldest longterm I could find) and it builds 
> fine (configure just disables the v4l2_m2m support); any data from 
> your particular build will be very welcome.
>
> again sorry about this.

ok I can reproduce on ubuntu 10.04.
will fix it and post v5 today

Patch hide | download patch | download mbox

diff --git a/libavcodec/v4l2_fmt.c b/libavcodec/v4l2_fmt.c
index 855cc64..3338984 100644
--- a/libavcodec/v4l2_fmt.c
+++ b/libavcodec/v4l2_fmt.c
@@ -58,7 +58,43 @@  const struct v4l_fmt_map avpriv_v4l_fmt_conversion_table[] = {
     { AV_PIX_FMT_BAYER_GRBG8, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_SGRBG8 , FF_V4L_PACK_AVPACKET | FF_V4L_PACK_AVFRAME },
     { AV_PIX_FMT_BAYER_RGGB8, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_SRGGB8 , FF_V4L_PACK_AVPACKET | FF_V4L_PACK_AVFRAME },
 #endif
-    { AV_PIX_FMT_NONE,    AV_CODEC_ID_NONE,     0                    },
+#ifdef V4L2_PIX_FMT_NV12M
+    { AV_PIX_FMT_NV12,    AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_NV12M      , FF_V4L_PACK_AVFRAME  },
+#endif
+#ifdef V4L2_PIX_FMT_NV21M
+    { AV_PIX_FMT_NV21,    AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_NV21M      , FF_V4L_PACK_AVFRAME  },
+#endif
+#ifdef V4L2_PIX_FMT_YUV420M
+    { AV_PIX_FMT_YUV420P, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YUV420M    , FF_V4L_PACK_AVFRAME  },
+#endif
+#ifdef V4L2_PIX_FMT_NV16M
+    { AV_PIX_FMT_NV16,    AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_NV16M      , FF_V4L_PACK_AVFRAME  },
+#endif
+#ifdef V4L2_PIX_FMT_DV
+    { AV_PIX_FMT_NONE,    AV_CODEC_ID_DVVIDEO,  V4L2_PIX_FMT_DV         , FF_V4L_PACK_AVPACKET },
+#endif
+#ifdef V4L2_PIX_FMT_H263
+    { AV_PIX_FMT_NONE,    AV_CODEC_ID_H263,     V4L2_PIX_FMT_H263       , FF_V4L_PACK_AVPACKET },
+#endif
+#ifdef V4L2_PIX_FMT_MPEG1
+    { AV_PIX_FMT_NONE,    AV_CODEC_ID_MPEG1VIDEO, V4L2_PIX_FMT_MPEG1    , FF_V4L_PACK_AVPACKET },
+#endif
+#ifdef V4L2_PIX_FMT_MPEG2
+    { AV_PIX_FMT_NONE,    AV_CODEC_ID_MPEG2VIDEO, V4L2_PIX_FMT_MPEG2    , FF_V4L_PACK_AVPACKET },
+#endif
+#ifdef V4L2_PIX_FMT_VC1_ANNEX_G
+    { AV_PIX_FMT_NONE,    AV_CODEC_ID_VC1,      V4L2_PIX_FMT_VC1_ANNEX_G, FF_V4L_PACK_AVPACKET },
+#endif
+#ifdef V4L2_PIX_FMT_VP8
+    { AV_PIX_FMT_NONE,    AV_CODEC_ID_VP8,      V4L2_PIX_FMT_VP8        , FF_V4L_PACK_AVPACKET },
+#endif
+#ifdef V4L2_PIX_FMT_HEVC
+    { AV_PIX_FMT_NONE,    AV_CODEC_ID_HEVC,     V4L2_PIX_FMT_HEVC        , FF_V4L_PACK_AVPACKET},
+#endif
+#ifdef V4L2_PIX_FMT_VP9
+    { AV_PIX_FMT_NONE,    AV_CODEC_ID_VP9,      V4L2_PIX_FMT_VP9        , FF_V4L_PACK_AVPACKET },
+#endif
+    { AV_PIX_FMT_NONE,    AV_CODEC_ID_NONE,     0,                      , 0                    },
 };
 
 uint32_t avpriv_v4l_fmt_ff2v4l(enum AVPixelFormat pix_fmt, enum AVCodecID codec_id, int pack_flags)