Re: [FFmpeg-devel] [PATCH v2] avcodec/v4l2_m2m_enc: Check encoder pix_fmt matches pix_fmt on device

2019-12-23 Thread Andriy Gelman
On Mon, 23. Dec 21:42, Michael Niedermayer wrote:
> On Mon, Dec 23, 2019 at 11:05:04AM -0500, Andriy Gelman wrote:
> > On Sat, 23. Nov 06:18, Andriy Gelman wrote:
> > > On Tue, 12. Nov 22:46, Andriy Gelman wrote:
> > > > From: Andriy Gelman 
> > > > 
> > > > Fixes #8079
> > > > 
> > > > During initialization of a v4l2m2m device, the configured pix_fmt can be
> > > > different to the pix_fmt of the encoder (i.e. avctx->pix_fmt).
> > > > 
> > > > For example on the Odroid XU4:
> > > > ./ffmpeg -f lavfi -i yuvtestsrc -codec:v h264_v4l2m2m out.h264
> > > > 
> > > > will configure the v4l2 encoder to pix_fmt nv21, whereas the input
> > > > frames will be yuv444p.
> > > > 
> > > > This commit checks that the configured v4l2 pix_fmt on device is the
> > > > same as avctx->pix_fmt. If they are different the initialization fails
> > > > and an error is returned. Tested on RPI4 and Odroid XU4.
> > > > 
> > > > Signed-off-by: Andriy Gelman 
> > > > ---
> > > >  libavcodec/v4l2_m2m_enc.c | 15 +++
> > > >  1 file changed, 15 insertions(+)
> > > > 
> > > > diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
> > > > index 474e6bef897..c0e82afe354 100644
> > > > --- a/libavcodec/v4l2_m2m_enc.c
> > > > +++ b/libavcodec/v4l2_m2m_enc.c
> > > > @@ -30,6 +30,7 @@
> > > >  #include "libavutil/opt.h"
> > > >  #include "v4l2_context.h"
> > > >  #include "v4l2_m2m.h"
> > > > +#include "v4l2_fmt.h"
> > > >  
> > > >  #define MPEG_CID(x) V4L2_CID_MPEG_VIDEO_##x
> > > >  #define MPEG_VIDEO(x) V4L2_MPEG_VIDEO_##x
> > > > @@ -288,6 +289,8 @@ static av_cold int v4l2_encode_init(AVCodecContext 
> > > > *avctx)
> > > >  V4L2Context *capture, *output;
> > > >  V4L2m2mContext *s;
> > > >  V4L2m2mPriv *priv = avctx->priv_data;
> > > > +enum AVPixelFormat pix_fmt_output;
> > > > +uint32_t v4l2_fmt_output;
> > > >  int ret;
> > > >  
> > > >  ret = ff_v4l2_m2m_create_context(priv, );
> > > > @@ -316,6 +319,18 @@ static av_cold int v4l2_encode_init(AVCodecContext 
> > > > *avctx)
> > > >  }
> > > >  s->avctx = avctx;
> > > >  
> > > > +if (V4L2_TYPE_IS_MULTIPLANAR(output->type))
> > > > +v4l2_fmt_output = output->format.fmt.pix_mp.pixelformat;
> > > > +else
> > > > +v4l2_fmt_output = output->format.fmt.pix.pixelformat;
> > > > +
> > > > +pix_fmt_output = ff_v4l2_format_v4l2_to_avfmt(v4l2_fmt_output, 
> > > > AV_CODEC_ID_RAWVIDEO);
> > > > +if (pix_fmt_output != avctx->pix_fmt) {
> > > > +const AVPixFmtDescriptor *desc = 
> > > > av_pix_fmt_desc_get(pix_fmt_output);
> > > > +av_log(priv, AV_LOG_ERROR, "Encoder requires %s pixel 
> > > > format.\n", desc->name);
> > > > +return AVERROR(EINVAL);
> > > > +}
> > > > +
> > > >  return v4l2_prepare_encoder(s);
> > > >  }
> > > >  
> > > > -- 
> > > > 2.23.0
> > > > 
> > > 
> > > ping 
> > > 
> > 
> > ping

