Re: [FFmpeg-devel] [PATCH] avformat/movenc: fixed fmp4 packets containing incorrect flags after transcoding

2023-04-22 Thread Steven Liu
<1035567...@qq.com> 于2023年4月10日周一 20:43写道:
>
> From: Wang Yaqiang 
>
> When write multi-trun box, the MOV_TRUN_FIRST_SAMPLE_FLAGS flag
> need judge by first param, not 0.
> If the original video contains consecutive I frames,
> this will cause the packets of fmp4 have error sample_flags ,
> and then incorrect keyframes were generated,
> and then error packet will be seeked.
>
> Signed-off-by: Wang Yaqiang 
> ---
>  libavformat/movenc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index c370922c7d..946e79c5ac 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -4858,8 +4858,8 @@ static int mov_write_trun_tag(AVIOContext *pb, 
> MOVMuxContext *mov,
>  if (i > first && get_sample_flags(track, >cluster[i]) != 
> track->default_sample_flags)
>  flags |= MOV_TRUN_SAMPLE_FLAGS;
>  }
> -if (!(flags & MOV_TRUN_SAMPLE_FLAGS) && track->entry > 0 &&
> - get_sample_flags(track, >cluster[0]) != 
> track->default_sample_flags)
> +if (!(flags & MOV_TRUN_SAMPLE_FLAGS) && track->entry > first &&
> + get_sample_flags(track, >cluster[first]) != 
> track->default_sample_flags)
>  flags |= MOV_TRUN_FIRST_SAMPLE_FLAGS;
>  if (track->flags & MOV_TRACK_CTTS)
>  flags |= MOV_TRUN_SAMPLE_CTS;
> --
> 2.39.2
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Test ok here.


Thanks
Steven
___
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] MXF - Add jpeg2000 subdescriptor - Sponsored by INA

