Re: [FFmpeg-devel] [PATCH] avcodec/v4l2_m2m_enc: Adapt to the new internal encode API

2020-03-07 Thread Andriy Gelman
On Sat, 07. Mar 23:13, James Almer wrote:
> On 3/7/2020 9:23 PM, Andriy Gelman wrote:
> > From: Andriy Gelman 
> > 
> > Should be squashed with:
> > http://ffmpeg.org/pipermail/ffmpeg-devel/2020-February/257735.html
> 
> Thank you! Only three remain now :)
> 
> > 
> > Signed-off-by: Andriy Gelman 
> > ---
> >  libavcodec/v4l2_m2m.c |  9 -
> >  libavcodec/v4l2_m2m.h |  6 +-
> >  libavcodec/v4l2_m2m_dec.c |  2 +-
> >  libavcodec/v4l2_m2m_enc.c | 17 +++--
> >  4 files changed, 29 insertions(+), 5 deletions(-)
> > 
> > diff --git a/libavcodec/v4l2_m2m.c b/libavcodec/v4l2_m2m.c
> > index 2d21f910bcc..1799837fb9f 100644
> > --- a/libavcodec/v4l2_m2m.c
> > +++ b/libavcodec/v4l2_m2m.c
> > @@ -329,6 +329,7 @@ static void v4l2_m2m_destroy_context(void *opaque, 
> > uint8_t *context)
> >  sem_destroy(>refsync);
> >  
> >  close(s->fd);
> > +av_frame_free(>frame);
> >  
> >  av_free(s);
> >  }
> > @@ -394,7 +395,7 @@ int ff_v4l2_m2m_codec_init(V4L2m2mPriv *priv)
> >  return v4l2_configure_contexts(s);
> >  }
> >  
> > -int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, V4L2m2mContext **s)
> > +int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, int is_encoder, 
> > V4L2m2mContext **s)
> >  {
> >  *s = av_mallocz(sizeof(V4L2m2mContext));
> >  if (!*s)
> > @@ -417,5 +418,11 @@ int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, 
> > V4L2m2mContext **s)
> >  priv->context->self_ref = priv->context_ref;
> >  priv->context->fd = -1;
> >  
> > +if (is_encoder) {
> > +priv->context->frame = av_frame_alloc();
> > +if (!priv->context->frame)
> > +return AVERROR(ENOMEM);
> > +}
> > +
> >  return 0;
> >  }
> > diff --git a/libavcodec/v4l2_m2m.h b/libavcodec/v4l2_m2m.h
> > index 456281f48c5..5d6106224dd 100644
> > --- a/libavcodec/v4l2_m2m.h
> > +++ b/libavcodec/v4l2_m2m.h
> > @@ -58,6 +58,9 @@ typedef struct V4L2m2mContext {
> >  int draining;
> >  AVPacket buf_pkt;
> >  
> > +/* Reference to a frame. Only used during encoding */
> > +AVFrame *frame;
> > +
> >  /* Reference to self; only valid while codec is active. */
> >  AVBufferRef *self_ref;
> >  
> > @@ -79,11 +82,12 @@ typedef struct V4L2m2mPriv {
> >   * Allocate a new context and references for a V4L2 M2M instance.
> >   *
> >   * @param[in] ctx The V4L2m2mPriv instantiated by the encoder/decoder.
> > + * @param[in] is_encoder Whether the context is for encoder/decoder
> >   * @param[out] ctx The V4L2m2mContext.
> >   *
> >   * @returns 0 in success, a negative error code otherwise.
> >   */
> > -int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, V4L2m2mContext **s);
> > +int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, int is_encoder, 
> > V4L2m2mContext **s);
> >  
> >  
> >  /**
> > diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
> > index d666edffe46..7c7ac2de8c5 100644
> > --- a/libavcodec/v4l2_m2m_dec.c
> > +++ b/libavcodec/v4l2_m2m_dec.c
> > @@ -181,7 +181,7 @@ static av_cold int v4l2_decode_init(AVCodecContext 
> > *avctx)
> >  V4L2m2mPriv *priv = avctx->priv_data;
> >  int ret;
> >  
> > -ret = ff_v4l2_m2m_create_context(priv, );
> > +ret = ff_v4l2_m2m_create_context(priv, 
> > !av_codec_is_decoder(avctx->codec), );

> 
> There's av_codec_is_encoder(). Also, You could pass avctx to
> ff_v4l2_m2m_create_context() instead of priv, and call
> av_codec_is_encoder() there, saving yourself the extra parameter.
> 
> Alternatively, just allocate the frame unconditionally and avoid all
> this extra code. ff_v4l2_m2m_create_context() is called once during
> init, so it's not an issue if the decoder allocates it as well.
> 

That's true, thanks.
I prefer your second option a bit more because it keeps same style in
v4l2_m2m.h.

I'll resend tomorrow in case there are more comments.

-- 
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] avcodec/v4l2_m2m_enc: Adapt to the new internal encode API

2020-03-07 Thread Andriy Gelman
On Sat, 07. Mar 23:23, James Almer wrote:
> On 3/7/2020 9:23 PM, Andriy Gelman wrote:
> > From: Andriy Gelman 
> > 
> > Should be squashed with:
> > http://ffmpeg.org/pipermail/ffmpeg-devel/2020-February/257735.html
> > 
> > Signed-off-by: Andriy Gelman 
> > ---
> >  libavcodec/v4l2_m2m.c |  9 -
> >  libavcodec/v4l2_m2m.h |  6 +-
> >  libavcodec/v4l2_m2m_dec.c |  2 +-
> >  libavcodec/v4l2_m2m_enc.c | 17 +++--
> >  4 files changed, 29 insertions(+), 5 deletions(-)
> > 
> > diff --git a/libavcodec/v4l2_m2m.c b/libavcodec/v4l2_m2m.c
> > index 2d21f910bcc..1799837fb9f 100644
> > --- a/libavcodec/v4l2_m2m.c
> > +++ b/libavcodec/v4l2_m2m.c
> > @@ -329,6 +329,7 @@ static void v4l2_m2m_destroy_context(void *opaque, 
> > uint8_t *context)
> >  sem_destroy(>refsync);
> >  
> >  close(s->fd);
> > +av_frame_free(>frame);
> >  
> >  av_free(s);
> >  }
> > @@ -394,7 +395,7 @@ int ff_v4l2_m2m_codec_init(V4L2m2mPriv *priv)
> >  return v4l2_configure_contexts(s);
> >  }
> >  
> > -int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, V4L2m2mContext **s)
> > +int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, int is_encoder, 
> > V4L2m2mContext **s)
> >  {
> >  *s = av_mallocz(sizeof(V4L2m2mContext));
> >  if (!*s)
> > @@ -417,5 +418,11 @@ int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, 
> > V4L2m2mContext **s)
> >  priv->context->self_ref = priv->context_ref;
> >  priv->context->fd = -1;
> >  
> > +if (is_encoder) {
> > +priv->context->frame = av_frame_alloc();
> > +if (!priv->context->frame)
> > +return AVERROR(ENOMEM);
> > +}
> > +
> >  return 0;
> >  }
> > diff --git a/libavcodec/v4l2_m2m.h b/libavcodec/v4l2_m2m.h
> > index 456281f48c5..5d6106224dd 100644
> > --- a/libavcodec/v4l2_m2m.h
> > +++ b/libavcodec/v4l2_m2m.h
> > @@ -58,6 +58,9 @@ typedef struct V4L2m2mContext {
> >  int draining;
> >  AVPacket buf_pkt;
> >  
> > +/* Reference to a frame. Only used during encoding */
> > +AVFrame *frame;
> > +
> >  /* Reference to self; only valid while codec is active. */
> >  AVBufferRef *self_ref;
> >  
> > @@ -79,11 +82,12 @@ typedef struct V4L2m2mPriv {
> >   * Allocate a new context and references for a V4L2 M2M instance.
> >   *
> >   * @param[in] ctx The V4L2m2mPriv instantiated by the encoder/decoder.
> > + * @param[in] is_encoder Whether the context is for encoder/decoder
> >   * @param[out] ctx The V4L2m2mContext.
> >   *
> >   * @returns 0 in success, a negative error code otherwise.
> >   */
> > -int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, V4L2m2mContext **s);
> > +int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, int is_encoder, 
> > V4L2m2mContext **s);
> >  
> >  
> >  /**
> > diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
> > index d666edffe46..7c7ac2de8c5 100644
> > --- a/libavcodec/v4l2_m2m_dec.c
> > +++ b/libavcodec/v4l2_m2m_dec.c
> > @@ -181,7 +181,7 @@ static av_cold int v4l2_decode_init(AVCodecContext 
> > *avctx)
> >  V4L2m2mPriv *priv = avctx->priv_data;
> >  int ret;
> >  
> > -ret = ff_v4l2_m2m_create_context(priv, );
> > +ret = ff_v4l2_m2m_create_context(priv, 
> > !av_codec_is_decoder(avctx->codec), );
> >  if (ret < 0)
> >  return ret;
> >  
> > diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
> > index c9f1741bfd0..22b0cbd27ac 100644
> > --- a/libavcodec/v4l2_m2m_enc.c
> > +++ b/libavcodec/v4l2_m2m_enc.c
> > @@ -24,6 +24,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include "encode.h"
> >  #include "libavcodec/avcodec.h"
> >  #include "libavutil/pixdesc.h"
> >  #include "libavutil/pixfmt.h"
> > @@ -259,11 +260,24 @@ static int v4l2_receive_packet(AVCodecContext *avctx, 
> > AVPacket *avpkt)
> >  V4L2m2mContext *s = ((V4L2m2mPriv*)avctx->priv_data)->context;
> >  V4L2Context *const capture = >capture;
> >  V4L2Context *const output = >output;
> > +AVFrame *frame = s->frame;
> >  int ret;
> >  
> >  if (s->draining)
> >  goto dequeue;
> >  
> > +ret = ff_encode_get_frame(avctx, frame);
> > +if (ret < 0 && ret != AVERROR_EOF)
> > +return ret;
> > +
> > +if (ret == AVERROR_EOF)
> > +frame = NULL;
> > +
> > +ret = v4l2_send_frame(avctx, frame);
> 
> What happens if ff_encode_get_frame() returns AVERROR(EAGAIN)? I don't
> think ff_v4l2_context_enqueue_frame() is meant to receive empty,
> non-NULL frames.
> 

I don't think that's possible because the if condition catches 
AVERROR(EAGAIN) and returns it.

> > +av_frame_unref(frame);
> > +if (ret < 0)
> > +return ret;
> > +
> >  if (!output->streamon) {
> >  ret = ff_v4l2_context_set_status(output, VIDIOC_STREAMON);
> >  if (ret) {
> > @@ -293,7 +307,7 @@ static av_cold int v4l2_encode_init(AVCodecContext 
> > *avctx)
> >  uint32_t v4l2_fmt_output;
> >  int ret;
> >  
> > -ret = ff_v4l2_m2m_create_context(priv, );
> > +ret = 

Re: [FFmpeg-devel] [PATCH 3/4] vaapi_encode_h265: Query encoding block sizes and features

2020-03-07 Thread Fu, Linjie
> From: ffmpeg-devel  On Behalf Of
> Mark Thompson
> Sent: Sunday, March 8, 2020 00:31
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH 3/4] vaapi_encode_h265: Query
> encoding block sizes and features
> 
> On 05/03/2020 05:13, Fu, Linjie wrote:
> >> -Original Message-
> >> From: ffmpeg-devel  On Behalf Of
> >> Mark Thompson
> >> Sent: Thursday, March 5, 2020 08:25
> >> To: ffmpeg-devel@ffmpeg.org
> >> Subject: [FFmpeg-devel] [PATCH 3/4] vaapi_encode_h265: Query
> encoding
> >> block sizes and features
> >>
> >> ---
> >> Requires .  That isn't upstream,
> so
> >> this will need to wait for that and then get at least a fix to the version
> >> numbering before applying.
> >
> > The query looks good to me since I'm suffering from the differences of
> default
> > parameters allowed for VDENC and VMEPAK in media-driver while adding
> support
> > for low power encoding [1] for VAAPI.
> >
> > However got several questions:
> >
> > 1. Why not include PPS parameters as well? There are some differences in
> > cu_qp_delta_enabled_flag and diff_cu_qp_delta_depth supported for
> VAEntrypointEncSliceLP.
> 
> Support for cu_qp_delta_enabled_flag is implied by the presence of non-
> CQP RC modes (maybe I should add a comment saying that explicitly?).
> 
> The possible range of diff_cu_qp_delta_depth is set by
> min_cu_qp_delta_block_size_minus3, since the variable you actually want to
> define is Log2MinCuQpDeltaSize.  (So for example that would be 1 if the
> smallest block supporting a qp_delta is 16x16 (Log2MinCuQpDeltaSize = 4),
> and then depth could be up to 2 on 64x64 CTBs or 1 on 32x32 CTBs.)

Yes you are right, this should be not related with LP,  setting the depth would
make sense. 
Log2MinCuQpDeltaSize = CtbLog2SizeY − diff_cu_qp_delta_depth;

> > 2. Would it be better to only involve the variable parameters for 
> > sps/pps... ?
> This is
> > what PR 379 [2] (unfinished) intended to do.
> 
> I'm not sure what you mean by this question - all of these are variable
> parameters in SPS/PPS.
>
> > 3. The suggested value of SAO enable flag could also be 1 in corresponding
> code in
> > media-driver, which would provide 3% BD-Rate improvement with no fps
> penalty
> > based on previous experiment with FFmpeg VAAPI.
> 
> Huh, nice.  That never worked in Gen 9, so I guess that's another difference
> which needs the query information to express.
> 
> > 4. There is separate media_libva_caps for gen11 and gen12, maybe need
> further update
> > or centralization for the code in driver. (not tested yet, will do later)
> 
> Since the documentation has not been released this needs someone from
> Intel to define what the capabilities actually are.  As I wrote in the PR 
> against
> iHD, all I have are guesses based on what I can observe working (or not).
> 

I'll sync with media-driver and try to get capabilities for each platform.
Thanks for the PRs in libva and iHD.

- Linjie
___
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] avcodec/v4l2_m2m_enc: Adapt to the new internal encode API

2020-03-07 Thread James Almer
On 3/7/2020 9:23 PM, Andriy Gelman wrote:
> From: Andriy Gelman 
> 
> Should be squashed with:
> http://ffmpeg.org/pipermail/ffmpeg-devel/2020-February/257735.html
> 
> Signed-off-by: Andriy Gelman 
> ---
>  libavcodec/v4l2_m2m.c |  9 -
>  libavcodec/v4l2_m2m.h |  6 +-
>  libavcodec/v4l2_m2m_dec.c |  2 +-
>  libavcodec/v4l2_m2m_enc.c | 17 +++--
>  4 files changed, 29 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/v4l2_m2m.c b/libavcodec/v4l2_m2m.c
> index 2d21f910bcc..1799837fb9f 100644
> --- a/libavcodec/v4l2_m2m.c
> +++ b/libavcodec/v4l2_m2m.c
> @@ -329,6 +329,7 @@ static void v4l2_m2m_destroy_context(void *opaque, 
> uint8_t *context)
>  sem_destroy(>refsync);
>  
>  close(s->fd);
> +av_frame_free(>frame);
>  
>  av_free(s);
>  }
> @@ -394,7 +395,7 @@ int ff_v4l2_m2m_codec_init(V4L2m2mPriv *priv)
>  return v4l2_configure_contexts(s);
>  }
>  
> -int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, V4L2m2mContext **s)
> +int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, int is_encoder, 
> V4L2m2mContext **s)
>  {
>  *s = av_mallocz(sizeof(V4L2m2mContext));
>  if (!*s)
> @@ -417,5 +418,11 @@ int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, 
> V4L2m2mContext **s)
>  priv->context->self_ref = priv->context_ref;
>  priv->context->fd = -1;
>  
> +if (is_encoder) {
> +priv->context->frame = av_frame_alloc();
> +if (!priv->context->frame)
> +return AVERROR(ENOMEM);
> +}
> +
>  return 0;
>  }
> diff --git a/libavcodec/v4l2_m2m.h b/libavcodec/v4l2_m2m.h
> index 456281f48c5..5d6106224dd 100644
> --- a/libavcodec/v4l2_m2m.h
> +++ b/libavcodec/v4l2_m2m.h
> @@ -58,6 +58,9 @@ typedef struct V4L2m2mContext {
>  int draining;
>  AVPacket buf_pkt;
>  
> +/* Reference to a frame. Only used during encoding */
> +AVFrame *frame;
> +
>  /* Reference to self; only valid while codec is active. */
>  AVBufferRef *self_ref;
>  
> @@ -79,11 +82,12 @@ typedef struct V4L2m2mPriv {
>   * Allocate a new context and references for a V4L2 M2M instance.
>   *
>   * @param[in] ctx The V4L2m2mPriv instantiated by the encoder/decoder.
> + * @param[in] is_encoder Whether the context is for encoder/decoder
>   * @param[out] ctx The V4L2m2mContext.
>   *
>   * @returns 0 in success, a negative error code otherwise.
>   */
> -int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, V4L2m2mContext **s);
> +int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, int is_encoder, 
> V4L2m2mContext **s);
>  
>  
>  /**
> diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
> index d666edffe46..7c7ac2de8c5 100644
> --- a/libavcodec/v4l2_m2m_dec.c
> +++ b/libavcodec/v4l2_m2m_dec.c
> @@ -181,7 +181,7 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx)
>  V4L2m2mPriv *priv = avctx->priv_data;
>  int ret;
>  
> -ret = ff_v4l2_m2m_create_context(priv, );
> +ret = ff_v4l2_m2m_create_context(priv, 
> !av_codec_is_decoder(avctx->codec), );
>  if (ret < 0)
>  return ret;
>  
> diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
> index c9f1741bfd0..22b0cbd27ac 100644
> --- a/libavcodec/v4l2_m2m_enc.c
> +++ b/libavcodec/v4l2_m2m_enc.c
> @@ -24,6 +24,7 @@
>  #include 
>  #include 
>  #include 
> +#include "encode.h"
>  #include "libavcodec/avcodec.h"
>  #include "libavutil/pixdesc.h"
>  #include "libavutil/pixfmt.h"
> @@ -259,11 +260,24 @@ static int v4l2_receive_packet(AVCodecContext *avctx, 
> AVPacket *avpkt)
>  V4L2m2mContext *s = ((V4L2m2mPriv*)avctx->priv_data)->context;
>  V4L2Context *const capture = >capture;
>  V4L2Context *const output = >output;
> +AVFrame *frame = s->frame;
>  int ret;
>  
>  if (s->draining)
>  goto dequeue;
>  
> +ret = ff_encode_get_frame(avctx, frame);
> +if (ret < 0 && ret != AVERROR_EOF)
> +return ret;
> +
> +if (ret == AVERROR_EOF)
> +frame = NULL;
> +
> +ret = v4l2_send_frame(avctx, frame);

What happens if ff_encode_get_frame() returns AVERROR(EAGAIN)? I don't
think ff_v4l2_context_enqueue_frame() is meant to receive empty,
non-NULL frames.

> +av_frame_unref(frame);
> +if (ret < 0)
> +return ret;
> +
>  if (!output->streamon) {
>  ret = ff_v4l2_context_set_status(output, VIDIOC_STREAMON);
>  if (ret) {
> @@ -293,7 +307,7 @@ static av_cold int v4l2_encode_init(AVCodecContext *avctx)
>  uint32_t v4l2_fmt_output;
>  int ret;
>  
> -ret = ff_v4l2_m2m_create_context(priv, );
> +ret = ff_v4l2_m2m_create_context(priv, 
> !av_codec_is_decoder(avctx->codec), );
>  if (ret < 0)
>  return ret;
>  
> @@ -367,7 +381,6 @@ static const AVOption options[] = {
>  .priv_data_size = sizeof(V4L2m2mPriv), \
>  .priv_class = _m2m_ ## NAME ##_enc_class, \
>  .init   = v4l2_encode_init, \
> -.send_frame = v4l2_send_frame, \
>  .receive_packet = v4l2_receive_packet, \
>   

Re: [FFmpeg-devel] [PATCH] avcodec/v4l2_m2m_enc: Adapt to the new internal encode API

2020-03-07 Thread James Almer
On 3/7/2020 9:23 PM, Andriy Gelman wrote:
> From: Andriy Gelman 
> 
> Should be squashed with:
> http://ffmpeg.org/pipermail/ffmpeg-devel/2020-February/257735.html

Thank you! Only three remain now :)

> 
> Signed-off-by: Andriy Gelman 
> ---
>  libavcodec/v4l2_m2m.c |  9 -
>  libavcodec/v4l2_m2m.h |  6 +-
>  libavcodec/v4l2_m2m_dec.c |  2 +-
>  libavcodec/v4l2_m2m_enc.c | 17 +++--
>  4 files changed, 29 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/v4l2_m2m.c b/libavcodec/v4l2_m2m.c
> index 2d21f910bcc..1799837fb9f 100644
> --- a/libavcodec/v4l2_m2m.c
> +++ b/libavcodec/v4l2_m2m.c
> @@ -329,6 +329,7 @@ static void v4l2_m2m_destroy_context(void *opaque, 
> uint8_t *context)
>  sem_destroy(>refsync);
>  
>  close(s->fd);
> +av_frame_free(>frame);
>  
>  av_free(s);
>  }
> @@ -394,7 +395,7 @@ int ff_v4l2_m2m_codec_init(V4L2m2mPriv *priv)
>  return v4l2_configure_contexts(s);
>  }
>  
> -int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, V4L2m2mContext **s)
> +int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, int is_encoder, 
> V4L2m2mContext **s)
>  {
>  *s = av_mallocz(sizeof(V4L2m2mContext));
>  if (!*s)
> @@ -417,5 +418,11 @@ int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, 
> V4L2m2mContext **s)
>  priv->context->self_ref = priv->context_ref;
>  priv->context->fd = -1;
>  
> +if (is_encoder) {
> +priv->context->frame = av_frame_alloc();
> +if (!priv->context->frame)
> +return AVERROR(ENOMEM);
> +}
> +
>  return 0;
>  }
> diff --git a/libavcodec/v4l2_m2m.h b/libavcodec/v4l2_m2m.h
> index 456281f48c5..5d6106224dd 100644
> --- a/libavcodec/v4l2_m2m.h
> +++ b/libavcodec/v4l2_m2m.h
> @@ -58,6 +58,9 @@ typedef struct V4L2m2mContext {
>  int draining;
>  AVPacket buf_pkt;
>  
> +/* Reference to a frame. Only used during encoding */
> +AVFrame *frame;
> +
>  /* Reference to self; only valid while codec is active. */
>  AVBufferRef *self_ref;
>  
> @@ -79,11 +82,12 @@ typedef struct V4L2m2mPriv {
>   * Allocate a new context and references for a V4L2 M2M instance.
>   *
>   * @param[in] ctx The V4L2m2mPriv instantiated by the encoder/decoder.
> + * @param[in] is_encoder Whether the context is for encoder/decoder
>   * @param[out] ctx The V4L2m2mContext.
>   *
>   * @returns 0 in success, a negative error code otherwise.
>   */
> -int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, V4L2m2mContext **s);
> +int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, int is_encoder, 
> V4L2m2mContext **s);
>  
>  
>  /**
> diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
> index d666edffe46..7c7ac2de8c5 100644
> --- a/libavcodec/v4l2_m2m_dec.c
> +++ b/libavcodec/v4l2_m2m_dec.c
> @@ -181,7 +181,7 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx)
>  V4L2m2mPriv *priv = avctx->priv_data;
>  int ret;
>  
> -ret = ff_v4l2_m2m_create_context(priv, );
> +ret = ff_v4l2_m2m_create_context(priv, 
> !av_codec_is_decoder(avctx->codec), );

There's av_codec_is_encoder(). Also, You could pass avctx to
ff_v4l2_m2m_create_context() instead of priv, and call
av_codec_is_encoder() there, saving yourself the extra parameter.

Alternatively, just allocate the frame unconditionally and avoid all
this extra code. ff_v4l2_m2m_create_context() is called once during
init, so it's not an issue if the decoder allocates it as well.

>  if (ret < 0)
>  return ret;
>  
> diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
> index c9f1741bfd0..22b0cbd27ac 100644
> --- a/libavcodec/v4l2_m2m_enc.c
> +++ b/libavcodec/v4l2_m2m_enc.c
> @@ -24,6 +24,7 @@
>  #include 
>  #include 
>  #include 
> +#include "encode.h"
>  #include "libavcodec/avcodec.h"
>  #include "libavutil/pixdesc.h"
>  #include "libavutil/pixfmt.h"
> @@ -259,11 +260,24 @@ static int v4l2_receive_packet(AVCodecContext *avctx, 
> AVPacket *avpkt)
>  V4L2m2mContext *s = ((V4L2m2mPriv*)avctx->priv_data)->context;
>  V4L2Context *const capture = >capture;
>  V4L2Context *const output = >output;
> +AVFrame *frame = s->frame;
>  int ret;
>  
>  if (s->draining)
>  goto dequeue;
>  
> +ret = ff_encode_get_frame(avctx, frame);
> +if (ret < 0 && ret != AVERROR_EOF)
> +return ret;
> +
> +if (ret == AVERROR_EOF)
> +frame = NULL;
> +
> +ret = v4l2_send_frame(avctx, frame);
> +av_frame_unref(frame);
> +if (ret < 0)
> +return ret;
> +
>  if (!output->streamon) {
>  ret = ff_v4l2_context_set_status(output, VIDIOC_STREAMON);
>  if (ret) {
> @@ -293,7 +307,7 @@ static av_cold int v4l2_encode_init(AVCodecContext *avctx)
>  uint32_t v4l2_fmt_output;
>  int ret;
>  
> -ret = ff_v4l2_m2m_create_context(priv, );
> +ret = ff_v4l2_m2m_create_context(priv, 
> !av_codec_is_decoder(avctx->codec), );
>  if (ret < 0)
>  return ret;
>  
> @@ -367,7 +381,6 @@ static const AVOption 

[FFmpeg-devel] [PATCH] avcodec/v4l2_m2m_enc: Adapt to the new internal encode API

2020-03-07 Thread Andriy Gelman
From: Andriy Gelman 

Should be squashed with:
http://ffmpeg.org/pipermail/ffmpeg-devel/2020-February/257735.html

Signed-off-by: Andriy Gelman 
---
 libavcodec/v4l2_m2m.c |  9 -
 libavcodec/v4l2_m2m.h |  6 +-
 libavcodec/v4l2_m2m_dec.c |  2 +-
 libavcodec/v4l2_m2m_enc.c | 17 +++--
 4 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/libavcodec/v4l2_m2m.c b/libavcodec/v4l2_m2m.c
index 2d21f910bcc..1799837fb9f 100644
--- a/libavcodec/v4l2_m2m.c
+++ b/libavcodec/v4l2_m2m.c
@@ -329,6 +329,7 @@ static void v4l2_m2m_destroy_context(void *opaque, uint8_t 
*context)
 sem_destroy(>refsync);
 
 close(s->fd);
+av_frame_free(>frame);
 
 av_free(s);
 }
@@ -394,7 +395,7 @@ int ff_v4l2_m2m_codec_init(V4L2m2mPriv *priv)
 return v4l2_configure_contexts(s);
 }
 
-int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, V4L2m2mContext **s)
+int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, int is_encoder, 
V4L2m2mContext **s)
 {
 *s = av_mallocz(sizeof(V4L2m2mContext));
 if (!*s)
@@ -417,5 +418,11 @@ int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, 
V4L2m2mContext **s)
 priv->context->self_ref = priv->context_ref;
 priv->context->fd = -1;
 
+if (is_encoder) {
+priv->context->frame = av_frame_alloc();
+if (!priv->context->frame)
+return AVERROR(ENOMEM);
+}
+
 return 0;
 }
diff --git a/libavcodec/v4l2_m2m.h b/libavcodec/v4l2_m2m.h
index 456281f48c5..5d6106224dd 100644
--- a/libavcodec/v4l2_m2m.h
+++ b/libavcodec/v4l2_m2m.h
@@ -58,6 +58,9 @@ typedef struct V4L2m2mContext {
 int draining;
 AVPacket buf_pkt;
 
+/* Reference to a frame. Only used during encoding */
+AVFrame *frame;
+
 /* Reference to self; only valid while codec is active. */
 AVBufferRef *self_ref;
 
