Re: [FFmpeg-devel] [PATCH v3] ffmpeg CLI multithreading

2023-12-11 Thread Anton Khirnov
both should now be fixed in my tree

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

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


Re: [FFmpeg-devel] [PATCH] lavc/lpc: R-V V apply_welch_window

2023-12-11 Thread Anton Khirnov
Quoting Rémi Denis-Courmont (2023-12-08 18:46:51)
> +#if __riscv_xlen >= 64
> +func ff_lpc_apply_welch_window_rvv, zve64d
> +vsetvli t0, zero, e64, m8, ta, ma
> +vid.v   v0
> +addit2, a1, -1
> +vfcvt.f.xu.v v0, v0
> +li  t3, 2
> +fcvt.d.l ft2, t2
> +srait1, a1, 1
> +fcvt.d.l ft3, t3
> +li  t4, 1
> +fdiv.d  ft0, ft3, ft2# ft0 = c = 2. / (len - 1)
> +fcvt.d.l fa1, t4 # fa1 = 1.
> +fsub.d  ft1, ft0, fa1
> +vfrsub.vf v0, v0, ft1# v0[i] = c - i - 1.
> +1:
> +vsetvli t0, t1, e64, m8, ta, ma
> +vfmul.vv v16, v0, v0  # no fused multipy-add as v0 is reused
> +sub t1, t1, t0
> +vle32.v v8, (a0)
> +fcvt.d.l ft2, t0
> +vfrsub.vf v16, v16, fa1  # v16 = 1. - w * w
> +sh2add  a0, t0, a0
> +vsetvli zero, zero, e32, m4, ta, ma
> +vfwcvt.f.x.v v24, v8
> +vsetvli zero, zero, e64, m8, ta, ma
> +vfsub.vf v0, v0, ft2 # v0 -= vl
> +vfmul.vv v8, v24, v16
> +vse64.v v8, (a2)
> +sh3add  a2, t0, a2
> +bnezt1, 1b
> +
> +andit1, a1, 1
> +beqzt1, 2f
> +
> +sd  zero, (a2)
> +addia0, a0, 4
> +addia2, a2, 8
> +2:
> +vsetvli t0, zero, e64, m8, ta, ma
> +vid.v   v0
> +srait1, a1, 1
> +vfcvt.f.xu.v v0, v0
> +fcvt.d.l ft1, t1
> +fsub.d  ft1, ft0, ft1# ft1 = c - (len / 2)
> +vfadd.vf v0, v0, ft1 # v0[i] = c - (len / 2) + i
> +3:
> +vsetvli t0, t1, e64, m8, ta, ma
> +vfmul.vv v16, v0, v0
> +sub t1, t1, t0
> +vle32.v v8, (a0)
> +fcvt.d.l ft2, t0
> +vfrsub.vf v16, v16, fa1  # v16 = 1. - w * w
> +sh2add  a0, t0, a0
> +vsetvli zero, zero, e32, m4, ta, ma
> +vfwcvt.f.x.v v24, v8
> +vsetvli zero, zero, e64, m8, ta, ma
> +vfadd.vf v0, v0, ft2 # v0 += vl
> +vfmul.vv v8, v24, v16
> +vse64.v v8, (a2)
> +sh3add  a2, t0, a2
> +bnezt1, 3b

I think it'd look a lot less like base64 < /dev/random if you vertically
aligned the first operands.

-- 
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] Initial tickering at unifying ProRes encoder

2023-12-11 Thread Anton Khirnov
Quoting Clément Bœsch (2023-12-11 02:35:01)
> Hello there,
> 
> I'm currently investigating an issue¹ affecting Kostya ProRes encoder
> which is not reproducible with Anatoliy encoder (but it's too early to
> say if the bug is not present there as well given the differences in
> quantization, and it's also unclear if the issue is even actually
> there in the first place and not in M2/M3 firmwares).
> 
> Since these encoders share more than similiarities, I've been looking
> into their differences, and unifying their common codepaths was helpful
> to my investigation.
> 
> Attached is an initial patchset working out their differences by either
> sharing data or making code identical where relevant.

Do you have any comments on their respective strengths and weaknesses -
when would one want to prefer one over the other?

And how feasible would it be to reduce that to a single encoder?

-- 
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] avdevice/avfoundation: replace deprecated AVCaptureDevice

2023-12-11 Thread Thilo Borgmann via ffmpeg-devel

Am 09.12.23 um 13:09 schrieb xufuji456 via ffmpeg-devel:

Building with iOS platform, the compiler has a warning: "'devicesWithMediaType:' is 
deprecated: first deprecated in iOS 10.0 - Use AVCaptureDeviceDiscoverySession 
instead"

Signed-off-by: xufuji456 <839789...@qq.com>
---
  libavdevice/avfoundation.m | 65 +++---
  1 file changed, 60 insertions(+), 5 deletions(-)


LGTM.

Will apply shortly if there are no more comments.

-Thilo

___
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] Initial tickering at unifying ProRes encoder

2023-12-11 Thread Clément Bœsch
On Mon, Dec 11, 2023 at 10:15:09AM +0100, Anton Khirnov wrote:
> Quoting Clément Bœsch (2023-12-11 02:35:01)
> > Hello there,
> > 
> > I'm currently investigating an issue¹ affecting Kostya ProRes encoder
> > which is not reproducible with Anatoliy encoder (but it's too early to
> > say if the bug is not present there as well given the differences in
> > quantization, and it's also unclear if the issue is even actually
> > there in the first place and not in M2/M3 firmwares).
> > 
> > Since these encoders share more than similiarities, I've been looking
> > into their differences, and unifying their common codepaths was helpful
> > to my investigation.
> > 
> > Attached is an initial patchset working out their differences by either
> > sharing data or making code identical where relevant.
> 
> Do you have any comments on their respective strengths and weaknesses -
> when would one want to prefer one over the other?

Right now their strength is that having both is helping me debugging a
pretty obscure issue, but I agree that's not a good argument for users.

Kostya encoder has more parameters, and seems to have a more advanced
quantization model. Internally it implies a bunch of duplication of
code for predicting the frame sizes (thinking of the estimate vs encode
AC/DC functions), but that's just internal stuff that can be reworked and
that doesn't concern users.

Anatoliy has more checks to avoid writing out invalid data (referring to
the sanity checks around color management right now), and doesn't seem to
trigger the bug I'm investigating (but again, still unclear if it is
unaffected by it).

> And how feasible would it be to reduce that to a single encoder?

That's pretty much the direction I'm taking, making as much in common as
possible in the hope that they will converge to the same identical code,
and in the process points out the eventual issue I'm looking for.

-- 
Clément B.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] lavc/lpc: R-V V apply_welch_window

2023-12-11 Thread Rémi Denis-Courmont


Le 11 décembre 2023 11:11:28 GMT+02:00, Anton Khirnov  a 
écrit :
>Quoting Rémi Denis-Courmont (2023-12-08 18:46:51)
>> +#if __riscv_xlen >= 64
>> +func ff_lpc_apply_welch_window_rvv, zve64d
>> +vsetvli t0, zero, e64, m8, ta, ma
>> +vid.v   v0
>> +addit2, a1, -1
>> +vfcvt.f.xu.v v0, v0
>> +li  t3, 2
>> +fcvt.d.l ft2, t2
>> +srait1, a1, 1
>> +fcvt.d.l ft3, t3
>> +li  t4, 1
>> +fdiv.d  ft0, ft3, ft2# ft0 = c = 2. / (len - 1)
>> +fcvt.d.l fa1, t4 # fa1 = 1.
>> +fsub.d  ft1, ft0, fa1
>> +vfrsub.vf v0, v0, ft1# v0[i] = c - i - 1.
>> +1:
>> +vsetvli t0, t1, e64, m8, ta, ma
>> +vfmul.vv v16, v0, v0  # no fused multipy-add as v0 is reused
>> +sub t1, t1, t0
>> +vle32.v v8, (a0)
>> +fcvt.d.l ft2, t0
>> +vfrsub.vf v16, v16, fa1  # v16 = 1. - w * w
>> +sh2add  a0, t0, a0
>> +vsetvli zero, zero, e32, m4, ta, ma
>> +vfwcvt.f.x.v v24, v8
>> +vsetvli zero, zero, e64, m8, ta, ma
>> +vfsub.vf v0, v0, ft2 # v0 -= vl
>> +vfmul.vv v8, v24, v16
>> +vse64.v v8, (a2)
>> +sh3add  a2, t0, a2
>> +bnezt1, 1b
>> +
>> +andit1, a1, 1
>> +beqzt1, 2f
>> +
>> +sd  zero, (a2)
>> +addia0, a0, 4
>> +addia2, a2, 8
>> +2:
>> +vsetvli t0, zero, e64, m8, ta, ma
>> +vid.v   v0
>> +srait1, a1, 1
>> +vfcvt.f.xu.v v0, v0
>> +fcvt.d.l ft1, t1
>> +fsub.d  ft1, ft0, ft1# ft1 = c - (len / 2)
>> +vfadd.vf v0, v0, ft1 # v0[i] = c - (len / 2) + i
>> +3:
>> +vsetvli t0, t1, e64, m8, ta, ma
>> +vfmul.vv v16, v0, v0
>> +sub t1, t1, t0
>> +vle32.v v8, (a0)
>> +fcvt.d.l ft2, t0
>> +vfrsub.vf v16, v16, fa1  # v16 = 1. - w * w
>> +sh2add  a0, t0, a0
>> +vsetvli zero, zero, e32, m4, ta, ma
>> +vfwcvt.f.x.v v24, v8
>> +vsetvli zero, zero, e64, m8, ta, ma
>> +vfadd.vf v0, v0, ft2 # v0 += vl
>> +vfmul.vv v8, v24, v16
>> +vse64.v v8, (a2)
>> +sh3add  a2, t0, a2
>> +bnezt1, 3b
>
>I think it'd look a lot less like base64 < /dev/random if you vertically
>aligned the first operands.

They are aligned to the 17th column. Problem is that quite a few vector 
mnemonics are larger than 7 characters.

>
>-- 
>Anton Khirnov
>___
>ffmpeg-devel mailing list
>ffmpeg-devel@ffmpeg.org
>https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>To unsubscribe, visit link above, or email
>ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] lavc/lpc: R-V V apply_welch_window

2023-12-11 Thread Anton Khirnov
Quoting Rémi Denis-Courmont (2023-12-11 10:50:53)
> Le 11 décembre 2023 11:11:28 GMT+02:00, Anton Khirnov  a 
> écrit :
> >I think it'd look a lot less like base64 < /dev/random if you vertically
> >aligned the first operands.
> 
> They are aligned to the 17th column. Problem is that quite a few vector 
> mnemonics are larger than 7 characters.

Align to 25 or 33 then?

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

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


Re: [FFmpeg-devel] [PATCH] lavc/lpc: R-V V apply_welch_window

2023-12-11 Thread Rémi Denis-Courmont


Le 11 décembre 2023 11:57:50 GMT+02:00, Anton Khirnov  a 
écrit :
>Quoting Rémi Denis-Courmont (2023-12-11 10:50:53)
>> Le 11 décembre 2023 11:11:28 GMT+02:00, Anton Khirnov  a 
>> écrit :
>> >I think it'd look a lot less like base64 < /dev/random if you vertically
>> >aligned the first operands.
>> 
>> They are aligned to the 17th column. Problem is that quite a few vector 
>> mnemonics are larger than 7 characters.
>
>Align to 25 or 33 then?

IMO that's even worse. The operands end up too far off from most mnemonics that 
it hurts legibility more than it improves.

I initially aligned to the longest mnemonics but that turned out badly whenever 
revectoring (for obvious reasons).

>
>-- 
>Anton Khirnov
>___
>ffmpeg-devel mailing list
>ffmpeg-devel@ffmpeg.org
>https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>To unsubscribe, visit link above, or email
>ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 1/8] avutil: introduce an Immersive Audio Model and Formats API

2023-12-11 Thread Anton Khirnov
Quoting James Almer (2023-12-05 23:43:55)
> diff --git a/libavutil/iamf.h b/libavutil/iamf.h
> new file mode 100644
> index 00..bc0363153d
> --- /dev/null
> +++ b/libavutil/iamf.h
> +/**
> + * @file
> + * Immersive Audio Model and Formats API header
> + * @see https://aomediacodec.github.io/iamf/";>Immersive Audio Model 
> and Formats
> + */
> +
> +#include 
> +#include 
> +
> +#include "attributes.h"
> +#include "avassert.h"
> +#include "channel_layout.h"
> +#include "dict.h"
> +#include "rational.h"
> +
> +/**
> + * @defgroup lavf_iamf_params Parameter Definition
> + * @{
> + * Parameters as defined in section 3.6.1 and 3.8 of IAMF.
> + * @}
> + * @defgroup lavf_iamf_audio Audio Element
> + * @{
> + * Audio Elements as defined in section 3.6 of IAMF.
> + * @}
> + * @defgroup lavf_iamf_mix Mix Presentation
> + * @{
> + * Mix Presentations as defined in section 3.7 of IAMF.
> + * @}
> + *
> + * @}
> + * @addtogroup lavf_iamf_params
> + * @{
> + */
> +enum AVIAMFAnimationType {
> +AV_IAMF_ANIMATION_TYPE_STEP,
> +AV_IAMF_ANIMATION_TYPE_LINEAR,
> +AV_IAMF_ANIMATION_TYPE_BEZIER,
> +};
> +
> +/**
> + * Mix Gain Parameter Data as defined in section 3.8.1 of IAMF.
> + *
> + * Subblocks in AVIAMFParamDefinition use this struct when the value or
> + * @ref AVIAMFParamDefinition.param_definition_type param_definition_type is
> + * AV_IAMF_PARAMETER_DEFINITION_MIX_GAIN.

This is the wrong place for this second paragraph. IMO it should go into
doxy for either param_definition_type, or
AV_IAMF_PARAMETER_DEFINITION_MIX_GAIN.

> +/**
> + * Parameters as defined in section 3.6.1 of IAMF.

It's not immediately obvious how the contents are structured, so I'd
extend it with something like:

The struct is allocated along with an array of subblocks, which are
either AVIAMFMixGain, AVIAMFDemixingInfo, or AVIAMFReconGain depending
on the value of param_definition_type. This array is placed
subblocks_offset bytes after the start of this struct.

> + */
> +typedef struct AVIAMFParamDefinition {
> +const AVClass *av_class;
> +
> +size_t subblocks_offset;

Offset in bytes from the start of this struct, at which the subblocks
array is located.

> +size_t subblock_size;

Size in bytes of each element in the subblocks array.

> +
> +enum AVIAMFParamDefinitionType param_definition_type;

This struct is already called ParamDefinition, so this could be just
type. Also:

Parameters type. Determines the type of the subblock elements.

> +unsigned int nb_subblocks;

Number of subblocks in the array.

> +
> +unsigned int parameter_id;
> +unsigned int parameter_rate;
> +unsigned int param_definition_mode;
> +unsigned int duration;
> +unsigned int constant_subblock_duration;

These should be documented.

> +typedef struct AVIAMFLayer {
> +const AVClass *av_class;
> +
> +AVChannelLayout ch_layout;
> +
> +/**
> + * A bitmask which may contain a combination of AV_IAMF_LAYER_FLAG_* 
> flags.
> + */
> +unsigned int flags;
> +/**
> + * Output gain channel flags as defined in section 3.6.2 of IAMF.
> + *
> + * This field is defined only if @ref 
> AVIAMFAudioElement.audio_element_type
> + * "the parent's Audio Element type" is 
> AV_IAMF_AUDIO_ELEMENT_TYPE_CHANNEL,
> + * must be 0 otherwise.
> + */
> +unsigned int output_gain_flags;
> +/**
> + * Output gain as defined in section 3.6.2 of IAMF.
> + *
> + * Must be 0 if @ref output_gain_flags is 0.
> + */
> +AVRational output_gain;
> +/**
> + * Ambisonics mode as defined in section 3.6.3 of IAMF.
> + *
> + * This field is defined only if @ref 
> AVIAMFAudioElement.audio_element_type
> + * "the parent's Audio Element type" is AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE.
> + *
> + * If AV_IAMF_AMBISONICS_MODE_MONO, channel_mapping is defined implicitly
> + * (Ambisonic Order) or explicitly (Custom Order with ambi channels) in
> + * @ref ch_layout.
> + * If AV_IAMF_AMBISONICS_MODE_PROJECTION, @ref demixing_matrix must be 
> set.
> + */
> +enum AVIAMFAmbisonicsMode ambisonics_mode;
> +
> +/**
> + * Demixing matrix as defined in section 3.6.3 of IAMF.
> + *
> + * May be set only if @ref ambisonics_mode == 
> AV_IAMF_AMBISONICS_MODE_PROJECTION,
> + * must be NULL otherwise.
> + */
> +AVRational *demixing_matrix;

How many elements are in the array?

-- 
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 2/8] avformat: introduce AVStreamGroup

2023-12-11 Thread Anton Khirnov
Quoting James Almer (2023-12-05 23:43:56)
> @@ -2819,6 +2972,22 @@ AVRational av_guess_frame_rate(AVFormatContext *ctx, 
> AVStream *stream,
>  int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st,
>  const char *spec);
>  
> +/**
> + * Check if the group stg contained in s is matched by the stream group
> + * specifier spec.
> + *
> + * See the "stream group specifiers" chapter in the documentation for the
> + * syntax of spec.
> + *
> + * @return  >0 if stg is matched by spec;
> + *  0  if stg is not matched by spec;
> + *  AVERROR code if spec is invalid
> + *
> + * @note  A stream group specifier can match several groups in the format.
> + */
> +int avformat_match_stream_group_specifier(AVFormatContext *s, AVStreamGroup 
> *stg,
> +  const char *spec);

What is this for? It does not seem to be used in this set.

-- 
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 2/8] avformat: introduce AVStreamGroup

2023-12-11 Thread Anton Khirnov
Quoting James Almer (2023-12-05 23:43:56)
> +/**
> + * Remove a stream group from its AVFormatContext and free it.
> + * The group must be the last stream of the AVFormatContext.
> + */
> +void ff_remove_stream_group(AVFormatContext *s, AVStreamGroup *stg);

When would this be useful?

-- 
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 3/8] ffmpeg: add support for muxing AVStreamGroups

2023-12-11 Thread Anton Khirnov
Quoting James Almer (2023-12-05 23:43:57)
> Starting with IAMF support.
> 
> Signed-off-by: James Almer 
> ---
>  fftools/ffmpeg.h  |   2 +
>  fftools/ffmpeg_mux_init.c | 335 ++
>  fftools/ffmpeg_opt.c  |   2 +
>  3 files changed, 339 insertions(+)

Missing documentation.

