Re: [FFmpeg-devel] [PATCH] avfilter/avfilter: Fix hardcoded input index

2021-09-05 Thread Soft Works



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Paul B Mahol
> Sent: Sunday, 5 September 2021 21:51
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH] avfilter/avfilter: Fix hardcoded
> input index
> 
> On Sun, Sep 5, 2021 at 9:44 PM Soft Works 
> wrote:
> 
> >
> >
> > > -Original Message-
> > > From: ffmpeg-devel  On Behalf Of
> > > Soft Works
> > > Sent: Sunday, 5 September 2021 16:59
> > > To: FFmpeg development discussions and patches  > > de...@ffmpeg.org>
> > > Subject: Re: [FFmpeg-devel] [PATCH] avfilter/avfilter: Fix
> hardcoded
> > > input index
> > >
> > >
> > >
> > > > -Original Message-
> > > > From: ffmpeg-devel  On Behalf
> Of
> > > > Paul B Mahol
> > > > Sent: Sunday, 5 September 2021 11:01
> > > > To: FFmpeg development discussions and patches  > > > de...@ffmpeg.org>
> > > > Subject: Re: [FFmpeg-devel] [PATCH] avfilter/avfilter: Fix
> > > hardcoded
> > > > input index
> > > >
> > > > With what filters this happens?
> > > >
> > > > IIUC this is forbidden and such filters should use .activate
> > > instead.
> > >
> > > The hardcoded [0] is wrong, no matter what the use case is.
> > >
> > > But to answer your question: It's about a new overlay_textsubs
> filter
> > > where framesync cannot be used and incoming frames (video on
> input0,
> > > subs on input1) need to be processed independently: the subtitle
> > > events
> > > are fed into the ass library (you could practically feed all
> events
> > > in advance) while the overlay image generation is done based on a
> > > given
> > > time code.
> > > This works fine by having a separate .filter_frame function for
> each
> > > input (after applying this patch).
> >
> > BTW
> >
> > > > IIUC this is forbidden and such filters should use .activate
> >
> > The scale2ref filter is set up in the same way (two .filter_frame
> > functions, no .activate, no framesync), probably because - like in
> > my case - the filter must not sync frames across inputs.
> >
> 
> FYI .activate does not sync frames across inputs.

Using .activate helped to solve another issue I had, so thanks again
for the hint.

Besides recommended usage patterns - would you disagree that this
patch is logically correct?

Regards,
softworkz


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

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


[FFmpeg-devel] [PATCH 17/34] avformat/asfenc: Return proper error codes

