Re: [FFmpeg-devel] [PATCH 1/2] lavc/vaapi_decode: add missing flag when picking best pixel format

2022-08-04 Thread Wang, Fei W
On Thu, 2022-08-04 at 20:59 -0700, Philip Langdale wrote:
> vaapi_decode_find_best_format currently does not set the
> VA_SURFACE_ATTRIB_SETTABLE flag on the pixel format attribute that it
> returns.
> 
> Without this flag, the attribute will be ignored by vaCreateSurfaces,
> meaning that the driver's default logic for picking a pixel format
> will
> kick in.
> 
> So far, this hasn't produced visible problems, but when trying to
> decode 4:4:4 content, at least on Intel, the driver will pick the
> 444P planar format, even though the decoder can only return the AYUV
> packed format.
> 
> The hwcontext_vaapi code that sets surface attributes when picking
> formats does not have this bug.
> 
> Applications may use their own logic for finding the best format, and
> so may not hit this bug. eg: mpv is unaffected.
> 
> Signed-off-by: Philip Langdale 
> ---
>  libavcodec/vaapi_decode.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
> index db48efc3ed..38813eb8e4 100644
> --- a/libavcodec/vaapi_decode.c
> +++ b/libavcodec/vaapi_decode.c
> @@ -358,6 +358,7 @@ static int
> vaapi_decode_find_best_format(AVCodecContext *avctx,
>  
>  ctx->pixel_format_attribute = (VASurfaceAttrib) {
>  .type  = VASurfaceAttribPixelFormat,
> +.flags = VA_SURFACE_ATTRIB_SETTABLE,

Better to fill .value.type with VAGenericValueTypeInteger together:
https://github.com/intel/media-driver/blob/4c95e8ef1e98cac661412d02f108e4e1c94d3556/media_driver/linux/common/ddi/media_libva.cpp#L2780

Thanks
Fei

>  .value.value.i = best_fourcc,
>  };
>  
___
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] lavfi/dnn: Fix OpenVINO missing model file corrupt issue.

2022-08-04 Thread Fu, Ting
Hi Anton,

Thank you for comment. 
After double checked the OpenVINO, it is true that the code would corrupt if 
the binary file does not exist.
We would have nothing to do in this case, that's why I code to check the file 
existence explicitly.
Yes, you are right, it is not a proper way to do like this. But I have no idea 
how to solve it more decently, since trying to open it as you mentioned would 
lead to crush immediately. Maybe there is some solution I don’t know, any 
further input would be appreciated. 

PS, it is not a good commit message since I have not fixed this issue, it's 
just a workaround. I would modify it in next version.

Thank you,
Ting FU
> -Original Message-
> From: ffmpeg-devel  On Behalf Of Anton
> Khirnov
> Sent: Thursday, August 4, 2022 06:40 PM
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH] lavfi/dnn: Fix OpenVINO missing model file
> corrupt issue.
> 
> Quoting Ting Fu (2022-08-04 11:31:01)
> > DNN OpenVINO backend would not report missing model file if it does
> > not exist. It would corrupt directly with out any error infomation.
> > This commit
> 
> "corrupt"?
> 
> The patch looks completely wrong. Testing for file existence explicitly is 
> known
> to be a bad pattern that leads to all kinds of races, security issues, and 
> other
> bugs. Just trying to open the file and returning an error if that fails is 
> the right
> thing to do.
> 
> --
> Anton Khirnov
> ___
> 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 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 11/11] avcodec/avcodec: Remove AV_CODEC_FLAG2_DROP_FRAME_TIMECODE