> +static int of_add_groups(Muxer *mux, const OptionsContext *o)
> +{
> +AVFormatContext *oc = mux->fc;
> +int ret;
> +
> +/* process manually set groups */
> +for (int i = 0; i < o->nb_stream_groups; i++) {
> +AVDictionary *dict = NULL, *tmp = NULL;
> +const AVDictionaryEntry *e;
> +AVStreamGroup *stg = NULL;
> +int type;
> +const char *token;
> +char *str, *ptr = NULL;
> +const AVOption opts[] = {
> +{ "type", "Set group type", offsetof(AVStreamGroup, type), 
> AV_OPT_TYPE_INT,
> +{ .i64 = 0 }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, 
> "type" },
> +{ "iamf_audio_element",NULL, 0, AV_OPT_TYPE_CONST,
> +{ .i64 = AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT },
> .unit = "type" },
> +{ "iamf_mix_presentation", NULL, 0, AV_OPT_TYPE_CONST,
> +{ .i64 = AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION }, 
> .unit = "type" },
> +{ NULL },
> +};
> + const AVClass class = {
> +.class_name = "StreamGroupType",
> +.item_name  = av_default_item_name,
> +.option = opts,
> +.version= LIBAVUTIL_VERSION_INT,
> +};
> +const AVClass *pclass = &class;
> +
> +str = av_strdup(o->stream_groups[i].u.str);
> +if (!str)
> +goto end;
> +
> +token = av_strtok(str, ",", &ptr);
> +if (token) {

Too many indentation levels, move this whole block into a separate
function.

> +ret = av_dict_parse_string(&dict, token, "=", ":", 
> AV_DICT_MULTIKEY);
> +if (ret < 0) {
> +av_log(mux, AV_LOG_ERROR, "Error parsing group specification 
> %s\n", token);
> +goto end;
> +}
> +
> +// "type" is not a user settable option in AVStreamGroup

This comment confuses me.

> +e = av_dict_get(dict, "type", NULL, 0);
> +if (!e) {
> +av_log(mux, AV_LOG_ERROR, "No type define for Steam Group 
> %d\n", i);

1) Steam
2) defined? Or maybe specified.
3) Print the string, not the index.

> +ret = AVERROR(EINVAL);
> +goto end;
> +}
> +
> +ret = av_opt_eval_int(&pclass, opts, e->value, &type);
> +if (ret < 0 || type == AV_STREAM_GROUP_PARAMS_NONE) {
> +av_log(mux, AV_LOG_ERROR, "Invalid group type \"%s\"\n", 
> e->value);
> +goto end;
> +}
> +
> +av_dict_copy(&tmp, dict, 0);
> +stg = avformat_stream_group_create(oc, type, &tmp);
> +if (!stg) {
> +ret = AVERROR(ENOMEM);
> +goto end;
> +}
> +av_dict_set(&tmp, "type", NULL, 0);
> +
> +e = NULL;
> +while (e = av_dict_get(dict, "st", e, 0)) {
> +unsigned int idx = strtol(e->value, NULL, 0);
> +if (idx >= oc->nb_streams) {
> +av_log(mux, AV_LOG_ERROR, "Invalid stream index %d\n", 
> idx);
> +ret = AVERROR(EINVAL);
> +goto end;
> +}

This block seems confused about signedness of e->value.

> +avformat_stream_group_add_stream(stg, oc->streams[idx]);

Unchecked return value.


-- 
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 v4] avcodec/pngdec: read colorspace info when decoding with AVDISCARD_ALL

2023-12-11 Thread Leo Izen

On 12/10/23 23:20, Kacper Michajlow wrote:

On Tue, 28 Feb 2023 at 20:46, Leo Izen  wrote:


On 2/27/23 11:34, Leo Izen wrote:

On 2/21/23 17:35, Leo Izen wrote:

These chunks are lightweight and it's useful information to have when
running ffmpeg -i or ffprobe, for example.
---
   libavcodec/pngdec.c  | 136 ++-
   tests/ref/fate/png-icc   |   8 +--
   tests/ref/fate/png-side-data |   2 +-
   3 files changed, 91 insertions(+), 55 deletions(-)

diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c


I will push this soon-ish if there's no other objections.

- Leo Izen (thebombzen)




Pushed as fadfa147f812a3fe9e68723347d37b9cccd6222d.


Hi, Sorry for digging this old patch, but I'm curious.

What does "unsupported tv-range cICP chunk\n" and "we only support
pc-range RGB" mean?

Before this patch the range was properly set:
avctx->color_range = f->color_range =
 s->cicp_range == 0 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;

Now it is ignored with a warning. Neither commit message, nor the
comments in the code explain why the cICP range is now ignored in the
decoder and the frames are no longer tagged with proper color range.



It means FFmpeg itself doesn't support tv-range RGB. The PNG format 
supports it but FFmpeg does not. Since the PNG spec specifies the matrix 
must equal zero (aka RGB), we can't support tv-range here and print a 
warning.


- Leo Izen (Traneptora)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 1/2] avcodec/libjxldec: produce rgbf32 and rgbaf32 frames

2023-12-11 Thread Leo Izen
These pixel formats have always been supported by libjxl, but at the
time this plugin was written, they were not in FFmpeg yet. Now that
they are in FFmpeg, we should support them.

Signed-off-by: Leo Izen 
---
 libavcodec/libjxldec.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c
index 494060ac8c..f763294eee 100644
--- a/libavcodec/libjxldec.c
+++ b/libavcodec/libjxldec.c
@@ -130,10 +130,11 @@ static enum AVPixelFormat 
libjxl_get_pix_fmt(AVCodecContext *avctx, LibJxlDecode
 return basic_info->alpha_bits ? AV_PIX_FMT_YA8 : AV_PIX_FMT_GRAY8;
 }
 if (basic_info->exponent_bits_per_sample || 
basic_info->bits_per_sample > 16) {
-if (basic_info->alpha_bits)
-return AV_PIX_FMT_NONE;
-format->data_type = JXL_TYPE_FLOAT;
-return AV_PIX_FMT_GRAYF32;
+if (!basic_info->alpha_bits) {
+format->data_type = JXL_TYPE_FLOAT;
+return AV_PIX_FMT_GRAYF32;
+}
+av_log(avctx, AV_LOG_WARNING, "Downsampling gray+alpha float to 
16-bit integer via libjxl\n");
 }
 format->data_type = JXL_TYPE_UINT16;
 return basic_info->alpha_bits ? AV_PIX_FMT_YA16 : AV_PIX_FMT_GRAY16;
@@ -145,10 +146,10 @@ static enum AVPixelFormat 
libjxl_get_pix_fmt(AVCodecContext *avctx, LibJxlDecode
 format->data_type = JXL_TYPE_UINT8;
 return basic_info->alpha_bits ? AV_PIX_FMT_RGBA : AV_PIX_FMT_RGB24;
 }
-if (basic_info->exponent_bits_per_sample)
-av_log(avctx, AV_LOG_WARNING, "Downsampling float to 16-bit 
integer via libjxl\n");
-else if (basic_info->bits_per_sample > 16)
-av_log(avctx, AV_LOG_WARNING, "Downsampling larger integer to 
16-bit via libjxl\n");
+if (basic_info->exponent_bits_per_sample || 
basic_info->bits_per_sample > 16) {
+format->data_type = JXL_TYPE_FLOAT;
+return basic_info->alpha_bits ? AV_PIX_FMT_RGBAF32 : 
AV_PIX_FMT_RGBF32;
+}
 format->data_type = JXL_TYPE_UINT16;
 return basic_info->alpha_bits ? AV_PIX_FMT_RGBA64 : AV_PIX_FMT_RGB48;
 }
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 2/2] avcodec/libjxlenc: accept rgbf32 and rgbaf32 frames

2023-12-11 Thread Leo Izen
These pixel formats have always been supported by libjxl, but at the
time this plugin was written, they were not in FFmpeg yet. Now that
they are in FFmpeg, we should support them.

Signed-off-by: Leo Izen 
---
 libavcodec/libjxlenc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/libjxlenc.c b/libavcodec/libjxlenc.c
index d707f3a61b..780dbb9e2e 100644
--- a/libavcodec/libjxlenc.c
+++ b/libavcodec/libjxlenc.c
@@ -493,6 +493,7 @@ const FFCodec ff_libjxl_encoder = {
 .p.pix_fmts   = (const enum AVPixelFormat[]) {
 AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA,
 AV_PIX_FMT_RGB48, AV_PIX_FMT_RGBA64,
+AV_PIX_FMT_RGBF32, AV_PIX_FMT_RGBAF32,
 AV_PIX_FMT_GRAY8, AV_PIX_FMT_YA8,
 AV_PIX_FMT_GRAY16, AV_PIX_FMT_YA16,
 AV_PIX_FMT_GRAYF32,
-- 
2.43.0

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

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


Re: [FFmpeg-devel] [PATCH 3/8] ffmpeg: add support for muxing AVStreamGroups

2023-12-11 Thread James Almer

On 12/11/2023 8:48 AM, Anton Khirnov wrote:

Quoting James Almer (2023-12-05 23:43:57)

Starting with IAMF support.

Signed-off-by: James Almer 
---
  fftools/ffmpeg.h  |   2 +
  fftools/ffmpeg_mux_init.c | 335 ++
  fftools/ffmpeg_opt.c  |   2 +
  3 files changed, 339 insertions(+)


Missing documentation.


Will do.




+static int of_add_groups(Muxer *mux, const OptionsContext *o)
+{
+AVFormatContext *oc = mux->fc;
+int ret;
+
+/* process manually set groups */
+for (int i = 0; i < o->nb_stream_groups; i++) {
+AVDictionary *dict = NULL, *tmp = NULL;
+const AVDictionaryEntry *e;
+AVStreamGroup *stg = NULL;
+int type;
+const char *token;
+char *str, *ptr = NULL;
+const AVOption opts[] = {
+{ "type", "Set group type", offsetof(AVStreamGroup, type), 
AV_OPT_TYPE_INT,
+{ .i64 = 0 }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, 
"type" },
+{ "iamf_audio_element",NULL, 0, AV_OPT_TYPE_CONST,
+{ .i64 = AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT },.unit = 
"type" },
+{ "iamf_mix_presentation", NULL, 0, AV_OPT_TYPE_CONST,
+{ .i64 = AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION }, .unit = 
"type" },
+{ NULL },
+};
+ const AVClass class = {
+.class_name = "StreamGroupType",
+.item_name  = av_default_item_name,
+.option = opts,
+.version= LIBAVUTIL_VERSION_INT,
+};
+const AVClass *pclass = &class;
+
+str = av_strdup(o->stream_groups[i].u.str);
+if (!str)
+goto end;
+
+token = av_strtok(str, ",", &ptr);
+if (token) {


Too many indentation levels, move this whole block into a separate
function.


+ret = av_dict_parse_string(&dict, token, "=", ":", 
AV_DICT_MULTIKEY);
+if (ret < 0) {
+av_log(mux, AV_LOG_ERROR, "Error parsing group specification 
%s\n", token);
+goto end;
+}
+
+// "type" is not a user settable option in AVStreamGroup


This comment confuses me.


AVStreamGroup.type is not setteable through AVOptions, but it of course 
needs to be supported by the CLI. So i catch it and remove it from the 
dict that will be used for avformat_stream_group_create().


I can change the comment to "'type' is not a user settable AVOption".




+e = av_dict_get(dict, "type", NULL, 0);
+if (!e) {
+av_log(mux, AV_LOG_ERROR, "No type define for Steam Group 
%d\n", i);


1) Steam
2) defined? Or maybe specified.


Will change to specified.


3) Print the string, not the index.


+ret = AVERROR(EINVAL);
+goto end;
+}
+
+ret = av_opt_eval_int(&pclass, opts, e->value, &type);
+if (ret < 0 || type == AV_STREAM_GROUP_PARAMS_NONE) {
+av_log(mux, AV_LOG_ERROR, "Invalid group type \"%s\"\n", 
e->value);
+goto end;
+}
+
+av_dict_copy(&tmp, dict, 0);
+stg = avformat_stream_group_create(oc, type, &tmp);
+if (!stg) {
+ret = AVERROR(ENOMEM);
+goto end;
+}
+av_dict_set(&tmp, "type", NULL, 0);
+
+e = NULL;
+while (e = av_dict_get(dict, "st", e, 0)) {
+unsigned int idx = strtol(e->value, NULL, 0);
+if (idx >= oc->nb_streams) {
+av_log(mux, AV_LOG_ERROR, "Invalid stream index %d\n", 
idx);
+ret = AVERROR(EINVAL);
+goto end;
+}


This block seems confused about signedness of e->value.


You mean change %d to %u?




+avformat_stream_group_add_stream(stg, oc->streams[idx]);


Unchecked return value.



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

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


Re: [FFmpeg-devel] [PATCH 2/8] avformat: introduce AVStreamGroup

2023-12-11 Thread James Almer

On 12/11/2023 7:59 AM, Anton Khirnov wrote:

Quoting James Almer (2023-12-05 23:43:56)

@@ -2819,6 +2972,22 @@ AVRational av_guess_frame_rate(AVFormatContext *ctx, 
AVStream *stream,
  int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st,
  const char *spec);
  
+/**

+ * Check if the group stg contained in s is matched by the stream group
+ * specifier spec.
+ *
+ * See the "stream group specifiers" chapter in the documentation for the
+ * syntax of spec.
+ *
+ * @return  >0 if stg is matched by spec;
+ *  0  if stg is not matched by spec;
+ *  AVERROR code if spec is invalid
+ *
+ * @note  A stream group specifier can match several groups in the format.
+ */
+int avformat_match_stream_group_specifier(AVFormatContext *s, AVStreamGroup 
*stg,
+  const char *spec);


What is this for? It does not seem to be used in this set.


Remnant from when i used in the CLI while developing this set.
I can remove it, but would it not be useful for some other API user?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 2/8] avformat: introduce AVStreamGroup

2023-12-11 Thread Anton Khirnov
Quoting James Almer (2023-12-11 13:48:17)
> On 12/11/2023 7:59 AM, Anton Khirnov wrote:
> > Quoting James Almer (2023-12-05 23:43:56)
> >> @@ -2819,6 +2972,22 @@ AVRational av_guess_frame_rate(AVFormatContext 
> >> *ctx, AVStream *stream,
> >>   int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st,
> >>   const char *spec);
> >>   
> >> +/**
> >> + * Check if the group stg contained in s is matched by the stream group
> >> + * specifier spec.
> >> + *
> >> + * See the "stream group specifiers" chapter in the documentation for the
> >> + * syntax of spec.
> >> + *
> >> + * @return  >0 if stg is matched by spec;
> >> + *  0  if stg is not matched by spec;
> >> + *  AVERROR code if spec is invalid
> >> + *
> >> + * @note  A stream group specifier can match several groups in the format.
> >> + */
> >> +int avformat_match_stream_group_specifier(AVFormatContext *s, 
> >> AVStreamGroup *stg,
> >> +  const char *spec);
> > 
> > What is this for? It does not seem to be used in this set.
> 
> Remnant from when i used in the CLI while developing this set.
> I can remove it, but would it not be useful for some other API user?

I doubt this API is useful to anyone and would much prefer to move it
back to the CLI where it belongs.

-- 
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 2/8] avformat: introduce AVStreamGroup

2023-12-11 Thread James Almer

On 12/11/2023 8:03 AM, Anton Khirnov wrote:

Quoting James Almer (2023-12-05 23:43:56)

+/**
+ * Remove a stream group from its AVFormatContext and free it.
+ * The group must be the last stream of the AVFormatContext.
+ */
+void ff_remove_stream_group(AVFormatContext *s, AVStreamGroup *stg);


When would this be useful?


I can't think of a use case right now, at least for the raw iamf demuxer 
and mp4 implementations. I added it for feature parity with AVStream and 
because it was four lines long.


Will remove.
___
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] avdevice/avfoundation: replace deprecated AVCaptureDevice

2023-12-11 Thread Thilo Borgmann via ffmpeg-devel

Am 11.12.23 um 10:32 schrieb Thilo Borgmann via ffmpeg-devel:

Am 09.12.23 um 13:09 schrieb xufuji456 via ffmpeg-devel:

Building with iOS platform, the compiler has a warning: "'devicesWithMediaType:' is 
deprecated: first deprecated in iOS 10.0 - Use AVCaptureDeviceDiscoverySession 
instead"

Signed-off-by: xufuji456 <839789...@qq.com>
---
  libavdevice/avfoundation.m | 65 +++---
  1 file changed, 60 insertions(+), 5 deletions(-)


LGTM.

Will apply shortly if there are no more comments.


Pushed.

-Thilo

___
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/5] avfilter: Add fsync filter

2023-12-11 Thread Thilo Borgmann via ffmpeg-devel
Synchronize video frames with an external mapping from a file.
Follows up on the idea in 
https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2023-January/305986.html
implemented as a filter.

Not storing the frame map in a probably huge string but buffering
piece-wise.

Thilo Borgmann (5):
  fftools/ffmpeg: split loop for parsing and validation of -stats_*
specifiers
  fftools/ffmpeg: move parsing of -stats_* specifiers to lavu/parseutils
  reindent after last commit
  avfilter: Add fsync filter
  fate: Add fsync filter tests

 Changelog|   1 +
 doc/filters.texi |  52 +
 fftools/ffmpeg.h |  33 +--
 fftools/ffmpeg_enc.c |   3 +-
 fftools/ffmpeg_mux_init.c| 152 ++---
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/vf_fsync.c   | 376 +++
 libavformat/version.h|   2 +-
 libavutil/parseutils.c   | 176 +++
 libavutil/parseutils.h   | 102 +
 libavutil/version.h  |   2 +-
 tests/Makefile   |   6 +-
 tests/fate/filter-video.mak  |   8 +
 tests/filtergraphs/fsync-down|   2 +
 tests/filtergraphs/fsync-up  |   2 +
 tests/maps/fsync-down|   7 +
 tests/maps/fsync-up  |  57 +
 tests/ref/fate/filter-fsync-down |  12 +
 tests/ref/fate/filter-fsync-up   |  62 +
 20 files changed, 891 insertions(+), 166 deletions(-)
 create mode 100644 libavfilter/vf_fsync.c
 create mode 100644 tests/filtergraphs/fsync-down
 create mode 100644 tests/filtergraphs/fsync-up
 create mode 100644 tests/maps/fsync-down
 create mode 100644 tests/maps/fsync-up
 create mode 100644 tests/ref/fate/filter-fsync-down
 create mode 100644 tests/ref/fate/filter-fsync-up

-- 
2.37.1 (Apple Git-137.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] fftools/ffmpeg: split loop for parsing and validation of -stats_* specifiers

2023-12-11 Thread Thilo Borgmann via ffmpeg-devel
---
 fftools/ffmpeg_mux_init.c | 40 ++-
 1 file changed, 27 insertions(+), 13 deletions(-)

diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 63a25a350f..6c473a8f09 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -365,6 +365,26 @@ static int enc_stats_init(OutputStream *ost, EncStats *es, 
int pre,
 
 c = &es->components[es->nb_components - 1];
 
+for (size_t i = 0; i < FF_ARRAY_ELEMS(fmt_specs); i++) {
+if (!strcmp(val, fmt_specs[i].str)) {
+c->type = fmt_specs[i].type;
+c->str  = val;
+c->str_len = val_len;
+break;
+}
+}
+
+if (!c->type) {
+av_log(NULL, AV_LOG_ERROR, "Invalid format directive: %s\n", val);
+ret = AVERROR(EINVAL);
+goto fail;
+}
+}
+
+for (int j = 0; j < es->nb_components; j++) {
+EncStatsComponent *c = &es->components[j];
+char *val = c->str;
+
 for (size_t i = 0; i < FF_ARRAY_ELEMS(fmt_specs); i++) {
 if (!strcmp(val, fmt_specs[i].str)) {
 if ((pre && fmt_specs[i].post_only) || (!pre && 
fmt_specs[i].pre_only)) {
@@ -375,8 +395,6 @@ static int enc_stats_init(OutputStream *ost, EncStats *es, 
int pre,
 goto fail;
 }
 
-c->type = fmt_specs[i].type;
-
 if (fmt_specs[i].need_input_data && !ost->ist) {
 av_log(ost, AV_LOG_WARNING,
"Format directive '%s' is unavailable, because "
@@ -387,20 +405,16 @@ static int enc_stats_init(OutputStream *ost, EncStats 
*es, int pre,
 break;
 }
 }
-
-if (!c->type) {
-av_log(NULL, AV_LOG_ERROR, "Invalid format directive: %s\n", val);
-ret = AVERROR(EINVAL);
-goto fail;
-}
-
-fail:
-av_freep(&val);
-if (ret < 0)
-return ret;
 }
 
 ret = enc_stats_get_file(&es->io, path);
+fail:
+for (int j = 0; j < es->nb_components; j++) {
+EncStatsComponent *c = &es->components[j];
+if (c->type != ENC_STATS_LITERAL) {
+av_freep(&c->str);
+}
+}
 if (ret < 0)
 return ret;
 
-- 
2.37.1 (Apple Git-137.1)

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

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


[FFmpeg-devel] [PATCH 2/5] fftools/ffmpeg: move parsing of -stats_* specifiers to lavu/parseutils

2023-12-11 Thread Thilo Borgmann via ffmpeg-devel
---
 fftools/ffmpeg.h  |  31 +--
 fftools/ffmpeg_enc.c  |   3 +-
 fftools/ffmpeg_mux_init.c | 152 +++-
 libavutil/parseutils.c| 176 ++
 libavutil/parseutils.h| 102 ++
 libavutil/version.h   |   2 +-
 6 files changed, 296 insertions(+), 170 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 1f11a2f002..cb4d90c7b2 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -42,6 +42,7 @@
 #include "libavutil/eval.h"
 #include "libavutil/fifo.h"
 #include "libavutil/hwcontext.h"
+#include "libavutil/parseutils.h"
 #include "libavutil/pixfmt.h"
 #include "libavutil/rational.h"
 #include "libavutil/thread.h"
@@ -437,36 +438,8 @@ enum forced_keyframes_const {
 #define ABORT_ON_FLAG_EMPTY_OUTPUT(1 <<  0)
 #define ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM (1 <<  1)
 
-enum EncStatsType {
-ENC_STATS_LITERAL = 0,
-ENC_STATS_FILE_IDX,
-ENC_STATS_STREAM_IDX,
-ENC_STATS_FRAME_NUM,
-ENC_STATS_FRAME_NUM_IN,
-ENC_STATS_TIMEBASE,
-ENC_STATS_TIMEBASE_IN,
-ENC_STATS_PTS,
-ENC_STATS_PTS_TIME,
-ENC_STATS_PTS_IN,
-ENC_STATS_PTS_TIME_IN,
-ENC_STATS_DTS,
-ENC_STATS_DTS_TIME,
-ENC_STATS_SAMPLE_NUM,
-ENC_STATS_NB_SAMPLES,
-ENC_STATS_PKT_SIZE,
-ENC_STATS_BITRATE,
-ENC_STATS_AVG_BITRATE,
-};
-
-typedef struct EncStatsComponent {
-enum EncStatsType type;
-
-uint8_t *str;
-size_t   str_len;
-} EncStatsComponent;
-
 typedef struct EncStats {
-EncStatsComponent  *components;
+AVEncStatsComponent  *components;
 int  nb_components;
 
 AVIOContext*io;
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index fa4539664f..a499bc0c81 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -30,6 +30,7 @@
 #include "libavutil/frame.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/log.h"
+#include "libavutil/parseutils.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/rational.h"
 #include "libavutil/timestamp.h"
@@ -499,7 +500,7 @@ void enc_stats_write(OutputStream *ost, EncStats *es,
 }
 
 for (size_t i = 0; i < es->nb_components; i++) {
-const EncStatsComponent *c = &es->components[i];
+const AVEncStatsComponent *c = &es->components[i];
 
 switch (c->type) {
 case ENC_STATS_LITERAL: avio_write (io, c->str, 
c->str_len);continue;
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 6c473a8f09..6acdf92c2c 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -242,152 +242,26 @@ void of_enc_stats_close(void)
 nb_enc_stats_files = 0;
 }
 
-static int unescape(char **pdst, size_t *dst_len,
-const char **pstr, char delim)
-{
-const char *str = *pstr;
-char *dst;
-size_t len, idx;
-
-*pdst = NULL;
-
-len = strlen(str);
-if (!len)
-return 0;
-
-dst = av_malloc(len + 1);
-if (!dst)
-return AVERROR(ENOMEM);
-
-for (idx = 0; *str; idx++, str++) {
-if (str[0] == '\\' && str[1])
-str++;
-else if (*str == delim)
-break;
-
-dst[idx] = *str;
-}
-if (!idx) {
-av_freep(&dst);
-return 0;
-}
-
-dst[idx] = 0;
-
-*pdst= dst;
-*dst_len = idx;
-*pstr= str;
-
-return 0;
-}
-
 static int enc_stats_init(OutputStream *ost, EncStats *es, int pre,
   const char *path, const char *fmt_spec)
 {
-static const struct {
-enum EncStatsType  type;
-const char*str;
-intpre_only:1;
-intpost_only:1;
-intneed_input_data:1;
-} fmt_specs[] = {
-{ ENC_STATS_FILE_IDX,   "fidx"  },
-{ ENC_STATS_STREAM_IDX, "sidx"  },
-{ ENC_STATS_FRAME_NUM,  "n" },
-{ ENC_STATS_FRAME_NUM_IN,   "ni",   0, 0, 1 },
-{ ENC_STATS_TIMEBASE,   "tb"},
-{ ENC_STATS_TIMEBASE_IN,"tbi",  0, 0, 1 },
-{ ENC_STATS_PTS,"pts"   },
-{ ENC_STATS_PTS_TIME,   "t" },
-{ ENC_STATS_PTS_IN, "ptsi", 0, 0, 1 },
-{ ENC_STATS_PTS_TIME_IN,"ti",   0, 0, 1 },
-{ ENC_STATS_DTS,"dts",  0, 1},
-{ ENC_STATS_DTS_TIME,   "dt",   0, 1},
-{ ENC_STATS_SAMPLE_NUM, "sn",   1   },
-{ ENC_STATS_NB_SAMPLES, "samp", 1   },
-{ ENC_STATS_PKT_SIZE,   "size", 0, 1},
-{ ENC_STATS_BITRATE,"br",   0, 1},
-{ ENC_STATS_AVG_BITRATE,"abr",  0, 1},
-};
-const char *

[FFmpeg-devel] [PATCH 4/5] avfilter: Add fsync filter

2023-12-11 Thread Thilo Borgmann via ffmpeg-devel
pu
---
 Changelog|   1 +
 doc/filters.texi |  52 ++
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/vf_fsync.c   | 376 +++
 libavformat/version.h|   2 +-
 6 files changed, 432 insertions(+), 1 deletion(-)
 create mode 100644 libavfilter/vf_fsync.c

diff --git a/Changelog b/Changelog
index f00bc27ca4..9cc441e9d4 100644
--- a/Changelog
+++ b/Changelog
@@ -7,6 +7,7 @@ version :
 - EVC encoding using external library libxeve
 - QOA decoder and demuxer
 - aap filter
+- fsync filter
 
 version 6.1:
 - libaribcaption decoder
diff --git a/doc/filters.texi b/doc/filters.texi
index 6d00ba2c3f..4ed12b83ac 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -14681,6 +14681,58 @@ option may cause flicker since the B-Frames have often 
larger QP. Default is
 
 @end table
 
+@anchor{fsync}
+@section fsync
+
+Synchronize video frames with an external mapping from a file.
+
+For each input PTS given in the map file it either drops or creates as many 
frames as necessary to recreate the sequence of output frames given in the map 
file.
+
+This filter is useful to recreate the output frames of a framerate conversion 
by the @ref{fps} filter, recorded into a map file using the ffmpeg option 
@code{-stats_mux_pre}, and do further processing to the corresponding frames 
e.g. quality comparison.
+
+The filter assumes the map file is sorted by increasing input PTS.
+
+The filter accepts the following options:
+@table @option
+
+@item file, f
+The filename of the map file to be used.
+Each line must contain at least one input PTS @code{@{ptsi@}}, one output PTS 
@code{@{pts@}} and one output timebase @code{@{tb@}}.
+Use the @code{format, fmt} option to specify which information is present in 
each line of the input file.
+
+@item format, fmt
+A format string describing the line format of the map file.
+It uses the same directives as the ffmpeg options @code{-stats_mux_pre_fmt}.
+The default value is @code{@{ptsi@} @{pts@} @{tb@}} which contains only the 
required information.
+@end table
+
+Some examples:
+@itemize
+@item Using the default format of the filter:
+@example
+# Convert a video to 25 fps and record a MAP_FILE file with the default format 
of this filter
+ffmpeg -i INPUT -vf fps=fps=25 -stats_mux_pre MAP_FILE -stats_mux_pre_fmt 
"@{ptsi@} @{pts@} @{tb@}" OUTPUT
+
+# Sort MAP_FILE by increasing input PTS
+sort -n MAP_FILE
+
+# Use INPUT, OUTPUT and the MAP_FILE from above to compare the corresponding 
frames in INPUT and OUTPUT via SSIM
+ffmpeg -i INPUT -i OUTPUT -filter_complex 
'[0:v]fsync=file=MAP_FILE[ref];[1:v][ref]ssim' -f null -
+@end example
+
+@item Using a custom format:
+@example
+# Convert a video to 25 fps and record a MAP_FILE file with a custom line 
format
+ffmpeg -i INPUT -vf fps=fps=25 -stats_mux_pre MAP_FILE -stats_mux_pre_fmt 
"@{n@} @{pts@} @{tb@} @{ni@} @{ptsi@} @{tbi@}" OUTPUT
+
+# Sort MAP_FILE by increasing input PTS
+sort -k 4 -n MAP_FILE
+
+# Use INPUT, OUTPUT and the MAP_FILE from above to compare the corresponding 
frames in INPUT and OUTPUT via SSIM
+ffmpeg -i INPUT -i OUTPUT -filter_complex '[0:v]fsync=file=MAP_FILE:fmt=@{n@} 
@{pts@} @{tb@} @{ni@} @{ptsi@} @{tbi@}[ref];[1:v][ref]ssim' -f null -
+@end example
+@end itemize
+
 @section gblur
 
 Apply Gaussian blur filter.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 63725f91b4..612616dfb4 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -323,6 +323,7 @@ OBJS-$(CONFIG_FREEZEDETECT_FILTER)   += 
vf_freezedetect.o
 OBJS-$(CONFIG_FREEZEFRAMES_FILTER)   += vf_freezeframes.o
 OBJS-$(CONFIG_FREI0R_FILTER) += vf_frei0r.o
 OBJS-$(CONFIG_FSPP_FILTER)   += vf_fspp.o qp_table.o
+OBJS-$(CONFIG_FSYNC_FILTER)  += vf_fsync.o
 OBJS-$(CONFIG_GBLUR_FILTER)  += vf_gblur.o
 OBJS-$(CONFIG_GBLUR_VULKAN_FILTER)   += vf_gblur_vulkan.o vulkan.o 
vulkan_filter.o
 OBJS-$(CONFIG_GEQ_FILTER)+= vf_geq.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index ed7c32be94..b32ffb2d71 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -299,6 +299,7 @@ extern const AVFilter ff_vf_freezedetect;
 extern const AVFilter ff_vf_freezeframes;
 extern const AVFilter ff_vf_frei0r;
 extern const AVFilter ff_vf_fspp;
+extern const AVFilter ff_vf_fsync;
 extern const AVFilter ff_vf_gblur;
 extern const AVFilter ff_vf_gblur_vulkan;
 extern const AVFilter ff_vf_geq;
diff --git a/libavfilter/vf_fsync.c b/libavfilter/vf_fsync.c
new file mode 100644
index 00..3d2027d007
--- /dev/null
+++ b/libavfilter/vf_fsync.c
@@ -0,0 +1,376 @@
+/*
+ * Copyright (c) 2023 Thilo Borgmann 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 

[FFmpeg-devel] [PATCH 3/5] reindent after last commit

2023-12-11 Thread Thilo Borgmann via ffmpeg-devel
---
 fftools/ffmpeg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index cb4d90c7b2..f169801366 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -440,7 +440,7 @@ enum forced_keyframes_const {
 
 typedef struct EncStats {
 AVEncStatsComponent  *components;
-int  nb_components;
+intnb_components;
 
 AVIOContext*io;
 } EncStats;
-- 
2.37.1 (Apple Git-137.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] fate: Add fsync filter tests

2023-12-11 Thread Thilo Borgmann via ffmpeg-devel
---
 tests/Makefile   |  6 +++-
 tests/fate/filter-video.mak  |  8 +
 tests/filtergraphs/fsync-down|  2 ++
 tests/filtergraphs/fsync-up  |  2 ++
 tests/maps/fsync-down|  7 
 tests/maps/fsync-up  | 57 +
 tests/ref/fate/filter-fsync-down | 12 +++
 tests/ref/fate/filter-fsync-up   | 62 
 8 files changed, 155 insertions(+), 1 deletion(-)
 create mode 100644 tests/filtergraphs/fsync-down
 create mode 100644 tests/filtergraphs/fsync-up
 create mode 100644 tests/maps/fsync-down
 create mode 100644 tests/maps/fsync-up
 create mode 100644 tests/ref/fate/filter-fsync-down
 create mode 100644 tests/ref/fate/filter-fsync-up

diff --git a/tests/Makefile b/tests/Makefile
index 444c09b3de..c7892a9313 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -23,7 +23,7 @@ FFMPEG=ffmpeg$(PROGSSUF)$(EXESUF)
 $(AREF): CMP=
 
 APITESTSDIR := tests/api
-FATE_OUTDIRS = tests/data tests/data/fate tests/data/filtergraphs 
tests/data/lavf tests/data/lavf-fate tests/data/pixfmt tests/vsynth1 
$(APITESTSDIR)
+FATE_OUTDIRS = tests/data tests/data/fate tests/data/filtergraphs 
tests/data/maps tests/data/lavf tests/data/lavf-fate tests/data/pixfmt 
tests/vsynth1 $(APITESTSDIR)
 OUTDIRS += $(FATE_OUTDIRS)
 
 $(VREF): tests/videogen$(HOSTEXESUF) | tests/vsynth1
@@ -66,6 +66,10 @@ tests/data/filtergraphs/%: TAG = COPY
 tests/data/filtergraphs/%: $(SRC_PATH)/tests/filtergraphs/% | 
tests/data/filtergraphs
$(M)cp $< $@
 
+tests/data/maps/%: TAG = COPY
+tests/data/maps/%: $(SRC_PATH)/tests/maps/% | tests/data/maps
+   $(M)cp $< $@
+
 RUNNING_FATE := $(filter check fate%,$(filter-out fate-rsync,$(MAKECMDGOALS)))
 
 # Check sanity of dependencies when running FATE tests.
diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index e4bdf59db9..e5af5bf7a5 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -395,6 +395,14 @@ FATE_FILTER_SAMPLES-$(call FILTERDEMDEC, FPS SCALE, MOV, 
QTRLE) += fate-filter-f
 fate-filter-fps-cfr: CMD = framecrc -auto_conversion_filters -i 
$(TARGET_SAMPLES)/qtrle/apple-animation-variable-fps-bug.mov -r 30 -fps_mode 
cfr -pix_fmt yuv420p
 fate-filter-fps: CMD = framecrc -auto_conversion_filters -i 
$(TARGET_SAMPLES)/qtrle/apple-animation-variable-fps-bug.mov -vf fps=30 
-pix_fmt yuv420p
 
+FATE_FILTER_SAMPLES-$(call FILTERFRAMECRC, TESTSRC2 FSYNC, FILE_PROTOCOL) += 
fate-filter-fsync-up fate-filter-fsync-down
+fate-filter-fsync-up: tests/data/filtergraphs/fsync-up
+fate-filter-fsync-up: tests/data/maps/fsync-up
+fate-filter-fsync-up: CMD = framecrc -filter_complex_script 
$(TARGET_PATH)/tests/data/filtergraphs/fsync-up
+fate-filter-fsync-down: tests/data/filtergraphs/fsync-down
+fate-filter-fsync-down: tests/data/maps/fsync-down
+fate-filter-fsync-down: CMD = framecrc -filter_complex_script 
$(TARGET_PATH)/tests/data/filtergraphs/fsync-down
+
 FATE_FILTER_ALPHAEXTRACT_ALPHAMERGE := $(addprefix 
fate-filter-alphaextract_alphamerge_, rgb yuv)
 FATE_FILTER_VSYNTH_PGMYUV-$(call ALLYES, SCALE_FILTER FORMAT_FILTER 
SPLIT_FILTER ALPHAEXTRACT_FILTER ALPHAMERGE_FILTER) += 
$(FATE_FILTER_ALPHAEXTRACT_ALPHAMERGE)
 $(FATE_FILTER_ALPHAEXTRACT_ALPHAMERGE): fate-filter-alphaextract_alphamerge_%: 
tests/data/filtergraphs/alphamerge_alphaextract_%
diff --git a/tests/filtergraphs/fsync-down b/tests/filtergraphs/fsync-down
new file mode 100644
index 00..56df6a6d52
--- /dev/null
+++ b/tests/filtergraphs/fsync-down
@@ -0,0 +1,2 @@
+testsrc2=r=25:d=1 [ref];
+[ref] fsync=f=tests/data/maps/fsync-down:fmt={ptsi} {tbi} {pts} {tb}
diff --git a/tests/filtergraphs/fsync-up b/tests/filtergraphs/fsync-up
new file mode 100644
index 00..e7a5c37728
--- /dev/null
+++ b/tests/filtergraphs/fsync-up
@@ -0,0 +1,2 @@
+testsrc2=r=25:d=1 [ref];
+[ref] fsync=f=tests/data/maps/fsync-up:fmt={pts} {tb} {ptsi} {tbi}
diff --git a/tests/maps/fsync-down b/tests/maps/fsync-down
new file mode 100644
index 00..536a993dd0
--- /dev/null
+++ b/tests/maps/fsync-down
@@ -0,0 +1,7 @@
+1 1/25 0 1/7
+5 1/25 1 1/7
+8 1/25 2 1/7
+12 1/25 3 1/7
+16 1/25 4 1/7
+19 1/25 5 1/7
+23 1/25 6 1/7
diff --git a/tests/maps/fsync-up b/tests/maps/fsync-up
new file mode 100644
index 00..7748b362e7
--- /dev/null
+++ b/tests/maps/fsync-up
@@ -0,0 +1,57 @@
+0 1/57 0 1/25
+1 1/57 0 1/25
+2 1/57 1 1/25
+3 1/57 1 1/25
+4 1/57 1 1/25
+5 1/57 2 1/25
+6 1/57 2 1/25
+7 1/57 3 1/25
+8 1/57 3 1/25
+9 1/57 4 1/25
+10 1/57 4 1/25
+11 1/57 5 1/25
+12 1/57 5 1/25
+13 1/57 5 1/25
+14 1/57 6 1/25
+15 1/57 6 1/25
+16 1/57 7 1/25
+17 1/57 7 1/25
+18 1/57 8 1/25
+19 1/57 8 1/25
+20 1/57 8 1/25
+21 1/57 9 1/25
+22 1/57 9 1/25
+23 1/57 10 1/25
+24 1/57 10 1/25
+25 1/57 11 1/25
+26 1/57 11 1/25
+27 1/57 12 1/25
+28 1/57 12 1/25
+29 1/57 12 1/25
+30 1/57 13 1/25
+31 1/57 13 1/25
+32 1/57 14 1/25
+33 1/57 14 1/25
+34 1/57 15 1/25
+35 1/57 15 1/25
+36 1/57 16 1/25
+37 1/57 16 1/25
+38 1/57 16 1/25
+39 1/57 17 1/25

Re: [FFmpeg-devel] [PATCH 4/5] avfilter: Add fsync filter

2023-12-11 Thread Thilo Borgmann via ffmpeg-devel

Am 11.12.23 um 16:07 schrieb Thilo Borgmann via ffmpeg-devel:

pu
---
  Changelog|   1 +
  doc/filters.texi |  52 ++
  libavfilter/Makefile |   1 +
  libavfilter/allfilters.c |   1 +
  libavfilter/vf_fsync.c   | 376 +++



  libavformat/version.h|   2 +-


Corrected locally...

-Thilo
___
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] avdevice/audiotoolbox: silence warning with new api

2023-12-11 Thread 徐福隆 via ffmpeg-devel
Hi, Thilo:
There is another patch that needs your review please.


Thanks




-- Original --
From:   
 "FFmpeg development discussions 
and patches"
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] avdevice/audiotoolbox: silence warning with new api

2023-12-11 Thread Thilo Borgmann via ffmpeg-devel

Am 11.12.23 um 16:28 schrieb 徐福隆 via ffmpeg-devel:

Hi, Thilo:
There is another patch that needs your review please.


Thanks for pointing me to it.


---
 libavdevice/audiotoolbox.m | 4 
 1 file changed, 4 insertions(+)


LGTM & pushed.

Thanks,
Thilo

___
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] doc/bitstream_filters: add filter_units practical examples for removing closed captions

2023-12-11 Thread Marth64
Added v2 label and signed off as per proper procedure.

Signed-off-by: Marth64 
---
 doc/bitstream_filters.texi | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index dc4f85bac0..7c36c5346d 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -213,6 +213,24 @@ To remove all AUDs, SEI and filler from an H.265 stream:
 ffmpeg -i INPUT -c:v copy -bsf:v 'filter_units=remove_types=35|38-40' OUTPUT
 @end example
 
+SEI messages are commonly used to contain Closed Captions as well as other 
metadata such as dynamic HDR.
+This filter can be used to remove the SEI messages if desired.
+
+To remove SEI messages (including CC) from a MPEG-2 stream:
+@example
+ffmpeg -i INPUT -c:v copy -bsf:v 'filter_units=remove_types=178' OUTPUT
+@end example
+
+To remove SEI messages (including CC) from a H264 stream:
+@example
+ffmpeg -i INPUT -c:v copy -bsf:v 'filter_units=remove_types=6' OUTPUT
+@end example
+
+To remove SEI messages (including CC and dynamic HDR) from a HEVC stream:
+@example
+ffmpeg -i INPUT -c:v copy -bsf:v 'filter_units=remove_types=39' OUTPUT
+@end example
+
 @section hapqa_extract
 
 Extract Rgb or Alpha part of an HAPQA file, without recompression, in order to 
create an HAPQ or an HAPAlphaOnly file.
-- 
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 1/2] checkasm: test for abs_pow34

2023-12-11 Thread Rémi Denis-Courmont
Le lauantaina 9. joulukuuta 2023, 12.45.03 EET flow gg a écrit :
> There's a strange issue:
> 
> Adding tests can compile successfully on x86 and lichee4a (risc v), but it
> results in an error on k230.
> 
> > collect2: fatal error: ld terminated with signal 9 [Killed]
> > compilation terminated.
> > 
> > [32833.539109]
> 
> oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),task=ld,pid=6804,uid=100
> 0
> > [32833.547321] Out of memory: Killed process 6804 (ld) total-vm:363180kB,
> 
> anon-rss:357536kB, file-rss:932kB, shmem-rss:0kB, UID:1000 pgtables:732kB
> oom_score_adj:0
> 
> > [32833.653223] oom_reaper: reaped process 6804 (ld), now anon-rss:0kB,
> 
> file-rss:0kB, shmem-rss:0kB
> 
> If I remove the line 1429 with FF_CODEC_ENCODE_CB(aac_encode_frame), there
> is no error on k230, but I am unsure of the reason.

Looks like plain dumb out-of-memory situation?
Not all that surprising when the hardware has only 512 MiB of RAM.

-- 
レミ・デニ-クールモン
http://www.remlab.net/



___
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/3] avcodec/libjxlenc: Add libjxl_animated encoder

2023-12-11 Thread Zsolt Vadasz via ffmpeg-devel
This patchset adds support for encoding animated JPEG XL images via a
new encoder (libjxl_animated). When using the encoder, the output format
needs to be set to raw video, as shown below:
`ffmpeg -i sample.gif -c:v libjxl_animated -f rawvideo out.jxl`

Feedback is welcome!

Zsolt Vadasz (3):
  avcodec/libjxlenc: Move JxlBasicInfo to LibJxlEncodeContext
  avcodec/libjxlenc: Move image initialization code into
libjxl_encode_init_image
  avcodec/libjxlenc: Add libjxl_animated encoder

 libavcodec/allcodecs.c |   1 +
 libavcodec/libjxlenc.c | 255 +++--
 2 files changed, 197 insertions(+), 59 deletions(-)

-- 
2.43.0


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

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


[FFmpeg-devel] [PATCH 2/3] avcodec/libjxlenc: Move image initialization code into libjxl_encode_init_image

2023-12-11 Thread Zsolt Vadász via ffmpeg-devel
---
 libavcodec/libjxlenc.c | 69 +++---
 1 file changed, 45 insertions(+), 24 deletions(-)

diff --git a/libavcodec/libjxlenc.c b/libavcodec/libjxlenc.c
index 92a458d51a..6110c42a7c 100644
--- a/libavcodec/libjxlenc.c
+++ b/libavcodec/libjxlenc.c
@@ -50,6 +50,9 @@ typedef struct LibJxlEncodeContext {
 JxlEncoder *encoder;
 JxlEncoderFrameSettings *options;
 JxlBasicInfo info;
+JxlPixelFormat jxl_fmt;
+int animated;
+int first_frame;
 int effort;
 float distance;
 int modular;
@@ -181,6 +184,9 @@ static av_cold int libjxl_encode_init(AVCodecContext *avctx)
 return AVERROR(ENOMEM);
 }
 
+ctx->animated = 0;
+ctx->first_frame = 1;
+
 return 0;
 }
 
@@ -235,28 +241,19 @@ static int libjxl_populate_primaries(void *avctx, 
JxlColorEncoding *jxl_color, e
 return 0;
 }
 
-/**
- * Encode an entire frame. Currently animation, is not supported by
- * this encoder, so this will always reinitialize a new still image
- * and encode a one-frame image (for image2 and image2pipe).
- */
-static int libjxl_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const 
AVFrame *frame, int *got_packet)
+static int libjxl_encode_init_image(AVCodecContext *avctx, const AVFrame 
*frame)
 {
 LibJxlEncodeContext *ctx = avctx->priv_data;
-AVFrameSideData *sd;
-const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(frame->format);
+int ret;
 JxlBasicInfo *info = &ctx->info;
+JxlPixelFormat *jxl_fmt = &ctx->jxl_fmt;
 JxlColorEncoding jxl_color;
-JxlPixelFormat jxl_fmt;
 int bits_per_sample;
 #if JPEGXL_NUMERIC_VERSION >= JPEGXL_COMPUTE_NUMERIC_VERSION(0, 8, 0)
 JxlBitDepth jxl_bit_depth;
 #endif
-JxlEncoderStatus jret;
-int ret;
-size_t available = ctx->buffer_size;
-size_t bytes_written = 0;
-uint8_t *next_out = ctx->buffer;
+const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(frame->format);
+AVFrameSideData *sd;
 
 /* reset the encoder every frame for image2 muxer */
 JxlEncoderReset(ctx->encoder);
@@ -269,23 +266,23 @@ static int libjxl_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt, const AVFra
 
 /* populate the basic info settings */
 JxlEncoderInitBasicInfo(info);
-jxl_fmt.num_channels = pix_desc->nb_components;
+jxl_fmt->num_channels = pix_desc->nb_components;
 info->xsize = frame->width;
 info->ysize = frame->height;
-info->num_extra_channels = (jxl_fmt.num_channels + 1) % 2;
-info->num_color_channels = jxl_fmt.num_channels - info->num_extra_channels;
-bits_per_sample = av_get_bits_per_pixel(pix_desc) / jxl_fmt.num_channels;
+info->num_extra_channels = (jxl_fmt->num_channels + 1) % 2;
+info->num_color_channels = jxl_fmt->num_channels - 
info->num_extra_channels;
+bits_per_sample = av_get_bits_per_pixel(pix_desc) / jxl_fmt->num_channels;
 info->bits_per_sample = avctx->bits_per_raw_sample > 0 && 
!(pix_desc->flags & AV_PIX_FMT_FLAG_FLOAT)
? avctx->bits_per_raw_sample : bits_per_sample;
 info->alpha_bits = (info->num_extra_channels > 0) * info->bits_per_sample;
 if (pix_desc->flags & AV_PIX_FMT_FLAG_FLOAT) {
 info->exponent_bits_per_sample = info->bits_per_sample > 16 ? 8 : 5;
 info->alpha_exponent_bits = info->alpha_bits ? 
info->exponent_bits_per_sample : 0;
-jxl_fmt.data_type = info->bits_per_sample > 16 ? JXL_TYPE_FLOAT : 
JXL_TYPE_FLOAT16;
+jxl_fmt->data_type = info->bits_per_sample > 16 ? JXL_TYPE_FLOAT : 
JXL_TYPE_FLOAT16;
 } else {
 info->exponent_bits_per_sample = 0;
 info->alpha_exponent_bits = 0;
-jxl_fmt.data_type = info->bits_per_sample <= 8 ? JXL_TYPE_UINT8 : 
JXL_TYPE_UINT16;
+jxl_fmt->data_type = info->bits_per_sample <= 8 ? JXL_TYPE_UINT8 : 
JXL_TYPE_UINT16;
 }
 
 #if JPEGXL_NUMERIC_VERSION >= JPEGXL_COMPUTE_NUMERIC_VERSION(0, 8, 0)
@@ -383,17 +380,41 @@ static int libjxl_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt, const AVFra
 av_log(avctx, AV_LOG_WARNING, "Could not increase codestream 
level\n");
 }
 
-jxl_fmt.endianness = JXL_NATIVE_ENDIAN;
-jxl_fmt.align = frame->linesize[0];
+jxl_fmt->endianness = JXL_NATIVE_ENDIAN;
+jxl_fmt->align = frame->linesize[0];
+
+return 0;
+}
+
+/**
+ * Encode an entire frame. Currently animation, is not supported by
+ * this encoder, so this will always reinitialize a new still image
+ * and encode a one-frame image (for image2 and image2pipe).
+ */
+static int libjxl_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const 
AVFrame *frame, int *got_packet)
+{
+LibJxlEncodeContext *ctx = avctx->priv_data;
+JxlEncoderStatus jret;
+JxlBasicInfo *info = &ctx->info;
+JxlPixelFormat *jxl_fmt = &ctx->jxl_fmt;
+int ret;
+size_t available = ctx->buffer_size;
+size_t bytes_written = 0;
+uint8_t *next_out = ctx->buffer;
+
+if(!ctx->animated || ctx->first_frame) {
+i

[FFmpeg-devel] [PATCH 1/3] avcodec/libjxlenc: Move JxlBasicInfo to LibJxlEncodeContext

2023-12-11 Thread Zsolt Vadász via ffmpeg-devel
---
 libavcodec/libjxlenc.c | 45 +-
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/libavcodec/libjxlenc.c b/libavcodec/libjxlenc.c
index d707f3a61b..92a458d51a 100644
--- a/libavcodec/libjxlenc.c
+++ b/libavcodec/libjxlenc.c
@@ -49,6 +49,7 @@ typedef struct LibJxlEncodeContext {
 void *runner;
 JxlEncoder *encoder;
 JxlEncoderFrameSettings *options;
+JxlBasicInfo info;
 int effort;
 float distance;
 int modular;
@@ -95,9 +96,6 @@ static int libjxl_init_jxl_encoder(AVCodecContext *avctx)
 {
 LibJxlEncodeContext *ctx = avctx->priv_data;
 
-/* reset the encoder every frame for image2 muxer */
-JxlEncoderReset(ctx->encoder);
-
 ctx->options = JxlEncoderFrameSettingsCreate(ctx->encoder, NULL);
 if (!ctx->options) {
 av_log(avctx, AV_LOG_ERROR, "Failed to create JxlEncoderOptions\n");
@@ -247,7 +245,7 @@ static int libjxl_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt, const AVFra
 LibJxlEncodeContext *ctx = avctx->priv_data;
 AVFrameSideData *sd;
 const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(frame->format);
-JxlBasicInfo info;
+JxlBasicInfo *info = &ctx->info;
 JxlColorEncoding jxl_color;
 JxlPixelFormat jxl_fmt;
 int bits_per_sample;
@@ -260,6 +258,9 @@ static int libjxl_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt, const AVFra
 size_t bytes_written = 0;
 uint8_t *next_out = ctx->buffer;
 
+/* reset the encoder every frame for image2 muxer */
+JxlEncoderReset(ctx->encoder);
+
 ret = libjxl_init_jxl_encoder(avctx);
 if (ret) {
 av_log(avctx, AV_LOG_ERROR, "Error frame-initializing JxlEncoder\n");
@@ -267,31 +268,31 @@ static int libjxl_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt, const AVFra
 }
 
 /* populate the basic info settings */
-JxlEncoderInitBasicInfo(&info);
+JxlEncoderInitBasicInfo(info);
 jxl_fmt.num_channels = pix_desc->nb_components;
-info.xsize = frame->width;
-info.ysize = frame->height;
-info.num_extra_channels = (jxl_fmt.num_channels + 1) % 2;
-info.num_color_channels = jxl_fmt.num_channels - info.num_extra_channels;
+info->xsize = frame->width;
+info->ysize = frame->height;
+info->num_extra_channels = (jxl_fmt.num_channels + 1) % 2;
+info->num_color_channels = jxl_fmt.num_channels - info->num_extra_channels;
 bits_per_sample = av_get_bits_per_pixel(pix_desc) / jxl_fmt.num_channels;
-info.bits_per_sample = avctx->bits_per_raw_sample > 0 && !(pix_desc->flags 
& AV_PIX_FMT_FLAG_FLOAT)
+info->bits_per_sample = avctx->bits_per_raw_sample > 0 && 
!(pix_desc->flags & AV_PIX_FMT_FLAG_FLOAT)
? avctx->bits_per_raw_sample : bits_per_sample;
-info.alpha_bits = (info.num_extra_channels > 0) * info.bits_per_sample;
+info->alpha_bits = (info->num_extra_channels > 0) * info->bits_per_sample;
 if (pix_desc->flags & AV_PIX_FMT_FLAG_FLOAT) {
-info.exponent_bits_per_sample = info.bits_per_sample > 16 ? 8 : 5;
-info.alpha_exponent_bits = info.alpha_bits ? 
info.exponent_bits_per_sample : 0;
-jxl_fmt.data_type = info.bits_per_sample > 16 ? JXL_TYPE_FLOAT : 
JXL_TYPE_FLOAT16;
+info->exponent_bits_per_sample = info->bits_per_sample > 16 ? 8 : 5;
+info->alpha_exponent_bits = info->alpha_bits ? 
info->exponent_bits_per_sample : 0;
+jxl_fmt.data_type = info->bits_per_sample > 16 ? JXL_TYPE_FLOAT : 
JXL_TYPE_FLOAT16;
 } else {
-info.exponent_bits_per_sample = 0;
-info.alpha_exponent_bits = 0;
-jxl_fmt.data_type = info.bits_per_sample <= 8 ? JXL_TYPE_UINT8 : 
JXL_TYPE_UINT16;
+info->exponent_bits_per_sample = 0;
+info->alpha_exponent_bits = 0;
+jxl_fmt.data_type = info->bits_per_sample <= 8 ? JXL_TYPE_UINT8 : 
JXL_TYPE_UINT16;
 }
 
 #if JPEGXL_NUMERIC_VERSION >= JPEGXL_COMPUTE_NUMERIC_VERSION(0, 8, 0)
 jxl_bit_depth.bits_per_sample = bits_per_sample;
 jxl_bit_depth.type = JXL_BIT_DEPTH_FROM_PIXEL_FORMAT;
 jxl_bit_depth.exponent_bits_per_sample = pix_desc->flags & 
AV_PIX_FMT_FLAG_FLOAT ?
- info.exponent_bits_per_sample : 0;
+ info->exponent_bits_per_sample : 
0;
 #endif
 
 /* JPEG XL format itself does not support limited range */
@@ -302,9 +303,9 @@ static int libjxl_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt, const AVFra
 av_log(avctx, AV_LOG_WARNING, "Unknown color range, assuming full 
(pc)\n");
 
 /* bitexact lossless requires there to be no XYB transform */
-info.uses_original_profile = ctx->distance == 0.0;
+info->uses_original_profile = ctx->distance == 0.0;
 
-if (JxlEncoderSetBasicInfo(ctx->encoder, &info) != JXL_ENC_SUCCESS) {
+if (JxlEncoderSetBasicInfo(ctx->encoder, info) != JXL_ENC_SUCCESS) {
 av_log(avctx, AV_LOG_ERROR, "Failed to set JxlBasicInfo\n");
 

[FFmpeg-devel] [PATCH 3/3] avcodec/libjxlenc: Add libjxl_animated encoder

2023-12-11 Thread Zsolt Vadász via ffmpeg-devel
---
 libavcodec/allcodecs.c |   1 +
 libavcodec/libjxlenc.c | 197 -
 2 files changed, 157 insertions(+), 41 deletions(-)

diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index b0f004e15c..e6733b0d4f 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -784,6 +784,7 @@ extern const FFCodec ff_libilbc_encoder;
 extern const FFCodec ff_libilbc_decoder;
 extern const FFCodec ff_libjxl_decoder;
 extern const FFCodec ff_libjxl_encoder;
+extern const FFCodec ff_libjxl_animated_encoder;
 extern const FFCodec ff_libmp3lame_encoder;
 extern const FFCodec ff_libopencore_amrnb_encoder;
 extern const FFCodec ff_libopencore_amrnb_decoder;
diff --git a/libavcodec/libjxlenc.c b/libavcodec/libjxlenc.c
index 6110c42a7c..5d437b2c05 100644
--- a/libavcodec/libjxlenc.c
+++ b/libavcodec/libjxlenc.c
@@ -31,14 +31,17 @@
 #include "libavutil/error.h"
 #include "libavutil/frame.h"
 #include "libavutil/libm.h"
+#include "libavutil/log.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/pixfmt.h"
 #include "libavutil/version.h"

+#include "packet.h"
 #include "avcodec.h"
 #include "encode.h"
 #include "codec_internal.h"
+#include "internal.h"

 #include 
 #include 
@@ -51,13 +54,14 @@ typedef struct LibJxlEncodeContext {
 JxlEncoderFrameSettings *options;
 JxlBasicInfo info;
 JxlPixelFormat jxl_fmt;
-int animated;
-int first_frame;
 int effort;
 float distance;
 int modular;
 uint8_t *buffer;
 size_t buffer_size;
+/* Only used by libjxl-animated */
+AVFrame *last;
+int animated;
 } LibJxlEncodeContext;

 /**
@@ -185,7 +189,6 @@ static av_cold int libjxl_encode_init(AVCodecContext *avctx)
 }

 ctx->animated = 0;
-ctx->first_frame = 1;

 return 0;
 }
@@ -284,6 +287,14 @@ static int libjxl_encode_init_image(AVCodecContext *avctx, 
const AVFrame *frame)
 info->alpha_exponent_bits = 0;
 jxl_fmt->data_type = info->bits_per_sample <= 8 ? JXL_TYPE_UINT8 : 
JXL_TYPE_UINT16;
 }
+if(ctx->animated) {
+info->have_animation = 1;
+info->animation.have_timecodes = 0;
+info->animation.num_loops = 0;
+info->animation.tps_numerator = frame->time_base.den;
+info->animation.tps_denominator = frame->time_base.num;
+avctx->time_base = frame->time_base;
+}

 #if JPEGXL_NUMERIC_VERSION >= JPEGXL_COMPUTE_NUMERIC_VERSION(0, 8, 0)
 jxl_bit_depth.bits_per_sample = bits_per_sample;
@@ -386,37 +397,12 @@ static int libjxl_encode_init_image(AVCodecContext 
*avctx, const AVFrame *frame)
 return 0;
 }

-/**
- * Encode an entire frame. Currently animation, is not supported by
- * this encoder, so this will always reinitialize a new still image
- * and encode a one-frame image (for image2 and image2pipe).
- */
-static int libjxl_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const 
AVFrame *frame, int *got_packet)
+static int libjxl_encode_process_output(AVCodecContext *avctx, size_t 
*bytes_written)
 {
 LibJxlEncodeContext *ctx = avctx->priv_data;
 JxlEncoderStatus jret;
-JxlBasicInfo *info = &ctx->info;
-JxlPixelFormat *jxl_fmt = &ctx->jxl_fmt;
-int ret;
-size_t available = ctx->buffer_size;
-size_t bytes_written = 0;
 uint8_t *next_out = ctx->buffer;
-
-if(!ctx->animated || ctx->first_frame) {
-if((ret = libjxl_encode_init_image(avctx, frame)) < 0)
-return ret;
-ctx->first_frame = 0;
-}
-
-if (JxlEncoderAddImageFrame(ctx->options, jxl_fmt, frame->data[0], 
jxl_fmt->align * info->ysize) != JXL_ENC_SUCCESS) {
-av_log(avctx, AV_LOG_ERROR, "Failed to add Image Frame\n");
-return AVERROR_EXTERNAL;
-}
-
-/*
- * Run this after the last frame in the image has been passed.
- */
-JxlEncoderCloseInput(ctx->encoder);
+size_t available = ctx->buffer_size;

 while (1) {
 jret = JxlEncoderProcessOutput(ctx->encoder, &next_out, &available);
@@ -424,7 +410,7 @@ static int libjxl_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt, const AVFra
 av_log(avctx, AV_LOG_ERROR, "Unspecified libjxl error occurred\n");
 return AVERROR_EXTERNAL;
 }
-bytes_written = ctx->buffer_size - available;
+*bytes_written = ctx->buffer_size - available;
 /* all data passed has been encoded */
 if (jret == JXL_ENC_SUCCESS)
 break;
@@ -441,14 +427,46 @@ static int libjxl_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt, const AVFra
 return AVERROR(ENOMEM);
 ctx->buffer = temp;
 ctx->buffer_size = new_size;
-next_out = ctx->buffer + bytes_written;
-available = new_size - bytes_written;
+next_out = ctx->buffer + *bytes_written;
+available = new_size - *bytes_written;
 continue;
 }
 av_log(avctx, AV_LOG_ERROR, "Bad libjxl event: %d\n", jret);

[FFmpeg-devel] [PATCH] lavd/avfoundation: Use correct preprocessing directive

2023-12-11 Thread Vittorio Giovara
Fixes compilation, introduced in e37b15e.

src/libavdevice/avfoundation.m:799:10: error: invalid preprocessing
directive
#elseif (TARGET_OS_OSX && __MAC_OS_X_VERSION_MAX_ALLOWED < 14)
-- 
Vittorio


0001-lavd-avfoundation-Use-correct-preprocessing-directiv.patch
Description: Binary data
___
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] lavd/avfoundation: Use correct preprocessing directive

2023-12-11 Thread Thilo Borgmann via ffmpeg-devel

Am 11.12.23 um 18:29 schrieb Vittorio Giovara:

Fixes compilation, introduced in e37b15e.

src/libavdevice/avfoundation.m:799:10: error: invalid preprocessing
directive


Which compiler did complain about that?


 #elseif (TARGET_OS_OSX && __MAC_OS_X_VERSION_MAX_ALLOWED < 14)


-Thilo

___
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] lavd/avfoundation: Use correct preprocessing directive

2023-12-11 Thread Thilo Borgmann via ffmpeg-devel

Am 11.12.23 um 18:29 schrieb Vittorio Giovara:

Fixes compilation, introduced in e37b15e.

src/libavdevice/avfoundation.m:799:10: error: invalid preprocessing
directive
 #elseif (TARGET_OS_OSX && __MAC_OS_X_VERSION_MAX_ALLOWED < 14)


Pushed.

-Thilo

___
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] lavd/avfoundation: Use correct preprocessing directive

2023-12-11 Thread Vittorio Giovara
On Mon, Dec 11, 2023 at 12:37 PM Thilo Borgmann via ffmpeg-devel <
ffmpeg-devel@ffmpeg.org> wrote:

> Am 11.12.23 um 18:29 schrieb Vittorio Giovara:
> > Fixes compilation, introduced in e37b15e.
> >
> > src/libavdevice/avfoundation.m:799:10: error: invalid preprocessing
> > directive
>
> Which compiler did complain about that?
>

Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: arm64-apple-darwin23.1.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
-- 
Vittorio
___
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] ffmpeg_opt: clarify that -ab is deprecated

2023-12-11 Thread Marth64
Added v2 flag and signoff to follow process. Adjusted based on feedback.

Signed-off-by: Marth64 
---
 fftools/ffmpeg_opt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 304471dd03..837bef8161 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1722,7 +1722,7 @@ const OptionDef options[] = {
   OPT_SPEC | OPT_OUTPUT,   
  { .off = OFFSET(forced_key_frames) },
 "force key frames at specified timestamps", "timestamps" },
 { "b",OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT,  
  { .func_arg = opt_bitrate },
-"video bitrate (please use -b:v)", "bitrate" },
+"stream bitrate (for video, please use -b:v)", "bitrate" },
 { "hwaccel",  OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT |
   OPT_SPEC | OPT_INPUT,
  { .off = OFFSET(hwaccels) },
 "use HW accelerated decoding", "hwaccel name" },
@@ -1763,7 +1763,7 @@ const OptionDef options[] = {
 OPT_INPUT | OPT_OUTPUT,
{ .func_arg = opt_audio_codec },
 "force audio codec ('copy' to copy stream)", "codec" },
 { "ab", OPT_AUDIO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT,
{ .func_arg = opt_bitrate },
-"audio bitrate (please use -b:a)", "bitrate" },
+"audio bitrate (deprecated, please use -b:a)", "bitrate" },
 { "atag",   OPT_AUDIO | HAS_ARG  | OPT_EXPERT | OPT_PERFILE |
 OPT_OUTPUT,
{ .func_arg = opt_old2new },
 "force audio tag/fourcc", "fourcc/tag" },
-- 
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] Misc ProRes frame header conformity fixes

2023-12-11 Thread Clément Bœsch
A bunch of fixes (currently made on top of the previous patchset but
shouldn't conflict much with a rebase) which are not extensively tested.

If some people have specific decoders available, tests are welcome.


___
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] avcodec/proresenc_anatoliy: use a compatible bitstream version

2023-12-11 Thread Clément Bœsch
Quoting SMPTE RDD 36:2015:
  A decoder shall abort if it encounters a bitstream with an unsupported
  bitstream_version value. If 0, the value of the chroma_format syntax
  element shall be 2 (4:2:2 sampling) and the value of the
  alpha_channel_type element shall be 0 (no encoded alpha); if 1, any
  permissible value may be used for those syntax elements.

So if we're not in 4:2:2 or if there is alpha, we are not allowed to use
version 0.
---
 libavcodec/proresenc_anatoliy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 414f52d396..6925dfe4bc 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -747,7 +747,7 @@ static int prores_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 bytestream_put_be32(&buf, FRAME_ID);
 
 bytestream_put_be16(&buf, header_size);
-bytestream_put_be16(&buf, 0); /* version */
+bytestream_put_be16(&buf, avctx->pix_fmt != AV_PIX_FMT_YUV422P10 || 
ctx->need_alpha ? 1 : 0); /* version */
 bytestream_put_buffer(&buf, ctx->vendor, 4);
 bytestream_put_be16(&buf, avctx->width);
 bytestream_put_be16(&buf, avctx->height);
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 2/5] avcodec/proresenc_kostya: use a compatible bitstream version

2023-12-11 Thread Clément Bœsch
Quoting SMPTE RDD 36:2015:
  A decoder shall abort if it encounters a bitstream with an unsupported
  bitstream_version value. If 0, the value of the chroma_format syntax
  element shall be 2 (4:2:2 sampling) and the value of the
  alpha_channel_type element shall be 0 (no encoded alpha); if 1, any
  permissible value may be used for those syntax elements.

So if we're not in 4:2:2 or if there is alpha, we are not allowed to use
version 0.
---
 libavcodec/proresenc_kostya.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index 05e90bb236..7e660a3708 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -995,7 +995,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket 
*pkt,
 // frame header
 tmp = buf;
 buf += 2;   // frame header size will be 
stored here
-bytestream_put_be16  (&buf, 0); // version 1
+bytestream_put_be16  (&buf, ctx->chroma_factor != CFACTOR_Y422 || 
ctx->alpha_bits ? 1 : 0);
 bytestream_put_buffer(&buf, ctx->vendor, 4);
 bytestream_put_be16  (&buf, avctx->width);
 bytestream_put_be16  (&buf, avctx->height);
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 3/5] avcodec/proresenc_kostya: do not write into alpha reserved bitfields

2023-12-11 Thread Clément Bœsch
This byte represents 4 reserved bits followed by 4 alpha_channel_type bits.

alpha_channel_type currently has 3 differents defined values: 0 (no
alpha), 1 (8b alpha), and 2 (16b alpha), all the other values are
reserved. This part is correctly written (alpha_bits>>3 does the correct
thing), but the 4 initial bits are reserved.
---
 libavcodec/proresenc_kostya.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index 7e660a3708..a71452466e 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -1009,7 +1009,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket 
*pkt,
 bytestream_put_byte  (&buf, pic->color_primaries);
 bytestream_put_byte  (&buf, pic->color_trc);
 bytestream_put_byte  (&buf, pic->colorspace);
-bytestream_put_byte  (&buf, 0x40 | (ctx->alpha_bits >> 3));
+bytestream_put_byte  (&buf, ctx->alpha_bits >> 3);
 bytestream_put_byte  (&buf, 0); // reserved
 if (ctx->quant_sel != QUANT_MAT_DEFAULT) {
 bytestream_put_byte  (&buf, 0x03);  // matrix flags - both 
matrices are present
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 4/5] avcodec/proresenc_anatoliy: do not write into alpha reserved bitfields

2023-12-11 Thread Clément Bœsch
This byte represents 4 reserved bits followed by 4 alpha_channel_type bits.

alpha_channel_type currently has 3 differents defined values: 0 (no
alpha), 1 (8b alpha), and 2 (16b alpha), all the other values are
reserved. The 4 initial reserved bits are expected to be 0.
---
 libavcodec/proresenc_anatoliy.c | 11 ++-
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 6925dfe4bc..727199ed3b 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -776,15 +776,8 @@ static int prores_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
   pict->color_trc, valid_trc, 0);
 *buf++ = int_from_list_or_default(avctx, "frame colorspace",
   pict->colorspace, valid_colorspace, 0);
-if (avctx->profile >= AV_PROFILE_PRORES_) {
-if (avctx->pix_fmt == AV_PIX_FMT_YUV444P10) {
-*buf++ = 0xA0;/* src b64a and no alpha */
-} else {
-*buf++ = 0xA2;/* src b64a and 16b alpha */
-}
-} else {
-*buf++ = 32;/* src v210 and no alpha */
-}
+if (ctx->need_alpha)
+*buf++ = 0x2; /* 16-bit alpha */
 *buf++ = 0; /* reserved */
 *buf++ = 3; /* luma and chroma matrix present */
 
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 5/5] avcodec/proresenc_anatoliy: do not write into chroma reserved bitfields

2023-12-11 Thread Clément Bœsch
The layout for the frame flags is as follow:

   chroma_format  u(2)
   reserved   u(2)
   interlace_mode u(2)
   reserved   u(2)

chroma_format has 2 allowed values:
   0: reserved
   1: reserved
   2: 4:2:2
   3: 4:4:4

interlace_mode has 3 allowed values:
   0: progressive
   1: tff
   2: bff
   3: reserved

0x80 is what we expect for "422 not interlaced", and the extra 0x2 from
0x82 is actually writting into the reserved bits.
---
 libavcodec/proresenc_anatoliy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 727199ed3b..7c2ec7b3fe 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -751,7 +751,7 @@ static int prores_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 bytestream_put_buffer(&buf, ctx->vendor, 4);
 bytestream_put_be16(&buf, avctx->width);
 bytestream_put_be16(&buf, avctx->height);
-frame_flags = 0x82; /* 422 not interlaced */
+frame_flags = 0x80; /* 422 not interlaced */
 if (avctx->profile >= AV_PROFILE_PRORES_) /*  or  Xq */
 frame_flags |= 0x40; /* 444 chroma */
 if (ctx->is_interlaced) {
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH] doc/filters: add example for idet filter

2023-12-11 Thread Marth64
Signed-off-by: Marth64 
---
 doc/filters.texi | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index 6d00ba2c3f..1250685bc7 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -15919,6 +15919,13 @@ further computations. This allows inserting the idet 
filter as a low computation
 method to clean up the interlaced flag
 @end table
 
+@subsection Examples
+
+Analyze the field order of the first 360 frames in a video (use @code{NUL} as 
output for Windows):
+@example
+ffmpeg -i INPUT -filter:v idet -frames:v 360 -an -f rawvideo -y /dev/null
+@end example
+
 @section il
 
 Deinterleave or interleave fields.
-- 
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 v2] doc/filters: add example for idet filter

2023-12-11 Thread Marth64
Cleaned up mistake of outputting with rawvideo format

Signed-off-by: Marth64 
---
 doc/filters.texi | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index 6d00ba2c3f..e595f7d152 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -15919,6 +15919,13 @@ further computations. This allows inserting the idet 
filter as a low computation
 method to clean up the interlaced flag
 @end table
 
+@subsection Examples
+
+Analyze the field order of the first 360 frames in a video (use @code{NUL} as 
output for Windows):
+@example
+ffmpeg -i INPUT -filter:v idet -frames:v 360 -an -f null -y /dev/null
+@end example
+
 @section il
 
 Deinterleave or interleave fields.
-- 
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 v3] doc/filters: add example for idet filter

2023-12-11 Thread Marth64
Clean up the example further. Sorry.

Signed-off-by: Marth64 
---
 doc/filters.texi | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index 6d00ba2c3f..bf59352ba0 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -15919,6 +15919,13 @@ further computations. This allows inserting the idet 
filter as a low computation
 method to clean up the interlaced flag
 @end table
 
+@subsection Examples
+
+Analyze the field order of the first 360 frames in a video:
+@example
+ffmpeg -i INPUT -filter:v idet -frames:v 360 -an -f null -
+@end example
+
 @section il
 
 Deinterleave or interleave fields.
-- 
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 v2] doc/bitstream_filters: add filter_units practical examples for removing closed captions

2023-12-11 Thread Mark Thompson

On 11/12/2023 16:33, Marth64 wrote:

Added v2 label and signed off as per proper procedure.

Signed-off-by: Marth64 
---
  doc/bitstream_filters.texi | 18 ++
  1 file changed, 18 insertions(+)

diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index dc4f85bac0..7c36c5346d 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -213,6 +213,24 @@ To remove all AUDs, SEI and filler from an H.265 stream:
  ffmpeg -i INPUT -c:v copy -bsf:v 'filter_units=remove_types=35|38-40' OUTPUT
  @end example
  
+SEI messages are commonly used to contain Closed Captions as well as other metadata such as dynamic HDR.

+This filter can be used to remove the SEI messages if desired.
+
+To remove SEI messages (including CC) from a MPEG-2 stream:
+@example
+ffmpeg -i INPUT -c:v copy -bsf:v 'filter_units=remove_types=178' OUTPUT
+@end example


MPEG-2 doesn't call these SEI, it is simply "user data".


+
+To remove SEI messages (including CC) from a H264 stream:
+@example
+ffmpeg -i INPUT -c:v copy -bsf:v 'filter_units=remove_types=6' OUTPUT
+@end example
+
+To remove SEI messages (including CC and dynamic HDR) from a HEVC stream:
+@example
+ffmpeg -i INPUT -c:v copy -bsf:v 'filter_units=remove_types=39' OUTPUT
+@end example


Are closed captions allowed in suffix SEI as well?  T.35 messages are certainly 
allowed there.

(I'm mildly inclined to think that a more specific bitstream filter able to 
mess with the SEI types would be more useful?  This approach feels like it has 
a lot of collateral damage.)

Thanks,

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

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


[FFmpeg-devel] [PATCH] checkasm/lpc: test compute_autocorr

2023-12-11 Thread Rémi Denis-Courmont
---
 tests/checkasm/lpc.c | 36 
 1 file changed, 36 insertions(+)

diff --git a/tests/checkasm/lpc.c b/tests/checkasm/lpc.c
index 592e34c03d..8e92a9e1b4 100644
--- a/tests/checkasm/lpc.c
+++ b/tests/checkasm/lpc.c
@@ -57,10 +57,40 @@ static void test_window(int len)
 bench_new(src, len, dst1);
 }
 
+static void test_compute_autocorr(int lag)
+{
+LOCAL_ALIGNED(16, double, src, [5000]);
+LOCAL_ALIGNED(16, double, dst0, [32]);
+LOCAL_ALIGNED(16, double, dst1, [32]);
+const size_t len = 5000;
+
+declare_func(void, const double *in, ptrdiff_t len, int lag, double *out);
+
+for (size_t i = 0; i < len; i++) {
+src[i] = (double)rnd() / (double)UINT_MAX;
+}
+
+call_ref(src, len, lag, dst0);
+call_new(src, len, lag, dst1);
+
+for (size_t i = 0; i < lag; i++) {
+if (!double_near_abs_eps(dst0[i], dst1[i], EPS)) {
+fprintf(stderr, "%zu: %- .12f - %- .12f = % .12g\n",
+i, dst0[i], dst1[i], dst0[i] - dst1[i]);
+fail();
+break;
+}
+}
+
+bench_new(src, len, lag, dst1);
+}
+
 void checkasm_check_lpc(void)
 {
 LPCContext ctx;
 int len = rnd() % 5000;
+static const int lags[] = { 10, 30, 32 };
+
 ff_lpc_init(&ctx, 32, 16, FF_LPC_TYPE_DEFAULT);
 
 if (check_func(ctx.lpc_apply_welch_window, "apply_welch_window_even")) {
@@ -73,5 +103,11 @@ void checkasm_check_lpc(void)
 }
 report("apply_welch_window_odd");
 
+for (size_t i = 0; i < FF_ARRAY_ELEMS(lags); i++) {
+if (check_func(ctx.lpc_compute_autocorr, "autocorr_%d", lags[i]))
+test_compute_autocorr(lags[i]);
+report("compute_autocorr_%d", lags[i]);
+}
+
 ff_lpc_end(&ctx);
 }
-- 
2.43.0

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

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


Re: [FFmpeg-devel] [PATCH v2 7/7] avcodec: add AV_CODEC_FLAG_CLEAR

2023-12-11 Thread Mark Thompson

On 07/12/2023 23:11, Marton Balint wrote:

On Thu, 7 Dec 2023, Anton Khirnov wrote:

Quoting Marton Balint (2023-12-06 09:22:20)

Signed-off-by: Marton Balint 
---
 doc/APIchanges |  3 +++
 doc/codecs.texi    | 14 ++
 libavcodec/avcodec.h   |  4 
 libavcodec/decode.c    |  6 ++
 libavcodec/options_table.h |  1 +
 libavcodec/version.h   |  2 +-
 6 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 416e2bec5e..f839504a64 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09

 API changes, most recent first:

+2023-12-xx - xxx - lavc 60.36.100 - avcodec.h
+  Add AV_CODEC_FLAG_CLEAR.


I'm not a huge fan of calling it just 'clear'. How about something more
descriptive like 'wipe_frames'.


Wipe reminds me of the wipe effect. How about 'predecode_clear'?


+
 2023-12-xx - xxx - lavu 58.33.100 - imgutils.h
   Add av_image_fill_color()

diff --git a/doc/codecs.texi b/doc/codecs.texi
index 5b950b4560..0504a535f2 100644
--- a/doc/codecs.texi
+++ b/doc/codecs.texi
@@ -76,6 +76,20 @@ Apply interlaced motion estimation.
 Use closed gop.
 @item output_corrupt
 Output even potentially corrupted frames.
+@item clear
+Clear the contents of the video buffer before decoding the next picture to it.
+
+Usually if only a part of a picture is affected by a decode error then the
+decoder (if it implements error concealment) tries to hide it by interpolating
+pixels from neighbouring areas or in some cases from the previous frame. Even
+without error concealment it is quite likely that the affected area will
+contain pixels from an earlier frame, due to frame pooling.
+
+For quality checking this might not be desirable, because it makes the errors
+less noticable. By using this flag, and combining it with disabled error
+concealment (@code{-ec 0}) it is possible to ensure that no leftover data from
+an earlier frame is presented in areas affected by decode errors.
+
 @end table

 @item time_base @var{rational number}
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 7fb44e28f4..97848e942f 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -312,6 +312,10 @@ typedef struct RcOverride{
  * loop filter.
  */
 #define AV_CODEC_FLAG_LOOP_FILTER (1 << 11)
+/**
+ * Clear frame buffer contents before decoding.


Clear the contents of each frame buffer after it is allocated with
AVCodecContext.get_buffer2() and before anything is decoded into it.

Note that this may have a significant performance cost.


ok.




+ */
+#define AV_CODEC_FLAG_CLEAR   (1 << 12)
 /**
  * Only decode/encode grayscale.
  */
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 2cfb3fcf97..f9b18a2c35 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1675,6 +1675,12 @@ FF_ENABLE_DEPRECATION_WARNINGS

 validate_avframe_allocation(avctx, frame);

+    if (avctx->flags & AV_CODEC_FLAG_CLEAR && avctx->codec_type == 
AVMEDIA_TYPE_VIDEO) {
+    uint32_t color[4] = {0};
+    ptrdiff_t linesize[4] = {frame->linesize[0], frame->linesize[1], 
frame->linesize[2], frame->linesize[3]};
+    av_image_fill_color(frame->data, linesize, frame->format, color, 
frame->width, frame->height);


Should this check for errors?


Lack of error checking is intentional. av_image_fill_color might not support 
all pixel formats, definitely not support hwaccel formats. It might make sense 
to warn the user once, but I don't think propagating the error back is needed 
here.


I don't think I agree with this?  Even if you say it isn't, it still looks like 
a privacy and security feature and so people may treat it as such.

Consider a transcoding application with user-supplied ingest - without 
something like this, a malformed input from the user could leak random 
previously-deallocated memory, which could contain anything (frames from other 
users, private keys, etc.).

So, if the user has explicitly requested that frames are cleared then IMO it 
should either clear them or fail.

(I do think the feature is a good idea.  Supporting hardware formats there is 
probably straightforward in at least some cases if useful.)

Thanks,

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

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


Re: [FFmpeg-devel] [PATCH] checkasm/lpc: test compute_autocorr

2023-12-11 Thread Rémi Denis-Courmont
Le maanantaina 11. joulukuuta 2023, 22.41.03 EET Rémi Denis-Courmont a écrit :
> ---
>  tests/checkasm/lpc.c | 36 
>  1 file changed, 36 insertions(+)
> 
> diff --git a/tests/checkasm/lpc.c b/tests/checkasm/lpc.c
> index 592e34c03d..8e92a9e1b4 100644
> --- a/tests/checkasm/lpc.c
> +++ b/tests/checkasm/lpc.c
> @@ -57,10 +57,40 @@ static void test_window(int len)
>  bench_new(src, len, dst1);
>  }
> 
> +static void test_compute_autocorr(int lag)
> +{
> +LOCAL_ALIGNED(16, double, src, [5000]);
> +LOCAL_ALIGNED(16, double, dst0, [32]);
> +LOCAL_ALIGNED(16, double, dst1, [32]);
> +const size_t len = 5000;
> +
> +declare_func(void, const double *in, ptrdiff_t len, int lag, double
> *out); +
> +for (size_t i = 0; i < len; i++) {
> +src[i] = (double)rnd() / (double)UINT_MAX;

Not sure if we should test negative numbers here.

> +}
> +
> +call_ref(src, len, lag, dst0);
> +call_new(src, len, lag, dst1);

Presumably src needs to be offset by one element, as the first iteration of the 
loop reads at offset minus one (in C code: sum1 += ...).

> +
> +for (size_t i = 0; i < lag; i++) {
> +if (!double_near_abs_eps(dst0[i], dst1[i], EPS)) {
> +fprintf(stderr, "%zu: %- .12f - %- .12f = % .12g\n",
> +i, dst0[i], dst1[i], dst0[i] - dst1[i]);
> +fail();
> +break;
> +}
> +}
> +
> +bench_new(src, len, lag, dst1);
> +}
> +
>  void checkasm_check_lpc(void)
>  {
>  LPCContext ctx;
>  int len = rnd() % 5000;
> +static const int lags[] = { 10, 30, 32 };
> +
>  ff_lpc_init(&ctx, 32, 16, FF_LPC_TYPE_DEFAULT);
> 
>  if (check_func(ctx.lpc_apply_welch_window, "apply_welch_window_even"))
> { @@ -73,5 +103,11 @@ void checkasm_check_lpc(void)
>  }
>  report("apply_welch_window_odd");
> 
> +for (size_t i = 0; i < FF_ARRAY_ELEMS(lags); i++) {
> +if (check_func(ctx.lpc_compute_autocorr, "autocorr_%d", lags[i]))
> +test_compute_autocorr(lags[i]);
> +report("compute_autocorr_%d", lags[i]);
> +}
> +
>  ff_lpc_end(&ctx);
>  }


-- 
雷米‧德尼-库尔蒙
http://www.remlab.net/



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

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


Re: [FFmpeg-devel] [PATCH] lavc/ac3: add R-V Zbb extract_exponents

2023-12-11 Thread Rémi Denis-Courmont
Le maanantaina 4. joulukuuta 2023, 4.34.26 EET Zhao Zhili a écrit :
> > So really you're better off with GCC. RISC-V support on LLVM is pretty
> > sad, TBH.
> OK, just check if this is an unknown issue. I’m totally fine to stay with
> GCC.

Build should be fixed (which means the "offending" files should no longer be 
compiled).

-- 
Rémi Denis-Courmont
http://www.remlab.net/



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

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


Re: [FFmpeg-devel] [PATCH 2/2] lavfi: add qrencodesrc source

2023-12-11 Thread Kyle Swanson
Hi,

On Sat, Dec 9, 2023 at 10:14 AM Stefano Sabatini  wrote:
>
> On date Thursday 2023-11-30 01:49:14 +0100, Stefano Sabatini wrote:
> > ---
> >  configure   |   4 +
> >  libavfilter/Makefile|   1 +
> >  libavfilter/allfilters.c|   1 +
> >  libavfilter/vsrc_qrencode.c | 435 
> >  4 files changed, 441 insertions(+)
> >  create mode 100644 libavfilter/vsrc_qrencode.c
>
> Rev2 with padding and doc.

libavfilter/vsrc_qrencode.c:42:10: fatal error: 'textutils.h' file not found
#include "textutils.h"
^
1 error generated.

Thanks,
Kyle
___
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 10 bit support v5 1/3] avcodec/amfenc: Fixes the color information in the output.

2023-12-11 Thread Mark Thompson

On 29/11/2023 10:57, Evgeny Pavlov wrote:

On Tue, Nov 28, 2023 at 8:13 PM Mark Thompson  wrote:


I upgraded to 23.11.1 and see no change - the colour information is still
missing in the header but not the stream, and the two different sequence
parameter sets are identical to what they were before the change.

Can you share what your trace_headers output looks like for the
out-of-band and in-band parameter sets?  Are they identical for you?


Yes, it seems that they are identical for me and both have colour
information (please find my output below).
Is it possible to provide a video you tested? Probably I need to
test the patch on your video input.


Not the same, but here is a freely-available test video which has the same effect: 
<https://4kmedia.org/lg-new-york-hdr-uhd-4k-demo/>.  Output below.

It doesn't seem like this should be dependent on the underlying hardware since 
(I hope) it won't go to the hardware for header information.  Still, just in 
case: it's a 5850U APU running driver version 23.11.1 on Windows 10.

(Seems like it might be a good idea for the debug output to print the driver 
and hardware versions at least?)

The VPS out-of-order is also a weird effect - it makes it look like the two 
headers are generated by separate processes, which doesn't seem like a good 
idea when you want them to be identical.

Thanks,

- Mark


ffmpeg started on 2023-12-11 at 21:08:30

Report written to "ffmpeg-20231211-210830.log"

Log level: 48

Command line:

ffmpeg_g.exe -report -y -threads 1 -i in.ts -an -c:v hevc_amf -bsf:v 
trace_headers -frames:v 1 out.mp4

ffmpeg version N-112951-g8c718b936a Copyright (c) 2000-2023 the FFmpeg 
developers

  built with gcc 13.2.0 (Rev3, Built by MSYS2 project)

  configuration: --assert-level=2 --enable-debug --disable-optimizations 
--enable-gpl --enable-libx264 --enable-libx265 --enable-libaom --enable-opencl 
--enable-amf --enable-dxva2 --enable-d3d11va

  libavutil  58. 32.100 / 58. 32.100

  libavcodec 60. 35.100 / 60. 35.100

  libavformat60. 18.100 / 60. 18.100

  libavdevice60.  4.100 / 60.  4.100

  libavfilter 9. 14.100 /  9. 14.100

  libswscale  7.  6.100 /  7.  6.100

  libswresample   4. 13.100 /  4. 13.100

  libpostproc57.  4.100 / 57.  4.100

Splitting the commandline.

Reading option '-report' ... matched as option 'report' (generate a report) 
with argument '1'.

Reading option '-y' ... matched as option 'y' (overwrite output files) with 
argument '1'.

Reading option '-threads' ... matched as AVOption 'threads' with argument '1'.

Reading option '-i' ... matched as output url with argument 'in.ts'.

Reading option '-an' ... matched as option 'an' (disable audio) with argument 
'1'.

Reading option '-c:v' ... matched as option 'c' (codec name) with argument 
'hevc_amf'.

Reading option '-bsf:v' ... matched as option 'bsf' (A comma-separated list of 
bitstream filters) with argument 'trace_headers'.

Reading option '-frames:v' ... matched as option 'frames' (set the number of 
frames to output) with argument '1'.

Reading option 'out.mp4' ... matched as output url.

Finished splitting the commandline.

Parsing a group of options: global .

Applying option report (generate a report) with argument 1.

Applying option y (overwrite output files) with argument 1.

Successfully parsed a group of options.

Parsing a group of options: input url in.ts.

Successfully parsed a group of options.

Opening an input file: in.ts.

[AVFormatContext @ 018927c73700] Opening 'in.ts' for reading

[file @ 018927c2da40] Setting default whitelist 'file,crypto,data'

[mpegts @ 018927c73700] Format mpegts probed with size=2048 and score=50

[mpegts @ 018927c73700] stream=0 stream_type=24 pid=101 prog_reg_desc=

[mpegts @ 018927c73700] stream=1 stream_type=f pid=102 prog_reg_desc=

[mpegts @ 018927c73700] Before avformat_find_stream_info() pos: 0 bytes 
read:32768 seeks:0 nb_streams:2

[hevc @ 018927c76fc0] nal_unit_type: 35(AUD), nuh_layer_id: 0, temporal_id: 0

[hevc @ 018927c76fc0] nal_unit_type: 32(VPS), nuh_layer_id: 0, temporal_id: 0

[hevc @ 018927c76fc0] nal_unit_type: 33(SPS), nuh_layer_id: 0, temporal_id: 0

[hevc @ 018927c76fc0] nal_unit_type: 34(PPS), nuh_layer_id: 0, temporal_id: 0

[hevc @ 018927c76fc0] nal_unit_type: 39(SEI_PREFIX), nuh_layer_id: 0, 
temporal_id: 0

[hevc @ 018927c76fc0] nal_unit_type: 39(SEI_PREFIX), nuh_layer_id: 0, 
temporal_id: 0

[hevc @ 018927c76fc0] nal_unit_type: 39(SEI_PREFIX), nuh_layer_id: 0, 
temporal_id: 0

[hevc @ 018927c76fc0] nal_unit_type: 20(IDR_N_LP), nuh_layer_id: 0, 
temporal_id: 0

[hevc @ 018927c76fc0] nal_unit_type: 38(FD_NUT), nuh_layer

[FFmpeg-devel] [PATCH] fate: Allow running multiple rounds of tests with differing settings

2023-12-11 Thread Martin Storsjö
This can be used to run tests multple times, with e.g. differing
QEMU settings, by adding something like this to the FATE configuration
file:

target_exec="qemu-aarch64-static"
fate_targets="fate-checkasm fate-cpu"

fate_environments="sve128 sve256 sve512"
sve128_env="QEMU_CPU=max,sve128=on"
sve256_env="QEMU_CPU=max,sve256=on"
sve512_env="QEMU_CPU=max,sve512=on"

It's also possible to customize the target_exec command further
by injecting a sufficiently quoted variable into it, which then can
be updated for each run, e.g. target_exec="\$(CUR_EXEC_CMD)".

For each of the environment names in fate_environments, the tests
that are run get the name suffixed on the fate tests in the
test log and fate report, e.g. "fate-checkasm-h264dsp_sve128".
---
For adding the environment to the fate run, there's three
ways it can be done:
- (${curenv}; make fate)
- ${curenv} make fate
- make fate ${curenv}

The first has most freedom in what one can do, but requires explicit
"export VAR=value", while the other two are simpler for just setting
"VAR1=val1 VAR2=val2". For now, I picked the third form.
---
 tests/Makefile |  4 ++--
 tests/fate.sh  | 14 +-
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/tests/Makefile b/tests/Makefile
index 444c09b3de..744dbcdfb3 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -305,8 +305,8 @@ $(FATE): export PROGSUF = $(PROGSSUF)
 $(FATE): export EXECSUF = $(EXESUF)
 $(FATE): export HOSTEXECSUF = $(HOSTEXESUF)
 $(FATE): $(FATE_UTILS:%=tests/%$(HOSTEXESUF)) | $(FATE_OUTDIRS)
-   @echo "TEST$(@:fate-%=%)"
-   $(Q)$(SRC_PATH)/tests/fate-run.sh $@ "$(TARGET_SAMPLES)" 
"$(TARGET_EXEC)" "$(TARGET_PATH)" '$(CMD)' '$(CMP)' '$(REF)' '$(FUZZ)' 
'$(THREADS)' '$(THREAD_TYPE)' '$(CPUFLAGS)' '$(CMP_SHIFT)' '$(CMP_TARGET)' 
'$(SIZE_TOLERANCE)' '$(CMP_UNIT)' '$(GEN)' '$(HWACCEL)' '$(REPORT)' 
'$(KEEP_FILES)'
+   @echo "TEST$(@:fate-%=%)$(FATE_SUFFIX)"
+   $(Q)$(SRC_PATH)/tests/fate-run.sh $@$(FATE_SUFFIX) "$(TARGET_SAMPLES)" 
"$(TARGET_EXEC)" "$(TARGET_PATH)" '$(CMD)' '$(CMP)' '$(REF)' '$(FUZZ)' 
'$(THREADS)' '$(THREAD_TYPE)' '$(CPUFLAGS)' '$(CMP_SHIFT)' '$(CMP_TARGET)' 
'$(SIZE_TOLERANCE)' '$(CMP_UNIT)' '$(GEN)' '$(HWACCEL)' '$(REPORT)' 
'$(KEEP_FILES)'
 
 fate-list:
@printf '%s\n' $(sort $(FATE))
diff --git a/tests/fate.sh b/tests/fate.sh
index 95408ea109..c04eb41cbe 100755
--- a/tests/fate.sh
+++ b/tests/fate.sh
@@ -101,7 +101,19 @@ compile_extra()(
 fate()(
 test "$build_only" = "yes" && return
 cd ${build} || return
-${make} ${makeopts_fate-${makeopts}} -k ${fate_targets}
+if [ -n "${fate_environments}" ]; then
+ret=0
+for e in ${fate_environments}; do
+eval "curenv=\${${e}_env}"
+echo Testing environment ${e}: ${curenv}
+${make} ${makeopts_fate-${makeopts}} -k ${fate_targets} 
FATE_SUFFIX=_${e} ${curenv}
+cur_ret=$?
+test $cur_ret != 0 && ret=$cur_ret
+done
+return $ret
+else
+${make} ${makeopts_fate-${makeopts}} -k ${fate_targets}
+fi
 )
 
 clean(){
-- 
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 6/7] avutil/imgutils: add new function av_image_fill_color()

2023-12-11 Thread Stefano Sabatini
On date Saturday 2023-12-09 20:25:07 +0100, Marton Balint wrote:
> v3: added flags argument.
> 
> Signed-off-by: Marton Balint 
> ---
>  doc/APIchanges   |  3 +++
>  libavutil/imgutils.c |  6 +++---
>  libavutil/imgutils.h | 31 +++
>  libavutil/version.h  |  2 +-
>  4 files changed, 38 insertions(+), 4 deletions(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 4a2dc1c44f..2b0326165e 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09
>  
>  API changes, most recent first:
>  
> +2023-12-xx - xxx - lavu 58.33.100 - imgutils.h
> +  Add av_image_fill_color().
> +
>  2023-11-08 - b82957a66a7 - lavu 58.32.100 - channel_layout.h
>Add AV_CH_LAYOUT_7POINT2POINT3 and AV_CHANNEL_LAYOUT_7POINT2POINT3.
>Add AV_CH_LAYOUT_9POINT1POINT4_BACK and 
> AV_CHANNEL_LAYOUT_9POINT1POINT4_BACK.
> diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
> index 278e30ee0f..aae40ba59a 100644
> --- a/libavutil/imgutils.c
> +++ b/libavutil/imgutils.c
> @@ -579,9 +579,9 @@ static void memset_bytes(uint8_t *dst, size_t dst_size, 
> uint8_t *clear,
>  // if it's a subsampled packed format).
>  #define MAX_BLOCK_SIZE 32
>  
> -static int image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t 
> dst_linesize[4],
> +int av_image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t 
> dst_linesize[4],
>  enum AVPixelFormat pix_fmt, const uint32_t color[4],
> -int width, int height)
> +int width, int height, int flags)
>  {
>  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
>  int nb_planes = av_pix_fmt_count_planes(pix_fmt);
> @@ -713,5 +713,5 @@ int av_image_fill_black(uint8_t * const dst_data[4], 
> const ptrdiff_t dst_linesiz
>  colors[c] = color;
>  }
>  
> -return image_fill_color(dst_data, dst_linesize, pix_fmt, colors, width, 
> height);
> +return av_image_fill_color(dst_data, dst_linesize, pix_fmt, colors, 
> width, height, 0);
>  }
> diff --git a/libavutil/imgutils.h b/libavutil/imgutils.h
> index fa3bb101b1..a29ed46a39 100644
> --- a/libavutil/imgutils.h
> +++ b/libavutil/imgutils.h
> @@ -339,6 +339,37 @@ int av_image_fill_black(uint8_t * const dst_data[4], 
> const ptrdiff_t dst_linesiz
>  enum AVPixelFormat pix_fmt, enum AVColorRange range,
>  int width, int height);
>  
> +/**
> + * Overwrite the image data with a color. This is suitable for filling a
> + * sub-rectangle of an image, meaning the padding between the right most 
> pixel
> + * and the left most pixel on the next line will not be overwritten. For some
> + * formats, the image size might be rounded up due to inherent alignment.
> + *
> + * If the pixel format has alpha, it is also replaced. Color component values
> + * are interpreted as native integers (or intfloats) regardless of actual 
> pixel
> + * format endianness.
> + *
> + * This can return an error if the pixel format is not supported. Normally, 
> all
> + * non-hwaccel pixel formats should be supported.
> + *
> + * Passing NULL for dst_data is allowed. Then the function returns whether 
> the
> + * operation would have succeeded. (It can return an error if the pix_fmt is
> + * not supported.)
> + *
> + * @param dst_data  data pointers to destination image
> + * @param dst_linesize  linesizes for the destination image
> + * @param pix_fmt   the pixel format of the image
> + * @param color the color components to be used for the fill
> + * @param width the width of the image in pixels
> + * @param heightthe height of the image in pixels
> + * @param flags currently unused
> + * @return 0 if the image data was filled, a negative AVERROR code otherwise
> + */
> +int av_image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t 
> dst_linesize[4],
> +enum AVPixelFormat pix_fmt, const uint32_t color[4],
> +int width, int height, int flags);

> +
> +

ni+++: drop the duplicated empty line

Still LGTM.
___
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] doc/bitstream_filters: add filter_units practical examples for removing closed captions