@@ -79,11 +82,12 @@ typedef struct V4L2m2mPriv {
  * Allocate a new context and references for a V4L2 M2M instance.
  *
  * @param[in] ctx The V4L2m2mPriv instantiated by the encoder/decoder.
+ * @param[in] is_encoder Whether the context is for encoder/decoder
  * @param[out] ctx The V4L2m2mContext.
  *
  * @returns 0 in success, a negative error code otherwise.
  */
-int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, V4L2m2mContext **s);
+int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, int is_encoder, 
V4L2m2mContext **s);
 
 
 /**
diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
index d666edffe46..7c7ac2de8c5 100644
--- a/libavcodec/v4l2_m2m_dec.c
+++ b/libavcodec/v4l2_m2m_dec.c
@@ -181,7 +181,7 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx)
 V4L2m2mPriv *priv = avctx->priv_data;
 int ret;
 
-ret = ff_v4l2_m2m_create_context(priv, );
+ret = ff_v4l2_m2m_create_context(priv, !av_codec_is_decoder(avctx->codec), 
);
 if (ret < 0)
 return ret;
 
diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
index c9f1741bfd0..22b0cbd27ac 100644
--- a/libavcodec/v4l2_m2m_enc.c
+++ b/libavcodec/v4l2_m2m_enc.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include "encode.h"
 #include "libavcodec/avcodec.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/pixfmt.h"
@@ -259,11 +260,24 @@ static int v4l2_receive_packet(AVCodecContext *avctx, 
AVPacket *avpkt)
 V4L2m2mContext *s = ((V4L2m2mPriv*)avctx->priv_data)->context;
 V4L2Context *const capture = >capture;
 V4L2Context *const output = >output;
+AVFrame *frame = s->frame;
 int ret;
 
 if (s->draining)
 goto dequeue;
 
+ret = ff_encode_get_frame(avctx, frame);
+if (ret < 0 && ret != AVERROR_EOF)
+return ret;
+
+if (ret == AVERROR_EOF)
+frame = NULL;
+
+ret = v4l2_send_frame(avctx, frame);
+av_frame_unref(frame);
+if (ret < 0)
+return ret;
+
 if (!output->streamon) {
 ret = ff_v4l2_context_set_status(output, VIDIOC_STREAMON);
 if (ret) {
@@ -293,7 +307,7 @@ static av_cold int v4l2_encode_init(AVCodecContext *avctx)
 uint32_t v4l2_fmt_output;
 int ret;
 
-ret = ff_v4l2_m2m_create_context(priv, );
+ret = ff_v4l2_m2m_create_context(priv, !av_codec_is_decoder(avctx->codec), 
);
 if (ret < 0)
 return ret;
 
@@ -367,7 +381,6 @@ static const AVOption options[] = {
 .priv_data_size = sizeof(V4L2m2mPriv), \
 .priv_class = _m2m_ ## NAME ##_enc_class, \
 .init   = v4l2_encode_init, \
-.send_frame = v4l2_send_frame, \
 .receive_packet = v4l2_receive_packet, \
 .close  = v4l2_encode_close, \
 .capabilities   = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY, \
-- 
2.25.0

___
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 7/7] avformat/audiointerleave: use a fixed frame duration for non-audio packets

2020-03-07 Thread Michael Niedermayer
On Sat, Mar 07, 2020 at 10:21:33AM +0100, Marton Balint wrote:
> 
> 
> On Sat, 7 Mar 2020, Michael Niedermayer wrote:
> 
> >On Thu, Mar 05, 2020 at 10:56:28PM +0100, Marton Balint wrote:
> >>The packet durations might not be set properly which can cause the MXF muxer
> >>to write more than one packet of a stream to an edit unit messing up the
> >>constant byte per element index...
> >>
> >>Also use nb_samples directly to calculate dts of audio packets because 
> >>adding
> >>packet durations might not be precise.
> >>
> >>Signed-off-by: Marton Balint 
> >>---
> >> libavformat/audiointerleave.c | 12 +---
> >> libavformat/audiointerleave.h |  3 ++-
> >> libavformat/gxfenc.c  |  2 +-
> >> libavformat/mxfenc.c  |  2 +-
> >> 4 files changed, 13 insertions(+), 6 deletions(-)
> >
> >This doesnt feel correct
> >
> >Either case
> >A. The durations are correct but not what the muxer wants
> >then changing them at the muxer level could lead to AV sync issues and
> >wrong timestamps, something which the application should have dealt with
> >by frame duplication / frame drops or other
> >
> >B. The durations are just wrong
> >then changing them at the muxer level will leave the calling application
> >with incorrect values potentially causing all kinds of problems.
> >
> >Maybe iam missing something but isnt this just fixing the issue when the
> >durtations are wrong in a very special way ?
> 
> It is the same "special" way that is used for audio. We ignore incoming DTS
> and duration, and make up our own.
> 
> Yes, it can cause A-V sync issues is somebody wants to push VFR video or
> sparse audio data, that is not allowed in the MXF muxer.
> 
> Maybe we should hard reject streams if there is a difference between the
> calculated and the incoming DTS? I have a feeling that such measure would
> broke a lot of existing command lines...

iam unsure if this concept of timestamp changing in the muxer is a good idea
but if its done, there probably should be a warning if it happens and maybe
more then that if the difference becomes larger than what is "harmless"

but maybe iam missing something

Thanks


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

During times of universal deceit, telling the truth becomes a
revolutionary act. -- George Orwell


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".

[FFmpeg-devel] [PATCH 2/2] avcodec/cbs_h2645: Avoid more cases of 0 size slices

2020-03-07 Thread Michael Niedermayer
Fixes: Assertion failure
Fixes: 
19629/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-5676822528524288

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/cbs_h2645.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index c8347ba5fa..7427eefa30 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -870,7 +870,8 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext 
*ctx,
"from slice data.\n", z);
 len -= z;
 }
-
+if (len <= pos / 8)
+return AVERROR_INVALIDDATA;
 slice->data_size = len - pos / 8;
 slice->data_ref  = av_buffer_ref(unit->data_ref);
 if (!slice->data_ref)
@@ -1052,7 +1053,8 @@ static int cbs_h265_read_nal_unit(CodedBitstreamContext 
*ctx,
"from slice data.\n", z);
 len -= z;
 }
-
+if (len <= pos / 8)
+return AVERROR_INVALIDDATA;
 slice->data_size = len - pos / 8;
 slice->data_ref  = av_buffer_ref(unit->data_ref);
 if (!slice->data_ref)
-- 
2.17.1

___
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".

[FFmpeg-devel] [PATCH 1/2] avcodec/cbs_jpeg: Check length for SOS

2020-03-07 Thread Michael Niedermayer
Fixes: out of array access
Fixes: 
19734/clusterfuzz-testcase-minimized-ffmpeg_BSF_TRACE_HEADERS_fuzzer-5673507031875584
Fixes: 
19353/clusterfuzz-testcase-minimized-ffmpeg_BSF_TRACE_HEADERS_fuzzer-5703944462663680

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/cbs_jpeg.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/cbs_jpeg.c b/libavcodec/cbs_jpeg.c
index 6bbce5f89b..89512a26bb 100644
--- a/libavcodec/cbs_jpeg.c
+++ b/libavcodec/cbs_jpeg.c
@@ -197,6 +197,9 @@ static int cbs_jpeg_split_fragment(CodedBitstreamContext 
*ctx,
 if (marker == JPEG_MARKER_SOS) {
 length = AV_RB16(frag->data + start);
 
+if (length > end - start)
+return AVERROR_INVALIDDATA;
+
 data_ref = NULL;
 data = av_malloc(end - start +
  AV_INPUT_BUFFER_PADDING_SIZE);
-- 
2.17.1

___
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] avformat/avidec: recognize H265 fourcc as hevc

2020-03-07 Thread Michael Niedermayer
On Sat, Mar 07, 2020 at 08:23:34AM +0100, Paul B Mahol wrote:
> On 3/6/20, Michael Niedermayer  wrote:
> > On Fri, Mar 06, 2020 at 09:18:50PM +0100, Paul B Mahol wrote:
> >> Fixes decoding of came2_2020-01-13__20-38-58_21-00-00__Chn2.avi
> >>
> >> Signed-off-by: Paul B Mahol 
> >> ---
> >>  libavformat/avidec.c | 2 ++
> >>  libavformat/riff.c   | 1 +
> >>  2 files changed, 3 insertions(+)
> >>
> >> diff --git a/libavformat/avidec.c b/libavformat/avidec.c
> >> index 412e4a8479..7fdc0fbf8b 100644
> >> --- a/libavformat/avidec.c
> >> +++ b/libavformat/avidec.c
> >> @@ -832,6 +832,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
> >>  st->need_parsing = AVSTREAM_PARSE_FULL;
> >>  if (st->codecpar->codec_id == AV_CODEC_ID_RV40)
> >>  st->need_parsing = AVSTREAM_PARSE_NONE;
> >> +if (st->codecpar->codec_id == AV_CODEC_ID_HEVC)
> >> +st->need_parsing = AVSTREAM_PARSE_FULL;
> >
> > why does this not check for the codec_tag ?
> > the addition of a new tag in the table below makes this patch look like it
> > possibly affects only that tag
> 
> Are you sure about this?
> Do you have other file(s) and can prove its not needed?

i think you misunderstood me
i dont know at all, i was just asking if you know because the
patch looked like its added for the new tag

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

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates


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 1/2] fftools/ffmpeg_opt: warn about overwritten parsed options

2020-03-07 Thread Marton Balint



On Sat, 29 Feb 2020, Marton Balint wrote:


Signed-off-by: Marton Balint 
---
fftools/ffmpeg_opt.c | 70 +---
1 file changed, 67 insertions(+), 3 deletions(-)


Ping, will apply soon.

Thanks,
Marton



diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 12d44886ee..3d6fafe073 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -44,16 +44,80 @@

#define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass"

+#define SPECIFIER_OPT_FMT_str  "%s"
+#define SPECIFIER_OPT_FMT_i"%i"
+#define SPECIFIER_OPT_FMT_i64  "%"PRId64"d"
+#define SPECIFIER_OPT_FMT_ui64 "%"PRIu64"d"
+#define SPECIFIER_OPT_FMT_f"%f"
+#define SPECIFIER_OPT_FMT_dbl  "%lf"
+
+static const char *opt_name_codec_names[]   = {"c", "codec", "acodec", "vcodec", 
"scodec", "dcodec", NULL};
+static const char *opt_name_audio_channels[]= {"ac", NULL};
+static const char *opt_name_audio_sample_rate[] = {"ar", NULL};
+static const char *opt_name_frame_rates[]   = {"r", NULL};
+static const char *opt_name_frame_sizes[]   = {"s", NULL};
+static const char *opt_name_frame_pix_fmts[]= {"pix_fmt", NULL};
+static const char *opt_name_ts_scale[]  = {"itsscale", NULL};
+static const char *opt_name_hwaccels[]  = {"hwaccel", NULL};
+static const char *opt_name_hwaccel_devices[]   = {"hwaccel_device", 
NULL};
+static const char *opt_name_hwaccel_output_formats[]= 
{"hwaccel_output_format", NULL};
+static const char *opt_name_autorotate[]= {"autorotate", NULL};
+static const char *opt_name_max_frames[]= {"frames", "aframes", 
"vframes", "dframes", NULL};
+static const char *opt_name_bitstream_filters[] = {"bsf", "absf", 
"vbsf", NULL};
+static const char *opt_name_codec_tags[]= {"tag", "atag", "vtag", 
"stag", NULL};
+static const char *opt_name_sample_fmts[]   = {"sample_fmt", NULL};
+static const char *opt_name_qscale[]= {"q", "qscale", 
NULL};
+static const char *opt_name_forced_key_frames[] = 
{"forced_key_frames", NULL};
+static const char *opt_name_force_fps[] = {"force_fps", NULL};
+static const char *opt_name_frame_aspect_ratios[]   = {"aspect", NULL};
+static const char *opt_name_rc_overrides[]  = {"rc_override", 
NULL};
+static const char *opt_name_intra_matrices[]= {"intra_matrix", 
NULL};
+static const char *opt_name_inter_matrices[]= {"inter_matrix", 
NULL};
+static const char *opt_name_chroma_intra_matrices[] = 
{"chroma_intra_matrix", NULL};
+static const char *opt_name_top_field_first[]   = {"top", NULL};
+static const char *opt_name_presets[]   = {"pre", "apre", "vpre", 
"spre", NULL};
+static const char *opt_name_copy_initial_nonkeyframes[] = {"copyinkfr", NULL};
+static const char *opt_name_copy_prior_start[]  = {"copypriorss", 
NULL};
+static const char *opt_name_filters[]   = {"filter", "af", 
"vf", NULL};
+static const char *opt_name_filter_scripts[]= {"filter_script", 
NULL};
+static const char *opt_name_reinit_filters[]= {"reinit_filter", 
NULL};
+static const char *opt_name_fix_sub_duration[]  = {"fix_sub_duration", 
NULL};
+static const char *opt_name_canvas_sizes[]  = {"canvas_size", 
NULL};
+static const char *opt_name_pass[]  = {"pass", NULL};
+static const char *opt_name_passlogfiles[]  = {"passlogfile", 
NULL};
+static const char *opt_name_max_muxing_queue_size[] = 
{"max_muxing_queue_size", NULL};
+static const char *opt_name_guess_layout_max[]  = {"guess_layout_max", 
NULL};
+static const char *opt_name_apad[]  = {"apad", NULL};
+static const char *opt_name_discard[]   = {"discard", NULL};
+static const char *opt_name_disposition[]   = {"disposition", 
NULL};
+static const char *opt_name_time_bases[]= {"time_base", NULL};
+static const char *opt_name_enc_time_bases[]= {"enc_time_base", 
NULL};
+
+#define WARN_MULTIPLE_OPT_USAGE(name, type, so, st)\
+{\
+char namestr[128] = "";\
+const char *spec = so->specifier && so->specifier[0] ? so->specifier : "";\
+for (i = 0; opt_name_##name[i]; i++)\
+av_strlcatf(namestr, sizeof(namestr), "-%s%s", opt_name_##name[i], opt_name_##name[i+1] ? 
(opt_name_##name[i+2] ? ", " : " or ") : "");\
+av_log(NULL, AV_LOG_WARNING, "Multiple %s options specified for stream %d, only the last 
option '-%s%s%s "SPECIFIER_OPT_FMT_##type"' will be used.\n",\
+   namestr, st->index, opt_name_##name[0], spec[0] ? ":" : "", spec, 
so->u.type);\
+}
+
#define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\
{\
-int i, ret;\
+int i, ret, matches = 0;\
+SpecifierOpt *so;\
for (i = 0; i < o->nb_ ## name; i++) {\
char 

Re: [FFmpeg-devel] [PATCH v2 3/4] changelog: add adpcm_ima_alp decoder and alp demuxer

2020-03-07 Thread Moritz Barsnick
On Sat, Mar 07, 2020 at 14:15:55 +, Zane van Iperen wrote:
>  - cas video filter
> -
> +- High Voltage Software ADPCM decoder
> +- LEGO Racers ALP (.tun & .pcm) demuxer

Changelog (and doc, patch 4/4) should be added with the respective
functional patch.

Oh, and don't remove that empty line from the Changelog please. ;-)

Moritz
___
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] ffmpeg: default hwaccel_output_format to cuda when hwaccel is cuvid

2020-03-07 Thread Timo Rothenpieler

On 07.03.2020 16:20, James Almer wrote:

On 3/7/2020 9:27 AM, Timo Rothenpieler wrote:

This ensures old commandlines using -hwaccel cuvid don't break due to
the recent removal of the the cuvid-specific hwaccel bringup.
---
  fftools/ffmpeg_opt.c | 31 +++
  1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 1b721c4954..043919faeb 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -817,6 +817,25 @@ static void add_input_streams(OptionsContext *o, 
AVFormatContext *ic)
  MATCH_PER_STREAM_OPT(top_field_first, i, ist->top_field_first, 
ic, st);
  
  MATCH_PER_STREAM_OPT(hwaccels, str, hwaccel, ic, st);

+MATCH_PER_STREAM_OPT(hwaccel_output_formats, str,
+ hwaccel_output_format, ic, st);
+
+if (!hwaccel_output_format && hwaccel && !strcmp(hwaccel, 
"cuvid")) {
+av_log(NULL, AV_LOG_WARNING,
+"WARNING: defaulting hwaccel_output_format to cuda for 
compatibility "
+"with old commandlines. This behaviour is DEPRECATED and will 
be removed "
+"in the future. Please explicitly set \"-hwaccel_output_format 
cuda\".\n");


So deprecating only the forced output format and leaving the alias alone?

LGTM either way.


Yes, if we want to deprecate the entire alias, that should be another 
patch anyway, so leaving it alone for now.


will apply very soon
___
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] lavc/vaapi_encode_h265: fix conf_win_xxx_offset for 4:2:2/4:4:4 encoding

2020-03-07 Thread Mark Thompson
On 05/03/2020 07:41, Linjie Fu wrote:
> Based on Table 6-1, set SubWidth and SubHeightC depending on chroma format.
> 
> Based on D-28 and D-29, set the correct cropped width/height.
> 
> croppedWidth  = pic_width_in_luma_samples −
> SubWidthC * ( conf_win_right_offset + conf_win_left_offset );
> 
> croppedHeight = pic_height_in_luma_samples −
> SubHeightC * ( conf_win_bottom_offset + conf_win_top_offset );
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/vaapi_encode_h265.c | 9 +++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
> index 12f0e6f..db1bf24 100644
> --- a/libavcodec/vaapi_encode_h265.c
> +++ b/libavcodec/vaapi_encode_h265.c
> @@ -268,6 +268,7 @@ static int 
> vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
>  VAEncPictureParameterBufferHEVC  *vpic = ctx->codec_picture_params;
>  const AVPixFmtDescriptor *desc;
>  int chroma_format, bit_depth;
> +int SubWidthC, SubHeightC;
>  int i;
>  
>  memset(vps, 0, sizeof(*vps));
> @@ -405,15 +406,19 @@ static int 
> vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
>  sps->pic_width_in_luma_samples  = ctx->surface_width;
>  sps->pic_height_in_luma_samples = ctx->surface_height;
>  
> +// Table 6-1
> +SubWidthC  = chroma_format == 1 || chroma_format == 2 ? 2 : 1;
> +SubHeightC = chroma_format == 1 ? 2 : 1;

You don't need to reverse chroma format into these value - desc->log2_chroma_* 
as used above to calculate it above is still available.

> +
>  if (avctx->width  != ctx->surface_width ||
>  avctx->height != ctx->surface_height) {
>  sps->conformance_window_flag = 1;
>  sps->conf_win_left_offset   = 0;
>  sps->conf_win_right_offset  =
> -(ctx->surface_width - avctx->width) / 2;
> +(ctx->surface_width - avctx->width) / SubWidthC;

(...width) >> desc->log2_chroma_w

>  sps->conf_win_top_offset= 0;
>  sps->conf_win_bottom_offset =
> -(ctx->surface_height - avctx->height) / 2;
> +(ctx->surface_height - avctx->height) / SubHeightC;

(...height) >> desc->log2_chroma_h

>  } else {
>  sps->conformance_window_flag = 0;
>  }
> 

Thanks,

- Mark
___
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 3/4] vaapi_encode_h265: Query encoding block sizes and features

2020-03-07 Thread Mark Thompson
On 05/03/2020 05:13, Fu, Linjie wrote:
>> -Original Message-
>> From: ffmpeg-devel  On Behalf Of
>> Mark Thompson
>> Sent: Thursday, March 5, 2020 08:25
>> To: ffmpeg-devel@ffmpeg.org
>> Subject: [FFmpeg-devel] [PATCH 3/4] vaapi_encode_h265: Query encoding
>> block sizes and features
>>
>> ---
>> Requires .  That isn't upstream, so
>> this will need to wait for that and then get at least a fix to the version
>> numbering before applying.
> 
> The query looks good to me since I'm suffering from the differences of default
> parameters allowed for VDENC and VMEPAK in media-driver while adding support
> for low power encoding [1] for VAAPI. 
> 
> However got several questions:
> 
> 1. Why not include PPS parameters as well? There are some differences in
> cu_qp_delta_enabled_flag and diff_cu_qp_delta_depth supported for 
> VAEntrypointEncSliceLP.

Support for cu_qp_delta_enabled_flag is implied by the presence of non-CQP RC 
modes (maybe I should add a comment saying that explicitly?).

The possible range of diff_cu_qp_delta_depth is set by 
min_cu_qp_delta_block_size_minus3, since the variable you actually want to 
define is Log2MinCuQpDeltaSize.  (So for example that would be 1 if the 
smallest block supporting a qp_delta is 16x16 (Log2MinCuQpDeltaSize = 4), and 
then depth could be up to 2 on 64x64 CTBs or 1 on 32x32 CTBs.)

> 2. Would it be better to only involve the variable parameters for sps/pps... 
> ? This is 
> what PR 379 [2] (unfinished) intended to do.

I'm not sure what you mean by this question - all of these are variable 
parameters in SPS/PPS.

> 3. The suggested value of SAO enable flag could also be 1 in corresponding 
> code in
> media-driver, which would provide 3% BD-Rate improvement with no fps penalty
> based on previous experiment with FFmpeg VAAPI.

Huh, nice.  That never worked in Gen 9, so I guess that's another difference 
which needs the query information to express.

> 4. There is separate media_libva_caps for gen11 and gen12, maybe need further 
> update
> or centralization for the code in driver. (not tested yet, will do later)

Since the documentation has not been released this needs someone from Intel to 
define what the capabilities actually are.  As I wrote in the PR against iHD, 
all I have are guesses based on what I can observe working (or not).

- Mark
___
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 4/4] vaapi_encode_h265: Enable 4:2:2 support

2020-03-07 Thread Mark Thompson
On 05/03/2020 02:49, Fu, Linjie wrote:
> 2. recon surface of Y210 or 444 (AYUV and Y410 in media-driver) depends on 
> the surface hint [3] in
> libva and corresponding code in media-driver to resize the recon surface 
> which is not upstreamed
> yet.

What is the reasoning for forcing the user to pass new extra attributes with 
this rather than handling it transparently so that it works like all other 
encoders?

In some places in Mesa surfaces are reallocated with different properties when 
they are used for a purpose they don't currently support, which avoids weird 
constraints being exported to the user (e.g. see 
).
  Since reconstructed picture surfaces are pretty unlikely to be used for 
anything else (just being copied out for debugging maybe?), it seems like an 
answer like that would be simpler in this case too.  (Though perhaps I'm 
missing something weird about the Intel hardware which makes this case uglier.)

- Mark
___
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".

[FFmpeg-devel] [PATCH] configure: Do not abort when cross-compiling to the native CPU

2020-03-07 Thread David Michael
Using a compiler with a different host triplet is considered
cross-compiling, even when it is for the same architecture as the
build system.  With such a cross-compiler, it is still valid to
optimize builds with --cpu=host.  Drop the condition that aborts in
this case, since a cross-compiler for an incompatible architecture
will fail with -mtune=native anyway.

Signed-off-by: David Michael 
---

Hi,

I am building software in a ChromeOS-style environment where the native
build system creates a cross-compiler with a different vendor string for
each supported architecture, and cross-compiled packages are installed
into their own root directory.  The build system's architecture is not
handled any differently, so packages compatible with the native
architecture are still technically being cross-compiled.

When I changed settings to tune for the native CPU so I can produce an
installation optimized to run on the build system hardware, FFmpeg fails
from this seemingly redundant test.  Can it just be dropped?

Thanks.

David

 configure | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/configure b/configure
index 06e3a7b2a8..69ffdeb3ed 100755
--- a/configure
+++ b/configure
@@ -4785,9 +4785,6 @@ if test -n "$sysroot"; then
 fi
 
 if test "$cpu" = host; then
-enabled cross_compile &&
-die "--cpu=host makes no sense when cross-compiling."
-
 case "$cc_type" in
 gcc|llvm_gcc)
 check_native(){
-- 
2.21.1

___
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".

[FFmpeg-devel] [PATCH] libavformat/lrcdec: Fix count of timestamp

2020-03-07 Thread Zhao, Gang
Current function count_ts will count invalid timestamp formats like
[00:00:00] [00-00-00] or [00:00.00][[[00:00.00]]] as valid timestamp.
This could cause some subtitles would be incorrectly counted as
timestamp. Fix it by using function read_ts to check valid timestamp
and get the offset.

Fixes trac #7255.

Signed-off-by: Zhao, Gang 
---
 libavformat/lrcdec.c | 38 +-
 1 file changed, 13 insertions(+), 25 deletions(-)

diff --git libavformat/lrcdec.c libavformat/lrcdec.c
index a9a117691a..3b206cf079 100644
--- libavformat/lrcdec.c
+++ libavformat/lrcdec.c
@@ -49,31 +49,6 @@ static int64_t find_header(const char *p)
 }
 }
 
-static int64_t count_ts(const char *p)
-{
-int64_t offset = 0;
-int in_brackets = 0;
-
-for(;;) {
-if(p[offset] == ' ' || p[offset] == '\t') {
-offset++;
-} else if(p[offset] == '[') {
-offset++;
-in_brackets++;
-} else if (p[offset] == ']' && in_brackets) {
-offset++;
-in_brackets--;
-} else if(in_brackets &&
- (p[offset] == ':' || p[offset] == '.' || p[offset] == '-' ||
- (p[offset] >= '0' && p[offset] <= '9'))) {
-offset++;
-} else {
-break;
-}
-}
-return offset;
-}
-
 static int64_t read_ts(const char *p, int64_t *start)
 {
 int64_t offset = 0;
@@ -99,6 +74,19 @@ static int64_t read_ts(const char *p, int64_t *start)
 return offset;
 }
 
+static int64_t count_ts(const char *p)
+{
+int64_t total_offset = 0;
+int64_t offset, start;
+
+while ((offset = read_ts(p, )) != 0) {
+total_offset += offset;
+p += offset;
+}
+
+return total_offset;
+}
+
 static int64_t read_line(AVBPrint *buf, AVIOContext *pb)
 {
 int64_t pos = avio_tell(pb);
-- 
2.17.1

___
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] ffmpeg: default hwaccel_output_format to cuda when hwaccel is cuvid

2020-03-07 Thread James Almer
On 3/7/2020 9:27 AM, Timo Rothenpieler wrote:
> This ensures old commandlines using -hwaccel cuvid don't break due to
> the recent removal of the the cuvid-specific hwaccel bringup.
> ---
>  fftools/ffmpeg_opt.c | 31 +++
>  1 file changed, 19 insertions(+), 12 deletions(-)
> 
> diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
> index 1b721c4954..043919faeb 100644
> --- a/fftools/ffmpeg_opt.c
> +++ b/fftools/ffmpeg_opt.c
> @@ -817,6 +817,25 @@ static void add_input_streams(OptionsContext *o, 
> AVFormatContext *ic)
>  MATCH_PER_STREAM_OPT(top_field_first, i, ist->top_field_first, 
> ic, st);
>  
>  MATCH_PER_STREAM_OPT(hwaccels, str, hwaccel, ic, st);
> +MATCH_PER_STREAM_OPT(hwaccel_output_formats, str,
> + hwaccel_output_format, ic, st);
> +
> +if (!hwaccel_output_format && hwaccel && !strcmp(hwaccel, 
> "cuvid")) {
> +av_log(NULL, AV_LOG_WARNING,
> +"WARNING: defaulting hwaccel_output_format to cuda for 
> compatibility "
> +"with old commandlines. This behaviour is DEPRECATED and 
> will be removed "
> +"in the future. Please explicitly set 
> \"-hwaccel_output_format cuda\".\n");

So deprecating only the forced output format and leaving the alias alone?

LGTM either way.

> +ist->hwaccel_output_format = AV_PIX_FMT_CUDA;
> +} else if (hwaccel_output_format) {
> +ist->hwaccel_output_format = 
> av_get_pix_fmt(hwaccel_output_format);
> +if (ist->hwaccel_output_format == AV_PIX_FMT_NONE) {
> +av_log(NULL, AV_LOG_FATAL, "Unrecognised hwaccel output "
> +   "format: %s", hwaccel_output_format);
> +}
> +} else {
> +ist->hwaccel_output_format = AV_PIX_FMT_NONE;
> +}
> +
>  if (hwaccel) {
>  // The NVDEC hwaccels use a CUDA device, so remap the name 
> here.
>  if (!strcmp(hwaccel, "nvdec") || !strcmp(hwaccel, "cuvid"))
> @@ -868,18 +887,6 @@ static void add_input_streams(OptionsContext *o, 
> AVFormatContext *ic)
>  exit_program(1);
>  }
>  
> -MATCH_PER_STREAM_OPT(hwaccel_output_formats, str,
> - hwaccel_output_format, ic, st);
> -if (hwaccel_output_format) {
> -ist->hwaccel_output_format = 
> av_get_pix_fmt(hwaccel_output_format);
> -if (ist->hwaccel_output_format == AV_PIX_FMT_NONE) {
> -av_log(NULL, AV_LOG_FATAL, "Unrecognised hwaccel output "
> -   "format: %s", hwaccel_output_format);
> -}
> -} else {
> -ist->hwaccel_output_format = AV_PIX_FMT_NONE;
> -}
> -
>  ist->hwaccel_pix_fmt = AV_PIX_FMT_NONE;
>  
>  break;
> 

___
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".

[FFmpeg-devel] [PATCH v2 4/4] doc: add adpcm_ima_alp

2020-03-07 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 doc/general.texi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/doc/general.texi b/doc/general.texi
index dbdc348598..87eaad7791 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -1100,6 +1100,7 @@ following image formats are supported:
 @item ADPCM IMA Electronic Arts EACS  @tab @tab  X
 @item ADPCM IMA Electronic Arts SEAD  @tab @tab  X
 @item ADPCM IMA Funcom   @tab @tab  X
+@item ADPCM IMA High Voltage Software ALP   @tab @tab  X
 @item ADPCM IMA QuickTime@tab  X  @tab  X
 @item ADPCM IMA Simon & Schuster Interactive   @tab  @tab  X
 @item ADPCM IMA Ubisoft APM  @tab @tab X
-- 
2.17.1


___
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".

[FFmpeg-devel] [PATCH v2 2/4] avformat: add demuxer for LEGO Racers' ALP format

2020-03-07 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/alp.c| 146 +++
 libavformat/version.h|   4 +-
 4 files changed, 150 insertions(+), 2 deletions(-)
 create mode 100644 libavformat/alp.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index e0681058a2..fbb29505ff 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -85,6 +85,7 @@ OBJS-$(CONFIG_AIFF_DEMUXER)  += aiffdec.o pcm.o 
isom.o \
 mov_chan.o replaygain.o
 OBJS-$(CONFIG_AIFF_MUXER)+= aiffenc.o id3v2enc.o
 OBJS-$(CONFIG_AIX_DEMUXER)   += aixdec.o
+OBJS-$(CONFIG_ALP_DEMUXER)   += alp.o
 OBJS-$(CONFIG_AMR_DEMUXER)   += amr.o
 OBJS-$(CONFIG_AMR_MUXER) += amr.o
 OBJS-$(CONFIG_AMRNB_DEMUXER) += amr.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 0209bf0e30..08012ea208 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -46,6 +46,7 @@ extern AVInputFormat  ff_afc_demuxer;
 extern AVInputFormat  ff_aiff_demuxer;
 extern AVOutputFormat ff_aiff_muxer;
 extern AVInputFormat  ff_aix_demuxer;
+extern AVInputFormat  ff_alp_demuxer;
 extern AVInputFormat  ff_amr_demuxer;
 extern AVOutputFormat ff_amr_muxer;
 extern AVInputFormat  ff_amrnb_demuxer;
diff --git a/libavformat/alp.c b/libavformat/alp.c
new file mode 100644
index 00..c0c7905380
--- /dev/null
+++ b/libavformat/alp.c
@@ -0,0 +1,146 @@
+/*
+ * LEGO Racers ALP (.tun & .pcm) demuxer
+ *
+ * Copyright (C) 2020 Zane van Iperen (z...@zanevaniperen.com)
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "avformat.h"
+#include "internal.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/internal.h"
+
+#define ALP_TAGMKTAG('A', 'L', 'P', ' ')
+#define ALP_MAX_READ_SIZE  4096
+
+typedef struct ALPHeader {
+uint32_tmagic;  /*< Magic Number, {'A', 'L', 'P', ' '} */
+uint32_theader_size;/*< Header size (after this). */
+charadpcm[6];   /*< "ADPCM" */
+uint8_t unk1;   /*< Unknown */
+uint8_t num_channels;   /*< Channel Count. */
+uint32_tsample_rate;/*< Sample rate, only if header_size >= 12. */
+} ALPHeader;
+
+static int alp_probe(const AVProbeData *p)
+{
+uint32_t i;
+
+if (AV_RL32(p->buf) != ALP_TAG)
+return 0;
+
+/* Only allowed header sizes are 8 and 12. */
+i = AV_RL32(p->buf + 4);
+if (i != 8 && i != 12)
+return 0;
+
+if (strncmp("ADPCM", p->buf + 8, 6) != 0)
+return 0;
+
+return AVPROBE_SCORE_EXTENSION + 1;
+}
+
+static int alp_read_header(AVFormatContext *s)
+{
+int ret;
+AVStream *st;
+ALPHeader hdr;
+AVCodecParameters *par;
+
+if ((hdr.magic = avio_rl32(s->pb)) != ALP_TAG)
+return AVERROR_INVALIDDATA;
+
+hdr.header_size = avio_rl32(s->pb);
+
+if (hdr.header_size != 8 && hdr.header_size != 12) {
+return AVERROR_INVALIDDATA;
+}
+
+if ((ret = avio_read(s->pb, hdr.adpcm, sizeof(hdr.adpcm))) < 0)
+return ret;
+else if (ret != sizeof(hdr.adpcm))
+return AVERROR(EIO);
+
+if (strncmp("ADPCM", hdr.adpcm, sizeof(hdr.adpcm)) != 0)
+return AVERROR_INVALIDDATA;
+
+hdr.unk1= avio_r8(s->pb);
+hdr.num_channels= avio_r8(s->pb);
+
+if (hdr.header_size == 8) {
+/* .TUN music file */
+hdr.sample_rate = 11025 * hdr.num_channels;
+} else {
+/* .PCM sound file */
+hdr.sample_rate = avio_rl32(s->pb);
+}
+
+if (hdr.sample_rate > 44100) {
+avpriv_request_sample(s, "Sample Rate > 44100");
+return AVERROR_PATCHWELCOME;
+}
+
+if (!(st = avformat_new_stream(s, NULL)))
+return AVERROR(ENOMEM);
+
+par = st->codecpar;
+par->codec_type = AVMEDIA_TYPE_AUDIO;
+par->codec_id   = AV_CODEC_ID_ADPCM_IMA_ALP;
+par->format = AV_SAMPLE_FMT_S16;
+par->sample_rate= hdr.sample_rate;
+par->channels   = hdr.num_channels;
+
+if 

[FFmpeg-devel] [PATCH v2 3/4] changelog: add adpcm_ima_alp decoder and alp demuxer

2020-03-07 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 Changelog | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index cb310a3abc..0503069daa 100644
--- a/Changelog
+++ b/Changelog
@@ -43,7 +43,8 @@ version :
 - Rayman 2 ADPCM decoder
 - Rayman 2 APM demuxer
 - cas video filter
-
+- High Voltage Software ADPCM decoder
+- LEGO Racers ALP (.tun & .pcm) demuxer
 
 version 4.2:
 - tpad filter
-- 
2.17.1


___
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".

[FFmpeg-devel] [PATCH v2 1/4] avcodec: add decoder for High Voltage Software's ALP ADPCM

2020-03-07 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavcodec/Makefile |  1 +
 libavcodec/adpcm.c  | 36 
 libavcodec/allcodecs.c  |  1 +
 libavcodec/avcodec.h|  1 +
 libavcodec/codec_desc.c |  7 +++
 libavcodec/version.h|  4 ++--
 6 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index f1c032b456..0fd374ffed 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -834,6 +834,7 @@ OBJS-$(CONFIG_ADPCM_G726_ENCODER) += g726.o
 OBJS-$(CONFIG_ADPCM_G726LE_DECODER)   += g726.o
 OBJS-$(CONFIG_ADPCM_G726LE_ENCODER)   += g726.o
 OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER)  += adpcm.o adpcm_data.o