2022-08-04 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> It has been deprecated in 94d68a41fabb55dd8c7e59b88fe4a28a637d1e5f
> and can't be set via AVOptions. The only codecs that use it
> (the MPEG-1/2 encoders) have private options for this.
> So remove it.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/avcodec.h   | 5 -
>  libavcodec/mpeg12enc.c | 1 -
>  2 files changed, 6 deletions(-)
> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index abd6272f63..1d55cdb07a 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -300,11 +300,6 @@ typedef struct RcOverride{
>   */
>  #define AV_CODEC_FLAG2_LOCAL_HEADER   (1 <<  3)
>  
> -/**
> - * timecode is in drop frame format. DEPRECATED
> - */
> -#define AV_CODEC_FLAG2_DROP_FRAME_TIMECODE (1 << 13)
> -
>  /**
>   * Input bitstream might be truncated at a packet boundaries
>   * instead of only at frame boundaries.
> diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
> index a7e7aef010..ae2311b39f 100644
> --- a/libavcodec/mpeg12enc.c
> +++ b/libavcodec/mpeg12enc.c
> @@ -234,7 +234,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
>  }
>  }
>  
> -mpeg12->drop_frame_timecode = mpeg12->drop_frame_timecode || 
> !!(avctx->flags2 & AV_CODEC_FLAG2_DROP_FRAME_TIMECODE);
>  if (mpeg12->drop_frame_timecode)
>  mpeg12->tc.flags |= AV_TIMECODE_FLAG_DROPFRAME;
>  if (mpeg12->drop_frame_timecode && mpeg12->frame_rate_index != 4) {

Does this one need a version bump? I think so and have therefore not
applied it with the rest of this series.

- Andreas
___
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 v5 1/2] avformat: refactor ff_stream_encode_params_copy() to ff_stream_params_copy()

2022-08-04 Thread Pierre-Anthony Lemieux
On Thu, Aug 4, 2022 at 4:13 PM Andreas Rheinhardt
 wrote:
>
> Pierre-Anthony Lemieux:
> > On Thu, Aug 4, 2022 at 3:22 PM Andreas Rheinhardt
> >  wrote:
> >>
> >> Pierre-Anthony Lemieux:
> >>> On Thu, Aug 4, 2022 at 10:15 AM Andreas Rheinhardt
> >>>  wrote:
> 
>  Pierre-Anthony Lemieux:
> > On Thu, Aug 4, 2022 at 9:53 AM Andreas Rheinhardt
> >  wrote:
> >>
> >> p...@sandflow.com:
> >>> From: Pierre-Anthony Lemieux 
> >>>
> >>> As discussed at 
> >>> https://ffmpeg.org/pipermail/ffmpeg-devel/2022-July/298491.html.
> >>> Note that ff_stream_params_copy() does not copy:
> >>>  * the index field
> >>>  * the attached_pic if its size is 0
> >>>
> >>> Addresses 
> >>> http://ffmpeg.org/pipermail/ffmpeg-devel/2022-August/299514.html
> >>>
> >>> ---
> >>>  libavformat/avformat.c   | 40 
> >>> 
> >>>  libavformat/fifo.c   |  2 +-
> >>>  libavformat/internal.h   | 12 
> >>>  libavformat/mux.h|  9 -
> >>>  libavformat/mux_utils.c  | 28 
> >>>  libavformat/segment.c|  2 +-
> >>>  libavformat/tee.c|  2 +-
> >>>  libavformat/webm_chunk.c |  2 +-
> >>>  8 files changed, 56 insertions(+), 41 deletions(-)
> >>>
> >>> diff --git a/libavformat/avformat.c b/libavformat/avformat.c
> >>> index 30d6ea6a49..242187c359 100644
> >>> --- a/libavformat/avformat.c
> >>> +++ b/libavformat/avformat.c
> >>> @@ -235,6 +235,46 @@ int ff_stream_side_data_copy(AVStream *dst, 
> >>> const AVStream *src)
> >>>  return 0;
> >>>  }
> >>>
> >>> +int ff_stream_params_copy(AVStream *dst, const AVStream *src)
> >>> +{
> >>> +int ret;
> >>> +
> >>> +dst->id  = src->id;
> >>> +dst->time_base   = src->time_base;
> >>> +dst->start_time  = src->start_time;
> >>> +dst->duration= src->duration;
> >>> +dst->nb_frames   = src->nb_frames;
> >>> +dst->disposition = src->disposition;
> >>> +dst->discard = src->discard;
> >>> +dst->sample_aspect_ratio = src->sample_aspect_ratio;
> >>> +dst->avg_frame_rate  = src->avg_frame_rate;
> >>> +dst->event_flags = src->event_flags;
> >>> +dst->r_frame_rate= src->r_frame_rate;
> >>> +dst->pts_wrap_bits   = src->pts_wrap_bits;
> >>> +
> >>> +av_dict_free(>metadata);
> >>> +ret = av_dict_copy(>metadata, src->metadata, 0);
> >>> +if (ret < 0)
> >>> +return ret;
> >>> +
> >>> +ret = avcodec_parameters_copy(dst->codecpar, src->codecpar);
> >>> +if (ret < 0)
> >>> +return ret;
> >>> +
> >>> +ret = ff_stream_side_data_copy(dst, src);
> >>> +if (ret < 0)
> >>> +return ret;
> >>> +
> >>> +av_packet_unref(>attached_pic);
> >>> +if (src->attached_pic.size > 0) {
> >>> +ret = av_packet_ref(>attached_pic, >attached_pic);
> >>> +if (ret < 0)
> >>> +return ret;
> >>> +}
> >>> +
> >>> +return 0;
> >>> +}
> >>> +
> >>>  AVProgram *av_new_program(AVFormatContext *ac, int id)
> >>>  {
> >>>  AVProgram *program = NULL;
> >>> diff --git a/libavformat/fifo.c b/libavformat/fifo.c
> >>> index ead2bdc5cf..fef116d040 100644
> >>> --- a/libavformat/fifo.c
> >>> +++ b/libavformat/fifo.c
> >>> @@ -509,7 +509,7 @@ static int fifo_mux_init(AVFormatContext *avf, 
> >>> const AVOutputFormat *oformat,
> >>>  if (!st)
> >>>  return AVERROR(ENOMEM);
> >>>
> >>> -ret = ff_stream_encode_params_copy(st, avf->streams[i]);
> >>> +ret = ff_stream_params_copy(st, avf->streams[i]);
> >>>  if (ret < 0)
> >>>  return ret;
> >>>  }
> >>> diff --git a/libavformat/internal.h b/libavformat/internal.h
> >>> index b6b8fbf56f..87a00bbae3 100644
> >>> --- a/libavformat/internal.h
> >>> +++ b/libavformat/internal.h
> >>> @@ -625,6 +625,18 @@ enum AVCodecID ff_get_pcm_codec_id(int bps, int 
> >>> flt, int be, int sflags);
> >>>   */
> >>>  int ff_stream_side_data_copy(AVStream *dst, const AVStream *src);
> >>>
> >>> +/**
> >>> + * Copy all stream parameters from source to destination stream, 
> >>> with the
> >>> + * exception of:
> >>> + *  * the index field, which is usually set by avformat_new_stream()
> >>> + *  * the attached_pic field, if attached_pic.size is 0 or less
> >>> + *
> >>> + * @param dst pointer to destination AVStream
> >>> + * @param src pointer to source AVStream
> >>> + * @return >=0 on success, AVERROR code on error
> >>> + */
> >>> +int ff_stream_params_copy(AVStream *dst, const 

Re: [FFmpeg-devel] [PATCH v5 1/2] avformat: refactor ff_stream_encode_params_copy() to ff_stream_params_copy()

2022-08-04 Thread Andreas Rheinhardt
Pierre-Anthony Lemieux:
> On Thu, Aug 4, 2022 at 3:22 PM Andreas Rheinhardt
>  wrote:
>>
>> Pierre-Anthony Lemieux:
>>> On Thu, Aug 4, 2022 at 10:15 AM Andreas Rheinhardt
>>>  wrote:

 Pierre-Anthony Lemieux:
> On Thu, Aug 4, 2022 at 9:53 AM Andreas Rheinhardt
>  wrote:
>>
>> p...@sandflow.com:
>>> From: Pierre-Anthony Lemieux 
>>>
>>> As discussed at 
>>> https://ffmpeg.org/pipermail/ffmpeg-devel/2022-July/298491.html.
>>> Note that ff_stream_params_copy() does not copy:
>>>  * the index field
>>>  * the attached_pic if its size is 0
>>>
>>> Addresses 
>>> http://ffmpeg.org/pipermail/ffmpeg-devel/2022-August/299514.html
>>>
>>> ---
>>>  libavformat/avformat.c   | 40 
>>>  libavformat/fifo.c   |  2 +-
>>>  libavformat/internal.h   | 12 
>>>  libavformat/mux.h|  9 -
>>>  libavformat/mux_utils.c  | 28 
>>>  libavformat/segment.c|  2 +-
>>>  libavformat/tee.c|  2 +-
>>>  libavformat/webm_chunk.c |  2 +-
>>>  8 files changed, 56 insertions(+), 41 deletions(-)
>>>
>>> diff --git a/libavformat/avformat.c b/libavformat/avformat.c
>>> index 30d6ea6a49..242187c359 100644
>>> --- a/libavformat/avformat.c
>>> +++ b/libavformat/avformat.c
>>> @@ -235,6 +235,46 @@ int ff_stream_side_data_copy(AVStream *dst, const 
>>> AVStream *src)
>>>  return 0;
>>>  }
>>>
>>> +int ff_stream_params_copy(AVStream *dst, const AVStream *src)
>>> +{
>>> +int ret;
>>> +
>>> +dst->id  = src->id;
>>> +dst->time_base   = src->time_base;
>>> +dst->start_time  = src->start_time;
>>> +dst->duration= src->duration;
>>> +dst->nb_frames   = src->nb_frames;
>>> +dst->disposition = src->disposition;
>>> +dst->discard = src->discard;
>>> +dst->sample_aspect_ratio = src->sample_aspect_ratio;
>>> +dst->avg_frame_rate  = src->avg_frame_rate;
>>> +dst->event_flags = src->event_flags;
>>> +dst->r_frame_rate= src->r_frame_rate;
>>> +dst->pts_wrap_bits   = src->pts_wrap_bits;
>>> +
>>> +av_dict_free(>metadata);
>>> +ret = av_dict_copy(>metadata, src->metadata, 0);
>>> +if (ret < 0)
>>> +return ret;
>>> +
>>> +ret = avcodec_parameters_copy(dst->codecpar, src->codecpar);
>>> +if (ret < 0)
>>> +return ret;
>>> +
>>> +ret = ff_stream_side_data_copy(dst, src);
>>> +if (ret < 0)
>>> +return ret;
>>> +
>>> +av_packet_unref(>attached_pic);
>>> +if (src->attached_pic.size > 0) {
>>> +ret = av_packet_ref(>attached_pic, >attached_pic);
>>> +if (ret < 0)
>>> +return ret;
>>> +}
>>> +
>>> +return 0;
>>> +}
>>> +
>>>  AVProgram *av_new_program(AVFormatContext *ac, int id)
>>>  {
>>>  AVProgram *program = NULL;
>>> diff --git a/libavformat/fifo.c b/libavformat/fifo.c
>>> index ead2bdc5cf..fef116d040 100644
>>> --- a/libavformat/fifo.c
>>> +++ b/libavformat/fifo.c
>>> @@ -509,7 +509,7 @@ static int fifo_mux_init(AVFormatContext *avf, 
>>> const AVOutputFormat *oformat,
>>>  if (!st)
>>>  return AVERROR(ENOMEM);
>>>
>>> -ret = ff_stream_encode_params_copy(st, avf->streams[i]);
>>> +ret = ff_stream_params_copy(st, avf->streams[i]);
>>>  if (ret < 0)
>>>  return ret;
>>>  }
>>> diff --git a/libavformat/internal.h b/libavformat/internal.h
>>> index b6b8fbf56f..87a00bbae3 100644
>>> --- a/libavformat/internal.h
>>> +++ b/libavformat/internal.h
>>> @@ -625,6 +625,18 @@ enum AVCodecID ff_get_pcm_codec_id(int bps, int 
>>> flt, int be, int sflags);
>>>   */
>>>  int ff_stream_side_data_copy(AVStream *dst, const AVStream *src);
>>>
>>> +/**
>>> + * Copy all stream parameters from source to destination stream, with 
>>> the
>>> + * exception of:
>>> + *  * the index field, which is usually set by avformat_new_stream()
>>> + *  * the attached_pic field, if attached_pic.size is 0 or less
>>> + *
>>> + * @param dst pointer to destination AVStream
>>> + * @param src pointer to source AVStream
>>> + * @return >=0 on success, AVERROR code on error
>>> + */
>>> +int ff_stream_params_copy(AVStream *dst, const AVStream *src);
>>> +
>>>  /**
>>>   * Wrap ffurl_move() and log if error happens.
>>>   *
>>> diff --git a/libavformat/mux.h b/libavformat/mux.h
>>> index c01da82194..1bfcaf795f 100644
>>> --- a/libavformat/mux.h
>>> +++ b/libavformat/mux.h
>>> @@ -113,15 +113,6 @@ int 

Re: [FFmpeg-devel] [PATCH v5 1/2] avformat: refactor ff_stream_encode_params_copy() to ff_stream_params_copy()

2022-08-04 Thread Pierre-Anthony Lemieux
On Thu, Aug 4, 2022 at 3:22 PM Andreas Rheinhardt
 wrote:
>
> Pierre-Anthony Lemieux:
> > On Thu, Aug 4, 2022 at 10:15 AM Andreas Rheinhardt
> >  wrote:
> >>
> >> Pierre-Anthony Lemieux:
> >>> On Thu, Aug 4, 2022 at 9:53 AM Andreas Rheinhardt
> >>>  wrote:
> 
>  p...@sandflow.com:
> > From: Pierre-Anthony Lemieux 
> >
> > As discussed at 
> > https://ffmpeg.org/pipermail/ffmpeg-devel/2022-July/298491.html.
> > Note that ff_stream_params_copy() does not copy:
> >  * the index field
> >  * the attached_pic if its size is 0
> >
> > Addresses 
> > http://ffmpeg.org/pipermail/ffmpeg-devel/2022-August/299514.html
> >
> > ---
> >  libavformat/avformat.c   | 40 
> >  libavformat/fifo.c   |  2 +-
> >  libavformat/internal.h   | 12 
> >  libavformat/mux.h|  9 -
> >  libavformat/mux_utils.c  | 28 
> >  libavformat/segment.c|  2 +-
> >  libavformat/tee.c|  2 +-
> >  libavformat/webm_chunk.c |  2 +-
> >  8 files changed, 56 insertions(+), 41 deletions(-)
> >
> > diff --git a/libavformat/avformat.c b/libavformat/avformat.c
> > index 30d6ea6a49..242187c359 100644
> > --- a/libavformat/avformat.c
> > +++ b/libavformat/avformat.c
> > @@ -235,6 +235,46 @@ int ff_stream_side_data_copy(AVStream *dst, const 
> > AVStream *src)
> >  return 0;
> >  }
> >
> > +int ff_stream_params_copy(AVStream *dst, const AVStream *src)
> > +{
> > +int ret;
> > +
> > +dst->id  = src->id;
> > +dst->time_base   = src->time_base;
> > +dst->start_time  = src->start_time;
> > +dst->duration= src->duration;
> > +dst->nb_frames   = src->nb_frames;
> > +dst->disposition = src->disposition;
> > +dst->discard = src->discard;
> > +dst->sample_aspect_ratio = src->sample_aspect_ratio;
> > +dst->avg_frame_rate  = src->avg_frame_rate;
> > +dst->event_flags = src->event_flags;
> > +dst->r_frame_rate= src->r_frame_rate;
> > +dst->pts_wrap_bits   = src->pts_wrap_bits;
> > +
> > +av_dict_free(>metadata);
> > +ret = av_dict_copy(>metadata, src->metadata, 0);
> > +if (ret < 0)
> > +return ret;
> > +
> > +ret = avcodec_parameters_copy(dst->codecpar, src->codecpar);
> > +if (ret < 0)
> > +return ret;
> > +
> > +ret = ff_stream_side_data_copy(dst, src);
> > +if (ret < 0)
> > +return ret;
> > +
> > +av_packet_unref(>attached_pic);
> > +if (src->attached_pic.size > 0) {
> > +ret = av_packet_ref(>attached_pic, >attached_pic);
> > +if (ret < 0)
> > +return ret;
> > +}
> > +
> > +return 0;
> > +}
> > +
> >  AVProgram *av_new_program(AVFormatContext *ac, int id)
> >  {
> >  AVProgram *program = NULL;
> > diff --git a/libavformat/fifo.c b/libavformat/fifo.c
> > index ead2bdc5cf..fef116d040 100644
> > --- a/libavformat/fifo.c
> > +++ b/libavformat/fifo.c
> > @@ -509,7 +509,7 @@ static int fifo_mux_init(AVFormatContext *avf, 
> > const AVOutputFormat *oformat,
> >  if (!st)
> >  return AVERROR(ENOMEM);
> >
> > -ret = ff_stream_encode_params_copy(st, avf->streams[i]);
> > +ret = ff_stream_params_copy(st, avf->streams[i]);
> >  if (ret < 0)
> >  return ret;
> >  }
> > diff --git a/libavformat/internal.h b/libavformat/internal.h
> > index b6b8fbf56f..87a00bbae3 100644
> > --- a/libavformat/internal.h
> > +++ b/libavformat/internal.h
> > @@ -625,6 +625,18 @@ enum AVCodecID ff_get_pcm_codec_id(int bps, int 
> > flt, int be, int sflags);
> >   */
> >  int ff_stream_side_data_copy(AVStream *dst, const AVStream *src);
> >
> > +/**
> > + * Copy all stream parameters from source to destination stream, with 
> > the
> > + * exception of:
> > + *  * the index field, which is usually set by avformat_new_stream()
> > + *  * the attached_pic field, if attached_pic.size is 0 or less
> > + *
> > + * @param dst pointer to destination AVStream
> > + * @param src pointer to source AVStream
> > + * @return >=0 on success, AVERROR code on error
> > + */
> > +int ff_stream_params_copy(AVStream *dst, const AVStream *src);
> > +
> >  /**
> >   * Wrap ffurl_move() and log if error happens.
> >   *
> > diff --git a/libavformat/mux.h b/libavformat/mux.h
> > index c01da82194..1bfcaf795f 100644
> > --- a/libavformat/mux.h
> > +++ b/libavformat/mux.h
> > @@ -113,15 +113,6 @@ int ff_format_shift_data(AVFormatContext *s, 

[FFmpeg-devel] [PATCH] avformat/mxfdec: do not log warning of multiple ANC packets if count is 0

2022-08-04 Thread Gavin Smith
Some NLVEs may insert a KLV packet for EIA-608 data even though
the number of encapsulated ANC packets is zero.
---
 libavformat/mxfdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 400941c348..f3d2cf4efa 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -509,7 +509,7 @@ static int mxf_get_eia608_packet(AVFormatContext *s, 
AVStream *st, AVPacket *pkt
 int did, sdid, data_length;
 int i, ret;
 
-if (count != 1)
+if (count > 1)
 av_log(s, AV_LOG_WARNING, "unsupported multiple ANC packets (%d) per 
KLV packet\n", count);
 
 for (i = 0; i < count; i++) {
-- 
2.34.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 v5 1/2] avformat: refactor ff_stream_encode_params_copy() to ff_stream_params_copy()

2022-08-04 Thread Andreas Rheinhardt
Pierre-Anthony Lemieux:
> On Thu, Aug 4, 2022 at 10:15 AM Andreas Rheinhardt
>  wrote:
>>
>> Pierre-Anthony Lemieux:
>>> On Thu, Aug 4, 2022 at 9:53 AM Andreas Rheinhardt
>>>  wrote:

 p...@sandflow.com:
> From: Pierre-Anthony Lemieux 
>
> As discussed at 
> https://ffmpeg.org/pipermail/ffmpeg-devel/2022-July/298491.html.
> Note that ff_stream_params_copy() does not copy:
>  * the index field
>  * the attached_pic if its size is 0
>
> Addresses http://ffmpeg.org/pipermail/ffmpeg-devel/2022-August/299514.html
>
> ---
>  libavformat/avformat.c   | 40 
>  libavformat/fifo.c   |  2 +-
>  libavformat/internal.h   | 12 
>  libavformat/mux.h|  9 -
>  libavformat/mux_utils.c  | 28 
>  libavformat/segment.c|  2 +-
>  libavformat/tee.c|  2 +-
>  libavformat/webm_chunk.c |  2 +-
>  8 files changed, 56 insertions(+), 41 deletions(-)
>
> diff --git a/libavformat/avformat.c b/libavformat/avformat.c
> index 30d6ea6a49..242187c359 100644
> --- a/libavformat/avformat.c
> +++ b/libavformat/avformat.c
> @@ -235,6 +235,46 @@ int ff_stream_side_data_copy(AVStream *dst, const 
> AVStream *src)
>  return 0;
>  }
>
> +int ff_stream_params_copy(AVStream *dst, const AVStream *src)
> +{
> +int ret;
> +
> +dst->id  = src->id;
> +dst->time_base   = src->time_base;
> +dst->start_time  = src->start_time;
> +dst->duration= src->duration;
> +dst->nb_frames   = src->nb_frames;
> +dst->disposition = src->disposition;
> +dst->discard = src->discard;
> +dst->sample_aspect_ratio = src->sample_aspect_ratio;
> +dst->avg_frame_rate  = src->avg_frame_rate;
> +dst->event_flags = src->event_flags;
> +dst->r_frame_rate= src->r_frame_rate;
> +dst->pts_wrap_bits   = src->pts_wrap_bits;
> +
> +av_dict_free(>metadata);
> +ret = av_dict_copy(>metadata, src->metadata, 0);
> +if (ret < 0)
> +return ret;
> +
> +ret = avcodec_parameters_copy(dst->codecpar, src->codecpar);
> +if (ret < 0)
> +return ret;
> +
> +ret = ff_stream_side_data_copy(dst, src);
> +if (ret < 0)
> +return ret;
> +
> +av_packet_unref(>attached_pic);
> +if (src->attached_pic.size > 0) {
> +ret = av_packet_ref(>attached_pic, >attached_pic);
> +if (ret < 0)
> +return ret;
> +}
> +
> +return 0;
> +}
> +
>  AVProgram *av_new_program(AVFormatContext *ac, int id)
>  {
>  AVProgram *program = NULL;
> diff --git a/libavformat/fifo.c b/libavformat/fifo.c
> index ead2bdc5cf..fef116d040 100644
> --- a/libavformat/fifo.c
> +++ b/libavformat/fifo.c
> @@ -509,7 +509,7 @@ static int fifo_mux_init(AVFormatContext *avf, const 
> AVOutputFormat *oformat,
>  if (!st)
>  return AVERROR(ENOMEM);
>
> -ret = ff_stream_encode_params_copy(st, avf->streams[i]);
> +ret = ff_stream_params_copy(st, avf->streams[i]);
>  if (ret < 0)
>  return ret;
>  }
> diff --git a/libavformat/internal.h b/libavformat/internal.h
> index b6b8fbf56f..87a00bbae3 100644
> --- a/libavformat/internal.h
> +++ b/libavformat/internal.h
> @@ -625,6 +625,18 @@ enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, 
> int be, int sflags);
>   */
>  int ff_stream_side_data_copy(AVStream *dst, const AVStream *src);
>
> +/**
> + * Copy all stream parameters from source to destination stream, with the
> + * exception of:
> + *  * the index field, which is usually set by avformat_new_stream()
> + *  * the attached_pic field, if attached_pic.size is 0 or less
> + *
> + * @param dst pointer to destination AVStream
> + * @param src pointer to source AVStream
> + * @return >=0 on success, AVERROR code on error
> + */
> +int ff_stream_params_copy(AVStream *dst, const AVStream *src);
> +
>  /**
>   * Wrap ffurl_move() and log if error happens.
>   *
> diff --git a/libavformat/mux.h b/libavformat/mux.h
> index c01da82194..1bfcaf795f 100644
> --- a/libavformat/mux.h
> +++ b/libavformat/mux.h
> @@ -113,15 +113,6 @@ int ff_format_shift_data(AVFormatContext *s, int64_t 
> read_start, int shift_size)
>   */
>  int ff_format_output_open(AVFormatContext *s, const char *url, 
> AVDictionary **options);
>
> -/**
> - * Copy encoding parameters from source to destination stream
> - *
> - * @param dst pointer to destination AVStream
> - * @param src 

[FFmpeg-devel] [PATCH] swscale/input: add VUYA input support

2022-08-04 Thread James Almer
Signed-off-by: James Almer 
---
 libswscale/input.c | 35 +++
 libswscale/utils.c |  1 +
 2 files changed, 36 insertions(+)

diff --git a/libswscale/input.c b/libswscale/input.c
index 750367b28b..68abc4d62c 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -650,6 +650,32 @@ static void read_ayuv64le_A_c(uint8_t *dst, const uint8_t 
*src, const uint8_t *u
 AV_WN16(dst + i * 2, AV_RL16(src + i * 8));
 }
 
+static void read_vuya_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t 
*unused0, const uint8_t *src,
+   const uint8_t *unused1, int width, uint32_t 
*unused2)
+{
+int i;
+for (i = 0; i < width; i++) {
+dstU[i] = src[i * 4 + 1];
+dstV[i] = src[i * 4];
+}
+}
+
+static void read_vuya_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t 
*unused0, const uint8_t *unused1, int width,
+  uint32_t *unused2)
+{
+int i;
+for (i = 0; i < width; i++)
+dst[i] = src[i * 4 + 2];
+}
+
+static void read_vuya_A_c(uint8_t *dst, const uint8_t *src, const uint8_t 
*unused0, const uint8_t *unused1, int width,
+  uint32_t *unused2)
+{
+int i;
+for (i = 0; i < width; i++)
+dst[i] = src[i * 4 + 3];
+}
+
 /* This is almost identical to the previous, end exists only because
  * yuy2ToY/UV)(dst, src + 1, ...) would have 100% unaligned accesses. */
 static void uyvyToY_c(uint8_t *dst, const uint8_t *src, const uint8_t 
*unused1, const uint8_t *unused2,  int width,
@@ -1229,6 +1255,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 c->chrToYV12 = bswap16UV_c;
 break;
 #endif
+case AV_PIX_FMT_VUYA:
+c->chrToYV12 = read_vuya_UV_c;
+break;
 case AV_PIX_FMT_AYUV64LE:
 c->chrToYV12 = read_ayuv64le_UV_c;
 break;
@@ -1591,6 +1620,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 case AV_PIX_FMT_YA16BE:
 c->lumToYV12 = read_ya16be_gray_c;
 break;
+case AV_PIX_FMT_VUYA:
+c->lumToYV12 = read_vuya_Y_c;
+break;
 case AV_PIX_FMT_AYUV64LE:
 c->lumToYV12 = read_ayuv64le_Y_c;
 break;
@@ -1746,6 +1778,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 case AV_PIX_FMT_YA16BE:
 c->alpToYV12 = read_ya16be_alpha_c;
 break;
+case AV_PIX_FMT_VUYA:
+c->alpToYV12 = read_vuya_A_c;
+break;
 case AV_PIX_FMT_AYUV64LE:
 c->alpToYV12 = read_ayuv64le_A_c;
 break;
diff --git a/libswscale/utils.c b/libswscale/utils.c
index c0504a6dfc..bc3d1c955c 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -258,6 +258,7 @@ static const FormatEntry format_entries[] = {
 [AV_PIX_FMT_P416BE]  = { 1, 1 },
 [AV_PIX_FMT_P416LE]  = { 1, 1 },
 [AV_PIX_FMT_NV16]= { 1, 1 },
+[AV_PIX_FMT_VUYA]= { 1, 0 },
 };
 
 int ff_shuffle_filter_coefficients(SwsContext *c, int *filterPos,
-- 
2.37.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 1/2] x86: Don't hardcode the height to 8 in sad8_xy2_mmx

2022-08-04 Thread Martin Storsjö

On Thu, 4 Aug 2022, Michael Niedermayer wrote:


On Thu, Aug 04, 2022 at 10:47:34AM +0300, Martin Storsjö wrote:

On Wed, 13 Jul 2022, Martin Storsjö wrote:


The height is hardcoded in some of the me_cmp functions, but not
in all of them. But in the case of all other functions, it's hardcoded
in the same place in SIMD functions as in the C reference functions,
while this one function differs from the behaviour of the C code.

(Before 542765ce3eccbca587d54262a512cbdb1407230d, there were a
couple other sad8_*_mmx functions with similar hardcoded height.)
---
libavcodec/x86/me_cmp_init.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/x86/me_cmp_init.c b/libavcodec/x86/me_cmp_init.c
index 61e9396b8f..dcc2621276 100644
--- a/libavcodec/x86/me_cmp_init.c
+++ b/libavcodec/x86/me_cmp_init.c
@@ -202,13 +202,12 @@ static inline int sum_mmx(void)
static int sad8_xy2_ ## suf(MpegEncContext *v, uint8_t *blk2,   \
uint8_t *blk1, ptrdiff_t stride, int h) \
{   \
-av_assert2(h == 8); \
__asm__ volatile (  \
"pxor %%mm7, %%mm7 \n\t"\
"pxor %%mm6, %%mm6 \n\t"\
::);\
\
-sad8_4_ ## suf(blk1, blk2, stride, 8);  \
+sad8_4_ ## suf(blk1, blk2, stride, h);  \
\
return sum_ ## suf();   \
}   \
--
2.25.1


Ping, does this seem reasonable? Michael indicated a desire to make the
me_cmp functions more general and flexible than what they are today, and
this would be a first step to making checkasm test such cases.


LGTM assuming it doesnt have any problematic perforamce impact


Thanks - I didn't notice any significant change in the checkasm bench 
numbers for it.


// Martin
___
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 v5 1/2] avformat: refactor ff_stream_encode_params_copy() to ff_stream_params_copy()

2022-08-04 Thread Pierre-Anthony Lemieux
On Thu, Aug 4, 2022 at 10:15 AM Andreas Rheinhardt
 wrote:
>
> Pierre-Anthony Lemieux:
> > On Thu, Aug 4, 2022 at 9:53 AM Andreas Rheinhardt
> >  wrote:
> >>
> >> p...@sandflow.com:
> >>> From: Pierre-Anthony Lemieux 
> >>>
> >>> As discussed at 
> >>> https://ffmpeg.org/pipermail/ffmpeg-devel/2022-July/298491.html.
> >>> Note that ff_stream_params_copy() does not copy:
> >>>  * the index field
> >>>  * the attached_pic if its size is 0
> >>>
> >>> Addresses http://ffmpeg.org/pipermail/ffmpeg-devel/2022-August/299514.html
> >>>
> >>> ---
> >>>  libavformat/avformat.c   | 40 
> >>>  libavformat/fifo.c   |  2 +-
> >>>  libavformat/internal.h   | 12 
> >>>  libavformat/mux.h|  9 -
> >>>  libavformat/mux_utils.c  | 28 
> >>>  libavformat/segment.c|  2 +-
> >>>  libavformat/tee.c|  2 +-
> >>>  libavformat/webm_chunk.c |  2 +-
> >>>  8 files changed, 56 insertions(+), 41 deletions(-)
> >>>
> >>> diff --git a/libavformat/avformat.c b/libavformat/avformat.c
> >>> index 30d6ea6a49..242187c359 100644
> >>> --- a/libavformat/avformat.c
> >>> +++ b/libavformat/avformat.c
> >>> @@ -235,6 +235,46 @@ int ff_stream_side_data_copy(AVStream *dst, const 
> >>> AVStream *src)
> >>>  return 0;
> >>>  }
> >>>
> >>> +int ff_stream_params_copy(AVStream *dst, const AVStream *src)
> >>> +{
> >>> +int ret;
> >>> +
> >>> +dst->id  = src->id;
> >>> +dst->time_base   = src->time_base;
> >>> +dst->start_time  = src->start_time;
> >>> +dst->duration= src->duration;
> >>> +dst->nb_frames   = src->nb_frames;
> >>> +dst->disposition = src->disposition;
> >>> +dst->discard = src->discard;
> >>> +dst->sample_aspect_ratio = src->sample_aspect_ratio;
> >>> +dst->avg_frame_rate  = src->avg_frame_rate;
> >>> +dst->event_flags = src->event_flags;
> >>> +dst->r_frame_rate= src->r_frame_rate;
> >>> +dst->pts_wrap_bits   = src->pts_wrap_bits;
> >>> +
> >>> +av_dict_free(>metadata);
> >>> +ret = av_dict_copy(>metadata, src->metadata, 0);
> >>> +if (ret < 0)
> >>> +return ret;
> >>> +
> >>> +ret = avcodec_parameters_copy(dst->codecpar, src->codecpar);
> >>> +if (ret < 0)
> >>> +return ret;
> >>> +
> >>> +ret = ff_stream_side_data_copy(dst, src);
> >>> +if (ret < 0)
> >>> +return ret;
> >>> +
> >>> +av_packet_unref(>attached_pic);
> >>> +if (src->attached_pic.size > 0) {
> >>> +ret = av_packet_ref(>attached_pic, >attached_pic);
> >>> +if (ret < 0)
> >>> +return ret;
> >>> +}
> >>> +
> >>> +return 0;
> >>> +}
> >>> +
> >>>  AVProgram *av_new_program(AVFormatContext *ac, int id)
> >>>  {
> >>>  AVProgram *program = NULL;
> >>> diff --git a/libavformat/fifo.c b/libavformat/fifo.c
> >>> index ead2bdc5cf..fef116d040 100644
> >>> --- a/libavformat/fifo.c
> >>> +++ b/libavformat/fifo.c
> >>> @@ -509,7 +509,7 @@ static int fifo_mux_init(AVFormatContext *avf, const 
> >>> AVOutputFormat *oformat,
> >>>  if (!st)
> >>>  return AVERROR(ENOMEM);
> >>>
> >>> -ret = ff_stream_encode_params_copy(st, avf->streams[i]);
> >>> +ret = ff_stream_params_copy(st, avf->streams[i]);
> >>>  if (ret < 0)
> >>>  return ret;
> >>>  }
> >>> diff --git a/libavformat/internal.h b/libavformat/internal.h
> >>> index b6b8fbf56f..87a00bbae3 100644
> >>> --- a/libavformat/internal.h
> >>> +++ b/libavformat/internal.h
> >>> @@ -625,6 +625,18 @@ enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, 
> >>> int be, int sflags);
> >>>   */
> >>>  int ff_stream_side_data_copy(AVStream *dst, const AVStream *src);
> >>>
> >>> +/**
> >>> + * Copy all stream parameters from source to destination stream, with the
> >>> + * exception of:
> >>> + *  * the index field, which is usually set by avformat_new_stream()
> >>> + *  * the attached_pic field, if attached_pic.size is 0 or less
> >>> + *
> >>> + * @param dst pointer to destination AVStream
> >>> + * @param src pointer to source AVStream
> >>> + * @return >=0 on success, AVERROR code on error
> >>> + */
> >>> +int ff_stream_params_copy(AVStream *dst, const AVStream *src);
> >>> +
> >>>  /**
> >>>   * Wrap ffurl_move() and log if error happens.
> >>>   *
> >>> diff --git a/libavformat/mux.h b/libavformat/mux.h
> >>> index c01da82194..1bfcaf795f 100644
> >>> --- a/libavformat/mux.h
> >>> +++ b/libavformat/mux.h
> >>> @@ -113,15 +113,6 @@ int ff_format_shift_data(AVFormatContext *s, int64_t 
> >>> read_start, int shift_size)
> >>>   */
> >>>  int ff_format_output_open(AVFormatContext *s, const char *url, 
> >>> AVDictionary **options);
> >>>
> >>> -/**
> >>> - * Copy encoding parameters from source to destination stream
> >>> - *
> >>> - * @param dst pointer to destination AVStream
> >>> - * @param src pointer to source AVStream
> >>> 

Re: [FFmpeg-devel] [PATCH 2/3 v2] avcodec/utils: add ff_thread_replace_frame()

2022-08-04 Thread James Almer

On 8/4/2022 3:33 PM, Michael Niedermayer wrote:

On Wed, Aug 03, 2022 at 01:02:47PM -0300, James Almer wrote:

Signed-off-by: James Almer 
---
  libavcodec/pthread_frame.c | 30 ++
  libavcodec/threadframe.h   |  3 +++
  libavcodec/utils.c | 21 +
  3 files changed, 54 insertions(+)

[...]

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index e73e3a7d08..44ed19458c 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -928,6 +928,27 @@ int ff_thread_get_ext_buffer(AVCodecContext *avctx, 
ThreadFrame *f, int flags)
  return ff_get_buffer(avctx, f->f, flags);
  }
  
+int ff_thread_replace_frame(AVCodecContext *avctx, , ThreadFrame *dst,

 ^^^
typo

thx


Fixed locally.
___
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/3 v2] avcodec/utils: add ff_thread_replace_frame()

2022-08-04 Thread Michael Niedermayer
On Wed, Aug 03, 2022 at 01:02:47PM -0300, James Almer wrote:
> Signed-off-by: James Almer 
> ---
>  libavcodec/pthread_frame.c | 30 ++
>  libavcodec/threadframe.h   |  3 +++
>  libavcodec/utils.c | 21 +
>  3 files changed, 54 insertions(+)
[...]
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index e73e3a7d08..44ed19458c 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -928,6 +928,27 @@ int ff_thread_get_ext_buffer(AVCodecContext *avctx, 
> ThreadFrame *f, int flags)
>  return ff_get_buffer(avctx, f->f, flags);
>  }
>  
> +int ff_thread_replace_frame(AVCodecContext *avctx, , ThreadFrame *dst,
^^^
typo

thx

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

There will always be a question for which you do not know the correct answer.


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 7/9] avcodec/cbs_jpeg: Use table-based alloc/free

2022-08-04 Thread Andreas Rheinhardt
cbs_jpeg was the last user of CBS that didn't use
CodedBitstreamUnitTypeDescriptors.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/cbs_internal.h |  7 
 libavcodec/cbs_jpeg.c | 76 ++-
 2 files changed, 34 insertions(+), 49 deletions(-)

diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
index 4030b76f1c..5ccba3c901 100644
--- a/libavcodec/cbs_internal.h
+++ b/libavcodec/cbs_internal.h
@@ -197,6 +197,13 @@ int ff_cbs_write_signed(CodedBitstreamContext *ctx, 
PutBitContext *pbc,
 .content_type   = CBS_CONTENT_TYPE_POD, \
 .content_size   = sizeof(structure), \
 }
+#define CBS_UNIT_RANGE_POD(range_start, range_end, structure) { \
+.nb_unit_types = CBS_UNIT_TYPE_RANGE, \
+.unit_type.range.start = range_start, \
+.unit_type.range.end   = range_end, \
+.content_type  = CBS_CONTENT_TYPE_POD, \
+.content_size  = sizeof(structure), \
+}
 
 #define CBS_UNIT_TYPES_INTERNAL_REF(types, structure, ref_field) { \
 .nb_unit_types  = FF_ARRAY_ELEMS((CodedBitstreamUnitType[])TYPE_LIST 
types), \
diff --git a/libavcodec/cbs_jpeg.c b/libavcodec/cbs_jpeg.c
index da7ee808cf..2afeecfa79 100644
--- a/libavcodec/cbs_jpeg.c
+++ b/libavcodec/cbs_jpeg.c
@@ -82,27 +82,6 @@
 #undef xu
 
 
-static void cbs_jpeg_free_application_data(void *opaque, uint8_t *content)
-{
-JPEGRawApplicationData *ad = (JPEGRawApplicationData*)content;
-av_buffer_unref(>Ap_ref);
-av_freep();
-}
-
-static void cbs_jpeg_free_comment(void *opaque, uint8_t *content)
-{
-JPEGRawComment *comment = (JPEGRawComment*)content;
-av_buffer_unref(>Cm_ref);
-av_freep();
-}
-
-static void cbs_jpeg_free_scan(void *opaque, uint8_t *content)
-{
-JPEGRawScan *scan = (JPEGRawScan*)content;
-av_buffer_unref(>data_ref);
-av_freep();
-}
-
 static int cbs_jpeg_split_fragment(CodedBitstreamContext *ctx,
CodedBitstreamFragment *frag,
int header)
@@ -248,41 +227,26 @@ static int cbs_jpeg_read_unit(CodedBitstreamContext *ctx,
 if (err < 0)
 return err;
 
+err = ff_cbs_alloc_unit_content2(ctx, unit);
+if (err < 0)
+return err;
+
 if (unit->type >= JPEG_MARKER_SOF0 &&
 unit->type <= JPEG_MARKER_SOF3) {
-err = ff_cbs_alloc_unit_content(unit,
-sizeof(JPEGRawFrameHeader),
-NULL);
-if (err < 0)
-return err;
-
 err = cbs_jpeg_read_frame_header(ctx, , unit->content);
 if (err < 0)
 return err;
 
 } else if (unit->type >= JPEG_MARKER_APPN &&
unit->type <= JPEG_MARKER_APPN + 15) {
-err = ff_cbs_alloc_unit_content(unit,
-sizeof(JPEGRawApplicationData),
-_jpeg_free_application_data);
-if (err < 0)
-return err;
-
 err = cbs_jpeg_read_application_data(ctx, , unit->content);
 if (err < 0)
 return err;
 
 } else if (unit->type == JPEG_MARKER_SOS) {
-JPEGRawScan *scan;
+JPEGRawScan *scan = unit->content;
 int pos;
 
-err = ff_cbs_alloc_unit_content(unit,
-sizeof(JPEGRawScan),
-_jpeg_free_scan);
-if (err < 0)
-return err;
-scan = unit->content;
-
 err = cbs_jpeg_read_scan_header(ctx, , >header);
 if (err < 0)
 return err;
@@ -299,21 +263,17 @@ static int cbs_jpeg_read_unit(CodedBitstreamContext *ctx,
 
 } else {
 switch (unit->type) {
-#define SEGMENT(marker, type, func, free) \
+#define SEGMENT(marker, func) \
 case JPEG_MARKER_ ## marker: \
 { \
-err = ff_cbs_alloc_unit_content(unit, \
-sizeof(type), free); \
-if (err < 0) \
-return err; \
 err = cbs_jpeg_read_ ## func(ctx, , unit->content); \
 if (err < 0) \
 return err; \
 } \
 break
-SEGMENT(DQT, JPEGRawQuantisationTableSpecification, dqt, NULL);
-SEGMENT(DHT, JPEGRawHuffmanTableSpecification,  dht, NULL);
-SEGMENT(COM, JPEGRawComment,  comment, _jpeg_free_comment);
+SEGMENT(DQT, dqt);
+SEGMENT(DHT, dht);
+SEGMENT(COM, comment);
 #undef SEGMENT
 default:
 return AVERROR(ENOSYS);
@@ -456,9 +416,27 @@ static int 
cbs_jpeg_assemble_fragment(CodedBitstreamContext *ctx,
 return 0;
 }
 
+static const CodedBitstreamUnitTypeDescriptor cbs_jpeg_unit_types[] = {
+CBS_UNIT_RANGE_POD(JPEG_MARKER_SOF0, JPEG_MARKER_SOF3, JPEGRawFrameHeader),
+
+CBS_UNIT_RANGE_INTERNAL_REF(JPEG_MARKER_APPN, 

[FFmpeg-devel] [PATCH 9/9] avcodec/cbs_h2645: Remove always-false check

2022-08-04 Thread Andreas Rheinhardt
The functions to replace parameter sets are only called
after the respective parameter set has just been read or
has just been written; all of these functions check
that the id field is within the appropriate range.
So the checks in the replace-functions can be removed.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/cbs_h2645.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index e0c617e81d..4ee06003c3 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -666,13 +666,7 @@ static int cbs_h26 ## h26n ## _replace_ ## 
ps_var(CodedBitstreamContext *ctx, \
 CodedBitstreamH26 ## h26n ## Context *priv = ctx->priv_data; \
 H26 ## h26n ## Raw ## ps_name *ps_var = unit->content; \
 unsigned int id = ps_var->id_element; \
-int err; \
-if (id >= FF_ARRAY_ELEMS(priv->ps_var)) { \
-av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid " #ps_name \
-   " id : %d.\n", id); \
-return AVERROR_INVALIDDATA; \
-} \
-err = ff_cbs_make_unit_refcounted(ctx, unit); \
+int err = ff_cbs_make_unit_refcounted(ctx, unit); \
 if (err < 0) \
 return err; \
 if (priv->ps_var[id] == priv->active_ ## ps_var) \
-- 
2.34.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 8/9] avcodec/cbs: Remove ff_cbs_alloc_unit_content

2022-08-04 Thread Andreas Rheinhardt
It is no longer used.
Also rename ff_cbs_alloc_unit_content2 to ff_cbs_alloc_unit_content.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/cbs.c   | 24 ++--
 libavcodec/cbs.h   | 13 ++---
 libavcodec/cbs_av1.c   |  2 +-
 libavcodec/cbs_h2645.c |  4 ++--
 libavcodec/cbs_jpeg.c  |  2 +-
 libavcodec/cbs_mpeg2.c |  2 +-
 libavcodec/cbs_sei.c   |  2 +-
 libavcodec/cbs_vp9.c   |  2 +-
 8 files changed, 11 insertions(+), 40 deletions(-)

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 57b57238ed..07ae658a4c 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -695,26 +695,6 @@ int ff_cbs_write_signed(CodedBitstreamContext *ctx, 
PutBitContext *pbc,
 }
 
 
-int ff_cbs_alloc_unit_content(CodedBitstreamUnit *unit,
-  size_t size,
-  void (*free)(void *opaque, uint8_t *data))
-{
-av_assert0(!unit->content && !unit->content_ref);
-
-unit->content = av_mallocz(size);
-if (!unit->content)
-return AVERROR(ENOMEM);
-
-unit->content_ref = av_buffer_create(unit->content, size,
- free, NULL, 0);
-if (!unit->content_ref) {
-av_freep(>content);
-return AVERROR(ENOMEM);
-}
-
-return 0;
-}
-
 static int cbs_insert_unit(CodedBitstreamFragment *frag,
int position)
 {
@@ -893,8 +873,8 @@ static const CodedBitstreamUnitTypeDescriptor
 return NULL;
 }
 
-int ff_cbs_alloc_unit_content2(CodedBitstreamContext *ctx,
-   CodedBitstreamUnit *unit)
+int ff_cbs_alloc_unit_content(CodedBitstreamContext *ctx,
+  CodedBitstreamUnit *unit)
 {
 const CodedBitstreamUnitTypeDescriptor *desc;
 
diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
index 5583063b5e..ee21623dac 100644
--- a/libavcodec/cbs.h
+++ b/libavcodec/cbs.h
@@ -363,22 +363,13 @@ void ff_cbs_fragment_reset(CodedBitstreamFragment *frag);
  */
 void ff_cbs_fragment_free(CodedBitstreamFragment *frag);
 