2021-09-05 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/asfenc.c | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index e4d74c80cb..13d7eebddc 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -625,8 +625,10 @@ static int asf_write_header1(AVFormatContext *s, int64_t 
file_size,
 /* WAVEFORMATEX header */
 int wavsize = ff_put_wav_header(s, pb, par, 
FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX);
 
-if (wavsize < 0)
+if (wavsize < 0) {
+ret = wavsize;
 goto fail;
+}
 if (wavsize != extra_size) {
 cur_pos = avio_tell(pb);
 avio_seek(pb, es_pos, SEEK_SET);
@@ -703,8 +705,10 @@ static int asf_write_header1(AVFormatContext *s, int64_t 
file_size,
 avio_wl16(pb, 4);
 avio_wl32(pb, par->codec_tag);
 }
-if (!par->codec_tag)
+if (!par->codec_tag) {
+ret = AVERROR(EINVAL);
 goto fail;
+}
 }
 end_header(pb, hpos);
 
@@ -735,16 +739,16 @@ static int asf_write_header1(AVFormatContext *s, int64_t 
file_size,
 avio_wl64(pb, asf->nb_packets); /* nb packets */
 avio_w8(pb, 1); /* ??? */
 avio_w8(pb, 1); /* ??? */
-ffio_free_dyn_buf(_buf);
-return 0;
+ret = 0;
 fail:
 ffio_free_dyn_buf(_buf);
-return -1;
+return ret;
 }
 
 static int asf_write_header(AVFormatContext *s)
 {
 ASFContext *asf = s->priv_data;
+int ret;
 
 s->packet_size  = asf->packet_size;
 s->max_interleave_delta = 0;
@@ -764,9 +768,8 @@ static int asf_write_header(AVFormatContext *s)
 /* the data-chunk-size has to be 50 (DATA_HEADER_SIZE), which is
  * data_size - asf->data_offset at the moment this function is done.
  * It is needed to use asf as a streamable format. */
-if (asf_write_header1(s, 0, DATA_HEADER_SIZE) < 0) {
-return -1;
-}
+if ((ret = asf_write_header1(s, 0, DATA_HEADER_SIZE)) < 0)
+return ret;
 
 asf->packet_nb_payloads = 0;
 asf->packet_timestamp_start = -1;
-- 
2.30.2

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

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


[FFmpeg-devel] [PATCH 29/34] avformat/tee: Avoid stack packet

2021-09-05 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/tee.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavformat/tee.c b/libavformat/tee.c
index 505873ce1e..f359218a08 100644
--- a/libavformat/tee.c
+++ b/libavformat/tee.c
@@ -540,7 +540,7 @@ static int tee_write_packet(AVFormatContext *avf, AVPacket 
*pkt)
 TeeContext *tee = avf->priv_data;
 AVFormatContext *avf2;
 AVBSFContext *bsfs;
-AVPacket pkt2;
+AVPacket *const pkt2 = avf->internal->pkt;
 int ret_all = 0, ret;
 unsigned i, s;
 int s2;
@@ -565,17 +565,17 @@ static int tee_write_packet(AVFormatContext *avf, 
AVPacket *pkt)
 if (s2 < 0)
 continue;
 
-if ((ret = av_packet_ref(, pkt)) < 0) {
+if ((ret = av_packet_ref(pkt2, pkt)) < 0) {
 if (!ret_all)
 ret_all = ret;
 continue;
 }
 bsfs = tee->slaves[i].bsfs[s2];
-pkt2.stream_index = s2;
+pkt2->stream_index = s2;
 
-ret = av_bsf_send_packet(bsfs, );
+ret = av_bsf_send_packet(bsfs, pkt2);
 if (ret < 0) {
-av_packet_unref();
+av_packet_unref(pkt2);
 av_log(avf, AV_LOG_ERROR, "Error while sending packet to bitstream 
filter: %s\n",
av_err2str(ret));
 ret = tee_process_slave_failure(avf, i, ret);
@@ -584,7 +584,7 @@ static int tee_write_packet(AVFormatContext *avf, AVPacket 
*pkt)
 }
 
 while(1) {
-ret = av_bsf_receive_packet(bsfs, );
+ret = av_bsf_receive_packet(bsfs, pkt2);
 if (ret == AVERROR(EAGAIN)) {
 ret = 0;
 break;
@@ -592,9 +592,9 @@ static int tee_write_packet(AVFormatContext *avf, AVPacket 
*pkt)
 break;
 }
 
-av_packet_rescale_ts(, bsfs->time_base_out,
+av_packet_rescale_ts(pkt2, bsfs->time_base_out,
  avf2->streams[s2]->time_base);
-ret = av_interleaved_write_frame(avf2, );
+ret = av_interleaved_write_frame(avf2, pkt2);
 if (ret < 0)
 break;
 };
-- 
2.30.2

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

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


[FFmpeg-devel] [PATCH 34/34] avformat/mux: Remove unnecessary av_packet_unref()

2021-09-05 Thread Andreas Rheinhardt
AVFormatInternal.parse_pkt is always blank after having been used.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/mux.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/libavformat/mux.c b/libavformat/mux.c
index c5e07aaf1c..47883ece37 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -1196,8 +1196,6 @@ int av_write_frame(AVFormatContext *s, AVPacket *in)
  * The following avoids copying in's data unnecessarily.
  * Copying side data is unavoidable as a bitstream filter
  * may change it, e.g. free it on errors. */
-av_packet_unref(pkt);
-pkt->buf  = NULL;
 pkt->data = in->data;
 pkt->size = in->size;
 ret = av_packet_copy_props(pkt, in);
@@ -1240,7 +1238,6 @@ int av_write_trailer(AVFormatContext *s)
 AVPacket *const pkt = s->internal->parse_pkt;
 int i, ret1, ret = 0;
 
-av_packet_unref(pkt);
 for (i = 0; i < s->nb_streams; i++) {
 if (s->streams[i]->internal->bsfc) {
 ret1 = write_packets_from_bsfs(s, s->streams[i], pkt, 
1/*interleaved*/);
@@ -1345,7 +1342,6 @@ static int write_uncoded_frame_internal(AVFormatContext 
*s, int stream_index,
 
 if (!framep)
 goto fail;
-av_packet_unref(pkt);
 pkt->buf = av_buffer_create((void *)framep, bufsize,
uncoded_frame_free, NULL, 0);
 if (!pkt->buf) {
-- 
2.30.2

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

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


[FFmpeg-devel] [PATCH 33/34] avformat/tee: Reindentation

2021-09-05 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/tee.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavformat/tee.c b/libavformat/tee.c
index 88a40ebe87..7ce9f7499d 100644
--- a/libavformat/tee.c
+++ b/libavformat/tee.c
@@ -98,15 +98,15 @@ static inline int parse_slave_failure_policy_option(const 
char *opt, TeeSlave *t
 
 static int parse_slave_fifo_policy(const char *use_fifo, TeeSlave *tee_slave)
 {
-/*TODO - change this to use proper function for parsing boolean
- *   options when there is one */
-if (av_match_name(use_fifo, "true,y,yes,enable,enabled,on,1")) {
-tee_slave->use_fifo = 1;
-} else if (av_match_name(use_fifo, 
"false,n,no,disable,disabled,off,0")) {
-tee_slave->use_fifo = 0;
-} else {
-return AVERROR(EINVAL);
-}
+/*TODO - change this to use proper function for parsing boolean
+ *   options when there is one */
+if (av_match_name(use_fifo, "true,y,yes,enable,enabled,on,1")) {
+tee_slave->use_fifo = 1;
+} else if (av_match_name(use_fifo, "false,n,no,disable,disabled,off,0")) {
+tee_slave->use_fifo = 0;
+} else {
+return AVERROR(EINVAL);
+}
 return 0;
 }
 
-- 
2.30.2

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

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


[FFmpeg-devel] [PATCH 32/34] avformat/tee: Process strings immediately if possible

2021-09-05 Thread Andreas Rheinhardt
This avoids having to free them manually lateron.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/tee.c | 54 ---
 1 file changed, 23 insertions(+), 31 deletions(-)

diff --git a/libavformat/tee.c b/libavformat/tee.c
index 4129954172..88a40ebe87 100644
--- a/libavformat/tee.c
+++ b/libavformat/tee.c
@@ -96,12 +96,8 @@ static inline int parse_slave_failure_policy_option(const 
char *opt, TeeSlave *t
 return AVERROR(EINVAL);
 }
 
-static int parse_slave_fifo_options(const char *use_fifo,
-const char *fifo_options, TeeSlave 
*tee_slave)
+static int parse_slave_fifo_policy(const char *use_fifo, TeeSlave *tee_slave)
 {
-int ret = 0;
-
-if (use_fifo) {
 /*TODO - change this to use proper function for parsing boolean
  *   options when there is one */
 if (av_match_name(use_fifo, "true,y,yes,enable,enabled,on,1")) {
@@ -111,12 +107,12 @@ static int parse_slave_fifo_options(const char *use_fifo,
 } else {
 return AVERROR(EINVAL);
 }
-}
-
-if (fifo_options)
-ret = av_dict_parse_string(_slave->fifo_options, fifo_options, 
"=", ":", 0);
+return 0;
+}
 
-return ret;
+static int parse_slave_fifo_options(const char *fifo_options, TeeSlave 
*tee_slave)
+{
+return av_dict_parse_string(_slave->fifo_options, fifo_options, "=", 
":", 0);
 }
 
 static int close_slave(TeeSlave *tee_slave)
@@ -174,19 +170,31 @@ static int open_slave(AVFormatContext *avf, char *slave, 
TeeSlave *tee_slave)
 if ((ret = ff_tee_parse_slave_options(avf, slave, , )) < 
0)
 return ret;
 
-#define STEAL_OPTION(option, field) do {\
+#define CONSUME_OPTION(option, field, action) do {  \
 if ((entry = av_dict_get(options, option, NULL, 0))) {  \
 field = entry->value;   \
-entry->value = NULL; /* prevent it from being freed */  \
+{ action }  \
 av_dict_set(, option, NULL, 0); \
 }   \
 } while (0)
+#define STEAL_OPTION(option, field) \
+CONSUME_OPTION(option, field,   \
+   entry->value = NULL; /* prevent it from being freed */)
+#define PROCESS_OPTION(option, field, function, on_error)   \
+CONSUME_OPTION(option, field, if ((ret = function) < 0) { { on_error } 
goto end; })
 
 STEAL_OPTION("f", format);
 STEAL_OPTION("select", select);
-STEAL_OPTION("onfail", on_fail);
-STEAL_OPTION("use_fifo", use_fifo);
-STEAL_OPTION("fifo_options", fifo_options_str);
+PROCESS_OPTION("onfail", on_fail,
+   parse_slave_failure_policy_option(on_fail, tee_slave),
+   av_log(avf, AV_LOG_ERROR, "Invalid onfail option value, "
+  "valid options are 'abort' and 'ignore'\n"););
+PROCESS_OPTION("use_fifo", use_fifo,
+   parse_slave_fifo_policy(use_fifo, tee_slave),
+   av_log(avf, AV_LOG_ERROR, "Error parsing fifo options: 
%s\n",
+  av_err2str(ret)););
+PROCESS_OPTION("fifo_options", fifo_options_str,
+   parse_slave_fifo_options(fifo_options_str, tee_slave), ;);
 entry = NULL;
 while ((entry = av_dict_get(options, "bsfs", entry, 
AV_DICT_IGNORE_SUFFIX))) {
 /* trim out strlen("bsfs") characters from key */
@@ -194,19 +202,6 @@ static int open_slave(AVFormatContext *avf, char *slave, 
TeeSlave *tee_slave)
 av_dict_set(, entry->key, NULL, 0);
 }
 
-ret = parse_slave_failure_policy_option(on_fail, tee_slave);
-if (ret < 0) {
-av_log(avf, AV_LOG_ERROR,
-   "Invalid onfail option value, valid options are 'abort' and 
'ignore'\n");
-goto end;
-}
-
-ret = parse_slave_fifo_options(use_fifo, fifo_options_str, tee_slave);
-if (ret < 0) {
-av_log(avf, AV_LOG_ERROR, "Error parsing fifo options: %s\n", 
av_err2str(ret));
-goto end;
-}
-
 if (tee_slave->use_fifo) {
 
 if (options) {
@@ -405,9 +400,6 @@ static int open_slave(AVFormatContext *avf, char *slave, 
TeeSlave *tee_slave)
 end:
 av_free(format);
 av_free(select);
-av_free(on_fail);
-av_free(use_fifo);
-av_free(fifo_options_str);
 av_dict_free();
 av_dict_free(_options);
 av_freep(_select);
-- 
2.30.2

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

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


[FFmpeg-devel] [PATCH 31/34] avformat/tee: Fix leak of FIFO-options dictionary

2021-09-05 Thread Andreas Rheinhardt
Happened for all slaves which didn't use the FIFO.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/tee.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/tee.c b/libavformat/tee.c
index 03356da6c0..4129954172 100644
--- a/libavformat/tee.c
+++ b/libavformat/tee.c
@@ -125,6 +125,7 @@ static int close_slave(TeeSlave *tee_slave)
 unsigned i;
 int ret = 0;
 
+av_dict_free(_slave->fifo_options);
 avf = tee_slave->avf;
 if (!avf)
 return 0;
@@ -230,6 +231,7 @@ static int open_slave(AVFormatContext *avf, char *slave, 
TeeSlave *tee_slave)
 
 av_dict_free();
 options = tee_slave->fifo_options;
+tee_slave->fifo_options = NULL;
 }
 ret = avformat_alloc_output_context2(, NULL,
  tee_slave->use_fifo ? "fifo" :format, 
filename);
-- 
2.30.2

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

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


[FFmpeg-devel] [PATCH 27/34] avformat/tee: Fix inconsistency wrt av_packet_ref() failure handling

2021-09-05 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/tee.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/tee.c b/libavformat/tee.c
index 759535bdea..a5bf34d083 100644
--- a/libavformat/tee.c
+++ b/libavformat/tee.c
@@ -565,11 +565,11 @@ static int tee_write_packet(AVFormatContext *avf, 
AVPacket *pkt)
 if (s2 < 0)
 continue;
 
-if ((ret = av_packet_ref(, pkt)) < 0)
-if (!ret_all) {
+if ((ret = av_packet_ref(, pkt)) < 0) {
+if (!ret_all)
 ret_all = ret;
-continue;
-}
+continue;
+}
 bsfs = tee->slaves[i].bsfs[s2];
 pkt2.stream_index = s2;
 
-- 
2.30.2

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

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


[FFmpeg-devel] [PATCH 26/34] avformat/webpenc: Don't use sizeof(AVPacket)

2021-09-05 Thread Andreas Rheinhardt
In this case it means replacing a packet in the muxer's context by
a pointer to an AVPacket, namely AVFormatInternal.pkt.
Because this packet is freed generically, one can remove the muxer's
deinit function.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/webpenc.c | 37 -
 1 file changed, 16 insertions(+), 21 deletions(-)

diff --git a/libavformat/webpenc.c b/libavformat/webpenc.c
index 9599fe7b85..8c9582a2df 100644
--- a/libavformat/webpenc.c
+++ b/libavformat/webpenc.c
@@ -27,7 +27,7 @@
 typedef struct WebpContext{
 AVClass *class;
 int frame_count;
-AVPacket last_pkt;
+AVPacket *last_pkt; /* Not owned by us */
 int loop;
 int wrote_webp_header;
 int using_webp_anim_encoder;
@@ -35,8 +35,11 @@ typedef struct WebpContext{
 
 static int webp_init(AVFormatContext *s)
 {
+WebpContext *const w = s->priv_data;
 AVStream *st;
 
+w->last_pkt = s->internal->pkt;
+
 if (s->nb_streams != 1) {
 av_log(s, AV_LOG_ERROR, "Only exactly 1 stream is supported\n");
 return AVERROR(EINVAL);
@@ -77,18 +80,18 @@ static int flush(AVFormatContext *s, int trailer, int64_t 
pts)
 WebpContext *w = s->priv_data;
 AVStream *st = s->streams[0];
 
-if (w->last_pkt.size) {
+if (w->last_pkt->size) {
 int skip = 0;
 unsigned flags = 0;
 int vp8x = 0;
 
-if (AV_RL32(w->last_pkt.data) == AV_RL32("RIFF"))
+if (AV_RL32(w->last_pkt->data) == AV_RL32("RIFF"))
 skip = 12;
 
-if (AV_RL32(w->last_pkt.data + skip) == AV_RL32("VP8X")) {
-flags |= w->last_pkt.data[skip + 4 + 4];
+if (AV_RL32(w->last_pkt->data + skip) == AV_RL32("VP8X")) {
+flags |= w->last_pkt->data[skip + 4 + 4];
 vp8x = 1;
-skip += AV_RL32(w->last_pkt.data + skip + 4) + 8;
+skip += AV_RL32(w->last_pkt->data + skip + 4) + 8;
 }
 
 if (!w->wrote_webp_header) {
@@ -122,19 +125,19 @@ static int flush(AVFormatContext *s, int trailer, int64_t 
pts)
 
 if (w->frame_count > trailer) {
 avio_write(s->pb, "ANMF", 4);
-avio_wl32(s->pb, 16 + w->last_pkt.size - skip);
+avio_wl32(s->pb, 16 + w->last_pkt->size - skip);
 avio_wl24(s->pb, 0);
 avio_wl24(s->pb, 0);
 avio_wl24(s->pb, st->codecpar->width - 1);
 avio_wl24(s->pb, st->codecpar->height - 1);
-if (w->last_pkt.pts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE) {
-avio_wl24(s->pb, pts - w->last_pkt.pts);
+if (w->last_pkt->pts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE) {
+avio_wl24(s->pb, pts - w->last_pkt->pts);
 } else
-avio_wl24(s->pb, w->last_pkt.duration);
+avio_wl24(s->pb, w->last_pkt->duration);
 avio_w8(s->pb, 0);
 }
-avio_write(s->pb, w->last_pkt.data + skip, w->last_pkt.size - skip);
-av_packet_unref(>last_pkt);
+avio_write(s->pb, w->last_pkt->data + skip, w->last_pkt->size - skip);
+av_packet_unref(w->last_pkt);
 }
 
 return 0;
@@ -159,7 +162,7 @@ static int webp_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 int ret;
 if ((ret = flush(s, 0, pkt->pts)) < 0)
 return ret;
-av_packet_ref(>last_pkt, pkt);
+av_packet_ref(w->last_pkt, pkt);
 }
 ++w->frame_count;
 
@@ -191,13 +194,6 @@ static int webp_write_trailer(AVFormatContext *s)
 return 0;
 }
 
-static void webp_deinit(AVFormatContext *s)
-{
-WebpContext *w = s->priv_data;
-
-av_packet_unref(>last_pkt);
-}
-
 #define OFFSET(x) offsetof(WebpContext, x)
 #define ENC AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
@@ -221,7 +217,6 @@ const AVOutputFormat ff_webp_muxer = {
 .init   = webp_init,
 .write_packet   = webp_write_packet,
 .write_trailer  = webp_write_trailer,
-.deinit = webp_deinit,
 .priv_class = _muxer_class,
 .flags  = AVFMT_VARIABLE_FPS,
 };
-- 
2.30.2

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

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


[FFmpeg-devel] [PATCH 25/34] avformat/flacenc: Avoid stack packet

2021-09-05 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/flacenc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index 44c9341493..ab57a1e45a 100644
--- a/libavformat/flacenc.c
+++ b/libavformat/flacenc.c
@@ -299,7 +299,7 @@ static int flac_write_audio_packet(struct AVFormatContext 
*s, AVPacket *pkt)
 static int flac_queue_flush(AVFormatContext *s)
 {
 FlacMuxerContext *c = s->priv_data;
-AVPacket pkt;
+AVPacket *const pkt = s->internal->pkt;
 int ret, write = 1;
 
 ret = flac_finish_header(s);
@@ -307,10 +307,10 @@ static int flac_queue_flush(AVFormatContext *s)
 write = 0;
 
 while (c->queue) {
-avpriv_packet_list_get(>queue, >queue_end, );
-if (write && (ret = flac_write_audio_packet(s, )) < 0)
+avpriv_packet_list_get(>queue, >queue_end, pkt);
+if (write && (ret = flac_write_audio_packet(s, pkt)) < 0)
 write = 0;
-av_packet_unref();
+av_packet_unref(pkt);
 }
 return ret;
 }
-- 
2.30.2

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

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


[FFmpeg-devel] [PATCH 30/34] avformat/tee: Fix leak of strings

2021-09-05 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/tee.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/tee.c b/libavformat/tee.c
index f359218a08..03356da6c0 100644
--- a/libavformat/tee.c
+++ b/libavformat/tee.c
@@ -404,6 +404,8 @@ end:
 av_free(format);
 av_free(select);
 av_free(on_fail);
+av_free(use_fifo);
+av_free(fifo_options_str);
 av_dict_free();
 av_dict_free(_options);
 av_freep(_select);
-- 
2.30.2

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

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


[FFmpeg-devel] [PATCH 24/34] avformat/img2enc: Don't use sizeof(AVPacket)

2021-09-05 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/img2enc.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index 655595374d..944e055e12 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -77,7 +77,7 @@ static int write_muxed_file(AVFormatContext *s, AVIOContext 
*pb, AVPacket *pkt)
 VideoMuxData *img = s->priv_data;
 AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar;
 AVStream *st;
-AVPacket pkt2;
+AVPacket *const pkt2 = s->internal->pkt;
 AVFormatContext *fmt = NULL;
 int ret;
 
@@ -94,17 +94,17 @@ static int write_muxed_file(AVFormatContext *s, AVIOContext 
*pb, AVPacket *pkt)
 
 fmt->pb = pb;
 
-ret = av_packet_ref(, pkt);
+ret = av_packet_ref(pkt2, pkt);
 if (ret < 0)
 goto out;
-pkt2.stream_index = 0;
+pkt2->stream_index = 0;
 
 if ((ret = avcodec_parameters_copy(st->codecpar, par)) < 0 ||
 (ret = avformat_write_header(fmt, NULL))   < 0 ||
-(ret = av_interleaved_write_frame(fmt, )) < 0 ||
+(ret = av_interleaved_write_frame(fmt, pkt2)) < 0 ||
 (ret = av_write_trailer(fmt))) {}
 
-av_packet_unref();
+av_packet_unref(pkt2);
 out:
 avformat_free_context(fmt);
 return ret;
-- 
2.30.2

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

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


[FFmpeg-devel] [PATCH 23/34] avformat/mp3enc: Avoid stack packet

2021-09-05 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/mp3enc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index c8328b8b9d..019e92ca8e 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -381,17 +381,17 @@ static int mp3_write_audio_packet(AVFormatContext *s, 
AVPacket *pkt)
 static int mp3_queue_flush(AVFormatContext *s)
 {
 MP3Context *mp3 = s->priv_data;
-AVPacket pkt;
+AVPacket *const pkt = s->internal->pkt;
 int ret = 0, write = 1;
 
 ff_id3v2_finish(>id3, s->pb, s->metadata_header_padding);
 mp3_write_xing(s);
 
 while (mp3->queue) {
-avpriv_packet_list_get(>queue, >queue_end, );
-if (write && (ret = mp3_write_audio_packet(s, )) < 0)
+avpriv_packet_list_get(>queue, >queue_end, pkt);
+if (write && (ret = mp3_write_audio_packet(s, pkt)) < 0)
 write = 0;
-av_packet_unref();
+av_packet_unref(pkt);
 }
 return ret;
 }
-- 
2.30.2

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

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


[FFmpeg-devel] [PATCH 21/34] avformat/matroskaenc: Avoid allocation of AVPacket

2021-09-05 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskaenc.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 6e34243f6b..250623535a 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -453,8 +453,6 @@ static void mkv_deinit(AVFormatContext *s)
 {
 MatroskaMuxContext *mkv = s->priv_data;
 
-av_packet_free(>cur_audio_pkt);
-
 ffio_free_dyn_buf(>cluster_bc);
 ffio_free_dyn_buf(>info.bc);
 ffio_free_dyn_buf(>track.bc);
@@ -2683,9 +2681,8 @@ static int mkv_init(struct AVFormatContext *s)
 } else
 mkv->mode = MODE_MATROSKAv2;
 
-mkv->cur_audio_pkt = av_packet_alloc();
-if (!mkv->cur_audio_pkt)
-return AVERROR(ENOMEM);
+mkv->cur_audio_pkt = s->internal->pkt;
+
 mkv->tracks = av_mallocz_array(s->nb_streams, sizeof(*mkv->tracks));
 if (!mkv->tracks)
 return AVERROR(ENOMEM);
-- 
2.30.2

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

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


[FFmpeg-devel] [PATCH 22/34] avformat/ttaenc: Avoid stack packet

2021-09-05 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/ttaenc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/ttaenc.c b/libavformat/ttaenc.c
index 5f66695a9a..842dee52dc 100644
--- a/libavformat/ttaenc.c
+++ b/libavformat/ttaenc.c
@@ -123,12 +123,12 @@ static int tta_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 static void tta_queue_flush(AVFormatContext *s)
 {
 TTAMuxContext *tta = s->priv_data;
-AVPacket pkt;
+AVPacket *const pkt = s->internal->pkt;
 
 while (tta->queue) {
-avpriv_packet_list_get(>queue, >queue_end, );
-avio_write(s->pb, pkt.data, pkt.size);
-av_packet_unref();
+avpriv_packet_list_get(>queue, >queue_end, pkt);
+avio_write(s->pb, pkt->data, pkt->size);
+av_packet_unref(pkt);
 }
 }
 
-- 
2.30.2

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

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


[FFmpeg-devel] [PATCH 28/34] avformat/tee: Unref packet on av_bsf_send_packet() failure

2021-09-05 Thread Andreas Rheinhardt
Given that the packet sent to av_bsf_send_packet() is always
already refcounted, it is doubtful whether the error can even
be triggered currently.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/tee.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/tee.c b/libavformat/tee.c
index a5bf34d083..505873ce1e 100644
--- a/libavformat/tee.c
+++ b/libavformat/tee.c
@@ -575,6 +575,7 @@ static int tee_write_packet(AVFormatContext *avf, AVPacket 
*pkt)
 
 ret = av_bsf_send_packet(bsfs, );
 if (ret < 0) {
+av_packet_unref();
 av_log(avf, AV_LOG_ERROR, "Error while sending packet to bitstream 
filter: %s\n",
av_err2str(ret));
 ret = tee_process_slave_failure(avf, i, ret);
-- 
2.30.2

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

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


[FFmpeg-devel] [PATCH 20/34] avformat/avienc: Avoid allocating AVPacket

2021-09-05 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/avienc.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 9eb072ce12..05bcb8cf79 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -275,9 +275,7 @@ static int avi_write_header(AVFormatContext *s)
 return AVERROR(EINVAL);
 }
 
-avi->empty_packet = av_packet_alloc();
-if (!avi->empty_packet)
-return AVERROR(ENOMEM);
+avi->empty_packet = s->internal->pkt;
 
 for (n = 0; n < s->nb_streams; n++) {
 s->streams[n]->priv_data = av_mallocz(sizeof(AVIStream));
@@ -980,10 +978,6 @@ static int avi_write_trailer(AVFormatContext *s)
 
 static void avi_deinit(AVFormatContext *s)
 {
-AVIContext *avi = s->priv_data;
-
-av_packet_free(>empty_packet);
-
 for (int i = 0; i < s->nb_streams; i++) {
 AVIStream *avist = s->streams[i]->priv_data;
 if (!avist)
-- 
2.30.2

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

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


[FFmpeg-devel] [PATCH 16/34] avformat/asfenc: Add deinit function

2021-09-05 Thread Andreas Rheinhardt
Fixes leaks when the trailer is never written.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/asfenc.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index 8e9b7ffc28..e4d74c80cb 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -765,8 +765,6 @@ static int asf_write_header(AVFormatContext *s)
  * data_size - asf->data_offset at the moment this function is done.
  * It is needed to use asf as a streamable format. */
 if (asf_write_header1(s, 0, DATA_HEADER_SIZE) < 0) {
-//av_free(asf);
-av_freep(>index_ptr);
 return -1;
 }
 
@@ -1110,10 +1108,16 @@ static int asf_write_trailer(AVFormatContext *s)
 asf_write_header1(s, file_size, data_size - asf->data_offset);
 }
 
-av_freep(>index_ptr);
 return 0;
 }
 
+static void asf_deinit(AVFormatContext *s)
+{
+ASFContext *const asf = s->priv_data;
+
+av_freep(>index_ptr);
+}
+
 static const AVOption asf_options[] = {
 { "packet_size", "Packet size", offsetof(ASFContext, packet_size), 
AV_OPT_TYPE_INT, {.i64 = 3200}, PACKET_SIZE_MIN, PACKET_SIZE_MAX, 
AV_OPT_FLAG_ENCODING_PARAM },
 { NULL },
@@ -1141,6 +1145,7 @@ const AVOutputFormat ff_asf_muxer = {
 .flags  = AVFMT_GLOBALHEADER,
 .codec_tag  = asf_codec_tags,
 .priv_class= _muxer_class,
+.deinit = asf_deinit,
 };
 #endif /* CONFIG_ASF_MUXER */
 
@@ -1159,5 +1164,6 @@ const AVOutputFormat ff_asf_stream_muxer = {
 .flags  = AVFMT_GLOBALHEADER,
 .codec_tag  = asf_codec_tags,
 .priv_class = _muxer_class,
+.deinit = asf_deinit,
 };
 #endif /* CONFIG_ASF_STREAM_MUXER */
-- 
2.30.2

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

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


[FFmpeg-devel] [PATCH 19/34] avformat/amvenc: Avoid allocating packet

2021-09-05 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/amvenc.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/libavformat/amvenc.c b/libavformat/amvenc.c
index cb03f00ed7..ff1a857dbf 100644
--- a/libavformat/amvenc.c
+++ b/libavformat/amvenc.c
@@ -62,7 +62,7 @@ typedef struct AMVContext
 
 int32_t aframe_size;  /* Expected audio frame size.  */
 int32_t ablock_align; /* Expected audio block align. */
-AVPacket *apad;   /* Dummy audio packet for padding. */
+AVPacket *apad;   /* Dummy audio packet for padding; not owned by us. 
*/
 AVPacket *vpad;   /* Most recent video frame, for padding. */
 
 /*
@@ -183,9 +183,7 @@ static av_cold int amv_init(AVFormatContext *s)
 }
 
 /* Allocate and fill dummy packet so we can pad the audio. */
-amv->apad = av_packet_alloc();
-if (!amv->apad)
-return AVERROR(ENOMEM);
+amv->apad = s->internal->pkt;
 if ((ret = av_new_packet(amv->apad, amv->ablock_align)) < 0) {
 return ret;
 }
@@ -207,7 +205,6 @@ static void amv_deinit(AVFormatContext *s)
 {
 AMVContext *amv = s->priv_data;
 
-av_packet_free(>apad);
 av_packet_free(>vpad);
 }
 
-- 
2.30.2

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

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


[FFmpeg-devel] [PATCH 18/34] avformat/internal: Allow AVFormatInternal.pkt to be used by muxers

2021-09-05 Thread Andreas Rheinhardt
It is unused by the generic muxing code.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/internal.h | 4 +++-
 libavformat/mux.c  | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavformat/internal.h b/libavformat/internal.h
index c3d0ff6b88..c16cb5b17f 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -116,7 +116,9 @@ struct AVFormatInternal {
 AVPacket *parse_pkt;
 
 /**
- * Used to hold temporary packets.
+ * Used to hold temporary packets for the generic demuxing code.
+ * When muxing, it may be used by muxers to hold packets (even
+ * permanent ones).
  */
 AVPacket *pkt;
 /**
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 7373fcd1a8..c5e07aaf1c 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -1277,6 +1277,7 @@ int av_write_trailer(AVFormatContext *s)
 if (s->oformat->priv_class)
 av_opt_free(s->priv_data);
 av_freep(>priv_data);
+av_packet_unref(s->internal->pkt);
 return ret;
 }
 
-- 
2.30.2

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

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


[FFmpeg-devel] [PATCH 15/34] avformat/asfenc: Avoid allocations when writing metadata

2021-09-05 Thread Andreas Rheinhardt
Also improves the error check for avio_open_dyn_buf().

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/asfenc.c | 68 +++-
 1 file changed, 29 insertions(+), 39 deletions(-)

diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index 1706062f7b..8e9b7ffc28 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -239,19 +239,16 @@ static const AVCodecTag *const asf_codec_tags[] = {
 
 #define PREROLL_TIME 3100
 
-static void put_str16(AVIOContext *s, const char *tag)
+static void put_str16(AVIOContext *s, AVIOContext *dyn_buf, const char *tag)
 {
+uint8_t *buf;
 int len;
-uint8_t *pb;
-AVIOContext *dyn_buf;
-if (avio_open_dyn_buf(_buf) < 0)
-return;
 
 avio_put_str16le(dyn_buf, tag);
-len = avio_close_dyn_buf(dyn_buf, );
+len = avio_get_dyn_buf(dyn_buf, );
 avio_wl16(s, len);
-avio_write(s, pb, len);
-av_freep();
+avio_write(s, buf, len);
+ffio_reset_dyn_buf(dyn_buf);
 }
 
 static int64_t put_header(AVIOContext *pb, const ff_asf_guid *g)
@@ -317,7 +314,7 @@ static int32_t get_send_time(ASFContext *asf, int64_t 
pres_time, uint64_t *offse
 return send_time / 1;
 }
 
-static int asf_write_markers(AVFormatContext *s)
+static void asf_write_markers(AVFormatContext *s, AVIOContext *dyn_buf)
 {
 ASFContext *asf = s->priv_data;
 AVIOContext *pb = s->pb;
@@ -336,14 +333,11 @@ static int asf_write_markers(AVFormatContext *s)
 int64_t pres_time = av_rescale_q(c->start, c->time_base, scale);
 uint64_t offset;
 int32_t send_time = get_send_time(asf, pres_time, );
-int len = 0, ret;
+int len = 0;
 uint8_t *buf;
-AVIOContext *dyn_buf;
 if (t) {
-if ((ret = avio_open_dyn_buf(_buf)) < 0)
-return ret;
 avio_put_str16le(dyn_buf, t->value);
-len = avio_close_dyn_buf(dyn_buf, );
+len = avio_get_dyn_buf(dyn_buf, );
 }
 avio_wl64(pb, offset);// offset of the packet with 
send_time
 avio_wl64(pb, pres_time + PREROLL_TIME * 1); // presentation time
@@ -353,11 +347,10 @@ static int asf_write_markers(AVFormatContext *s)
 avio_wl32(pb, len / 2);   // marker desc length in WCHARS!
 if (t) {
 avio_write(pb, buf, len); // marker desc
-av_freep();
+ffio_reset_dyn_buf(dyn_buf);
 }
 }
 end_header(pb, hpos);
-return 0;
 }
 
 /* write the header (used two times if non streamed) */
@@ -365,14 +358,14 @@ static int asf_write_header1(AVFormatContext *s, int64_t 
file_size,
  int64_t data_chunk_size)
 {
 ASFContext *asf = s->priv_data;
-AVIOContext *pb = s->pb;
+AVIOContext *pb = s->pb, *dyn_buf;
 AVDictionaryEntry *tags[5];
 int header_size, n, extra_size, extra_size2, wav_extra_size;
 int has_title, has_aspect_ratio = 0;
 int metadata_count;
 AVCodecParameters *par;
 int64_t header_offset, cur_pos, hpos;
-int bit_rate;
+int bit_rate, ret;
 int64_t duration;
 int audio_language_counts[128] = { 0 };
 
@@ -556,14 +549,13 @@ static int asf_write_header1(AVFormatContext *s, int64_t 
file_size,
 }
 end_header(pb, hpos);
 
+if ((ret = avio_open_dyn_buf(_buf)) < 0)
+return ret;
+
 /* title and other info */
 if (has_title) {
-int len, ret;
 uint8_t *buf;
-AVIOContext *dyn_buf;
-
-if ((ret = avio_open_dyn_buf(_buf)) < 0)
-return ret;
+int len;
 
 hpos = put_header(pb, _asf_comment_header);
 
@@ -571,9 +563,9 @@ static int asf_write_header1(AVFormatContext *s, int64_t 
file_size,
 len = tags[n] ? avio_put_str16le(dyn_buf, tags[n]->value) : 0;
 avio_wl16(pb, len);
 }
-len = avio_close_dyn_buf(dyn_buf, );
+len = avio_get_dyn_buf(dyn_buf, );
 avio_write(pb, buf, len);
-av_freep();
+ffio_reset_dyn_buf(dyn_buf);
 end_header(pb, hpos);
 }
 if (metadata_count) {
@@ -581,17 +573,15 @@ static int asf_write_header1(AVFormatContext *s, int64_t 
file_size,
 hpos = put_header(pb, _asf_extended_content_header);
 avio_wl16(pb, metadata_count);
 while ((tag = av_dict_get(s->metadata, "", tag, 
AV_DICT_IGNORE_SUFFIX))) {
-put_str16(pb, tag->key);
+put_str16(pb, dyn_buf, tag->key);
 avio_wl16(pb, 0);
-put_str16(pb, tag->value);
+put_str16(pb, dyn_buf, tag->value);
 }
 end_header(pb, hpos);
 }
 /* chapters using ASF markers */
 if (!asf->is_streamed && s->nb_chapters) {
-int ret;
-if ((ret = asf_write_markers(s)) < 0)
-return ret;
+asf_write_markers(s, dyn_buf);
 }
 /* stream headers */
 for (n = 0; n < s->nb_streams; n++) {
@@ -636,7 +626,7 @@ static int 

[FFmpeg-devel] [PATCH 14/34] avformat/asfenc: Remove unused fields from ASFStream

2021-09-05 Thread Andreas Rheinhardt
It has never been done in b08569a23948db107e5e6175cd4c695427d5339d,
30b8f3e7dcd0318b91e205dcbf774ef92fb6193c.

After this change, this muxer does no longer use sizeof(AVPacket).

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/asfenc.c | 25 -
 1 file changed, 25 deletions(-)

diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index b294431aec..1706062f7b 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -186,36 +186,11 @@
 #define PACKET_SIZE_MAX 65536
 #define PACKET_SIZE_MIN 100
 
-typedef struct ASFPayload {
-uint8_t type;
-uint16_t size;
-} ASFPayload;
-
 typedef struct ASFStream {
 int num;
 unsigned char seq;
-/* use for reading */
-AVPacket pkt;
-int frag_offset;
-int packet_obj_size;
-int timestamp;
-int64_t duration;
-int skip_to_key;
-int pkt_clean;
-
-int ds_span;/* descrambling  */
-int ds_packet_size;
-int ds_chunk_size;
-
-int64_t packet_pos;
 
 uint16_t stream_language_index;
-
-int  palette_changed;
-uint32_t palette[256];
-
-int payload_ext_ct;
-ASFPayload payload[8];
 } ASFStream;
 
 typedef struct ASFContext {
-- 
2.30.2

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

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


[FFmpeg-devel] [PATCH 13/34] avformat/mux: Use AVFormatInternal.parse_pkt for temporary packets

2021-09-05 Thread Andreas Rheinhardt
The documentation of said packet ("Every user has to ensure that
this packet is blank after using it") perfectly fits how we use said
packet in the generic muxing code. Better than the documentation of pkt.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/mux.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/mux.c b/libavformat/mux.c
index ea298c1221..7373fcd1a8 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -1174,7 +1174,7 @@ static int write_packets_common(AVFormatContext *s, 
AVPacket *pkt, int interleav
 
 int av_write_frame(AVFormatContext *s, AVPacket *in)
 {
-AVPacket *pkt = s->internal->pkt;
+AVPacket *pkt = s->internal->parse_pkt;
 int ret;
 
 if (!in) {
@@ -1237,8 +1237,8 @@ int av_interleaved_write_frame(AVFormatContext *s, 
AVPacket *pkt)
 
 int av_write_trailer(AVFormatContext *s)
 {
+AVPacket *const pkt = s->internal->parse_pkt;
 int i, ret1, ret = 0;
-AVPacket *pkt = s->internal->pkt;
 
 av_packet_unref(pkt);
 for (i = 0; i < s->nb_streams; i++) {
@@ -1328,7 +1328,7 @@ static void uncoded_frame_free(void *unused, uint8_t 
*data)
 static int write_uncoded_frame_internal(AVFormatContext *s, int stream_index,
 AVFrame *frame, int interleaved)
 {
-AVPacket *pkt = s->internal->pkt;
+AVPacket *pkt = s->internal->parse_pkt;
 
 av_assert0(s->oformat);
 if (!s->oformat->write_uncoded_frame) {
-- 
2.30.2

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

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


[FFmpeg-devel] [PATCH 12/34] avformat/mux: Don't use stack packet when writing interleaved packets

2021-09-05 Thread Andreas Rheinhardt
Currently the interleave_packet functions use a packet for
a new packet to be interleaved (may be NULL if there is none) and
a packet for output; said packet is always a stack packet in
interleaved_write_packet(). But all the interleave_packet functions
in use first move the packet to the packet list and then check whether
a packet can be returned, i.e. the effective lifetime of the new packet
ends before the packet for output is touched.

So one can use one packet both for input and output by adding a new
parameter that indicates whether there is a packet to add to the packet
list; there is just one complication: In case the muxer is flushed,
there is no packet available. This can be solved by reusing one of
the packets from AVFormatInternal. They are currently unused when
flushing in av_interleaved_write_frame().

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/avformat.h | 18 ++---
 libavformat/gxfenc.c   |  7 ---
 libavformat/internal.h | 19 ++---
 libavformat/mux.c  | 46 ++
 libavformat/mxfenc.c   |  9 +
 5 files changed, 50 insertions(+), 49 deletions(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 9b560c15be..7262ce8c5b 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -553,9 +553,21 @@ typedef struct AVOutputFormat {
 /**
  * A format-specific function for interleavement.
  * If unset, packets will be interleaved by dts.
- */
-int (*interleave_packet)(struct AVFormatContext *, AVPacket *out,
- AVPacket *in, int flush);
+ *
+ * @param s   An AVFormatContext for output. pkt will be added to
+ *resp. taken from its packet buffer.
+ * @param[in,out] pkt A packet to be interleaved if has_packet is set;
+ *also used to return packets. If no packet is returned
+ *(e.g. on error), pkt is blank on return.
+ * @param flush   1 if no further packets are available as input and
+ *all remaining packets should be output.
+ * @param has_packet  If set, pkt contains a packet to be interleaved
+ *on input; otherwise pkt is blank on input.
+ * @return 1 if a packet was output, 0 if no packet could be output,
+ * < 0 if an error occurred
+ */
+int (*interleave_packet)(struct AVFormatContext *s, AVPacket *pkt,
+ int flush, int has_packet);
 /**
  * Test if the given codec can be stored in this container.
  *
diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c
index 1a80ecb603..70a911673f 100644
--- a/libavformat/gxfenc.c
+++ b/libavformat/gxfenc.c
@@ -1008,10 +1008,11 @@ static int gxf_compare_field_nb(AVFormatContext *s, 
const AVPacket *next,
 (field_nb[1] == field_nb[0] && sc[1]->order > sc[0]->order);
 }
 
-static int gxf_interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket 
*pkt, int flush)
+static int gxf_interleave_packet(AVFormatContext *s, AVPacket *pkt,
+ int flush, int has_packet)
 {
 int ret;
-if (pkt) {
+if (has_packet) {
 AVStream *st = s->streams[pkt->stream_index];
 GXFStreamContext *sc = st->priv_data;
 if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
@@ -1022,7 +1023,7 @@ static int gxf_interleave_packet(AVFormatContext *s, 
AVPacket *out, AVPacket *pk
 if ((ret = ff_interleave_add_packet(s, pkt, gxf_compare_field_nb)) < 0)
 return ret;
 }
-return ff_interleave_packet_per_dts(s, out, NULL, flush);
+return ff_interleave_packet_per_dts(s, pkt, flush, 0);
 }
 
 const AVOutputFormat ff_gxf_muxer = {
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 9d7312c0e2..c3d0ff6b88 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -102,7 +102,8 @@ struct AVFormatInternal {
 struct PacketList *parse_queue_end;
 /**
  * The generic code uses this as a temporary packet
- * to parse packets; it may also be used for other means
+ * to parse packets or for muxing, especially flushing.
+ * For demuxers, it may also be used for other means
  * for short periods that are guaranteed not to overlap
  * with calls to av_read_frame() (or ff_read_packet())
  * or with each other.
@@ -701,18 +702,10 @@ int ff_add_attached_pic(AVFormatContext *s, AVStream *st, 
AVIOContext *pb,
 
 /**
  * Interleave an AVPacket per dts so it can be muxed.
- *
- * @param s   an AVFormatContext for output. pkt resp. out will be added to
- *resp. taken from its packet buffer.
- * @param out the interleaved packet will be output here
- * @param pkt the input packet; will be blank on return if not NULL
- * @param flush 1 if no further packets are available as input and all
- *  remaining packets should be output
- * @return 1 if a packet was output, 0 if 

Re: [FFmpeg-devel] [PATCH 1/4] libavfilter/x86/vf_hflip: add ff_flip_byte/short_avx512()

2021-09-05 Thread Wu, Jianhua
Ping.

> -Original Message-
> From: Wu, Jianhua 
> Sent: Friday, August 27, 2021 12:52 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Wu, Jianhua 
> Subject: [PATCH 1/4] libavfilter/x86/vf_hflip: add ff_flip_byte/short_avx512()
> 
> Performance(Less is better):
> 8bit:
> ff_hflip_byte_ssse3   0.61
> ff_hflip_byte_avx20.37
> ff_hflip_byte_avx512  0.19
> 16bit:
> ff_hflip_short_ssse3  1.27
> ff_hflip_short_avx2   0.76
> ff_hflip_short_avx512 0.40
> 
> Signed-off-by: Wu Jianhua 
> ---
>  libavfilter/x86/vf_hflip.asm| 23 ++-
>  libavfilter/x86/vf_hflip_init.c |  8 
>  2 files changed, 26 insertions(+), 5 deletions(-)
> 
> diff --git a/libavfilter/x86/vf_hflip.asm b/libavfilter/x86/vf_hflip.asm index
> 285618954f..c2237217f7 100644
> --- a/libavfilter/x86/vf_hflip.asm
> +++ b/libavfilter/x86/vf_hflip.asm
> @@ -26,12 +26,16 @@ SECTION_RODATA
> 
>  pb_flip_byte:  db 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0
>  pb_flip_short: db 14,15,12,13,10,11,8,9,6,7,4,5,2,3,0,1
> +pd_flip_indicies: dd 12,13,14,15,8,9,10,11,4,5,6,7,0,1,2,3
> 
>  SECTION .text
> 
>  ;%1 byte or short, %2 b or w, %3 size in byte (1 for byte, 2 for short)  
> %macro
> HFLIP 3  cglobal hflip_%1, 3, 5, 3, src, dst, w, r, x
> +%if mmsize == 64
> +movu  m3, [pd_flip_indicies]
> +%endif
>  VBROADCASTI128m0, [pb_flip_%1]
>  xor   xq, xq
>  %if %3 == 1
> @@ -47,12 +51,15 @@ cglobal hflip_%1, 3, 5, 3, src, dst, w, r, x
> 
>  .loop0:
>  neg xq
> -%if mmsize == 32
> -vpermq  m1, [srcq + xq - mmsize + %3], 0x4e; flip each lane at 
> load
> -vpermq  m2, [srcq + xq - 2 * mmsize + %3], 0x4e; flip each lane at 
> load
> +%if   mmsize == 64
> +vpermd  m1, m3, [srcq + xq - mmsize + %3]
> +vpermd  m2, m3, [srcq + xq - 2 * mmsize + %3] %elif mmsize ==
> +32
> +vpermq  m1, [srcq + xq - mmsize + %3], 0x4e; flip each lane 
> at load
> +vpermq  m2, [srcq + xq - 2 * mmsize + %3], 0x4e; flip each lane 
> at load
>  %else
> -movum1, [srcq + xq - mmsize + %3]
> -movum2, [srcq + xq - 2 * mmsize + %3]
> +movum1, [srcq + xq - mmsize + %3]
> +movum2, [srcq + xq - 2 * mmsize + %3]
>  %endif
>  pshufb  m1, m0
>  pshufb  m2, m0
> @@ -88,3 +95,9 @@ INIT_YMM avx2
>  HFLIP byte, b, 1
>  HFLIP short, w, 2
>  %endif
> +
> +%if HAVE_AVX512_EXTERNAL
> +INIT_ZMM avx512
> +HFLIP byte, b, 1
> +HFLIP short, w, 2
> +%endif
> diff --git a/libavfilter/x86/vf_hflip_init.c 
> b/libavfilter/x86/vf_hflip_init.c index
> 0ac399b0d4..25fc40f7b0 100644
> --- a/libavfilter/x86/vf_hflip_init.c
> +++ b/libavfilter/x86/vf_hflip_init.c
> @@ -25,8 +25,10 @@
> 
>  void ff_hflip_byte_ssse3(const uint8_t *src, uint8_t *dst, int w);  void
> ff_hflip_byte_avx2(const uint8_t *src, uint8_t *dst, int w);
> +void ff_hflip_byte_avx512(const uint8_t *src, uint8_t *dst, int w);
>  void ff_hflip_short_ssse3(const uint8_t *src, uint8_t *dst, int w);  void
> ff_hflip_short_avx2(const uint8_t *src, uint8_t *dst, int w);
> +void ff_hflip_short_avx512(const uint8_t *src, uint8_t *dst, int w);
> 
>  av_cold void ff_hflip_init_x86(FlipContext *s, int step[4], int nb_planes)
> { @@ -41,6 +43,9 @@ av_cold void ff_hflip_init_x86(FlipContext *s, int
> step[4], int nb_planes)
>  if (EXTERNAL_AVX2_FAST(cpu_flags)) {
>  s->flip_line[i] = ff_hflip_byte_avx2;
>  }
> +if (EXTERNAL_AVX512(cpu_flags)) {
> +s->flip_line[i] = ff_hflip_byte_avx512;
> +}
>  } else if (step[i] == 2) {
>  if (EXTERNAL_SSSE3(cpu_flags)) {
>  s->flip_line[i] = ff_hflip_short_ssse3; @@ -48,6 +53,9 @@ 
> av_cold
> void ff_hflip_init_x86(FlipContext *s, int step[4], int nb_planes)
>  if (EXTERNAL_AVX2_FAST(cpu_flags)) {
>  s->flip_line[i] = ff_hflip_short_avx2;
>  }
> +if (EXTERNAL_AVX512(cpu_flags)) {
> +s->flip_line[i] = ff_hflip_short_avx512;
> +}
>  }
>  }
>  }
> --
> 2.17.1

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

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


[FFmpeg-devel] [PATCH v2 2/4] avcodec/nvenc: Add intra refresh support

2021-09-05 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/nvenc.c  | 32 +++-
 libavcodec/nvenc.h  |  1 +
 libavcodec/nvenc_h264.c |  2 ++
 libavcodec/nvenc_hevc.c |  2 ++
 4 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 163d442..a298549 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -529,6 +529,12 @@ static int nvenc_check_capabilities(AVCodecContext *avctx)
 }
 #endif
 
+ret = nvenc_check_cap(avctx, NV_ENC_CAPS_SUPPORT_INTRA_REFRESH);
+if(ctx->intra_refresh && ret <= 0) {
+av_log(avctx, AV_LOG_WARNING, "Intra refresh not supported by the 
device\n");
+return AVERROR(ENOSYS);
+}
+
 ctx->support_dyn_bitrate = nvenc_check_cap(avctx, 
NV_ENC_CAPS_SUPPORT_DYN_BITRATE_CHANGE);
 
 return 0;
@@ -1076,6 +1082,12 @@ static av_cold int 
nvenc_setup_h264_config(AVCodecContext *avctx)
 h264->sliceMode = 3;
 h264->sliceModeData = avctx->slices > 0 ? avctx->slices : 1;
 
+if (ctx->intra_refresh) {
+h264->enableIntraRefresh = 1;
+h264->intraRefreshPeriod = avctx->gop_size;
+h264->intraRefreshCnt = avctx->gop_size - 1;
+}
+
 h264->disableSPSPPS = (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0;
 h264->repeatSPSPPS  = (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) ? 0 : 1;
 h264->outputAUD = ctx->aud;
@@ -1084,8 +1096,10 @@ static av_cold int 
nvenc_setup_h264_config(AVCodecContext *avctx)
 /* 0 means "let the hardware decide" */
 h264->maxNumRefFrames = ctx->dpb_size;
 }
-if (avctx->gop_size >= 0) {
-h264->idrPeriod = cc->gopLength;
+if (ctx->intra_refresh) {
+h264->idrPeriod = NVENC_INFINITE_GOPLENGTH;
+} else if (avctx->gop_size >= 0) {
+h264->idrPeriod = avctx->gop_size;
 }
 
 if (IS_CBR(cc->rcParams.rateControlMode)) {
@@ -1173,6 +1187,12 @@ static av_cold int 
nvenc_setup_hevc_config(AVCodecContext *avctx)
 hevc->sliceMode = 3;
 hevc->sliceModeData = avctx->slices > 0 ? avctx->slices : 1;
 
+if (ctx->intra_refresh) {
+hevc->enableIntraRefresh = 1;
+hevc->intraRefreshPeriod = avctx->gop_size;
+hevc->intraRefreshCnt = avctx->gop_size - 1;
+}
+
 hevc->disableSPSPPS = (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0;
 hevc->repeatSPSPPS  = (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) ? 0 : 1;
 hevc->outputAUD = ctx->aud;
@@ -1181,8 +1201,10 @@ static av_cold int 
nvenc_setup_hevc_config(AVCodecContext *avctx)
 /* 0 means "let the hardware decide" */
 hevc->maxNumRefFramesInDPB = ctx->dpb_size;
 }
-if (avctx->gop_size >= 0) {
-hevc->idrPeriod = cc->gopLength;
+if (ctx->intra_refresh) {
+hevc->idrPeriod = NVENC_INFINITE_GOPLENGTH;
+} else if (avctx->gop_size >= 0) {
+hevc->idrPeriod = avctx->gop_size;
 }
 
 if (IS_CBR(cc->rcParams.rateControlMode)) {
@@ -1361,7 +1383,7 @@ static av_cold int nvenc_setup_encoder(AVCodecContext 
*avctx)
 ctx->encode_config.frameIntervalP = avctx->max_b_frames + 1;
 }
 
-ctx->encode_config.gopLength = avctx->gop_size;
+ctx->encode_config.gopLength = ctx->intra_refresh ? 
NVENC_INFINITE_GOPLENGTH : avctx->gop_size;
 } else if (avctx->gop_size == 0) {
 ctx->encode_config.frameIntervalP = 0;
 ctx->encode_config.gopLength = 1;
diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h
index 7c284fb..e7cc0e6 100644
--- a/libavcodec/nvenc.h
+++ b/libavcodec/nvenc.h
@@ -230,6 +230,7 @@ typedef struct NvencContext
 int multipass;
 int ldkfs;
 int extra_sei;
+int intra_refresh;
 } NvencContext;
 
 int ff_nvenc_encode_init(AVCodecContext *avctx);
diff --git a/libavcodec/nvenc_h264.c b/libavcodec/nvenc_h264.c
index fffdedc..532dff3 100644
--- a/libavcodec/nvenc_h264.c
+++ b/libavcodec/nvenc_h264.c
@@ -188,6 +188,8 @@ static const AVOption options[] = {
 #endif
 { "extra_sei","Pass on extra SEI data (e.g. a53 cc) to be included in 
the bitstream",
 OFFSET(extra_sei), 
   AV_OPT_TYPE_BOOL,  { .i64 = 1 }, 0, 1, VE },
+{ "intra_refresh", "Use Periodic Intra Refresh instead of IDR frames.",
+
OFFSET(intra_refresh),AV_OPT_TYPE_BOOL,  { .i64 = 0 }, 0, 1, VE },
 { NULL }
 };
 
diff --git a/libavcodec/nvenc_hevc.c b/libavcodec/nvenc_hevc.c
index 4edc179..6814fe1 100644
--- a/libavcodec/nvenc_hevc.c
+++ b/libavcodec/nvenc_hevc.c
@@ -169,6 +169,8 @@ static const AVOption options[] = {
 #endif
 { "extra_sei","Pass on extra SEI data (e.g. a53 cc) to be included in 
the bitstream",
 OFFSET(extra_sei), 
   AV_OPT_TYPE_BOOL,  { .i64 = 1 }, 0, 1, VE },
+{ "intra_refresh", "Use Periodic Intra Refresh instead of IDR frames.",
+ 

Re: [FFmpeg-devel] [V2 08/10] libavutil/hwcontext_vulkan: fix wrong offset of plane

2021-09-05 Thread Chen, Wenbin
> -Original Message-
> From: Lynne 
> Sent: Wednesday, September 1, 2021 7:33 PM
> To: Chen, Wenbin 
> Subject: RE: [FFmpeg-devel] [V2 08/10] libavutil/hwcontext_vulkan: fix wrong
> offset of plane
> 
> 1 Sept 2021, 03:40 by wenbin.c...@intel.com:
> 
> >
> >
> >> -Original Message-
> >> From: ffmpeg-devel  On Behalf Of
> >> Lynne
> >> Sent: Tuesday, August 31, 2021 7:42 PM
> >> To: FFmpeg development discussions and patches  >> de...@ffmpeg.org>
> >> Subject: Re: [FFmpeg-devel] [V2 08/10] libavutil/hwcontext_vulkan: fix
> wrong
> >> offset of plane
> >>
> >> 31 Aug 2021, 09:24 by wenbin.c...@intel.com:
> >>
> >> > According to spec, if we use VkBindImagePlaneMemoryInfo to bind
> image
> >> > we mush create image with disjoint flag.
> >> > The offset in subresourcelayout is relative to the base address of
> >> > the plane, but the offset in drm is relative to the drm objectis so
> >> > I think this offset should be 0.
> >> > Also, when I import vaapi frame to vulkan I got broken frame, and
> >> > setting plane_data->offset to 0 makes command works.
> >> >
> >> > Signed-off-by: Wenbin Chen 
> >> >
> >>
> >> I don't quite get the point of this. Is there some situation where
> >> clients may want to change the modifier of the image they're allocating,
> >> like maybe use a different modifier when allocating images that would
> >> be used as framebuffers to be presented?
> >>
> >
> > Maybe you reply to the wrong patch? I assume you want to reply to the 9th
> patch.
> > " specify the modifier to create VKImage".
> > I tried on the latest intel driver. The log recommend to use linear or
> drmModifier to create image.
> > Also if I use optimal to create image, the export drm modifier is unknown.
> >
> 
> Linear is almost never optimal. Could you post a link to the recommendation?
> The DRM modifier is known for optimal, there's a Vulkan API to retrieve
> image modifiers.

This restriction is for VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT.

I get recommendation information from here.
https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/src/intel/vulkan/anv_formats.c#L1412
If I use optimal to create VkImage, the modifier I get from 
VkGetImageDrmFormatModifierPropertiesExt() 
is DRM_FORMAT_MOD_INVALID.
I tested this on Intel platform, and I see AMD has this restriction as well.
https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/src/amd/vulkan/radv_formats.c#L1530
 

___
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] libavcodec/libx264: add user data unregistered SEI encoding

2021-09-05 Thread Brad Hards
On Sunday, 22 August 2021 7:25:25 PM AEST Brad Hards wrote:
> On Saturday, 14 August 2021 9:51:03 AM AEST Brad Hards wrote:
> > On Friday, 6 August 2021 7:16:33 PM AEST Brad Hards wrote:
> > > MISB ST 0604 and ST 2101 require user data unregistered SEI messages
> > > (precision timestamps and sensor identifiers) to be included. That
> > > currently isn't supported for libx264. This patch adds support
> > > for user data unregistered SEI messages in accordance with ISO/IEC
> > > 14496-10:2020(E) section D.1.7 (syntax) and D.2.7 (semantics).
> > > 
> > > This code is based on a similar change for libx265 (commit
> > > 1f58503013720700a5adfd72c708e6275aefc165).
> > > ---
> > > 
> > >  libavcodec/libx264.c | 30 ++
> > >  1 file changed, 30 insertions(+)
> > > 
> > > diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
> > > index 9afaf19547..e9bbe8d494 100644
> > > --- a/libavcodec/libx264.c
> > > +++ b/libavcodec/libx264.c
> > > @@ -32,6 +32,7 @@
> > > 
> > >  #include "internal.h"
> > >  #include "packet_internal.h"
> > >  #include "atsc_a53.h"
> > > 
> > > +#include "sei.h"
> > > 
> > >  #if defined(_MSC_VER)
> > >  #define X264_API_IMPORTS 1
> > > 
> > > @@ -114,6 +115,9 @@ typedef struct X264Context {
> > > 
> > >   * encounter a frame with ROI side data.
> > >   */
> > >  
> > >  int roi_warned;
> > > 
> > > +
> > > +void *sei_data;
> > > +int sei_data_size;
> > > 
> > >  } X264Context;
> > >  
> > >  static void X264_log(void *p, int level, const char *fmt, va_list args)
> > > 
> > > @@ -317,6 +321,9 @@ static int X264_frame(AVCodecContext *ctx, AVPacket
> > > *pkt, const AVFrame *frame,>
> > > 
> > >  x4->pic.img.i_plane = avfmt2_num_planes(ctx->pix_fmt);
> > >  
> > >  if (frame) {
> > > 
> > > +x264_sei_t *sei = >pic.extra_sei;
> > > +sei->num_payloads = 0;
> > > +
> > > 
> > >  for (i = 0; i < x4->pic.img.i_plane; i++) {
> > >  
> > >  x4->pic.img.plane[i]= frame->data[i];
> > >  x4->pic.img.i_stride[i] = frame->linesize[i];
> > > 
> > > @@ -439,6 +446,27 @@ static int X264_frame(AVCodecContext *ctx, AVPacket
> > > *pkt, const AVFrame *frame,>
> > > 
> > >  }
> > >  
> > >  }
> > >  
> > >  }
> > > 
> > > +
> > > +for (int j = 0; j < frame->nb_side_data; j++) {
> > > +AVFrameSideData *side_data = frame->side_data[j];
> > > +void *tmp;
> > > +x264_sei_payload_t *sei_payload;
> > > +if (side_data->type != AV_FRAME_DATA_SEI_UNREGISTERED)
> > > +continue;
> > > +tmp = av_fast_realloc(x4->sei_data, >sei_data_size,
> > > (sei->num_payloads + 1) * sizeof(*sei_payload)); +if (!tmp)
> > > {
> > > +av_freep(>pic.extra_sei.payloads);
> > > +av_freep(>pic.prop.quant_offsets);
> > > +return AVERROR(ENOMEM);
> > > +}
> > > +x4->sei_data = tmp;
> > > +sei->payloads = x4->sei_data;
> > > +sei_payload = >payloads[sei->num_payloads];
> > > +sei_payload->payload = side_data->data;
> > > +sei_payload->payload_size = side_data->size;
> > > +sei_payload->payload_type =
> > > SEI_TYPE_USER_DATA_UNREGISTERED;
> > > +sei->num_payloads++;
> > > +}
> > > 
> > >  }
> > >  
> > >  do {
> > > 
> > > @@ -505,6 +533,8 @@ static av_cold int X264_close(AVCodecContext *avctx)
> > > 
> > >  x264_param_cleanup(>params);
> > >  
> > >  #endif
> > > 
> > > +av_freep(>sei_data);
> > > +
> > > 
> > >  if (x4->enc) {
> > >  
> > >  x264_encoder_close(x4->enc);
> > >  x4->enc = NULL;
> > 
> > Ping on this patch.
> 
> Ping on this patch.
Ping on this patch.

Brad



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

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


Re: [FFmpeg-devel] [PATCH 4/4] avcodec/xpmdec: Move allocations down after more error checks

2021-09-05 Thread Michael Niedermayer
On Fri, Sep 03, 2021 at 08:51:23PM +0200, Paul B Mahol wrote:
> probably fine

will apply

thx

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

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin


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/4] avcodec/argo: Move U, fix shift

2021-09-05 Thread Michael Niedermayer
On Fri, Sep 03, 2021 at 08:50:27PM +0200, Paul B Mahol wrote:
> lgtm

will apply

thx

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

Observe your enemies, for they first find out your faults. -- Antisthenes


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 4/4] avcodec/jpeg2000dec: Check that atom header is within bytsetream

2021-09-05 Thread Michael Niedermayer
On Sun, Sep 05, 2021 at 09:27:08PM +0200, Paul B Mahol wrote:
> lgtm

will apply

thx

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

The worst form of inequality is to try to make unequal things equal.
-- Aristotle


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

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


Re: [FFmpeg-devel] [PATCH 2/4] avcodec/apedec: Fix 2 integer overflows in filter_3800()

2021-09-05 Thread Michael Niedermayer
On Sun, Sep 05, 2021 at 09:35:19PM +0200, Paul B Mahol wrote:
> lgtm

will apply

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin


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] avfilter/avfilter: Fix hardcoded input index

2021-09-05 Thread Soft Works



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Paul B Mahol
> Sent: Sunday, 5 September 2021 22:06
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH] avfilter/avfilter: Fix hardcoded
> input index
> 
> On Sun, Sep 5, 2021 at 9:56 PM Soft Works 
> wrote:
> 
> >
> >
> > > -Original Message-
> > > From: ffmpeg-devel  On Behalf Of
> > > Paul B Mahol
> > > Sent: Sunday, 5 September 2021 21:51
> > > To: FFmpeg development discussions and patches  > > de...@ffmpeg.org>
> > > Subject: Re: [FFmpeg-devel] [PATCH] avfilter/avfilter: Fix
> hardcoded
> > > input index
> > >
> > > On Sun, Sep 5, 2021 at 9:44 PM Soft Works 
> > > wrote:
> > >
> > > >
> > > >
> > > > > -Original Message-
> > > > > From: ffmpeg-devel  On
> Behalf Of
> > > > > Soft Works
> > > > > Sent: Sunday, 5 September 2021 16:59
> > > > > To: FFmpeg development discussions and patches  > > > > de...@ffmpeg.org>
> > > > > Subject: Re: [FFmpeg-devel] [PATCH] avfilter/avfilter: Fix
> > > hardcoded
> > > > > input index
> > > > >
> > > > >
> > > > >
> > > > > > -Original Message-
> > > > > > From: ffmpeg-devel  On
> Behalf
> > > Of
> > > > > > Paul B Mahol
> > > > > > Sent: Sunday, 5 September 2021 11:01
> > > > > > To: FFmpeg development discussions and patches  > > > > > de...@ffmpeg.org>
> > > > > > Subject: Re: [FFmpeg-devel] [PATCH] avfilter/avfilter: Fix
> > > > > hardcoded
> > > > > > input index
> > > > > >
> > > > > > With what filters this happens?
> > > > > >
> > > > > > IIUC this is forbidden and such filters should use
> .activate
> > > > > instead.
> > > > >
> > > > > The hardcoded [0] is wrong, no matter what the use case is.
> > > > >
> > > > > But to answer your question: It's about a new
> overlay_textsubs
> > > filter
> > > > > where framesync cannot be used and incoming frames (video on
> > > input0,
> > > > > subs on input1) need to be processed independently: the
> subtitle
> > > > > events
> > > > > are fed into the ass library (you could practically feed all
> > > events
> > > > > in advance) while the overlay image generation is done based
> on a
> > > > > given
> > > > > time code.
> > > > > This works fine by having a separate .filter_frame function
> for
> > > each
> > > > > input (after applying this patch).
> > > >
> > > > BTW
> > > >
> > > > > > IIUC this is forbidden and such filters should use
> .activate
> > > >
> > > > The scale2ref filter is set up in the same way (two
> .filter_frame
> > > > functions, no .activate, no framesync), probably because - like
> in
> > > > my case - the filter must not sync frames across inputs.
> > > >
> > >
> > > FYI .activate does not sync frames across inputs.
> >
> > Thanks for the information, I wasn't aware of that; so far I had
> always
> > seen it used in combination with framesync, do you know an example
> > where it's being used without framesync?
> >
> 
> Numerous examples across code base, grep for .activate.

Grep (lol..) - I asked because I thought you might 
have an example in mind that would be similar to the discussed case.
Nevermind, I'll find one..

But if you don't mind, could you please elaborate on why .activate 
would be a preferred approach when input frame processing is
meant to be totally independent between two inputs?`

Thanks,
softworkz



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

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


Re: [FFmpeg-devel] [PATCH] avfilter/avfilter: Fix hardcoded input index

2021-09-05 Thread Paul B Mahol
On Sun, Sep 5, 2021 at 9:56 PM Soft Works  wrote:

>
>
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > Paul B Mahol
> > Sent: Sunday, 5 September 2021 21:51
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>
> > Subject: Re: [FFmpeg-devel] [PATCH] avfilter/avfilter: Fix hardcoded
> > input index
> >
> > On Sun, Sep 5, 2021 at 9:44 PM Soft Works 
> > wrote:
> >
> > >
> > >
> > > > -Original Message-
> > > > From: ffmpeg-devel  On Behalf Of
> > > > Soft Works
> > > > Sent: Sunday, 5 September 2021 16:59
> > > > To: FFmpeg development discussions and patches  > > > de...@ffmpeg.org>
> > > > Subject: Re: [FFmpeg-devel] [PATCH] avfilter/avfilter: Fix
> > hardcoded
> > > > input index
> > > >
> > > >
> > > >
> > > > > -Original Message-
> > > > > From: ffmpeg-devel  On Behalf
> > Of
> > > > > Paul B Mahol
> > > > > Sent: Sunday, 5 September 2021 11:01
> > > > > To: FFmpeg development discussions and patches  > > > > de...@ffmpeg.org>
> > > > > Subject: Re: [FFmpeg-devel] [PATCH] avfilter/avfilter: Fix
> > > > hardcoded
> > > > > input index
> > > > >
> > > > > With what filters this happens?
> > > > >
> > > > > IIUC this is forbidden and such filters should use .activate
> > > > instead.
> > > >
> > > > The hardcoded [0] is wrong, no matter what the use case is.
> > > >
> > > > But to answer your question: It's about a new overlay_textsubs
> > filter
> > > > where framesync cannot be used and incoming frames (video on
> > input0,
> > > > subs on input1) need to be processed independently: the subtitle
> > > > events
> > > > are fed into the ass library (you could practically feed all
> > events
> > > > in advance) while the overlay image generation is done based on a
> > > > given
> > > > time code.
> > > > This works fine by having a separate .filter_frame function for
> > each
> > > > input (after applying this patch).
> > >
> > > BTW
> > >
> > > > > IIUC this is forbidden and such filters should use .activate
> > >
> > > The scale2ref filter is set up in the same way (two .filter_frame
> > > functions, no .activate, no framesync), probably because - like in
> > > my case - the filter must not sync frames across inputs.
> > >
> >
> > FYI .activate does not sync frames across inputs.
>
> Thanks for the information, I wasn't aware of that; so far I had always
> seen it used in combination with framesync, do you know an example
> where it's being used without framesync?
>

Numerous examples across code base, grep for .activate.


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

2021-09-05 Thread Soft Works



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Paul B Mahol
> Sent: Sunday, 5 September 2021 21:51
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH] avfilter/avfilter: Fix hardcoded
> input index
> 
> On Sun, Sep 5, 2021 at 9:44 PM Soft Works 
> wrote:
> 
> >
> >
> > > -Original Message-
> > > From: ffmpeg-devel  On Behalf Of
> > > Soft Works
> > > Sent: Sunday, 5 September 2021 16:59
> > > To: FFmpeg development discussions and patches  > > de...@ffmpeg.org>
> > > Subject: Re: [FFmpeg-devel] [PATCH] avfilter/avfilter: Fix
> hardcoded
> > > input index
> > >
> > >
> > >
> > > > -Original Message-
> > > > From: ffmpeg-devel  On Behalf
> Of
> > > > Paul B Mahol
> > > > Sent: Sunday, 5 September 2021 11:01
> > > > To: FFmpeg development discussions and patches  > > > de...@ffmpeg.org>
> > > > Subject: Re: [FFmpeg-devel] [PATCH] avfilter/avfilter: Fix
> > > hardcoded
> > > > input index
> > > >
> > > > With what filters this happens?
> > > >
> > > > IIUC this is forbidden and such filters should use .activate
> > > instead.
> > >
> > > The hardcoded [0] is wrong, no matter what the use case is.
> > >
> > > But to answer your question: It's about a new overlay_textsubs
> filter
> > > where framesync cannot be used and incoming frames (video on
> input0,
> > > subs on input1) need to be processed independently: the subtitle
> > > events
> > > are fed into the ass library (you could practically feed all
> events
> > > in advance) while the overlay image generation is done based on a
> > > given
> > > time code.
> > > This works fine by having a separate .filter_frame function for
> each
> > > input (after applying this patch).
> >
> > BTW
> >
> > > > IIUC this is forbidden and such filters should use .activate
> >
> > The scale2ref filter is set up in the same way (two .filter_frame
> > functions, no .activate, no framesync), probably because - like in
> > my case - the filter must not sync frames across inputs.
> >
> 
> FYI .activate does not sync frames across inputs.

Thanks for the information, I wasn't aware of that; so far I had always
seen it used in combination with framesync, do you know an example
where it's being used without framesync?

Thanks,
softworkz




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

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


Re: [FFmpeg-devel] [PATCH 3/4] avcodec/h264_parser: Fix nalsize check

2021-09-05 Thread Andreas Rheinhardt
Michael Niedermayer:
> Fixes: Assertion failure
> Fixes: 
> 37463/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-4914693494931456
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/h264_parser.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
> index 01ea016409..47cc1d5c78 100644
> --- a/libavcodec/h264_parser.c
> +++ b/libavcodec/h264_parser.c
> @@ -87,7 +87,7 @@ static int h264_find_frame_end(H264ParseContext *p, const 
> uint8_t *buf,
>  i = next_avc;
>  for (j = 0; j < p->nal_length_size; j++)
>  nalsize = (nalsize << 8) | buf[i++];
> -if (!nalsize || nalsize > buf_size - i) {
> +if (!nalsize || i > buf_size || nalsize > buf_size - i) {
>  av_log(logctx, AV_LOG_ERROR, "AVC-parser: nal size %"PRIu32" 
> "
> "remaining %d\n", nalsize, buf_size - i);
>  return buf_size;
> 
The cheapest fix for this is to make nalsize int64_t. But actually this
whole code looks highly weird: In contrast to how the parsing API is
supposed to be, it requires the whole buffer being available, despite
the PARSER_FLAG_COMPLETE_FRAMES being unset.

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

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


Re: [FFmpeg-devel] [PATCH] avfilter/avfilter: Fix hardcoded input index

2021-09-05 Thread Paul B Mahol
On Sun, Sep 5, 2021 at 9:44 PM Soft Works  wrote:

>
>
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > Soft Works
> > Sent: Sunday, 5 September 2021 16:59
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>
> > Subject: Re: [FFmpeg-devel] [PATCH] avfilter/avfilter: Fix hardcoded
> > input index
> >
> >
> >
> > > -Original Message-
> > > From: ffmpeg-devel  On Behalf Of
> > > Paul B Mahol
> > > Sent: Sunday, 5 September 2021 11:01
> > > To: FFmpeg development discussions and patches  > > de...@ffmpeg.org>
> > > Subject: Re: [FFmpeg-devel] [PATCH] avfilter/avfilter: Fix
> > hardcoded
> > > input index
> > >
> > > With what filters this happens?
> > >
> > > IIUC this is forbidden and such filters should use .activate
> > instead.
> >
> > The hardcoded [0] is wrong, no matter what the use case is.
> >
> > But to answer your question: It's about a new overlay_textsubs filter
> > where framesync cannot be used and incoming frames (video on input0,
> > subs on input1) need to be processed independently: the subtitle
> > events
> > are fed into the ass library (you could practically feed all events
> > in advance) while the overlay image generation is done based on a
> > given
> > time code.
> > This works fine by having a separate .filter_frame function for each
> > input (after applying this patch).
>
> BTW
>
> > > IIUC this is forbidden and such filters should use .activate
>
> The scale2ref filter is set up in the same way (two .filter_frame
> functions, no .activate, no framesync), probably because - like in
> my case - the filter must not sync frames across inputs.
>

FYI .activate does not sync frames across inputs.


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

2021-09-05 Thread Soft Works



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Soft Works
> Sent: Sunday, 5 September 2021 16:59
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH] avfilter/avfilter: Fix hardcoded
> input index
> 
> 
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > Paul B Mahol
> > Sent: Sunday, 5 September 2021 11:01
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>
> > Subject: Re: [FFmpeg-devel] [PATCH] avfilter/avfilter: Fix
> hardcoded
> > input index
> >
> > With what filters this happens?
> >
> > IIUC this is forbidden and such filters should use .activate
> instead.
> 
> The hardcoded [0] is wrong, no matter what the use case is.
> 
> But to answer your question: It's about a new overlay_textsubs filter
> where framesync cannot be used and incoming frames (video on input0,
> subs on input1) need to be processed independently: the subtitle
> events
> are fed into the ass library (you could practically feed all events
> in advance) while the overlay image generation is done based on a
> given
> time code.
> This works fine by having a separate .filter_frame function for each
> input (after applying this patch).

BTW

> > IIUC this is forbidden and such filters should use .activate

The scale2ref filter is set up in the same way (two .filter_frame
functions, no .activate, no framesync), probably because - like in 
my case - the filter must not sync frames across inputs.

softworkz


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

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


Re: [FFmpeg-devel] [PATCH 2/4] avcodec/apedec: Fix 2 integer overflows in filter_3800()

2021-09-05 Thread Paul B Mahol
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 2/4] avcodec/apedec: Fix 2 integer overflows in filter_3800()

2021-09-05 Thread Michael Niedermayer
Fixes: signed integer overflow: 1683879955 - -466265224 cannot be represented 
in type 'int'
Fixes: 
37419/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-6074294407921664

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

diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index 022a6f9398..bf481ba354 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -909,8 +909,8 @@ static av_always_inline int filter_3800(APEPredictor *p,
 return predictionA;
 }
 d2 =  p->buf[delayA];
-d1 = (p->buf[delayA] - p->buf[delayA - 1]) * 2U;
-d0 =  p->buf[delayA] + ((p->buf[delayA - 2] - p->buf[delayA - 1]) * 8U);
+d1 = (p->buf[delayA] - (unsigned)p->buf[delayA - 1]) * 2;
+d0 =  p->buf[delayA] + ((p->buf[delayA - 2] - (unsigned)p->buf[delayA - 
1]) * 8);
 d3 =  p->buf[delayB] * 2U - p->buf[delayB - 1];
 d4 =  p->buf[delayB];
 
-- 
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 4/4] avcodec/jpeg2000dec: Check that atom header is within bytsetream

2021-09-05 Thread Paul B Mahol
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 4/4] avcodec/jpeg2000dec: Check that atom header is within bytsetream

2021-09-05 Thread Michael Niedermayer
Fixes: Infinite loop
Fixes: 
3/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5912760671141888

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

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index e62f7b19e6..c95f22bc90 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -2360,6 +2360,8 @@ static int jp2_find_codestream(Jpeg2000DecoderContext *s)
atom_size >= 16) {
 uint32_t atom2_size, atom2, atom2_end;
 do {
+if (bytestream2_get_bytes_left(>g) < 8)
+break;
 atom2_size = bytestream2_get_be32u(>g);
 atom2  = bytestream2_get_be32u(>g);
 atom2_end  = bytestream2_tell(>g) + atom2_size - 8;
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH 3/4] avcodec/h264_parser: Fix nalsize check

2021-09-05 Thread Michael Niedermayer
Fixes: Assertion failure
Fixes: 
37463/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-4914693494931456

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

diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index 01ea016409..47cc1d5c78 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -87,7 +87,7 @@ static int h264_find_frame_end(H264ParseContext *p, const 
uint8_t *buf,
 i = next_avc;
 for (j = 0; j < p->nal_length_size; j++)
 nalsize = (nalsize << 8) | buf[i++];
-if (!nalsize || nalsize > buf_size - i) {
+if (!nalsize || i > buf_size || nalsize > buf_size - i) {
 av_log(logctx, AV_LOG_ERROR, "AVC-parser: nal size %"PRIu32" "
"remaining %d\n", nalsize, buf_size - i);
 return buf_size;
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH 1/4] avformat/mxfdec: check channel number in mxf_get_d10_aes3_packet()

2021-09-05 Thread Michael Niedermayer
Fixes: Out of array access
Fixes: 
37030/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5387719147651072

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

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 55f2e5c767..ebe411b04d 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -552,6 +552,10 @@ static int mxf_get_d10_aes3_packet(AVIOContext *pb, 
AVStream *st, AVPacket *pkt,
 data_ptr = pkt->data;
 end_ptr = pkt->data + length;
 buf_ptr = pkt->data + 4; /* skip SMPTE 331M header */
+
+if (st->codecpar->channels > 8)
+return AVERROR_INVALIDDATA;
+
 for (; end_ptr - buf_ptr >= st->codecpar->channels * 4; ) {
 for (i = 0; i < st->codecpar->channels; i++) {
 uint32_t sample = bytestream_get_le32(_ptr);
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH] avformat/mlpdec: fix time_base for packet timestamps

2021-09-05 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavformat/mlpdec.c | 43 ---
 1 file changed, 40 insertions(+), 3 deletions(-)

diff --git a/libavformat/mlpdec.c b/libavformat/mlpdec.c
index 8f0aabb510..f0996fef31 100644
--- a/libavformat/mlpdec.c
+++ b/libavformat/mlpdec.c
@@ -22,8 +22,12 @@
  */
 
 #include "avformat.h"
+#include "avio_internal.h"
+#include "internal.h"
 #include "rawdec.h"
 #include "libavutil/intreadwrite.h"
+#include "libavcodec/mlp.h"
+#include "libavcodec/mlp_parse.h"
 
 static int av_always_inline mlp_thd_probe(const AVProbeData *p, uint32_t sync)
 {
@@ -50,6 +54,40 @@ static int av_always_inline mlp_thd_probe(const AVProbeData 
*p, uint32_t sync)
 return 0;
 }
 
+static int mlp_read_header(AVFormatContext *s)
+{
+int ret = ff_raw_audio_read_header(s);
+
+if (ret < 0)
+return ret;
+
+ret = ffio_ensure_seekback(s->pb, 10);
+if (ret == 0) {
+uint8_t buffer[10];
+int read, sample_rate = 0;
+
+read = avio_read(s->pb, buffer, 10);
+if (read == 10) {
+switch (buffer[7]) {
+case SYNC_TRUEHD:
+sample_rate = mlp_samplerate(buffer[8] >> 4);
+break;
+case SYNC_MLP:
+sample_rate = mlp_samplerate(buffer[9] >> 4);
+break;
+}
+
+if (sample_rate)
+avpriv_set_pts_info(s->streams[0], 64, 1, sample_rate);
+}
+
+if (read > 0)
+avio_seek(s->pb, -read, SEEK_CUR);
+}
+
+return 0;
+}
+
 #if CONFIG_MLP_DEMUXER
 static int mlp_probe(const AVProbeData *p)
 {
@@ -60,7 +98,7 @@ const AVInputFormat ff_mlp_demuxer = {
 .name   = "mlp",
 .long_name  = NULL_IF_CONFIG_SMALL("raw MLP"),
 .read_probe = mlp_probe,
-.read_header= ff_raw_audio_read_header,
+.read_header= mlp_read_header,
 .read_packet= ff_raw_read_partial_packet,
 .flags  = AVFMT_GENERIC_INDEX | AVFMT_NOTIMESTAMPS,
 .extensions = "mlp",
@@ -80,7 +118,7 @@ const AVInputFormat ff_truehd_demuxer = {
 .name   = "truehd",
 .long_name  = NULL_IF_CONFIG_SMALL("raw TrueHD"),
 .read_probe = thd_probe,
-.read_header= ff_raw_audio_read_header,
+.read_header= mlp_read_header,
 .read_packet= ff_raw_read_partial_packet,
 .flags  = AVFMT_GENERIC_INDEX | AVFMT_NOTIMESTAMPS,
 .extensions = "thd",
@@ -89,4 +127,3 @@ const AVInputFormat ff_truehd_demuxer = {
 .priv_class = _raw_demuxer_class,
 };
 #endif
-
-- 
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 1/2] avformat/mlpdec: fix time_base for packet timestamps

2021-09-05 Thread Andreas Rheinhardt
Paul B Mahol:
> Signed-off-by: Paul B Mahol 
> ---
>  libavformat/mlpdec.c | 43 ---
>  1 file changed, 40 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/mlpdec.c b/libavformat/mlpdec.c
> index 8f0aabb510..cc5b8d07bb 100644
> --- a/libavformat/mlpdec.c
> +++ b/libavformat/mlpdec.c
> @@ -22,8 +22,12 @@
>   */
>  
>  #include "avformat.h"
> +#include "avio_internal.h"
> +#include "internal.h"
>  #include "rawdec.h"
>  #include "libavutil/intreadwrite.h"
> +#include "libavcodec/mlp.h"
> +#include "libavcodec/mlp_parse.h"
>  
>  static int av_always_inline mlp_thd_probe(const AVProbeData *p, uint32_t 
> sync)
>  {
> @@ -50,6 +54,40 @@ static int av_always_inline mlp_thd_probe(const 
> AVProbeData *p, uint32_t sync)
>  return 0;
>  }
>  
> +static int mlp_read_header(AVFormatContext *s)
> +{
> +int ret = ff_raw_audio_read_header(s);
> +
> +if (ret < 0)
> +return ret;
> +
> +ret = ffio_ensure_seekback(s->pb, 10);
> +if (ret == 0) {
> +uint8_t buffer[10];
> +int read, sample_rate = 0;
> +
> +read = avio_read(s->pb, buffer, 10);
> +if (read == 10) {
> +switch (buffer[7]) {
> +case SYNC_TRUEHD:
> +sample_rate = mlp_samplerate(buffer[8] >> 4);
> +break;
> +case SYNC_MLP:
> +sample_rate = mlp_samplerate((buffer[9] >> 4) & 0xF);

The "& 0xF" is unnecessary now.

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

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


[FFmpeg-devel] [PATCH 1/2] avformat/mlpdec: fix time_base for packet timestamps

2021-09-05 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavformat/mlpdec.c | 43 ---
 1 file changed, 40 insertions(+), 3 deletions(-)

diff --git a/libavformat/mlpdec.c b/libavformat/mlpdec.c
index 8f0aabb510..cc5b8d07bb 100644
--- a/libavformat/mlpdec.c
+++ b/libavformat/mlpdec.c
@@ -22,8 +22,12 @@
  */
 
 #include "avformat.h"
+#include "avio_internal.h"
+#include "internal.h"
 #include "rawdec.h"
 #include "libavutil/intreadwrite.h"
+#include "libavcodec/mlp.h"
+#include "libavcodec/mlp_parse.h"
 
 static int av_always_inline mlp_thd_probe(const AVProbeData *p, uint32_t sync)
 {
@@ -50,6 +54,40 @@ static int av_always_inline mlp_thd_probe(const AVProbeData 
*p, uint32_t sync)
 return 0;
 }
 
+static int mlp_read_header(AVFormatContext *s)
+{
+int ret = ff_raw_audio_read_header(s);
+
+if (ret < 0)
+return ret;
+
+ret = ffio_ensure_seekback(s->pb, 10);
+if (ret == 0) {
+uint8_t buffer[10];
+int read, sample_rate = 0;
+
+read = avio_read(s->pb, buffer, 10);
+if (read == 10) {
+switch (buffer[7]) {
+case SYNC_TRUEHD:
+sample_rate = mlp_samplerate(buffer[8] >> 4);
+break;
+case SYNC_MLP:
+sample_rate = mlp_samplerate((buffer[9] >> 4) & 0xF);
+break;
+}
+
+if (sample_rate)
+avpriv_set_pts_info(s->streams[0], 64, 1, sample_rate);
+}
+
+if (read > 0)
+avio_seek(s->pb, -read, SEEK_CUR);
+}
+
+return 0;
+}
+
 #if CONFIG_MLP_DEMUXER
 static int mlp_probe(const AVProbeData *p)
 {
@@ -60,7 +98,7 @@ const AVInputFormat ff_mlp_demuxer = {
 .name   = "mlp",
 .long_name  = NULL_IF_CONFIG_SMALL("raw MLP"),
 .read_probe = mlp_probe,
-.read_header= ff_raw_audio_read_header,
+.read_header= mlp_read_header,
 .read_packet= ff_raw_read_partial_packet,
 .flags  = AVFMT_GENERIC_INDEX | AVFMT_NOTIMESTAMPS,
 .extensions = "mlp",
@@ -80,7 +118,7 @@ const AVInputFormat ff_truehd_demuxer = {
 .name   = "truehd",
 .long_name  = NULL_IF_CONFIG_SMALL("raw TrueHD"),
 .read_probe = thd_probe,
-.read_header= ff_raw_audio_read_header,
+.read_header= mlp_read_header,
 .read_packet= ff_raw_read_partial_packet,
 .flags  = AVFMT_GENERIC_INDEX | AVFMT_NOTIMESTAMPS,
 .extensions = "thd",
@@ -89,4 +127,3 @@ const AVInputFormat ff_truehd_demuxer = {
 .priv_class = _raw_demuxer_class,
 };
 #endif
-
-- 
2.17.1

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

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


Re: [FFmpeg-devel] [PATCH] avformat/mlpdec: fix time_base for packet timestamps

2021-09-05 Thread Andreas Rheinhardt
Paul B Mahol:
> On Sun, Sep 5, 2021 at 6:12 PM Andreas Rheinhardt <
> andreas.rheinha...@outlook.com> wrote:
> 
>> Paul B Mahol:
>>> Signed-off-by: Paul B Mahol 
>>> ---
>>>  libavformat/mlpdec.c | 38 +++---
>>>  1 file changed, 35 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/libavformat/mlpdec.c b/libavformat/mlpdec.c
>>> index 8f0aabb510..f13d0fac8c 100644
>>> --- a/libavformat/mlpdec.c
>>> +++ b/libavformat/mlpdec.c
>>> @@ -22,8 +22,11 @@
>>>   */
>>>
>>>  #include "avformat.h"
>>> +#include "avio_internal.h"
>>> +#include "internal.h"
>>>  #include "rawdec.h"
>>>  #include "libavutil/intreadwrite.h"
>>> +#include "libavcodec/mlp_parse.h"
>>>
>>>  static int av_always_inline mlp_thd_probe(const AVProbeData *p,
>> uint32_t sync)
>>>  {
>>> @@ -50,6 +53,36 @@ static int av_always_inline mlp_thd_probe(const
>> AVProbeData *p, uint32_t sync)
>>>  return 0;
>>>  }
>>>
>>> +static int mlp_read_header(AVFormatContext *s)
>>> +{
>>> +int ret = ff_raw_audio_read_header(s);
>>> +
>>> +if (ret < 0)
>>> +return ret;
>>> +
>>> +ret = ffio_ensure_seekback(s->pb, 10);
>>> +if (ret == 0) {
>>> +int sample_rate, type;
>>> +
>>> +avio_skip(s->pb, 7);
>>> +type = avio_r8(s->pb);
>>> +
>>> +switch (type) {
>>> +case 0xba:
>>> +sample_rate = mlp_samplerate(avio_r8(s->pb) >> 4);
>>> +break;
>>> +case 0xbb:
>>> +sample_rate = mlp_samplerate((avio_rb16(s->pb) >> 4) & 0xF);
>>> +break;
>>> +}
>>> +
>>> +avpriv_set_pts_info(s->streams[0], 64, 1, sample_rate);
>>> +avio_seek(s->pb, -9 - (type == 0xbb), SEEK_CUR);
>>
>> This presumes that one of the two cases of the switch will be taken.
>> I think it would be easier if you just read the first 10 bytes into a
>> stack buffer and parsed from it instead. Then you can always seek back
>> by 10 bytes.
>>
>> (I always thought that thd can have very high samplerates (up to
>> 192kHz). Am I wrong?)
>>
> 
> Yes, but lowest is 44100 Hz.
> 
Seems like I completely misunderstood mlp_samplerate(). I forgot the
shifting.

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

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


Re: [FFmpeg-devel] [PATCH] avformat/mlpdec: fix time_base for packet timestamps

2021-09-05 Thread Paul B Mahol
On Sun, Sep 5, 2021 at 6:12 PM Andreas Rheinhardt <
andreas.rheinha...@outlook.com> wrote:

> Paul B Mahol:
> > Signed-off-by: Paul B Mahol 
> > ---
> >  libavformat/mlpdec.c | 38 +++---
> >  1 file changed, 35 insertions(+), 3 deletions(-)
> >
> > diff --git a/libavformat/mlpdec.c b/libavformat/mlpdec.c
> > index 8f0aabb510..f13d0fac8c 100644
> > --- a/libavformat/mlpdec.c
> > +++ b/libavformat/mlpdec.c
> > @@ -22,8 +22,11 @@
> >   */
> >
> >  #include "avformat.h"
> > +#include "avio_internal.h"
> > +#include "internal.h"
> >  #include "rawdec.h"
> >  #include "libavutil/intreadwrite.h"
> > +#include "libavcodec/mlp_parse.h"
> >
> >  static int av_always_inline mlp_thd_probe(const AVProbeData *p,
> uint32_t sync)
> >  {
> > @@ -50,6 +53,36 @@ static int av_always_inline mlp_thd_probe(const
> AVProbeData *p, uint32_t sync)
> >  return 0;
> >  }
> >
> > +static int mlp_read_header(AVFormatContext *s)
> > +{
> > +int ret = ff_raw_audio_read_header(s);
> > +
> > +if (ret < 0)
> > +return ret;
> > +
> > +ret = ffio_ensure_seekback(s->pb, 10);
> > +if (ret == 0) {
> > +int sample_rate, type;
> > +
> > +avio_skip(s->pb, 7);
> > +type = avio_r8(s->pb);
> > +
> > +switch (type) {
> > +case 0xba:
> > +sample_rate = mlp_samplerate(avio_r8(s->pb) >> 4);
> > +break;
> > +case 0xbb:
> > +sample_rate = mlp_samplerate((avio_rb16(s->pb) >> 4) & 0xF);
> > +break;
> > +}
> > +
> > +avpriv_set_pts_info(s->streams[0], 64, 1, sample_rate);
> > +avio_seek(s->pb, -9 - (type == 0xbb), SEEK_CUR);
>
> This presumes that one of the two cases of the switch will be taken.
> I think it would be easier if you just read the first 10 bytes into a
> stack buffer and parsed from it instead. Then you can always seek back
> by 10 bytes.
>
> (I always thought that thd can have very high samplerates (up to
> 192kHz). Am I wrong?)
>

Yes, but lowest is 44100 Hz.

>
> > +}
> > +
> > +return 0;
> > +}
> > +
> >  #if CONFIG_MLP_DEMUXER
> >  static int mlp_probe(const AVProbeData *p)
> >  {
> > @@ -60,7 +93,7 @@ const AVInputFormat ff_mlp_demuxer = {
> >  .name   = "mlp",
> >  .long_name  = NULL_IF_CONFIG_SMALL("raw MLP"),
> >  .read_probe = mlp_probe,
> > -.read_header= ff_raw_audio_read_header,
> > +.read_header= mlp_read_header,
> >  .read_packet= ff_raw_read_partial_packet,
> >  .flags  = AVFMT_GENERIC_INDEX | AVFMT_NOTIMESTAMPS,
> >  .extensions = "mlp",
> > @@ -80,7 +113,7 @@ const AVInputFormat ff_truehd_demuxer = {
> >  .name   = "truehd",
> >  .long_name  = NULL_IF_CONFIG_SMALL("raw TrueHD"),
> >  .read_probe = thd_probe,
> > -.read_header= ff_raw_audio_read_header,
> > +.read_header= mlp_read_header,
> >  .read_packet= ff_raw_read_partial_packet,
> >  .flags  = AVFMT_GENERIC_INDEX | AVFMT_NOTIMESTAMPS,
> >  .extensions = "thd",
> > @@ -89,4 +122,3 @@ const AVInputFormat ff_truehd_demuxer = {
> >  .priv_class = _raw_demuxer_class,
> >  };
> >  #endif
> > -
> >
>
> ___
> 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] avformat/mlpdec: fix time_base for packet timestamps

2021-09-05 Thread Andreas Rheinhardt
Paul B Mahol:
> Signed-off-by: Paul B Mahol 
> ---
>  libavformat/mlpdec.c | 38 +++---
>  1 file changed, 35 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/mlpdec.c b/libavformat/mlpdec.c
> index 8f0aabb510..f13d0fac8c 100644
> --- a/libavformat/mlpdec.c
> +++ b/libavformat/mlpdec.c
> @@ -22,8 +22,11 @@
>   */
>  
>  #include "avformat.h"
> +#include "avio_internal.h"
> +#include "internal.h"
>  #include "rawdec.h"
>  #include "libavutil/intreadwrite.h"
> +#include "libavcodec/mlp_parse.h"
>  
>  static int av_always_inline mlp_thd_probe(const AVProbeData *p, uint32_t 
> sync)
>  {
> @@ -50,6 +53,36 @@ static int av_always_inline mlp_thd_probe(const 
> AVProbeData *p, uint32_t sync)
>  return 0;
>  }
>  
> +static int mlp_read_header(AVFormatContext *s)
> +{
> +int ret = ff_raw_audio_read_header(s);
> +
> +if (ret < 0)
> +return ret;
> +
> +ret = ffio_ensure_seekback(s->pb, 10);
> +if (ret == 0) {
> +int sample_rate, type;
> +
> +avio_skip(s->pb, 7);
> +type = avio_r8(s->pb);
> +
> +switch (type) {
> +case 0xba:
> +sample_rate = mlp_samplerate(avio_r8(s->pb) >> 4);
> +break;
> +case 0xbb:
> +sample_rate = mlp_samplerate((avio_rb16(s->pb) >> 4) & 0xF);
> +break;
> +}
> +
> +avpriv_set_pts_info(s->streams[0], 64, 1, sample_rate);
> +avio_seek(s->pb, -9 - (type == 0xbb), SEEK_CUR);

This presumes that one of the two cases of the switch will be taken.
I think it would be easier if you just read the first 10 bytes into a
stack buffer and parsed from it instead. Then you can always seek back
by 10 bytes.

(I always thought that thd can have very high samplerates (up to
192kHz). Am I wrong?)

> +}
> +
> +return 0;
> +}
> +
>  #if CONFIG_MLP_DEMUXER
>  static int mlp_probe(const AVProbeData *p)
>  {
> @@ -60,7 +93,7 @@ const AVInputFormat ff_mlp_demuxer = {
>  .name   = "mlp",
>  .long_name  = NULL_IF_CONFIG_SMALL("raw MLP"),
>  .read_probe = mlp_probe,
> -.read_header= ff_raw_audio_read_header,
> +.read_header= mlp_read_header,
>  .read_packet= ff_raw_read_partial_packet,
>  .flags  = AVFMT_GENERIC_INDEX | AVFMT_NOTIMESTAMPS,
>  .extensions = "mlp",
> @@ -80,7 +113,7 @@ const AVInputFormat ff_truehd_demuxer = {
>  .name   = "truehd",
>  .long_name  = NULL_IF_CONFIG_SMALL("raw TrueHD"),
>  .read_probe = thd_probe,
> -.read_header= ff_raw_audio_read_header,
> +.read_header= mlp_read_header,
>  .read_packet= ff_raw_read_partial_packet,
>  .flags  = AVFMT_GENERIC_INDEX | AVFMT_NOTIMESTAMPS,
>  .extensions = "thd",
> @@ -89,4 +122,3 @@ const AVInputFormat ff_truehd_demuxer = {
>  .priv_class = _raw_demuxer_class,
>  };
>  #endif
> -
> 

___
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] avformat/mlpdec: fix time_base for packet timestamps

2021-09-05 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavformat/mlpdec.c | 38 +++---
 1 file changed, 35 insertions(+), 3 deletions(-)

diff --git a/libavformat/mlpdec.c b/libavformat/mlpdec.c
index 8f0aabb510..f13d0fac8c 100644
--- a/libavformat/mlpdec.c
+++ b/libavformat/mlpdec.c
@@ -22,8 +22,11 @@
  */
 
 #include "avformat.h"
+#include "avio_internal.h"
+#include "internal.h"
 #include "rawdec.h"
 #include "libavutil/intreadwrite.h"
+#include "libavcodec/mlp_parse.h"
 
 static int av_always_inline mlp_thd_probe(const AVProbeData *p, uint32_t sync)
 {
@@ -50,6 +53,36 @@ static int av_always_inline mlp_thd_probe(const AVProbeData 
*p, uint32_t sync)
 return 0;
 }
 
+static int mlp_read_header(AVFormatContext *s)
+{
+int ret = ff_raw_audio_read_header(s);
+
+if (ret < 0)
+return ret;
+
+ret = ffio_ensure_seekback(s->pb, 10);
+if (ret == 0) {
+int sample_rate, type;
+
+avio_skip(s->pb, 7);
+type = avio_r8(s->pb);
+
+switch (type) {
+case 0xba:
+sample_rate = mlp_samplerate(avio_r8(s->pb) >> 4);
+break;
+case 0xbb:
+sample_rate = mlp_samplerate((avio_rb16(s->pb) >> 4) & 0xF);
+break;
+}
+
+avpriv_set_pts_info(s->streams[0], 64, 1, sample_rate);
+avio_seek(s->pb, -9 - (type == 0xbb), SEEK_CUR);
+}
+
+return 0;
+}
+
 #if CONFIG_MLP_DEMUXER
 static int mlp_probe(const AVProbeData *p)
 {
@@ -60,7 +93,7 @@ const AVInputFormat ff_mlp_demuxer = {
 .name   = "mlp",
 .long_name  = NULL_IF_CONFIG_SMALL("raw MLP"),
 .read_probe = mlp_probe,
-.read_header= ff_raw_audio_read_header,
+.read_header= mlp_read_header,
 .read_packet= ff_raw_read_partial_packet,
 .flags  = AVFMT_GENERIC_INDEX | AVFMT_NOTIMESTAMPS,
 .extensions = "mlp",
@@ -80,7 +113,7 @@ const AVInputFormat ff_truehd_demuxer = {
 .name   = "truehd",
 .long_name  = NULL_IF_CONFIG_SMALL("raw TrueHD"),
 .read_probe = thd_probe,
-.read_header= ff_raw_audio_read_header,
+.read_header= mlp_read_header,
 .read_packet= ff_raw_read_partial_packet,
 .flags  = AVFMT_GENERIC_INDEX | AVFMT_NOTIMESTAMPS,
 .extensions = "thd",
@@ -89,4 +122,3 @@ const AVInputFormat ff_truehd_demuxer = {
 .priv_class = _raw_demuxer_class,
 };
 #endif
-
-- 
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] avfilter/avfilter: Fix hardcoded input index

2021-09-05 Thread Soft Works



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Paul B Mahol
> Sent: Sunday, 5 September 2021 11:01
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH] avfilter/avfilter: Fix hardcoded
> input index
> 
> With what filters this happens?
> 
> IIUC this is forbidden and such filters should use .activate instead.

The hardcoded [0] is wrong, no matter what the use case is.

But to answer your question: It's about a new overlay_textsubs filter
where framesync cannot be used and incoming frames (video on input0,
subs on input1) need to be processed independently: the subtitle events 
are fed into the ass library (you could practically feed all events
in advance) while the overlay image generation is done based on a given
time code. 
This works fine by having a separate .filter_frame function for each
input (after applying this patch).

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

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


[FFmpeg-devel] [PATCH] avfilter/frei0r: use win32dlfcn wrapper

2021-09-05 Thread Timo Rothenpieler
---
 configure   | 7 ---
 libavfilter/vf_frei0r.c | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index af410a9d11..b4b5c7e138 100755
--- a/configure
+++ b/configure
@@ -3598,8 +3598,9 @@ firequalizer_filter_select="rdft"
 flite_filter_deps="libflite"
 framerate_filter_select="scene_sad"
 freezedetect_filter_select="scene_sad"
-frei0r_filter_deps="frei0r libdl"
-frei0r_src_filter_deps="frei0r libdl"
+frei0r_deps_any="libdl LoadLibrary"
+frei0r_filter_deps="frei0r"
+frei0r_src_filter_deps="frei0r"
 fspp_filter_deps="gpl"
 histeq_filter_deps="gpl"
 hqdn3d_filter_deps="gpl"
@@ -6385,7 +6386,7 @@ enabled cuda_nvcc && { check_nvcc cuda_nvcc || 
die "ERROR: failed checki
 enabled chromaprint   && require chromaprint chromaprint.h 
chromaprint_get_version -lchromaprint
 enabled decklink  && { require_headers DeckLinkAPI.h &&
{ test_cpp_condition DeckLinkAPIVersion.h 
"BLACKMAGIC_DECKLINK_API_VERSION >= 0x0a0b" || die "ERROR: Decklink API 
version must be >= 10.11"; } }
-enabled frei0r&& require_headers "frei0r.h dlfcn.h"
+enabled frei0r&& require_headers "frei0r.h"
 enabled gmp   && require gmp gmp.h mpz_export -lgmp
 enabled gnutls&& require_pkg_config gnutls gnutls gnutls/gnutls.h 
gnutls_global_init
 enabled jni   && { [ $target_os = "android" ] && check_headers 
jni.h && enabled pthreads || die "ERROR: jni not found"; }
diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c
index 65191e1932..827f9c7082 100644
--- a/libavfilter/vf_frei0r.c
+++ b/libavfilter/vf_frei0r.c
@@ -22,12 +22,12 @@
  * frei0r wrapper
  */
 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include "config.h"
+#include "compat/w32dlfcn.h"
 #include "libavutil/avstring.h"
 #include "libavutil/common.h"
 #include "libavutil/eval.h"
-- 
2.25.1

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

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


[FFmpeg-devel] [PATCH 1/2] avcodec/h274: don't read from uninitialized array members

2021-09-05 Thread Niklas Haas
From: Niklas Haas 

This bug flew under the radar because, in practice, these values are
0-initialized for the first invocation. But for subsequent invocations
(with different h/v values), reading from the uninitialized parts of
`out` is undefined behavior.

Avoid this by simply adjusting the iteration range of the next loop. Has
the added benefit of being a minor speedup.
---
 libavcodec/h274.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/h274.c b/libavcodec/h274.c
index 5e2cf150ea..a59d09b66e 100644
--- a/libavcodec/h274.c
+++ b/libavcodec/h274.c
@@ -74,12 +74,14 @@ static void init_slice_c(int8_t out[64][64], uint8_t h, 
uint8_t v,
 
 // 64x64 inverse integer transform
 for (int y = 0; y < 64; y++) {
-for (int x = 0; x < 64; x++) {
+for (int x = 0; x <= freq_h; x++) {
 int32_t sum = 0;
-for (int p = 0; p < 64; p++)
+for (int p = 0; p <= freq_v; p++)
 sum += R64T[y][p] * out[x][p];
 tmp[y][x] = (sum + 128) >> 8;
 }
+for (int x = freq_h+1; x < 64; x++)
+tmp[y][x] = 0;
 }
 
 for (int y = 0; y < 64; y++) {
-- 
2.33.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/h274: trim unnecessarily large array

2021-09-05 Thread Niklas Haas
From: Niklas Haas 

We only ever read to idx+3, so 256 values are overkill.
---
 libavcodec/h274.c | 21 +++--
 1 file changed, 3 insertions(+), 18 deletions(-)

diff --git a/libavcodec/h274.c b/libavcodec/h274.c
index a59d09b66e..54e33030c2 100644
--- a/libavcodec/h274.c
+++ b/libavcodec/h274.c
@@ -30,7 +30,7 @@
 
 #include "h274.h"
 
-static const int8_t Gaussian_LUT[2048+256];
+static const int8_t Gaussian_LUT[2048+4];
 static const uint32_t Seed_LUT[256];
 static const int8_t R64T[64][64];
 
@@ -291,7 +291,7 @@ int ff_h274_apply_film_grain(AVFrame *out_frame, const 
AVFrame *in_frame,
 }
 
 // These tables are all taken from the SMPTE RDD 5-2006 specification
-static const int8_t Gaussian_LUT[2048+256] = {
+static const int8_t Gaussian_LUT[2048+4] = {
 -11, 12, 103, -11, 42, -35, 12, 59, 77, 98, -87, 3, 65, -78, 45, 56, -51, 
21,
 13, -11, -20, -19, 33, -127, 17, -6, -105, 18, 19, 71, 48, -10, -38, 42,
 -2, 75, -67, 52, -90, 33, -47, 21, -3, -56, 49, 1, -57, -42, -1, 120, -127,
@@ -419,22 +419,7 @@ static const int8_t Gaussian_LUT[2048+256] = {
 4, -66, -81, 122, -20, -34, -37, -84, 127, 68, 46, 17, 47,
 
 // Repeat the beginning of the array to allow wrapping reads
--11, 12, 103, -11, 42, -35, 12, 59, 77, 98, -87, 3, 65, -78, 45, 56, -51, 
21,
-13, -11, -20, -19, 33, -127, 17, -6, -105, 18, 19, 71, 48, -10, -38, 42,
--2, 75, -67, 52, -90, 33, -47, 21, -3, -56, 49, 1, -57, -42, -1, 120, -127,
--108, -49, 9, 14, 127, 122, 109, 52, 127, 2, 7, 114, 19, 30, 12, 77, 112,
-82, -61, -127, 111, -52, -29, 2, -49, -24, 58, -29, -73, 12, 112, 67, 79,
--3, -114, -87, -6, -5, 40, 58, -81, 49, -27, -31, -34, -105, 50, 16, -24,
--35, -14, -15, -127, -55, -22, -55, -127, -112, 5, -26, -72, 127, 127, -2,
-41, 87, -65, -16, 55, 19, 91, -81, -65, -64, 35, -7, -54, 99, -7, 88, 125,
--26, 91, 0, 63, 60, -14, -23, 113, -33, 116, 14, 26, 51, -16, 107, -8, 53,
-38, -34, 17, -7, 4, -91, 6, 63, 63, -15, 39, -36, 19, 55, 17, -51, 40, 33,
--37, 126, -39, -118, 17, -30, 0, 19, 98, 60, 101, -12, -73, -17, -52, 98,
-3, 3, 60, 33, -3, -2, 10, -42, -106, -38, 14, 127, 16, -127, -31, -86, -39,
--56, 46, -41, 75, 23, -19, -22, -70, 74, -54, -2, 32, -45, 17, -92, 59,
--64, -67, 56, -102, -29, -87, -34, -92, 68, 5, -74, -61, 93, -43, 14, -26,
--38, -126, -17, 16, -127, 64, 34, 31, 93, 17, -51, -59, 71, 77, 81, 127,
-127, 61, 33, -106, -93, 0, 0, 75,
+-11, 12, 103, -11,
 };
 
 static const uint32_t Seed_LUT[256] = {
-- 
2.33.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] Controlling range conversions in the "scale" filter

2021-09-05 Thread Steinar Apalnes
Hi,
It seems to be a bug (maybe by design) when trying to control how the
video/color ranges are treated in the "scale" filter.
Basically what I need to specify is that the range should NOT be converted
when input range == output range, for example:
in_range=pc:out_range=pc or
in_range=tv:out_range=tv

In my head there should be NO range conversion in either commands.
However, this does not seem to be the case. If you look at the test
commands below and their output you will see that a range conversion has
taken place even though input range and output range are set to be the
exact same. The only parameters I change are the scale width and height.
I'm using a late august 2021 build.

Command:
ffmpeg -f lavfi -i smptebars=duration=1:size=720x576:rate=1 -vf
"signalstats,metadata=print:key=lavfi.signalstats.YMIN,metadata=print:key=lavfi.signalstats.YMAX,scale=w=1920:h=1080:in_color_matrix=bt709:out_color_matrix=bt709:in_range=pc:out_range=pc,signalstats,metadata=print:key=lavfi.signalstats.YMIN,metadata=print:key=lavfi.signalstats.YMAX"
-f null -

Raw FFmpeg output:
ffmpeg version N-103405-g1930a85e83 Copyright (c) 2000-2021 the FFmpeg
developers
  built with gcc 10.3.0 (Rev2, Built by MSYS2 project)
  configuration:  --disable-static --enable-shared --pkg-config=pkgconf
--cc='ccache gcc' --cxx='ccache g++' --disable-autodetect --enable-amf
--enable-bzlib --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2
--enable-iconv --enable-lzma --enable-nvenc --enable-zlib --enable-sdl2
--enable-ffnvcodec --enable-nvdec --enable-cuda-llvm --enable-libmp3lame
--enable-libopus --enable-libvorbis --enable-libx264 --enable-libx265
--enable-libdav1d --enable-libaom --disable-debug --enable-fontconfig
--enable-libass --enable-libbluray --enable-libfreetype --enable-libmfx
--enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb
--enable-libopenjpeg --enable-libsnappy --enable-libsoxr --enable-libspeex
--enable-libtheora --enable-libtwolame --enable-libvidstab
--enable-libvo-amrwbenc --enable-libwebp --enable-libxml2 --enable-libzimg
--enable-libshine --enable-gpl --enable-avisynth --enable-libxvid
--enable-libopenmpt --enable-version3 --enable-libsrt --enable-libgsm
--enable-libvmaf --enable-libsvtav1 --enable-mbedtls
--extra-cflags=-DLIBTWOLAME_STATIC --extra-libs=-lstdc++
--extra-cflags=-DLIBXML_STATIC --extra-libs=-liconv --disable-w32threads
--shlibdir=/local64/bin-video
  libavutil  57.  4.101 / 57.  4.101
  libavcodec 59.  6.100 / 59.  6.100
  libavformat59.  4.102 / 59.  4.102
  libavdevice59.  0.101 / 59.  0.101
  libavfilter 8.  4.100 /  8.  4.100
  libswscale  6.  0.100 /  6.  0.100
  libswresample   4.  0.100 /  4.  0.100
  libpostproc56.  0.100 / 56.  0.100
Input #0, lavfi, from 'smptebars=duration=1:size=720x576:rate=1':
  Duration: N/A, start: 0.00, bitrate: N/A
  Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 720x576 [SAR
1:1 DAR 5:4], 1 tbr, 1 tbn
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> wrapped_avframe (native))
Press [q] to stop, [?] for help
[Parsed_metadata_1 @ 0298dcb6c7c0] frame:0pts:0   pts_time:0
[Parsed_metadata_1 @ 0298dcb6c7c0] lavfi.signalstats.YMIN=7
[Parsed_metadata_2 @ 0298dcb6bcc0] frame:0pts:0   pts_time:0
[Parsed_metadata_2 @ 0298dcb6bcc0] lavfi.signalstats.YMAX=235
[swscaler @ 0298dcb7fec0] Warning: data is not aligned! This can lead
to a speed loss
[Parsed_metadata_5 @ 0298dcb6b0c0] frame:0pts:0   pts_time:0
[Parsed_metadata_5 @ 0298dcb6b0c0] lavfi.signalstats.YMIN=0
[Parsed_metadata_6 @ 0298dcb6b4c0] frame:0pts:0   pts_time:0
[Parsed_metadata_6 @ 0298dcb6b4c0] lavfi.signalstats.YMAX=255
Output #0, null, to 'pipe:':
  Metadata:
encoder : Lavf59.4.102
  Stream #0:0: Video: wrapped_avframe, yuv420p(pc, progressive), 1920x1080
[SAR 45:64 DAR 5:4], q=2-31, 200 kb/s, 1 fps, 1 tbn
Metadata:
  encoder : Lavc59.6.100 wrapped_avframe
frame=1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:01.00 bitrate=N/A
speed=20.1x
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: unknown

If we can trust the signalstats filter, YMIN has gone from 7 to 0, YMAX has
gone from 235 to 255

Furthermore, it's not consistent:

Command:
ffmpeg -f lavfi -i smptebars=duration=1:size=720x576:rate=1 -vf
"signalstats,metadata=print:key=lavfi.signalstats.YMIN,metadata=print:key=lavfi.signalstats.YMAX,scale=w=1280:h=720:in_color_matrix=bt709:out_color_matrix=bt709:in_range=pc:out_range=pc,signalstats,metadata=print:key=lavfi.signalstats.YMIN,metadata=print:key=lavfi.signalstats.YMAX"
-f null -

Washed FFmpeg output:
[Parsed_metadata_1 @ 01ab9f8dc9c0] frame:0pts:0   pts_time:0
[Parsed_metadata_1 @ 01ab9f8dc9c0] lavfi.signalstats.YMIN=7
[Parsed_metadata_2 @ 01ab9f8db3c0] frame:0pts:0   pts_time:0
[Parsed_metadata_2 @ 01ab9f8db3c0] lavfi.signalstats.YMAX=235
[swscaler @ 01ab9f8efec0] 

Re: [FFmpeg-devel] [PATCH] avfilter/avfilter: Fix hardcoded input index

2021-09-05 Thread Paul B Mahol
With what filters this happens?

IIUC this is forbidden and such filters should use .activate instead.
___
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] lavfi: add nlmeans CUDA filter

2021-09-05 Thread Timo Rothenpieler

On 05.09.2021 20:02, Dylan Fernando wrote:


Impossible to convert between the formats supported by the filter 'graph 0
input from stream 0:0' and the filter 'auto_scale_0'

Thread 1 "ffmpeg" received signal SIGSEGV, Segmentation fault.
0x556726eb in uninit (ctx=0x5817e800) at
libavfilter/vf_nlmeans_cuda.c:704
704 CudaFunctions *cu = s->hwctx->internal->cuda_dl;


Seems like some error state can cause uninit to be called before the 
hwctx is properly set up.

So it needs a guard against that case.


(gdb) backtrace
#0  0x556726eb in uninit (ctx=0x5817e800) at
libavfilter/vf_nlmeans_cuda.c:704
#1  0x55742e65 in avfilter_free (filter=0x5817e800) at
libavfilter/avfilter.c:769
#2  0x55744cac in avfilter_graph_free (graph=0x5716ded0) at
libavfilter/avfiltergraph.c:126
#3  0x55707ae0 in cleanup_filtergraph (fg=0x5716dec0) at
fftools/ffmpeg_filter.c:952
#4  configure_filtergraph (fg=fg@entry=0x5716dec0) at
fftools/ffmpeg_filter.c:1130
#5  0x5571b060 in ifilter_send_frame (frame=0x57a72d00,
ifilter=0x5716db40) at fftools/ffmpeg.c:2242
#6  send_frame_to_filters (ist=ist@entry=0x5716c5c0,
decoded_frame=decoded_frame@entry=0x57a72d00) at fftools/ffmpeg.c:2323
#7  0x5571c204 in decode_video (decode_failed=,
eof=, duration_pts=, got_output=, pkt=, ist=)
 at fftools/ffmpeg.c:2520
#8  process_input_packet (ist=ist@entry=0x5716c5c0, pkt=0x5716c7c0,
no_eof=no_eof@entry=0) at fftools/ffmpeg.c:2682
#9  0x5571daee in process_input (file_index=) at
fftools/ffmpeg.c:4636
#10 transcode_step () at fftools/ffmpeg.c:4776
#11 transcode () at fftools/ffmpeg.c:4830
#12 0x556f84a7 in main (argc=, argv=)
at fftools/ffmpeg.c:5035




smime.p7s
Description: S/MIME Cryptographic 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 v2] lavfi: add nlmeans CUDA filter

2021-09-05 Thread Dylan Fernando
On Sat, Sep 4, 2021 at 10:43 AM Timo Rothenpieler 
wrote:

> On 04.09.2021 22:03, Dylan Fernando wrote:
> > On Thu, Sep 2, 2021 at 4:25 PM Timo Rothenpieler 
> > wrote:
> >
> >> On 02.09.2021 15:32, Timo Rothenpieler wrote:
> >>> On 02.09.2021 19:50, Dylan Fernando wrote:
>  I want to add support for the other formats, but I'm not sure how to
> >> find
>  video files to test it out. I tried looking through
>  https://samples.ffmpeg.org/, but I'm not sure which files on there
> are
>  the
>  formats im looking for (AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P,
>  AV_PIX_FMT_P010, AV_PIX_FMT_P016, AV_PIX_FMT_YUV444P16).
> >>>
> >>> Just slap a format_cuda filter in front and convert to the desired
> >> format.
> >>> For RGB formats, which it doesn't support right now, just use
> >>> format,hwupload_cuda.
> >>
> >> sorry, scale_cuda or format+hwupload
> >> ___
> >> 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".
> >>
> >
> > Thanks, I have yuv420p and yuv444p working now.
> >
> > For P010, I tried using:
> > ffmpeg -loglevel debug -v verbose -hwaccel cuda -hwaccel_output_format
> cuda
> > -i noise.mp4 -vf format=p010,hwupload,nlmeans_cuda=20,hwdownload
> nlmeans.mp4
> >
> > and I get:
> > [Parsed_format_0 @ 0x558bf0ff6bc0] auto-inserting filter 'auto_scale_0'
> > between the filter 'graph 0 input from stream 0:0' and the filter
> > 'Parsed_format_0'
> > Impossible to convert between the formats supported by the filter 'graph
> 0
> > input from stream 0:0' and the filter 'auto_scale_0'
> >
> > Segmentation fault (core dumped)
>
> you're trying to hwupload something that already is uploaded by the
> decoder.
> Either use scale_cuda for the conversion, or don't have the decoder
> output CUDA frames.
>
> The segfault is a bit unexpected though. Can you get a backtrace?
> ___
> 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".
>


Impossible to convert between the formats supported by the filter 'graph 0
input from stream 0:0' and the filter 'auto_scale_0'

Thread 1 "ffmpeg" received signal SIGSEGV, Segmentation fault.
0x556726eb in uninit (ctx=0x5817e800) at
libavfilter/vf_nlmeans_cuda.c:704
704 CudaFunctions *cu = s->hwctx->internal->cuda_dl;
(gdb) backtrace
#0  0x556726eb in uninit (ctx=0x5817e800) at
libavfilter/vf_nlmeans_cuda.c:704
#1  0x55742e65 in avfilter_free (filter=0x5817e800) at
libavfilter/avfilter.c:769
#2  0x55744cac in avfilter_graph_free (graph=0x5716ded0) at
libavfilter/avfiltergraph.c:126
#3  0x55707ae0 in cleanup_filtergraph (fg=0x5716dec0) at
fftools/ffmpeg_filter.c:952
#4  configure_filtergraph (fg=fg@entry=0x5716dec0) at
fftools/ffmpeg_filter.c:1130
#5  0x5571b060 in ifilter_send_frame (frame=0x57a72d00,
ifilter=0x5716db40) at fftools/ffmpeg.c:2242
#6  send_frame_to_filters (ist=ist@entry=0x5716c5c0,
decoded_frame=decoded_frame@entry=0x57a72d00) at fftools/ffmpeg.c:2323
#7  0x5571c204 in decode_video (decode_failed=,
eof=, duration_pts=, got_output=, pkt=, ist=)
at fftools/ffmpeg.c:2520
#8  process_input_packet (ist=ist@entry=0x5716c5c0, pkt=0x5716c7c0,
no_eof=no_eof@entry=0) at fftools/ffmpeg.c:2682
#9  0x5571daee in process_input (file_index=) at
fftools/ffmpeg.c:4636
#10 transcode_step () at fftools/ffmpeg.c:4776
#11 transcode () at fftools/ffmpeg.c:4830
#12 0x556f84a7 in main (argc=, argv=)
at fftools/ffmpeg.c:5035

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