2023-12-11 Thread Stefano Sabatini
On date Saturday 2023-12-09 19:35:50 -0600, Marth64 wrote:
> ---
>  doc/bitstream_filters.texi | 18 ++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
> index c63c20370f..d2ad6e78ff 100644
> --- a/doc/bitstream_filters.texi
> +++ b/doc/bitstream_filters.texi
> @@ -213,6 +213,24 @@ To remove all AUDs, SEI and filler from an H.265 stream:
>  ffmpeg -i INPUT -c:v copy -bsf:v 'filter_units=remove_types=35|38-40' OUTPUT
>  @end example
>  
> +SEI messages are commonly used to contain Closed Captions as well as other 
> metadata such as dynamic HDR.
> +This filter can be used to remove the SEI messages if desired.
> +
> +To remove SEI messages (including CC) from a MPEG-2 stream:
> +@example
> +ffmpeg -i INPUT -c:v copy -bsf:v 'filter_units=remove_types=178' OUTPUT
> +@end example
> +
> +To remove SEI messages (including CC) from a H264 stream:
> +@example
> +ffmpeg -i INPUT -c:v copy -bsf:v 'filter_units=remove_types=6' OUTPUT
> +@end example
> +
> +To remove SEI messages (including CC and dynamic HDR) from a HEVC stream:
> +@example
> +ffmpeg -i INPUT -c:v copy -bsf:v 'filter_units=remove_types=39' OUTPUT
> +@end example