> 
> try to mail the people listed in MAINTAINERs or the last person working on the
> file you need a review for
> 

I emailed Jorge Ramirez-Ortiz, he replied:

> On 09/12/19 21:26:19, Jorge Ramirez-Ortiz, Gmail wrote:
> > On 09/12/19 09:22:45, Andriy Gelman wrote:
> > > Hello Jorge, 
> > > 
> > > Do you have time to look at this patch, please?
> > > 
> > > Thank you, 
> > > Andriy
> > 
> 
> I apologoize to everyone - I cant find the time to work on this (due to a 
> number of very different reasons I have been struggling for a while with my 
> workload so it is time for me to be realistic).
>  
> I think it would be best if someone else picks up maintainership of this 
> interface and provides it with the technical direction it needs.
> 
> thanks
> Jorge

On irc, Aman told me he'll try to look at the patch. 

-- 
Andriy
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2] avcodec/v4l2_m2m_enc: Check encoder pix_fmt matches pix_fmt on device

2019-12-23 Thread Michael Niedermayer
On Mon, Dec 23, 2019 at 11:05:04AM -0500, Andriy Gelman wrote:
> On Sat, 23. Nov 06:18, Andriy Gelman wrote:
> > On Tue, 12. Nov 22:46, Andriy Gelman wrote:
> > > From: Andriy Gelman 
> > > 
> > > Fixes #8079
> > > 
> > > During initialization of a v4l2m2m device, the configured pix_fmt can be
> > > different to the pix_fmt of the encoder (i.e. avctx->pix_fmt).
> > > 
> > > For example on the Odroid XU4:
> > > ./ffmpeg -f lavfi -i yuvtestsrc -codec:v h264_v4l2m2m out.h264
> > > 
> > > will configure the v4l2 encoder to pix_fmt nv21, whereas the input
> > > frames will be yuv444p.
> > > 
> > > This commit checks that the configured v4l2 pix_fmt on device is the
> > > same as avctx->pix_fmt. If they are different the initialization fails
> > > and an error is returned. Tested on RPI4 and Odroid XU4.
> > > 
> > > Signed-off-by: Andriy Gelman 
> > > ---
> > >  libavcodec/v4l2_m2m_enc.c | 15 +++
> > >  1 file changed, 15 insertions(+)
> > > 
> > > diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
> > > index 474e6bef897..c0e82afe354 100644
> > > --- a/libavcodec/v4l2_m2m_enc.c
> > > +++ b/libavcodec/v4l2_m2m_enc.c
> > > @@ -30,6 +30,7 @@
> > >  #include "libavutil/opt.h"
> > >  #include "v4l2_context.h"
> > >  #include "v4l2_m2m.h"
> > > +#include "v4l2_fmt.h"
> > >  
> > >  #define MPEG_CID(x) V4L2_CID_MPEG_VIDEO_##x
> > >  #define MPEG_VIDEO(x) V4L2_MPEG_VIDEO_##x
> > > @@ -288,6 +289,8 @@ static av_cold int v4l2_encode_init(AVCodecContext 
> > > *avctx)
> > >  V4L2Context *capture, *output;
> > >  V4L2m2mContext *s;
> > >  V4L2m2mPriv *priv = avctx->priv_data;
> > > +enum AVPixelFormat pix_fmt_output;
> > > +uint32_t v4l2_fmt_output;
> > >  int ret;
> > >  
> > >  ret = ff_v4l2_m2m_create_context(priv, );
> > > @@ -316,6 +319,18 @@ static av_cold int v4l2_encode_init(AVCodecContext 
> > > *avctx)
> > >  }
> > >  s->avctx = avctx;
> > >  
> > > +if (V4L2_TYPE_IS_MULTIPLANAR(output->type))
> > > +v4l2_fmt_output = output->format.fmt.pix_mp.pixelformat;
> > > +else
> > > +v4l2_fmt_output = output->format.fmt.pix.pixelformat;
> > > +
> > > +pix_fmt_output = ff_v4l2_format_v4l2_to_avfmt(v4l2_fmt_output, 
> > > AV_CODEC_ID_RAWVIDEO);
> > > +if (pix_fmt_output != avctx->pix_fmt) {
> > > +const AVPixFmtDescriptor *desc = 
> > > av_pix_fmt_desc_get(pix_fmt_output);
> > > +av_log(priv, AV_LOG_ERROR, "Encoder requires %s pixel 
> > > format.\n", desc->name);
> > > +return AVERROR(EINVAL);
> > > +}
> > > +
> > >  return v4l2_prepare_encoder(s);
> > >  }
> > >  
> > > -- 
> > > 2.23.0
> > > 
> > 
> > ping 
> > 
> 
> ping

