[FFmpeg-devel] kmsgrab: fix build error when use old libdrm

Submitted by Jun Zhao on Sept. 14, 2017, 12:34 a.m.

Details

Message ID 81962f71-7fdc-6330-dab2-793cfb1987ad@gmail.com
State New
Headers show

Commit Message

Jun Zhao Sept. 14, 2017, 12:34 a.m.
From 8c7ddfcabf686f213aa59544d90055d20bdac0f7 Mon Sep 17 00:00:00 2001
From: Jun Zhao <jun.zhao@intel.com>
Date: Wed, 13 Sep 2017 20:21:38 -0400
Subject: [PATCH] kmsgrab: fix build error when use old libdrm

DRM_FORMAT_R16 adding from libdrm 2.4.82, fix the build error
when libdrm < 2.4.82.

Signed-off-by: Jun Zhao <jun.zhao@intel.com>
---
 libavdevice/kmsgrab.c       | 2 ++
 libavutil/hwcontext_vaapi.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

Comments

Mark Thompson Sept. 14, 2017, 8:12 a.m.
On 14/09/17 01:34, Jun Zhao wrote:
> From 8c7ddfcabf686f213aa59544d90055d20bdac0f7 Mon Sep 17 00:00:00 2001
> From: Jun Zhao <jun.zhao@intel.com>
> Date: Wed, 13 Sep 2017 20:21:38 -0400
> Subject: [PATCH] kmsgrab: fix build error when use old libdrm
> 
> DRM_FORMAT_R16 adding from libdrm 2.4.82, fix the build error
> when libdrm < 2.4.82.
> 
> Signed-off-by: Jun Zhao <jun.zhao@intel.com>
> ---
>  libavdevice/kmsgrab.c       | 2 ++
>  libavutil/hwcontext_vaapi.c | 2 +-
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavdevice/kmsgrab.c b/libavdevice/kmsgrab.c
> index d0b9cf5001..49eb44f6f2 100644
> --- a/libavdevice/kmsgrab.c
> +++ b/libavdevice/kmsgrab.c
> @@ -203,7 +203,9 @@ static const struct {
>      uint32_t drm_format;
>  } kmsgrab_formats[] = {
>      { AV_PIX_FMT_GRAY8,    DRM_FORMAT_R8       },
> +#ifdef DRM_FORMAT_R16
>      { AV_PIX_FMT_GRAY16LE, DRM_FORMAT_R16      },
> +#endif
>      { AV_PIX_FMT_RGB24,    DRM_FORMAT_RGB888   },
>      { AV_PIX_FMT_BGR24,    DRM_FORMAT_BGR888   },
>      { AV_PIX_FMT_0RGB,     DRM_FORMAT_XRGB8888 },
> diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
> index 2cc6f26715..837b79da11 100644
> --- a/libavutil/hwcontext_vaapi.c
> +++ b/libavutil/hwcontext_vaapi.c
> @@ -920,7 +920,7 @@ static const struct {
>  } vaapi_drm_format_map[] = {
>      DRM_MAP(NV12, 2, DRM_FORMAT_R8,  DRM_FORMAT_RG88),
>      DRM_MAP(NV12, 1, DRM_FORMAT_NV12),
> -#ifdef VA_FOURCC_P010
> +#if defined(VA_FOURCC_P010) && defined(DRM_FORMAT_R16)
>      DRM_MAP(P010, 2, DRM_FORMAT_R16, DRM_FORMAT_RG1616),
>  #endif
>      DRM_MAP(BGRA, 1, DRM_FORMAT_BGRA8888),
> -- 
> 2.11.0
> 

Hmm, yeah.  Thanks for noticing this - let me think about it a bit further, I imagine there are more cases than just this one.  (It isn't autodetected so nothing is directly broken.)

- Mark
Mark Thompson Sept. 14, 2017, 10:02 a.m.
On 14/09/17 01:34, Jun Zhao wrote:
> From 8c7ddfcabf686f213aa59544d90055d20bdac0f7 Mon Sep 17 00:00:00 2001
> From: Jun Zhao <jun.zhao@intel.com>
> Date: Wed, 13 Sep 2017 20:21:38 -0400
> Subject: [PATCH] kmsgrab: fix build error when use old libdrm
> 
> DRM_FORMAT_R16 adding from libdrm 2.4.82, fix the build error
> when libdrm < 2.4.82.
> 
> Signed-off-by: Jun Zhao <jun.zhao@intel.com>
> ---
>  libavdevice/kmsgrab.c       | 2 ++
>  libavutil/hwcontext_vaapi.c | 2 +-
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavdevice/kmsgrab.c b/libavdevice/kmsgrab.c
> index d0b9cf5001..49eb44f6f2 100644
> --- a/libavdevice/kmsgrab.c
> +++ b/libavdevice/kmsgrab.c
> @@ -203,7 +203,9 @@ static const struct {
>      uint32_t drm_format;
>  } kmsgrab_formats[] = {
>      { AV_PIX_FMT_GRAY8,    DRM_FORMAT_R8       },
> +#ifdef DRM_FORMAT_R16
>      { AV_PIX_FMT_GRAY16LE, DRM_FORMAT_R16      },
> +#endif
>      { AV_PIX_FMT_RGB24,    DRM_FORMAT_RGB888   },
>      { AV_PIX_FMT_BGR24,    DRM_FORMAT_BGR888   },
>      { AV_PIX_FMT_0RGB,     DRM_FORMAT_XRGB8888 },
> diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
> index 2cc6f26715..837b79da11 100644
> --- a/libavutil/hwcontext_vaapi.c
> +++ b/libavutil/hwcontext_vaapi.c
> @@ -920,7 +920,7 @@ static const struct {
>  } vaapi_drm_format_map[] = {
>      DRM_MAP(NV12, 2, DRM_FORMAT_R8,  DRM_FORMAT_RG88),
>      DRM_MAP(NV12, 1, DRM_FORMAT_NV12),
> -#ifdef VA_FOURCC_P010
> +#if defined(VA_FOURCC_P010) && defined(DRM_FORMAT_R16)
>      DRM_MAP(P010, 2, DRM_FORMAT_R16, DRM_FORMAT_RG1616),
>  #endif
>      DRM_MAP(BGRA, 1, DRM_FORMAT_BGRA8888),
> -- 
> 2.11.0
> 

R8/RG88 can be a problem as well (2.4.68).  Also, this should be two patches (one for each of the two components).

I can split and add that later myself, or you can send a new version if you prefer?

Thanks,

- Mark
Mark Thompson Sept. 14, 2017, 10:11 p.m.
On 14/09/17 11:02, Mark Thompson wrote:
> On 14/09/17 01:34, Jun Zhao wrote:
>> From 8c7ddfcabf686f213aa59544d90055d20bdac0f7 Mon Sep 17 00:00:00 2001
>> From: Jun Zhao <jun.zhao@intel.com>
>> Date: Wed, 13 Sep 2017 20:21:38 -0400
>> Subject: [PATCH] kmsgrab: fix build error when use old libdrm
>>
>> DRM_FORMAT_R16 adding from libdrm 2.4.82, fix the build error
>> when libdrm < 2.4.82.
>>
>> Signed-off-by: Jun Zhao <jun.zhao@intel.com>
>> ---
>>  libavdevice/kmsgrab.c       | 2 ++
>>  libavutil/hwcontext_vaapi.c | 2 +-
>>  2 files changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavdevice/kmsgrab.c b/libavdevice/kmsgrab.c
>> index d0b9cf5001..49eb44f6f2 100644
>> --- a/libavdevice/kmsgrab.c
>> +++ b/libavdevice/kmsgrab.c
>> @@ -203,7 +203,9 @@ static const struct {
>>      uint32_t drm_format;
>>  } kmsgrab_formats[] = {
>>      { AV_PIX_FMT_GRAY8,    DRM_FORMAT_R8       },
>> +#ifdef DRM_FORMAT_R16
>>      { AV_PIX_FMT_GRAY16LE, DRM_FORMAT_R16      },
>> +#endif
>>      { AV_PIX_FMT_RGB24,    DRM_FORMAT_RGB888   },
>>      { AV_PIX_FMT_BGR24,    DRM_FORMAT_BGR888   },
>>      { AV_PIX_FMT_0RGB,     DRM_FORMAT_XRGB8888 },
>> diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
>> index 2cc6f26715..837b79da11 100644
>> --- a/libavutil/hwcontext_vaapi.c
>> +++ b/libavutil/hwcontext_vaapi.c
>> @@ -920,7 +920,7 @@ static const struct {
>>  } vaapi_drm_format_map[] = {
>>      DRM_MAP(NV12, 2, DRM_FORMAT_R8,  DRM_FORMAT_RG88),
>>      DRM_MAP(NV12, 1, DRM_FORMAT_NV12),
>> -#ifdef VA_FOURCC_P010
>> +#if defined(VA_FOURCC_P010) && defined(DRM_FORMAT_R16)
>>      DRM_MAP(P010, 2, DRM_FORMAT_R16, DRM_FORMAT_RG1616),
>>  #endif
>>      DRM_MAP(BGRA, 1, DRM_FORMAT_BGRA8888),
>> -- 
>> 2.11.0
>>
> 
> R8/RG88 can be a problem as well (2.4.68).  Also, this should be two patches (one for each of the two components).
> 
> I can split and add that later myself, or you can send a new version if you prefer?

Split, added the other case, applied.

Thanks!

- Mark
Moritz Barsnick Sept. 19, 2017, 8:17 p.m.
On Thu, Sep 14, 2017 at 09:12:50 +0100, Mark Thompson wrote:
> > DRM_FORMAT_R16 adding from libdrm 2.4.82, fix the build error
> > when libdrm < 2.4.82.

> Hmm, yeah.  Thanks for noticing this - let me think about it a bit
> further, I imagine there are more cases than just this one. (It isn't
> autodetected so nothing is directly broken.)

There's certainly more stuff in here which isn't supported by older
libdrm. I'm talking e.g. headers which were introduced around 2011.
That's probably so ancient it doesn't warrent a version check/guard
though. (IOW I managed to configure with --enable-libdrm, but not
compile.)

Moritz

Patch hide | download patch | download mbox

diff --git a/libavdevice/kmsgrab.c b/libavdevice/kmsgrab.c
index d0b9cf5001..49eb44f6f2 100644
--- a/libavdevice/kmsgrab.c
+++ b/libavdevice/kmsgrab.c
@@ -203,7 +203,9 @@  static const struct {
     uint32_t drm_format;
 } kmsgrab_formats[] = {
     { AV_PIX_FMT_GRAY8,    DRM_FORMAT_R8       },
+#ifdef DRM_FORMAT_R16
     { AV_PIX_FMT_GRAY16LE, DRM_FORMAT_R16      },
+#endif
     { AV_PIX_FMT_RGB24,    DRM_FORMAT_RGB888   },
     { AV_PIX_FMT_BGR24,    DRM_FORMAT_BGR888   },
     { AV_PIX_FMT_0RGB,     DRM_FORMAT_XRGB8888 },
diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index 2cc6f26715..837b79da11 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -920,7 +920,7 @@  static const struct {
 } vaapi_drm_format_map[] = {
     DRM_MAP(NV12, 2, DRM_FORMAT_R8,  DRM_FORMAT_RG88),
     DRM_MAP(NV12, 1, DRM_FORMAT_NV12),
-#ifdef VA_FOURCC_P010
+#if defined(VA_FOURCC_P010) && defined(DRM_FORMAT_R16)
     DRM_MAP(P010, 2, DRM_FORMAT_R16, DRM_FORMAT_RG1616),
 #endif
     DRM_MAP(BGRA, 1, DRM_FORMAT_BGRA8888),