-/**
- * Allocate a new internal content buffer of the given size in the unit.
- *
- * The content will be zeroed.
- */
-int ff_cbs_alloc_unit_content(CodedBitstreamUnit *unit,
-  size_t size,
-  void (*free)(void *opaque, uint8_t *content));
-
 /**
  * Allocate a new internal content buffer matching the type of the unit.
  *
  * The content will be zeroed.
  */
-int ff_cbs_alloc_unit_content2(CodedBitstreamContext *ctx,
-   CodedBitstreamUnit *unit);
+int ff_cbs_alloc_unit_content(CodedBitstreamContext *ctx,
+  CodedBitstreamUnit *unit);
 
 /**
  * Insert a new unit into a fragment with the given content.
diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
index 1229480567..154d9156cf 100644
--- a/libavcodec/cbs_av1.c
+++ b/libavcodec/cbs_av1.c
@@ -878,7 +878,7 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx,
 GetBitContext gbc;
 int err, start_pos, end_pos;
 
-err = ff_cbs_alloc_unit_content2(ctx, unit);
+err = ff_cbs_alloc_unit_content(ctx, unit);
 if (err < 0)
 return err;
 obu = unit->content;
diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 117b609dc3..e0c617e81d 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -702,7 +702,7 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext 
*ctx,
 if (err < 0)
 return err;
 
-err = ff_cbs_alloc_unit_content2(ctx, unit);
+err = ff_cbs_alloc_unit_content(ctx, unit);
 if (err < 0)
 return err;
 
@@ -821,7 +821,7 @@ static int cbs_h265_read_nal_unit(CodedBitstreamContext 
*ctx,
 if (err < 0)
 return err;
 
-err = ff_cbs_alloc_unit_content2(ctx, unit);
+err = ff_cbs_alloc_unit_content(ctx, unit);
 if (err < 0)
 return err;
 
diff --git a/libavcodec/cbs_jpeg.c b/libavcodec/cbs_jpeg.c
index 2afeecfa79..5921d624a1 100644
--- a/libavcodec/cbs_jpeg.c
+++ b/libavcodec/cbs_jpeg.c
@@ -227,7 +227,7 @@ static int cbs_jpeg_read_unit(CodedBitstreamContext *ctx,
 if (err < 0)
 return err;
 
-err = ff_cbs_alloc_unit_content2(ctx, unit);
+err = ff_cbs_alloc_unit_content(ctx, unit);
 if (err < 0)
 return err;
 
diff --git a/libavcodec/cbs_mpeg2.c b/libavcodec/cbs_mpeg2.c
index 1c9519cdaf..04b0c7f87d 100644
--- a/libavcodec/cbs_mpeg2.c
+++ b/libavcodec/cbs_mpeg2.c
@@ -204,7 +204,7 @@ static int cbs_mpeg2_read_unit(CodedBitstreamContext *ctx,
 if (err < 0)
 return err;
 
-err = ff_cbs_alloc_unit_content2(ctx, unit);
+err = ff_cbs_alloc_unit_content(ctx, unit);
 if (err < 0)
 return err;
 
diff --git a/libavcodec/cbs_sei.c b/libavcodec/cbs_sei.c
index 141e97ec58..50a513f592 100644
--- a/libavcodec/cbs_sei.c
+++ b/libavcodec/cbs_sei.c
@@ -179,7 +179,7 @@ static int cbs_sei_get_unit(CodedBitstreamContext *ctx,
 unit = >units[position];
 unit->type = 

[FFmpeg-devel] [PATCH 6/9] avcodec/cbs_internal: Use unions to shrink size of descriptors

2022-08-04 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/cbs.c  | 26 +++
 libavcodec/cbs_internal.h | 69 ++-
 libavcodec/cbs_mpeg2.c| 10 +++---
 3 files changed, 57 insertions(+), 48 deletions(-)

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index c81297ec93..57b57238ed 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -857,8 +857,8 @@ static void cbs_default_free_unit_content(void *opaque, 
uint8_t *data)
 const CodedBitstreamUnitTypeDescriptor *desc = opaque;
 if (desc->content_type == CBS_CONTENT_TYPE_INTERNAL_REFS) {
 int i;
-for (i = 0; i < desc->nb_ref_offsets; i++) {
-void **ptr = (void**)(data + desc->ref_offsets[i]);
+for (i = 0; i < desc->type.ref.nb_offsets; i++) {
+void **ptr = (void**)(data + desc->type.ref.offsets[i]);
 av_buffer_unref((AVBufferRef**)(ptr + 1));
 }
 }
@@ -880,12 +880,12 @@ static const CodedBitstreamUnitTypeDescriptor
 if (desc->nb_unit_types == 0)
 break;
 if (desc->nb_unit_types == CBS_UNIT_TYPE_RANGE) {
-if (unit->type >= desc->unit_type_range_start &&
-unit->type <= desc->unit_type_range_end)
+if (unit->type >= desc->unit_type.range.start &&
+unit->type <= desc->unit_type.range.end)
 return desc;
 } else {
 for (j = 0; j < desc->nb_unit_types; j++) {
-if (desc->unit_types[j] == unit->type)
+if (desc->unit_type.list[j] == unit->type)
 return desc;
 }
 }
@@ -910,7 +910,8 @@ int ff_cbs_alloc_unit_content2(CodedBitstreamContext *ctx,
 
 unit->content_ref =
 av_buffer_create(unit->content, desc->content_size,
- desc->content_free ? desc->content_free
+ desc->content_type == CBS_CONTENT_TYPE_COMPLEX
+? desc->type.complex.content_free
 : cbs_default_free_unit_content,
  (void*)desc, 0);
 if (!unit->content_ref) {
@@ -936,10 +937,10 @@ static int 
cbs_clone_internal_refs_unit_content(AVBufferRef **clone_ref,
 if (!copy)
 return AVERROR(ENOMEM);
 
-for (i = 0; i < desc->nb_ref_offsets; i++) {
-const uint8_t *const *src_ptr = (const uint8_t* const*)(src + 
desc->ref_offsets[i]);
+for (i = 0; i < desc->type.ref.nb_offsets; i++) {
+const uint8_t *const *src_ptr = (const uint8_t* const*)(src + 
desc->type.ref.offsets[i]);
 const AVBufferRef *src_buf = *(AVBufferRef**)(src_ptr + 1);
-uint8_t **copy_ptr = (uint8_t**)(copy + desc->ref_offsets[i]);
+uint8_t **copy_ptr = (uint8_t**)(copy + desc->type.ref.offsets[i]);
 AVBufferRef **copy_buf = (AVBufferRef**)(copy_ptr + 1);
 
 if (!*src_ptr) {
@@ -962,7 +963,6 @@ static int cbs_clone_internal_refs_unit_content(AVBufferRef 
**clone_ref,
 }
 
 *clone_ref = av_buffer_create(copy, desc->content_size,
-  desc->content_free ? desc->content_free :
   cbs_default_free_unit_content,
   (void*)desc, 0);
 if (!*clone_ref) {
@@ -974,7 +974,7 @@ static int cbs_clone_internal_refs_unit_content(AVBufferRef 
**clone_ref,
 
 fail:
 for (--i; i >= 0; i--)
-av_buffer_unref((AVBufferRef**)(copy + desc->ref_offsets[i]));
+av_buffer_unref((AVBufferRef**)(copy + desc->type.ref.offsets[i]));
 av_freep();
 *clone_ref = NULL;
 return err;
@@ -1010,9 +1010,9 @@ static int cbs_clone_unit_content(CodedBitstreamContext 
*ctx,
 break;
 
 case CBS_CONTENT_TYPE_COMPLEX:
-if (!desc->content_clone)
+if (!desc->type.complex.content_clone)
 return AVERROR_PATCHWELCOME;
-err = desc->content_clone(, unit);
+err = desc->type.complex.content_clone(, unit);
 break;
 
 default:
diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
index 314d54daea..4030b76f1c 100644
--- a/libavcodec/cbs_internal.h
+++ b/libavcodec/cbs_internal.h
@@ -60,13 +60,16 @@ typedef const struct CodedBitstreamUnitTypeDescriptor {
 // used instead.
 int nb_unit_types;
 
-// Array of unit types that this entry describes.
-const CodedBitstreamUnitType unit_types[CBS_MAX_UNIT_TYPES];
-
-// Start and end of unit type range, used if nb_unit_types is
-// CBS_UNIT_TYPE_RANGE.
-const CodedBitstreamUnitType unit_type_range_start;
-const CodedBitstreamUnitType unit_type_range_end;
+union {
+// Array of unit types that this entry describes.
+CodedBitstreamUnitType list[CBS_MAX_UNIT_TYPES];
+// Start and end of unit type range, used if nb_unit_types is
+// CBS_UNIT_TYPE_RANGE.
+struct {
+CodedBitstreamUnitType start;
+

[FFmpeg-devel] [PATCH 5/9] avcodec/cbs_internal, cbs_h2645: Add and use new descriptor macros

2022-08-04 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/cbs_h2645.c| 56 ---
 libavcodec/cbs_internal.h | 31 +-
 2 files changed, 35 insertions(+), 52 deletions(-)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 12e38c80b5..117b609dc3 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -1396,18 +1396,9 @@ static const CodedBitstreamUnitTypeDescriptor 
cbs_h264_unit_types[] = {
 
 CBS_UNIT_TYPE_INTERNAL_REF(H264_NAL_PPS, H264RawPPS, slice_group_id),
 
-{
-.nb_unit_types  = 3,
-.unit_types = {
-H264_NAL_IDR_SLICE,
-H264_NAL_SLICE,
-H264_NAL_AUXILIARY_SLICE,
-},
-.content_type   = CBS_CONTENT_TYPE_INTERNAL_REFS,
-.content_size   = sizeof(H264RawSlice),
-.nb_ref_offsets = 1,
-.ref_offsets= { offsetof(H264RawSlice, data) },
-},
+CBS_UNIT_TYPES_INTERNAL_REF((H264_NAL_IDR_SLICE,
+ H264_NAL_SLICE,
+ H264_NAL_AUXILIARY_SLICE), H264RawSlice, 
data),
 
 CBS_UNIT_TYPE_POD(H264_NAL_AUD,  H264RawAUD),
 CBS_UNIT_TYPE_POD(H264_NAL_FILLER_DATA,  H264RawFiller),
@@ -1433,40 +1424,15 @@ static const CodedBitstreamUnitTypeDescriptor 
cbs_h265_unit_types[] = {
 
 CBS_UNIT_TYPE_POD(HEVC_NAL_AUD, H265RawAUD),
 
-{
-// Slices of non-IRAP pictures.
-.nb_unit_types = CBS_UNIT_TYPE_RANGE,
-.unit_type_range_start = HEVC_NAL_TRAIL_N,
-.unit_type_range_end   = HEVC_NAL_RASL_R,
-
-.content_type   = CBS_CONTENT_TYPE_INTERNAL_REFS,
-.content_size   = sizeof(H265RawSlice),
-.nb_ref_offsets = 1,
-.ref_offsets= { offsetof(H265RawSlice, data) },
-},
+// Slices of non-IRAP pictures.
+CBS_UNIT_RANGE_INTERNAL_REF(HEVC_NAL_TRAIL_N, HEVC_NAL_RASL_R,
+H265RawSlice, data),
+// Slices of IRAP pictures.
+CBS_UNIT_RANGE_INTERNAL_REF(HEVC_NAL_BLA_W_LP, HEVC_NAL_CRA_NUT,
+H265RawSlice, data),
 
-{
-// Slices of IRAP pictures.
-.nb_unit_types = CBS_UNIT_TYPE_RANGE,
-.unit_type_range_start = HEVC_NAL_BLA_W_LP,
-.unit_type_range_end   = HEVC_NAL_CRA_NUT,
-
-.content_type   = CBS_CONTENT_TYPE_INTERNAL_REFS,
-.content_size   = sizeof(H265RawSlice),
-.nb_ref_offsets = 1,
-.ref_offsets= { offsetof(H265RawSlice, data) },
-},
-
-{
-.nb_unit_types  = 2,
-.unit_types = {
-HEVC_NAL_SEI_PREFIX,
-HEVC_NAL_SEI_SUFFIX
-},
-.content_type   = CBS_CONTENT_TYPE_COMPLEX,
-.content_size   = sizeof(H265RawSEI),
-.content_free   = _h265_free_sei,
-},
+CBS_UNIT_TYPES_COMPLEX((HEVC_NAL_SEI_PREFIX, HEVC_NAL_SEI_SUFFIX),
+   H265RawSEI, cbs_h265_free_sei),
 
 CBS_UNIT_TYPE_END_OF_LIST
 };
diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
index f853086fa3..314d54daea 100644
--- a/libavcodec/cbs_internal.h
+++ b/libavcodec/cbs_internal.h
@@ -181,28 +181,45 @@ int ff_cbs_write_signed(CodedBitstreamContext *ctx, 
PutBitContext *pbc,
 // range_min in the above functions.
 #define MIN_INT_BITS(length) (-(INT64_C(1) << ((length) - 1)))
 
-
+#define TYPE_LIST(...) { __VA_ARGS__ }
 #define CBS_UNIT_TYPE_POD(type, structure) { \
 .nb_unit_types  = 1, \
 .unit_types = { type }, \
 .content_type   = CBS_CONTENT_TYPE_POD, \
 .content_size   = sizeof(structure), \
 }
-#define CBS_UNIT_TYPE_INTERNAL_REF(type, structure, ref_field) { \
-.nb_unit_types  = 1, \
-.unit_types = { type }, \
+
+#define CBS_UNIT_TYPES_INTERNAL_REF(types, structure, ref_field) { \
+.nb_unit_types  = FF_ARRAY_ELEMS((CodedBitstreamUnitType[])TYPE_LIST 
types), \
+.unit_types = TYPE_LIST types, \
 .content_type   = CBS_CONTENT_TYPE_INTERNAL_REFS, \
 .content_size   = sizeof(structure), \
 .nb_ref_offsets = 1, \
 .ref_offsets= { offsetof(structure, ref_field) }, \
 }
-#define CBS_UNIT_TYPE_COMPLEX(type, structure, free_func) { \
-.nb_unit_types  = 1, \
-.unit_types = { type }, \
+#define CBS_UNIT_TYPE_INTERNAL_REF(type, structure, ref_field) \
+CBS_UNIT_TYPES_INTERNAL_REF((type), structure, ref_field)
+
+#define CBS_UNIT_RANGE_INTERNAL_REF(range_start, range_end, structure, 
ref_field) { \
+.nb_unit_types  = CBS_UNIT_TYPE_RANGE, \
+.unit_type_range_start = range_start, \
+.unit_type_range_end   = range_end, \
+.content_type  = CBS_CONTENT_TYPE_INTERNAL_REFS, \
+.content_size  = sizeof(structure), \
+.nb_ref_offsets= 1, \
+.ref_offsets   = { offsetof(structure, ref_field) }, \
+}
+
+#define CBS_UNIT_TYPES_COMPLEX(types, structure, 

[FFmpeg-devel] [PATCH 4/9] avcodec/cbs: Use smaller scope for variables, add const

2022-08-04 Thread Andreas Rheinhardt
And also avoid an unnecessary indirection for src_buf.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/cbs.c | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 43329a14a4..c81297ec93 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -925,9 +925,8 @@ static int cbs_clone_internal_refs_unit_content(AVBufferRef 
**clone_ref,
 const CodedBitstreamUnit *unit,
 const 
CodedBitstreamUnitTypeDescriptor *desc)
 {
-uint8_t *src, *copy;
-uint8_t **src_ptr, **copy_ptr;
-AVBufferRef **src_buf, **copy_buf;
+const uint8_t *src;
+uint8_t *copy;
 int err, i;
 
 av_assert0(unit->content);
@@ -938,16 +937,16 @@ static int 
cbs_clone_internal_refs_unit_content(AVBufferRef **clone_ref,
 return AVERROR(ENOMEM);
 
 for (i = 0; i < desc->nb_ref_offsets; i++) {
-src_ptr  = (uint8_t**)(src + desc->ref_offsets[i]);
-src_buf  = (AVBufferRef**)(src_ptr + 1);
-copy_ptr = (uint8_t**)(copy + desc->ref_offsets[i]);
-copy_buf = (AVBufferRef**)(copy_ptr + 1);
+const uint8_t *const *src_ptr = (const uint8_t* const*)(src + 
desc->ref_offsets[i]);
+const AVBufferRef *src_buf = *(AVBufferRef**)(src_ptr + 1);
+uint8_t **copy_ptr = (uint8_t**)(copy + desc->ref_offsets[i]);
+AVBufferRef **copy_buf = (AVBufferRef**)(copy_ptr + 1);
 
 if (!*src_ptr) {
-av_assert0(!*src_buf);
+av_assert0(!src_buf);
 continue;
 }
-if (!*src_buf) {
+if (!src_buf) {
 // We can't handle a non-refcounted pointer here - we don't
 // have enough information to handle whatever structure lies
 // at the other end of it.
@@ -955,7 +954,7 @@ static int cbs_clone_internal_refs_unit_content(AVBufferRef 
**clone_ref,
 goto fail;
 }
 
-*copy_buf = av_buffer_ref(*src_buf);
+*copy_buf = av_buffer_ref(src_buf);
 if (!*copy_buf) {
 err = AVERROR(ENOMEM);
 goto fail;
-- 
2.34.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 3/9] avcodec/cbs: Remove redundant assignment

2022-08-04 Thread Andreas Rheinhardt
The code just creates new references without allocating
new buffers for the subobjects; therefore the actual data pointer
stays valid and need not be updated.

Also remove an assert that ensured that the calculation
for updating the pointer makes sense.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/cbs.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index f715e463a1..43329a14a4 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -955,17 +955,11 @@ static int 
cbs_clone_internal_refs_unit_content(AVBufferRef **clone_ref,
 goto fail;
 }
 
-// src_ptr is required to point somewhere inside src_buf.  If it
-// doesn't, there is a bug somewhere.
-av_assert0(*src_ptr >= (*src_buf)->data &&
-   *src_ptr <  (*src_buf)->data + (*src_buf)->size);
-
 *copy_buf = av_buffer_ref(*src_buf);
 if (!*copy_buf) {
 err = AVERROR(ENOMEM);
 goto fail;
 }
-*copy_ptr = (*copy_buf)->data + (*src_ptr - (*src_buf)->data);
 }
 
 *clone_ref = av_buffer_create(copy, desc->content_size,
-- 
2.34.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 2/9] avcodec/cbs: Avoid code duplication for making unit refcounted/writable

2022-08-04 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/cbs.c | 74 
 1 file changed, 25 insertions(+), 49 deletions(-)

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 8c0a5b5719..f715e463a1 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -921,9 +921,9 @@ int ff_cbs_alloc_unit_content2(CodedBitstreamContext *ctx,
 return 0;
 }
 
-static int cbs_clone_unit_content(AVBufferRef **clone_ref,
-  CodedBitstreamUnit *unit,
-  const CodedBitstreamUnitTypeDescriptor *desc)
+static int cbs_clone_internal_refs_unit_content(AVBufferRef **clone_ref,
+const CodedBitstreamUnit *unit,
+const 
CodedBitstreamUnitTypeDescriptor *desc)
 {
 uint8_t *src, *copy;
 uint8_t **src_ptr, **copy_ptr;
@@ -987,19 +987,18 @@ fail:
 return err;
 }
 
-int ff_cbs_make_unit_refcounted(CodedBitstreamContext *ctx,
-CodedBitstreamUnit *unit)
+/*
+ * On success, unit->content and unit->content_ref are updated with
+ * the new content; unit is untouched on failure.
+ * Any old content_ref is simply overwritten and not freed.
+ */
+static int cbs_clone_unit_content(CodedBitstreamContext *ctx,
+  CodedBitstreamUnit *unit)
 {
 const CodedBitstreamUnitTypeDescriptor *desc;
 AVBufferRef *ref;
 int err;
 
-av_assert0(unit->content);
-if (unit->content_ref) {
-// Already refcounted, nothing to do.
-return 0;
-}
-
 desc = cbs_find_unit_type_desc(ctx, unit);
 if (!desc)
 return AVERROR(ENOSYS);
@@ -1014,7 +1013,7 @@ int ff_cbs_make_unit_refcounted(CodedBitstreamContext 
*ctx,
 break;
 
 case CBS_CONTENT_TYPE_INTERNAL_REFS:
-err = cbs_clone_unit_content(, unit, desc);
+err = cbs_clone_internal_refs_unit_content(, unit, desc);
 break;
 
 case CBS_CONTENT_TYPE_COMPLEX:
@@ -1035,51 +1034,28 @@ int ff_cbs_make_unit_refcounted(CodedBitstreamContext 
*ctx,
 return 0;
 }
 
+int ff_cbs_make_unit_refcounted(CodedBitstreamContext *ctx,
+CodedBitstreamUnit *unit)
+{
+av_assert0(unit->content);
+if (unit->content_ref)
+return 0;
+return cbs_clone_unit_content(ctx, unit);
+}
+
 int ff_cbs_make_unit_writable(CodedBitstreamContext *ctx,
   CodedBitstreamUnit *unit)
 {
-const CodedBitstreamUnitTypeDescriptor *desc;
-AVBufferRef *ref;
+AVBufferRef *ref = unit->content_ref;
 int err;
 
-// This can only be applied to refcounted units.
-err = ff_cbs_make_unit_refcounted(ctx, unit);
-if (err < 0)
-return err;
-av_assert0(unit->content && unit->content_ref);
-
-if (av_buffer_is_writable(unit->content_ref))
+av_assert0(unit->content);
+if (ref && av_buffer_is_writable(ref))
 return 0;
 
-desc = cbs_find_unit_type_desc(ctx, unit);
-if (!desc)
-return AVERROR(ENOSYS);
-
-switch (desc->content_type) {
-case CBS_CONTENT_TYPE_POD:
-err = av_buffer_make_writable(>content_ref);
-break;
-
-case CBS_CONTENT_TYPE_INTERNAL_REFS:
-err = cbs_clone_unit_content(, unit, desc);
-break;
-
-case CBS_CONTENT_TYPE_COMPLEX:
-if (!desc->content_clone)
-return AVERROR_PATCHWELCOME;
-err = desc->content_clone(, unit);
-break;
-
-default:
-av_assert0(0 && "Invalid content type.");
-}
+err = cbs_clone_unit_content(ctx, unit);
 if (err < 0)
 return err;
-
-if (desc->content_type != CBS_CONTENT_TYPE_POD) {
-av_buffer_unref(>content_ref);
-unit->content_ref = ref;
-}
-unit->content = unit->content_ref->data;
+av_buffer_unref();
 return 0;
 }
-- 
2.34.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/9] avcodec/error_resilience: Avoid overhead of AVBuffer API

2022-08-04 Thread Andreas Rheinhardt
These buffers are not shared in any way.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/error_resilience.c | 18 +-
 libavcodec/error_resilience.h |  4 ++--
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
index f957c68d2c..2aa6f1d864 100644
--- a/libavcodec/error_resilience.c
+++ b/libavcodec/error_resilience.c
@@ -946,17 +946,17 @@ void ff_er_frame_end(ERContext *s)
 av_log(s->avctx, AV_LOG_ERROR, "Warning MVs not available\n");
 
 for (i = 0; i < 2; i++) {
-s->ref_index_buf[i]  = av_buffer_allocz(s->mb_stride * 
s->mb_height * 4 * sizeof(uint8_t));
-s->motion_val_buf[i] = av_buffer_allocz((size + 4) * 2 * 
sizeof(uint16_t));
-if (!s->ref_index_buf[i] || !s->motion_val_buf[i])
+s->ref_index[i]   = av_calloc(s->mb_stride * s->mb_height, 4 * 
sizeof(uint8_t));
+s->motion_val_base[i] = av_calloc(size + 4, 2 * sizeof(uint16_t));
+if (!s->ref_index[i] || !s->motion_val_base[i])
 break;
-s->cur_pic.ref_index[i]  = s->ref_index_buf[i]->data;
-s->cur_pic.motion_val[i] = (int16_t 
(*)[2])s->motion_val_buf[i]->data + 4;
+s->cur_pic.ref_index[i]  = s->ref_index[i];
+s->cur_pic.motion_val[i] = s->motion_val_base[i] + 4;
 }
 if (i < 2) {
 for (i = 0; i < 2; i++) {
-av_buffer_unref(>ref_index_buf[i]);
-av_buffer_unref(>motion_val_buf[i]);
+av_freep(>ref_index[i]);
+av_freep(>motion_val_base[i]);
 s->cur_pic.ref_index[i]  = NULL;
 s->cur_pic.motion_val[i] = NULL;
 }
@@ -1343,8 +1343,8 @@ void ff_er_frame_end(ERContext *s)
 }
 
 for (i = 0; i < 2; i++) {
-av_buffer_unref(>ref_index_buf[i]);
-av_buffer_unref(>motion_val_buf[i]);
+av_freep(>ref_index[i]);
+av_freep(>motion_val_base[i]);
 s->cur_pic.ref_index[i]  = NULL;
 s->cur_pic.motion_val[i] = NULL;
 }
diff --git a/libavcodec/error_resilience.h b/libavcodec/error_resilience.h
index 53e5cf2621..47cc8a4fc6 100644
--- a/libavcodec/error_resilience.h
+++ b/libavcodec/error_resilience.h
@@ -75,8 +75,8 @@ typedef struct ERContext {
 ERPicture last_pic;
 ERPicture next_pic;
 
-AVBufferRef *ref_index_buf[2];
-AVBufferRef *motion_val_buf[2];
+int8_t *ref_index[2];
+int16_t (*motion_val_base[2])[2];
 
 uint16_t pp_time;
 uint16_t pb_time;
-- 
2.34.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 v5 1/2] avformat: refactor ff_stream_encode_params_copy() to ff_stream_params_copy()

2022-08-04 Thread Andreas Rheinhardt
Pierre-Anthony Lemieux:
> On Thu, Aug 4, 2022 at 9:53 AM Andreas Rheinhardt
>  wrote:
>>
>> p...@sandflow.com:
>>> From: Pierre-Anthony Lemieux 
>>>
>>> As discussed at 
>>> https://ffmpeg.org/pipermail/ffmpeg-devel/2022-July/298491.html.
>>> Note that ff_stream_params_copy() does not copy:
>>>  * the index field
>>>  * the attached_pic if its size is 0
>>>
>>> Addresses http://ffmpeg.org/pipermail/ffmpeg-devel/2022-August/299514.html
>>>
>>> ---
>>>  libavformat/avformat.c   | 40 
>>>  libavformat/fifo.c   |  2 +-
>>>  libavformat/internal.h   | 12 
>>>  libavformat/mux.h|  9 -
>>>  libavformat/mux_utils.c  | 28 
>>>  libavformat/segment.c|  2 +-
>>>  libavformat/tee.c|  2 +-
>>>  libavformat/webm_chunk.c |  2 +-
>>>  8 files changed, 56 insertions(+), 41 deletions(-)
>>>
>>> diff --git a/libavformat/avformat.c b/libavformat/avformat.c
>>> index 30d6ea6a49..242187c359 100644
>>> --- a/libavformat/avformat.c
>>> +++ b/libavformat/avformat.c
>>> @@ -235,6 +235,46 @@ int ff_stream_side_data_copy(AVStream *dst, const 
>>> AVStream *src)
>>>  return 0;
>>>  }
>>>
>>> +int ff_stream_params_copy(AVStream *dst, const AVStream *src)
>>> +{
>>> +int ret;
>>> +
>>> +dst->id  = src->id;
>>> +dst->time_base   = src->time_base;
>>> +dst->start_time  = src->start_time;
>>> +dst->duration= src->duration;
>>> +dst->nb_frames   = src->nb_frames;
>>> +dst->disposition = src->disposition;
>>> +dst->discard = src->discard;
>>> +dst->sample_aspect_ratio = src->sample_aspect_ratio;
>>> +dst->avg_frame_rate  = src->avg_frame_rate;
>>> +dst->event_flags = src->event_flags;
>>> +dst->r_frame_rate= src->r_frame_rate;
>>> +dst->pts_wrap_bits   = src->pts_wrap_bits;
>>> +
>>> +av_dict_free(>metadata);
>>> +ret = av_dict_copy(>metadata, src->metadata, 0);
>>> +if (ret < 0)
>>> +return ret;
>>> +
>>> +ret = avcodec_parameters_copy(dst->codecpar, src->codecpar);
>>> +if (ret < 0)
>>> +return ret;
>>> +
>>> +ret = ff_stream_side_data_copy(dst, src);
>>> +if (ret < 0)
>>> +return ret;
>>> +
>>> +av_packet_unref(>attached_pic);
>>> +if (src->attached_pic.size > 0) {
>>> +ret = av_packet_ref(>attached_pic, >attached_pic);
>>> +if (ret < 0)
>>> +return ret;
>>> +}
>>> +
>>> +return 0;
>>> +}
>>> +
>>>  AVProgram *av_new_program(AVFormatContext *ac, int id)
>>>  {
>>>  AVProgram *program = NULL;
>>> diff --git a/libavformat/fifo.c b/libavformat/fifo.c
>>> index ead2bdc5cf..fef116d040 100644
>>> --- a/libavformat/fifo.c
>>> +++ b/libavformat/fifo.c
>>> @@ -509,7 +509,7 @@ static int fifo_mux_init(AVFormatContext *avf, const 
>>> AVOutputFormat *oformat,
>>>  if (!st)
>>>  return AVERROR(ENOMEM);
>>>
>>> -ret = ff_stream_encode_params_copy(st, avf->streams[i]);
>>> +ret = ff_stream_params_copy(st, avf->streams[i]);
>>>  if (ret < 0)
>>>  return ret;
>>>  }
>>> diff --git a/libavformat/internal.h b/libavformat/internal.h
>>> index b6b8fbf56f..87a00bbae3 100644
>>> --- a/libavformat/internal.h
>>> +++ b/libavformat/internal.h
>>> @@ -625,6 +625,18 @@ enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, 
>>> int be, int sflags);
>>>   */
>>>  int ff_stream_side_data_copy(AVStream *dst, const AVStream *src);
>>>
>>> +/**
>>> + * Copy all stream parameters from source to destination stream, with the
>>> + * exception of:
>>> + *  * the index field, which is usually set by avformat_new_stream()
>>> + *  * the attached_pic field, if attached_pic.size is 0 or less
>>> + *
>>> + * @param dst pointer to destination AVStream
>>> + * @param src pointer to source AVStream
>>> + * @return >=0 on success, AVERROR code on error
>>> + */
>>> +int ff_stream_params_copy(AVStream *dst, const AVStream *src);
>>> +
>>>  /**
>>>   * Wrap ffurl_move() and log if error happens.
>>>   *
>>> diff --git a/libavformat/mux.h b/libavformat/mux.h
>>> index c01da82194..1bfcaf795f 100644
>>> --- a/libavformat/mux.h
>>> +++ b/libavformat/mux.h
>>> @@ -113,15 +113,6 @@ int ff_format_shift_data(AVFormatContext *s, int64_t 
>>> read_start, int shift_size)
>>>   */
>>>  int ff_format_output_open(AVFormatContext *s, const char *url, 
>>> AVDictionary **options);
>>>
>>> -/**
>>> - * Copy encoding parameters from source to destination stream
>>> - *
>>> - * @param dst pointer to destination AVStream
>>> - * @param src pointer to source AVStream
>>> - * @return >=0 on success, AVERROR code on error
>>> - */
>>> -int ff_stream_encode_params_copy(AVStream *dst, const AVStream *src);
>>> -
>>>  /**
>>>   * Parse creation_time in AVFormatContext metadata if exists and warn if 
>>> the
>>>   * parsing fails.
>>> diff --git a/libavformat/mux_utils.c b/libavformat/mux_utils.c

Re: [FFmpeg-devel] [PATCH v5 1/2] avformat: refactor ff_stream_encode_params_copy() to ff_stream_params_copy()

2022-08-04 Thread Pierre-Anthony Lemieux
On Thu, Aug 4, 2022 at 9:53 AM Andreas Rheinhardt
 wrote:
>
> p...@sandflow.com:
> > From: Pierre-Anthony Lemieux 
> >
> > As discussed at 
> > https://ffmpeg.org/pipermail/ffmpeg-devel/2022-July/298491.html.
> > Note that ff_stream_params_copy() does not copy:
> >  * the index field
> >  * the attached_pic if its size is 0
> >
> > Addresses http://ffmpeg.org/pipermail/ffmpeg-devel/2022-August/299514.html
> >
> > ---
> >  libavformat/avformat.c   | 40 
> >  libavformat/fifo.c   |  2 +-
> >  libavformat/internal.h   | 12 
> >  libavformat/mux.h|  9 -
> >  libavformat/mux_utils.c  | 28 
> >  libavformat/segment.c|  2 +-
> >  libavformat/tee.c|  2 +-
> >  libavformat/webm_chunk.c |  2 +-
> >  8 files changed, 56 insertions(+), 41 deletions(-)
> >
> > diff --git a/libavformat/avformat.c b/libavformat/avformat.c
> > index 30d6ea6a49..242187c359 100644
> > --- a/libavformat/avformat.c
> > +++ b/libavformat/avformat.c
> > @@ -235,6 +235,46 @@ int ff_stream_side_data_copy(AVStream *dst, const 
> > AVStream *src)
> >  return 0;
> >  }
> >
> > +int ff_stream_params_copy(AVStream *dst, const AVStream *src)
> > +{
> > +int ret;
> > +
> > +dst->id  = src->id;
> > +dst->time_base   = src->time_base;
> > +dst->start_time  = src->start_time;
> > +dst->duration= src->duration;
> > +dst->nb_frames   = src->nb_frames;
> > +dst->disposition = src->disposition;
> > +dst->discard = src->discard;
> > +dst->sample_aspect_ratio = src->sample_aspect_ratio;
> > +dst->avg_frame_rate  = src->avg_frame_rate;
> > +dst->event_flags = src->event_flags;
> > +dst->r_frame_rate= src->r_frame_rate;
> > +dst->pts_wrap_bits   = src->pts_wrap_bits;
> > +
> > +av_dict_free(>metadata);
> > +ret = av_dict_copy(>metadata, src->metadata, 0);
> > +if (ret < 0)
> > +return ret;
> > +
> > +ret = avcodec_parameters_copy(dst->codecpar, src->codecpar);
> > +if (ret < 0)
> > +return ret;
> > +
> > +ret = ff_stream_side_data_copy(dst, src);
> > +if (ret < 0)
> > +return ret;
> > +
> > +av_packet_unref(>attached_pic);
> > +if (src->attached_pic.size > 0) {
> > +ret = av_packet_ref(>attached_pic, >attached_pic);
> > +if (ret < 0)
> > +return ret;
> > +}
> > +
> > +return 0;
> > +}
> > +
> >  AVProgram *av_new_program(AVFormatContext *ac, int id)
> >  {
> >  AVProgram *program = NULL;
> > diff --git a/libavformat/fifo.c b/libavformat/fifo.c
> > index ead2bdc5cf..fef116d040 100644
> > --- a/libavformat/fifo.c
> > +++ b/libavformat/fifo.c
> > @@ -509,7 +509,7 @@ static int fifo_mux_init(AVFormatContext *avf, const 
> > AVOutputFormat *oformat,
> >  if (!st)
> >  return AVERROR(ENOMEM);
> >
> > -ret = ff_stream_encode_params_copy(st, avf->streams[i]);
> > +ret = ff_stream_params_copy(st, avf->streams[i]);
> >  if (ret < 0)
> >  return ret;
> >  }
> > diff --git a/libavformat/internal.h b/libavformat/internal.h
> > index b6b8fbf56f..87a00bbae3 100644
> > --- a/libavformat/internal.h
> > +++ b/libavformat/internal.h
> > @@ -625,6 +625,18 @@ enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, 
> > int be, int sflags);
> >   */
> >  int ff_stream_side_data_copy(AVStream *dst, const AVStream *src);
> >
> > +/**
> > + * Copy all stream parameters from source to destination stream, with the
> > + * exception of:
> > + *  * the index field, which is usually set by avformat_new_stream()
> > + *  * the attached_pic field, if attached_pic.size is 0 or less
> > + *
> > + * @param dst pointer to destination AVStream
> > + * @param src pointer to source AVStream
> > + * @return >=0 on success, AVERROR code on error
> > + */
> > +int ff_stream_params_copy(AVStream *dst, const AVStream *src);
> > +
> >  /**
> >   * Wrap ffurl_move() and log if error happens.
> >   *
> > diff --git a/libavformat/mux.h b/libavformat/mux.h
> > index c01da82194..1bfcaf795f 100644
> > --- a/libavformat/mux.h
> > +++ b/libavformat/mux.h
> > @@ -113,15 +113,6 @@ int ff_format_shift_data(AVFormatContext *s, int64_t 
> > read_start, int shift_size)
> >   */
> >  int ff_format_output_open(AVFormatContext *s, const char *url, 
> > AVDictionary **options);
> >
> > -/**
> > - * Copy encoding parameters from source to destination stream
> > - *
> > - * @param dst pointer to destination AVStream
> > - * @param src pointer to source AVStream
> > - * @return >=0 on success, AVERROR code on error
> > - */
> > -int ff_stream_encode_params_copy(AVStream *dst, const AVStream *src);
> > -
> >  /**
> >   * Parse creation_time in AVFormatContext metadata if exists and warn if 
> > the
> >   * parsing fails.
> > diff --git a/libavformat/mux_utils.c b/libavformat/mux_utils.c
> > index 

Re: [FFmpeg-devel] [PATCH v5 1/2] avformat: refactor ff_stream_encode_params_copy() to ff_stream_params_copy()

2022-08-04 Thread Andreas Rheinhardt
p...@sandflow.com:
> From: Pierre-Anthony Lemieux 
> 
> As discussed at 
> https://ffmpeg.org/pipermail/ffmpeg-devel/2022-July/298491.html.
> Note that ff_stream_params_copy() does not copy:
>  * the index field
>  * the attached_pic if its size is 0
> 
> Addresses http://ffmpeg.org/pipermail/ffmpeg-devel/2022-August/299514.html
> 
> ---
>  libavformat/avformat.c   | 40 
>  libavformat/fifo.c   |  2 +-
>  libavformat/internal.h   | 12 
>  libavformat/mux.h|  9 -
>  libavformat/mux_utils.c  | 28 
>  libavformat/segment.c|  2 +-
>  libavformat/tee.c|  2 +-
>  libavformat/webm_chunk.c |  2 +-
>  8 files changed, 56 insertions(+), 41 deletions(-)
> 
> diff --git a/libavformat/avformat.c b/libavformat/avformat.c
> index 30d6ea6a49..242187c359 100644
> --- a/libavformat/avformat.c
> +++ b/libavformat/avformat.c
> @@ -235,6 +235,46 @@ int ff_stream_side_data_copy(AVStream *dst, const 
> AVStream *src)
>  return 0;
>  }
>  
> +int ff_stream_params_copy(AVStream *dst, const AVStream *src)
> +{
> +int ret;
> +
> +dst->id  = src->id;
> +dst->time_base   = src->time_base;
> +dst->start_time  = src->start_time;
> +dst->duration= src->duration;
> +dst->nb_frames   = src->nb_frames;
> +dst->disposition = src->disposition;
> +dst->discard = src->discard;
> +dst->sample_aspect_ratio = src->sample_aspect_ratio;
> +dst->avg_frame_rate  = src->avg_frame_rate;
> +dst->event_flags = src->event_flags;
> +dst->r_frame_rate= src->r_frame_rate;
> +dst->pts_wrap_bits   = src->pts_wrap_bits;
> +
> +av_dict_free(>metadata);
> +ret = av_dict_copy(>metadata, src->metadata, 0);
> +if (ret < 0)
> +return ret;
> +
> +ret = avcodec_parameters_copy(dst->codecpar, src->codecpar);
> +if (ret < 0)
> +return ret;
> +
> +ret = ff_stream_side_data_copy(dst, src);
> +if (ret < 0)
> +return ret;
> +
> +av_packet_unref(>attached_pic);
> +if (src->attached_pic.size > 0) {
> +ret = av_packet_ref(>attached_pic, >attached_pic);
> +if (ret < 0)
> +return ret;
> +}
> +
> +return 0;
> +}
> +
>  AVProgram *av_new_program(AVFormatContext *ac, int id)
>  {
>  AVProgram *program = NULL;
> diff --git a/libavformat/fifo.c b/libavformat/fifo.c
> index ead2bdc5cf..fef116d040 100644
> --- a/libavformat/fifo.c
> +++ b/libavformat/fifo.c
> @@ -509,7 +509,7 @@ static int fifo_mux_init(AVFormatContext *avf, const 
> AVOutputFormat *oformat,
>  if (!st)
>  return AVERROR(ENOMEM);
>  
> -ret = ff_stream_encode_params_copy(st, avf->streams[i]);
> +ret = ff_stream_params_copy(st, avf->streams[i]);
>  if (ret < 0)
>  return ret;
>  }
> diff --git a/libavformat/internal.h b/libavformat/internal.h
> index b6b8fbf56f..87a00bbae3 100644
> --- a/libavformat/internal.h
> +++ b/libavformat/internal.h
> @@ -625,6 +625,18 @@ enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, int 
> be, int sflags);
>   */
>  int ff_stream_side_data_copy(AVStream *dst, const AVStream *src);
>  
> +/**
> + * Copy all stream parameters from source to destination stream, with the
> + * exception of:
> + *  * the index field, which is usually set by avformat_new_stream()
> + *  * the attached_pic field, if attached_pic.size is 0 or less
> + *
> + * @param dst pointer to destination AVStream
> + * @param src pointer to source AVStream
> + * @return >=0 on success, AVERROR code on error
> + */
> +int ff_stream_params_copy(AVStream *dst, const AVStream *src);
> +
>  /**
>   * Wrap ffurl_move() and log if error happens.
>   *
> diff --git a/libavformat/mux.h b/libavformat/mux.h
> index c01da82194..1bfcaf795f 100644
> --- a/libavformat/mux.h
> +++ b/libavformat/mux.h
> @@ -113,15 +113,6 @@ int ff_format_shift_data(AVFormatContext *s, int64_t 
> read_start, int shift_size)
>   */
>  int ff_format_output_open(AVFormatContext *s, const char *url, AVDictionary 
> **options);
>  
> -/**
> - * Copy encoding parameters from source to destination stream
> - *
> - * @param dst pointer to destination AVStream
> - * @param src pointer to source AVStream
> - * @return >=0 on success, AVERROR code on error
> - */
> -int ff_stream_encode_params_copy(AVStream *dst, const AVStream *src);
> -
>  /**
>   * Parse creation_time in AVFormatContext metadata if exists and warn if the
>   * parsing fails.
> diff --git a/libavformat/mux_utils.c b/libavformat/mux_utils.c
> index eb8ea3d560..2fa2ab5b0f 100644
> --- a/libavformat/mux_utils.c
> +++ b/libavformat/mux_utils.c
> @@ -121,34 +121,6 @@ int ff_format_output_open(AVFormatContext *s, const char 
> *url, AVDictionary **op
>  return 0;
>  }
>  
> -int ff_stream_encode_params_copy(AVStream *dst, const AVStream *src)
> -{
> -int ret;
> -
> -dst->id   

Re: [FFmpeg-devel] [PATCH 1/2] x86: Don't hardcode the height to 8 in sad8_xy2_mmx

2022-08-04 Thread Michael Niedermayer
On Thu, Aug 04, 2022 at 10:47:34AM +0300, Martin Storsjö wrote:
> On Wed, 13 Jul 2022, Martin Storsjö wrote:
> 
> > The height is hardcoded in some of the me_cmp functions, but not
> > in all of them. But in the case of all other functions, it's hardcoded
> > in the same place in SIMD functions as in the C reference functions,
> > while this one function differs from the behaviour of the C code.
> > 
> > (Before 542765ce3eccbca587d54262a512cbdb1407230d, there were a
> > couple other sad8_*_mmx functions with similar hardcoded height.)
> > ---
> > libavcodec/x86/me_cmp_init.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/libavcodec/x86/me_cmp_init.c b/libavcodec/x86/me_cmp_init.c
> > index 61e9396b8f..dcc2621276 100644
> > --- a/libavcodec/x86/me_cmp_init.c
> > +++ b/libavcodec/x86/me_cmp_init.c
> > @@ -202,13 +202,12 @@ static inline int sum_mmx(void)
> > static int sad8_xy2_ ## suf(MpegEncContext *v, uint8_t *blk2,   \
> > uint8_t *blk1, ptrdiff_t stride, int h) \
> > {   \
> > -av_assert2(h == 8);
> >  \
> > __asm__ volatile (  \
> > "pxor %%mm7, %%mm7 \n\t"\
> > "pxor %%mm6, %%mm6 \n\t"\
> > ::);\
> > \
> > -sad8_4_ ## suf(blk1, blk2, stride, 8);  \
> > +sad8_4_ ## suf(blk1, blk2, stride, h);  \
> > \
> > return sum_ ## suf();   \
> > }   \
> > -- 
> > 2.25.1
> 
> Ping, does this seem reasonable? Michael indicated a desire to make the
> me_cmp functions more general and flexible than what they are today, and
> this would be a first step to making checkasm test such cases.

LGTM assuming it doesnt have any problematic perforamce impact

thx

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

Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.


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/7] lavu/pixfmt: summarize yuv naming conventions

2022-08-04 Thread Michael Niedermayer
On Thu, Aug 04, 2022 at 03:57:27PM +0200, Nicolas George wrote:
> Michael Niedermayer (12022-08-04):
> > You seem to describe samples as rectangular areas of constant value IIUC.
> > If you look at the ITU/ISO specs (mpeg2, h264 or others) they are described
> > by point samples. The desity of samples matches. While the default locations
> > do not.
> > What you list above are where probably most sane people would place the
> > samples. But ISO/ITU, probably because of historic TV standard reasons and
> > interlacing convertion reasons place the chroma samples in a more crooked 
> > way
> > I think either the ascii art should be adapted or the text should clarify
> > this difference
> 
> I am not sure what exactly you explain.

What i meant is what is also in AVChromaLocation
The chroma sample locations are shifted from where one would expect


> 
> The picture represents memory cells and how we think of them when we
> implement generic functions, for example cropping or drawutils. Do we
> need to fix all this code somehow?

I suspect several filters are somewhat "wrong"
for example hflip fliping 4:1:1
would turn a:   *--- into ---*
where * is teh chroma sample location, i dont think it updates the chroma
sample location metadata nor does it apply some filter to chroma to shift by
3/4 samples. so it looks wrong, one of the 2 is neeed.

vf_scale contains some code to handle this but iam not seeing code considering
the input and output frames chroma location metadata

All this leads to small errors, often probably not vissible
when you have one one chroma sample for 4 luma samples you will always have
some artifacts on sharp color edges, if the location of the chroma sample
is wrong the artifact would be more to one side of a diagonal edge than the
other. If the locations are correct it should be more symmetric in theory.

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No great genius has ever existed without some touch of madness. -- Aristotle


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 07/25] fftools/ffmpeg: remove OutputStream.stream_copy

2022-08-04 Thread Andreas Rheinhardt
Anton Khirnov:
> Quoting Andreas Rheinhardt (2022-08-04 14:54:41)
>> Michael Niedermayer:
>>> On Wed, Aug 03, 2022 at 03:58:26PM +0200, Anton Khirnov wrote:
 There are currently three possible modes for an output stream:
 1) The stream is produced by encoding output from some filtergraph. This
is true when ost->enc_ctx != NULL, or equivalently when
ost->encoding_needed != 0.
 2) The stream is produced by copying some input stream's packets. This
is true when ost->enc_ctx == NULL && ost->source_index >= 0.
 3) The stream is produced by attaching some file directly. This is true
when ost->enc_ctx == NULL && ost->source_index < 0.

 OutputStream.stream_copy is currently used to identify case 2), and
 sometimes to confusingly (or even incorrectly) identify case 1). Remove
 it, replacing its usage with checking enc_ctx/source_index values.
 ---
  fftools/ffmpeg.c | 23 +--
  fftools/ffmpeg.h |  1 -
  fftools/ffmpeg_opt.c | 33 -
  3 files changed, 21 insertions(+), 36 deletions(-)
>>>
>>> seems to break build with shared libs:
>>>
>>> CC  fftools/ffmpeg.o
>>> src/fftools/ffmpeg.c:405:32: warning: suggest braces around initialization 
>>> of subobject [-Wmissing-braces]
>>> struct sigaction action = {0};
>>>^
>>>{}
>>> src/fftools/ffmpeg.c:1612:37: error: address argument to atomic operation 
>>> must be a pointer to non-const _Atomic type ('const atomic_uint_least64_t 
>>> *' (aka 'const _Atomic(uint_least64_t) *') invalid)
>>> uint64_t frame_number = atomic_load(>packets_written);
>>> ^   ~
>>> /usr/lib/llvm-6.0/lib/clang/6.0.0/include/stdatomic.h:134:29: note: 
>>> expanded from macro 'atomic_load'
>>> #define atomic_load(object) __c11_atomic_load(object, __ATOMIC_SEQ_CST)
>>> ^ ~~
>>> 1 warning and 1 error generated.
>>> src/ffbuild/common.mak:81: recipe for target 'fftools/ffmpeg.o' failed
>>> make: *** [fftools/ffmpeg.o] Error 1
>>>
>>> [...]
>>>
>>
>> This has nothing to do with shared libs. It is just that C11 defines
>> atomic_load in such a way that it does not allow a pointer to const
>> atomic; presumably because atomic types might be emulated via mutexes in
>> which case even a read involves a write.
> 
> I don't even get a warning with gcc 11 or clang 13.
> 

Yes, same for me (this is meant literally:
https://ffmpeg.org/pipermail/ffmpeg-devel/2022-July/298360.html). Maybe
the spec has been modified since then:
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1807.htm and
https://en.cppreference.com/w/c/atomic/atomic_load indicate this.

- Andreas
___
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 07/25] fftools/ffmpeg: remove OutputStream.stream_copy

2022-08-04 Thread Anton Khirnov
Quoting Andreas Rheinhardt (2022-08-04 14:54:41)
> Michael Niedermayer:
> > On Wed, Aug 03, 2022 at 03:58:26PM +0200, Anton Khirnov wrote:
> >> There are currently three possible modes for an output stream:
> >> 1) The stream is produced by encoding output from some filtergraph. This
> >>is true when ost->enc_ctx != NULL, or equivalently when
> >>ost->encoding_needed != 0.
> >> 2) The stream is produced by copying some input stream's packets. This
> >>is true when ost->enc_ctx == NULL && ost->source_index >= 0.
> >> 3) The stream is produced by attaching some file directly. This is true
> >>when ost->enc_ctx == NULL && ost->source_index < 0.
> >>
> >> OutputStream.stream_copy is currently used to identify case 2), and
> >> sometimes to confusingly (or even incorrectly) identify case 1). Remove
> >> it, replacing its usage with checking enc_ctx/source_index values.
> >> ---
> >>  fftools/ffmpeg.c | 23 +--
> >>  fftools/ffmpeg.h |  1 -
> >>  fftools/ffmpeg_opt.c | 33 -
> >>  3 files changed, 21 insertions(+), 36 deletions(-)
> > 
> > seems to break build with shared libs:
> > 
> > CC  fftools/ffmpeg.o
> > src/fftools/ffmpeg.c:405:32: warning: suggest braces around initialization 
> > of subobject [-Wmissing-braces]
> > struct sigaction action = {0};
> >^
> >{}
> > src/fftools/ffmpeg.c:1612:37: error: address argument to atomic operation 
> > must be a pointer to non-const _Atomic type ('const atomic_uint_least64_t 
> > *' (aka 'const _Atomic(uint_least64_t) *') invalid)
> > uint64_t frame_number = atomic_load(>packets_written);
> > ^   ~
> > /usr/lib/llvm-6.0/lib/clang/6.0.0/include/stdatomic.h:134:29: note: 
> > expanded from macro 'atomic_load'
> > #define atomic_load(object) __c11_atomic_load(object, __ATOMIC_SEQ_CST)
> > ^ ~~
> > 1 warning and 1 error generated.
> > src/ffbuild/common.mak:81: recipe for target 'fftools/ffmpeg.o' failed
> > make: *** [fftools/ffmpeg.o] Error 1
> > 
> > [...]
> > 
> 
> This has nothing to do with shared libs. It is just that C11 defines
> atomic_load in such a way that it does not allow a pointer to const
> atomic; presumably because atomic types might be emulated via mutexes in
> which case even a read involves a write.

I don't even get a warning with gcc 11 or clang 13.

-- 
Anton Khirnov
___
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/7] lavu/pixfmt: summarize yuv naming conventions

2022-08-04 Thread Nicolas George
Michael Niedermayer (12022-08-04):
> You seem to describe samples as rectangular areas of constant value IIUC.
> If you look at the ITU/ISO specs (mpeg2, h264 or others) they are described
> by point samples. The desity of samples matches. While the default locations
> do not.
> What you list above are where probably most sane people would place the
> samples. But ISO/ITU, probably because of historic TV standard reasons and
> interlacing convertion reasons place the chroma samples in a more crooked way
> I think either the ascii art should be adapted or the text should clarify
> this difference

I am not sure what exactly you explain.

The picture represents memory cells and how we think of them when we
implement generic functions, for example cropping or drawutils. Do we
need to fix all this code somehow?

Regards,

-- 
  Nicolas George


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 6/7] lavi/pixdesc: add comments about pixel format scoring

2022-08-04 Thread Michael Niedermayer
On Tue, Aug 02, 2022 at 06:54:20PM +0200, Nicolas George wrote:
> Signed-off-by: Nicolas George 
> ---
>  libavutil/pixdesc.c | 6 ++
>  1 file changed, 6 insertions(+)

probably ok

thx

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

The smallest minority on earth is the individual. Those who deny 
individual rights cannot claim to be defenders of minorities. - Ayn Rand


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/7] lavu/pixfmt: summarize yuv naming conventions

2022-08-04 Thread Michael Niedermayer
On Tue, Aug 02, 2022 at 06:54:15PM +0200, Nicolas George wrote:
> Signed-off-by: Nicolas George 
> ---
>  libavutil/pixfmt.h | 17 +
>  1 file changed, 17 insertions(+)
> 
> 
> Identical to the one I posted last week.
> 
> 
> diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
> index 2d3927cc3f..3d0f92ed4d 100644
> --- a/libavutil/pixfmt.h
> +++ b/libavutil/pixfmt.h
> @@ -60,6 +60,23 @@
>   * For all the 8 bits per pixel formats, an RGB32 palette is in data[1] like
>   * for pal8. This palette is filled in automatically by the function
>   * allocating the picture.
> + *
> + * @par
> + * Summary of the naming conventions for YUV formats:
> + *444 422 440 420 411 410
> + * ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╋━┿━┿━┿━╋   ╋━┿━┿━┿━╋
> + * ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╂─╂─╂─╂─╂   ╂─┼─╂─┼─╂   ╋━┿━┿━┿━╋   ╂─┼─┼─┼─╂
> + * ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╋━┿━┿━┿━╋   ╂─┼─┼─┼─╂
> + * ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╂─╂─╂─╂─╂   ╂─┼─╂─┼─╂   ╋━┿━┿━┿━╋   ╂─┼─┼─┼─╂
> + * ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╋━┿━┿━┿━╋   ╋━┿━┿━┿━╋
> + * where
> + * ┼─┼ = luma pixel  ╋━╋ = chroma pixel
> + * ┼─┼   ╋━╋
> + *
> + * yuv4ab →
> + *  log2_chroma_w = log₂(4/a)
> + *  log2_chroma_h = b == a ? 0 : b == 0 ? log2_chroma_w : unused
> + * i.e. a = horizontally, number of luma pixels for four chroma pixels
>   */