+OBJS-$(CONFIG_ADPCM_IMA_ALP_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_APC_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_APM_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_DAT4_DECODER) += adpcm.o adpcm_data.o
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index 5f152ee6ef..c69cac3379 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -15,6 +15,7 @@
  * Argonaut Games ADPCM decoder by Zane van Iperen (z...@zanevaniperen.com)
  * Simon & Schuster Interactive ADPCM decoder by Zane van Iperen 
(z...@zanevaniperen.com)
  * Ubisoft ADPCM decoder by Zane van Iperen (z...@zanevaniperen.com)
+ * High Voltage Software ALP decoder by Zane van Iperen 
(z...@zanevaniperen.com)
  *
  * This file is part of FFmpeg.
  *
@@ -280,6 +281,29 @@ static inline int16_t 
adpcm_ima_expand_nibble(ADPCMChannelStatus *c, int8_t nibb
 return (int16_t)c->predictor;
 }
 
+static inline int16_t adpcm_ima_alp_expand_nibble(ADPCMChannelStatus *c, 
int8_t nibble, int shift)
+{
+int step_index;
+int predictor;
+int sign, delta, diff, step;
+
+step = ff_adpcm_step_table[c->step_index];
+step_index = c->step_index + ff_adpcm_index_table[(unsigned)nibble];
+step_index = av_clip(step_index, 0, 88);
+
+sign = nibble & 8;
+delta = nibble & 7;
+diff = (delta * step) >> shift;
+predictor = c->predictor;
+if (sign) predictor -= diff;
+else predictor += diff;
+
+c->predictor = av_clip_int16(predictor);
+c->step_index = step_index;
+
+return (int16_t)c->predictor;
+}
+
 static inline int16_t adpcm_ima_wav_expand_nibble(ADPCMChannelStatus *c, 
GetBitContext *gb, int bps)
 {
 int nibble, step_index, predictor, sign, delta, diff, step, shift;
@@ -675,6 +699,7 @@ static int get_nb_samples(AVCodecContext *avctx, 
GetByteContext *gb,
 case AV_CODEC_ID_ADPCM_AICA:
 case AV_CODEC_ID_ADPCM_IMA_SSI:
 case AV_CODEC_ID_ADPCM_IMA_APM:
+case AV_CODEC_ID_ADPCM_IMA_ALP:
 nb_samples = buf_size * 2 / ch;
 break;
 }
@@ -1247,6 +1272,16 @@ static int adpcm_decode_frame(AVCodecContext *avctx, 
void *data,
 samples += avctx->channels;
 }
 break;
+case AV_CODEC_ID_ADPCM_IMA_ALP:
+for (n = nb_samples / 2; n > 0; n--) {
+for (channel = 0; channel < avctx->channels; channel++) {
+int v = bytestream2_get_byteu();
+*samples++  = adpcm_ima_alp_expand_nibble(>status[channel], 
v >> 4  , 2);
+samples[st] = adpcm_ima_alp_expand_nibble(>status[channel], 
v & 0x0F, 2);
+}
+samples += avctx->channels;
+}
+break;
 case AV_CODEC_ID_ADPCM_IMA_OKI:
 while (bytestream2_get_bytes_left() > 0) {
 int v = bytestream2_get_byteu();
@@ -1997,6 +2032,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_QT,  
sample_fmts_s16p, adpcm_ima_qt,
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_RAD, sample_fmts_s16,  adpcm_ima_rad,  
   "ADPCM IMA Radical");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_SSI, sample_fmts_s16,  adpcm_ima_ssi,  
   "ADPCM IMA Simon & Schuster Interactive");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_SMJPEG,  sample_fmts_s16,  
