Re: [FFmpeg-devel] [PATCH v5 3/3] ffmpeg: add video heartbeat capability to fix_sub_duration

2022-10-11 Thread Nicolas George
Jan Ekström (12022-10-10):
> From: Jan Ekström 
> 
> Splits the currently handled subtitle at random access point
> packets that can be configured to follow a specific output stream.
> 
> This way the subtitle - which is known to be shown at this time
> can be split and passed to muxer before its full duration is
> yet known.

Please document the drawbacks of doing using this option.

Regards,

-- 
  Nicolas George
___
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] aarch64: Implement stack spilling in a consistent way.

2022-10-11 Thread Reimar Döffinger

Hi Martin,

> On 10 Oct 2022, at 23:29, Martin Storsjö  wrote:
> 
> On Sun, 9 Oct 2022, reimar.doeffin...@gmx.de wrote:
> 
>> From: Reimar Döffinger 
>> 
>> Currently it is done in several different ways, which
>> might cause needless dependencies or in case of
>> tx_float_neon.S is incorrect.
> 
> This looks reasonable to me, assuming that it passes fate. Do you want to 
> push it yourself, or do you want me to do it?

Thanks, I pushed it.
I had only run checkasm on it (I had made a couple of mistakes first), but it 
also passes fate.

___
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 3/3] ffmpeg: add video heartbeat capability to fix_sub_duration

2022-10-11 Thread Soft Works


> -Original Message-
> From: ffmpeg-devel  On Behalf Of Jan
> Ekström
> Sent: Monday, October 10, 2022 2:45 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH v5 3/3] ffmpeg: add video heartbeat
> capability to fix_sub_duration
> 
> From: Jan Ekström 
> 
> Splits the currently handled subtitle at random access point
> packets that can be configured to follow a specific output stream.
> 
> This way the subtitle - which is known to be shown at this time
> can be split and passed to muxer before its full duration is
> yet known.
> 
> Co-authored-by: Andrzej Nadachowski 
> Co-authored-by: Bernard Boulay 
> 
> Signed-off-by: Jan Ekström 

I hope you don't mind me to mention that my subtitle filtering
patchset provides a way more comprehensive and flexible approach
to this.

Best,
softworkz
___
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 v3] lavc/aarch64: add hevc horizontal qpel/uni/bi

2022-10-11 Thread J. Dekker
checkasm benchmark on Ampere Altra (Neoverse N1):

put_hevc_qpel_bi_h4_8_c: 170.7
put_hevc_qpel_bi_h4_8_neon: 64.5
put_hevc_qpel_bi_h6_8_c: 373.7
put_hevc_qpel_bi_h6_8_neon: 130.2
put_hevc_qpel_bi_h8_8_c: 662.0
put_hevc_qpel_bi_h8_8_neon: 138.5
put_hevc_qpel_bi_h12_8_c: 1529.5
put_hevc_qpel_bi_h12_8_neon: 422.0
put_hevc_qpel_bi_h16_8_c: 2735.5
put_hevc_qpel_bi_h16_8_neon: 560.5
put_hevc_qpel_bi_h24_8_c: 6015.7
put_hevc_qpel_bi_h24_8_neon: 1636.0
put_hevc_qpel_bi_h32_8_c: 10779.0
put_hevc_qpel_bi_h32_8_neon: 2204.5
put_hevc_qpel_bi_h48_8_c: 24375.0
put_hevc_qpel_bi_h48_8_neon: 4984.0
put_hevc_qpel_bi_h64_8_c: 42768.0
put_hevc_qpel_bi_h64_8_neon: 8795.7
put_hevc_qpel_h4_8_c: 149.0
put_hevc_qpel_h4_8_neon: 55.7
put_hevc_qpel_h6_8_c: 321.2
put_hevc_qpel_h6_8_neon: 106.0
put_hevc_qpel_h8_8_c: 578.7
put_hevc_qpel_h8_8_neon: 133.2
put_hevc_qpel_h12_8_c: 1279.0
put_hevc_qpel_h12_8_neon: 391.7
put_hevc_qpel_h16_8_c: 2286.2
put_hevc_qpel_h16_8_neon: 519.7
put_hevc_qpel_h24_8_c: 5100.7
put_hevc_qpel_h24_8_neon: 1546.2
put_hevc_qpel_h32_8_c: 9022.0
put_hevc_qpel_h32_8_neon: 2060.2
put_hevc_qpel_h48_8_c: 20293.5
put_hevc_qpel_h48_8_neon: 4656.7
put_hevc_qpel_h64_8_c: 36037.0
put_hevc_qpel_h64_8_neon: 8262.7
put_hevc_qpel_uni_h4_8_c: 162.2
put_hevc_qpel_uni_h4_8_neon: 61.7
put_hevc_qpel_uni_h6_8_c: 355.2
put_hevc_qpel_uni_h6_8_neon: 114.2
put_hevc_qpel_uni_h8_8_c: 651.0
put_hevc_qpel_uni_h8_8_neon: 135.7
put_hevc_qpel_uni_h12_8_c: 1412.5
put_hevc_qpel_uni_h12_8_neon: 402.7
put_hevc_qpel_uni_h16_8_c: 2551.0
put_hevc_qpel_uni_h16_8_neon: 533.5
put_hevc_qpel_uni_h24_8_c: 5782.2
put_hevc_qpel_uni_h24_8_neon: 1578.7
put_hevc_qpel_uni_h32_8_c: 10586.5
put_hevc_qpel_uni_h32_8_neon: 2102.2
put_hevc_qpel_uni_h48_8_c: 23812.0
put_hevc_qpel_uni_h48_8_neon: 4739.5
put_hevc_qpel_uni_h64_8_c: 42958.7
put_hevc_qpel_uni_h64_8_neon: 8366.5

Signed-off-by: J. Dekker 
---

 Summary of changes since last iteration:
 - Interleaved stores
 - Changed tiling to loop more naturally
 - Increased code reuse (.text reduction by ~60%)
 - Simplified function variations through .req

 libavcodec/aarch64/Makefile   |   1 +
 libavcodec/aarch64/hevcdsp_init_aarch64.c |  67 +++
 libavcodec/aarch64/hevcdsp_qpel_neon.S| 484 ++
 3 files changed, 552 insertions(+)
 create mode 100644 libavcodec/aarch64/hevcdsp_qpel_neon.S

diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile
index 9ce21566c6..02fb51c3ab 100644
--- a/libavcodec/aarch64/Makefile
+++ b/libavcodec/aarch64/Makefile
@@ -67,4 +67,5 @@ NEON-OBJS-$(CONFIG_VP9_DECODER) += 
aarch64/vp9itxfm_16bpp_neon.o   \
aarch64/vp9mc_neon.o
 NEON-OBJS-$(CONFIG_HEVC_DECODER)+= aarch64/hevcdsp_idct_neon.o 
\
aarch64/hevcdsp_init_aarch64.o  
\
+   aarch64/hevcdsp_qpel_neon.o 
\
aarch64/hevcdsp_sao_neon.o
diff --git a/libavcodec/aarch64/hevcdsp_init_aarch64.c 
b/libavcodec/aarch64/hevcdsp_init_aarch64.c
index 644cc17715..44399b05d8 100644
--- a/libavcodec/aarch64/hevcdsp_init_aarch64.c
+++ b/libavcodec/aarch64/hevcdsp_init_aarch64.c
@@ -69,6 +69,46 @@ void ff_hevc_sao_edge_filter_16x16_8_neon(uint8_t *dst, 
const uint8_t *src, ptrd
   const int16_t *sao_offset_val, int 
eo, int width, int height);
 void ff_hevc_sao_edge_filter_8x8_8_neon(uint8_t *dst, const uint8_t *src, 
ptrdiff_t stride_dst,
 const int16_t *sao_offset_val, int eo, 
int width, int height);
+void ff_hevc_put_hevc_qpel_h4_8_neon(int16_t *dst, uint8_t *_src, ptrdiff_t 
_srcstride, int height,
+ intptr_t mx, intptr_t my, int width);
+void ff_hevc_put_hevc_qpel_h6_8_neon(int16_t *dst, uint8_t *_src, ptrdiff_t 
_srcstride, int height,
+ intptr_t mx, intptr_t my, int width);
+void ff_hevc_put_hevc_qpel_h8_8_neon(int16_t *dst, uint8_t *_src, ptrdiff_t 
_srcstride, int height,
+ intptr_t mx, intptr_t my, int width);
+void ff_hevc_put_hevc_qpel_h12_8_neon(int16_t *dst, uint8_t *_src, ptrdiff_t 
_srcstride, int height,
+  intptr_t mx, intptr_t my, int width);
+void ff_hevc_put_hevc_qpel_h16_8_neon(int16_t *dst, uint8_t *_src, ptrdiff_t 
_srcstride, int height,
+  intptr_t mx, intptr_t my, int width);
+void ff_hevc_put_hevc_qpel_uni_h4_8_neon(uint8_t *_dst, ptrdiff_t _dststride, 
uint8_t *_src,
+ ptrdiff_t _srcstride, int height, 
intptr_t mx, intptr_t my,
+ int width);
+void ff_hevc_put_hevc_qpel_uni_h6_8_neon(uint8_t *_dst, ptrdiff_t _dststride, 
uint8_t *_src,
+ ptrdiff_t _srcstride, int height, 
intptr_t mx, intptr_t my,
+   

Re: [FFmpeg-devel] [PATCH 1/3] lavc/encode: make sure frame timebase matches encoder, when set

2022-10-11 Thread Anton Khirnov
Quoting Marton Balint (2022-10-05 20:54:46)
> 
> 
> On Tue, 4 Oct 2022, Anton Khirnov wrote:
> 
> > Quoting Marton Balint (2022-09-28 21:54:11)
> >>
> >>
> >> On Wed, 28 Sep 2022, Anton Khirnov wrote:
> >>
> >>> AVFrame.time_base has been added recently, but is currently not used for
> >>> anything. Prepare for its use in encoders by rejecting frames where
> >>> time_base is set, but differs from the AVCodecContext one.
> >>
> >> How is that not an API break? Users can encode AVFrames with anything in
> >> the AVFrame->time_base right now, if you change that behaviour, that will
> >> surely break some code. That is why it was explicitly documented that
> >> it will be ignored by encoders by default.
> >
> > Why would there be anything in that field? No code we have currently
> > sets that field or does anything with it.
> 
> It is a public field which was explicitly documented to be ignored by 
> filters or encoders. The user could store any data in it, because the 
> documentation of the field ensured it will not be a problem.
> 
> If you read back the old threads which added AVFrame->time_base 
> you will find the reasoning behind the original comments, in fact,
> you suggested the actual wording for the documentation of the field, and 
> now you want now to change the semantics of the field which contradicts 
> the existing documentation... Usually we introduce a new field and 
> deprecate the old if we want to do something like this.

Honestly I do not remember why I wrote it that way and it now seems like
a mistake to me. We did not add this field as random-number storage for
our callers, we added it to use it in the libraries.

> One could argue that this break is "small" enough, to not dance around it, 
> but I don't really see the benefit of the change in the first place. So 
> the real question is why do you want to start using AVFrame->time_base in 
> encoders, and what is the feature which is undoable with the current 
> AVCodecContext->time_base?

Where I'm going with this is duration handling in encoders. libavcodec
currently disregards AVFrame.duration completely, while properly it
should set output AVPacket.duration from its corresponding
AVFrame.duration. The problem with that is that we cannot just use
AVFrame.duration, because there is no guarantee that the caller is aware
of it and set in the correct timebase. E.g. ffmpeg.c currently does not
touch AVFrame.duration, so whatever value it acquired along the way
(from the decoder or some filter) will linger there in whatever timebase
it was originally in, which is not necessarily equal to the encoder
timebase.

So my idea was to use the timebase being set as an indicator of the
caller being duration-aware. But on more thought, this seems rather
obscure and an explicit option is probably better.

-- 
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] [PATCH 2/5] lavfi/vf_deinterlace_qsv: set output frame durations

2022-10-11 Thread Anton Khirnov
---
 libavfilter/vf_deinterlace_qsv.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavfilter/vf_deinterlace_qsv.c b/libavfilter/vf_deinterlace_qsv.c
index 3065d6ac95..98ed7283ad 100644
--- a/libavfilter/vf_deinterlace_qsv.c
+++ b/libavfilter/vf_deinterlace_qsv.c
@@ -516,6 +516,11 @@ static int process_frame(AVFilterContext *ctx, const 
AVFrame *in,
 out->pts++;
 s->last_pts = out->pts;
 
+if (outlink->frame_rate.num && outlink->frame_rate.den)
+out->duration = av_rescale_q(1, av_inv_q(outlink->frame_rate), 
outlink->time_base);
+else
+out->duration = 0;
+
 ret = ff_filter_frame(outlink, out);
 if (ret < 0)
 return ret;
-- 
2.35.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/5] lavfi/vf_frei0r: set frame durations for frei0r_src

2022-10-11 Thread Anton Khirnov
This source produces CFR output.
---
 libavfilter/vf_frei0r.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c
index 1e01114b76..66351d6678 100644
--- a/libavfilter/vf_frei0r.c
+++ b/libavfilter/vf_frei0r.c
@@ -488,6 +488,7 @@ static int source_request_frame(AVFilterLink *outlink)
 
 frame->sample_aspect_ratio = (AVRational) {1, 1};
 frame->pts = s->pts++;