Shall be good, but probably we can still do a bit better, by making
explicit the common pattern.

Something as:
...

SEI messages are commonly used to contain Closed Captions as well as
other metadata such as dynamic HDR.

This filter can be used to remove the SEI messages, including CC,
given the bitstream SEI unit type (which changes depending on the
video stream).

To remove SEI messages (including CC) from a MPEG-2 stream:
...
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 2/2] lavfi: add qrencodesrc source

2023-12-11 Thread Stefano Sabatini
On date Monday 2023-12-11 12:59:39 -0800, Kyle Swanson wrote:
> Hi,
> 
> On Sat, Dec 9, 2023 at 10:14 AM Stefano Sabatini  wrote:
> >
> > On date Thursday 2023-11-30 01:49:14 +0100, Stefano Sabatini wrote:
> > > ---
> > >  configure   |   4 +
> > >  libavfilter/Makefile|   1 +
> > >  libavfilter/allfilters.c|   1 +
> > >  libavfilter/vsrc_qrencode.c | 435 
> > >  4 files changed, 441 insertions(+)
> > >  create mode 100644 libavfilter/vsrc_qrencode.c
> >
> > Rev2 with padding and doc.
> 
> libavfilter/vsrc_qrencode.c:42:10: fatal error: 'textutils.h' file not found
> #include "textutils.h"
> ^
> 1 error generated.