adpcm_ima_smjpeg,  "ADPCM IMA Loki SDL MJPEG");
+ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_ALP, sample_fmts_s16,  adpcm_ima_alp,  
   "ADPCM IMA High Voltage Software ALP");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_WAV, sample_fmts_s16p, adpcm_ima_wav,  
   "ADPCM IMA WAV");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_WS,  sample_fmts_both, adpcm_ima_ws,   
   "ADPCM IMA Westwood");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_MS,  sample_fmts_both, adpcm_ms,   
   "ADPCM Microsoft");
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 674995df72..f4cf180716 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -599,6 +599,7 @@ extern AVCodec ff_adpcm_g726_decoder;
 extern AVCodec ff_adpcm_g726le_encoder;
 extern AVCodec ff_adpcm_g726le_decoder;
 extern AVCodec ff_adpcm_ima_amv_decoder;
+extern AVCodec ff_adpcm_ima_alp_decoder;
 extern AVCodec ff_adpcm_ima_apc_decoder;
 extern AVCodec ff_adpcm_ima_apm_decoder;
 extern AVCodec ff_adpcm_ima_dat4_decoder;
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 

[FFmpeg-devel] [PATCH v2 0/4] High Voltage Software ALP demuxer + decoder.

2020-03-07 Thread Zane van Iperen
Adds support for the .TUN and .PCM files used by some
High Voltage Software games.