+frame->duration = 1;
 
 s->update(s->instance, av_rescale_q(frame->pts, s->time_base, 
(AVRational){1,1000}),
NULL, (uint32_t *)frame->data[0]);
-- 
2.35.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 4/5] lavfi/vf_minterpolate: set output frame durations

2022-10-11 Thread Anton Khirnov
This filter produces CFR output.
---
 libavfilter/vf_minterpolate.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavfilter/vf_minterpolate.c b/libavfilter/vf_minterpolate.c
index 97d0e96c59..f2de61ca39 100644
--- a/libavfilter/vf_minterpolate.c
+++ b/libavfilter/vf_minterpolate.c
@@ -1189,6 +1189,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*avf_in)
 
 av_frame_copy_props(avf_out, mi_ctx->frames[NB_FRAMES - 1].avf);
 avf_out->pts = mi_ctx->out_pts++;
+avf_out->duration = 1;
 
 interpolate(inlink, avf_out);
 
-- 
2.35.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 5/5] lavfi/src_avsynctest: set video frame durations

2022-10-11 Thread Anton Khirnov
This filter produces CFR video output.
---
 libavfilter/src_avsynctest.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavfilter/src_avsynctest.c b/libavfilter/src_avsynctest.c
index c78e517ac3..78e4a2ba50 100644
--- a/libavfilter/src_avsynctest.c
+++ b/libavfilter/src_avsynctest.c
@@ -348,6 +348,7 @@ static int video_frame(AVFilterLink *outlink)
 }
 
 out->pts = s->vpts++;
+out->duration = 1;
 
 return ff_filter_frame(outlink, out);
 }
-- 
2.35.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/5] lavfi/vf_framepack: properly set output duration for framesequence output

2022-10-11 Thread Anton Khirnov
Output has to be CFR in this case.
---
 libavfilter/vf_framepack.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_framepack.c b/libavfilter/vf_framepack.c
index f30909ccff..6ea88df8b2 100644
--- a/libavfilter/vf_framepack.c
+++ b/libavfilter/vf_framepack.c
@@ -329,8 +329,10 @@ static int try_push_frame(AVFilterContext *ctx)
 
 for (i = 0; i < 2; i++) {
 // set correct timestamps
-if (pts != AV_NOPTS_VALUE)
+if (pts != AV_NOPTS_VALUE) {
 s->input_views[i]->pts = i == 0 ? pts * 2 : pts * 2 + 
av_rescale_q(1, av_inv_q(outlink->frame_rate), outlink->time_base);
+s->input_views[i]->duration = av_rescale_q(1, 
av_inv_q(outlink->frame_rate), outlink->time_base);
+}
 
 // set stereo3d side data
 stereo = av_stereo3d_create_side_data(s->input_views[i]);
-- 
2.35.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] [crop support for matroska demuxer, V3 1/3] libavcodec: Add crop related fields to structure AVCodecContext and AVCodecParameters.

2022-10-11 Thread Anton Khirnov
Quoting OvchinnikovDmitrii (2022-10-07 16:59:40)
> ---
>  libavcodec/avcodec.h   | 35 +++
>  libavcodec/codec_par.h |  8 
>  libavcodec/options_table.h |  4 
>  3 files changed, 47 insertions(+)
> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 7365eb5cc0..d28a7cc022 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -380,6 +380,19 @@ typedef struct RcOverride{
>   */
>  #define AV_GET_ENCODE_BUFFER_FLAG_REF (1 << 0)
>  
> +/**
> +* Video decoding only. Certain container support cropping, meaning that
> +* only a sub-rectangle of the decoded frame is intended for display.
> +* Certain codec supports cropping as well.This option controls how
> +* cropping is handled by libavcodec when  container cropping and
> +* codec cropping exist.
> +*/
> +enum CONTAINER_CROPPING_POLICY_TYPE {
> +FF_CONTAINER_CROPPING_IGNORE = 0,
> +FF_CONTAINER_CROPPING_ADDITION,
> +FF_CONTAINER_CROPPING_OVERWRITE
> +};
> +
>  struct AVCodecInternal;
>  
>  /**
> @@ -2057,6 +2070,28 @@ typedef struct AVCodecContext {
>   * The decoder can then override during decoding as needed.
>   */
>  AVChannelLayout ch_layout;
> +
> +/* When set to 1 (the default), libavcodec will apply container cropping
> + * to codec cropping additionally.
> + *
> + * When set to 2, libavcodec will use container cropping to overwrite
> + * codec cropping (the final cropping uses container cropping parameters)
> + *
> + * When set to 0, libavcodec will ignore container cropping parameters
> + * (the final cropping uses codec cropping parameters)
> + *
> + * This field works with "apply_cropping". Only if apply_cropping is 1, 
> this
> + * field works
> + */
> +enum CONTAINER_CROPPING_POLICY_TYPE container_apply_cropping;
> +
> +/**
> + * The cropping parameters from container.
> + */
> +int container_crop_top;
> +int container_crop_left;
> +int container_crop_bottom;
> +int container_crop_right;

I don't see why should a decoder deal with this at all? This can be just
as well done by the caller.

-- 
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 v3] avformat/hls: Add option to retry failed segments for hls

2022-10-11 Thread ChenLiucheng


> On Oct 11, 2022, at 14:19, Steven Liu  > wrote:
> 
> Steven Liu mailto:lingjiujia...@gmail.com>> 
> 于2022年10月11日周二 10:55写道:
>> 
>> gnattu mailto:gnatt...@me.com>> 于2022年10月10日周一 20:09写道:
>>> 
>>> Current HLS implementation simply skip a failed segment to catch up
>>> the stream, but this is not optimal for some use cases like livestream
>>> recording.
>>> Add an option to retry a failed segment to ensure the output file is
>>> a complete stream.
>>> 
>>> Signed-off-by: gnattu mailto:gnatt...@me.com>>
>>> ---
>>> Fixed commit message wrap
>>> libavformat/hls.c | 15 ++-
>>> 1 file changed, 14 insertions(+), 1 deletion(-)
>>> 
>>> diff --git a/libavformat/hls.c b/libavformat/hls.c
>>> index e622425e80..2b977f9132 100644
>>> --- a/libavformat/hls.c
>>> +++ b/libavformat/hls.c
>>> @@ -225,6 +225,7 @@ typedef struct HLSContext {
>>> int http_persistent;
>>> int http_multiple;
>>> int http_seekable;
>>> +int seg_max_retry;
>>> AVIOContext *playlist_pb;
>>> HLSCryptoContext  crypto_ctx;
>>> } HLSContext;
>>> @@ -1472,6 +1473,7 @@ static int read_data(void *opaque, uint8_t *buf, int 
>>> buf_size)
>>> int ret;
>>> int just_opened = 0;
>>> int reload_count = 0;
>>> +int segment_retries = 0;
>>> struct segment *seg;
>>> 
>>> restart:
>>> @@ -1563,9 +1565,18 @@ reload:
>>> av_log(v->parent, AV_LOG_WARNING, "Failed to open segment 
>>> %"PRId64" of playlist %d\n",
>>>v->cur_seq_no,
>>>v->index);
>>> -v->cur_seq_no += 1;
>>> +if (segment_retries >= c->seg_max_retry) {
>>> +av_log(v->parent, AV_LOG_WARNING, "Segment %"PRId64" of 
>>> playlist %d failed too many times, skipping\n",
>>> +   v->cur_seq_no,
>>> +   v->index);
>>> +v->cur_seq_no += 1;
>>> +segment_retries = 0;
>>> +} else {
>>> +segment_retries += 1;
>>> +}
>>> goto reload;
>>> }
>>> +segment_retries = 0;
>>> just_opened = 1;
>>> }
>>> 
>>> @@ -2549,6 +2560,8 @@ static const AVOption hls_options[] = {
>>> OFFSET(http_seekable), AV_OPT_TYPE_BOOL, { .i64 = -1}, -1, 1, 
>>> FLAGS},
>>> {"seg_format_options", "Set options for segment demuxer",
>>> OFFSET(seg_format_opts), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, 
>>> FLAGS},
>>> +{"seg_max_retry", "Maximum number of times to reload a segment on 
>>> error.",
>>> + OFFSET(seg_max_retry), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, 
>>> FLAGS},
> BTW, Document should add describe about the option.
>>> {NULL}
>>> };
>>> 
>>> --
>>> 2.37.0 (Apple Git-136)
>>> 
>>> ___
>>> 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".
>> 
>> Not sure this functions is usefull. because there have a option named
>> "max_reload" for  playlist reload,
>> but this can be used for segment reload.
>> 
>> Perhaps there have some sence need reload segment, so this lookd ok to me.
> 
>> 
>> 
>> 
>> Thanks
>> Steven


May I have more clarification on this? Like on which aspect it need to have 
more details to better describe this option? I tried to keep the help text as 
concise as possible and I probably missed something here. 
___
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] [crop support for matroska demuxer, V3 1/3] libavcodec: Add crop related fields to structure AVCodecContext and AVCodecParameters.

2022-10-11 Thread Timo Rothenpieler




On 07/10/2022 16:59, OvchinnikovDmitrii wrote:

---
  libavcodec/avcodec.h   | 35 +++
  libavcodec/codec_par.h |  8 
  libavcodec/options_table.h |  4 
  3 files changed, 47 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 7365eb5cc0..d28a7cc022 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -380,6 +380,19 @@ typedef struct RcOverride{
   */
  #define AV_GET_ENCODE_BUFFER_FLAG_REF (1 << 0)
  
+/**

+* Video decoding only. Certain container support cropping, meaning that
+* only a sub-rectangle of the decoded frame is intended for display.
+* Certain codec supports cropping as well.This option controls how
+* cropping is handled by libavcodec when  container cropping and
+* codec cropping exist.
+*/
+enum CONTAINER_CROPPING_POLICY_TYPE {
+FF_CONTAINER_CROPPING_IGNORE = 0,
+FF_CONTAINER_CROPPING_ADDITION,
+FF_CONTAINER_CROPPING_OVERWRITE
+};
+
  struct AVCodecInternal;
  
  /**

@@ -2057,6 +2070,28 @@ typedef struct AVCodecContext {
   * The decoder can then override during decoding as needed.
   */
  AVChannelLayout ch_layout;
+
+/* When set to 1 (the default), libavcodec will apply container cropping
+ * to codec cropping additionally.
+ *
+ * When set to 2, libavcodec will use container cropping to overwrite
+ * codec cropping (the final cropping uses container cropping parameters)
+ *
+ * When set to 0, libavcodec will ignore container cropping parameters
+ * (the final cropping uses codec cropping parameters)
+ *
+ * This field works with "apply_cropping". Only if apply_cropping is 1, 
this
+ * field works
+ */
+enum CONTAINER_CROPPING_POLICY_TYPE container_apply_cropping;
+
+/**
+ * The cropping parameters from container.
+ */
+int container_crop_top;
+int container_crop_left;
+int container_crop_bottom;
+int container_crop_right;
  } AVCodecContext;
  
  /**

diff --git a/libavcodec/codec_par.h b/libavcodec/codec_par.h
index 7660791a12..12d8ceb521 100644
--- a/libavcodec/codec_par.h
+++ b/libavcodec/codec_par.h
@@ -210,6 +210,14 @@ typedef struct AVCodecParameters {
   * Audio only. The channel layout and number of channels.
   */
  AVChannelLayout ch_layout;
+
+/**
+ * The cropping parameters from container.
+ */
+int container_crop_top;
+int container_crop_left;
+int container_crop_bottom;
+int container_crop_right;
  } AVCodecParameters;


I really don't like seeing this in avcodec.
Why does an encoder or decoder need to care about this, given it's 
container level information?


Do you plan on implementing cropping support into all the encoders?
This should be handled via an avfilter, which might get the cropping 
info from the demuxer via site data or something.

___
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] [crop support for matroska demuxer, V3 1/3] libavcodec: Add crop related fields to structure AVCodecContext and AVCodecParameters.

2022-10-11 Thread James Almer

On 10/11/2022 9:43 AM, Timo Rothenpieler wrote:



On 07/10/2022 16:59, OvchinnikovDmitrii wrote:

---
  libavcodec/avcodec.h   | 35 +++
  libavcodec/codec_par.h |  8 
  libavcodec/options_table.h |  4 
  3 files changed, 47 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 7365eb5cc0..d28a7cc022 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -380,6 +380,19 @@ typedef struct RcOverride{
   */
  #define AV_GET_ENCODE_BUFFER_FLAG_REF (1 << 0)
+/**
+* Video decoding only. Certain container support cropping, meaning that
+* only a sub-rectangle of the decoded frame is intended for display.
+* Certain codec supports cropping as well.This option controls how
+* cropping is handled by libavcodec when  container cropping and
+* codec cropping exist.
+*/
+enum CONTAINER_CROPPING_POLICY_TYPE {
+    FF_CONTAINER_CROPPING_IGNORE = 0,
+    FF_CONTAINER_CROPPING_ADDITION,
+    FF_CONTAINER_CROPPING_OVERWRITE
+};
+
  struct AVCodecInternal;
  /**
@@ -2057,6 +2070,28 @@ typedef struct AVCodecContext {
   * The decoder can then override during decoding as 
needed.

   */
  AVChannelLayout ch_layout;
+
+    /* When set to 1 (the default), libavcodec will apply container 
cropping

+ * to codec cropping additionally.
+ *
+ * When set to 2, libavcodec will use container cropping to 
overwrite
+ * codec cropping (the final cropping uses container cropping 
parameters)

+ *
+ * When set to 0, libavcodec will ignore container cropping 
parameters

+ * (the final cropping uses codec cropping parameters)
+ *
+ * This field works with "apply_cropping". Only if apply_cropping 
is 1, this

+ * field works
+ */
+    enum CONTAINER_CROPPING_POLICY_TYPE container_apply_cropping;
+
+    /**
+ * The cropping parameters from container.
+ */
+    int container_crop_top;
+    int container_crop_left;
+    int container_crop_bottom;
+    int container_crop_right;
  } AVCodecContext;
  /**
diff --git a/libavcodec/codec_par.h b/libavcodec/codec_par.h
index 7660791a12..12d8ceb521 100644
--- a/libavcodec/codec_par.h
+++ b/libavcodec/codec_par.h
@@ -210,6 +210,14 @@ typedef struct AVCodecParameters {
   * Audio only. The channel layout and number of channels.
   */
  AVChannelLayout ch_layout;
+
+    /**
+ * The cropping parameters from container.
+ */
+    int container_crop_top;
+    int container_crop_left;
+    int container_crop_bottom;
+    int container_crop_right;
  } AVCodecParameters;


I really don't like seeing this in avcodec.
Why does an encoder or decoder need to care about this, given it's 
container level information?


Do you plan on implementing cropping support into all the encoders?
This should be handled via an avfilter, which might get the cropping 
info from the demuxer via site data or something.


There's logic in decode.c to apply bitstream level cropping (like in 
h264). This could be extended to also apply container level cropping 
exported as packet side data, like you suggested.


How are we handling stream side data, for that matter? Apparently 
injected only on the first output packet, which is then converted into 
frame side data in lavc, and only done by ffplay.c?

___
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/4] avcodec/svq1enc: Inline constants

2022-10-11 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/svq1.h|  7 +++
 libavcodec/svq1enc.c | 13 +
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/libavcodec/svq1.h b/libavcodec/svq1.h
index 0ebc73a933..af8a7dfa04 100644
--- a/libavcodec/svq1.h
+++ b/libavcodec/svq1.h
@@ -42,6 +42,13 @@
 #define SVQ1_BLOCK_INTER_4V 2
 #define SVQ1_BLOCK_INTRA3
 
+#define SVQ1_BLOCK_SKIP_CODE1
+#define SVQ1_BLOCK_SKIP_LEN 1
+#define SVQ1_BLOCK_INTER_CODE   1
+#define SVQ1_BLOCK_INTER_LEN2
+#define SVQ1_BLOCK_INTRA_CODE   0
+#define SVQ1_BLOCK_INTRA_LEN3
+
 extern const int8_t *const ff_svq1_inter_codebooks[6];
 extern const int8_t *const ff_svq1_intra_codebooks[6];
 
diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
index ef6655c2f7..79e9e578ac 100644
--- a/libavcodec/svq1enc.c
+++ b/libavcodec/svq1enc.c
@@ -390,9 +390,8 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane,
 init_put_bits(&s->reorder_pb[i], reorder_buffer[0][i],
   7 * 32);
 if (s->pict_type == AV_PICTURE_TYPE_P) {
-const uint8_t *vlc = 
ff_svq1_block_type_vlc[SVQ1_BLOCK_INTRA];
-put_bits(&s->reorder_pb[5], vlc[1], vlc[0]);
-score[0] = vlc[1] * lambda;
+put_bits(&s->reorder_pb[5], SVQ1_BLOCK_INTRA_LEN, 
SVQ1_BLOCK_INTRA_CODE);
+score[0] = SVQ1_BLOCK_INTRA_LEN * lambda;
 }
 score[0] += encode_block(s, src + 16 * x, NULL, temp, stride,
  5, 64, lambda, 1);
@@ -406,7 +405,6 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane,
 best = 0;
 
 if (s->pict_type == AV_PICTURE_TYPE_P) {
-const uint8_t *vlc = ff_svq1_block_type_vlc[SVQ1_BLOCK_INTER];
 int mx, my, pred_x, pred_y, dxy;
 int16_t *motion_ptr;
 
@@ -417,7 +415,7 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane,
 init_put_bits(&s->reorder_pb[i], reorder_buffer[1][i],
   7 * 32);
 
-put_bits(&s->reorder_pb[5], vlc[1], vlc[0]);
+put_bits(&s->reorder_pb[5], SVQ1_BLOCK_INTER_LEN, 
SVQ1_BLOCK_INTER_CODE);
 
 s->m.pb = s->reorder_pb[5];
 mx  = motion_ptr[0];
@@ -442,14 +440,13 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane,
  decoded, stride, 5, 64, lambda, 
0);
 best  = score[1] <= score[0];
 
-vlc   = ff_svq1_block_type_vlc[SVQ1_BLOCK_SKIP];
 score[2]  = s->mecc.sse[0](NULL, src + 16 * x, ref,
stride, 16);
-score[2] += vlc[1] * lambda;
+score[2] += SVQ1_BLOCK_SKIP_LEN * lambda;
 if (score[2] < score[best] && mx == 0 && my == 0) {
 best = 2;
 s->hdsp.put_pixels_tab[0][0](decoded, ref, stride, 16);
-put_bits(&s->pb, vlc[1], vlc[0]);
+put_bits(&s->pb, SVQ1_BLOCK_SKIP_LEN, 
SVQ1_BLOCK_SKIP_CODE);
 }
 }
 
-- 
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 v3] avformat/hls: Add option to retry failed segments for hls

2022-10-11 Thread Steven Liu
ChenLiucheng  于2022年10月11日周二 20:14写道:
>
>
>
> On Oct 11, 2022, at 14:19, Steven Liu  wrote:
>
> Steven Liu  于2022年10月11日周二 10:55写道:
>
>
> gnattu  于2022年10月10日周一 20:09写道:
>
>
> Current HLS implementation simply skip a failed segment to catch up
> the stream, but this is not optimal for some use cases like livestream
> recording.
> Add an option to retry a failed segment to ensure the output file is
> a complete stream.
>
> Signed-off-by: gnattu 
> ---
> Fixed commit message wrap
> libavformat/hls.c | 15 ++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index e622425e80..2b977f9132 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -225,6 +225,7 @@ typedef struct HLSContext {
> int http_persistent;
> int http_multiple;
> int http_seekable;
> +int seg_max_retry;
> AVIOContext *playlist_pb;
> HLSCryptoContext  crypto_ctx;
> } HLSContext;
> @@ -1472,6 +1473,7 @@ static int read_data(void *opaque, uint8_t *buf, int 
> buf_size)
> int ret;
> int just_opened = 0;
> int reload_count = 0;
> +int segment_retries = 0;
> struct segment *seg;
>
> restart:
> @@ -1563,9 +1565,18 @@ reload:
> av_log(v->parent, AV_LOG_WARNING, "Failed to open segment 
> %"PRId64" of playlist %d\n",
>v->cur_seq_no,
>v->index);
> -v->cur_seq_no += 1;
> +if (segment_retries >= c->seg_max_retry) {
> +av_log(v->parent, AV_LOG_WARNING, "Segment %"PRId64" of 
> playlist %d failed too many times, skipping\n",
> +   v->cur_seq_no,
> +   v->index);
> +v->cur_seq_no += 1;
> +segment_retries = 0;
> +} else {
> +segment_retries += 1;
> +}
> goto reload;
> }
> +segment_retries = 0;
> just_opened = 1;
> }
>
> @@ -2549,6 +2560,8 @@ static const AVOption hls_options[] = {
> OFFSET(http_seekable), AV_OPT_TYPE_BOOL, { .i64 = -1}, -1, 1, FLAGS},
> {"seg_format_options", "Set options for segment demuxer",
> OFFSET(seg_format_opts), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, 
> FLAGS},
> +{"seg_max_retry", "Maximum number of times to reload a segment on 
> error.",
> + OFFSET(seg_max_retry), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS},
>
> BTW, Document should add describe about the option.
>
> {NULL}
> };
>
> --
> 2.37.0 (Apple Git-136)
>
> ___
> 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".
>
>
> Not sure this functions is usefull. because there have a option named
> "max_reload" for  playlist reload,
> but this can be used for segment reload.
>
> Perhaps there have some sence need reload segment, so this lookd ok to me.
>
>
>
>
>
> Thanks
> Steven
>
>
>
> May I have more clarification on this? Like on which aspect it need to have 
> more details to better describe this option? I tried to keep the help text as 
> concise as possible and I probably missed something here.
Do you mean documents? If yes, you need modify the file
./doc/demuxers.texi and add the option description, you can reference
the "max_reload" option.
___
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 0/2] Print filter input/output formats in help output

2022-10-11 Thread ffmpegagent
Example out put for command: ffmpeg -h filters=overlay

Filter overlay
  Overlay a video source on top of the input.
slice threading supported
Inputs:
   #0: main (video), Formats: Dynamic, Default: [yuv420p, yuvj420p, 
yuva420p, nv12, nv21]
   #1: overlay (video), Formats: Dynamic, Default: [yuva420p]
Outputs:
   #0: default (video), Formats: Dynamic, Default: [yuv420p, yuvj420p, 
yuva420p, nv12, nv21]

overlay AVOptions:
[...]



Examples for what it prints in various cases



For pass-through filter links
=

"All (passthrough)"



For filters using query_formats
===

"Dynamic"



For filters using query_formats where a call to query_formats succeeds
==

"Dynamic, Default: [yuv420p, yuvj420p, yuva420p, nv12, nv21]"



For all other cases
===

"[s16p, s32p, fltp, dblp]"



Except in case when all formats are supported
=

(when the number of formats equals the number of available formats)

"All"


softworkz (2):
  avfilter/avfilter: add avfilter_print_config_formats()
  ftools/opt_common: Print filter input/output formats in help output

 doc/APIchanges  |   3 ++
 fftools/opt_common.c|  39 +-
 libavfilter/avfilter.c  | 102 +++-
 libavfilter/avfilter.h  |  12 +
 libavfilter/avfiltergraph.c |  14 +++--
 libavfilter/internal.h  |   9 
 libavfilter/version.h   |   4 +-
 7 files changed, 163 insertions(+), 20 deletions(-)


base-commit: e10e27a2ead8848648b29a1b397cc240206e9c3d
Published-As: 
https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-43%2Fsoftworkz%2Fsubmit_print_formats-v1
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg 
pr-ffstaging-43/softworkz/submit_print_formats-v1
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/43
-- 
ffmpeg-codebot
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 2/2] ftools/opt_common: Print filter input/output formats in help output

2022-10-11 Thread softworkz
From: softworkz 

Exmaple command: ffmpeg -h filters=overlay

Output:

Filter overlay
  Overlay a video source on top of the input.
slice threading supported
Inputs:
   #0: main (video), Formats: Dynamic, Default: [yuv420p, yuvj420p,
  yuva420p, nv12, nv21]
   #1: overlay (video), Formats: Dynamic, Default: [yuva420p]
Outputs:
   #0: default (video), Formats: Dynamic, Default: [yuv420p, yuvj420p,
 yuva420p, nv12, nv21]

overlay AVOptions:
[...]