try to mail the people listed in MAINTAINERs or the last person working on the
file you need a review for

Thanks

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Concerning the gods, I have no means of knowing whether they exist or not
or of what sort they may be, because of the obscurity of the subject, and
the brevity of human life -- Protagoras


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2] avcodec/v4l2_m2m_enc: Check encoder pix_fmt matches pix_fmt on device

2019-12-23 Thread Andriy Gelman
On Sat, 23. Nov 06:18, Andriy Gelman wrote:
> On Tue, 12. Nov 22:46, Andriy Gelman wrote:
> > From: Andriy Gelman 
> > 
> > Fixes #8079
> > 
> > During initialization of a v4l2m2m device, the configured pix_fmt can be
> > different to the pix_fmt of the encoder (i.e. avctx->pix_fmt).
> > 
> > For example on the Odroid XU4:
> > ./ffmpeg -f lavfi -i yuvtestsrc -codec:v h264_v4l2m2m out.h264
> > 
> > will configure the v4l2 encoder to pix_fmt nv21, whereas the input
> > frames will be yuv444p.
> > 
> > This commit checks that the configured v4l2 pix_fmt on device is the
> > same as avctx->pix_fmt. If they are different the initialization fails
> > and an error is returned. Tested on RPI4 and Odroid XU4.
> > 
> > Signed-off-by: Andriy Gelman 
> > ---
> >  libavcodec/v4l2_m2m_enc.c | 15 +++
> >  1 file changed, 15 insertions(+)
> > 
> > diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
> > index 474e6bef897..c0e82afe354 100644
> > --- a/libavcodec/v4l2_m2m_enc.c
> > +++ b/libavcodec/v4l2_m2m_enc.c
> > @@ -30,6 +30,7 @@
> >  #include "libavutil/opt.h"
> >  #include "v4l2_context.h"
> >  #include "v4l2_m2m.h"
> > +#include "v4l2_fmt.h"
> >  
> >  #define MPEG_CID(x) V4L2_CID_MPEG_VIDEO_##x
> >  #define MPEG_VIDEO(x) V4L2_MPEG_VIDEO_##x
> > @@ -288,6 +289,8 @@ static av_cold int v4l2_encode_init(AVCodecContext 
> > *avctx)
> >  V4L2Context *capture, *output;
> >  V4L2m2mContext *s;
> >  V4L2m2mPriv *priv = avctx->priv_data;
> > +enum AVPixelFormat pix_fmt_output;
> > +uint32_t v4l2_fmt_output;
> >  int ret;
> >  
> >  ret = ff_v4l2_m2m_create_context(priv, );
> > @@ -316,6 +319,18 @@ static av_cold int v4l2_encode_init(AVCodecContext 
> > *avctx)
> >  }
> >  s->avctx = avctx;
> >  
> > +if (V4L2_TYPE_IS_MULTIPLANAR(output->type))
> > +v4l2_fmt_output = output->format.fmt.pix_mp.pixelformat;
> > +else
> > +v4l2_fmt_output = output->format.fmt.pix.pixelformat;
> > +
> > +pix_fmt_output = ff_v4l2_format_v4l2_to_avfmt(v4l2_fmt_output, 
> > AV_CODEC_ID_RAWVIDEO);
> > +if (pix_fmt_output != avctx->pix_fmt) {
> > +const AVPixFmtDescriptor *desc = 
> > av_pix_fmt_desc_get(pix_fmt_output);
> > +av_log(priv, AV_LOG_ERROR, "Encoder requires %s pixel format.\n", 
> > desc->name);
> > +return AVERROR(EINVAL);
> > +}
> > +
> >  return v4l2_prepare_encoder(s);
> >  }
> >  
> > -- 
> > 2.23.0
> > 
> 
> ping 
> 