v2:
  - check for header size and "ADPCM" magic in probe
  - error if sample rate > 44100 to catch possible overflow
  - don't allocate stream until after header is validated
  - formatting fixes

Zane van Iperen (4):
  avcodec: add decoder for High Voltage Software's ALP ADPCM
  avformat: add demuxer for LEGO Racers' ALP format
  changelog: add adpcm_ima_alp decoder and alp demuxer
  doc: add adpcm_ima_alp

 Changelog|   3 +-
 doc/general.texi |   1 +
 libavcodec/Makefile  |   1 +
 libavcodec/adpcm.c   |  36 ++
 libavcodec/allcodecs.c   |   1 +
 libavcodec/avcodec.h |   1 +
 libavcodec/codec_desc.c  |   7 ++
 libavcodec/version.h |   4 +-
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/alp.c| 146 +++
 libavformat/version.h|   4 +-
 12 files changed, 201 insertions(+), 5 deletions(-)
 create mode 100644 libavformat/alp.c

-- 
2.17.1


___
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".

[FFmpeg-devel] [PATCH] ffmpeg: default hwaccel_output_format to cuda when hwaccel is cuvid

2020-03-07 Thread Timo Rothenpieler
This ensures old commandlines using -hwaccel cuvid don't break due to
the recent removal of the the cuvid-specific hwaccel bringup.
---
 fftools/ffmpeg_opt.c | 31 +++
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 1b721c4954..043919faeb 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -817,6 +817,25 @@ static void add_input_streams(OptionsContext *o, 
AVFormatContext *ic)
 MATCH_PER_STREAM_OPT(top_field_first, i, ist->top_field_first, ic, 
st);
 
 MATCH_PER_STREAM_OPT(hwaccels, str, hwaccel, ic, st);