This depends on:
[PATCH 1/2] lavfi: introduce textutils
___
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] examples/transcode: fix log message

2023-12-11 Thread Stefano Sabatini
On date Thursday 2023-11-30 23:57:31 +0800, Zhao Zhili wrote:
> From: Zhao Zhili 
> 
> 'encoder' can be audio or video encoder.
> ---
>  doc/examples/transcode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Looks good, will apply.
___
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] doc/filters: add example for idet filter

2023-12-11 Thread Stefano Sabatini
On date Monday 2023-12-11 14:07:42 -0600, Marth64 wrote:
> Clean up the example further. Sorry.
> 
> Signed-off-by: Marth64 
> ---
>  doc/filters.texi | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 6d00ba2c3f..bf59352ba0 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -15919,6 +15919,13 @@ further computations. This allows inserting the idet 
> filter as a low computation
>  method to clean up the interlaced flag
>  @end table
>  
> +@subsection Examples
> +

> +Analyze the field order of the first 360 frames in a video:
> +@example
> +ffmpeg -i INPUT -filter:v idet -frames:v 360 -an -f null -
> +@end example

Probably it's also useful to clarify the expectations for the user.
This command will add the metadata to the frames, which will be then
discarded, and print a final report with some stats.
Probably it's more useful to show a complete example showing the value
for each frame, for example with metadata=mode=print