You seem to describe samples as rectangular areas of constant value IIUC.
If you look at the ITU/ISO specs (mpeg2, h264 or others) they are described
by point samples. The desity of samples matches. While the default locations
do not.
What you list above are where probably most sane people would place the
samples. But ISO/ITU, probably because of historic TV standard reasons and
interlacing convertion reasons place the chroma samples in a more crooked way
I think either the ascii art should be adapted or the text should clarify
this difference

thx

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

"Nothing to hide" only works if the folks in power share the values of
you and everyone you know entirely and always will -- Tom Scott



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 07/25] fftools/ffmpeg: remove OutputStream.stream_copy

2022-08-04 Thread Andreas Rheinhardt
Michael Niedermayer:
> On Wed, Aug 03, 2022 at 03:58:26PM +0200, Anton Khirnov wrote:
>> There are currently three possible modes for an output stream:
>> 1) The stream is produced by encoding output from some filtergraph. This
>>is true when ost->enc_ctx != NULL, or equivalently when
>>ost->encoding_needed != 0.
>> 2) The stream is produced by copying some input stream's packets. This
>>is true when ost->enc_ctx == NULL && ost->source_index >= 0.
>> 3) The stream is produced by attaching some file directly. This is true
>>when ost->enc_ctx == NULL && ost->source_index < 0.
>>
>> OutputStream.stream_copy is currently used to identify case 2), and
>> sometimes to confusingly (or even incorrectly) identify case 1). Remove
>> it, replacing its usage with checking enc_ctx/source_index values.
>> ---
>>  fftools/ffmpeg.c | 23 +--
>>  fftools/ffmpeg.h |  1 -
>>  fftools/ffmpeg_opt.c | 33 -
>>  3 files changed, 21 insertions(+), 36 deletions(-)
> 
> seems to break build with shared libs:
> 
> CCfftools/ffmpeg.o
> src/fftools/ffmpeg.c:405:32: warning: suggest braces around initialization of 
> subobject [-Wmissing-braces]
> struct sigaction action = {0};
>^
>{}
> src/fftools/ffmpeg.c:1612:37: error: address argument to atomic operation 
> must be a pointer to non-const _Atomic type ('const atomic_uint_least64_t *' 
> (aka 'const _Atomic(uint_least64_t) *') invalid)
> uint64_t frame_number = atomic_load(>packets_written);
> ^   ~
> /usr/lib/llvm-6.0/lib/clang/6.0.0/include/stdatomic.h:134:29: note: expanded 
> from macro 'atomic_load'
> #define atomic_load(object) __c11_atomic_load(object, __ATOMIC_SEQ_CST)
> ^ ~~
> 1 warning and 1 error generated.
> src/ffbuild/common.mak:81: recipe for target 'fftools/ffmpeg.o' failed
> make: *** [fftools/ffmpeg.o] Error 1
> 
> [...]
> 