+MATCH_PER_STREAM_OPT(hwaccel_output_formats, str,
+ hwaccel_output_format, ic, st);
+
+if (!hwaccel_output_format && hwaccel && !strcmp(hwaccel, 
"cuvid")) {
+av_log(NULL, AV_LOG_WARNING,
+"WARNING: defaulting hwaccel_output_format to cuda for 
compatibility "
+"with old commandlines. This behaviour is DEPRECATED and 
will be removed "
+"in the future. Please explicitly set 
\"-hwaccel_output_format cuda\".\n");
+ist->hwaccel_output_format = AV_PIX_FMT_CUDA;
+} else if (hwaccel_output_format) {
+ist->hwaccel_output_format = 
av_get_pix_fmt(hwaccel_output_format);
+if (ist->hwaccel_output_format == AV_PIX_FMT_NONE) {
+av_log(NULL, AV_LOG_FATAL, "Unrecognised hwaccel output "
+   "format: %s", hwaccel_output_format);
+}
+} else {
+ist->hwaccel_output_format = AV_PIX_FMT_NONE;
+}
+
 if (hwaccel) {
 // The NVDEC hwaccels use a CUDA device, so remap the name 
here.
 if (!strcmp(hwaccel, "nvdec") || !strcmp(hwaccel, "cuvid"))
@@ -868,18 +887,6 @@ static void add_input_streams(OptionsContext *o, 
AVFormatContext *ic)
 exit_program(1);
 }
 