-filter:v idet,metadata=mode=print 
___
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] doc/ffprobe: add a useful one-liner example to get essential input information as JSON

2023-12-11 Thread Stefano Sabatini
On date Saturday 2023-12-09 20:57:09 -0600, Marth64 wrote:
> Signed-off-by: Marth64 
> 
> This could be useful for folks who are just learning ffmpeg or have simple 
> needs for parsing input information as JSON.
> 
> ---
>  doc/ffprobe.texi | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/doc/ffprobe.texi b/doc/ffprobe.texi
> index b74ff650ac..ed88e619f6 100644
> --- a/doc/ffprobe.texi
> +++ b/doc/ffprobe.texi
> @@ -572,6 +572,12 @@ printed on a single line. Default value is 0.
>  
>  For more information about JSON, see @url{http://www.json.org/}.
>  
> +@subsection Examples
> +Output format, stream, and chapter information of an input as JSON:
> +@example
> +ffprobe -of json -show_format -show_streams -show_chapters INPUT
> +@end example

Not convinced this is the right place for it (because the writers
section is mostly about the writers).

Probably we miss an overall generic section showing complete examples
(which might well contain your example).
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] avformat/options_table, doc/formats: clarify meaning of igndts as per definition in avformat.h

2023-12-11 Thread Stefano Sabatini
On date Saturday 2023-12-09 21:05:13 -0600, Marth64 wrote:
> This confused me for a long time, hopefully this is helpful to others.
> The definition in avformat.h says "Ignore DTS on frames that contain both DTS 
> & PTS"
> 
> Signed-off-by: Marth64 
> ---
>  doc/formats.texi| 2 +-
>  libavformat/options_table.h | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/doc/formats.texi b/doc/formats.texi
> index 640b23b790..2ebcef50c0 100644
> --- a/doc/formats.texi
> +++ b/doc/formats.texi
> @@ -46,7 +46,7 @@ Enable fast, but inaccurate seeks for some formats.
>  @item genpts
>  Generate missing PTS if DTS is present.
>  @item igndts
> -Ignore DTS if PTS is set. Inert when nofillin is set.
> +Ignore DTS if PTS is also set. Inert when nofillin is set.

This can be expanded a bit, my take:

Ignore DTS if PTS is also set. In case the PTS is set, the DTS value
is set to NOPTS. This is ignored when the @code{nofillin} flag is set.

>  @item ignidx
>  Ignore index.
>  @item nobuffer
> diff --git a/libavformat/options_table.h b/libavformat/options_table.h
> index 91708de453..4ee3fc1d81 100644
> --- a/libavformat/options_table.h
> +++ b/libavformat/options_table.h
> @@ -45,7 +45,7 @@ static const AVOption avformat_options[] = {
>  {"genpts", "generate pts", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_GENPTS 
> }, INT_MIN, INT_MAX, D, "fflags"},
>  {"nofillin", "do not fill in missing values that can be exactly calculated", 
> 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_NOFILLIN }, INT_MIN, INT_MAX, D, 
> "fflags"},
>  {"noparse", "disable AVParsers, this needs nofillin too", 0, 
> AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_NOPARSE }, INT_MIN, INT_MAX, D, 
> "fflags"},
> -{"igndts", "ignore dts", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_IGNDTS }, 
> INT_MIN, INT_MAX, D, "fflags"},

> +{"igndts", "ignore dts (if pts is also set)", 0, AV_OPT_TYPE_CONST,
>  {.i64 = AVFMT_FLAG_IGNDTS }, INT_MIN, INT_MAX, D, "fflags"},

set DTS to NOPTS value in case PTS is set
?

___
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] doc/filters: add example for idet filter

2023-12-11 Thread Michael Niedermayer
On Mon, Dec 11, 2023 at 01:53:36PM -0600, Marth64 wrote:
> Signed-off-by: Marth64 
> ---
>  doc/filters.texi | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 6d00ba2c3f..1250685bc7 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -15919,6 +15919,13 @@ further computations. This allows inserting the idet 
> filter as a low computation
>  method to clean up the interlaced flag
>  @end table
>  
> +@subsection Examples
> +
> +Analyze the field order of the first 360 frames in a video (use @code{NUL} 
> as output for Windows):
> +@example
> +ffmpeg -i INPUT -filter:v idet -frames:v 360 -an -f rawvideo -y /dev/null