ping

-- 
Andriy
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2] avcodec/v4l2_m2m_enc: Check encoder pix_fmt matches pix_fmt on device

2019-12-04 Thread Andriy Gelman
On Sat, 23. Nov 06:18, Andriy Gelman wrote:
> On Tue, 12. Nov 22:46, Andriy Gelman wrote:
> > From: Andriy Gelman 
> > 
> > Fixes #8079
> > 
> > During initialization of a v4l2m2m device, the configured pix_fmt can be
> > different to the pix_fmt of the encoder (i.e. avctx->pix_fmt).
> > 
> > For example on the Odroid XU4:
> > ./ffmpeg -f lavfi -i yuvtestsrc -codec:v h264_v4l2m2m out.h264
> > 
> > will configure the v4l2 encoder to pix_fmt nv21, whereas the input
> > frames will be yuv444p.
> > 
> > This commit checks that the configured v4l2 pix_fmt on device is the
> > same as avctx->pix_fmt. If they are different the initialization fails
> > and an error is returned. Tested on RPI4 and Odroid XU4.
> > 
> > Signed-off-by: Andriy Gelman 
> > ---
> >  libavcodec/v4l2_m2m_enc.c | 15 +++
> >  1 file changed, 15 insertions(+)
> > 
> > diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
> > index 474e6bef897..c0e82afe354 100644
> > --- a/libavcodec/v4l2_m2m_enc.c
> > +++ b/libavcodec/v4l2_m2m_enc.c
> > @@ -30,6 +30,7 @@
> >  #include "libavutil/opt.h"
> >  #include "v4l2_context.h"
> >  #include "v4l2_m2m.h"
> > +#include "v4l2_fmt.h"
> >  
> >  #define MPEG_CID(x) V4L2_CID_MPEG_VIDEO_##x
> >  #define MPEG_VIDEO(x) V4L2_MPEG_VIDEO_##x
> > @@ -288,6 +289,8 @@ static av_cold int v4l2_encode_init(AVCodecContext 
> > *avctx)
> >  V4L2Context *capture, *output;
> >  V4L2m2mContext *s;
> >  V4L2m2mPriv *priv = avctx->priv_data;
> > +enum AVPixelFormat pix_fmt_output;
> > +uint32_t v4l2_fmt_output;
> >  int ret;
> >  
> >  ret = ff_v4l2_m2m_create_context(priv, );
> > @@ -316,6 +319,18 @@ static av_cold int v4l2_encode_init(AVCodecContext 
> > *avctx)
> >  }
> >  s->avctx = avctx;
> >  
> > +if (V4L2_TYPE_IS_MULTIPLANAR(output->type))
> > +v4l2_fmt_output = output->format.fmt.pix_mp.pixelformat;
> > +else
> > +v4l2_fmt_output = output->format.fmt.pix.pixelformat;
> > +
> > +pix_fmt_output = ff_v4l2_format_v4l2_to_avfmt(v4l2_fmt_output, 
> > AV_CODEC_ID_RAWVIDEO);
> > +if (pix_fmt_output != avctx->pix_fmt) {
> > +const AVPixFmtDescriptor *desc = 
> > av_pix_fmt_desc_get(pix_fmt_output);
> > +av_log(priv, AV_LOG_ERROR, "Encoder requires %s pixel format.\n", 
> > desc->name);
> > +return AVERROR(EINVAL);
> > +}
> > +
> >  return v4l2_prepare_encoder(s);
> >  }
> >  
> > -- 
> > 2.23.0
> > 
> 
> ping 
> 