-MATCH_PER_STREAM_OPT(hwaccel_output_formats, str,
- hwaccel_output_format, ic, st);
-if (hwaccel_output_format) {
-ist->hwaccel_output_format = 
av_get_pix_fmt(hwaccel_output_format);
-if (ist->hwaccel_output_format == AV_PIX_FMT_NONE) {
-av_log(NULL, AV_LOG_FATAL, "Unrecognised hwaccel output "
-   "format: %s", hwaccel_output_format);
-}
-} else {
-ist->hwaccel_output_format = AV_PIX_FMT_NONE;
-}
-
 ist->hwaccel_pix_fmt = AV_PIX_FMT_NONE;
 
 break;
-- 
2.20.1

___
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 6/7] avformat/mxfenc: allow all frame rates if -strict mode is set to unofficial or lower

2020-03-07 Thread Tomas Härdin
tor 2020-03-05 klockan 22:56 +0100 skrev Marton Balint:
> There was no consensus wheter or not to allow unofficial frame rates due to
> possible interoperability issues, a compromise is to only allow it if -strict
> mode is set to unofficial.
> 
> Signed-off-by: Marton Balint 
> ---
>  libavformat/mxfenc.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
> index 51e2dc5f31..6279ba9d6d 100644
> --- a/libavformat/mxfenc.c
> +++ b/libavformat/mxfenc.c
> @@ -2413,8 +2413,12 @@ static int mxf_init_timecode(AVFormatContext *s, 
> AVStream *st, AVRational tbc)
>  AVDictionaryEntry *tcr = av_dict_get(s->metadata, "timecode", NULL, 0);
>  
>  if (!ff_mxf_get_content_package_rate(tbc)) {
> -av_log(s, AV_LOG_ERROR, "Unsupported frame rate %d/%d\n", tbc.den, 
> tbc.num);
> -return AVERROR(EINVAL);
> +if (s->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) {
> +av_log(s, AV_LOG_ERROR, "Unsupported frame rate %d/%d. Set 
> -strict option to 'unofficial' or lower in order to allow it!\n", tbc.den, 
> tbc.num);
> +return AVERROR(EINVAL);
> +} else {
> +av_log(s, AV_LOG_WARNING, "Unofficial frame rate %d/%d.\n", 
> tbc.den, tbc.num);
> +}

This can work. That way we make it clear to users that here be dragons

/Tomas

___
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 4/4] avformat/mxfenc: add some missing content package rates