why -f rawvideo and not -f null ?

thx

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

Does the universe only have a finite lifespan? No, its going to go on
forever, its just that you wont like living in it. -- Hiranya Peiri


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

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


Re: [FFmpeg-devel] [PATCH] doc/filters: add example for idet filter

2023-12-11 Thread Michael Niedermayer
On Tue, Dec 12, 2023 at 01:18:01AM +0100, Michael Niedermayer wrote:
> On Mon, Dec 11, 2023 at 01:53:36PM -0600, Marth64 wrote:
> > Signed-off-by: Marth64 
> > ---
> >  doc/filters.texi | 7 +++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/doc/filters.texi b/doc/filters.texi
> > index 6d00ba2c3f..1250685bc7 100644
> > --- a/doc/filters.texi
> > +++ b/doc/filters.texi
> > @@ -15919,6 +15919,13 @@ further computations. This allows inserting the 
> > idet filter as a low computation
> >  method to clean up the interlaced flag
> >  @end table
> >  
> > +@subsection Examples
> > +
> > +Analyze the field order of the first 360 frames in a video (use @code{NUL} 
> > as output for Windows):
> > +@example
> > +ffmpeg -i INPUT -filter:v idet -frames:v 360 -an -f rawvideo -y /dev/null
> 
> why -f rawvideo and not -f null ?

i see you changed this already in a subsequent patch, please ignore me

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

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


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

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


Re: [FFmpeg-devel] [PATCH] gdigrab: Allow capturing a window by its handle

2023-12-11 Thread Stefano Sabatini
On date Monday 2023-12-11 02:52:01 +0100, ffmpeg-devel Mailing List wrote:
> x11grab can capture windows by their ID, but gdigrab can only capture windows 
> by their names, internally calling FindWindowW to lookup its handle.
> 
> This patch simply allows the user to specify a window handle directly.
> Signed-off-by: Lena 
> ---

>  libavdevice/gdigrab.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)

Missing doc/indevs.texi updates.

> diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c
> index c069232472..05d3c0c929 100644
> --- a/libavdevice/gdigrab.c
> +++ b/libavdevice/gdigrab.c
> @@ -273,9 +273,13 @@ gdigrab_read_header(AVFormatContext *s1)
>  }
>  } else if (!strcmp(filename, "desktop")) {
>  hwnd = NULL;

> +} else if (!strncmp(filename, "hwnd=", 5)) {
> +name = filename + 5;
> +
> +hwnd = strtol(name, NULL, 0);

This should fail in case the parsing failed, for this you can check
the second argument (see examples in the code).
___
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] Add new vf_tiltandshift filter

2023-12-11 Thread Vittorio Giovara
This is an older filter I wrote and never got around publishing.
It can be used to generate a distortion effect like
https://vimeo.com/104938599?share=copy
Please see attached.
-- 
Vittorio


0001-Add-new-vf_tiltandshift-filter.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH v2 2/4] libavfilter/vf_dnn_detect: Add input pad

2023-12-11 Thread wenbin . chen-at-intel . com
From: Wenbin Chen 

Add input pad to get model input resolution. Detection models always
have fixed input size. And the output coordinators are based on the
input resolution, so we need to get input size to map coordinators to
our real output frames.

Signed-off-by: Wenbin Chen 
---
 libavfilter/dnn/dnn_backend_openvino.c | 24 --
 libavfilter/vf_dnn_detect.c| 28 +-
 2 files changed, 45 insertions(+), 7 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_openvino.c 
b/libavfilter/dnn/dnn_backend_openvino.c
index 089e028818..671a995c70 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -1073,9 +1073,15 @@ static int get_input_ov(void *model, DNNData *input, 
const char *input_name)
 return AVERROR(ENOSYS);
 }
 
-input->channels = dims[1];
-input->height   = input_resizable ? -1 : dims[2];
-input->width= input_resizable ? -1 : dims[3];
+if (dims[1] <= 3) { // NCHW
+input->channels = dims[1];
+input->height   = input_resizable ? -1 : dims[2];
+input->width= input_resizable ? -1 : dims[3];
+} else { // NHWC
+input->height   = input_resizable ? -1 : dims[1];
+input->width= input_resizable ? -1 : dims[2];
+input->channels = dims[3];
+}
 input->dt   = precision_to_datatype(precision);
 
 return 0;
@@ -1105,9 +,15 @@ static int get_input_ov(void *model, DNNData *input, 
const char *input_name)
 return DNN_GENERIC_ERROR;
 }
 
-input->channels = dims.dims[1];
-input->height   = input_resizable ? -1 : dims.dims[2];
-input->width= input_resizable ? -1 : dims.dims[3];
+if (dims[1] <= 3) { // NCHW
+input->channels = dims[1];
+input->height   = input_resizable ? -1 : dims[2];
+input->width= input_resizable ? -1 : dims[3];
+} else { // NHWC
+input->height   = input_resizable ? -1 : dims[1];
+input->width= input_resizable ? -1 : dims[2];
+input->channels = dims[3];
+}
 input->dt   = precision_to_datatype(precision);
 return 0;
 }
diff --git a/libavfilter/vf_dnn_detect.c b/libavfilter/vf_dnn_detect.c
index 373dda58bf..86f61c9907 100644
--- a/libavfilter/vf_dnn_detect.c
+++ b/libavfilter/vf_dnn_detect.c
@@ -699,13 +699,39 @@ static av_cold void dnn_detect_uninit(AVFilterContext 
*context)
 free_detect_labels(ctx);
 }
 