This has nothing to do with shared libs. It is just that C11 defines
atomic_load in such a way that it does not allow a pointer to const
atomic; presumably because atomic types might be emulated via mutexes in
which case even a read involves a write.

- Andreas
___
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/2] libavcodec: Set hidden visibility on global symbols accessed from x86_64 assembly

2022-08-04 Thread Andreas Rheinhardt
Thomas Guillem:
> DECLARE_ALIGNED, DECLARE_ASM_ALIGNED, and DECLARE_ASM_CONST will include
> attribute_visibility_hidden.
> 
> ld: error: relocation R_X86_64_PC32 cannot be used against symbol 
> 'ff_h264_cabac_tables'; recompile with -fPIC
 defined in 
 /home/tom/work/git/vlc-android/vlc/contrib/x86_64-linux-android/lib/libavcodec.a(cabac.o)
 referenced by cabac.h:187 (libavcodec/x86/cabac.h:187)
   h264_cabac.o:(ff_h264_decode_mb_cabac) in archive 
 /home/tom/work/git/vlc-android/vlc/contrib/x86_64-linux-android/lib/libavcodec.a
> ---
>  libavcodec/ac3dsp.h|  3 +-
>  libavcodec/cabac.h |  3 +-
>  libavcodec/h263dsp.h   |  3 +-
>  libavcodec/x86/constants.h | 81 +++---
>  libavutil/mem.h|  6 +--
>  libswscale/x86/rgb2rgb.c   |  2 +-
>  6 files changed, 51 insertions(+), 47 deletions(-)
> 
> diff --git a/libavcodec/ac3dsp.h b/libavcodec/ac3dsp.h
> index a23b11526e..f8c03a7c23 100644
> --- a/libavcodec/ac3dsp.h
> +++ b/libavcodec/ac3dsp.h
> @@ -23,12 +23,13 @@
>  #define AVCODEC_AC3DSP_H
>  
>  #include 
> +#include "libavutil/internal.h"
>  
>  /**
>   * Number of mantissa bits written for each bap value.
>   * bap values with fractional bits are set to 0 and are calculated 
> separately.
>   */
> -extern const uint16_t ff_ac3_bap_bits[16];
> +extern const uint16_t attribute_visibility_hidden ff_ac3_bap_bits[16];
>  
>  typedef struct AC3DSPContext {
>  /**
> diff --git a/libavcodec/cabac.h b/libavcodec/cabac.h
> index 38d06b2842..356aa368d0 100644
> --- a/libavcodec/cabac.h
> +++ b/libavcodec/cabac.h
> @@ -28,8 +28,9 @@
>  #define AVCODEC_CABAC_H
>  
>  #include 
> +#include "libavutil/internal.h"
>  
> -extern const uint8_t ff_h264_cabac_tables[512 + 4*2*64 + 4*64 + 63];
> +extern const uint8_t attribute_visibility_hidden ff_h264_cabac_tables[512 + 
> 4*2*64 + 4*64 + 63];
>  #define H264_NORM_SHIFT_OFFSET 0
>  #define H264_LPS_RANGE_OFFSET 512
>  #define H264_MLPS_STATE_OFFSET 1024
> diff --git a/libavcodec/h263dsp.h b/libavcodec/h263dsp.h
> index 1abea3ca8c..514a148fb1 100644
> --- a/libavcodec/h263dsp.h
> +++ b/libavcodec/h263dsp.h
> @@ -20,8 +20,9 @@
>  #define AVCODEC_H263DSP_H
>  
>  #include 
> +#include "libavutil/internal.h"
>  
> -extern const uint8_t ff_h263_loop_filter_strength[32];
> +extern const uint8_t attribute_visibility_hidden 
> ff_h263_loop_filter_strength[32];
>  
>  typedef struct H263DSPContext {
>  void (*h263_h_loop_filter)(uint8_t *src, int stride, int qscale);
> diff --git a/libavcodec/x86/constants.h b/libavcodec/x86/constants.h
> index 85da38b7b9..c84b0d4324 100644
> --- a/libavcodec/x86/constants.h
> +++ b/libavcodec/x86/constants.h
> @@ -22,51 +22,52 @@
>  #define AVCODEC_X86_CONSTANTS_H
>  
>  #include 
> +#include "libavutil/internal.h"
>  
>  #include "libavutil/x86/asm.h"
>  
> -extern const ymm_reg  ff_pw_1;
> -extern const ymm_reg  ff_pw_2;
> -extern const xmm_reg  ff_pw_3;
> -extern const ymm_reg  ff_pw_4;
> -extern const xmm_reg  ff_pw_5;
> -extern const xmm_reg  ff_pw_8;
> -extern const xmm_reg  ff_pw_9;
> -extern const uint64_t ff_pw_15;
> -extern const xmm_reg  ff_pw_16;
> -extern const xmm_reg  ff_pw_18;
> -extern const xmm_reg  ff_pw_20;
> -extern const xmm_reg  ff_pw_32;
> -extern const uint64_t ff_pw_42;
> -extern const uint64_t ff_pw_53;
> -extern const xmm_reg  ff_pw_64;
> -extern const uint64_t ff_pw_96;
> -extern const uint64_t ff_pw_128;
> -extern const ymm_reg  ff_pw_255;
> -extern const ymm_reg  ff_pw_256;
> -extern const ymm_reg  ff_pw_512;
> -extern const ymm_reg  ff_pw_1023;
> -extern const ymm_reg  ff_pw_1024;
> -extern const ymm_reg  ff_pw_2048;
> -extern const ymm_reg  ff_pw_4095;
> -extern const ymm_reg  ff_pw_4096;
> -extern const ymm_reg  ff_pw_8192;
> -extern const ymm_reg  ff_pw_m1;
> +extern const ymm_reg attribute_visibility_hidden  ff_pw_1;
> +extern const ymm_reg attribute_visibility_hidden  ff_pw_2;
> +extern const xmm_reg attribute_visibility_hidden  ff_pw_3;
> +extern const ymm_reg attribute_visibility_hidden  ff_pw_4;
> +extern const xmm_reg attribute_visibility_hidden  ff_pw_5;
> +extern const xmm_reg attribute_visibility_hidden  ff_pw_8;
> +extern const xmm_reg attribute_visibility_hidden  ff_pw_9;
> +extern const uint64_t attribute_visibility_hidden ff_pw_15;
> +extern const xmm_reg attribute_visibility_hidden  ff_pw_16;
> +extern const xmm_reg attribute_visibility_hidden  ff_pw_18;
> +extern const xmm_reg attribute_visibility_hidden  ff_pw_20;
> +extern const xmm_reg attribute_visibility_hidden  ff_pw_32;
> +extern const uint64_t attribute_visibility_hidden ff_pw_42;
> +extern const uint64_t attribute_visibility_hidden ff_pw_53;
> +extern const xmm_reg attribute_visibility_hidden  ff_pw_64;
> +extern const uint64_t attribute_visibility_hidden ff_pw_96;
> +extern const uint64_t attribute_visibility_hidden ff_pw_128;
> +extern const ymm_reg attribute_visibility_hidden  ff_pw_255;
> +extern const ymm_reg 

Re: [FFmpeg-devel] [PATCH 07/25] fftools/ffmpeg: remove OutputStream.stream_copy

2022-08-04 Thread Michael Niedermayer
On Wed, Aug 03, 2022 at 03:58:26PM +0200, Anton Khirnov wrote:
> There are currently three possible modes for an output stream:
> 1) The stream is produced by encoding output from some filtergraph. This
>is true when ost->enc_ctx != NULL, or equivalently when
>ost->encoding_needed != 0.
> 2) The stream is produced by copying some input stream's packets. This
>is true when ost->enc_ctx == NULL && ost->source_index >= 0.
> 3) The stream is produced by attaching some file directly. This is true
>when ost->enc_ctx == NULL && ost->source_index < 0.
> 
> OutputStream.stream_copy is currently used to identify case 2), and
> sometimes to confusingly (or even incorrectly) identify case 1). Remove
> it, replacing its usage with checking enc_ctx/source_index values.
> ---
>  fftools/ffmpeg.c | 23 +--
>  fftools/ffmpeg.h |  1 -
>  fftools/ffmpeg_opt.c | 33 -
>  3 files changed, 21 insertions(+), 36 deletions(-)

seems to break build with shared libs:

CC  fftools/ffmpeg.o
src/fftools/ffmpeg.c:405:32: warning: suggest braces around initialization of 
subobject [-Wmissing-braces]
struct sigaction action = {0};
   ^
   {}
src/fftools/ffmpeg.c:1612:37: error: address argument to atomic operation must 
be a pointer to non-const _Atomic type ('const atomic_uint_least64_t *' (aka 
'const _Atomic(uint_least64_t) *') invalid)
uint64_t frame_number = atomic_load(>packets_written);
^   ~
/usr/lib/llvm-6.0/lib/clang/6.0.0/include/stdatomic.h:134:29: note: expanded 
from macro 'atomic_load'
#define atomic_load(object) __c11_atomic_load(object, __ATOMIC_SEQ_CST)
^ ~~
1 warning and 1 error generated.
src/ffbuild/common.mak:81: recipe for target 'fftools/ffmpeg.o' failed
make: *** [fftools/ffmpeg.o] Error 1

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

In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope


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] Consulting enquiry: H264 nvenc for libwebrtc

2022-08-04 Thread Tudor Zaharia
I don't know if the mailing list includes my contact details, so here is my 
email address: tudor(at)swisstch[dot]com

Best regards,
Tudor Zaharia

From: ffmpeg-devel  on behalf of Tudor Zaharia 

Sent: Thursday, August 4, 2022 2:22 PM
To: ffmpeg-devel@ffmpeg.org 
Subject: [FFmpeg-devel] Consulting enquiry: H264 nvenc for libwebrtc

Dear FFmpeg development community,

My name is Tudor Zaharia and I am sending this message after reading this page: 
https://ffmpeg.org/consulting.html

For a project that I am implementing, I would like to have H264 hardware 
encoding capabilities in libwebrtc through Nvidia's nvenc. My understading is 
that libwebrtc is already using FFmpeg for hardware decoding, but not for 
encoding. From what I know, the code that uses the OpenH264 encoder should be 
adapted to use the nvenc encoder (already contained in libwebrtc's source 
through FFmpeg). I am only interested in a solution that works on Linux, which 
I believe is a CUDA implementation of the encoder. I believe such 
implementations do exist - since some browsers have it, but I guess due to 
licensing issues, I couldn't find any.

Is this in your area of expertise and would have an interest in implementing it?
If yes, can you give me a price and time estimate? If you already have 
knowledge of an existing implementation that you can directly provide me for a 
fee, all the better.

Best regards,
Tudor Zaharia



___
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 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] Consulting enquiry: H264 nvenc for libwebrtc

2022-08-04 Thread Tudor Zaharia
Dear FFmpeg development community,

My name is Tudor Zaharia and I am sending this message after reading this page: 
https://ffmpeg.org/consulting.html

For a project that I am implementing, I would like to have H264 hardware 
encoding capabilities in libwebrtc through Nvidia's nvenc. My understading is 
that libwebrtc is already using FFmpeg for hardware decoding, but not for 
encoding. From what I know, the code that uses the OpenH264 encoder should be 
adapted to use the nvenc encoder (already contained in libwebrtc's source 
through FFmpeg). I am only interested in a solution that works on Linux, which 
I believe is a CUDA implementation of the encoder. I believe such 
implementations do exist - since some browsers have it, but I guess due to 
licensing issues, I couldn't find any.

Is this in your area of expertise and would have an interest in implementing it?
If yes, can you give me a price and time estimate? If you already have 
knowledge of an existing implementation that you can directly provide me for a 
fee, all the better.

Best regards,
Tudor Zaharia



___
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 2/2] swscale/aarch64: add vscale specializations

2022-08-04 Thread Martin Storsjö

On Wed, 27 Jul 2022, Swinney, Jonathan wrote:


This commit adds new code paths for vscale when filterSize is 2, 4, or
8. By using specialized code with unrolling to match the filterSize we
can improve performance.



This patch also corrects the behavor for
filterSize 1 which was previously failing the checkasm test.


Hmm, can you elaborate on this bit? With only the first patch applied, the 
checkasm test still succeeds.



On AWS c7g (Graviton 3, Neoverse V1) instances:
   before   after
yuv2yuvX_2_0_512_neon:  355.1270.4
yuv2yuvX_4_0_512_neon:  621.4436.6
yuv2yuvX_8_0_512_neon:  1134.4   817.6
yuv2yuvX_16_0_512_neon: 2071.9   1845.1

Signed-off-by: Jonathan Swinney 
---
libswscale/aarch64/output.S  | 188 +--
libswscale/aarch64/swscale.c |  12 +++
2 files changed, 194 insertions(+), 6 deletions(-)

diff --git a/libswscale/aarch64/output.S b/libswscale/aarch64/output.S
index af71de6050..a18e2c7541 100644
--- a/libswscale/aarch64/output.S
+++ b/libswscale/aarch64/output.S
@@ -21,29 +21,48 @@
#include "libavutil/aarch64/asm.S"

function ff_yuv2planeX_8_neon, export=1
+// x0 - const int16_t *filter,
+// x1 - int filterSize,
+// x2 - const int16_t **src,
+// x3 - uint8_t *dest,
+// x4 - int dstW,
+// x5 - const uint8_t *dither,
+// x6 - int offset
+


x4 and x6 should be w4/w6


ld1 {v0.8B}, [x5]   // load 8x8-bit 
dither
+and w6, w6, #7
cbz w6, 1f  // check if 
offsetting present
ext v0.8B, v0.8B, v0.8B, #3 // honor offsetting 
which can be 0 or 3 only
1:  uxtlv0.8H, v0.8B// extend dither to 
16-bit
ushll   v1.4S, v0.4H, #12   // extend dither to 
32-bit with left shift by 12 (part 1)
ushll2  v2.4S, v0.8H, #12   // extend dither to 
32-bit with left shift by 12 (part 2)
+cmp w1, #8  // if filterSize 
== 8, branch to specialized version
+b.eq6f
+cmp w1, #4  // if filterSize 
== 4, branch to specialized version
+b.eq8f
+cmp w1, #2  // if filterSize 
== 2, branch to specialized version
+b.eq10f
+
+// The filter size does not match of the of specialized implementations. It is 
either even or odd. If it is even
+// then use the first section below.
mov x7, #0  // i = 0
+tbnzw1, #0, 4f  // if filterSize % 
2 != 0 branch to specialized version
+// fs % 2 == 0
2:  mov v3.16B, v1.16B  // initialize 
accumulator part 1 with dithering value
mov v4.16B, v2.16B  // initialize 
accumulator part 2 with dithering value
mov w8, w1  // tmpfilterSize = 
filterSize
mov x9, x2  // srcp= src
mov x10, x0 // filterp = filter
3:  ldp x11, x12, [x9], #16 // get 2 pointers: 
src[j] and src[j+1]
+ldr s7, [x10], #4   // read 2x16-bit 
coeff X and Y at filter[j] and filter[j+1]
add x11, x11, x7, lsl #1// [j  ][i]
add x12, x12, x7, lsl #1// [j+1][i]
ld1 {v5.8H}, [x11]  // read 8x16-bit @ 
src[j  ][i + {0..7}]: A,B,C,D,E,F,G,H
ld1 {v6.8H}, [x12]  // read 8x16-bit @ 
src[j+1][i + {0..7}]: I,J,K,L,M,N,O,P
-ld1r{v7.8H}, [x10], #2  // read 1x16-bit 
coeff X at filter[j  ] and duplicate across lanes
-ld1r{v16.8H}, [x10], #2 // read 1x16-bit 
coeff Y at filter[j+1] and duplicate across lanes
-smlal   v3.4S, v5.4H, v7.4H // val0 += 
{A,B,C,D} * X
-smlal2  v4.4S, v5.8H, v7.8H // val1 += 
{E,F,G,H} * X
-smlal   v3.4S, v6.4H, v16.4H// val0 += 
{I,J,K,L} * Y
-smlal2  v4.4S, v6.8H, v16.8H// val1 += 
{M,N,O,P} * Y
+smlal   v3.4S, v5.4H, v7.H[0]   // val0 += 
{A,B,C,D} * X
+smlal2  v4.4S, v5.8H, v7.H[0]   // val1 += 
{E,F,G,H} * X
+smlal   v3.4S, v6.4H, v7.H[1]   // val0 += 
{I,J,K,L} * Y
+smlal2  v4.4S, v6.8H, v7.H[1]   // val1 += 
{M,N,O,P} * Y


Could we split this improvement for the existing codepath into a separate 
preceding patch, to keep things a bit clearer?




subs

Re: [FFmpeg-devel] [PATCH v2 1/2] checkasm: updated tests for sw_scale

2022-08-04 Thread Martin Storsjö

On Wed, 27 Jul 2022, Swinney, Jonathan wrote:


- added a test for yuv2plane1
- fixed test for yuv2planeX for aarch64 which was previously not working
 at all
- updated the test for yuv2planeX to check exact results or approximated
 results

Signed-off-by: Jonathan Swinney 
---
libswscale/x86/swscale.c  |   8 +-
tests/checkasm/sw_scale.c | 189 ++
2 files changed, 155 insertions(+), 42 deletions(-)

diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c
index 628f12137c..32d441245d 100644
--- a/libswscale/x86/swscale.c
+++ b/libswscale/x86/swscale.c
@@ -534,7 +534,8 @@ switch(c->dstBpc){ \
ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse2, sse2);
ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse2, ,
HAVE_ALIGNED_STACK || ARCH_X86_64);
-ASSIGN_VSCALE_FUNC(c->yuv2plane1, sse2);
+if (!(c->flags & SWS_ACCURATE_RND))
+ASSIGN_VSCALE_FUNC(c->yuv2plane1, sse2);

switch (c->srcFormat) {
case AV_PIX_FMT_YA8:
@@ -583,14 +584,15 @@ switch(c->dstBpc){ \
ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse4,
if (!isBE(c->dstFormat)) c->yuv2planeX = 
ff_yuv2planeX_16_sse4,
HAVE_ALIGNED_STACK || ARCH_X86_64);
-if (c->dstBpc == 16 && !isBE(c->dstFormat))
+if (c->dstBpc == 16 && !isBE(c->dstFormat) && !(c->flags & 
SWS_ACCURATE_RND))
c->yuv2plane1 = ff_yuv2plane1_16_sse4;
}

if (EXTERNAL_AVX(cpu_flags)) {
ASSIGN_VSCALEX_FUNC(c->yuv2planeX, avx, ,
HAVE_ALIGNED_STACK || ARCH_X86_64);
-ASSIGN_VSCALE_FUNC(c->yuv2plane1, avx);
+if (!(c->flags & SWS_ACCURATE_RND))
+ASSIGN_VSCALE_FUNC(c->yuv2plane1, avx);

switch (c->srcFormat) {
case AV_PIX_FMT_YUYV422:


I think it would be good to have someone who's more familiar with swscale 
(or just someone else overall) acknowledge these changes too.



diff --git a/tests/checkasm/sw_scale.c b/tests/checkasm/sw_scale.c
index b643a47c30..b01fc31fd9 100644
--- a/tests/checkasm/sw_scale.c
+++ b/tests/checkasm/sw_scale.c
@@ -18,6 +18,7 @@
 */

#include 
+#include 


We don't generally use stdbool in ffmpeg, even if it's C99 - just use a 
plain int and 0/1.



Other than that, the checkasm changes look fine (I coauthored part of 
them - and your cleanup of my WIP patch looks good!).


// Martin

___
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/1] libswscale/aarch64: add another hscale specialization