Signed-off-by: softworkz 
---
 fftools/opt_common.c | 39 +++
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/fftools/opt_common.c b/fftools/opt_common.c
index 8a06df82df..cb9de897a3 100644
--- a/fftools/opt_common.c
+++ b/fftools/opt_common.c
@@ -504,7 +504,8 @@ static void show_help_filter(const char *name)
 {
 #if CONFIG_AVFILTER
 const AVFilter *f = avfilter_get_by_name(name);
-int i, count;
+AVBPrint bp;
+int i, count, ret;
 
 if (!name) {
 av_log(NULL, AV_LOG_ERROR, "No filter name specified.\n");
@@ -514,40 +515,54 @@ static void show_help_filter(const char *name)
 return;
 }
 
-printf("Filter %s\n", f->name);
+av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
+av_log_set_callback(NULL);
+
+av_bprintf(&bp, "Filter %s\n", f->name);
 if (f->description)
-printf("  %s\n", f->description);
+av_bprintf(&bp, "  %s\n", f->description);
 
 if (f->flags & AVFILTER_FLAG_SLICE_THREADS)
-printf("slice threading supported\n");
+av_bprintf(&bp, "slice threading supported\n");
 
-printf("Inputs:\n");
+av_bprintf(&bp, "Inputs:\n");
 count = avfilter_filter_pad_count(f, 0);
 for (i = 0; i < count; i++) {
-printf("   #%d: %s (%s)\n", i, avfilter_pad_get_name(f->inputs, i),
+av_bprintf(&bp, "   #%d: %s (%s), Formats: ", i, 
avfilter_pad_get_name(f->inputs, i),
av_get_media_type_string(avfilter_pad_get_type(f->inputs, i)));
+
+avfilter_print_config_formats(&bp, f, 0, i);
+av_bprintf(&bp, "\n");
 }
 if (f->flags & AVFILTER_FLAG_DYNAMIC_INPUTS)
-printf("dynamic (depending on the options)\n");
+av_bprintf(&bp, "dynamic (depending on the options)\n");
 else if (!count)
-printf("none (source filter)\n");
+av_bprintf(&bp, "none (source filter)\n");
 
-printf("Outputs:\n");
+av_bprintf(&bp, "Outputs:\n");
 count = avfilter_filter_pad_count(f, 1);
 for (i = 0; i < count; i++) {
-printf("   #%d: %s (%s)\n", i, avfilter_pad_get_name(f->outputs, 
i),
+av_bprintf(&bp, "   #%d: %s (%s), Formats: ", i, 
avfilter_pad_get_name(f->outputs, i),
av_get_media_type_string(avfilter_pad_get_type(f->outputs, i)));
+ 
+avfilter_print_config_formats(&bp, f, 1, i);
+av_bprintf(&bp, "\n");
 }
 if (f->flags & AVFILTER_FLAG_DYNAMIC_OUTPUTS)
-printf("dynamic (depending on the options)\n");
+av_bprintf(&bp, "dynamic (depending on the options)\n");
 else if (!count)
-printf("none (sink filter)\n");
+av_bprintf(&bp, "none (sink filter)\n");
+
+av_log_set_callback(log_callback_help);
+printf("%s\n", bp.str);
 
 if (f->priv_class)
 show_help_children(f->priv_class, AV_OPT_FLAG_VIDEO_PARAM | 
AV_OPT_FLAG_FILTERING_PARAM |
   AV_OPT_FLAG_AUDIO_PARAM);
 if (f->flags & AVFILTER_FLAG_SUPPORT_TIMELINE)
 printf("This filter has support for timeline through the 'enable' 
option.\n");
+
+av_bprint_finalize(&bp, NULL);
 #else
 av_log(NULL, AV_LOG_ERROR, "Build without libavfilter; "
"can not to satisfy request\n");
-- 
ffmpeg-codebot
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 1/2] avfilter/avfilter: add avfilter_print_config_formats()

2022-10-11 Thread softworkz
From: softworkz 

Prints the following to AVBPrint:

For pass-through filter links:

"All (passthrough)"

For filters using query_formats:

"Dynamic"

For filters using query_formats where a call to query_formats
succeeds (example):

"Dynamic, Defaults: [yuv420p, yuvj420p, yuva420p, nv12, nv21]"

For all other filters (example):

"[s16p, s32p, fltp, dblp]"

Except in case when the number of formats equals the number of
available formats:

"All"

Signed-off-by: softworkz 
---
 doc/APIchanges  |   3 ++
 libavfilter/avfilter.c  | 102 +++-
 libavfilter/avfilter.h  |  12 +
 libavfilter/avfiltergraph.c |  14 +++--
 libavfilter/internal.h  |   9 
 libavfilter/version.h   |   4 +-
 6 files changed, 136 insertions(+), 8 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index cbb579612e..6e2a528b04 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,9 @@ libavutil: 2021-04-27
 
 API changes, most recent first:
 
+2022-10-11 - xx - lavf 59.50.100 - avfilter.h
+  Add add avfilter_print_config_formats().
+
 2022-10-05 - 37d5ddc317 - lavu 57.39.100 - cpu.h
   Add AV_CPU_FLAG_RVB_BASIC.
 
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index cc5505e65b..8cc665e19c 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -196,6 +196,104 @@ void avfilter_link_free(AVFilterLink **link)
 av_freep(link);
 }
 
+static unsigned get_nb_pix_fmts()
+{
+unsigned i = 0;
+while (av_pix_fmt_desc_get(i++)) {}
+return i - 1;
+}
+
+static unsigned get_nb_sample_fmts()
+{
+unsigned i = 0;
+while (av_get_sample_fmt_name(i++)) {}
+return i - 1;
+}
+
+int avfilter_print_config_formats(AVBPrint *bp, const struct AVFilter *filter, 
int for_output, unsigned pad_index)
+{
+AVFilterGraph *graph;
+AVFilterContext *filter_context;
+AVFilterFormatsConfig *config;
+enum AVMediaType media_type;
+int ret = 0;
+
+if (filter->formats_state == FF_FILTER_FORMATS_PASSTHROUGH) {
+av_bprintf(bp, "All (passthrough)");
+return 0;
+}
+
+graph = avfilter_graph_alloc();
+if (!graph) {
+av_log(NULL, AV_LOG_ERROR, "Failed to create filtergraph\n");
+ret = AVERROR(ENOMEM);
+goto cleanup;
+}
+
+filter_context = avfilter_graph_alloc_filter(graph, filter, "filter");
+if (!filter_context) {
+av_log(NULL, AV_LOG_ERROR, "Failed to create filter\n");
+ret = AVERROR(ENOMEM);
+goto cleanup;
+}
+
+avfilter_init_str(filter_context, NULL);
+
+if (filter->formats_state == FF_FILTER_FORMATS_QUERY_FUNC)
+av_bprintf(bp, "Dynamic");
+
+if (!for_output && pad_index >= filter_context->nb_inputs 
+|| for_output && pad_index >= filter_context->nb_outputs)
+goto cleanup;
+
+avfilter_graph_config(graph, graph);
+
+for (unsigned i = 0; i < filter_context->nb_inputs; i++)
+filter_context->inputs[i] = (AVFilterLink 
*)av_mallocz(sizeof(AVFilterLink));
+
+for (unsigned i = 0; i < filter_context->nb_outputs; i++)
+filter_context->outputs[i] = (AVFilterLink 
*)av_mallocz(sizeof(AVFilterLink));
+
+ff_filter_query_formats(filter_context);
+
+config = for_output ? &filter_context->outputs[pad_index]->incfg : 
&filter_context->inputs[pad_index]->outcfg;
+
+if (!config || !config->formats)
+goto cleanup;
+
+media_type= for_output ? filter->outputs[pad_index].type : 
filter->inputs[pad_index].type;
+
+if (filter->formats_state == FF_FILTER_FORMATS_QUERY_FUNC) {
+if (config->formats && config->formats->nb_formats)
+av_bprintf(bp, ", Default: ");
+}
+
+if (config->formats == NULL)
+av_bprintf(bp, "unknown");
+else if (media_type == AVMEDIA_TYPE_VIDEO && config->formats->nb_formats 
== get_nb_pix_fmts() ||
+ media_type == AVMEDIA_TYPE_AUDIO && config->formats->nb_formats 
== get_nb_sample_fmts())
+av_bprintf(bp, "All");
+else {
+for (unsigned i = 0; i < config->formats->nb_formats; i++) {
+if (i == 0)
+av_bprintf(bp, "[");
+
+if (media_type == AVMEDIA_TYPE_VIDEO)
+av_bprintf(bp, "%s", 
av_get_pix_fmt_name(config->formats->formats[i]));
+else if (media_type == AVMEDIA_TYPE_AUDIO)
+av_bprintf(bp, "%s", 
av_get_sample_fmt_name(config->formats->formats[i]));
+
+if (i < config->formats->nb_formats - 1)
+av_bprintf(bp, ", ");
+else
+av_bprintf(bp, "]");}
+}
+
+cleanup:
+avfilter_graph_free(&graph);
+return ret;
+}
+
 void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
 {
 filter->ready = FFMAX(filter->ready, priority);
@@ -759,12 +857,12 @@ void avfilter_free(AVFilterContext *filter)
 
 for (i = 0; i < filter->nb_inputs; i++) {
 free_link(filter->inputs[i]);
-if (fil

[FFmpeg-devel] [PATCH 2/4] avcodec/svq1enc: Add SVQ1EncDSPContext, make codec context private

2022-10-11 Thread Andreas Rheinhardt
Currently, SVQ1EncContext is defined in a header that is also
included by the arch-specific code that initializes the one
and only dsp function that this encoder uses directly.

But the arch-specific functions to set this dsp function
do not need anything from SVQ1EncContext. This commit therefore
adds a small SVQ1EncDSPContext whose only member is said
function pointer and renames svq1enc.h to svq1encdsp.h
to avoid exposing unnecessary internals to these init
functions (and the whole mpegvideo with it).

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/ppc/svq1enc_altivec.c |  4 +-
 libavcodec/svq1enc.c | 60 --
 libavcodec/svq1enc.h | 86 
 libavcodec/svq1encdsp.h  | 34 +
 libavcodec/x86/svq1enc_init.c|  4 +-
 5 files changed, 93 insertions(+), 95 deletions(-)
 delete mode 100644 libavcodec/svq1enc.h
 create mode 100644 libavcodec/svq1encdsp.h

diff --git a/libavcodec/ppc/svq1enc_altivec.c b/libavcodec/ppc/svq1enc_altivec.c
index aa66b40996..5721bede34 100644
--- a/libavcodec/ppc/svq1enc_altivec.c
+++ b/libavcodec/ppc/svq1enc_altivec.c
@@ -27,7 +27,7 @@
 #include "libavutil/ppc/cpu.h"
 #include "libavutil/ppc/util_altivec.h"
 
-#include "libavcodec/svq1enc.h"
+#include "libavcodec/svq1encdsp.h"
 
 #if HAVE_ALTIVEC
 static int ssd_int8_vs_int16_altivec(const int8_t *pix1, const int16_t *pix2,
@@ -71,7 +71,7 @@ static int ssd_int8_vs_int16_altivec(const int8_t *pix1, 
const int16_t *pix2,
 }
 #endif /* HAVE_ALTIVEC */
 
-av_cold void ff_svq1enc_init_ppc(SVQ1EncContext *c)
+av_cold void ff_svq1enc_init_ppc(SVQ1EncDSPContext *c)
 {
 #if HAVE_ALTIVEC
 if (!PPC_ALTIVEC(av_get_cpu_flags()))
diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
index 79e9e578ac..67a6de5cc0 100644
--- a/libavcodec/svq1enc.c
+++ b/libavcodec/svq1enc.c
@@ -37,11 +37,61 @@
 #include "internal.h"
 #include "mpegutils.h"
 #include "packet_internal.h"
+#include "put_bits.h"
 #include "svq1.h"
-#include "svq1enc.h"
+#include "svq1encdsp.h"
 #include "svq1enc_cb.h"
+
 #include "libavutil/avassert.h"
+#include "libavutil/frame.h"
+#include "libavutil/mem_internal.h"
+
+typedef struct SVQ1EncContext {
+/* FIXME: Needed for motion estimation, should not be used for anything
+ * else, the idea is to make the motion estimation eventually independent
+ * of MpegEncContext, so this will be removed then. */
+MpegEncContext m;
+AVCodecContext *avctx;
+MECmpContext mecc;
+HpelDSPContext hdsp;
+AVFrame *current_picture;
+AVFrame *last_picture;
+PutBitContext pb;
+
+/* Some compression statistics */
+enum AVPictureType pict_type;
+int quality;
+
+/* why ooh why this sick breadth first order,
+ * everything is slower and more complex */
+PutBitContext reorder_pb[6];
+
+int frame_width;
+int frame_height;
+
+/* Y plane block dimensions */
+int y_block_width;
+int y_block_height;
+
+/* U & V plane (C planes) block dimensions */
+int c_block_width;
+int c_block_height;
+
+DECLARE_ALIGNED(16, int16_t, encoded_block_levels)[6][7][256];
+
+uint16_t *mb_type;
+uint32_t *dummy;
+int16_t (*motion_val8[3])[2];
+int16_t (*motion_val16[3])[2];
+
+int64_t rd_total;
+
+uint8_t *scratchbuf;
+
+int motion_est;
 
+SVQ1EncDSPContext svq1encdsp;
+} SVQ1EncContext;
 
 static void svq1_write_header(SVQ1EncContext *s, int frame_type)
 {
@@ -154,7 +204,7 @@ static int encode_block(SVQ1EncContext *s, uint8_t *src, 
uint8_t *ref,
 int sqr, diff, score;
 
 vector = codebook + stage * size * 16 + i * size;
-sqr= s->ssd_int8_vs_int16(vector, block[stage], size);
+sqr= s->svq1encdsp.ssd_int8_vs_int16(vector, block[stage], 
size);
 diff   = block_sum[stage] - sum;
 score  = sqr - (diff * (int64_t)diff >> (level + 3)); // 
FIXME: 64 bits slooow
 if (score < best_vector_score) {
@@ -558,7 +608,7 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx)
 s->y_block_height * sizeof(int16_t));
 s->dummy   = av_mallocz((s->y_block_width + 1) *
 s->y_block_height * sizeof(int32_t));
-s->ssd_int8_vs_int16   = ssd_int8_vs_int16_c;
+s->svq1encdsp.ssd_int8_vs_int16 = ssd_int8_vs_int16_c;
 
 if (!s->m.me.temp || !s->m.me.scratchpad || !s->m.me.map ||
 !s->m.me.score_map || !s->mb_type || !s->dummy) {
@@ -566,9 +616,9 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx)
 }
 
 #if ARCH_PPC
-ff_svq1enc_init_ppc(s);
+ff_svq1enc_init_ppc(&s->svq1encdsp);
 #elif ARCH_X86
-ff_svq1enc_init_x86(s);
+ff_svq1enc_init_x86(&s->svq1encdsp);
 #endif
 
 ff_h263_encode_init(&s->m); // mv_penalty
diff --git a/libavcodec/svq1enc.h b/libavcodec/svq1enc.h
deleted file mode 100644
index bb6af082d5..00
-

[FFmpeg-devel] [PATCH 3/4] avcodec/svq1: Set hidden visibility

2022-10-11 Thread Andreas Rheinhardt
The encoder uses ff_svq1_inter_mean_vlc + 256 and setting
hidden visibility allows to bake this "+ 256" into the
general offset of ff_svq1_inter_mean_vlc and the code
accessing it.

For certain arches, this is also required for the compiler
to not produce overtly pessimistic code that can't be fixed
up by the linker lateron.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/svq1.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/svq1.h b/libavcodec/svq1.h
index af8a7dfa04..0ccf17c253 100644
--- a/libavcodec/svq1.h
+++ b/libavcodec/svq1.h
@@ -37,6 +37,8 @@
 
 #include 
 
+#include "libavutil/attributes_internal.h"
+
 #define SVQ1_BLOCK_SKIP 0
 #define SVQ1_BLOCK_INTER1
 #define SVQ1_BLOCK_INTER_4V 2
@@ -49,6 +51,7 @@
 #define SVQ1_BLOCK_INTRA_CODE   0
 #define SVQ1_BLOCK_INTRA_LEN3
 
+FF_VISIBILITY_PUSH_HIDDEN
 extern const int8_t *const ff_svq1_inter_codebooks[6];
 extern const int8_t *const ff_svq1_intra_codebooks[6];
 
@@ -59,5 +62,6 @@ extern const uint16_t ff_svq1_intra_mean_vlc[256][2];
 extern const uint16_t ff_svq1_inter_mean_vlc[512][2];
 
 extern const uint16_t ff_svq1_frame_size_table[7][2];
+FF_VISIBILITY_POP_HIDDEN
 
 #endif /* AVCODEC_SVQ1_H */
-- 
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 4/4] avcodec/svq1enc: Move PutBitContext from context to stack

2022-10-11 Thread Andreas Rheinhardt
This is more natural, because said context is only used
for the duration of one call to svq1_encode_frame().

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/svq1enc.c | 44 ++--
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
index 67a6de5cc0..75adbe7ea0 100644
--- a/libavcodec/svq1enc.c
+++ b/libavcodec/svq1enc.c
@@ -56,7 +56,6 @@ typedef struct SVQ1EncContext {
 HpelDSPContext hdsp;
 AVFrame *current_picture;
 AVFrame *last_picture;
-PutBitContext pb;
 
 /* Some compression statistics */
 enum AVPictureType pict_type;
@@ -93,38 +92,38 @@ typedef struct SVQ1EncContext {
 SVQ1EncDSPContext svq1encdsp;
 } SVQ1EncContext;
 
-static void svq1_write_header(SVQ1EncContext *s, int frame_type)
+static void svq1_write_header(SVQ1EncContext *s, PutBitContext *pb, int 
frame_type)
 {
 int i;
 
 /* frame code */
-put_bits(&s->pb, 22, 0x20);
+put_bits(pb, 22, 0x20);
 
 /* temporal reference (sure hope this is a "don't care") */
-put_bits(&s->pb, 8, 0x00);
+put_bits(pb, 8, 0x00);
 
 /* frame type */
-put_bits(&s->pb, 2, frame_type - 1);
+put_bits(pb, 2, frame_type - 1);
 
 if (frame_type == AV_PICTURE_TYPE_I) {
 /* no checksum since frame code is 0x20 */
 /* no embedded string either */
 /* output 5 unknown bits (2 + 2 + 1) */
-put_bits(&s->pb, 5, 2); /* 2 needed by quicktime decoder */
+put_bits(pb, 5, 2); /* 2 needed by quicktime decoder */
 
 i = ff_match_2uint16((void*)ff_svq1_frame_size_table,
  FF_ARRAY_ELEMS(ff_svq1_frame_size_table),
  s->frame_width, s->frame_height);
-put_bits(&s->pb, 3, i);
+put_bits(pb, 3, i);
 
 if (i == 7) {
-put_bits(&s->pb, 12, s->frame_width);
-put_bits(&s->pb, 12, s->frame_height);
+put_bits(pb, 12, s->frame_width);
+put_bits(pb, 12, s->frame_height);
 }
 }
 
 /* no checksum or extra data (next 2 bits get 0) */
-put_bits(&s->pb, 2, 0);
+put_bits(pb, 2, 0);
 }
 
 #define QUALITY_THRESHOLD100
@@ -298,6 +297,7 @@ static void init_block_index(MpegEncContext *s){
 }
 
 static int svq1_encode_plane(SVQ1EncContext *s, int plane,
+ PutBitContext *pb,
  const unsigned char *src_plane,
  unsigned char *ref_plane,
  unsigned char *decoded_plane,
@@ -425,7 +425,7 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane,
 int score[4] = { 0, 0, 0, 0 }, best;
 uint8_t *temp= s->scratchbuf;
 
-if (put_bytes_left(&s->pb, 0) < 3000) { // FIXME: check size
+if (put_bytes_left(pb, 0) < 3000) { // FIXME: check size
 av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
 return -1;
 }
@@ -496,7 +496,7 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane,
 if (score[2] < score[best] && mx == 0 && my == 0) {
 best = 2;
 s->hdsp.put_pixels_tab[0][0](decoded, ref, stride, 16);
-put_bits(&s->pb, SVQ1_BLOCK_SKIP_LEN, 
SVQ1_BLOCK_SKIP_CODE);
+put_bits(pb, SVQ1_BLOCK_SKIP_LEN, 
SVQ1_BLOCK_SKIP_CODE);
 }
 }
 
@@ -521,7 +521,7 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane,
 
 if (best != 2)
 for (i = 5; i >= 0; i--)
-ff_copy_bits(&s->pb, reorder_buffer[best][i],
+ff_copy_bits(pb, reorder_buffer[best][i],
  count[best][i]);
 if (best == 0)
 s->hdsp.put_pixels_tab[0][0](decoded, temp, stride, 16);
@@ -630,6 +630,7 @@ static int svq1_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
  const AVFrame *pict, int *got_packet)
 {
 SVQ1EncContext *const s = avctx->priv_data;
+PutBitContext pb;
 int i, ret;
 
 ret = ff_alloc_packet(avctx, pkt, s->y_block_width * s->y_block_height *
@@ -660,8 +661,6 @@ static int svq1_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 
 FFSWAP(AVFrame*, s->current_picture, s->last_picture);
 
-init_put_bits(&s->pb, pkt->data, pkt->size);
-
 if (avctx->gop_size && (avctx->frame_number % avctx->gop_size))
 s->pict_type = AV_PICTURE_TYPE_P;
 else
@@ -670,9 +669,10 @@ static int svq1_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 
 ff_side_data_set_encoder_stats(pkt, pict->quality, NULL, 0, s->pict_type);
 
-svq1_write_header(s, s->pict_type);
+init_put_bits(&pb, pkt->data, pkt->size);
+svq1_write_header(s, &pb, s->pict_type);
 for (i = 0; i < 3; i++) {
-int ret = svq1_encode_plane(s, i,
+int ret = svq1_enco

Re: [FFmpeg-devel] [PATCH v2 1/5] avutil/dict: Add av_dict_iterate

2022-10-11 Thread Marvin Scholz
On 24 Sep 2022, at 16:36, Marvin Scholz wrote:

> This is a more explicit iteration API rather than using the "magic"
> av_dict_get(d, "", t, AV_DICT_IGNORE_SUFFIX) which is not really
> trivial to grasp what it does when casually reading through code.
> ---
>  libavutil/dict.c| 19 +++
>  libavutil/dict.h| 46 +++--
>  libavutil/version.h |  4 ++--
>  3 files changed, 57 insertions(+), 12 deletions(-)
>
> diff --git a/libavutil/dict.c b/libavutil/dict.c
> index 14ad780a79..ee059d712c 100644
> --- a/libavutil/dict.c
> +++ b/libavutil/dict.c
> @@ -20,6 +20,7 @@
>
>  #include 
>
> +#include "avassert.h"
>  #include "avstring.h"
>  #include "dict.h"
>  #include "dict_internal.h"
> @@ -38,6 +39,24 @@ int av_dict_count(const AVDictionary *m)
>  return m ? m->count : 0;
>  }
>
> +const AVDictionaryEntry *av_dict_iterate(const AVDictionary *m,
> + const AVDictionaryEntry *prev)
> +{
> +int i = 0;
> +
> +if (!m)
> +return NULL;
> +
> +if (prev)
> +i = prev - m->elems + 1;
> +
> +av_assert2(i >= 0);
> +if (i >= m->count)
> +return NULL;
> +
> +return &m->elems[i];
> +}
> +
>  AVDictionaryEntry *av_dict_get(const AVDictionary *m, const char *key,
> const AVDictionaryEntry *prev, int flags)
>  {
> diff --git a/libavutil/dict.h b/libavutil/dict.h
> index 0d1afc6c64..344afb452b 100644
> --- a/libavutil/dict.h
> +++ b/libavutil/dict.h
> @@ -32,6 +32,8 @@
>
>  #include 
>
> +#include "attributes.h"
> +
>  /**
>   * @addtogroup lavu_dict AVDictionary
>   * @ingroup lavu_data
> @@ -43,9 +45,9 @@
>   * an AVDictionary, simply pass an address of a NULL pointer to
>   * av_dict_set(). NULL can be used as an empty dictionary wherever
>   * a pointer to an AVDictionary is required.
> - * Use av_dict_get() to retrieve an entry or iterate over all
> - * entries and finally av_dict_free() to free the dictionary
> - * and all its contents.
> + * Use av_dict_get() to retrieve an entry and av_dict_iterate() to
> + * iterate over all entries and finally av_dict_free() to free the
> + * dictionary and all its contents.
>   *
>   @code
> AVDictionary *d = NULL;   // "create" an empty dictionary
> @@ -57,8 +59,8 @@
> char *v = av_strdup("value"); // you can avoid copying them like this
> av_dict_set(&d, k, v, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
>
> -   while (t = av_dict_get(d, "", t, AV_DICT_IGNORE_SUFFIX)) {
> -   <> // iterate over all entries in d
> +   while (t = av_dict_iterate(d, t)) {
> +   <>// iterate over all entries in d
> }
> av_dict_free(&d);
>   @endcode
> @@ -89,9 +91,6 @@ typedef struct AVDictionary AVDictionary;
>   * The returned entry key or value must not be changed, or it will
>   * cause undefined behavior.
>   *
> - * To iterate through all the dictionary entries, you can set the matching 
> key
> - * to the null string "" and set the AV_DICT_IGNORE_SUFFIX flag.
> - *
>   * @param prev Set to the previous matching element to find the next.
>   * If set to NULL the first matching element is returned.
>   * @param key matching key
> @@ -101,6 +100,33 @@ typedef struct AVDictionary AVDictionary;
>  AVDictionaryEntry *av_dict_get(const AVDictionary *m, const char *key,
> const AVDictionaryEntry *prev, int flags);
>
> +/**
> + * Iterate over a dictionary
> + *
> + * Iterates through all entries in the dictionary.
> + *
> + * @warning The returned AVDictionaryEntry key/value must not be changed.
> + *
> + * @warning As av_dict_set() invalidates all previous entries returned
> + * by this function, it must not be called while iterating over the dict.
> + *
> + * Typical usage:
> + * @code
> + * const AVDictionaryEntry *e = NULL;
> + * while ((e = av_dict_iterate(m, e))) {
> + * // ...
> + * }
> + * @endcode
> + *
> + * @param m The dictionary to iterate over
> + * @param prev  Pointer to the previous AVDictionaryEntry, NULL initially
> + *
> + * @retval AVDictionaryEntry* The next element in the dictionary
> + * @retval NULL   No more elements in the dictionary
> + */
> +const AVDictionaryEntry *av_dict_iterate(const AVDictionary *m,
> + const AVDictionaryEntry *prev);
> +
>  /**
>   * Get number of entries in dictionary.
>   *
> @@ -115,8 +141,8 @@ int av_dict_count(const AVDictionary *m);
>   * Note: If AV_DICT_DONT_STRDUP_KEY or AV_DICT_DONT_STRDUP_VAL is set,
>   * these arguments will be freed on error.
>   *
> - * Warning: Adding a new entry to a dictionary invalidates all existing 
> entries
> - * previously returned with av_dict_get.
> + * @warning Adding a new entry to a dictionary invalidates all existing 
> entries
> + * previously returned with av_dict_get() or av_dict_iterate().
>   *
>   * @param pm pointer t

Re: [FFmpeg-devel] [PATCH] Makefile: Build complete doc with Doxygen

2022-10-11 Thread Marvin Scholz



On 24 Sep 2022, at 23:09, Marvin Scholz wrote:

> Add DISABLEDINSTHEADERS, a variable containing the headers of disabled
> libraries. This is needed so that Doxygen does not generate incomplete
> documentation when a component is disabled, which is quite unexpected
> behaviour and results in warnings due to, among other things, broken
> references.
> ---
>  Makefile | 10 ++
>  doc/Makefile |  2 +-
>  2 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index 61f79e27ae..26714950b7 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -110,7 +110,17 @@ include $(SRC_PATH)/$(1)/Makefile
>  include $(SRC_PATH)/ffbuild/library.mak
>  endef
>
> +define DODISABLEDSUBDIR
> +$(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V
> +SUBDIR := $(1)/
> +include $(SRC_PATH)/$(1)/Makefile
> +DISABLEDINSTHEADERS := $$(DISABLEDINSTHEADERS) $$(HEADERS:%=$$(SUBDIR)%)
> +endef
> +
> +DISABLEDFFLIBS := $(filter-out $(FFLIBS),$(ALLFFLIBS))
> +
>  $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D
> +$(foreach D,$(DISABLEDFFLIBS),$(eval $(call DODISABLEDSUBDIR,lib$(D
>
>  include $(SRC_PATH)/fftools/Makefile
>  include $(SRC_PATH)/doc/Makefile
> diff --git a/doc/Makefile b/doc/Makefile
> index 25774c7bad..d71a02e408 100644
> --- a/doc/Makefile
> +++ b/doc/Makefile
> @@ -100,7 +100,7 @@ doc/%.3: doc/%.pod $(GENTEXI)
>
>  $(DOCS) doc/doxy/html: | doc/
>
> -DOXY_INPUT  = $(INSTHEADERS)
> +DOXY_INPUT  = $(INSTHEADERS) $(DISABLEDINSTHEADERS)
>  DOXY_INPUT_DEPS = $(addprefix $(SRC_PATH)/, $(DOXY_INPUT)) ffbuild/config.mak
>
>  doc/doxy/html: TAG = DOXY
> -- 
> 2.37.0 (Apple Git-136)

Ping for review, please.
___
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/8] configure: Remove dependencies of inexistant rtjpeg decoder

2022-10-11 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> rtjpeg is a mode of nuv and not a decoder in its own right.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  configure | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/configure b/configure
> index ab6ff27249..2c4f5043d5 100755
> --- a/configure
> +++ b/configure
> @@ -2934,7 +2934,6 @@ ralf_decoder_select="golomb"
>  rasc_decoder_select="inflate_wrapper"
>  rawvideo_decoder_select="bswapdsp"
>  rscc_decoder_deps="zlib"
> -rtjpeg_decoder_select="me_cmp"
>  rv10_decoder_select="h263_decoder"
>  rv10_encoder_select="h263_encoder"
>  rv20_decoder_select="h263_decoder"

Will apply the first nine patches of this tomorrow unless there are
objections.

- 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 v7 0/3] 32bps FLAC patches

2022-10-11 Thread Martijn van Beurden
Recently libFLAC gained the ability (first released in FLAC 1.4.0)
to create FLAC files containing 32-bit int PCM samples. To
keep complexity reasonable, the choice was made to limit residuals
to 32-bit integers, which the encoder must make sure of. In case
the encoder cannot find any predictor of which the residuals fit
this limit, it must default to using a verbatim subframe. Tests have
shown that this does not happen often (<0.1% of subframes on a
music corpus of various styles). See also discussion here:
https://github.com/ietf-wg-cellar/flac-specification/pull/148

These two patches implement decoding and encoding following this
format.

Changes since v1:
fix copy-paste error in encoder, several invocations of
lpc_encode_choose_datapath used wrong parameters, making FATE fail as
compression was less than it should be

Changes since v2:
Rebased decoder part as it didn't apply anymore

Changes since v3:
Moved put_golomb part to flacenc.c (as it is now quite specific to FLAC)
and renamed put_sbits64 to put_sbits63 (and changed assert accordingly)

Changes since v4:
Fix check of decoded_buffer_33bps malloc. Fix reading of wasted bits
for 33bps subframe. Add fate test

Changes since v5:
Slimmed down 32 bps fate flac test from 2 to 1 input file. Replaced
-strict -2 with -strict experimental in fate and encoder warning.

Changes since v6:
Deduplicated function bodies with preprocessor macros in both
encoder and decoder, declared variables in loop body where possible
and changed ff_ctz to ff_ctzll where necessary

Martijn van Beurden (3):
  libavcodec/flacdec: Implement decoding of 32 bit-per-sample PCM
  libavcodec/flacenc: Implement encoding of 32 bit-per-sample PCM
  fate/flac: Add test of 32 bps encoding/decoding

 libavcodec/flac.c   |   4 +-
 libavcodec/flacdec.c| 218 --
 libavcodec/flacenc.c| 480 +++-
 libavcodec/get_bits.h   |  12 +
 libavcodec/mathops.h|   9 +
 libavcodec/put_bits.h   |   7 +
 libavcodec/put_golomb.h |  14 --
 tests/fate/flac.mak |   4 +
 8 files changed, 602 insertions(+), 146 deletions(-)

-- 
2.30.2

___
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 v7 1/3] libavcodec/flacdec: Implement decoding of 32 bit-per-sample PCM

2022-10-11 Thread Martijn van Beurden
Add decoding of FLAC files coding for 32 bit-per-sample PCM to libavcodec.
---
 libavcodec/flac.c |   4 +-
 libavcodec/flacdec.c  | 218 +-
 libavcodec/get_bits.h |  12 +++
 libavcodec/mathops.h  |   9 ++
 4 files changed, 219 insertions(+), 24 deletions(-)

diff --git a/libavcodec/flac.c b/libavcodec/flac.c
index 352d663c67..174b4801be 100644
--- a/libavcodec/flac.c
+++ b/libavcodec/flac.c
@@ -28,7 +28,7 @@
 #include "flacdata.h"
 #include "flac_parse.h"
 
-static const int8_t sample_size_table[] = { 0, 8, 12, 0, 16, 20, 24, 0 };
+static const int8_t sample_size_table[] = { 0, 8, 12, 0, 16, 20, 24, 32 };
 
 static const AVChannelLayout flac_channel_layouts[8] = {
 AV_CHANNEL_LAYOUT_MONO,
@@ -82,7 +82,7 @@ int ff_flac_decode_frame_header(AVCodecContext *avctx, 
GetBitContext *gb,
 
 /* bits per sample */
 bps_code = get_bits(gb, 3);
-if (bps_code == 3 || bps_code == 7) {
+if (bps_code == 3) {
 av_log(avctx, AV_LOG_ERROR + log_level_offset,
"invalid sample size code (%d)\n",
bps_code);
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index 5b8547a98f..56ef033a42 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -64,6 +64,9 @@ typedef struct FLACContext {
 int32_t *decoded[FLAC_MAX_CHANNELS];///< decoded samples
 uint8_t *decoded_buffer;
 unsigned int decoded_buffer_size;
+int64_t *decoded_33bps;  ///< decoded samples for a 33 bps 
subframe
+uint8_t *decoded_buffer_33bps;
+unsigned int decoded_buffer_size_33bps;
 int buggy_lpc;  ///< use workaround for old lavc 
encoded files
 
 FLACDSPContext dsp;
@@ -154,6 +157,24 @@ static int allocate_buffers(FLACContext *s)
  s->stream_info.channels,
  s->stream_info.max_blocksize,
  AV_SAMPLE_FMT_S32P, 0);
+if (ret >= 0 && s->stream_info.bps == 32 && s->stream_info.channels == 2) {
+buf_size = av_samples_get_buffer_size(NULL, 1,
+  s->stream_info.max_blocksize,
+  AV_SAMPLE_FMT_S64P, 0);
+if (buf_size < 0)
+return buf_size;
+
+av_fast_malloc(&s->decoded_buffer_33bps, 
&s->decoded_buffer_size_33bps, buf_size);
+if (!s->decoded_buffer_33bps)
+return AVERROR(ENOMEM);
+
+ret = av_samples_fill_arrays((uint8_t **)&s->decoded_33bps, NULL,
+ s->decoded_buffer_33bps,
+ 1,
+ s->stream_info.max_blocksize,
+ AV_SAMPLE_FMT_S64P, 0);
+
+}
 return ret < 0 ? ret : 0;
 }
 
@@ -331,6 +352,62 @@ static int decode_subframe_fixed(FLACContext *s, int32_t 
*decoded,
 return 0;
 }
 
+#define DECODER_SUBFRAME_FIXED_WIDE(residual) {   \
+const int blocksize = s->blocksize;   \
+int ret;  \
+  \
+if ((ret = decode_residuals(s, residual, pred_order)) < 0)\
+return ret;   \
+  \
+switch (pred_order) { \
+case 0:   \
+   for (int i = pred_order; i < blocksize; i++)  \
+decoded[i] = residual[i]; \
+break;\
+case 1:   \
+for (int i = pred_order; i < blocksize; i++)  \
+decoded[i] = (int64_t)residual[i] + (int64_t)decoded[i-1];\
+break;\
+case 2:   \
+for (int i = pred_order; i < blocksize; i++)  \
+decoded[i] = (int64_t)residual[i] + 2*(int64_t)decoded[i-1] - 
(int64_t)decoded[i-2];  \
+break;\
+case 3:   \
+for (int i = pred_order; i < blocksize; i++)  \
+decoded[i] = (int64_t)residual[i] + 3*(int64_t)decoded[i-1] - 
3*(int64_t)decoded[i-2] + (int64_t)decoded[i-3];   \
+break;\
+case 4:   \
+for (int i = pred_order; i < blocksize; i++)  \
+decoded[i] = (int64_t)residual[i] + 4*(int64_t)decoded[i-

[FFmpeg-devel] [PATCH v7 2/3] libavcodec/flacenc: Implement encoding of 32 bit-per-sample PCM

2022-10-11 Thread Martijn van Beurden
Add encoding of 32 bit-per-sample PCM to FLAC files to libavcodec.
Coding to this format is at this point considered experimental and
-strict experimental is needed to get ffmpeg to encode such files.
---
 libavcodec/flacenc.c| 480 +++-
 libavcodec/put_bits.h   |   7 +
 libavcodec/put_golomb.h |  14 --
 3 files changed, 379 insertions(+), 122 deletions(-)

diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c
index 5d8c3f82be..1e4eb0d319 100644
--- a/libavcodec/flacenc.c
+++ b/libavcodec/flacenc.c
@@ -31,7 +31,6 @@
 #include "codec_internal.h"
 #include "encode.h"
 #include "put_bits.h"
-#include "put_golomb.h"
 #include "lpc.h"
 #include "flac.h"
 #include "flacdata.h"
@@ -95,6 +94,7 @@ typedef struct FlacSubframe {
 
 typedef struct FlacFrame {
 FlacSubframe subframes[FLAC_MAX_CHANNELS];
+int64_t samples_33bps[FLAC_MAX_BLOCKSIZE];
 int blocksize;
 int bs_code[2];
 uint8_t crc8;
@@ -282,10 +282,22 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
 s->bps_code= 4;
 break;
 case AV_SAMPLE_FMT_S32:
-if (avctx->bits_per_raw_sample != 24)
-av_log(avctx, AV_LOG_WARNING, "encoding as 24 bits-per-sample\n");
-avctx->bits_per_raw_sample = 24;
-s->bps_code= 6;
+if (avctx->bits_per_raw_sample <= 24) {
+if (avctx->bits_per_raw_sample < 24)
+av_log(avctx, AV_LOG_WARNING, "encoding as 24 
bits-per-sample\n");
+avctx->bits_per_raw_sample = 24;
+s->bps_code= 6;
+} else if (avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
+av_log(avctx, AV_LOG_WARNING,
+   "encoding as 24 bits-per-sample, more is considered "
+   "experimental. Add -strict experimental if you want "
+   "to encode more than 24 bits-per-sample\n");
+avctx->bits_per_raw_sample = 24;
+s->bps_code= 6;
+} else {
+avctx->bits_per_raw_sample = 32;
+s->bps_code = 7;
+}
 break;
 }
 
@@ -533,8 +545,7 @@ static uint64_t rice_count_exact(const int32_t *res, int n, 
int k)
 uint64_t count = 0;
 
 for (i = 0; i < n; i++) {
-int32_t v = -2 * res[i] - 1;
-v ^= v >> 31;
+unsigned v = ((unsigned)(res[i]) << 1) ^ (res[i] >> 31);
 count += (v >> k) + 1 + k;
 }
 return count;
@@ -713,8 +724,8 @@ static uint64_t calc_rice_params(RiceContext *rc,
 
 tmp_rc.coding_mode = rc->coding_mode;
 
-for (i = 0; i < n; i++)
-udata[i] = (2 * data[i]) ^ (data[i] >> 31);
+for (i = pred_order; i < n; i++)
+udata[i] = ((unsigned)(data[i]) << 1) ^ (data[i] >> 31);
 
 calc_sum_top(pmax, exact ? kmax : 0, udata, n, pred_order, sums);
 
@@ -812,6 +823,130 @@ static void encode_residual_fixed(int32_t *res, const 
int32_t *smp, int n,
 }
 
 
+/* These four functions check for every residual whether it can be
+ * contained in  INT32_MAX)  \
+return 1; \
+res[i] = res64;   \
+} \
+} else if (order == 2) {  \
+for (int i = order; i < n; i++) { \
+int64_t res64 = (int64_t)smp[i] - 2*(int64_t)smp[i-1] + smp[i-2]; \
+if (res64 <= INT32_MIN || res64 > INT32_MAX)  \
+return 1; \
+res[i] = res64;   \
+} \
+} else if (order == 3) {  \
+for (int i = order; i < n; i++) { \
+int64_t res64 = (int64_t)smp[i] - 3*(int64_t)smp[i-1] + 
3*(int64_t)smp[i-2] - smp[i-3];  \
+if (res64 <= INT32_MIN || res64 > INT32_MAX)  \
+return 1; \
+res[i] = res64;   \
+} \
+} else {  \
+for (int i = order; i < n; i++) { \
+int64_t res64 = (int64_t)smp[i] - 4*(int64_t)smp[i-1] + 
6*(int64_t)smp[i-2] - 4*(int64_t)smp[i-3] + smp[i-4];   \
+if (res64 <= INT32_MIN || res64 > INT32_MAX)  \
+return 1; \
+res[i] = res64;   \
+} \
+}  

[FFmpeg-devel] [PATCH v7 3/3] fate/flac: Add test of 32 bps encoding/decoding

2022-10-11 Thread Martijn van Beurden
---
 tests/fate/flac.mak | 4 
 1 file changed, 4 insertions(+)

diff --git a/tests/fate/flac.mak b/tests/fate/flac.mak
index 115cc965e1..3424b2bf82 100644
--- a/tests/fate/flac.mak
+++ b/tests/fate/flac.mak
@@ -6,6 +6,7 @@ FATE_FLAC += fate-flac-16-chmode-indep  
\
  fate-flac-16-lpc-cholesky  \
  fate-flac-16-lpc-levinson  \
  fate-flac-24-comp-8\
+ fate-flac-32-wasted-bits   \
  fate-flac-rice-params  \
 
 fate-flac-16-chmode-%: OPTS = -ch_mode $(@:fate-flac-16-chmode-%=%)
@@ -20,6 +21,9 @@ fate-flac-24-comp-%: OPTS = -compression_level 
$(@:fate-flac-24-comp-%=%)
 fate-flac-24-%: REF = $(SAMPLES)/audio-reference/divertimenti_2ch_96kHz_s24.wav
 fate-flac-24-%: CMD = enc_dec_pcm flac wav s24le $(subst 
$(SAMPLES),$(TARGET_SAMPLES),$(REF)) -c flac $(OPTS)
 
+fate-flac-32-wasted-bits: REF = 
$(SAMPLES)/audio-reference/drums_2ch_44kHz_s32_wastedbits.wav
+fate-flac-32-wasted-bits: CMD = enc_dec_pcm flac wav s32le $(subst 
$(SAMPLES),$(TARGET_SAMPLES),$(REF)) -c flac -strict experimental
+
 fate-flac-rice-params: REF = 
$(SAMPLES)/audio-reference/chorusnoise_2ch_44kHz_s16.wav
 fate-flac-rice-params: CMD = enc_dec_pcm flac wav s16le $(subst 
$(SAMPLES),$(TARGET_SAMPLES),$(REF)) -c flac
 
-- 
2.30.2

___
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] avcodec/libdav1d: add an option to set max frame delay

2022-10-11 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/libdav1d.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
index e76f33d7e2..028929404e 100644
--- a/libavcodec/libdav1d.c
+++ b/libavcodec/libdav1d.c
@@ -50,6 +50,7 @@ typedef struct Libdav1dContext {
 Dav1dData data;
 int tile_threads;
 int frame_threads;
+int max_frame_delay;
 int apply_grain;
 int operating_point;
 int all_layers;
@@ -246,7 +247,9 @@ static av_cold int libdav1d_init(AVCodecContext *c)
 s.n_threads = FFMAX(dav1d->frame_threads, dav1d->tile_threads);
 else
 s.n_threads = FFMIN(threads, DAV1D_MAX_THREADS);
-s.max_frame_delay = (c->flags & AV_CODEC_FLAG_LOW_DELAY) ? 1 : 0;
+if (dav1d->max_frame_delay > 0 && (c->flags & AV_CODEC_FLAG_LOW_DELAY))
+av_log(c, AV_LOG_WARNING, "Low delay mode requested, forcing 
max_frame_delay 1\n");
+s.max_frame_delay = (c->flags & AV_CODEC_FLAG_LOW_DELAY) ? 1 : 
dav1d->max_frame_delay;
 av_log(c, AV_LOG_DEBUG, "Using %d threads, %d max_frame_delay\n",
s.n_threads, s.max_frame_delay);
 #else
@@ -256,6 +259,8 @@ static av_cold int libdav1d_init(AVCodecContext *c)
 s.n_frame_threads = dav1d->frame_threads
   ? dav1d->frame_threads
   : FFMIN(ceil(threads / s.n_tile_threads), 
DAV1D_MAX_FRAME_THREADS);
+if (dav1d->max_frame_delay > 0)
+s.n_frame_threads = FFMIN(s.n_frame_threads, dav1d->max_frame_delay);
 av_log(c, AV_LOG_DEBUG, "Using %d frame threads, %d tile threads\n",
s.n_frame_threads, s.n_tile_threads);
 #endif
@@ -555,12 +560,16 @@ static av_cold int libdav1d_close(AVCodecContext *c)
 #ifndef DAV1D_MAX_TILE_THREADS
 #define DAV1D_MAX_TILE_THREADS DAV1D_MAX_THREADS
 #endif
+#ifndef DAV1D_MAX_FRAME_DELAY
+#define DAV1D_MAX_FRAME_DELAY DAV1D_MAX_FRAME_THREADS
+#endif
 
 #define OFFSET(x) offsetof(Libdav1dContext, x)
 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
 static const AVOption libdav1d_options[] = {
 { "tilethreads", "Tile threads", OFFSET(tile_threads), AV_OPT_TYPE_INT, { 
.i64 = 0 }, 0, DAV1D_MAX_TILE_THREADS, VD | AV_OPT_FLAG_DEPRECATED },
 { "framethreads", "Frame threads", OFFSET(frame_threads), AV_OPT_TYPE_INT, 
{ .i64 = 0 }, 0, DAV1D_MAX_FRAME_THREADS, VD | AV_OPT_FLAG_DEPRECATED },
+{ "max_frame_delay", "Max frame delay", OFFSET(max_frame_delay), 
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, DAV1D_MAX_FRAME_DELAY, VD },
 { "filmgrain", "Apply Film Grain", OFFSET(apply_grain), AV_OPT_TYPE_BOOL, 
{ .i64 = -1 }, -1, 1, VD | AV_OPT_FLAG_DEPRECATED },
 { "oppoint",  "Select an operating point of the scalable bitstream", 
OFFSET(operating_point), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 31, VD },
 { "alllayers", "Output all spatial layers", OFFSET(all_layers), 
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD },
-- 
2.37.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".


[FFmpeg-devel] [PATCH v2 0/2] Print filter input/output formats in help output

2022-10-11 Thread ffmpegagent
Example output for command: ffmpeg -h filters=overlay

Filter overlay
  Overlay a video source on top of the input.
slice threading supported
Inputs:
   #0: main (video), Formats: Dynamic, Default: [yuv420p, yuvj420p, 
yuva420p, nv12, nv21]
   #1: overlay (video), Formats: Dynamic, Default: [yuva420p]
Outputs:
   #0: default (video), Formats: Dynamic, Default: [yuv420p, yuvj420p, 
yuva420p, nv12, nv21]

overlay AVOptions:
[...]



Examples for what it prints in various cases


For pass-through filter links

"All (passthrough)"


For filters using query_formats

"Dynamic"


For filters using query_formats where a call to query_formats succeeds

"Dynamic, Default: [yuv420p, yuvj420p, yuva420p, nv12, nv21]"


For all other cases

"[s16p, s32p, fltp, dblp]"


Except when all formats are supported (number of formats equals number of
available formats)

"All"




v2: rebase and fix compiler warnings

softworkz (2):
  avfilter/avfilter: add avfilter_print_config_formats()
  ftools/opt_common: Print filter input/output formats in help output

 doc/APIchanges  |   3 ++
 fftools/opt_common.c|  37 +
 libavfilter/avfilter.c  | 102 +++-
 libavfilter/avfilter.h  |  12 +
 libavfilter/avfiltergraph.c |  15 --
 libavfilter/internal.h  |   9 
 libavfilter/version.h   |   4 +-
 7 files changed, 163 insertions(+), 19 deletions(-)


base-commit: 479747645f795b6f4f376578ea1556409f943c31
Published-As: 
https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-43%2Fsoftworkz%2Fsubmit_print_formats-v2
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg 
pr-ffstaging-43/softworkz/submit_print_formats-v2
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/43

Range-diff vs v1:

 1:  c9496ca671 ! 1:  5ae347e40c avfilter/avfilter: add 
avfilter_print_config_formats()
 @@ doc/APIchanges: libavutil: 2021-04-27
   
  +2022-10-11 - xx - lavf 59.50.100 - avfilter.h
  +  Add add avfilter_print_config_formats().
 -+
 - 2022-10-05 - 37d5ddc317 - lavu 57.39.100 - cpu.h
 -   Add AV_CPU_FLAG_RVB_BASIC.
 ++  
 + 2022-10-11 - xx - lavu 57.39.101 - pixfmt.h
 +   Add AV_PIX_FMT_RGBF32 and AV_PIX_FMT_RGBAF32.
   
  
   ## libavfilter/avfilter.c ##
 @@ libavfilter/avfilter.c: void avfilter_link_free(AVFilterLink **link)
   av_freep(link);
   }
   
 -+static unsigned get_nb_pix_fmts()
 ++static unsigned get_nb_pix_fmts(void)
  +{
  +unsigned i = 0;
  +while (av_pix_fmt_desc_get(i++)) {}
  +return i - 1;
  +}
  +
 -+static unsigned get_nb_sample_fmts()
 ++static unsigned get_nb_sample_fmts(void)
  +{
  +unsigned i = 0;
  +while (av_get_sample_fmt_name(i++)) {}
 @@ libavfilter/avfiltergraph.c: static int query_formats(AVFilterGraph 
*graph, void
  -ret = filter_query_formats(f);
  -else
  -ret = ff_default_query_formats(f);
 ++
  +ret = ff_filter_query_formats(f);
   if (ret < 0 && ret != AVERROR(EAGAIN))
   return ret;
 2:  c99d278881 ! 2:  29389422a9 ftools/opt_common: Print filter input/output 
formats in help output
 @@ fftools/opt_common.c: static void show_help_filter(const char *name)
   {
   #if CONFIG_AVFILTER
   const AVFilter *f = avfilter_get_by_name(name);
 --int i, count;
  +AVBPrint bp;
 -+int i, count, ret;
 + int i, count;
   
   if (!name) {
 - av_log(NULL, AV_LOG_ERROR, "No filter name specified.\n");
  @@ fftools/opt_common.c: static void show_help_filter(const char *name)
   return;
   }

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

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


[FFmpeg-devel] [PATCH v2 1/2] avfilter/avfilter: add avfilter_print_config_formats()

2022-10-11 Thread softworkz
From: softworkz 

Prints the following to AVBPrint:

For pass-through filter links:

"All (passthrough)"

For filters using query_formats:

"Dynamic"

For filters using query_formats where a call to query_formats
succeeds (example):

"Dynamic, Defaults: [yuv420p, yuvj420p, yuva420p, nv12, nv21]"

For all other filters (example):

"[s16p, s32p, fltp, dblp]"

Except in case when the number of formats equals the number of
available formats:

"All"

Signed-off-by: softworkz 
---
 doc/APIchanges  |   3 ++
 libavfilter/avfilter.c  | 102 +++-
 libavfilter/avfilter.h  |  12 +
 libavfilter/avfiltergraph.c |  15 --
 libavfilter/internal.h  |   9 
 libavfilter/version.h   |   4 +-
 6 files changed, 137 insertions(+), 8 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 5807bf8069..82a029144d 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,9 @@ libavutil: 2021-04-27
 
 API changes, most recent first:
 
+2022-10-11 - xx - lavf 59.50.100 - avfilter.h
+  Add add avfilter_print_config_formats().
+  
 2022-10-11 - xx - lavu 57.39.101 - pixfmt.h
   Add AV_PIX_FMT_RGBF32 and AV_PIX_FMT_RGBAF32.
 
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index cc5505e65b..8f2741c6ec 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -196,6 +196,104 @@ void avfilter_link_free(AVFilterLink **link)
 av_freep(link);
 }
 
+static unsigned get_nb_pix_fmts(void)
+{
+unsigned i = 0;
+while (av_pix_fmt_desc_get(i++)) {}
+return i - 1;
+}
+
+static unsigned get_nb_sample_fmts(void)
+{
+unsigned i = 0;
+while (av_get_sample_fmt_name(i++)) {}
+return i - 1;
+}
+
+int avfilter_print_config_formats(AVBPrint *bp, const struct AVFilter *filter, 
int for_output, unsigned pad_index)
+{
+AVFilterGraph *graph;
+AVFilterContext *filter_context;
+AVFilterFormatsConfig *config;
+enum AVMediaType media_type;
+int ret = 0;
+
+if (filter->formats_state == FF_FILTER_FORMATS_PASSTHROUGH) {
+av_bprintf(bp, "All (passthrough)");
+return 0;
+}
+
+graph = avfilter_graph_alloc();
+if (!graph) {
+av_log(NULL, AV_LOG_ERROR, "Failed to create filtergraph\n");
+ret = AVERROR(ENOMEM);
+goto cleanup;
+}
+
+filter_context = avfilter_graph_alloc_filter(graph, filter, "filter");
+if (!filter_context) {
+av_log(NULL, AV_LOG_ERROR, "Failed to create filter\n");
+ret = AVERROR(ENOMEM);
+goto cleanup;
+}
+
+avfilter_init_str(filter_context, NULL);
+
+if (filter->formats_state == FF_FILTER_FORMATS_QUERY_FUNC)
+av_bprintf(bp, "Dynamic");
+
+if (!for_output && pad_index >= filter_context->nb_inputs 
+|| for_output && pad_index >= filter_context->nb_outputs)
+goto cleanup;
+
+avfilter_graph_config(graph, graph);
+
+for (unsigned i = 0; i < filter_context->nb_inputs; i++)
+filter_context->inputs[i] = (AVFilterLink 
*)av_mallocz(sizeof(AVFilterLink));
+
+for (unsigned i = 0; i < filter_context->nb_outputs; i++)
+filter_context->outputs[i] = (AVFilterLink 
*)av_mallocz(sizeof(AVFilterLink));
+
+ff_filter_query_formats(filter_context);
+
+config = for_output ? &filter_context->outputs[pad_index]->incfg : 
&filter_context->inputs[pad_index]->outcfg;
+
+if (!config || !config->formats)
+goto cleanup;
+
+media_type= for_output ? filter->outputs[pad_index].type : 
filter->inputs[pad_index].type;
+
+if (filter->formats_state == FF_FILTER_FORMATS_QUERY_FUNC) {
+if (config->formats && config->formats->nb_formats)
+av_bprintf(bp, ", Default: ");
+}
+
+if (config->formats == NULL)
+av_bprintf(bp, "unknown");
+else if (media_type == AVMEDIA_TYPE_VIDEO && config->formats->nb_formats 
== get_nb_pix_fmts() ||
+ media_type == AVMEDIA_TYPE_AUDIO && config->formats->nb_formats 
== get_nb_sample_fmts())
+av_bprintf(bp, "All");
+else {
+for (unsigned i = 0; i < config->formats->nb_formats; i++) {
+if (i == 0)
+av_bprintf(bp, "[");
+
+if (media_type == AVMEDIA_TYPE_VIDEO)
+av_bprintf(bp, "%s", 
av_get_pix_fmt_name(config->formats->formats[i]));
+else if (media_type == AVMEDIA_TYPE_AUDIO)
+av_bprintf(bp, "%s", 
av_get_sample_fmt_name(config->formats->formats[i]));
+
+if (i < config->formats->nb_formats - 1)
+av_bprintf(bp, ", ");
+else
+av_bprintf(bp, "]");}
+}
+
+cleanup:
+avfilter_graph_free(&graph);
+return ret;
+}
+
 void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
 {
 filter->ready = FFMAX(filter->ready, priority);
@@ -759,12 +857,12 @@ void avfilter_free(AVFilterContext *filter)
 
 for (i = 0; i < filter->nb_inputs; i++) {
 free_link(fil

[FFmpeg-devel] [PATCH v2 2/2] ftools/opt_common: Print filter input/output formats in help output

2022-10-11 Thread softworkz
From: softworkz 

Exmaple command: ffmpeg -h filters=overlay

Output:

Filter overlay
  Overlay a video source on top of the input.
slice threading supported
Inputs:
   #0: main (video), Formats: Dynamic, Default: [yuv420p, yuvj420p,
  yuva420p, nv12, nv21]
   #1: overlay (video), Formats: Dynamic, Default: [yuva420p]
Outputs:
   #0: default (video), Formats: Dynamic, Default: [yuv420p, yuvj420p,
 yuva420p, nv12, nv21]

overlay AVOptions:
[...]

Signed-off-by: softworkz 
---
 fftools/opt_common.c | 37 ++---
 1 file changed, 26 insertions(+), 11 deletions(-)

diff --git a/fftools/opt_common.c b/fftools/opt_common.c
index 8a06df82df..774e3c776b 100644
--- a/fftools/opt_common.c
+++ b/fftools/opt_common.c
@@ -504,6 +504,7 @@ static void show_help_filter(const char *name)
 {
 #if CONFIG_AVFILTER
 const AVFilter *f = avfilter_get_by_name(name);
+AVBPrint bp;
 int i, count;
 
 if (!name) {
@@ -514,40 +515,54 @@ static void show_help_filter(const char *name)
 return;
 }
 
-printf("Filter %s\n", f->name);
+av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
+av_log_set_callback(NULL);
+
+av_bprintf(&bp, "Filter %s\n", f->name);
 if (f->description)
-printf("  %s\n", f->description);
+av_bprintf(&bp, "  %s\n", f->description);
 
 if (f->flags & AVFILTER_FLAG_SLICE_THREADS)
-printf("slice threading supported\n");
+av_bprintf(&bp, "slice threading supported\n");
 
-printf("Inputs:\n");
+av_bprintf(&bp, "Inputs:\n");
 count = avfilter_filter_pad_count(f, 0);
 for (i = 0; i < count; i++) {
-printf("   #%d: %s (%s)\n", i, avfilter_pad_get_name(f->inputs, i),
+av_bprintf(&bp, "   #%d: %s (%s), Formats: ", i, 
avfilter_pad_get_name(f->inputs, i),
av_get_media_type_string(avfilter_pad_get_type(f->inputs, i)));
+
+avfilter_print_config_formats(&bp, f, 0, i);
+av_bprintf(&bp, "\n");
 }
 if (f->flags & AVFILTER_FLAG_DYNAMIC_INPUTS)
-printf("dynamic (depending on the options)\n");
+av_bprintf(&bp, "dynamic (depending on the options)\n");
 else if (!count)
-printf("none (source filter)\n");
+av_bprintf(&bp, "none (source filter)\n");
 
-printf("Outputs:\n");
+av_bprintf(&bp, "Outputs:\n");
 count = avfilter_filter_pad_count(f, 1);
 for (i = 0; i < count; i++) {
-printf("   #%d: %s (%s)\n", i, avfilter_pad_get_name(f->outputs, 
i),
+av_bprintf(&bp, "   #%d: %s (%s), Formats: ", i, 
avfilter_pad_get_name(f->outputs, i),
av_get_media_type_string(avfilter_pad_get_type(f->outputs, i)));
+ 
+avfilter_print_config_formats(&bp, f, 1, i);
+av_bprintf(&bp, "\n");
 }
 if (f->flags & AVFILTER_FLAG_DYNAMIC_OUTPUTS)
-printf("dynamic (depending on the options)\n");
+av_bprintf(&bp, "dynamic (depending on the options)\n");
 else if (!count)
-printf("none (sink filter)\n");
+av_bprintf(&bp, "none (sink filter)\n");
+
+av_log_set_callback(log_callback_help);
+printf("%s\n", bp.str);
 
 if (f->priv_class)
 show_help_children(f->priv_class, AV_OPT_FLAG_VIDEO_PARAM | 
AV_OPT_FLAG_FILTERING_PARAM |
   AV_OPT_FLAG_AUDIO_PARAM);
 if (f->flags & AVFILTER_FLAG_SUPPORT_TIMELINE)
 printf("This filter has support for timeline through the 'enable' 
option.\n");
+
+av_bprint_finalize(&bp, NULL);
 #else
 av_log(NULL, AV_LOG_ERROR, "Build without libavfilter; "
"can not to satisfy request\n");
-- 
ffmpeg-codebot
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH v2] avcodec/startcode: Avoid unaligned accesses

2022-10-11 Thread Andreas Rheinhardt
Up until now, ff_startcode_find_candidate_c() simply casts
an uint8_t* to uint64_t*/uint32_t* to read 64/32 bits at a time
in case HAVE_FAST_UNALIGNED is true. Yet this ignores the
alignment requirement of these types as well as effective type
rules of the C standard. This commit therefore replaces these
direct accesses with AV_RN64/32; this also improves
readability.

UBSan reported these unaligned accesses which happened in 233
FATE-tests involving H.264 and VC-1 (this has also been reported
in tickets #8138 and #8485); these tests are fixed by this commit.

The output of GCC with -O3 is unchanged for aarch64, alpha, arm,
loongarch, ppc and x64. There was only a slight difference for mips.

Signed-off-by: Andreas Rheinhardt 
---
This is v2 of 
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20200122145210.6898-1-andreas.rheinha...@gmail.com/

Here is the mips code before this change:

startcode_old_O3.o: file format elf64-tradlittlemips


Disassembly of section .text:

 :
   0:   18a00029bleza1,a8 
   4:   3c08ff7flui a4,0xff7f
   8:   3c07ff01lui a3,0xff01
   c:   65087f7fdaddiu  a4,a4,32639
  10:   64e70101daddiu  a3,a3,257
  14:   00084438dslla4,a4,0x10
  18:   00073c38dslla3,a3,0x10
  1c:   65087f7fdaddiu  a4,a4,32639
  20:   64e70101daddiu  a3,a3,257
  24:   00084478dslla4,a4,0x11
  28:   00073df8dslla3,a3,0x17
  2c:   00803025movea2,a0
  30:   1025movev0,zero
  34:   3508feffori a4,a4,0xfeff
  38:   1005b   50 
  3c:   34e78080ori a3,a3,0x8080
  40:   24420008addiu   v0,v0,8
  44:   0045182aslt v1,v0,a1
  48:   10600015beqzv1,a0 
  4c:   nop
  50:   dcc3ld  v1,0(a2)
  54:   0068482ddaddu   a5,v1,a4
  58:   44a3dmtc1   v1,$f0
  5c:   44a90800dmtc1   a5,$f1
  60:   4be10002pandn   $f0,$f0,$f1
  64:   4423dmfc1   v1,$f0
  68:   00671824and v1,v1,a3
  6c:   1060fff4beqzv1,40 
  70:   64c60008daddiu  a2,a2,8
  74:   0045182aslt v1,v0,a1
  78:   1069beqzv1,a0 
  7c:   0082182ddaddu   v1,a0,v0
  80:   1005b   98 
  84:   9064lbu a0,0(v1)
  88:   24420001addiu   v0,v0,1
  8c:   10a20008beq a1,v0,b0 
  90:   nop
  94:   9064lbu a0,0(v1)
  98:   1480fffbbneza0,88 
  9c:   64630001daddiu  v1,v1,1
  a0:   03e8jr  ra
  a4:   nop
  a8:   03e8jr  ra
  ac:   1025movev0,zero
  b0:   03e8jr  ra
  b4:   00a01025movev0,a1
...

And here after this change:

startcode_new_O3.o: file format elf64-tradlittlemips


Disassembly of section .text:

 :
   0:   18a0002bbleza1,b0 
   4:   3c08ff7flui a4,0xff7f
   8:   3c07ff01lui a3,0xff01
   c:   65087f7fdaddiu  a4,a4,32639
  10:   64e70101daddiu  a3,a3,257
  14:   00084438dslla4,a4,0x10
  18:   00073c38dslla3,a3,0x10
  1c:   65087f7fdaddiu  a4,a4,32639
  20:   64e70101daddiu  a3,a3,257
  24:   00084478dslla4,a4,0x11
  28:   00073df8dslla3,a3,0x17
  2c:   00803025movea2,a0
  30:   1025movev0,zero
  34:   3508feffori a4,a4,0xfeff
  38:   1005b   50 
  3c:   34e78080ori a3,a3,0x8080
  40:   24420008addiu   v0,v0,8
  44:   0045182aslt v1,v0,a1
  48:   10600017beqzv1,a8 
  4c:   nop
  50:   68c30007ldl v1,7(a2)
  54:   6cc3ldr v1,0(a2)
  58:   0068482ddaddu   a5,v1,a4
  5c:   44a3dmtc1   v1,$f0
  60:   44a90800dmtc1   a5,$f1
  64:   4be10002pandn   $f0,$f0,$f1
  68:   4423dmfc1   v1,$f0
  6c:   00671824and v1,v1,a3
  70:   1060fff3beqzv1,40 
  74:   64c60008daddiu  a2,a2,8
  78:   0045182aslt v1,v0,a1
  7c:   106abeqzv1,a8 
  80:   0082182ddaddu   v1,a0,v0
  84:   1006b   a0 
  88:   9064lbu a0,0(v1)
  8c:   nop
  90:   24420001addiu   v0,v0,1
  94:   10a20008beq a1,v0,b8 
  98:   nop
  9c:   9064lbu a0,0(v1)
  a0:   1480fffbbneza0,90 
  a4:   64630001daddiu  v1,v1,1
  a8:   03e8jr  ra
  ac:   nop
  b0:   03e8jr  ra
  b4:   1025movev0,zero
  b8:   03e8jr  ra
  bc:   00a01025movev0,a1

As one can see, the difference is that an ld has been replaced
by a pair of ldl and ldr. I don't know the performance implica

Re: [FFmpeg-devel] [PATCH] ffmpeg: fix implementation of updated input start time

2022-10-11 Thread Gyan Doshi




On 2022-10-04 02:41 pm, Anton Khirnov wrote:

Quoting Gyan Doshi (2022-10-02 21:46:59)


On 2022-09-27 10:10 am, Gyan Doshi wrote:

The current adjustment of input start times just adjusts the tsoffset.
And it does so, by resetting the tsoffset to nullify the new start time.
This leads to breakage of -copyts, ignoring of user_ts_offset, breaking
of -isync as well as breaking wrap correction.

Fixed by taking cognizance of these parameters, and by correcting start
times just before sync offsets are applied.

Comments?

sorry, was busy

will look at this in a few days


Ping.

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