The underlying issue is that supported .pix_fmts may vary for different v4l2m2m
devices. Ideally, if .pix_fmts could be set at runtime that would solve 
problem. 

I did see that libx264 sets .pix_fmts via .init_static_data function. But I
don't think we want to call this v4l2m2m initialization each time
avcodec_register() is called.

Perhaps figuring out supported .pix_fmts via configure, and then creating a
define symbol for the supported option? 

Anyone have suggestions? 

-- 
Andriy
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2] avcodec/v4l2_m2m_enc: Check encoder pix_fmt matches pix_fmt on device

2019-11-23 Thread Andriy Gelman
On Tue, 12. Nov 22:46, Andriy Gelman wrote:
> From: Andriy Gelman 
> 
> Fixes #8079
> 
> During initialization of a v4l2m2m device, the configured pix_fmt can be
> different to the pix_fmt of the encoder (i.e. avctx->pix_fmt).
> 
> For example on the Odroid XU4:
> ./ffmpeg -f lavfi -i yuvtestsrc -codec:v h264_v4l2m2m out.h264
> 
> will configure the v4l2 encoder to pix_fmt nv21, whereas the input
> frames will be yuv444p.
> 
> This commit checks that the configured v4l2 pix_fmt on device is the
> same as avctx->pix_fmt. If they are different the initialization fails
> and an error is returned. Tested on RPI4 and Odroid XU4.
> 
> Signed-off-by: Andriy Gelman 
> ---
>  libavcodec/v4l2_m2m_enc.c | 15 +++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
> index 474e6bef897..c0e82afe354 100644
> --- a/libavcodec/v4l2_m2m_enc.c
> +++ b/libavcodec/v4l2_m2m_enc.c
> @@ -30,6 +30,7 @@
>  #include "libavutil/opt.h"
>  #include "v4l2_context.h"
>  #include "v4l2_m2m.h"
> +#include "v4l2_fmt.h"
>  
>  #define MPEG_CID(x) V4L2_CID_MPEG_VIDEO_##x
>  #define MPEG_VIDEO(x) V4L2_MPEG_VIDEO_##x
> @@ -288,6 +289,8 @@ static av_cold int v4l2_encode_init(AVCodecContext *avctx)
>  V4L2Context *capture, *output;
>  V4L2m2mContext *s;
>  V4L2m2mPriv *priv = avctx->priv_data;
> +enum AVPixelFormat pix_fmt_output;
> +uint32_t v4l2_fmt_output;
>  int ret;
>  
>  ret = ff_v4l2_m2m_create_context(priv, );
> @@ -316,6 +319,18 @@ static av_cold int v4l2_encode_init(AVCodecContext 
> *avctx)
>  }
>  s->avctx = avctx;
>  
> +if (V4L2_TYPE_IS_MULTIPLANAR(output->type))
> +v4l2_fmt_output = output->format.fmt.pix_mp.pixelformat;
> +else
> +v4l2_fmt_output = output->format.fmt.pix.pixelformat;
> +
> +pix_fmt_output = ff_v4l2_format_v4l2_to_avfmt(v4l2_fmt_output, 
> AV_CODEC_ID_RAWVIDEO);
> +if (pix_fmt_output != avctx->pix_fmt) {
> +const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt_output);
> +av_log(priv, AV_LOG_ERROR, "Encoder requires %s pixel format.\n", 
> desc->name);
> +return AVERROR(EINVAL);
> +}
> +
>  return v4l2_prepare_encoder(s);
>  }
>  
> -- 
> 2.23.0
> 

ping 

-- 
Andriy
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".