2022-08-04 Thread Martin Storsjö

On Fri, 22 Jul 2022, Swinney, Jonathan wrote:


This specialization handles the case where filtersize is 4 mod 8, e.g.
12, 20, etc. Aarch64 was previously using the c function for this case.
This implementation speeds up that case significantly.

hscale_8_to_15__fs_12_dstW_512_c: 6234.1
hscale_8_to_15__fs_12_dstW_512_neon: 1505.6

Signed-off-by: Jonathan Swinney 
---
libswscale/aarch64/hscale.S  | 107 +++
libswscale/aarch64/swscale.c |  15 ++---
2 files changed, 115 insertions(+), 7 deletions(-)

diff --git a/libswscale/aarch64/hscale.S b/libswscale/aarch64/hscale.S
index b7b21b7a0f..93b9094ded 100644
--- a/libswscale/aarch64/hscale.S
+++ b/libswscale/aarch64/hscale.S
@@ -91,6 +91,113 @@ function ff_hscale8to15_X8_neon, export=1
ret
endfunc

+function ff_hscale8to15_X4_neon, export=1
+// x0  SwsContext *c (not used)
+// x1  int16_t *dst
+// x2  int dstW
+// x3  const uint8_t *src
+// x4  const int16_t *filter
+// x5  const int32_t *filterPos
+// x6  int filterSize