2023-04-22 Thread Pierre-Anthony Lemieux
On Wed, Mar 29, 2023 at 1:54 PM Cédric Le Barz  wrote:
>
> Add jpeg2000 subdescriptor in MXF file.
>
> Signed-off-by: Cedric Le Barz 
> ---
>   ffmpeg/libavformat/mxf.h|  1 +
>   ffmpeg/libavformat/mxfenc.c | 74 -
>   2 files changed, 74 insertions(+), 1 deletion(-)
>
> diff --git a/ffmpeg/libavformat/mxf.h b/ffmpeg/libavformat/mxf.h
> index 2561605..7dd1681 100644
> --- a/ffmpeg/libavformat/mxf.h
> +++ b/ffmpeg/libavformat/mxf.h
> @@ -55,6 +55,7 @@ enum MXFMetadataSetType {
>   SoundfieldGroupLabelSubDescriptor,
>   GroupOfSoundfieldGroupsLabelSubDescriptor,
>   FFV1SubDescriptor,
> +JPEG2000SubDescriptor,
>   };
>enum MXFFrameLayout {
> diff --git a/ffmpeg/libavformat/mxfenc.c b/ffmpeg/libavformat/mxfenc.c
> index a29d678..3bdf90a 100644
> --- a/ffmpeg/libavformat/mxfenc.c
> +++ b/ffmpeg/libavformat/mxfenc.c
> @@ -390,6 +390,20 @@ static const MXFLocalTagPair mxf_local_tag_batch[] = {
>   { 0x8302, FF_MXF_MasteringDisplayWhitePointChromaticity },
>   { 0x8303, FF_MXF_MasteringDisplayMaximumLuminance },
>   { 0x8304, FF_MXF_MasteringDisplayMinimumLuminance },
> +// ff_mxf_jpeg2000_local_tags
> +{ 0x8400,
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x09,0x06,0x01,0x01,0x04,0x06,0x10,0x00,0x00}},
> /* Sub Descriptors / Opt Ordered array of strong references to sub
> descriptor sets */
> +{ 0x8401,
> {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x01,0x00,0x00,0x00}},
> /* 2 bytes : An enumerated value that defines the decoder capabilities.  */

Please add to the comment the symbol and type of the attribute as
specified in the SMPTE registers [1]  -- it makes it easier to
review/debug.

In the case above, it would be Riz (UInt16).

[1] https://registry.smpte-ra.org/view/published/elements_by_group_view.html

> +{ 0x8402,
> {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x02,0x00,0x00,0x00}},
> /* 4 bytes : Width of the reference grid */
> +{ 0x8403,
> {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x03,0x00,0x00,0x00}},
> /* 4 bytes : Height of the reference grid */
> +{ 0x8404,
> {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x04,0x00,0x00,0x00}},
> /* 4 bytes : Horizontal offset from the origin of the reference grid to
> the left side of the image area */
> +{ 0x8405,
> {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x05,0x00,0x00,0x00}},
> /* 4 bytes : Vertical offset from the origin of the reference grid to
> the left side of the image area */
> +{ 0x8406,
> {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x06,0x00,0x00,0x00}},
> /* 4 bytes : Width of one reference tile with respect to the reference
> grid, */
> +{ 0x8407,
> {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x07,0x00,0x00,0x00}},
> /* 4 bytes : Height of one reference tile with respect to the reference
> grid, */
> +{ 0x8408,
> {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x08,0x00,0x00,0x00}},
> /* 4 bytes : Horizontal offset from the origin of the reference grid to
> the left side of the first tile */
> +{ 0x8409,
> {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x09,0x00,0x00,0x00}},
> /* 4 bytes : Vertical offset from the origin of the reference grid to
> the left side of the first tile */
> +{ 0x840A,
> {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x0A,0x00,0x00,0x00}},
> /* 2 bytes : The number of components in the picture */
> +{ 0x840B,
> {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x0B,0x00,0x00,0x00}},
> /* 8+3n bytes : Array of picture components where each component
> comprises 3 bytes named Ssizi, XRSizi, YRSizi  The array of 3-byte
> groups is preceded by the array header comprising a 4-byte value of the
> number of components followed by a 4-byte value of 3. */
> +{ 0x840C,
> {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x0E,0x00,0x00,0x00}},
> /* The nature and order of the image components in the compressed domain
> as carried in the J2C codestream.. */
>   };
>#define MXF_NUM_TAGS FF_ARRAY_ELEMS(mxf_local_tag_batch)
> @@ -1095,8 +1109,8 @@ static const UID mxf_wav_descriptor_key   = {
> 0x06,0x0E,0x2B,0x34,0x02,0x53,
>   static const UID mxf_aes3_descriptor_key  = {
> 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x47,0x00
> };
>   static const UID mxf_cdci_descriptor_key  = {
> 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0D,0x01,0x01,0x01,0x01,0x01,0x28,0x00
> };
>   static const UID mxf_generic_sound_descriptor_key = {
> 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0D,0x01,0x01,0x01,0x01,0x01,0x42,0x00
> };
> -
>   static const UID mxf_avc_subdescriptor_key = {
> 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x6E,0x00
> };
> +static const UID mxf_jpeg2000_subdescriptor_key   = {
> 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0D,0x01,0x01,0x01,0x01,0x01,0x5A,00
> };
>

[FFmpeg-devel] [PATCH] avcodec/bonk: Avoid undefined integer overflow in predictor_calc_error()

2023-04-22 Thread Michael Niedermayer
Fixes: signed integer overflow: -159584 * 5105950 cannot be represented in type 
'int'
Fixes: 
55165/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BONK_fuzzer-5796023719297024

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

diff --git a/libavcodec/bonk.c b/libavcodec/bonk.c
index 5f510e49103..f2baa9c9315 100644
--- a/libavcodec/bonk.c
+++ b/libavcodec/bonk.c
@@ -265,14 +265,14 @@ static inline int shift(int a, int b)
 
 static int predictor_calc_error(int *k, int *state, int order, int error)
 {
-int i, x = error - shift_down(k[order-1] * state[order-1], LATTICE_SHIFT);
+int i, x = error - shift_down(k[order-1] * (unsigned)state[order-1], 
LATTICE_SHIFT);
 int *k_ptr = &(k[order-2]),
 *state_ptr = &(state[order-2]);
 
 for (i = order-2; i >= 0; i--, k_ptr--, state_ptr--) {
 unsigned k_value = *k_ptr, state_value = *state_ptr;
 
-x -= shift_down(k_value * state_value, LATTICE_SHIFT);
+x -= shift_down(k_value * (unsigned)state_value, LATTICE_SHIFT);
 state_ptr[1] = state_value + shift_down(k_value * x, LATTICE_SHIFT);
 }
 
-- 
2.17.1

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

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


Re: [FFmpeg-devel] [PATCH] avcodec/vorbisdec: Check codebook float values to be finite

2023-04-22 Thread Michael Niedermayer
On Mon, Feb 13, 2023 at 01:33:30AM +0100, Michael Niedermayer wrote:
> Fixes: Timeout
> Fixes: 
> 55116/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VORBIS_fuzzer-4572159970508800
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/vorbisdec.c | 4 
>  1 file changed, 4 insertions(+)

will apply

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

Take away the freedom of one citizen and you will be jailed, take away
the freedom of all citizens and you will be congratulated by your peers
in Parliament.


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

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


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/g2meet: Replace fake allocation avoidance for framebuf

2023-04-22 Thread Michael Niedermayer
On Wed, Jan 25, 2023 at 12:42:53AM +0100, Michael Niedermayer wrote:
> framebuf is only allocated when the new width/height are larger than the old
> but nothing sets the old so its always allocated.
> Use av_fast_mallocz() instead.
> 
> Fixes: Timeout
> Fixes: 
> 55094/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_G2M_fuzzer-5116909932904448
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/g2meet.c | 19 ++-
>  1 file changed, 10 insertions(+), 9 deletions(-)

will apply patchset

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

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.


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 2/2] avutil/tx_priv: Use unsigned in BF() to avoid signed overflows

2023-04-22 Thread Michael Niedermayer
On Sun, Jan 22, 2023 at 01:02:22AM +0100, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 100183269 - -2132769113 cannot be represented 
> in type 'int'
> Fixes: 
> 55063/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_FIXED_fuzzer-5039294027005952
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavutil/tx_priv.h | 14 ++
>  1 file changed, 10 insertions(+), 4 deletions(-)

will apply

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

You can kill me, but you cannot change the truth.


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

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


[FFmpeg-devel] [PATCH] avfilter: add audio rls filter

2023-04-22 Thread Paul B Mahol
Attached.
From cda21a1e12c8dbc5dbf39556cec26b3e255184ec Mon Sep 17 00:00:00 2001
From: Paul B Mahol 
Date: Sun, 16 Apr 2023 18:53:07 +0200
Subject: [PATCH] avfilter: add arls filter

Signed-off-by: Paul B Mahol 
---
 libavfilter/Makefile |   1 +
 libavfilter/af_arls.c| 353 +++
 libavfilter/allfilters.c |   1 +
 3 files changed, 355 insertions(+)
 create mode 100644 libavfilter/af_arls.c

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index cfb3104d43..c463f45689 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -90,6 +90,7 @@ OBJS-$(CONFIG_APULSATOR_FILTER)  += af_apulsator.o
 OBJS-$(CONFIG_AREALTIME_FILTER)  += f_realtime.o
 OBJS-$(CONFIG_ARESAMPLE_FILTER)  += af_aresample.o
 OBJS-$(CONFIG_AREVERSE_FILTER)   += f_reverse.o
+OBJS-$(CONFIG_ARLS_FILTER)   += af_arls.o
 OBJS-$(CONFIG_ARNNDN_FILTER) += af_arnndn.o
 OBJS-$(CONFIG_ASDR_FILTER)   += af_asdr.o
 OBJS-$(CONFIG_ASEGMENT_FILTER)   += f_segment.o
diff --git a/libavfilter/af_arls.c b/libavfilter/af_arls.c
new file mode 100644
index 00..1d91954c02
--- /dev/null
+++ b/libavfilter/af_arls.c
@@ -0,0 +1,353 @@
+/*
+ * Copyright (c) 2023 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/common.h"
+#include "libavutil/float_dsp.h"
+#include "libavutil/opt.h"
+
+#include "audio.h"
+#include "avfilter.h"
+#include "formats.h"
+#include "filters.h"
+#include "internal.h"
+
+enum OutModes {
+IN_MODE,
+DESIRED_MODE,
+OUT_MODE,
+NOISE_MODE,
+NB_OMODES
+};
+
+typedef struct AudioRLSContext {
+const AVClass *class;
+
+int order;
+float lambda;
+float delta;
+int output_mode;
+
+int kernel_size;
+AVFrame *offset;
+AVFrame *delay;
+AVFrame *coeffs;
+AVFrame *p, *dp;
+AVFrame *gains;
+AVFrame *u, *tmp;
+
+AVFrame *frame[2];
+
+AVFloatDSPContext *fdsp;
+} AudioRLSContext;
+
+#define OFFSET(x) offsetof(AudioRLSContext, x)
+#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
+#define AT AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
+
+static const AVOption arls_options[] = {
+{ "order","set the filter order",  OFFSET(order),  AV_OPT_TYPE_INT,   {.i64=16}, 1, INT16_MAX, A },
+{ "lambda",   "set the filter lambda", OFFSET(lambda), AV_OPT_TYPE_FLOAT, {.dbl=1.f}, 0, 1, AT },
+{ "delta","set the filter delta",  OFFSET(delta),  AV_OPT_TYPE_FLOAT, {.dbl=2.f}, 0, INT16_MAX, A },
+{ "out_mode", "set output mode",   OFFSET(output_mode), AV_OPT_TYPE_INT, {.i64=OUT_MODE}, 0, NB_OMODES-1, AT, "mode" },
+{  "i", "input",   0, AV_OPT_TYPE_CONST, {.i64=IN_MODE},  0, 0, AT, "mode" },
+{  "d", "desired", 0, AV_OPT_TYPE_CONST, {.i64=DESIRED_MODE}, 0, 0, AT, "mode" },
+{  "o", "output",  0, AV_OPT_TYPE_CONST, {.i64=OUT_MODE}, 0, 0, AT, "mode" },
+{  "n", "noise",   0, AV_OPT_TYPE_CONST, {.i64=NOISE_MODE},   0, 0, AT, "mode" },
+{ NULL }
+};
+
+AVFILTER_DEFINE_CLASS(arls);
+
+static float fir_sample(AudioRLSContext *s, float sample, float *delay,
+float *coeffs, float *tmp, int *offset)
+{
+const int order = s->order;
+float output;
+
+delay[*offset] = sample;
+
+memcpy(tmp, coeffs + order - *offset, order * sizeof(float));
+
+output = s->fdsp->scalarproduct_float(delay, tmp, s->kernel_size);
+
+if (--(*offset) < 0)
+*offset = order - 1;
+
+return output;
+}
+
+static float process_sample(AudioRLSContext *s, float input, float desired, int ch)
+{
+float *coeffs = (float *)s->coeffs->extended_data[ch];
+float *delay = (float *)s->delay->extended_data[ch];
+float *gains = (float *)s->gains->extended_data[ch];
+float *tmp = (float *)s->tmp->extended_data[ch];
+float *u = (float *)s->u->extended_data[ch];
+float *p = (float *)s->p->extended_data[ch];
+float *dp = (float *)s->dp->extended_data[ch];
+int *offsetp = (int *)s->offset->extended_data[ch];
+const int kernel_size = s->kernel_size;
+const int order = s->order;
+const float lambda = s->lambda;
+int offset = *offsetp;
+float g = 

[FFmpeg-devel] [PATCH] Add support for flac in-stream metadata.

2023-04-22 Thread toots
From: Romain Beauxis 

This patch adds support for in-stream metadata updates in the ogg/flac parser.

Code for detecting metadata frame is based on libavcodec/flacdec.c, code for
handling comment update is based on libavformat/oggparsevorbis.c.

This has been successfully tested locally. To reproduce:
* Setup an ogg/flac icecast stream.
* Read the stream
* Check the associated AVStream metadata

There seems to be similar issues with opus as well, which will be addressed
in a separate patch.

---
 libavformat/oggparseflac.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c
index eef6e09927..1dd292483d 100644
--- a/libavformat/oggparseflac.c
+++ b/libavformat/oggparseflac.c
@@ -126,10 +126,30 @@ fail:
 return ret;
 }
 
+static int flac_packet(AVFormatContext *s, int idx)
+{
+struct ogg *ogg = s->priv_data;
+struct ogg_stream *os = ogg->streams + idx;
+int ret;
+
+if (os->psize > 4 && (*(os->buf + os->pstart) & 0x7F) == 
FLAC_METADATA_TYPE_VORBIS_COMMENT) {
+AVStream *st = s->streams[idx];
+av_dict_free(>metadata);
+ret = ff_vorbis_stream_comment(s, st, os->buf + os->pstart + 4,
+   os->psize - 4);
+
+if (ret < 0) return ret;
+}
+
+return 0;
+}
+
+
 const struct ogg_codec ff_flac_codec = {
 .magic = "\177FLAC",
 .magicsize = 5,
 .header = flac_header,
+.packet = flac_packet,
 .nb_header = 2,
 };
 
-- 
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".


Re: [FFmpeg-devel] [PATCH v2] fftools/ffmpeg_mux: fix reporting muxer EOF as error

2023-04-22 Thread Anton Khirnov
Quoting Zhao Zhili (2023-04-22 14:56:34)
> From: Zhao Zhili 
> 
> Fix #10327.
> 
> Signed-off-by: Zhao Zhili 
> ---
>  fftools/ffmpeg_mux.c | 12 +---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
> index a2e8873ad2..0e1a5d7dc5 100644
> --- a/fftools/ffmpeg_mux.c
> +++ b/fftools/ffmpeg_mux.c
> @@ -214,9 +214,15 @@ static void *muxer_thread(void *arg)
>  ost = of->streams[stream_idx];
>  ret = sync_queue_process(mux, ost, ret < 0 ? NULL : pkt, 
> _eof);
>  av_packet_unref(pkt);
> -if (ret == AVERROR_EOF && stream_eof)
> -tq_receive_finish(mux->tq, stream_idx);
> -else if (ret < 0) {
> +if (ret == AVERROR_EOF) {
> +if (stream_eof) {
> +tq_receive_finish(mux->tq, stream_idx);
> +} else {
> +av_log(mux, AV_LOG_VERBOSE, "Muxer %s\n", av_err2str(ret));

That seems unnecesarily convoluted, given that we _know_ the error to be
EOF here. Also, please make it "Muxer returned EOF" to make it clear
what exactly is the source of EOF.

Otherwise ok, feel free to push with this change.

Thanks.
-- 
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] [RFC/PATCH] fftools/ffmpeg: stop printing PSNR information in status report

2023-04-22 Thread Anton Khirnov
If nobody has more comments or objections, I'm planning to push this on
Monday.

-- 
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] fate/h264: add a test disabling cropping

2023-04-22 Thread James Almer

On 4/21/2023 9:12 AM, James Almer wrote:

Signed-off-by: James Almer 
---
  tests/fate/h264.mak |  4 ++
  tests/ref/fate/h264-no-cropping | 95 +
  2 files changed, 99 insertions(+)
  create mode 100644 tests/ref/fate/h264-no-cropping

diff --git a/tests/fate/h264.mak b/tests/fate/h264.mak
index 173806861a..cd2ad79ea2 100644
--- a/tests/fate/h264.mak
+++ b/tests/fate/h264.mak
@@ -232,6 +232,7 @@ FATE_H264-$(call FRAMECRC, MOV, H264) += 
fate-h264-attachment-631
  FATE_H264-$(call FRAMECRC, MPEGTS, H264, H264_PARSER MP3_DECODER SCALE_FILTER 
ARESAMPLE_FILTER) += fate-h264-skip-nokey fate-h264-skip-nointra
  FATE_H264_FFPROBE-$(call DEMDEC, MATROSKA, H264) += fate-h264-dts_5frames
  FATE_H264_FFPROBE-$(call PARSERDEMDEC, H264, H264, H264) += fate-h264-afd
+FATE_H264_FFPROBE-$(call PARSERDEMDEC, H264, H264, H264) += 
fate-h264-no-cropping
  
  FATE_SAMPLES_AVCONV += $(FATE_H264-yes)

  FATE_SAMPLES_FFPROBE += $(FATE_H264_FFPROBE-yes)
@@ -452,6 +453,9 @@ fate-h264-reinit-%:   CMD = 
framecrc -i $(TARGET_SAM
  
  fate-h264-dts_5frames:CMD = probeframes $(TARGET_SAMPLES)/h264/dts_5frames.mkv

  fate-h264-afd:CMD = run 
ffprobe$(PROGSSUF)$(EXESUF) -bitexact -show_entries frame_side_data_list 
$(TARGET_SAMPLES)/h264/bbc2.sample.h264
+fate-h264-no-cropping:CMD = run 
ffprobe$(PROGSSUF)$(EXESUF) -bitexact -apply_cropping 0 -show_entries 
stream=width,height,coded_width,coded_height \
+   
 -show_entries 
frame=width,height,crop_top,crop_bottom,crop_left,crop_right \
+   
 -of compact=p=0 -i $(TARGET_SAMPLES)/h264/bbc2.sample.h264


Will merge this test with the one above it as it uses the same sample 
and command line, and 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] avcodec/hevcdec: further constrain some slice header field values

2023-04-22 Thread James Almer

On 4/20/2023 10:14 AM, James Almer wrote:

num_ref_idx_l0_active_minus1, num_ref_idx_l1_active_minus1, 
num_ref_idx_l0_default_active,
and num_ref_idx_l1_default_active are all in the range 1 to 15, inclusive.

Signed-off-by: James Almer 
---
  libavcodec/hevc_ps.c | 10 --
  libavcodec/hevcdec.c |  6 +++---
  2 files changed, 11 insertions(+), 5 deletions(-)


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


[FFmpeg-devel] [PATCH v2] fftools/ffmpeg_mux: fix reporting muxer EOF as error

2023-04-22 Thread Zhao Zhili
From: Zhao Zhili 

Fix #10327.

Signed-off-by: Zhao Zhili 
---
 fftools/ffmpeg_mux.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index a2e8873ad2..0e1a5d7dc5 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -214,9 +214,15 @@ static void *muxer_thread(void *arg)
 ost = of->streams[stream_idx];
 ret = sync_queue_process(mux, ost, ret < 0 ? NULL : pkt, _eof);
 av_packet_unref(pkt);
-if (ret == AVERROR_EOF && stream_eof)
-tq_receive_finish(mux->tq, stream_idx);
-else if (ret < 0) {
+if (ret == AVERROR_EOF) {
+if (stream_eof) {
+tq_receive_finish(mux->tq, stream_idx);
+} else {
+av_log(mux, AV_LOG_VERBOSE, "Muxer %s\n", av_err2str(ret));
+ret = 0;
+break;
+}
+} else if (ret < 0) {
 av_log(mux, AV_LOG_ERROR, "Error muxing a packet\n");
 break;
 }
-- 
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 31/92] Vulkan patchset part 1 - common code changes

2023-04-22 Thread Anton Khirnov
Quoting Lynne (2023-04-19 16:39:28)
> Apr 17, 2023, 11:25 by an...@khirnov.net:
> 
> > Quoting Lynne (2023-03-14 07:33:43)
> >
> >> From 6e2dfc44e50798264eb16bc2dcabfdbf2fbac2d7 Mon Sep 17 00:00:00 2001
> >> From: Lynne 
> >> Date: Thu, 15 Dec 2022 01:06:52 +0100
> >> Subject: [PATCH 24/92] hwconfig: add a new HWACCEL_CAP_THREAD_SAFE for
> >>  threadsafe hwaccels
> >>
> >> Vulkan is fully threadsafe and stateless, so we can benefit from this.
> >> ---
> >>  libavcodec/hwconfig.h  | 1 +
> >>  libavcodec/pthread_frame.c | 2 +-
> >>  2 files changed, 2 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/libavcodec/hwconfig.h b/libavcodec/hwconfig.h
> >> index 721424912c..e6b78f0160 100644
> >> --- a/libavcodec/hwconfig.h
> >> +++ b/libavcodec/hwconfig.h
> >> @@ -24,6 +24,7 @@
> >>  
> >>  
> >>  #define HWACCEL_CAP_ASYNC_SAFE  (1 << 0)
> >> +#define HWACCEL_CAP_THREAD_SAFE (1 << 1)
> >>  
> >>  
> >>  typedef struct AVCodecHWConfigInternal {
> >> diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
> >> index 74864e19c5..c096287233 100644
> >> --- a/libavcodec/pthread_frame.c
> >> +++ b/libavcodec/pthread_frame.c
> >> @@ -204,7 +204,7 @@ static attribute_align_arg void 
> >> *frame_worker_thread(void *arg)
> >>  
> >>  /* if the previous thread uses hwaccel then we take the lock to ensure
> >>  * the threads don't run concurrently */
> >> -if (avctx->hwaccel) {
> >> +if (avctx->hwaccel && !(avctx->hwaccel->caps_internal & 
> >> HWACCEL_CAP_THREAD_SAFE)) {
> >>
> >
> > A major problem here is that hwaccel_priv_data exists in only a single
> > instance shared across all the worker threads. If you want frame-threaded
> > hwaccels, you'll need to add some mechanism for synchronizing it between
> > threads.
> >
> > I really wonder how does your code survive all the races involved.
> >
> 
> It works because hwaccel_priv_data is read-only. No need to synchronize
> anything, the contexts Vulkan creates are defined as driver-synchronized,
> and all the info a frame needs is provided when decoding it, rather than
> kept as a state.
> So I don't see a problem here.

>From a quick glance, at least vk_av1_free_frame_priv() modifies this
context, which seems highly unsafe.

This really seems like a disaster waiting to happen, there should be
some stronger guarantees that nobody will modify this context when they
shouldn't.

-- 
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 31/92] Vulkan patchset part 1 - common code changes

2023-04-22 Thread Anton Khirnov
Quoting Lynne (2023-04-19 16:47:11)
> Apr 17, 2023, 11:07 by an...@khirnov.net:
> 
> > Quoting Anton Khirnov (2023-04-16 22:38:16)
> >
> >> Quoting Lynne (2023-03-14 07:33:43)
> >> > From 61f412eea3fbcb1e2a8625796760c0e24fa3fb83 Mon Sep 17 00:00:00 2001
> >> > From: Lynne 
> >> > Date: Tue, 17 Jan 2023 05:01:45 +0100
> >> > Subject: [PATCH 27/92] h264dec: add hwaccel_params_buf
> >> > 
> >> > diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
> >> > index 0aee724c0d..6559593195 100644
> >> > --- a/libavcodec/h264dec.c
> >> > +++ b/libavcodec/h264dec.c
> >> > @@ -341,6 +341,7 @@ static av_cold int h264_decode_end(AVCodecContext 
> >> > *avctx)
> >> >  H264Context *h = avctx->priv_data;
> >> >  int i;
> >> > 
> >> > +av_buffer_unref(>hwaccel_params_buf);
> >> >  ff_h264_remove_all_refs(h);
> >> >  ff_h264_free_tables(h);
> >> > 
> >> > @@ -470,6 +471,7 @@ static void h264_decode_flush(AVCodecContext *avctx)
> >> > 
> >> >  ff_h264_flush_change(h);
> >> >  ff_h264_sei_uninit(>sei);
> >> > +av_buffer_unref(>hwaccel_params_buf);
> >> > 
> >> >  for (i = 0; i < H264_MAX_PICTURE_COUNT; i++)
> >> >  ff_h264_unref_picture(h, >DPB[i]);
> >> > @@ -669,6 +671,7 @@ static int decode_nal_units(H264Context *h, const 
> >> > uint8_t *buf, int buf_size)
> >> >  avpriv_request_sample(avctx, "data partitioning");
> >> >  break;
> >> >  case H264_NAL_SEI:
> >> > +av_buffer_unref(>hwaccel_params_buf);
> >> >  if (h->setup_finished) {
> >> >  avpriv_request_sample(avctx, "Late SEI");
> >> >  break;
> >> > @@ -682,6 +685,7 @@ static int decode_nal_units(H264Context *h, const 
> >> > uint8_t *buf, int buf_size)
> >> >  break;
> >> >  case H264_NAL_SPS: {
> >> >  GetBitContext tmp_gb = nal->gb;
> >> > +av_buffer_unref(>hwaccel_params_buf);
> >> >  if (avctx->hwaccel && avctx->hwaccel->decode_params) {
> >> >  ret = avctx->hwaccel->decode_params(avctx,
> >> >  nal->type,
> >>
> >> Removed on SEI and SPS? That seems bizarre and highly arbitrary. Why
> >> specifically those two?
> >>
> >
> > Found the explanation in the cover letter - I assume SEI is a mistake
> > and should really be PPS. The points where it is reset still seem highly
> > Vulkan-specific, so I think it'd be better for the decoder to set a flag
> > on seeing new parameter sets. Vulkan could would then check and clear
> > the flag as needed.
> >
> 
> It was a typo, changed to remove it on SPS and PPS.
> We still have to store the compiled bufferref somewhere, and synchronize
> it between frames, and having it in the frame context itself solves
> those issues.

Except the way it is handled makes no sense for anything other than
vulkan.

Having per-thread hwaccel contexts with a callback for propagating the
data would solve this more cleanly.

-- 
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] fftools/ffmpeg_mux: fix regression with muxer EOF

2023-04-22 Thread Anton Khirnov
Quoting Zhao Zhili (2023-04-21 18:58:09)
> From: Zhao Zhili 
> 
> Regression introduced by b40856.
> 
> Fix #10327.

The commit message is entirely useless, it tells the reader nothing
about what the problem is or how it is fixed.

> ---
>  fftools/ffmpeg_mux.c | 11 ---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
> index a2e8873ad2..b4b4dab8fd 100644
> --- a/fftools/ffmpeg_mux.c
> +++ b/fftools/ffmpeg_mux.c
> @@ -214,9 +214,14 @@ static void *muxer_thread(void *arg)
>  ost = of->streams[stream_idx];
>  ret = sync_queue_process(mux, ost, ret < 0 ? NULL : pkt, 
> _eof);
>  av_packet_unref(pkt);
> -if (ret == AVERROR_EOF && stream_eof)
> -tq_receive_finish(mux->tq, stream_idx);
> -else if (ret < 0) {
> +if (ret == AVERROR_EOF) {
> +if (stream_eof) {
> +tq_receive_finish(mux->tq, stream_idx);
> +} else {
> +ret = 0;
> +break;

All the other exit paths from the loop have a log message saying why it
happened, this one should as well.

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