+static int config_input(AVFilterLink *inlink)
+{
+AVFilterContext *context = inlink->dst;
+DnnDetectContext *ctx = context->priv;
+DNNData model_input;
+int ret;
+
+ret = ff_dnn_get_input(&ctx->dnnctx, &model_input);
+if (ret != 0) {
+av_log(ctx, AV_LOG_ERROR, "could not get input from the model\n");
+return ret;
+}
+ctx->scale_width = model_input.width == -1 ? inlink->w : model_input.width;
+ctx->scale_height = model_input.height ==  -1 ? inlink->h : 
model_input.height;
+
+return 0;
+}
+
+static const AVFilterPad dnn_detect_inputs[] = {
+{
+.name = "default",
+.type = AVMEDIA_TYPE_VIDEO,
+.config_props = config_input,
+},
+};
+
 const AVFilter ff_vf_dnn_detect = {
 .name  = "dnn_detect",
 .description   = NULL_IF_CONFIG_SMALL("Apply DNN detect filter to the 
input."),
 .priv_size = sizeof(DnnDetectContext),
 .init  = dnn_detect_init,
 .uninit= dnn_detect_uninit,
-FILTER_INPUTS(ff_video_default_filterpad),
+FILTER_INPUTS(dnn_detect_inputs),
 FILTER_OUTPUTS(ff_video_default_filterpad),
 FILTER_PIXFMTS_ARRAY(pix_fmts),
 .priv_class= &dnn_detect_class,
-- 
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 v2 4/4] libavfilter/vf_dnn_detect: Add yolov4 support

2023-12-11 Thread wenbin . chen-at-intel . com
From: Wenbin Chen 

The difference of yolov4 is that sigmoid function needed to be applied
on x, y coordinates. Also make it compatiple with NHWC output as the
yolov4 model from openvino model zoo has NHWC output layout.

Model refer to: 
https://github.com/openvinotoolkit/open_model_zoo/tree/master/models/public/yolo-v4-tf

Signed-off-by: Wenbin Chen 
---
 libavfilter/vf_dnn_detect.c | 71 ++---
 1 file changed, 59 insertions(+), 12 deletions(-)

diff --git a/libavfilter/vf_dnn_detect.c b/libavfilter/vf_dnn_detect.c
index 7a32b191c3..1b04a2cb98 100644
--- a/libavfilter/vf_dnn_detect.c
+++ b/libavfilter/vf_dnn_detect.c
@@ -35,7 +35,8 @@
 typedef enum {
 DDMT_SSD,
 DDMT_YOLOV1V2,
-DDMT_YOLOV3
+DDMT_YOLOV3,
+DDMT_YOLOV4
 } DNNDetectionModelType;
 
 typedef struct DnnDetectContext {
@@ -75,6 +76,7 @@ static const AVOption dnn_detect_options[] = {
 { "ssd", "output shape [1, 1, N, 7]",  0,
AV_OPT_TYPE_CONST,   { .i64 = DDMT_SSD },0, 0, FLAGS, "model_type" },
 { "yolo","output shape [1, N*Cx*Cy*DetectionBox]",  0,   
AV_OPT_TYPE_CONST,   { .i64 = DDMT_YOLOV1V2 },0, 0, FLAGS, "model_type" 
},
 { "yolov3",  "outputs shape [1, N*D, Cx, Cy]",  0,   
AV_OPT_TYPE_CONST,   { .i64 = DDMT_YOLOV3 },  0, 0, FLAGS, "model_type" 
},
+{ "yolov4",  "outputs shape [1, N*D, Cx, Cy]",  0,   
AV_OPT_TYPE_CONST,   { .i64 = DDMT_YOLOV4 },0, 0, FLAGS, "model_type" },
 { "cell_w",  "cell width", OFFSET2(cell_w),  
AV_OPT_TYPE_INT,   { .i64 = 0 },0, INTMAX_MAX, FLAGS },
 { "cell_h",  "cell height",OFFSET2(cell_h),  
AV_OPT_TYPE_INT,   { .i64 = 0 },0, INTMAX_MAX, FLAGS },
 { "nb_classes",  "The number of class",OFFSET2(nb_classes),  
AV_OPT_TYPE_INT,   { .i64 = 0 },0, INTMAX_MAX, FLAGS },
@@ -84,6 +86,14 @@ static const AVOption dnn_detect_options[] = {
 
 AVFILTER_DEFINE_CLASS(dnn_detect);
 
+static inline float sigmoid(float x) {
+return 1.f / (1.f + exp(-x));
+}
+
+static inline float linear(float x) {
+return x;
+}
+
 static int dnn_detect_get_label_id(int nb_classes, int cell_size, float 
*label_data)
 {
 float max_prob = 0;
@@ -142,6 +152,8 @@ static int dnn_detect_parse_yolo_output(AVFrame *frame, 
DNNData *output, int out
 float *output_data = output[output_index].data;
 float *anchors = ctx->anchors;
 AVDetectionBBox *bbox;
+float (*post_process_raw_data)(float x);
+int is_NHWC = 0;
 
 if (ctx->model_type == DDMT_YOLOV1V2) {
 cell_w = ctx->cell_w;
@@ -149,13 +161,30 @@ static int dnn_detect_parse_yolo_output(AVFrame *frame, 
DNNData *output, int out
 scale_w = cell_w;
 scale_h = cell_h;
 } else {
-cell_w = output[output_index].width;
-cell_h = output[output_index].height;
+if (output[output_index].height != output[output_index].width &&
+output[output_index].height == output[output_index].channels) {
+is_NHWC = 1;
+cell_w = output[output_index].height;
+cell_h = output[output_index].channels;
+} else {
+cell_w = output[output_index].width;
+cell_h = output[output_index].height;
+}
 scale_w = ctx->scale_width;
 scale_h = ctx->scale_height;
 }
 box_size = nb_classes + 5;
 
+switch (ctx->model_type) {
+case DDMT_YOLOV1V2:
+case DDMT_YOLOV3:
+post_process_raw_data = linear;
+break;
+case DDMT_YOLOV4:
+post_process_raw_data = sigmoid;
+ break;
+}
+
 if (!cell_h || !cell_w) {
 av_log(filter_ctx, AV_LOG_ERROR, "cell_w and cell_h are detected\n");
 return AVERROR(EINVAL);
@@ -193,19 +222,36 @@ static int dnn_detect_parse_yolo_output(AVFrame *frame, 
DNNData *output, int out
 float *detection_boxes_data;
 int label_id;
 
-detection_boxes_data = output_data + box_id * box_size * 
cell_w * cell_h;
-conf = detection_boxes_data[cy * cell_w + cx + 4 * cell_w * 
cell_h];
+if (is_NHWC) {
+detection_boxes_data = output_data +
+((cy * cell_w + cx) * detection_boxes + box_id) * 
box_size;
+conf = post_process_raw_data(detection_boxes_data[4]);
+} else {
+detection_boxes_data = output_data + box_id * box_size * 
cell_w * cell_h;
+conf = post_process_raw_data(
+detection_boxes_data[cy * cell_w + cx + 4 * 
cell_w * cell_h]);
+}
 if (conf < conf_threshold) {
 continue;
 }
 
-x= detection_boxes_data[cy * cell_w + cx];
-y= detection_boxes_data[cy * cell_w + cx + cel

[FFmpeg-devel] [PATCH v2 1/4] libavfiter/dnn_backend_openvino: Add multiple output support

2023-12-11 Thread wenbin . chen-at-intel . com
From: Wenbin Chen 

Add multiple output support to openvino backend. You can use '&' to
split different output when you set output name using command line.

Signed-off-by: Wenbin Chen 
---
 libavfilter/dnn/dnn_backend_common.c   |   7 -
 libavfilter/dnn/dnn_backend_openvino.c | 216 +
 libavfilter/vf_dnn_detect.c|  11 +-
 3 files changed, 150 insertions(+), 84 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_common.c 
b/libavfilter/dnn/dnn_backend_common.c
index 91a4a3c4bf..632832ec36 100644
--- a/libavfilter/dnn/dnn_backend_common.c
+++ b/libavfilter/dnn/dnn_backend_common.c
@@ -43,13 +43,6 @@ int ff_check_exec_params(void *ctx, DNNBackendType backend, 
DNNFunctionType func
 return AVERROR(EINVAL);
 }
 
-if (exec_params->nb_output != 1 && backend != DNN_TF) {
-// currently, the filter does not need multiple outputs,
-// so we just pending the support until we really need it.
-avpriv_report_missing_feature(ctx, "multiple outputs");
-return AVERROR(ENOSYS);
-}
-
 return 0;
 }
 
diff --git a/libavfilter/dnn/dnn_backend_openvino.c 
b/libavfilter/dnn/dnn_backend_openvino.c
index 6fe8b9c243..089e028818 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -64,7 +64,7 @@ typedef struct OVModel{
 ov_compiled_model_t *compiled_model;
 ov_output_const_port_t* input_port;
 ov_preprocess_input_info_t* input_info;
-ov_output_const_port_t* output_port;
+ov_output_const_port_t** output_ports;
 ov_preprocess_output_info_t* output_info;
 ov_preprocess_prepostprocessor_t* preprocess;
 #else
@@ -77,6 +77,7 @@ typedef struct OVModel{
 SafeQueue *request_queue;   // holds OVRequestItem
 Queue *task_queue;  // holds TaskItem
 Queue *lltask_queue; // holds LastLevelTaskItem
+int nb_outputs;
 } OVModel;
 
 // one request for one call to openvino
@@ -349,7 +350,7 @@ static void infer_completion_callback(void *args)
 TaskItem *task = lltask->task;
 OVModel *ov_model = task->model;
 SafeQueue *requestq = ov_model->request_queue;
-DNNData output;
+DNNData *outputs;
 OVContext *ctx = &ov_model->ctx;
 #if HAVE_OPENVINO2
 size_t* dims;
@@ -358,45 +359,61 @@ static void infer_completion_callback(void *args)
 ov_shape_t output_shape = {0};
 ov_element_type_e precision;
 
-memset(&output, 0, sizeof(output));
-status = 
ov_infer_request_get_output_tensor_by_index(request->infer_request, 0, 
&output_tensor);
-if (status != OK) {
-av_log(ctx, AV_LOG_ERROR,
-   "Failed to get output tensor.");
+outputs = av_calloc(ov_model->nb_outputs, sizeof(*outputs));
+if (!outputs) {
+av_log(ctx, AV_LOG_ERROR, "Failed to alloc outputs.");
 return;
 }
 
-status = ov_tensor_data(output_tensor, &output.data);
-if (status != OK) {
-av_log(ctx, AV_LOG_ERROR,
-   "Failed to get output data.");
-return;
-}
+for (int i = 0; i < ov_model->nb_outputs; i++) {
+status = 
ov_infer_request_get_tensor_by_const_port(request->infer_request,
+   
ov_model->output_ports[i],
+   &output_tensor);
+if (status != OK) {
+av_log(ctx, AV_LOG_ERROR,
+"Failed to get output tensor.");
+goto end;
+}
 
-status = ov_tensor_get_shape(output_tensor, &output_shape);
-if (status != OK) {
-av_log(ctx, AV_LOG_ERROR, "Failed to get output port shape.\n");
-return;
-}
-dims = output_shape.dims;
+status = ov_tensor_data(output_tensor, &outputs[i].data);
+if (status != OK) {
+av_log(ctx, AV_LOG_ERROR,
+"Failed to get output data.");
+goto end;
+}
 
-status = ov_port_get_element_type(ov_model->output_port, &precision);
-if (status != OK) {
-av_log(ctx, AV_LOG_ERROR, "Failed to get output port data type.\n");
+status = ov_tensor_get_shape(output_tensor, &output_shape);
+if (status != OK) {
+av_log(ctx, AV_LOG_ERROR, "Failed to get output port shape.\n");
+goto end;
+}
+dims = output_shape.dims;
+
+status = ov_port_get_element_type(ov_model->output_ports[i], 
&precision);
+if (status != OK) {
+av_log(ctx, AV_LOG_ERROR, "Failed to get output port data 
type.\n");
+goto end;
+}
+outputs[i].dt   = precision_to_datatype(precision);
+
+outputs[i].channels = output_shape.rank > 2 ? dims[output_shape.rank - 
3] : 1;
+outputs[i].height   = output_shape.rank > 1 ? dims[output_shape.rank - 
2] : 1;
+outputs[i].width= output_shape.rank > 0 ? dims[output_shape.rank - 
1] : 1;
+av_assert0(request->lltask_count <= dims[0]);
+outputs[i].layou

[FFmpeg-devel] [PATCH v2 3/4] libavfilter/vf_dnn_detect: Add yolov3 support

2023-12-11 Thread wenbin . chen-at-intel . com
From: Wenbin Chen 

Add yolov3 support. The difference of yolov3 is that it has multiple
outputs in different scale to perform better on both large and small
object.

The model detail refer to: 
https://github.com/openvinotoolkit/open_model_zoo/tree/master/models/public/yolo-v3-tf

Signed-off-by: Wenbin Chen 
---
 libavfilter/vf_dnn_detect.c | 28 +++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_dnn_detect.c b/libavfilter/vf_dnn_detect.c
index 86f61c9907..7a32b191c3 100644
--- a/libavfilter/vf_dnn_detect.c
+++ b/libavfilter/vf_dnn_detect.c
@@ -35,6 +35,7 @@
 typedef enum {
 DDMT_SSD,
 DDMT_YOLOV1V2,
+DDMT_YOLOV3
 } DNNDetectionModelType;
 
 typedef struct DnnDetectContext {
@@ -73,6 +74,7 @@ static const AVOption dnn_detect_options[] = {
 { "model_type",  "DNN detection model type",   OFFSET2(model_type),  
AV_OPT_TYPE_INT,   { .i64 = DDMT_SSD },INT_MIN, INT_MAX, FLAGS, 
"model_type" },
 { "ssd", "output shape [1, 1, N, 7]",  0,
AV_OPT_TYPE_CONST,   { .i64 = DDMT_SSD },0, 0, FLAGS, "model_type" },
 { "yolo","output shape [1, N*Cx*Cy*DetectionBox]",  0,   
AV_OPT_TYPE_CONST,   { .i64 = DDMT_YOLOV1V2 },0, 0, FLAGS, "model_type" 
},
+{ "yolov3",  "outputs shape [1, N*D, Cx, Cy]",  0,   
AV_OPT_TYPE_CONST,   { .i64 = DDMT_YOLOV3 },  0, 0, FLAGS, "model_type" 
},
 { "cell_w",  "cell width", OFFSET2(cell_w),  
AV_OPT_TYPE_INT,   { .i64 = 0 },0, INTMAX_MAX, FLAGS },
 { "cell_h",  "cell height",OFFSET2(cell_h),  
AV_OPT_TYPE_INT,   { .i64 = 0 },0, INTMAX_MAX, FLAGS },
 { "nb_classes",  "The number of class",OFFSET2(nb_classes),  
AV_OPT_TYPE_INT,   { .i64 = 0 },0, INTMAX_MAX, FLAGS },
@@ -146,6 +148,11 @@ static int dnn_detect_parse_yolo_output(AVFrame *frame, 
DNNData *output, int out
 cell_h = ctx->cell_h;
 scale_w = cell_w;
 scale_h = cell_h;
+} else {
+cell_w = output[output_index].width;
+cell_h = output[output_index].height;
+scale_w = ctx->scale_width;
+scale_h = ctx->scale_height;
 }
 box_size = nb_classes + 5;
 
@@ -173,6 +180,7 @@ static int dnn_detect_parse_yolo_output(AVFrame *frame, 
DNNData *output, int out
   output[output_index].height *
   output[output_index].width / box_size / cell_w / cell_h;
 
+anchors = anchors + (detection_boxes * output_index * 2);
 /**
  * find all candidate bbox
  * yolo output can be reshaped to [B, N*D, Cx, Cy]
@@ -284,6 +292,21 @@ static int dnn_detect_post_proc_yolo(AVFrame *frame, 
DNNData *output, AVFilterCo
 return 0;
 }
 
+static int dnn_detect_post_proc_yolov3(AVFrame *frame, DNNData *output,
+   AVFilterContext *filter_ctx, int 
nb_outputs)
+{
+int ret = 0;
+for (int i = 0; i < nb_outputs; i++) {
+ret = dnn_detect_parse_yolo_output(frame, output, i, filter_ctx);
+if (ret < 0)
+return ret;
+}
+ret = dnn_detect_fill_side_data(frame, filter_ctx);
+if (ret < 0)
+return ret;
+return 0;
+}
+
 static int dnn_detect_post_proc_ssd(AVFrame *frame, DNNData *output, 
AVFilterContext *filter_ctx)
 {
 DnnDetectContext *ctx = filter_ctx->priv;
@@ -380,8 +403,11 @@ static int dnn_detect_post_proc_ov(AVFrame *frame, DNNData 
*output, int nb_outpu
 ret = dnn_detect_post_proc_yolo(frame, output, filter_ctx);
 if (ret < 0)
 return ret;
+case DDMT_YOLOV3:
+ret = dnn_detect_post_proc_yolov3(frame, output, filter_ctx, 
nb_outputs);
+if (ret < 0)
+return ret;
 }
-
 return 0;
 }
 
-- 
2.34.1

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

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


Re: [FFmpeg-devel] [PATCH 01/35] avcodec/proresenc_kostya: remove an unnecessary parenthesis level in MAKE_CODE() macro

2023-12-11 Thread Stefano Sabatini
On date Monday 2023-12-11 02:35:02 +0100, Clément Bœsch wrote:
> ---
>  libavcodec/proresenc_kostya.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
> index 52fe5639b1..58fc340879 100644
> --- a/libavcodec/proresenc_kostya.c
> +++ b/libavcodec/proresenc_kostya.c
> @@ -429,7 +429,7 @@ static inline void encode_vlc_codeword(PutBitContext *pb, 
> unsigned codebook, int
>  }
>  
>  #define GET_SIGN(x)  ((x) >> 31)
> -#define MAKE_CODE(x) x)) * 2) ^ GET_SIGN(x))
> +#define MAKE_CODE(x) (((x) * 2) ^ GET_SIGN(x))

LGTM.
___
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 02/35] avcodec/proresenc_kostya: remove unused plane factor variables

2023-12-11 Thread Stefano Sabatini
On date Monday 2023-12-11 02:35:03 +0100, Clément Bœsch wrote:
> ---
>  libavcodec/proresenc_kostya.c | 36 ---
>  1 file changed, 12 insertions(+), 24 deletions(-)
> 
> diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
> index 58fc340879..7aed3974c3 100644
> --- a/libavcodec/proresenc_kostya.c
> +++ b/libavcodec/proresenc_kostya.c
> @@ -459,7 +459,6 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
>  
>  static void encode_acs(PutBitContext *pb, int16_t *blocks,
> int blocks_per_slice,
> -   int plane_size_factor,
> const uint8_t *scan, const int16_t *qmat)
>  {
>  int idx, i;
> @@ -494,14 +493,13 @@ static void encode_acs(PutBitContext *pb, int16_t 
> *blocks,
>  static void encode_slice_plane(ProresContext *ctx, PutBitContext *pb,
>const uint16_t *src, ptrdiff_t linesize,
>int mbs_per_slice, int16_t *blocks,
> -  int blocks_per_mb, int plane_size_factor,
> +  int blocks_per_mb,
>const int16_t *qmat)
>  {
>  int blocks_per_slice = mbs_per_slice * blocks_per_mb;
>  
>  encode_dcs(pb, blocks, blocks_per_slice, qmat[0]);
> -encode_acs(pb, blocks, blocks_per_slice, plane_size_factor,
> -   ctx->scantable, qmat);
> +encode_acs(pb, blocks, blocks_per_slice, ctx->scantable, qmat);
>  }
>  
>  static void put_alpha_diff(PutBitContext *pb, int cur, int prev, int abits)
> @@ -575,10 +573,9 @@ static int encode_slice(AVCodecContext *avctx, const 
> AVFrame *pic,
>  int i, xp, yp;
>  int total_size = 0;
>  const uint16_t *src;
> -int slice_width_factor = av_log2(mbs_per_slice);
>  int num_cblocks, pwidth, line_add;
>  ptrdiff_t linesize;
> -int plane_factor, is_chroma;
> +int is_chroma;
>  uint16_t *qmat;
>  uint16_t *qmat_chroma;
>  
> @@ -604,9 +601,6 @@ static int encode_slice(AVCodecContext *avctx, const 
> AVFrame *pic,
>  
>  for (i = 0; i < ctx->num_planes; i++) {
>  is_chroma= (i == 1 || i == 2);
> -plane_factor = slice_width_factor + 2;
> -if (is_chroma)
> -plane_factor += ctx->chroma_factor - 3;
>  if (!is_chroma || ctx->chroma_factor == CFACTOR_Y444) {
>  xp  = x << 4;
>  yp  = y << 4;
> @@ -631,11 +625,11 @@ static int encode_slice(AVCodecContext *avctx, const 
> AVFrame *pic,
>  if (!is_chroma) {/* luma quant */
>  encode_slice_plane(ctx, pb, src, linesize,
> mbs_per_slice, ctx->blocks[0],
> -   num_cblocks, plane_factor, qmat);
> +   num_cblocks, qmat);
>  } else { /* chroma plane */
>  encode_slice_plane(ctx, pb, src, linesize,
> mbs_per_slice, ctx->blocks[0],
> -   num_cblocks, plane_factor, qmat_chroma);
> +   num_cblocks, qmat_chroma);
>  }
>  } else {
>  get_alpha_data(ctx, src, linesize, xp, yp,
> @@ -704,7 +698,6 @@ static int estimate_dcs(int *error, int16_t *blocks, int 
> blocks_per_slice,
>  }
>  
>  static int estimate_acs(int *error, int16_t *blocks, int blocks_per_slice,
> -int plane_size_factor,
>  const uint8_t *scan, const int16_t *qmat)
>  {
>  int idx, i;
> @@ -742,7 +735,7 @@ static int estimate_acs(int *error, int16_t *blocks, int 
> blocks_per_slice,
>  static int estimate_slice_plane(ProresContext *ctx, int *error, int plane,
>  const uint16_t *src, ptrdiff_t linesize,
>  int mbs_per_slice,
> -int blocks_per_mb, int plane_size_factor,
> +int blocks_per_mb,
>  const int16_t *qmat, ProresThreadData *td)
>  {
>  int blocks_per_slice;
> @@ -751,8 +744,7 @@ static int estimate_slice_plane(ProresContext *ctx, int 
> *error, int plane,
>  blocks_per_slice = mbs_per_slice * blocks_per_mb;
>  
>  bits  = estimate_dcs(error, td->blocks[plane], blocks_per_slice, 
> qmat[0]);
> -bits += estimate_acs(error, td->blocks[plane], blocks_per_slice,
> - plane_size_factor, ctx->scantable, qmat);
> +bits += estimate_acs(error, td->blocks[plane], blocks_per_slice, 
> ctx->scantable, qmat);
>  
>  return FFALIGN(bits, 8);
>  }
> @@ -821,9 +813,8 @@ static int find_slice_quant(AVCodecContext *avctx,
>  ProresContext *ctx = avctx->priv_data;
>  int i, q, pq, xp, yp;
>  const uint16_t *src;
> -int slice_width_factor = av_log2(mbs_per_slice);
>  int num_cblocks[MAX_PLANES], pwidth;
> -int plane_factor

Re: [FFmpeg-devel] [PATCH 03/35] avcodec/proresenc_kostya: remove redundant codebook assignments

2023-12-11 Thread Stefano Sabatini
On date Monday 2023-12-11 02:35:04 +0100, Clément Bœsch wrote:
> This is already assigned at declaration.
> ---
>  libavcodec/proresenc_kostya.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
> index 7aed3974c3..6e1d5a0cef 100644
> --- a/libavcodec/proresenc_kostya.c
> +++ b/libavcodec/proresenc_kostya.c
> @@ -440,7 +440,6 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
>  prev_dc = (blocks[0] - 0x4000) / scale;
>  encode_vlc_codeword(pb, FIRST_DC_CB, MAKE_CODE(prev_dc));
>  sign = 0;
> -codebook = 3;
>  blocks  += 64;
>  
>  for (i = 1; i < blocks_per_slice; i++, blocks += 64) {
> @@ -676,7 +675,6 @@ static int estimate_dcs(int *error, int16_t *blocks, int 
> blocks_per_slice,
>  prev_dc  = (blocks[0] - 0x4000) / scale;
>  bits = estimate_vlc(FIRST_DC_CB, MAKE_CODE(prev_dc));
>  sign = 0;
> -codebook = 3;
>  blocks  += 64;
>  *error  += FFABS(blocks[0] - 0x4000) % scale;

Since this is the only value assigned with declaration, maybe it's
better to drop the codebook = 3 in the assignment, but LGTM anyway.
___
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 04/35] avcodec/proresenc_anatoliy: move run/lev to codebook LUT to shared proresdata

2023-12-11 Thread Stefano Sabatini
On date Monday 2023-12-11 02:35:05 +0100, Clément Bœsch wrote:
> This is going to be shared with proresenc_kostya in the upcoming commit.
> ---
>  libavcodec/proresdata.c | 6 ++
>  libavcodec/proresdata.h | 2 ++
>  libavcodec/proresenc_anatoliy.c | 9 ++---
>  3 files changed, 10 insertions(+), 7 deletions(-)

LGTM.
___
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 0/3] Initial support for fragmented TTML muxing

2023-12-11 Thread Jan Ekström
Changes compared to v2:

* General rebase.
* Limited the test to the first overlapping lines that
  finish at around 24.5 seconds. This brings us down to 430 lines
  per test (of which there are two).
* Switched from the rawvideo to the data muxer.

This enables pushing TTML together with another track (usually video)
as part of CMAF Ingest, as defined by the DASH-IF Live Media Ingest
Protocol.

Currently does not function well with just the subtitle track unless
the API user explicitly requests fragmentation with a nullptr packet,
as the generic fragmentation decision logic is based on tracks which
do not require squashing.

Currently does support overlapping subtitles, but the implementation
utilizes another packet queue for it, which is probably not optimal.
Recommendations on how to improve things are welcome.

Jan

Jan Ekström (3):
  tests/fate-run: add support for specifying the final encode muxer in
`transcode`
  avcodec/avpacket: add functionality to prepend to AVPacketLists
  avformat/movenc: add support for fragmented TTML muxing

 libavcodec/avpacket.c   |  20 +-
 libavcodec/packet_internal.h|   2 +
 libavformat/movenc.c|   9 -
 libavformat/movenc_ttml.c   | 157 ++-
 tests/fate-run.sh   |   4 +-
 tests/fate/mov.mak  |  21 +
 tests/ref/fate/mov-mp4-fragmented-ttml-dfxp | 430 
 tests/ref/fate/mov-mp4-fragmented-ttml-stpp | 430 
 8 files changed, 1054 insertions(+), 19 deletions(-)
 create mode 100644 tests/ref/fate/mov-mp4-fragmented-ttml-dfxp
 create mode 100644 tests/ref/fate/mov-mp4-fragmented-ttml-stpp

-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH v3 1/3] tests/fate-run: add support for specifying the final encode muxer in `transcode`

2023-12-11 Thread Jan Ekström
From: Jan Ekström 

This allows for direct dumping of the packets' contents (useful for
text based formats), while getting the timestamps/sizes etc from
ffprobe.

If used via TRANSCODE, the actually utilized muxer should be added
within the last argument as an additional dependency, as that is not
done automatically.

Signed-off-by: Jan Ekström 
---
 tests/fate-run.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tests/fate-run.sh b/tests/fate-run.sh
index 8efb1586b8..73c4d16f21 100755
--- a/tests/fate-run.sh
+++ b/tests/fate-run.sh
@@ -257,7 +257,9 @@ transcode(){
 additional_input=$7
 final_decode=$8
 enc_opt_in=$9
+final_encode_muxer="${10}"
 test -z "$additional_input" || additional_input="$DEC_OPTS 
$additional_input"
+test -z "$final_encode_muxer" && final_encode_muxer="framecrc"
 encfile="${outdir}/${test}.${enc_fmt}"
 test $keep -ge 1 || cleanfiles="$cleanfiles $encfile"
 tsrcfile=$(target_path $srcfile)
@@ -267,7 +269,7 @@ transcode(){
 do_md5sum $encfile
 echo $(wc -c $encfile)
 ffmpeg $DEC_OPTS $final_decode -i $tencfile $ENC_OPTS $FLAGS $final_encode 
\
--f framecrc - || return
+-f $final_encode_muxer - || return
 test -z $ffprobe_opts || \
 run ffprobe${PROGSUF}${EXECSUF} -bitexact $ffprobe_opts $tencfile || 
return
 }
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH v3 2/3] avcodec/avpacket: add functionality to prepend to AVPacketLists

2023-12-11 Thread Jan Ekström
From: Jan Ekström 

Signed-off-by: Jan Ekström 
---
 libavcodec/avpacket.c| 20 +++-
 libavcodec/packet_internal.h |  2 ++
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index e29725c2d2..e223ab63ef 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -540,6 +540,7 @@ int avpriv_packet_list_put(PacketList *packet_buffer,
int flags)
 {
 PacketListEntry *pktl = av_malloc(sizeof(*pktl));
+unsigned int update_end_point = 1;
 int ret;
 
 if (!pktl)
@@ -563,13 +564,22 @@ int avpriv_packet_list_put(PacketList *packet_buffer,
 
 pktl->next = NULL;
 
-if (packet_buffer->head)
-packet_buffer->tail->next = pktl;
-else
+if (packet_buffer->head) {
+if (flags & FF_PACKETLIST_FLAG_PREPEND) {
+pktl->next = packet_buffer->head;
+packet_buffer->head = pktl;
+update_end_point = 0;
+} else {
+packet_buffer->tail->next = pktl;
+}
+} else
 packet_buffer->head = pktl;
 
-/* Add the packet in the buffered packet list. */
-packet_buffer->tail = pktl;
+if (update_end_point) {
+/* Add the packet in the buffered packet list. */
+packet_buffer->tail = pktl;
+}
+
 return 0;
 }
 
diff --git a/libavcodec/packet_internal.h b/libavcodec/packet_internal.h
index 52fa6d9be9..9c0f4fead5 100644
--- a/libavcodec/packet_internal.h
+++ b/libavcodec/packet_internal.h
@@ -34,6 +34,8 @@ typedef struct PacketList {
 PacketListEntry *head, *tail;
 } PacketList;
 
+#define FF_PACKETLIST_FLAG_PREPEND (1 << 0) /**< Prepend created AVPacketList 
instead of appending */
+
 /**
  * Append an AVPacket to the list.
  *
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH v3 3/3] avformat/movenc: add support for fragmented TTML muxing

2023-12-11 Thread Jan Ekström
From: Jan Ekström 

Attempts to base the fragmentation timing on other streams
as most receivers expect media fragments to be more or less
aligned.

Currently does not support fragmentation on subtitle track
only, as the subtitle packet queue timings would have to be
checked in addition to the current fragmentation timing logic.

Signed-off-by: Jan Ekström 
---
 libavformat/movenc.c|   9 -
 libavformat/movenc_ttml.c   | 157 ++-
 tests/fate/mov.mak  |  21 +
 tests/ref/fate/mov-mp4-fragmented-ttml-dfxp | 430 
 tests/ref/fate/mov-mp4-fragmented-ttml-stpp | 430 
 5 files changed, 1034 insertions(+), 13 deletions(-)
 create mode 100644 tests/ref/fate/mov-mp4-fragmented-ttml-dfxp
 create mode 100644 tests/ref/fate/mov-mp4-fragmented-ttml-stpp

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index e39f1ac987..0b0006fd93 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -7324,15 +7324,6 @@ static int mov_init(AVFormatContext *s)
 track->squash_fragment_samples_to_one =
 ff_is_ttml_stream_paragraph_based(track->par);
 
-if (mov->flags & FF_MOV_FLAG_FRAGMENT &&
-track->squash_fragment_samples_to_one) {
-av_log(s, AV_LOG_ERROR,
-   "Fragmentation is not currently supported for "
-   "TTML in MP4/ISMV (track synchronization between "
-   "subtitles and other media is not yet 
implemented)!\n");
-return AVERROR_PATCHWELCOME;
-}
-
 if (track->mode != MODE_ISM &&
 track->par->codec_tag == MOV_ISMV_TTML_TAG &&
 s->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) {
diff --git a/libavformat/movenc_ttml.c b/libavformat/movenc_ttml.c
index 6deae49657..2aefb0b6c3 100644
--- a/libavformat/movenc_ttml.c
+++ b/libavformat/movenc_ttml.c
@@ -54,6 +54,50 @@ static int mov_init_ttml_writer(MOVTrack *track, 
AVFormatContext **out_ctx)
 return 0;
 }
 
+static void mov_calculate_start_and_end_of_other_tracks(
+AVFormatContext *s, MOVTrack *track, int64_t *start_pts, int64_t *end_pts)
+{
+MOVMuxContext *mov = s->priv_data;
+
+// Initialize at the end of the previous document/fragment, which is NOPTS
+// until the first fragment is created.
+int64_t max_track_end_dts = *start_pts = track->end_pts;
+
+for (unsigned int i = 0; i < s->nb_streams; i++) {
+MOVTrack *other_track = &mov->tracks[i];
+
+// Skip our own track, any other track that needs squashing,
+// or any track which still has its start_dts at NOPTS or
+// any track that did not yet get any packets.
+if (track == other_track ||
+other_track->squash_fragment_samples_to_one ||
+other_track->start_dts == AV_NOPTS_VALUE ||
+!other_track->entry) {
+continue;
+}
+
+{
+int64_t picked_start = 
av_rescale_q_rnd(other_track->cluster[0].dts + other_track->cluster[0].cts,
+other_track->st->time_base,
+track->st->time_base,
+AV_ROUND_NEAR_INF | 
AV_ROUND_PASS_MINMAX);
+int64_t picked_end   = av_rescale_q_rnd(other_track->end_pts,
+other_track->st->time_base,
+track->st->time_base,
+AV_ROUND_NEAR_INF | 
AV_ROUND_PASS_MINMAX);
+
+if (*start_pts == AV_NOPTS_VALUE)
+*start_pts = picked_start;
+else if (picked_start >= track->end_pts)
+*start_pts = FFMIN(*start_pts, picked_start);
+
+max_track_end_dts = FFMAX(max_track_end_dts, picked_end);
+}
+}
+
+*end_pts = max_track_end_dts;
+}
+
 static int mov_write_ttml_document_from_queue(AVFormatContext *s,
   AVFormatContext *ttml_ctx,
   MOVTrack *track,
@@ -65,13 +109,85 @@ static int 
mov_write_ttml_document_from_queue(AVFormatContext *s,
 int64_t start_ts = track->start_dts == AV_NOPTS_VALUE ?
0 : (track->start_dts + track->track_duration);
 int64_t end_ts   = start_ts;
+unsigned int time_limited = 0;
+PacketList back_to_queue_list = { 0 };
+
+if (*out_start_ts != AV_NOPTS_VALUE) {
+// we have non-nopts values here, thus we have been given a time range
+time_limited = 1;
+start_ts = *out_start_ts;
+end_ts   = *out_start_ts + *out_duration;
+}
 
 if ((ret = avformat_write_header(ttml_ctx, NULL)) < 0) {
 return ret;
 }
 
 while (!avpriv_packet_l

Re: [FFmpeg-devel] [PATCH 1/3] swscale: don't assign range converters for float

2023-12-11 Thread Chen, Wenbin
> > > From: Niklas Haas 
> > >
> > > This logic was incongruent with logic used elsewhere, where floating
> > > point formats are explicitly exempted from range conversion. Fixes an
> > > issue where floating point formats were not going through special
> > > unscaled converters even when it was otherwise possible.
> > > ---
> > >  libswscale/swscale.c | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/libswscale/swscale.c b/libswscale/swscale.c
> > > index 46ba68fe6a..a66db22767 100644
> > > --- a/libswscale/swscale.c
> > > +++ b/libswscale/swscale.c
> > > @@ -534,7 +534,8 @@ av_cold void
> ff_sws_init_range_convert(SwsContext
> > > *c)
> > >  {
> > >  c->lumConvertRange = NULL;
> > >  c->chrConvertRange = NULL;
> > > -if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) {
> > > +if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat) &&
> > > +!isFloat(c->srcFormat) && !isFloat(c->dstFormat)) {
> > >  if (c->dstBpc <= 14) {
> > >  if (c->srcRange) {
> > >  c->lumConvertRange = lumRangeFromJpeg_c;
> > > --
> > > 2.42.0
> > >
> >
> > This patchset works for me. Thanks for your quick fixing.
> 
> Ping. When can this patchset be merged?
> 
> Thanks
> Wenbin

Anyone who can help to merge this patchset?

Thanks
Wenbin

> >
> > > ___
> > > ffmpeg-devel mailing list
> > > ffmpeg-devel@ffmpeg.org
> > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > >
> > > To unsubscribe, visit link above, or email
> > > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel 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".