2020-03-07 Thread Tomas Härdin
ons 2020-03-04 klockan 17:48 +0100 skrev Carl Eugen Hoyos:
> Am Mi., 4. März 2020 um 17:29 Uhr schrieb Tomas Härdin <
> tjop...@acc.umu.se>:
> > ons 2020-03-04 klockan 11:31 +0100 skrev Carl Eugen Hoyos:
> > > Am Di., 3. März 2020 um 02:18 Uhr schrieb Marton Balint <
> > > c...@passwd.hu>:
> > > 
> > > > 2) support all frame rates and write 0 (undefined) as the
> > > > package rate
> > > > for frame rates which cannot be exactly represented
> > > 
> > > Why not?
> > > 
> > > Allow me to repeat: Professional archivists recommend using mxf.
> > > How
> > > do they store digitized content from (old) low-fps film?
> > 
> > We can worry about that when archivists open tickets on trac.
> 
> A ticket was actually opened asking for more frame rates (just as
> a ticket was opened earlier because of a limitation in aspect
> ratios),

Which one? #8523?

> I wonder why mxf is the only (?) libavformat muxer that tells the
> user which frame rates (in the past: which aspect ratios) to use.
> It is very hard to believe that the reason is that mxf does not allow
> other frame rates (I have to listen once a year to a presentation
> explaining how versatile mxf is compared to all other multimedia
> containers).
> 
> Just print a warning when you feel that the chosen framerate will
> not ensure maximum compatibility.

If the output can be guaranteed to be correct, sure. If not then no. We
should not output files which we can't verify to be correct, especially
when it comes to MXF. The ecosystem is enough of a mess as it is. It is
pointless to output files with mxfenc that can only be consumed by
mxfdec. To be useful the output must be possible to exchange with other
MXF decoders.

/Tomas

___
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 2/4] avformat/mxf: get rid of samples per frame array usage

2020-03-07 Thread Tomas Härdin
ons 2020-03-04 klockan 19:58 +0100 skrev Michael Niedermayer:
> On Tue, Mar 03, 2020 at 07:54:55PM +0100, Tomas Härdin wrote:
> > mån 2020-03-02 klockan 21:35 +0100 skrev Marton Balint:
> > > On Mon, 2 Mar 2020, Tomas Härdin wrote:
> > > 
> > > > fre 2020-02-28 klockan 01:37 +0100 skrev Marton Balint:
> > > > > Signed-off-by: Marton Balint 
> > > > > ---
> > > > >  libavformat/mxf.c| 44 
> > > > > 
> > > > >  libavformat/mxf.h|  6 --
> > > > >  libavformat/mxfdec.c | 23 +++
> > > > >  libavformat/mxfenc.c | 24 ++--
> > > > >  4 files changed, 13 insertions(+), 84 deletions(-)
> > > > >  int ff_mxf_get_content_package_rate(AVRational time_base)
> > > > >  {
> > > > > -int idx = av_find_nearest_q_idx(time_base, mxf_time_base);
> > > > > -AVRational diff = av_sub_q(time_base, mxf_time_base[idx]);
> > > > > -
> > > > > -diff.num = FFABS(diff.num);
> > > > > -
> > > > > -if (av_cmp_q(diff, (AVRational){1, 1000}) >= 0)
> > > > > -return -1;
> > > > > -
> > > > > -return mxf_content_package_rates[idx];
> > > > > +for (int i = 0; mxf_time_base[i].num; i++)
> > > > > +if (!av_cmp_q(time_base, mxf_time_base[i]))
> > > > 
> > > > I see this gets rid of the inexact check for an exact one. Approve!
> > > > 
> > > > > @@ -3307,20 +3307,17 @@ static int 
> > > > > mxf_get_next_track_edit_unit(MXFContext *mxf, MXFTrack *track, int64_
> > > > >  static int64_t mxf_compute_sample_count(MXFContext *mxf, AVStream 
> > > > > *st,
> > > > >  int64_t edit_unit)
> > > > >  {
> > > > > -int i, total = 0, size = 0;
> > > > >  MXFTrack *track = st->priv_data;
> > > > >  AVRational time_base = av_inv_q(track->edit_rate);
> > > > >  AVRational sample_rate = av_inv_q(st->time_base);
> > > > > -const MXFSamplesPerFrame *spf = NULL;
> > > > > -int64_t sample_count;
> > > > > 
> > > > >  // For non-audio sample_count equals current edit unit
> > > > >  if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO)
> > > > >  return edit_unit;
> > > > > 
> > > > > -if ((sample_rate.num / sample_rate.den) == 48000)
> > > > > -spf = ff_mxf_get_samples_per_frame(mxf->fc, time_base);
> > > > > -if (!spf) {
> > > > > +if ((sample_rate.num / sample_rate.den) == 48000) {
> > > > > +return av_rescale_q(edit_unit, sample_rate, 
> > > > > track->edit_rate);
> > > > 
> > > > Should be OK, per previous rounding argument
> > > > 
> > > > >  }
> > > > >  sc->index = INDEX_D10_AUDIO;
> > > > >  sc->container_ul = 
> > > > > ((MXFStreamContext*)s->streams[0]->priv_data)->container_ul;
> > > > > -sc->frame_size = 4 + 8 * spf[0].samples_per_frame[0] 
> > > > > * 4;
> > > > > +sc->frame_size = 4 + 8 * av_rescale_rnd(st-
> > > > > > codecpar->sample_rate, mxf->time_base.num, mxf->time_base.den,
> > > > > AV_ROUND_UP) * 4;
> > > > 
> > > > I was going to say this is only used for CBR video, but closer
> > > > inspection reveals it's used to prevent 1/1.001 rate audio packets from
> > > > making their way into CBR files. This is a bit surprising to me, since
> > > > D-10 supports NTSC (without audio?)
> > > 
> > > I thought D10 can only be CBR and and it can only use a constant edit 
> > > unit 
> > > size, 1/1.001 audio packet size difference is handled using KLV 
> > > padding. So what we compute here is a _maximum_ frame size.
> > 
> > Now I remember: D-10 is indeed CBR, but at the MXF/CP level. To make it
> > CBR you must pad the content packages with fill KLVs as necessary. This
> > filling was actually removed by Baptiste a while back, and we had a set
> > of patches attempting to fix support for NTSC but sadly the ratecontrol
> > in lavc is not up to snuff to support that for files longer than about
> > an hour.
> 
> Do you have a testcase for this so the ratecontrol can be fixed by fixing
> the testcase ?

See the thread "[FFmpeg-devel] [PATCH] libavformat/mxfenc: Allow more
bitrates for NTSC IMX50" in the archives. The basic problem is that it
is not possible to ask the ratecontrol system to produce packets with a
specified size. It is only possible to use bitrate, which never cleanly
divides by 30/1.001 for IMX

/Tomas

___
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 7/7] avformat/audiointerleave: use a fixed frame duration for non-audio packets

2020-03-07 Thread Marton Balint



On Sat, 7 Mar 2020, Michael Niedermayer wrote:


On Thu, Mar 05, 2020 at 10:56:28PM +0100, Marton Balint wrote:

The packet durations might not be set properly which can cause the MXF muxer
to write more than one packet of a stream to an edit unit messing up the
constant byte per element index...

Also use nb_samples directly to calculate dts of audio packets because adding
packet durations might not be precise.

Signed-off-by: Marton Balint 
---
 libavformat/audiointerleave.c | 12 +---
 libavformat/audiointerleave.h |  3 ++-
 libavformat/gxfenc.c  |  2 +-
 libavformat/mxfenc.c  |  2 +-
 4 files changed, 13 insertions(+), 6 deletions(-)


This doesnt feel correct

Either case
A. The durations are correct but not what the muxer wants
then changing them at the muxer level could lead to AV sync issues and
wrong timestamps, something which the application should have dealt with
by frame duplication / frame drops or other

B. The durations are just wrong
then changing them at the muxer level will leave the calling application
with incorrect values potentially causing all kinds of problems.

Maybe iam missing something but isnt this just fixing the issue when the
durtations are wrong in a very special way ?


It is the same "special" way that is used for audio. We ignore incoming 
DTS and duration, and make up our own.


Yes, it can cause A-V sync issues is somebody wants to push VFR video or 
sparse audio data, that is not allowed in the MXF muxer.


Maybe we should hard reject streams if there is a difference between the 
calculated and the incoming DTS? I have a feeling that such measure would 
broke a lot of existing command lines...


Regards,
Marton
___
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".