Here, x2 and x6 should be w2 and w6


+
+// This function for filter sizes that are 4 mod 8. In other words, anything 
that's 0 mod 4 but not
+// 0 mod 8. It also assumes that dstW is 0 mod 4.
+
+lsl w7, w6, #1  // w7 = filterSize * 2
+1:
+ldp w8, w9,  [x5]   // filterPos[idx + 0], 
[idx + 1]
+ldp w10, w11, [x5, 8]   // filterPos[idx + 2], 
[idx + 3]


With MS armasm64, this produces the following error:

libswscale\aarch64\hscale.o.asm(1034) : error A2079: improper line syntax; 
symbol expected

ldp w10, w11, [x5, 8]

(The error is that the immediate offset should be written #8.)


+
+moviv16.2d, #0  // initialize 
accumulator for idx + 0
+moviv17.2d, #0  // initialize 
accumulator for idx + 1
+moviv18.2d, #0  // initialize 
accumulator for idx + 2
+moviv19.2d, #0  // initialize 
accumulator for idx + 3
+
+mov x12, x4 // filter pointer for 
idx + 0
+add x13, x4, x7 // filter pointer for 
idx + 1
+add x8, x3, w8, uxtw// srcp + 
filterPos[idx + 0]
+add x9, x3, w9, uxtw// srcp + 
filterPos[idx + 1]
+
+add x14, x13, x7// filter pointer for 
idx + 2
+add x10, x3, w10, uxtw  // srcp + 
filterPos[idx + 2]
+add x11, x3, w11, uxtw  // srcp + 
filterPos[idx + 3]
+
+mov w0, w6  // copy filterSize to 
a temp register, w0
+add x5, x5, #16 // advance the 
filterPos pointer
+add x15, x14, x7// filter pointer for 
idx + 3
+mov x16, xzr// temp register for 
offsetting filter pointers
+
+2:
+// This section loops over 8-wide chunks of filter size
+ldr d4, [x8], #8// load 8 bytes from 
srcp for idx + 0
+ldr q0, [x12, x16]  // load 8 values, 16 
bytes from filter for idx + 0
+
+ldr d5, [x9], #8// load 8 bytes from 
srcp for idx + 1
+ldr q1, [x13, x16]  // load 8 values, 16 
bytes from filter for idx + 1
+
+uxtlv4.8h, v4.8b// unsigned extend 
long for idx + 0
+uxtlv5.8h, v5.8b// unsigned extend 
long for idx + 1
+
+ldr d6, [x10], #8   // load 8 bytes from 
srcp for idx + 2
+ldr q2, [x14, x16]  // load 8 values, 16 
bytes from filter for idx + 2
+
+smlal   v16.4s, v0.4h, v4.4h// val += src[srcPos + 
j + 0..3] * filter[fs * i + j + 0..3], idx + 0
+smlal   v17.4s, v1.4h, v5.4h// val += src[srcPos + 
j + 0..3] * filter[fs * i + j + 0..3], idx + 1
+
+ldr d7, [x11], #8   // load 8 bytes from 
srcp for idx + 3
+ldr q3, [x15, x16]  // load 8 values, 16 
bytes from filter for idx + 3
+
+sub w0, w0, #8  // decrement the 
remaining filterSize counter
+smlal2  v16.4s, v0.8h, v4.8h// val += src[srcPos + 
j + 4..7] * filter[fs * i + j + 4..7], idx + 0
+smlal2  v17.4s, v1.8h, v5.8h// val += src[srcPos + 
j + 4..7] * filter[fs * i + j + 4..7], idx + 1
+uxtlv6.8h, v6.8b// unsigned extend 
long for idx + 2
+uxtlv7.8h, v7.8b// 

Re: [FFmpeg-devel] [PATCH 2/2] libavcodec: Set hidden visibility on global symbols accessed from x86_64 assembly

2022-08-04 Thread Martin Storsjö

On Wed, 27 Jul 2022, Thomas Guillem wrote:


DECLARE_ALIGNED, DECLARE_ASM_ALIGNED, and DECLARE_ASM_CONST will include
attribute_visibility_hidden.


Hmm, I'm not entirely sure that we should do that - if we should add such 
extra meaning to those macros.


How many symbols would it need to be applied on, if we don't apply it via 
these macros?


I was a bit concerned that DECLARE_ALIGNED could be used for e.g. stack 
local variables (where visibility doesn't make sense) - but we do have 
LOCAL_ALIGNED_* macros for that instead, so maybe it could work this way 
after all?


Do note, that these are currently defined in libavutil/mem.h, but after 
the next major bump they'll be in libavutil/mem_internal.h. Currently 
their contents are duplicated in the both, so any changes would need to 
apply to both.


I see that libavutil/mem.h (which is a public installed header) doesn't 
explicitly include libavutil/internal.h, so if someone uses those macros 
without including libavutil/internal.h, attribute_visibility_hidden would 
be undefined.


After the next bump, when these macros are entirely internal, this issue 
is much clearer (and at that point, I think it could be a bit more 
tolerable to extend their meaning to include visibility).


// Martin

___
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 v3] libavcodec: Set hidden visibility on global symbols accessed from AArch64 assembly

2022-08-04 Thread Martin Storsjö

On Thu, 14 Jul 2022, Martin Storsjö wrote:


The AArch64 assembly accesses those symbols directly, without
indirection via e.g. the GOT on ELF. In order for this not to
require text relocations, those symbols need to be resolved fully
at link time, i.e. those symbols can't be interposable.

Normally, so far, this is achieved when linking shared libraries
in two ways; we have a version script (libavcodec/libavcodec.v) which
marks all symbols that don't start with av* as local. Additionally,
we try to add -Wl,-Bsymbolic to the linker options if supported,
making sure that such symbol references are resolved fully at link
time, instead of making them interposable.

When the libavcodec static library is linked into another shared
library, there's no guarantee that it uses similar options (even though
that would be favourable), which would end up requiring text relocations
in the AArch64 assembly.

Explicitly mark the symbols that are accessed from AArch64 assembly
as hidden, so that they are resolved fully at link time even without
the version script and -Wl,-Bsymbolic.

Signed-off-by: Martin Storsjö 
---
Moved the attribute to libavutil/internal.h, renamed to a different
namespace (not av_ prefixed), moved the attribute on ff_vp9_subpel_filters
to the header, as suggested.

Added explicit includes of libavutil/internal.h to fix builds on
x86.
---
libavcodec/aacsbrdata.h | 3 ++-
libavcodec/fft.h| 3 ++-
libavcodec/vp9dsp.h | 3 ++-
libavutil/internal.h| 6 ++
4 files changed, 12 insertions(+), 3 deletions(-)


Ping - any further comments on this - is it acceptable/tolerable, as a 
practical fix to make sure these symbols aren't interposable?


// Martin
___
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] lavf/hevc: replace the unicode signal quotation with normal

2022-08-04 Thread Jun Zhao
replace the unicode left/right signal quotation mark with normal
signal quotation.

Signed-off-by: Jun Zhao 
---
 libavformat/hevc.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavformat/hevc.c b/libavformat/hevc.c
index df141aec26..37d97941d5 100644
--- a/libavformat/hevc.c
+++ b/libavformat/hevc.c
@@ -924,31 +924,31 @@ static int hvcc_write(AVIOContext *pb, 
HEVCDecoderConfigurationRecord *hvcc)
 avio_w8(pb, hvcc->general_level_idc);
 
 /*
- * bit(4) reserved = ‘’b;
+ * bit(4) reserved = ''b;
  * unsigned int(12) min_spatial_segmentation_idc;
  */
 avio_wb16(pb, hvcc->min_spatial_segmentation_idc | 0xf000);
 
 /*
- * bit(6) reserved = ‘11’b;
+ * bit(6) reserved = '11'b;
  * unsigned int(2) parallelismType;
  */
 avio_w8(pb, hvcc->parallelismType | 0xfc);
 
 /*
- * bit(6) reserved = ‘11’b;
+ * bit(6) reserved = '11'b;
  * unsigned int(2) chromaFormat;
  */
 avio_w8(pb, hvcc->chromaFormat | 0xfc);
 
 /*
- * bit(5) reserved = ‘1’b;
+ * bit(5) reserved = '1'b;
  * unsigned int(3) bitDepthLumaMinus8;
  */
 avio_w8(pb, hvcc->bitDepthLumaMinus8 | 0xf8);
 
 /*
- * bit(5) reserved = ‘1’b;
+ * bit(5) reserved = '1'b;
  * unsigned int(3) bitDepthChromaMinus8;
  */
 avio_w8(pb, hvcc->bitDepthChromaMinus8 | 0xf8);
-- 
2.25.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] avutil/hwcontext_videotoolbox: add missing include for AVFrame

2022-08-04 Thread Zhao Zhili
From: Zhao Zhili 

Signed-off-by: Zhao Zhili 
---
 libavutil/hwcontext_videotoolbox.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavutil/hwcontext_videotoolbox.h 
b/libavutil/hwcontext_videotoolbox.h
index b6bdcf243d..25dde85df5 100644
--- a/libavutil/hwcontext_videotoolbox.h
+++ b/libavutil/hwcontext_videotoolbox.h
@@ -23,6 +23,7 @@
 
 #include 
 
+#include "frame.h"
 #include "pixfmt.h"
 
 /**
-- 
2.35.3

___
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: allow .ec3 as extension for raw E-AC-3 stream

2022-08-04 Thread Anton Khirnov
Looks reasonable, will push soonish if nobody objects.

-- 
Anton Khirnov
___
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] lavfi/dnn: Fix OpenVINO missing model file corrupt issue.

2022-08-04 Thread Anton Khirnov
Quoting Ting Fu (2022-08-04 11:31:01)
> DNN OpenVINO backend would not report missing model file if it does not
> exist. It would corrupt directly with out any error infomation. This commit

"corrupt"?

The patch looks completely wrong. Testing for file existence explicitly
is known to be a bad pattern that leads to all kinds of races, security
issues, and other bugs. Just trying to open the file and returning an
error if that fails is the right thing to do.

-- 
Anton Khirnov
___
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/Makefile: fix make checkheaders fail

2022-08-04 Thread Andreas Rheinhardt
Jun Zhao:
> Fix the break when used libavcodec/Makefile
> 
> Signed-off-by: Jun Zhao 
> ---
>  libavcodec/Makefile | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 836132f430..5ba7fb6b86 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -1234,6 +1234,7 @@ SKIPHEADERS-$(CONFIG_D3D11VA)  += d3d11va.h 
> dxva2_internal.h
>  SKIPHEADERS-$(CONFIG_DXVA2)+= dxva2.h dxva2_internal.h
>  SKIPHEADERS-$(CONFIG_JNI)  += ffjni.h
>  SKIPHEADERS-$(CONFIG_LCMS2)+= fflcms2.h
> +SKIPHEADERS-$(CONFIG_LIBAOM)   += libaom.h
>  SKIPHEADERS-$(CONFIG_LIBJXL)   += libjxl.h
>  SKIPHEADERS-$(CONFIG_LIBVPX)   += libvpx.h
>  SKIPHEADERS-$(CONFIG_LIBWEBP_ENCODER)  += libwebpenc_common.h
> @@ -1248,6 +1249,7 @@ SKIPHEADERS-$(CONFIG_VAAPI)+= 
> vaapi_decode.h vaapi_hevc.h vaapi_enco
>  SKIPHEADERS-$(CONFIG_VDPAU)+= vdpau.h vdpau_internal.h
>  SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.h vt_internal.h
>  SKIPHEADERS-$(CONFIG_V4L2_M2M) += v4l2_buffers.h v4l2_context.h 
> v4l2_m2m.h
> +SKIPHEADERS-$(CONFIG_ZLIB) += zlib_wrapper.h
>  
>  TESTPROGS = avcodec \
>  avpacket\

LGTM.

- Andreas
___
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] lavc/Makefile: fix make checkheaders fail

2022-08-04 Thread Jun Zhao
Fix the break when used libavcodec/Makefile

Signed-off-by: Jun Zhao 
---
 libavcodec/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 836132f430..5ba7fb6b86 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1234,6 +1234,7 @@ SKIPHEADERS-$(CONFIG_D3D11VA)  += d3d11va.h 
dxva2_internal.h
 SKIPHEADERS-$(CONFIG_DXVA2)+= dxva2.h dxva2_internal.h
 SKIPHEADERS-$(CONFIG_JNI)  += ffjni.h
 SKIPHEADERS-$(CONFIG_LCMS2)+= fflcms2.h
+SKIPHEADERS-$(CONFIG_LIBAOM)   += libaom.h
 SKIPHEADERS-$(CONFIG_LIBJXL)   += libjxl.h
 SKIPHEADERS-$(CONFIG_LIBVPX)   += libvpx.h
 SKIPHEADERS-$(CONFIG_LIBWEBP_ENCODER)  += libwebpenc_common.h
@@ -1248,6 +1249,7 @@ SKIPHEADERS-$(CONFIG_VAAPI)+= vaapi_decode.h 
vaapi_hevc.h vaapi_enco
 SKIPHEADERS-$(CONFIG_VDPAU)+= vdpau.h vdpau_internal.h
 SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.h vt_internal.h
 SKIPHEADERS-$(CONFIG_V4L2_M2M) += v4l2_buffers.h v4l2_context.h 
v4l2_m2m.h
+SKIPHEADERS-$(CONFIG_ZLIB) += zlib_wrapper.h
 
 TESTPROGS = avcodec \
 avpacket\
-- 
2.25.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] lavfi/dnn: Fix OpenVINO missing model file corrupt issue.

2022-08-04 Thread Ting Fu
DNN OpenVINO backend would not report missing model file if it does not
exist. It would corrupt directly with out any error infomation. This commit
would check both .xml and .bin file existance before loading model.

Signed-off-by: Ting Fu 
---
 libavfilter/dnn/dnn_backend_openvino.c | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/libavfilter/dnn/dnn_backend_openvino.c 
b/libavfilter/dnn/dnn_backend_openvino.c
index b494f26f55..47e3fc8280 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -34,6 +34,7 @@
 #include "../internal.h"
 #include "safe_queue.h"
 #include 
+#include 
 #include "dnn_backend_common.h"
 
 typedef struct OVOptions{
@@ -728,7 +729,7 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, 
DNNFunctionType func_
 OVContext *ctx = NULL;
 IEStatusCode status;
 size_t node_count = 0;
-char *node_name = NULL;
+char *node_name, *model_binary_file, *extension_chr = NULL;
 
 model = av_mallocz(sizeof(DNNModel));
 if (!model){
@@ -758,6 +759,22 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, 
DNNFunctionType func_
 if (status != OK)
 goto err;
 
+//file existance check
+model_binary_file = (char *)malloc(sizeof(model_filename));
+strcpy(model_binary_file, model_filename);
+extension_chr = strstr(model_binary_file, ".xml");
+if (!extension_chr) {
+av_log(ctx, AV_LOG_ERROR, "Model file name \"%s\" with incorrect 
extension.",
+   model_filename);
+goto err;
+}
+strcpy(extension_chr, ".bin");
+if (access(model_filename, F_OK) || access(model_binary_file, F_OK)) {
+av_log(ctx, AV_LOG_ERROR, "Model file \"%s\" or \"%s\" does not 
exist.",
+   model_filename, model_binary_file);
+goto err;
+}
+
 status = ie_core_read_network(ov_model->core, model_filename, NULL, 
_model->network);
 if (status != OK) {
 ie_version_t ver;
@@ -806,6 +823,7 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, 
DNNFunctionType func_
 return model;
 
 err:
+free(model_binary_file);
 ff_dnn_free_model_ov();
 return NULL;
 }
-- 
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 19/25] fftools/ffmpeg: report new streams from the input thread

2022-08-04 Thread Nicolas George
Andreas Rheinhardt (12022-08-04):
> Or the timebase should be passed by value (as is commonly done elsewhere).

That would have been the best initially. But it is a public function,
changing it would be an API break, probably not worth the deprecation
dance.

Regards,

-- 
  Nicolas George


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 19/25] fftools/ffmpeg: report new streams from the input thread

2022-08-04 Thread Andreas Rheinhardt
Nicolas George:
> Anton Khirnov (12022-08-04):
>> src/fftools/ffmpeg_demux.c:41:46: warning: passing argument 3 of 
>> ‘av_ts_make_time_string’ discards ‘const’ qualifier from pointer target type 
>> [-Wdiscarded-qualifiers]
>>41 |pkt->pos, av_ts2timestr(pkt->dts, >time_base));
> 
> av_ts_make_time_string() should have const on its *tb argument. Good
> catch.
> 

Or the timebase should be passed by value (as is commonly done elsewhere).

- Andreas
___
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 19/25] fftools/ffmpeg: report new streams from the input thread

2022-08-04 Thread Nicolas George
Anton Khirnov (12022-08-04):
> src/fftools/ffmpeg_demux.c:41:46: warning: passing argument 3 of 
> ‘av_ts_make_time_string’ discards ‘const’ qualifier from pointer target type 
> [-Wdiscarded-qualifiers]
>41 |pkt->pos, av_ts2timestr(pkt->dts, >time_base));

av_ts_make_time_string() should have const on its *tb argument. Good
catch.

Regards,

-- 
  Nicolas George


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 19/25] fftools/ffmpeg: report new streams from the input thread

2022-08-04 Thread Anton Khirnov
Quoting Andreas Rheinhardt (2022-08-03 20:47:36)
> Missing const on st

src/fftools/ffmpeg_demux.c:41:46: warning: passing argument 3 of 
‘av_ts_make_time_string’ discards ‘const’ qualifier from pointer target type 
[-Wdiscarded-qualifiers]
   41 |pkt->pos, av_ts2timestr(pkt->dts, >time_base));

> and pkt.

can do

-- 
Anton Khirnov
___
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/aarch64: Add neon implementation for pix_abs16_y2

2022-08-04 Thread Martin Storsjö

On Mon, 25 Jul 2022, Hubert Mazur wrote:


Provide optimized implementation of pix_abs16_y2 function for arm64.

Performance comparison tests are shown below.
pix_abs_0_2_c: 308.5
pix_abs_0_2_neon: 39.2

Benchmarks and tests run with checkasm tool on AWS Graviton 3.

Signed-off-by: Hubert Mazur 
---
libavcodec/aarch64/me_cmp_init_aarch64.c |  3 +
libavcodec/aarch64/me_cmp_neon.S | 73 
2 files changed, 76 insertions(+)



+// iterate by one
+2:
+
+ld1 {v1.16b}, [x2], x3  // Load pix2
+ld1 {v2.16b}, [x5], x3  // Load pix3
+urhadd  v30.16b, v1.16b, v2.16b // Rounding halving add
+ld1 {v0.16b}, [x1], x3  // Load pix1
+uabdv30.16b, v30.16b, v30.16b


This should be "uabd v30, v30, v0" here too - please check the uncommon 
codepaths too (until we can make checkasm test them by default).


// Martin

___
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/aarch64: Add neon implementation for pix_abs8

2022-08-04 Thread Martin Storsjö

On Mon, 25 Jul 2022, Hubert Mazur wrote:


Provide optimized implementation of pix_abs8 function for arm64.

Performance comparison tests are shown below.
- pix_abs_1_0_c: 105.2
- pix_abs_1_0_neon: 21.4
- sad_1_c: 107.2
- sad_1_neon: 20.9

Benchmarks and tests are run with checkasm tool on AWS Graviton 3.
---
libavcodec/aarch64/me_cmp_init_aarch64.c |  4 ++
libavcodec/aarch64/me_cmp_neon.S | 53 
2 files changed, 57 insertions(+)

diff --git a/libavcodec/aarch64/me_cmp_init_aarch64.c 
b/libavcodec/aarch64/me_cmp_init_aarch64.c
index 89c817990c..7d7dc38754 100644
--- a/libavcodec/aarch64/me_cmp_init_aarch64.c
+++ b/libavcodec/aarch64/me_cmp_init_aarch64.c
@@ -31,6 +31,8 @@ int ff_pix_abs16_x2_neon(MpegEncContext *v, uint8_t *pix1, 
uint8_t *pix2,
  ptrdiff_t stride, int h);
int ff_pix_abs16_y2_neon(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
  ptrdiff_t stride, int h);
+int ff_pix_abs8_neon(MpegEncContext *s, uint8_t *blk1, uint8_t *blk2,
+  ptrdiff_t stride, int h);

int sse16_neon(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
  ptrdiff_t stride, int h);
@@ -48,8 +50,10 @@ av_cold void ff_me_cmp_init_aarch64(MECmpContext *c, 
AVCodecContext *avctx)
c->pix_abs[0][1] = ff_pix_abs16_x2_neon;
c->pix_abs[0][2] = ff_pix_abs16_y2_neon;
c->pix_abs[0][3] = ff_pix_abs16_xy2_neon;
+c->pix_abs[1][0] = ff_pix_abs8_neon;

c->sad[0] = ff_pix_abs16_neon;
+c->sad[1] = ff_pix_abs8_neon;
c->sse[0] = sse16_neon;
c->sse[1] = sse8_neon;
c->sse[2] = sse4_neon;
diff --git a/libavcodec/aarch64/me_cmp_neon.S b/libavcodec/aarch64/me_cmp_neon.S
index dcaffc9b73..f2dd63ced1 100644
--- a/libavcodec/aarch64/me_cmp_neon.S
+++ b/libavcodec/aarch64/me_cmp_neon.S
@@ -72,6 +72,59 @@ function ff_pix_abs16_neon, export=1
ret
endfunc

+function ff_pix_abs8_neon, export=1
+// x0   unused
+// x1   uint8_t *pix1
+// x2   uint8_t *pix2
+// x3   ptrdiff_t stride
+// x4   int h
+
+movid18, #0
+cmp w4, #4
+b.lt2f
+
+// make 4 iterations at once
+1:
+ld1 {v0.8b}, [x1], x3   // Load pix1 for first 
iteration
+ld1 {v1.8b}, [x2], x3   // Load pix2 for first 
iteration
+uabdl   v30.8h, v0.8b, v1.8b// Absolute 
difference, first iteration
+ld1 {v2.8b}, [x1], x3   // Load pix1 for 
second iteration
+ld1 {v3.8b}, [x2], x3   // Load pix2 for 
second iteration
+uabal   v30.8h, v2.8b, v3.8b// Absolute 
difference, second iteration
+ld1 {v4.8b}, [x1], x3   // Load pix1 for third 
iteration
+ld1 {v5.8b}, [x2], x3   // Load pix2 for third 
iteration
+uabal   v30.8h, v4.8b, v5.8b// Absolute 
difference, third iteration
+ld1 {v6.8b}, [x1], x3   // Load pix1 for 
foruth iteration
+ld1 {v7.8b}, [x2], x3   // Load pix2 for 
fourth iteration
+uabal   v30.8h, v6.8b, v7.8b// Absolute 
difference, foruth iteration


This is maybe the simplest example so far, where the unrolled version here 
just is 4 identical serial copies of the same set of 3 instructions; this 
maybe helps a bit on some CPUs, but it doesn't help nearly as much as it 
can on others, if it would be better unrolled.


I.e., same comments as for the other patches; improve interleaving, don't 
do uaddlv once per iteration.


// Martin

___
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/aarch64: Add neon implementation for pix_abs16_y2

2022-08-04 Thread Martin Storsjö

On Mon, 25 Jul 2022, Hubert Mazur wrote:


Provide optimized implementation of pix_abs16_y2 function for arm64.

Performance comparison tests are shown below.
pix_abs_0_2_c: 308.5
pix_abs_0_2_neon: 39.2

Benchmarks and tests run with checkasm tool on AWS Graviton 3.

Signed-off-by: Hubert Mazur 
---
libavcodec/aarch64/me_cmp_init_aarch64.c |  3 +
libavcodec/aarch64/me_cmp_neon.S | 73 
2 files changed, 76 insertions(+)


Please do the same optimizations as done for pix_abs_xy2 in 
b46de9aba436dea0cff76f3ed0f7c98448367fd0, 
68a03f64240dcbe408c3fd43d1071a105508a588 and 
4136405c86162063e45d40d55c9985f348d4ea0a for this function too
("aarch64: me_cmp: Interleave some of the loads in ff_pix_abs16_xy2_neon", 
"aarch64: me_cmp: Switch from uabd to uabal in ff_pix_abs16_xy2_neon" and 
"aarch64: me_cmp: Don't do uaddlv once per iteration").


// Martin

___
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/aarch64: Add neon implementation for sse8

2022-08-04 Thread Martin Storsjö

On Mon, 25 Jul 2022, Hubert Mazur wrote:


Provide optimized implementation of sse8 function for arm64.

Performance comparison tests are shown below.
- sse_1_c: 133.0
- sse_1_neon: 36.7

Benchmarks and tests run with checkasm tool on AWS Graviton 3.

Signed-off-by: Hubert Mazur 
---
libavcodec/aarch64/me_cmp_init_aarch64.c |  3 +
libavcodec/aarch64/me_cmp_neon.S | 72 
2 files changed, 75 insertions(+)


The same comments as for sse16 and sse4 apply here too.

// Martin

___
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/aarch64: Add neon implementation for sse4

2022-08-04 Thread Martin Storsjö

On Mon, 25 Jul 2022, Hubert Mazur wrote:


Provide neon implementation for sse4 function.

Performance comparison tests are shown below.
- sse_2_c: 74.0
- sse_2_neon: 24.0

Benchmarks and tests are run with checkasm tool on AWS Graviton 3.

Signed-off-by: Hubert Mazur 
---
libavcodec/aarch64/me_cmp_init_aarch64.c |  3 ++
libavcodec/aarch64/me_cmp_neon.S | 65 
2 files changed, 68 insertions(+)

diff --git a/libavcodec/aarch64/me_cmp_init_aarch64.c 
b/libavcodec/aarch64/me_cmp_init_aarch64.c
index 3ff5767bd0..72a2062e7e 100644
--- a/libavcodec/aarch64/me_cmp_init_aarch64.c
+++ b/libavcodec/aarch64/me_cmp_init_aarch64.c
@@ -32,6 +32,8 @@ int ff_pix_abs16_x2_neon(MpegEncContext *v, uint8_t *pix1, 
uint8_t *pix2,

int sse16_neon(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
  ptrdiff_t stride, int h);
+int sse4_neon(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+  ptrdiff_t stride, int h);

av_cold void ff_me_cmp_init_aarch64(MECmpContext *c, AVCodecContext *avctx)
{
@@ -44,5 +46,6 @@ av_cold void ff_me_cmp_init_aarch64(MECmpContext *c, 
AVCodecContext *avctx)

c->sad[0] = ff_pix_abs16_neon;
c->sse[0] = sse16_neon;
+c->sse[2] = sse4_neon;
}
}
diff --git a/libavcodec/aarch64/me_cmp_neon.S b/libavcodec/aarch64/me_cmp_neon.S
index 98c912b608..3336d88848 100644
--- a/libavcodec/aarch64/me_cmp_neon.S
+++ b/libavcodec/aarch64/me_cmp_neon.S
@@ -352,3 +352,68 @@ function sse16_neon, export=1
ret

endfunc
+
+function sse4_neon, export=1
+// x0 - unused
+// x1 - pix1
+// x2 - pix2
+// x3 - stride
+// w4 - h
+
+movid18, #0
+movid17, #0


In the current implementation, it doesn't seem like d17 needs to be 
initialized here



+cmp w4, #4
+b.le2f
+
+// make 4 iterations at once
+1:
+
+// res = abs(pix1[0] - pix2[0])
+// res * res
+
+ld1 {v0.s}[0], [x1], x3 // Load pix1, first 
iteration
+ld1 {v1.s}[0], [x2], x3 // Load pix2, first 
iteration
+uabdl   v30.8h, v0.8b, v1.8b// Absolute 
difference, first iteration


Right now, half of the values calculated by uabdl are unused; you could 
try loading two iterations into v0.s[0] and v0.s[1] so that the full 
.8b register gets used. Doing that would reduce the number of uabdl 
instructions from 4 to 2 - but it might make it harder to interleave 
instructions efficiently. So after all, maybe it's not worth if, it we 
can make the loads more efficiently interleaved this way?


Again, also here, it'd be good to interleave things more efficiently, e.g. 
like this:


   ld1 first
   ld1 first
   ld1 second
   ld1 second
   uabdl first
   ld1 third
   ld1 third
   uabdl second
   umull first
   ld1 fourth
   ld1 fourth
   uabdl third
   umlal second
   uabdl fourth
   umlal third
   umlal fourth


+ld1 {v2.s}[0], [x1], x3 // Load pix1, second 
iteration
+ld1 {v3.s}[0], [x2], x3 // Load pix2, second 
iteration
+umull   v16.4s, v30.4h, v30.4h  // Multiply vectors, 
first iteration
+uabdl   v29.8h, v2.8b, v3.8b// Absolute 
difference, second iteration
+ld1 {v4.s}[0], [x1], x3 // Load pix1, third 
iteration
+ld1 {v5.s}[0], [x2], x3 // Load pix2, third 
iteration
+umlal   v16.4s, v29.4h, v29.4h  // Multiply and 
accumulate, second iteration
+uabdl   v28.8h, v4.8b, v5.8b// Absolute 
difference, third iteration
+ld1 {v6.s}[0], [x1], x3 // Load pix1, fourth 
iteration
+ld1 {v7.s}[0], [x2], x3 // Load pix2, fourth 
iteration
+umlal   v16.4s, v28.4h, v28.4h  // Multiply and 
accumulate, third iteration
+uabdl   v27.8h, v6.8b, v7.8b// Absolue difference, 
fourth iteration
+umlal   v16.4s, v27.4h, v27.4h  // Multiply and 
accumulate, fourth iteration
+
+uaddlv  d17, v16.4s // Add vector
+add d18, d18, d17


As usual, don't do any *add*v within the loop, defer it as far as 
possible. Here you're accumulating in 32 bit elements, so it will surely 
fit the results from the whole algorithm.


Also, if you get rid of the uaddlv here, you can also accumulate into two 
separate .4s registers that you only add at the end; that allows two umlal 
instructions to possibly execute in parallel without waiting for each 
other (provided that the cpu has enough execution units for that).


// Martin

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

To unsubscribe, 

Re: [FFmpeg-devel] [PATCH 2/2] RFC: checkasm: motion: Test different h parameters

2022-08-04 Thread Martin Storsjö

On Wed, 13 Jul 2022, Martin Storsjö wrote:


Previously, the checkasm test always passed h=8, so no other cases
were tested.

Out of the me_cmp functions, in practice, some functions are hardcoded
to always assume a 8x8 block (ignoring the h parameter), while others
do use the parameter. For those with hardcoded height, both the
reference C function and the assembly implementations ignore the
parameter similarly.

The documentation for the functions indicate that heights between
w/2 and 2*w, within the range of 4 to 16, should be supported. This
patch just tests random heights in that range, without knowing what
width the current function actually uses.
---
I'm not sure if it's good to have checkasm exercise cases that
don't occur in practice or not. In particular, the aarch64
functions have a separate implementation for non-multiple-of-4
height, which probably doesn't ever get called in practice, while
other SIMD implementations lack that.

Alternatively, we'd improve the documentation for the expectations
for these functions and make the test match that, and remove the
unused non-multiple-of-4 case in the aarch64 assembly.
---
tests/checkasm/motion.c | 10 ++
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tests/checkasm/motion.c b/tests/checkasm/motion.c
index 0112822174..79e4358941 100644
--- a/tests/checkasm/motion.c
+++ b/tests/checkasm/motion.c
@@ -45,7 +45,7 @@ static void test_motion(const char *name, me_cmp_func 
test_func)
/* motion estimation can look up to 17 bytes ahead */
static const int look_ahead = 17;

-int i, x, y, d1, d2;
+int i, x, y, h, d1, d2;
uint8_t *ptr;

LOCAL_ALIGNED_16(uint8_t, img1, [WIDTH * HEIGHT]);
@@ -68,14 +68,16 @@ static void test_motion(const char *name, me_cmp_func 
test_func)
for (i = 0; i < ITERATIONS; i++) {
x = rnd() % (WIDTH - look_ahead);
y = rnd() % (HEIGHT - look_ahead);
+// Pick a random h between 4 and 16; pick an even value.
+h = 4 + ((rnd() % (16 + 1 - 4)) & ~1);

ptr = img2 + y * WIDTH + x;
-d2 = call_ref(NULL, img1, ptr, WIDTH, 8);
-d1 = call_new(NULL, img1, ptr, WIDTH, 8);
+d2 = call_ref(NULL, img1, ptr, WIDTH, h);
+d1 = call_new(NULL, img1, ptr, WIDTH, h);

if (d1 != d2) {
fail();
-printf("func: %s, x=%d y=%d, error: asm=%d c=%d\n", name, x, 
y, d1, d2);
+printf("func: %s, x=%d y=%d h=%d, error: asm=%d c=%d\n", name, 
x, y, h, d1, d2);
break;
}
}
--
2.25.1


Ping

// Martin
___
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] x86: Don't hardcode the height to 8 in sad8_xy2_mmx

2022-08-04 Thread Martin Storsjö

On Wed, 13 Jul 2022, Martin Storsjö wrote:


The height is hardcoded in some of the me_cmp functions, but not
in all of them. But in the case of all other functions, it's hardcoded
in the same place in SIMD functions as in the C reference functions,
while this one function differs from the behaviour of the C code.

(Before 542765ce3eccbca587d54262a512cbdb1407230d, there were a
couple other sad8_*_mmx functions with similar hardcoded height.)
---
libavcodec/x86/me_cmp_init.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/x86/me_cmp_init.c b/libavcodec/x86/me_cmp_init.c
index 61e9396b8f..dcc2621276 100644
--- a/libavcodec/x86/me_cmp_init.c
+++ b/libavcodec/x86/me_cmp_init.c
@@ -202,13 +202,12 @@ static inline int sum_mmx(void)
static int sad8_xy2_ ## suf(MpegEncContext *v, uint8_t *blk2,   \
uint8_t *blk1, ptrdiff_t stride, int h) \
{   \
-av_assert2(h == 8); \
__asm__ volatile (  \
"pxor %%mm7, %%mm7 \n\t"\
"pxor %%mm6, %%mm6 \n\t"\
::);\
\
-sad8_4_ ## suf(blk1, blk2, stride, 8);  \
+sad8_4_ ## suf(blk1, blk2, stride, h);  \
\
return sum_ ## suf();   \
}   \
--
2.25.1


Ping, does this seem reasonable? Michael indicated a desire to make the 
me_cmp functions more general and flexible than what they are today, and 
this would be a first step to making checkasm test such cases.


// Martin
___
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/aarch64: Add neon implementation for sse16

2022-08-04 Thread Martin Storsjö

On Mon, 25 Jul 2022, Hubert Mazur wrote:


Provide neon implementation for sse16 function.

Performance comparison tests are shown below.
- sse_0_c: 273.0
- sse_0_neon: 48.2

Benchmarks and tests run with checkasm tool on AWS Graviton 3.

Signed-off-by: Hubert Mazur 
---
libavcodec/aarch64/me_cmp_init_aarch64.c |  4 ++
libavcodec/aarch64/me_cmp_neon.S | 82 
2 files changed, 86 insertions(+)



+// iterate by one
+2:
+
+ld1 {v0.16b}, [x1], x3  // Load pix1
+ld1 {v1.16b}, [x2], x3  // Load pix2
+
+uabdv30.16b, v0.16b, v1.16b
+umull   v29.8h, v0.8b, v1.8b
+umull2  v28.8h, v0.16b, v1.16b


This should probably be using v30 instead of v0/v1 in the umull here.

The whole codepath for non-modulo-4 heights is untested in practice. You 
can apply the patches from 
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=7028 to make 
checkasm test it, so please make sure that the uncommon codepaths in the 
patches do work too.


// Martin

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