[FFmpeg-devel] [PATCH 1/2] avformat/swfenc: Fix memleak upon write_header error

2020-09-20 Thread Andreas Rheinhardt
The SWF muxer accepts at most one mp3 audio and at most one VP6F, FLV1
or MJPEG stream. Upon encountering an mp3 stream, a fifo is allocated
that leaks if one of the subsequent streams is incompliant with the
restrictions mentioned above or if the framerate or samplerate are
invalid. This is fixed by adding a deinit function to free said fifo.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/swfenc.c | 24 +++-
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c
index 9da4aad959..750ec56ec1 100644
--- a/libavformat/swfenc.c
+++ b/libavformat/swfenc.c
@@ -482,24 +482,13 @@ static int swf_write_trailer(AVFormatContext *s)
 {
 SWFContext *swf = s->priv_data;
 AVIOContext *pb = s->pb;
-AVCodecParameters *par, *video_par;
-int file_size, i;
-
-video_par = NULL;
-for(i=0;inb_streams;i++) {
-par = s->streams[i]->codecpar;
-if (par->codec_type == AVMEDIA_TYPE_VIDEO)
-video_par = par;
-else {
-av_fifo_freep(&swf->audio_fifo);
-}
-}
+int file_size;
 
 put_swf_tag(s, TAG_END);
 put_swf_end_tag(s);
 
 /* patch file size and number of frames if not streamed */
-if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && video_par) {
+if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && swf->video_par) {
 file_size = avio_tell(pb);
 avio_seek(pb, 4, SEEK_SET);
 avio_wl32(pb, file_size);
@@ -514,6 +503,13 @@ static int swf_write_trailer(AVFormatContext *s)
 return 0;
 }
 
+static void swf_deinit(AVFormatContext *s)
+{
+SWFContext *swf = s->priv_data;
+
+av_fifo_freep(&swf->audio_fifo);
+}
+
 #if CONFIG_SWF_MUXER
 AVOutputFormat ff_swf_muxer = {
 .name  = "swf",
@@ -526,6 +522,7 @@ AVOutputFormat ff_swf_muxer = {
 .write_header  = swf_write_header,
 .write_packet  = swf_write_packet,
 .write_trailer = swf_write_trailer,
+.deinit= swf_deinit,
 .flags = AVFMT_TS_NONSTRICT,
 };
 #endif
@@ -540,6 +537,7 @@ AVOutputFormat ff_avm2_muxer = {
 .write_header  = swf_write_header,
 .write_packet  = swf_write_packet,
 .write_trailer = swf_write_trailer,
+.deinit= swf_deinit,
 .flags = AVFMT_TS_NONSTRICT,
 };
 #endif
-- 
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 2/2] avformat/swfdec: Avoid unnecessary skip

2020-09-20 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/swfdec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c
index 9a0b27bd8c..e427998744 100644
--- a/libavformat/swfdec.c
+++ b/libavformat/swfdec.c
@@ -78,10 +78,9 @@ static int swf_probe(const AVProbeData *p)
 && p->buf[3] <= 20)
 return AVPROBE_SCORE_MAX / 4 + 1;
 
-if (init_get_bits8(&gb, p->buf + 3, p->buf_size - 3) < 0)
+if (init_get_bits8(&gb, p->buf + 8, p->buf_size - 8) < 0)
 return 0;
 
-skip_bits(&gb, 40);
 len = get_bits(&gb, 5);
 if (!len)
 return 0;
-- 
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 00/10] argo_brp cleanups and fixes

2020-09-20 Thread Zane van Iperen
Fixes handling of embedded ASF streams and BVID timestamps. Also adds
AV_CODEC_ID_ARGO to libavcodec in preparation for Paul's decoder.

Zane van Iperen (10):
  avformat/argo_asf: fix enforcement of chunk count
  avformat/argo_asf: cosmetics
  avformat/argo_brp: remove an allocation
  avformat/argo_brp: cleanup 'goto fail's
  avformat/argo_brp: make sure stream ids match
  avformat/argo_brp: handle multiple BASF blocks
  avformat/argo_brp: set BVID packet duration
  avformat/argo_brp: don't pass AVStream into avpriv_request_sample()
  avcodec: add "Argonaut Games Video" descriptor
  avformat/argo_brp: use AV_CODEC_ID_ARGO

 libavcodec/codec_desc.c |   7 ++
 libavcodec/codec_id.h   |   1 +
 libavcodec/version.h|   2 +-
 libavformat/argo_asf.c  |  19 ++--
 libavformat/argo_brp.c  | 238 ++--
 5 files changed, 104 insertions(+), 163 deletions(-)

-- 
2.25.4


___
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 02/10] avformat/argo_asf: cosmetics

2020-09-20 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavformat/argo_asf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c
index eb0c18601d..6f7d9e93c9 100644
--- a/libavformat/argo_asf.c
+++ b/libavformat/argo_asf.c
@@ -348,7 +348,7 @@ static int argo_asf_write_header(AVFormatContext *s)
 const char *end   = strrchr(start, '.');
 size_t  len;
 
-if(end)
+if (end)
 len = end - start;
 else
 len = strlen(start);
-- 
2.25.4


___
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 01/10] avformat/argo_asf: fix enforcement of chunk count

2020-09-20 Thread Zane van Iperen
Enforcing num_chunks == 1 only makes sense when demuxing from an ASF
file. When embedded in a BRP file, an ASF stream can have multiple chunks.

Signed-off-by: Zane van Iperen 
---
 libavformat/argo_asf.c | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c
index 048e5441d6..eb0c18601d 100644
--- a/libavformat/argo_asf.c
+++ b/libavformat/argo_asf.c
@@ -59,11 +59,6 @@ int ff_argo_asf_validate_file_header(AVFormatContext *s, 
const ArgoASFFileHeader
 if (hdr->magic != ASF_TAG || hdr->num_chunks == 0)
 return AVERROR_INVALIDDATA;
 
-if (hdr->num_chunks > 1) {
-avpriv_request_sample(s, ">1 chunk");
-return AVERROR_PATCHWELCOME;
-}
-
 if (hdr->chunk_offset < ASF_FILE_HEADER_SIZE)
 return AVERROR_INVALIDDATA;
 
@@ -139,8 +134,12 @@ int ff_argo_asf_fill_stream(AVStream *st, const 
ArgoASFFileHeader *fhdr,
 
 avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
 st->start_time  = 0;
-st->duration= ckhdr->num_blocks * ckhdr->num_samples;
-st->nb_frames   = ckhdr->num_blocks;
+
+if (fhdr->num_chunks == 1) {
+st->duration= ckhdr->num_blocks * ckhdr->num_samples;
+st->nb_frames   = ckhdr->num_blocks;
+}
+
 return 0;
 }
 
@@ -199,6 +198,10 @@ static int argo_asf_read_header(AVFormatContext *s)
 if ((ret = ff_argo_asf_validate_file_header(s, &asf->fhdr)) < 0)
 return ret;
 
+/* This should only be 1 in ASF files. >1 is fine if in BRP. */
+if (asf->fhdr.num_chunks != 1)
+return AVERROR_INVALIDDATA;
+
 if ((ret = avio_skip(pb, asf->fhdr.chunk_offset - ASF_FILE_HEADER_SIZE)) < 
0)
 return ret;
 
-- 
2.25.4


___
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 03/10] avformat/argo_brp: remove an allocation

2020-09-20 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavformat/argo_brp.c | 20 ++--
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git a/libavformat/argo_brp.c b/libavformat/argo_brp.c
index 27029d07b1..e57c20eb96 100644
--- a/libavformat/argo_brp.c
+++ b/libavformat/argo_brp.c
@@ -77,7 +77,7 @@ typedef struct ArgoBRPStreamHeader {
 
 typedef struct ArgoBRPDemuxContext {
 ArgoBRPFileHeader   fhdr;
-ArgoBRPStreamHeader *streams;
+ArgoBRPStreamHeader streams[BRP_MAX_STREAMS];
 /* To know how much of a BASF to give. */
 int64_t lastpts;
 int hit_eof;
@@ -101,16 +101,6 @@ static int argo_brp_probe(const AVProbeData *p)
 return AVPROBE_SCORE_EXTENSION + 1;
 }
 
-static int argo_brp_read_close(AVFormatContext *s)
-{
-ArgoBRPDemuxContext *brp = s->priv_data;
-
-if (brp->streams != NULL)
-av_freep(&brp->streams);
-
-return 0;
-}
-
 static int read_extradata(AVFormatContext *s, const ArgoBRPStreamHeader *hdr,
   void *buf, size_t bufsz)
 {
@@ -174,9 +164,6 @@ static int argo_brp_read_header(AVFormatContext *s)
 return AVERROR_PATCHWELCOME;
 }
 
-if ((brp->streams = av_mallocz_array(brp->fhdr.num_streams, 
sizeof(ArgoBRPStreamHeader))) == NULL)
-return AVERROR(ENOMEM);
-
 /* Build the stream info. */
 brp->basf.index = -1;
 for (uint32_t i = 0; i < brp->fhdr.num_streams; i++) {
@@ -331,8 +318,6 @@ static int argo_brp_read_header(AVFormatContext *s)
 return 0;
 
 fail:
-/* TODO: Remove once AVFMT_HEADER_CLEANUP lands. */
-argo_brp_read_close(s);
 return ret;
 }
 
@@ -444,6 +429,5 @@ AVInputFormat ff_argo_brp_demuxer = {
 .priv_data_size = sizeof(ArgoBRPDemuxContext),
 .read_probe = argo_brp_probe,
 .read_header= argo_brp_read_header,
-.read_packet= argo_brp_read_packet,
-.read_close = argo_brp_read_close
+.read_packet= argo_brp_read_packet
 };
-- 
2.25.4


___
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 07/10] avformat/argo_brp: set BVID packet duration

2020-09-20 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavformat/argo_brp.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavformat/argo_brp.c b/libavformat/argo_brp.c
index fb5c2b7245..ad54420283 100644
--- a/libavformat/argo_brp.c
+++ b/libavformat/argo_brp.c
@@ -306,6 +306,7 @@ static int argo_brp_read_packet(AVFormatContext *s, 
AVPacket *pkt)
 {
 ArgoBRPDemuxContext *brp = s->priv_data;
 ArgoBRPBlockHeader blk;
+const ArgoBRPStreamHeader *shdr;
 AVStream *st;
 uint8_t buf[BRP_MIN_BUFFER_SIZE];
 ArgoASFChunkHeader ckhdr;
@@ -327,6 +328,7 @@ static int argo_brp_read_packet(AVFormatContext *s, 
AVPacket *pkt)
 return AVERROR_INVALIDDATA;
 
 st = s->streams[blk.stream_id];
+shdr = brp->streams + blk.stream_id;
 
 if (blk.stream_id == brp->basf.index) {
 if (blk.size < ASF_CHUNK_HEADER_SIZE)
@@ -358,6 +360,9 @@ static int argo_brp_read_packet(AVFormatContext *s, 
AVPacket *pkt)
 if (blk.stream_id == brp->basf.index) {
 pkt->duration = ckhdr.num_samples * ckhdr.num_blocks;
 pkt->pts  = av_rescale_rnd(blk.start_ms, ckhdr.sample_rate, 1000, 
AV_ROUND_UP);
+} else if (brp->streams[blk.stream_id].codec_id == BRP_CODEC_ID_BVID) {
+pkt->duration = av_rescale_rnd(1, st->duration, 
shdr->extradata.bvid.num_frames, AV_ROUND_UP);
+pkt->pts  = blk.start_ms;
 } else {
 pkt->pts  = blk.start_ms;
 }
-- 
2.25.4


___
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 05/10] avformat/argo_brp: make sure stream ids match

2020-09-20 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavformat/argo_brp.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavformat/argo_brp.c b/libavformat/argo_brp.c
index 6c6e126b17..312eb23771 100644
--- a/libavformat/argo_brp.c
+++ b/libavformat/argo_brp.c
@@ -184,6 +184,10 @@ static int argo_brp_read_header(AVFormatContext *s)
 hdr->byte_rate  = AV_RL32(buf + 12);
 hdr->extradata_size = AV_RL32(buf + 16);
 
+/* This should always be the case. */
+if (hdr->id != i)
+return AVERROR_INVALIDDATA;
+
 /* Timestamps are in milliseconds. */
 avpriv_set_pts_info(st, 64, 1, 1000);
 st->duration   = hdr->duration_ms;
-- 
2.25.4


___
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 06/10] avformat/argo_brp: handle multiple BASF blocks

2020-09-20 Thread Zane van Iperen
Turns out that there are files with multiple (reasonably-sized) BASF
blocks. Some of the files just have particularly large frames (~10s).

Signed-off-by: Zane van Iperen 
---
 libavformat/argo_brp.c | 142 ++---
 1 file changed, 49 insertions(+), 93 deletions(-)

diff --git a/libavformat/argo_brp.c b/libavformat/argo_brp.c
index 312eb23771..fb5c2b7245 100644
--- a/libavformat/argo_brp.c
+++ b/libavformat/argo_brp.c
@@ -78,18 +78,10 @@ typedef struct ArgoBRPStreamHeader {
 typedef struct ArgoBRPDemuxContext {
 ArgoBRPFileHeader   fhdr;
 ArgoBRPStreamHeader streams[BRP_MAX_STREAMS];
-/* To know how much of a BASF to give. */
-int64_t lastpts;
-int hit_eof;
 
-/* BASF-specific fields. */
 struct {
 int index;
 ArgoASFChunkHeader  ckhdr;
-int64_t blocks_read;
-int64_t offset;
-/* ms, not samples. */
-int64_t lastpts;
 } basf;
 } ArgoBRPDemuxContext;
 
@@ -255,18 +247,24 @@ static int argo_brp_read_header(AVFormatContext *s)
 }
 
 /*
- * This is nasty. BASF streams only have one (huge) block.
- * It should be the first one. It contains the chunk header, so
- * it needs to be read here.
+ * This is nasty. BASF streams have their chunk header in each block,
+ * so the first one needs to be read to get the stream info. It should
+ * always be the first one.
  */
 if (brp->basf.index >= 0) {
 AVStream *st = s->streams[brp->basf.index];
 ArgoBRPStreamHeader *hdr = brp->streams + brp->basf.index;
 ArgoBRPBlockHeader blk;
+int64_t offset;
 
 av_assert0(st->codecpar->codec_id == AV_CODEC_ID_ADPCM_ARGO);
 av_assert0(brp->streams[brp->basf.index].extradata_size == 
ASF_FILE_HEADER_SIZE);
 
+if ((ret = avio_tell(s->pb)) < 0)
+return ret;
+
+offset = ret;
+
 if ((ret = avio_read(pb, buf, BRP_BLOCK_HEADER_SIZE)) < 0)
 return ret;
 else if (ret != BRP_BLOCK_HEADER_SIZE)
@@ -295,86 +293,25 @@ static int argo_brp_read_header(AVFormatContext *s)
 return ret;
 
 /* Convert ms to samples. */
-st->start_time = (blk.start_ms * st->codecpar->sample_rate) / 1000;
-
-if ((ret = avio_tell(s->pb)) < 0)
-return ret;
-
-brp->basf.offset = ret;
+st->start_time = av_rescale_rnd(blk.start_ms, 
st->codecpar->sample_rate, 1000, AV_ROUND_UP);
+st->duration   = av_rescale_rnd(hdr->duration_ms, 
st->codecpar->sample_rate, 1000, AV_ROUND_UP);
 
-if ((ret = avio_skip(s->pb, blk.size - ASF_CHUNK_HEADER_SIZE)) < 0)
+if ((ret = avio_seek(s->pb, offset, SEEK_SET)) < 0)
 return ret;
 }
 return 0;
 }
 
-static int argo_brp_read_basf(AVFormatContext *s, AVPacket *pkt,
-  ArgoBRPDemuxContext *brp, int ignorepts)
-{
-ArgoASFChunkHeader *ckhdr = &brp->basf.ckhdr;
-AVCodecParameters *par;
-int64_t ret, old;
-
-if (brp->basf.index < 0)
-return 0;
-
-par = s->streams[brp->basf.index]->codecpar;
-
-if (brp->basf.blocks_read >= ckhdr->num_blocks)
-return 0;
-
-if (!ignorepts && brp->lastpts < brp->basf.lastpts)
-return 0;
-
-if ((ret = avio_tell(s->pb)) < 0)
-return ret;
-
-old = ret;
-
-if ((ret = avio_seek(s->pb, brp->basf.offset, SEEK_SET)) < 0)
-return ret;
-else if (ret != brp->basf.offset)
-return AVERROR(EIO);
-
-if ((ret = av_get_packet(s->pb, pkt, par->block_align)) < 0)
-return ret;
-
-if ((ret = avio_seek(s->pb, old, SEEK_SET)) < 0)
-return ret;
-else if (ret != old)
-return AVERROR(EIO);
-
-pkt->stream_index  = brp->basf.index;
-pkt->duration  = ckhdr->num_samples;
-
-brp->basf.offset  += pkt->size;
-brp->basf.blocks_read += 1;
-/* Need the ceil() because ((32 * 1000) / 44100) < 1 */
-brp->basf.lastpts += ceilf((ckhdr->num_samples * 1000.0f) / 
ckhdr->sample_rate);
-return 1;
-}
-
 static int argo_brp_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
 ArgoBRPDemuxContext *brp = s->priv_data;
 ArgoBRPBlockHeader blk;
-AVIOContext *pb = s->pb;
-uint8_t buf[BRP_BLOCK_HEADER_SIZE];
+AVStream *st;
+uint8_t buf[BRP_MIN_BUFFER_SIZE];
+ArgoASFChunkHeader ckhdr;
 int ret;
 
-/*
- * Special-case: send some more BASF content if we're running behind.
- * Grr, why couldn't they just interleave it.
- */
-if ((ret = argo_brp_read_basf(s, pkt, brp, brp->hit_eof)) < 0)
-return ret;
-else if (ret > 0)
-return 0;
-
-if (brp->hit_eof)
-return AVERROR_EOF;
-
-if ((ret = avio_read(pb, buf, BRP_BLOCK_HEADER_SIZE)) < 0)
+if ((ret = avio_read(s->pb, buf, BRP_BLOCK_HEADER_SIZE)) < 0)
 return ret;
 else if (ret != BRP_BLOCK_HEADER_SIZE)

[FFmpeg-devel] [PATCH 08/10] avformat/argo_brp: don't pass AVStream into avpriv_request_sample()

2020-09-20 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavformat/argo_brp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/argo_brp.c b/libavformat/argo_brp.c
index ad54420283..75587b24c0 100644
--- a/libavformat/argo_brp.c
+++ b/libavformat/argo_brp.c
@@ -275,7 +275,7 @@ static int argo_brp_read_header(AVFormatContext *s)
 blk.size  = AV_RL32(buf + 8);
 
 if (blk.stream_id != brp->basf.index) {
-avpriv_request_sample(st, "first block not BASF");
+avpriv_request_sample(s, "first block not BASF");
 return AVERROR_PATCHWELCOME;
 }
 
-- 
2.25.4


___
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 04/10] avformat/argo_brp: cleanup 'goto fail's

2020-09-20 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavformat/argo_brp.c | 63 +++---
 1 file changed, 23 insertions(+), 40 deletions(-)

diff --git a/libavformat/argo_brp.c b/libavformat/argo_brp.c
index e57c20eb96..6c6e126b17 100644
--- a/libavformat/argo_brp.c
+++ b/libavformat/argo_brp.c
@@ -170,17 +170,13 @@ static int argo_brp_read_header(AVFormatContext *s)
 ArgoBRPStreamHeader *hdr = brp->streams + i;
 AVStream *st;
 
-if (!(st = avformat_new_stream(s, NULL))) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
+if (!(st = avformat_new_stream(s, NULL)))
+return AVERROR(ENOMEM);
 
-if ((ret = avio_read(pb, buf, BRP_STREAM_HEADER_SIZE)) < 0) {
-goto fail;
-} else if (ret != BRP_STREAM_HEADER_SIZE) {
-ret = AVERROR(EIO);
-goto fail;
-}
+if ((ret = avio_read(pb, buf, BRP_STREAM_HEADER_SIZE)) < 0)
+return ret;
+else if (ret != BRP_STREAM_HEADER_SIZE)
+return AVERROR(EIO);
 
 hdr->codec_id   = AV_RL32(buf + 0);
 hdr->id = AV_RL32(buf + 4);
@@ -194,7 +190,7 @@ static int argo_brp_read_header(AVFormatContext *s)
 st->codecpar->bit_rate = hdr->byte_rate * 8;
 
 if ((ret = read_extradata(s, hdr, buf, sizeof(buf))) < 0) {
-goto fail;
+return ret;
 } else if (ret > 0) {
 st->codecpar->codec_type = AVMEDIA_TYPE_UNKNOWN;
 continue;
@@ -216,8 +212,7 @@ static int argo_brp_read_header(AVFormatContext *s)
 /* These are from 1990's games, sanity check this. */
 if (bvid->width >= 65536 || bvid->height >= 65536 ||
 bvid->depth > 24 || bvid->depth % 8 != 0) {
-ret = AVERROR_INVALIDDATA;
-goto fail;
+return AVERROR_INVALIDDATA;
 }
 
 st->codecpar->width  = bvid->width;
@@ -229,8 +224,7 @@ static int argo_brp_read_header(AVFormatContext *s)
 st->codecpar->format = AV_PIX_FMT_RGB24;
 } else {
 avpriv_request_sample(s, "depth == %u", bvid->depth);
-ret = AVERROR_PATCHWELCOME;
-goto fail;
+return AVERROR_PATCHWELCOME;
 }
 } else if (hdr->codec_id == BRP_CODEC_ID_BASF) {
 /*
@@ -240,8 +234,7 @@ static int argo_brp_read_header(AVFormatContext *s)
  */
 if (brp->basf.index >= 0) {
 avpriv_request_sample(s, "Multiple BASF streams");
-ret = AVERROR_PATCHWELCOME;
-goto fail;
+return AVERROR_PATCHWELCOME;
 }
 
 st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
@@ -250,7 +243,7 @@ static int argo_brp_read_header(AVFormatContext *s)
 ff_argo_asf_parse_file_header(&hdr->extradata.basf, buf);
 
 if ((ret = ff_argo_asf_validate_file_header(s, 
&hdr->extradata.basf)) < 0)
-goto fail;
+return ret;
 
 } else {
 av_assert0(0); /* Caught above, should never happen. */
@@ -271,11 +264,9 @@ static int argo_brp_read_header(AVFormatContext *s)
 av_assert0(brp->streams[brp->basf.index].extradata_size == 
ASF_FILE_HEADER_SIZE);
 
 if ((ret = avio_read(pb, buf, BRP_BLOCK_HEADER_SIZE)) < 0)
-goto fail;
-else if (ret != BRP_BLOCK_HEADER_SIZE) {
-ret = AVERROR(EIO);
-goto fail;
-}
+return ret;
+else if (ret != BRP_BLOCK_HEADER_SIZE)
+return AVERROR(EIO);
 
 blk.stream_id = AV_RL32(buf + 0);
 blk.start_ms  = AV_RL32(buf + 4);
@@ -283,42 +274,34 @@ static int argo_brp_read_header(AVFormatContext *s)
 
 if (blk.stream_id != brp->basf.index) {
 avpriv_request_sample(st, "first block not BASF");
-ret = AVERROR_PATCHWELCOME;
-goto fail;
+return AVERROR_PATCHWELCOME;
 }
 
-if (blk.size < ASF_CHUNK_HEADER_SIZE) {
-ret = AVERROR_INVALIDDATA;
-goto fail;
-}
+if (blk.size < ASF_CHUNK_HEADER_SIZE)
+return AVERROR_INVALIDDATA;
 
 if ((ret = avio_read(pb, buf, ASF_CHUNK_HEADER_SIZE)) < 0)
-goto fail;
-else if (ret != ASF_CHUNK_HEADER_SIZE) {
-ret = AVERROR(EIO);
-goto fail;
-}
+return ret;
+else if (ret != ASF_CHUNK_HEADER_SIZE)
+return AVERROR(EIO);
 
 ff_argo_asf_parse_chunk_header(&brp->basf.ckhdr, buf);
 
 if ((ret = ff_argo_asf_fill_stream(st, &hdr->extradata.basf, 
&brp->basf.ckhdr)) < 0)
-goto fail;
+return ret;
 
 /* Convert ms to samples. */
 st->start_time = (blk.start_ms * st->codecpar->sample_rate) / 1000;
 
 if ((ret = avio_tell(s->pb)) < 0)
-goto 

[FFmpeg-devel] [PATCH 09/10] avcodec: add "Argonaut Games Video" descriptor

2020-09-20 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavcodec/codec_desc.c | 7 +++
 libavcodec/codec_id.h   | 1 +
 libavcodec/version.h| 2 +-
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 9e73dcba27..713a45ddc9 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1798,6 +1798,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("Kodak Photo CD"),
 .props = AV_CODEC_PROP_LOSSY,
 },
+{
+.id= AV_CODEC_ID_ARGO,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "argo",
+.long_name = NULL_IF_CONFIG_SMALL("Argonaut Games Video"),
+.props = AV_CODEC_PROP_LOSSY,
+},
 
 /* various PCM "codecs" */
 {
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index e4eca5d580..e730e5ae4a 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -298,6 +298,7 @@ enum AVCodecID {
 AV_CODEC_ID_PFM,
 AV_CODEC_ID_MOBICLIP,
 AV_CODEC_ID_PHOTOCD,
+AV_CODEC_ID_ARGO,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the 
start of audio codecs
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 5ce4ba55d9..85b96c8c20 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -28,7 +28,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR  58
-#define LIBAVCODEC_VERSION_MINOR 106
+#define LIBAVCODEC_VERSION_MINOR 107
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
-- 
2.25.4


___
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 10/10] avformat/argo_brp: use AV_CODEC_ID_ARGO

2020-09-20 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavformat/argo_brp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavformat/argo_brp.c b/libavformat/argo_brp.c
index 75587b24c0..5c8d6b0851 100644
--- a/libavformat/argo_brp.c
+++ b/libavformat/argo_brp.c
@@ -196,9 +196,7 @@ static int argo_brp_read_header(AVFormatContext *s)
 ArgoBVIDHeader *bvid = &hdr->extradata.bvid;
 
 st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
-
-/* No decoder for this yet. */
-st->codecpar->codec_id   = AV_CODEC_ID_NONE;
+st->codecpar->codec_id   = AV_CODEC_ID_ARGO;
 
 bvid->num_frames = AV_RL32(buf +  0);
 bvid->width  = AV_RL32(buf +  4);
-- 
2.25.4


___
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 03/10] avformat/argo_brp: remove an allocation

2020-09-20 Thread Andreas Rheinhardt
Zane van Iperen:
> Signed-off-by: Zane van Iperen 
> ---
>  libavformat/argo_brp.c | 20 ++--
>  1 file changed, 2 insertions(+), 18 deletions(-)
> 
> diff --git a/libavformat/argo_brp.c b/libavformat/argo_brp.c
> index 27029d07b1..e57c20eb96 100644
> --- a/libavformat/argo_brp.c
> +++ b/libavformat/argo_brp.c
> @@ -77,7 +77,7 @@ typedef struct ArgoBRPStreamHeader {
>  
>  typedef struct ArgoBRPDemuxContext {
>  ArgoBRPFileHeader   fhdr;
> -ArgoBRPStreamHeader *streams;
> +ArgoBRPStreamHeader streams[BRP_MAX_STREAMS];
>  /* To know how much of a BASF to give. */
>  int64_t lastpts;
>  int hit_eof;
> @@ -101,16 +101,6 @@ static int argo_brp_probe(const AVProbeData *p)
>  return AVPROBE_SCORE_EXTENSION + 1;
>  }
>  
> -static int argo_brp_read_close(AVFormatContext *s)
> -{
> -ArgoBRPDemuxContext *brp = s->priv_data;
> -
> -if (brp->streams != NULL)
> -av_freep(&brp->streams);
> -
> -return 0;
> -}
> -
>  static int read_extradata(AVFormatContext *s, const ArgoBRPStreamHeader *hdr,
>void *buf, size_t bufsz)
>  {
> @@ -174,9 +164,6 @@ static int argo_brp_read_header(AVFormatContext *s)
>  return AVERROR_PATCHWELCOME;
>  }
>  
> -if ((brp->streams = av_mallocz_array(brp->fhdr.num_streams, 
> sizeof(ArgoBRPStreamHeader))) == NULL)
> -return AVERROR(ENOMEM);
> -
>  /* Build the stream info. */
>  brp->basf.index = -1;
>  for (uint32_t i = 0; i < brp->fhdr.num_streams; i++) {
> @@ -331,8 +318,6 @@ static int argo_brp_read_header(AVFormatContext *s)
>  return 0;
>  
>  fail:
> -/* TODO: Remove once AVFMT_HEADER_CLEANUP lands. */
> -argo_brp_read_close(s);
>  return ret;
>  }
>  
> @@ -444,6 +429,5 @@ AVInputFormat ff_argo_brp_demuxer = {
>  .priv_data_size = sizeof(ArgoBRPDemuxContext),
>  .read_probe = argo_brp_probe,
>  .read_header= argo_brp_read_header,
> -.read_packet= argo_brp_read_packet,
> -.read_close = argo_brp_read_close
> +.read_packet= argo_brp_read_packet

Unless you absolutely know that no entry will ever be added afterwards
(e.g. if you have a sentinel), you should add a trailing comma as this
means that if you add/remove a line later, you will leave the other
lines as they are. If not, the diff will be unnecessarily bigger and
more complicated and the usefulness of git blame will suffer (if you
applied the above, git blame would show that this commit added the
read_pack line and one would have to go further into the history to see
the commit that really did it).
So just remove the offending read_close, but leave the other stuff
untouched.

>  };
> 

___
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/aviobuf: fix broken logic in ffio_ensure_seekback()

2020-09-20 Thread Marton Balint



On Sun, 20 Sep 2020, Paul B Mahol wrote:


On Sat, Sep 19, 2020 at 11:46:50PM +0200, Marton Balint wrote:



On Sat, 19 Sep 2020, Paul B Mahol wrote:

> On Thu, Sep 17, 2020 at 12:31:06PM +0200, Paul B Mahol wrote:
> > This removes big CPU overhead for demuxing chained ogg streams.
> > 
> > Signed-off-by: Paul B Mahol 

> > ---
> >  libavformat/aviobuf.c | 10 +-
> >  1 file changed, 5 insertions(+), 5 deletions(-)
> > 
> 
> will apply soon.


Don't apply it, as I explained, it is not correct.


I carefully examined your explanation and I already reported
here on mailing list for every one to see that it does not work.

So please reconsider your blocking statement and provide
correct solution to problem.


Your solution will break the fundamentals of ffio_ensure_seekback, so it 
is not OK. Checking if (buf_size <= s->buffer_size) will not guarantee 
that the buffer will not be flushed when reading the next buf_size bytes 
because buf_ptr can be anywhere in the buffer. See how fill_buffer() 
works. It not only makes sure the buffer has space, it makes sure that the 
buffer has max_buffer_size space available. If not, then it gets flushed.


There are some issues with current code, I will send a patch to fix them. 
Unfortunately it will NOT fix your problem entirely. As I suggested, if 
you use 2*max_buffer_size buffers by default, that might help you, but the 
fundamental problem is that ffio_ensure_seekback simply cannot be 
implemented efficiently with the current design. The guarantees should be 
reduced (e.g. ffio_ensure_seekback can flush the buffer and invalidate 
previous ffio_ensure_seekback request)


Regards,
Marton
___
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/3] avformat/aviobuf: increase default read buffer size to 2*max_buffer_size for streamed data

2020-09-20 Thread Marton Balint
This should increase the effectiveness of ffio_ensure_seekback.

Note: increasing buffer size to non-streamed or write buffer should also
work, but they both cause fate failures... The reason for that should be
checked.

Signed-off-by: Marton Balint 
---
 libavformat/aviobuf.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index aa1d6c0830..13cad7f5f0 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -938,6 +938,11 @@ int ffio_fdopen(AVIOContext **s, URLContext *h)
 } else {
 buffer_size = IO_BUFFER_SIZE;
 }
+if (h->flags & AVIO_FLAG_READ && h->is_streamed) {
+if (buffer_size > INT_MAX/2)
+return AVERROR(EINVAL);
+buffer_size *= 2;
+}
 buffer = av_malloc(buffer_size);
 if (!buffer)
 return AVERROR(ENOMEM);
-- 
2.26.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 1/3] avformat/aviobuf: read till the very end of the IO buffer

2020-09-20 Thread Marton Balint
There was an off-by-one error when checking if the IO buffer still has enough
space till the end.

Signed-off-by: Marton Balint 
---
 libavformat/aviobuf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index a77517d712..9675425349 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -540,7 +540,7 @@ static void fill_buffer(AVIOContext *s)
 {
 int max_buffer_size = s->max_packet_size ?
   s->max_packet_size : IO_BUFFER_SIZE;
-uint8_t *dst= s->buf_end - s->buffer + max_buffer_size < 
s->buffer_size ?
+uint8_t *dst= s->buf_end - s->buffer + max_buffer_size <= 
s->buffer_size ?
   s->buf_end : s->buffer;
 int len = s->buffer_size - (dst - s->buffer);
 
-- 
2.26.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 2/3] avformat/aviobuf: fix checks in ffio_ensure_seekback

2020-09-20 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavformat/aviobuf.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 9675425349..aa1d6c0830 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -999,9 +999,12 @@ int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
 int filled = s->buf_end - s->buffer;
 ptrdiff_t checksum_ptr_offset = s->checksum_ptr ? s->checksum_ptr - 
s->buffer : -1;
 
-buf_size += s->buf_ptr - s->buffer + max_buffer_size;
+if (buf_size <= s->buf_end - s->buf_ptr)
+return 0;
+
+buf_size += s->buf_ptr - s->buffer + max_buffer_size - 1;
 
-if (buf_size < filled || s->seekable || !s->read_packet)
+if (buf_size <= s->buffer_size || s->seekable || !s->read_packet)
 return 0;
 av_assert0(!s->write_flag);
 
-- 
2.26.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".

Re: [FFmpeg-devel] [PATCH 2/2] avformat/swfdec: Avoid unnecessary skip

2020-09-20 Thread Paul B Mahol
On Sun, Sep 20, 2020 at 09:43:46AM +0200, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/swfdec.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 

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

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

Re: [FFmpeg-devel] [PATCH 1/2] avformat/swfenc: Fix memleak upon write_header error

2020-09-20 Thread Paul B Mahol
On Sun, Sep 20, 2020 at 09:43:45AM +0200, Andreas Rheinhardt wrote:
> The SWF muxer accepts at most one mp3 audio and at most one VP6F, FLV1
> or MJPEG stream. Upon encountering an mp3 stream, a fifo is allocated
> that leaks if one of the subsequent streams is incompliant with the
> restrictions mentioned above or if the framerate or samplerate are
> invalid. This is fixed by adding a deinit function to free said fifo.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/swfenc.c | 24 +++-
>  1 file changed, 11 insertions(+), 13 deletions(-)
> 

probably ok
___
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 03/10] avformat/argo_brp: remove an allocation

2020-09-20 Thread Zane van Iperen
On Sun, 20 Sep 2020 10:13:48 +0200
"Andreas Rheinhardt"  wrote:

> > @@ -444,6 +429,5 @@ AVInputFormat ff_argo_brp_demuxer = {
> >  .priv_data_size = sizeof(ArgoBRPDemuxContext),
> >  .read_probe = argo_brp_probe,
> >  .read_header= argo_brp_read_header,
> > -.read_packet= argo_brp_read_packet,
> > -.read_close = argo_brp_read_close
> > +.read_packet= argo_brp_read_packet
> 
> Unless you absolutely know that no entry will ever be added afterwards
> (e.g. if you have a sentinel), you should add a trailing comma as this
> means that if you add/remove a line later, you will leave the other
> lines as they are. If not, the diff will be unnecessarily bigger and
> more complicated and the usefulness of git blame will suffer (if you
> applied the above, git blame would show that this commit added the
> read_pack line and one would have to go further into the history to see
> the commit that really did it).
> So just remove the offending read_close, but leave the other stuff
> untouched.

Whoops, never meant to remove it. Have fixed locally.

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

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

Re: [FFmpeg-devel] [PATCH 01/10] avformat/argo_asf: fix enforcement of chunk count

2020-09-20 Thread Zane van Iperen
On Sun, 20 Sep 2020 10:54:44 +0200
"Paul B Mahol"  wrote:

> 
> On Sun, Sep 20, 2020 at 08:06:18AM +, Zane van Iperen wrote:
> > Enforcing num_chunks == 1 only makes sense when demuxing from an ASF
> > file. When embedded in a BRP file, an ASF stream can have multiple chunks.
> >
> > Signed-off-by: Zane van Iperen 
> > ---
> >  libavformat/argo_asf.c | 17 ++---
> >  1 file changed, 10 insertions(+), 7 deletions(-)
> >
> 
> LGTM this set except last two patches (patch 9 and patch 10), they are not 
> needed.
> 
> I would like to commit that lines when actual decoder comes not before.

Okay, I'll leave them out.


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

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

Re: [FFmpeg-devel] [PATCH 01/10] avformat/argo_asf: fix enforcement of chunk count

2020-09-20 Thread Paul B Mahol
On Sun, Sep 20, 2020 at 08:06:18AM +, Zane van Iperen wrote:
> Enforcing num_chunks == 1 only makes sense when demuxing from an ASF
> file. When embedded in a BRP file, an ASF stream can have multiple chunks.
> 
> Signed-off-by: Zane van Iperen 
> ---
>  libavformat/argo_asf.c | 17 ++---
>  1 file changed, 10 insertions(+), 7 deletions(-)
> 

LGTM this set except last two patches (patch 9 and patch 10), they are not 
needed.

I would like to commit that lines when actual decoder comes not before.
___
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/3] avformat/aviobuf: read till the very end of the IO buffer

2020-09-20 Thread Paul B Mahol
On Sun, Sep 20, 2020 at 10:52:51AM +0200, Marton Balint wrote:
> There was an off-by-one error when checking if the IO buffer still has enough
> space till the end.

How to reproduce such error(s)?

> 
> Signed-off-by: Marton Balint 
> ---
>  libavformat/aviobuf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
> index a77517d712..9675425349 100644
> --- a/libavformat/aviobuf.c
> +++ b/libavformat/aviobuf.c
> @@ -540,7 +540,7 @@ static void fill_buffer(AVIOContext *s)
>  {
>  int max_buffer_size = s->max_packet_size ?
>s->max_packet_size : IO_BUFFER_SIZE;
> -uint8_t *dst= s->buf_end - s->buffer + max_buffer_size < 
> s->buffer_size ?
> +uint8_t *dst= s->buf_end - s->buffer + max_buffer_size <= 
> s->buffer_size ?
>s->buf_end : s->buffer;
>  int len = s->buffer_size - (dst - s->buffer);
>  
> -- 
> 2.26.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 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] avfilter/vf_scale: translate and verify swscale internal range flag

2020-09-20 Thread Jan Ekström
This value - while it looks like the actual range of the content -
is nothing but the internal value of swscale.

Thus, if we have RGB content, translate the value to 1 which is what
at least this filter expects for RGB. Swscale will ignore this value
when set.

Additionally, after calling sws_setColorspaceDetails double-check
the configured internal flag for the color range. Warn if this is
different to the requested value.

Finally, utilize the translated configured output value as the
output AVFrame's color_range.
---
 libavfilter/vf_scale.c | 44 +-
 1 file changed, 43 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 58eee96744..da8ce399cf 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -647,6 +647,8 @@ static int scale_slice(AVFilterLink *link, AVFrame 
*out_buf, AVFrame *cur_pic, s
  out,out_stride);
 }
 
+// swscale's internal range flag is 0 for RGB, which we have to override
+#define NORMALIZE_SWS_RANGE(format_flags, sws_range) (((format_flags) & 
AV_PIX_FMT_FLAG_RGB) ? 1 : (sws_range))
 static int scale_frame(AVFilterLink *link, AVFrame *in, AVFrame **frame_out)
 {
 AVFilterContext *ctx = link->dst;
@@ -750,11 +752,19 @@ scale:
 || in_range != AVCOL_RANGE_UNSPECIFIED
 || scale->out_range != AVCOL_RANGE_UNSPECIFIED) {
 int in_full, out_full, brightness, contrast, saturation;
+int configured_in_full_range_flag, configured_out_full_range_flag;
 const int *inv_table, *table;
+const AVPixFmtDescriptor *in_desc  = av_pix_fmt_desc_get(in->format);
+const AVPixFmtDescriptor *out_desc = av_pix_fmt_desc_get(out->format);
+av_assert0(in_desc && out_desc);
 
 sws_getColorspaceDetails(scale->sws, (int **)&inv_table, &in_full,
  (int **)&table, &out_full,
  &brightness, &contrast, &saturation);
+// translate the internal range flags according to this
+// filter's expectations for RGB.
+in_full = NORMALIZE_SWS_RANGE(in_desc->flags, in_full);
+out_full = NORMALIZE_SWS_RANGE(out_desc->flags, out_full);
 
 if (scale->in_color_matrix)
 inv_table = parse_yuv_type(scale->in_color_matrix, in->colorspace);
@@ -782,7 +792,39 @@ scale:
  table, out_full,
  brightness, contrast, saturation);
 
-out->color_range = out_full ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;
+// double-check what was actually just configured,
+// since swscale can silently ignore the color range
+// value in sws_setColorspaceDetails.
+sws_getColorspaceDetails(scale->sws, (int **)&inv_table,
+ &configured_in_full_range_flag,
+ (int **)&table,
+ &configured_out_full_range_flag,
+ &brightness, &contrast, &saturation);
+
+// translate the actually configured internal range flags according
+// to this filter's expectations for RGB.
+configured_in_full_range_flag = \
+NORMALIZE_SWS_RANGE(in_desc->flags,
+configured_in_full_range_flag);
+configured_out_full_range_flag = \
+NORMALIZE_SWS_RANGE(out_desc->flags,
+configured_out_full_range_flag);
+
+if (in_full != configured_in_full_range_flag ||
+out_full != configured_out_full_range_flag) {
+av_log(ctx, AV_LOG_WARNING,
+   "swscale overrode set input/output range value as it "
+   "considered it an invalid configuration! "
+   "(input: requested: %s, configured: %s), "
+   "(output: requested: %s, configured: %s)!\n",
+   in_full ? "full" : "limited",
+   configured_in_full_range_flag ? "full" : "limited",
+   out_full ? "full" : "limited",
+   configured_out_full_range_flag ? "full" : "limited");
+}
+
+out->color_range = configured_out_full_range_flag ?
+   AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;
 }
 
 av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den,
-- 
2.26.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".

Re: [FFmpeg-devel] [PATCH 1/3] avformat/aviobuf: read till the very end of the IO buffer

2020-09-20 Thread Marton Balint



On Sun, 20 Sep 2020, Paul B Mahol wrote:


On Sun, Sep 20, 2020 at 10:52:51AM +0200, Marton Balint wrote:

There was an off-by-one error when checking if the IO buffer still has enough
space till the end.


How to reproduce such error(s)?


It is not something you will notice, only the buffer is flushed when it
does not necessarily need to be.

But I guess you can reproduce it by using an buffer size of 66852 and try
receiving an MPEGTS UDP stream. Without the patch fill_buffer always
flushes, with the patch fill_buffer only flushes in every second
call, as it needs to, because a single UDP TS packet (1316 bytes) and
the potential maximum sized UDP packet (65536 bytes) simultaneously fit in
the buffer.

Regards,
Marton






Signed-off-by: Marton Balint 
---
 libavformat/aviobuf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index a77517d712..9675425349 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -540,7 +540,7 @@ static void fill_buffer(AVIOContext *s)
 {
 int max_buffer_size = s->max_packet_size ?
   s->max_packet_size : IO_BUFFER_SIZE;
-uint8_t *dst= s->buf_end - s->buffer + max_buffer_size < 
s->buffer_size ?
+uint8_t *dst= s->buf_end - s->buffer + max_buffer_size <= 
s->buffer_size ?
   s->buf_end : s->buffer;
 int len = s->buffer_size - (dst - s->buffer);

--
2.26.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 mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

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

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

[FFmpeg-devel] [PATCH 1/1] configure: use require_pkg_config to check for wavpack

2020-09-20 Thread Bernd Kuhls
Fixes static builds with toolchains needing "-lm" for math functions.

Signed-off-by: Bernd Kuhls 
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 5d68695192..4e6c6edd30 100755
--- a/configure
+++ b/configure
@@ -6438,7 +6438,7 @@ enabled libvpx&& {
 fi
 }
 
-enabled libwavpack&& require libwavpack wavpack/wavpack.h 
WavpackOpenFileOutput  -lwavpack
+enabled libwavpack&& require_pkg_config libwavpack wavpack 
"wavpack/wavpack.h" WavpackOpenFileOutput
 enabled libwebp   && {
 enabled libwebp_encoder  && require_pkg_config libwebp "libwebp >= 
0.2.0" webp/encode.h WebPGetEncoderVersion
 enabled libwebp_anim_encoder && check_pkg_config libwebp_anim_encoder 
"libwebpmux >= 0.4.0" webp/mux.h WebPAnimEncoderOptionsInit; }
-- 
2.27.0

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

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

[FFmpeg-devel] [PATCH 3/3] avformat/swf: Separate mux and demux contexts

2020-09-20 Thread Andreas Rheinhardt
There was almost no overlap between them: The only field used by both
was an int named samples_per_frame. Therefore this commit separates
them.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/swf.h| 33 -
 libavformat/swfdec.c | 22 +-
 libavformat/swfenc.c | 35 ++-
 3 files changed, 43 insertions(+), 47 deletions(-)

diff --git a/libavformat/swf.h b/libavformat/swf.h
index d0f0194c3f..b66420c60a 100644
--- a/libavformat/swf.h
+++ b/libavformat/swf.h
@@ -23,15 +23,6 @@
 #ifndef AVFORMAT_SWF_H
 #define AVFORMAT_SWF_H
 
-#include "config.h"
-
-#if CONFIG_ZLIB
-#include 
-#endif
-
-#include "libavutil/fifo.h"
-#include "avformat.h"
-#include "avio.h"
 #include "internal.h"
 
 /* should have a generic way to indicate probable size */
@@ -113,35 +104,11 @@ enum {
 #define FLAG_SETFILL00x02
 #define FLAG_SETFILL10x04
 
-#define AUDIO_FIFO_SIZE 65536
-
 /* character id used */
 #define BITMAP_ID 0
 #define VIDEO_ID 0
 #define SHAPE_ID  1
 
-typedef struct SWFContext {
-int64_t duration_pos;
-int64_t tag_pos;
-int64_t vframes_pos;
-int samples_per_frame;
-int sound_samples;
-int swf_frame_number;
-int video_frame_number;
-int frame_rate;
-int tag;
-AVFifoBuffer *audio_fifo;
-AVCodecParameters *audio_par, *video_par;
-AVStream *video_st;
-#if CONFIG_ZLIB
-#define ZBUF_SIZE 4096
-AVIOContext *zpb;
-uint8_t *zbuf_in;
-uint8_t *zbuf_out;
-z_stream zstream;
-#endif
-} SWFContext;
-
 extern const AVCodecTag ff_swf_codec_tags[];
 
 #endif /* AVFORMAT_SWF_H */
diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c
index d1ed1e2a53..2769a768de 100644
--- a/libavformat/swfdec.c
+++ b/libavformat/swfdec.c
@@ -34,6 +34,18 @@
 #include "libavcodec/get_bits.h"
 #include "swf.h"
 
+typedef struct SWFDecContext {
+int samples_per_frame;
+int frame_rate;
+#if CONFIG_ZLIB
+#define ZBUF_SIZE 4096
+AVIOContext *zpb;
+uint8_t *zbuf_in;
+uint8_t *zbuf_out;
+z_stream zstream;
+#endif
+} SWFDecContext;
+
 static const AVCodecTag swf_audio_codec_tags[] = {
 { AV_CODEC_ID_PCM_S16LE,  0x00 },
 { AV_CODEC_ID_ADPCM_SWF,  0x01 },
@@ -101,7 +113,7 @@ static int swf_probe(const AVProbeData *p)
 static int zlib_refill(void *opaque, uint8_t *buf, int buf_size)
 {
 AVFormatContext *s = opaque;
-SWFContext *swf = s->priv_data;
+SWFDecContext *swf = s->priv_data;
 z_stream *z = &swf->zstream;
 int ret;
 
@@ -134,7 +146,7 @@ static av_cold int swf_read_close(AVFormatContext *avctx);
 
 static int swf_read_header(AVFormatContext *s)
 {
-SWFContext *swf = s->priv_data;
+SWFDecContext *swf = s->priv_data;
 AVIOContext *pb = s->pb;
 int nbits, len, tag;
 
@@ -203,7 +215,7 @@ static AVStream *create_new_audio_stream(AVFormatContext 
*s, int id, int info)
 
 static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
-SWFContext *swf = s->priv_data;
+SWFDecContext *swf = s->priv_data;
 AVIOContext *pb = s->pb;
 AVStream *vst = NULL, *ast = NULL, *st = 0;
 int tag, len, i, frame, v, res;
@@ -526,7 +538,7 @@ bitmap_end_skip:
 #if CONFIG_ZLIB
 static av_cold int swf_read_close(AVFormatContext *avctx)
 {
-SWFContext *s = avctx->priv_data;
+SWFDecContext *s = avctx->priv_data;
 inflateEnd(&s->zstream);
 av_freep(&s->zbuf_in);
 av_freep(&s->zbuf_out);
@@ -538,7 +550,7 @@ static av_cold int swf_read_close(AVFormatContext *avctx)
 AVInputFormat ff_swf_demuxer = {
 .name   = "swf",
 .long_name  = NULL_IF_CONFIG_SMALL("SWF (ShockWave Flash)"),
-.priv_data_size = sizeof(SWFContext),
+.priv_data_size = sizeof(SWFDecContext),
 .read_probe = swf_probe,
 .read_header= swf_read_header,
 .read_packet= swf_read_packet,
diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c
index 750ec56ec1..14be2b72aa 100644
--- a/libavformat/swfenc.c
+++ b/libavformat/swfenc.c
@@ -22,12 +22,29 @@
 
 #include "libavcodec/put_bits.h"
 #include "libavutil/avassert.h"
+#include "libavutil/fifo.h"
 #include "avformat.h"
 #include "swf.h"
 
+#define AUDIO_FIFO_SIZE 65536
+
+typedef struct SWFEncContext {
+int64_t duration_pos;
+int64_t tag_pos;
+int64_t vframes_pos;
+int samples_per_frame;
+int sound_samples;
+int swf_frame_number;
+int video_frame_number;
+int tag;
+AVFifoBuffer *audio_fifo;
+AVCodecParameters *audio_par, *video_par;
+AVStream *video_st;
+} SWFEncContext;
+
 static void put_swf_tag(AVFormatContext *s, int tag)
 {
-SWFContext *swf = s->priv_data;
+SWFEncContext *swf = s->priv_data;
 AVIOContext *pb = s->pb;
 
 swf->tag_pos = avio_tell(pb);
@@ -43,7 +60,7 @@ static void put_swf_tag(AVFormatContext *s, int tag)
 
 static void put_swf_end_tag(AVFormatContext *s)
 {
-SWFContext *swf = s->priv_data;
+SWFEncContext *swf = s->priv_data;
 AVIOContext *pb = s->pb;
 int64_t pos;
 int t

[FFmpeg-devel] [PATCH 2/3] avformat/swfdec: Reorder allocations/initializations

2020-09-20 Thread Andreas Rheinhardt
The earlier code would first attempt to allocate two buffers, then
attempt to allocate an AVIOContext, using one of the new buffers I/O
buffer, then check the allocations. On success, a z_stream that is used
in the AVIOContext's read_packet callback is initialized afterwards.

There are two problems with this: In case the allocation of the I/O
buffer fails avio_alloc_context() will be given a NULL read buffer
with a size > 0. This works right now, but it is fragile. The second
problem is that the z_stream used in the read_packet callback is not
functional when avio_alloc_context() is allocated (it might be that
avio_alloc_context() might already fill the buffer in the future). This
commit fixes both of these problems by reordering the operations.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/swfdec.c | 24 ++--
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c
index 7a74fa3ac7..d1ed1e2a53 100644
--- a/libavformat/swfdec.c
+++ b/libavformat/swfdec.c
@@ -128,6 +128,8 @@ retry:
 
 return buf_size - z->avail_out;
 }
+
+static av_cold int swf_read_close(AVFormatContext *avctx);
 #endif
 
 static int swf_read_header(AVFormatContext *s)
@@ -142,24 +144,18 @@ static int swf_read_header(AVFormatContext *s)
 if (tag == MKBETAG('C', 'W', 'S', 0)) {
 av_log(s, AV_LOG_INFO, "SWF compressed file detected\n");
 #if CONFIG_ZLIB
-swf->zbuf_in  = av_malloc(ZBUF_SIZE);
-swf->zbuf_out = av_malloc(ZBUF_SIZE);
-swf->zpb = avio_alloc_context(swf->zbuf_out, ZBUF_SIZE, 0, s,
-  zlib_refill, NULL, NULL);
-if (!swf->zbuf_in || !swf->zbuf_out || !swf->zpb) {
-av_freep(&swf->zbuf_in);
-av_freep(&swf->zbuf_out);
-avio_context_free(&swf->zpb);
-return AVERROR(ENOMEM);
-}
-swf->zpb->seekable = 0;
 if (inflateInit(&swf->zstream) != Z_OK) {
 av_log(s, AV_LOG_ERROR, "Unable to init zlib context\n");
-av_freep(&swf->zbuf_in);
-av_freep(&swf->zbuf_out);
-avio_context_free(&swf->zpb);
 return AVERROR(EINVAL);
 }
+if (!(swf->zbuf_in  = av_malloc(ZBUF_SIZE)) ||
+!(swf->zbuf_out = av_malloc(ZBUF_SIZE)) ||
+!(swf->zpb = avio_alloc_context(swf->zbuf_out, ZBUF_SIZE, 0,
+s, zlib_refill, NULL, NULL))) {
+swf_read_close(s);
+return AVERROR(ENOMEM);
+}
+swf->zpb->seekable = 0;
 pb = swf->zpb;
 #else
 av_log(s, AV_LOG_ERROR, "zlib support is required to read SWF 
compressed files\n");
-- 
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/3] avformat/swfdec: Fix memleaks on error

2020-09-20 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/swfdec.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c
index e427998744..7a74fa3ac7 100644
--- a/libavformat/swfdec.c
+++ b/libavformat/swfdec.c
@@ -146,13 +146,18 @@ static int swf_read_header(AVFormatContext *s)
 swf->zbuf_out = av_malloc(ZBUF_SIZE);
 swf->zpb = avio_alloc_context(swf->zbuf_out, ZBUF_SIZE, 0, s,
   zlib_refill, NULL, NULL);
-if (!swf->zbuf_in || !swf->zbuf_out || !swf->zpb)
+if (!swf->zbuf_in || !swf->zbuf_out || !swf->zpb) {
+av_freep(&swf->zbuf_in);
+av_freep(&swf->zbuf_out);
+avio_context_free(&swf->zpb);
 return AVERROR(ENOMEM);
+}
 swf->zpb->seekable = 0;
 if (inflateInit(&swf->zstream) != Z_OK) {
 av_log(s, AV_LOG_ERROR, "Unable to init zlib context\n");
 av_freep(&swf->zbuf_in);
 av_freep(&swf->zbuf_out);
+avio_context_free(&swf->zpb);
 return AVERROR(EINVAL);
 }
 pb = swf->zpb;
-- 
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".

Re: [FFmpeg-devel] [PATCH 00/10] argo_brp cleanups and fixes

2020-09-20 Thread Zane van Iperen
On Sun, 20 Sep 2020 08:06:09 +
"Zane van Iperen"  wrote:

> 
> Fixes handling of embedded ASF streams and BVID timestamps. Also adds
> AV_CODEC_ID_ARGO to libavcodec in preparation for Paul's decoder.

I'll push this shortly without parts 9 & 10 and with the missing ','
readded.

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

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

Re: [FFmpeg-devel] [PATCH 1/1] configure: use require_pkg_config to check for wavpack

2020-09-20 Thread Carl Eugen Hoyos




> Am 20.09.2020 um 13:52 schrieb Bernd Kuhls :
> 
> Fixes static builds with toolchains needing "-lm" for math functions.

Please don’t.

Why is this necessary? Doesn’t every FFmpeg link command contain -lm?

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

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

Re: [FFmpeg-devel] [PATCH 2/3] avformat/aviobuf: fix checks in ffio_ensure_seekback

2020-09-20 Thread Paul B Mahol
On Sun, Sep 20, 2020 at 10:52:52AM +0200, Marton Balint wrote:
> Signed-off-by: Marton Balint 
> ---
>  libavformat/aviobuf.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
> index 9675425349..aa1d6c0830 100644
> --- a/libavformat/aviobuf.c
> +++ b/libavformat/aviobuf.c
> @@ -999,9 +999,12 @@ int ffio_ensure_seekback(AVIOContext *s, int64_t 
> buf_size)
>  int filled = s->buf_end - s->buffer;
>  ptrdiff_t checksum_ptr_offset = s->checksum_ptr ? s->checksum_ptr - 
> s->buffer : -1;
>  
> -buf_size += s->buf_ptr - s->buffer + max_buffer_size;
> +if (buf_size <= s->buf_end - s->buf_ptr)
> +return 0;
> +
> +buf_size += s->buf_ptr - s->buffer + max_buffer_size - 1;
>  
> -if (buf_size < filled || s->seekable || !s->read_packet)
> +if (buf_size <= s->buffer_size || s->seekable || !s->read_packet)
>  return 0;
>  av_assert0(!s->write_flag);


Not acceptable change.

Your code does this to chained ogg files:

XXX 10
XXX 65307
XXX 65307
102031
106287
110527
114745
119319
[...]

It continues allocating excessive small extra chunks of bytes for no apparent 
reason in each and every call
which slowly and gradually increases memory usage, but every call causes 
unnecessary memcpy calls thus causing
almost exponential slowdown of file processing.

Lines with XXX, means that allocation and memcpy was not needed.

I can also post behavior of my solution, which work just fine, and I yet need 
to find scenario when it does not work.

>  
> -- 
> 2.26.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 mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 1/1] configure: use require_pkg_config to check for wavpack

2020-09-20 Thread Jan Ekström
On Sun, Sep 20, 2020 at 3:34 PM Carl Eugen Hoyos  wrote:
>
>
>
>
>
> > Am 20.09.2020 um 13:52 schrieb Bernd Kuhls :
> >
> > Fixes static builds with toolchains needing "-lm" for math functions.
>
> Please don’t.
>

Please reword this in another way if your meaning is to note that
you'd like the configure option to still work without pkg-config.

I find pkg-config (or its less glib-dependant reimplementation,
pkgconf) to be great helpers, esp. when coupled with
PKG_CONFIG_{PATH,LIBDIR} (PATH appends, LIBDIR overrides) if you have
a custom prefix. So in my opinion the more pkg-config enabled checks
the better.

> Why is this necessary? Doesn’t every FFmpeg link command contain -lm?
>

"-lm" is only utilized in host_extralibs (and disabled in Haiku,
apparently), which is only utilized in `ffbuild/common.mak`. So when
you are doing configure checks you are going to be missing all of the
usual flags that you have not specifically specified in each and every
check.

That said, there is also a `libm` check_lib check which most likely
exports `libm_extralibs` as its result. It seems to be also utilized
in various checks where pkg-config is not utilized and the math
library was found to be required as part of the check.

Jan

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

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

Re: [FFmpeg-devel] [PATCH 2/3] avformat/aviobuf: fix checks in ffio_ensure_seekback

2020-09-20 Thread Marton Balint



On Sun, 20 Sep 2020, Paul B Mahol wrote:


On Sun, Sep 20, 2020 at 10:52:52AM +0200, Marton Balint wrote:

Signed-off-by: Marton Balint 
---
 libavformat/aviobuf.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 9675425349..aa1d6c0830 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -999,9 +999,12 @@ int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
 int filled = s->buf_end - s->buffer;
 ptrdiff_t checksum_ptr_offset = s->checksum_ptr ? s->checksum_ptr - 
s->buffer : -1;

-buf_size += s->buf_ptr - s->buffer + max_buffer_size;
+if (buf_size <= s->buf_end - s->buf_ptr)
+return 0;
+
+buf_size += s->buf_ptr - s->buffer + max_buffer_size - 1;

-if (buf_size < filled || s->seekable || !s->read_packet)
+if (buf_size <= s->buffer_size || s->seekable || !s->read_packet)
 return 0;
 av_assert0(!s->write_flag);



Not acceptable change.

Your code does this to chained ogg files:

XXX 10
XXX 65307
XXX 65307
102031
106287
110527
114745
119319
[...]


This was also the case before the patch, no? So this alone is no reason
to reject the patch.



It continues allocating excessive small extra chunks of bytes for no apparent 
reason in each and every call
which slowly and gradually increases memory usage, but every call causes 
unnecessary memcpy calls thus causing
almost exponential slowdown of file processing.


And when I say ffio_ensure_seekback() has a design issue, this is exactly 
what I mean. It is not that suprising, consider this:


I have 32k buffer, and I read at most 32k at once.
I want seekback of 64k. Buffer got increased to 96k
I read 64k.
I want seekback of 64k. Buffer got increased to 160k.
I read 64k.
... and so on.

a read call cannot flush the buffer because I am always whitin my 
requested boundary. ffio_ensure_seekback() cannot flush the buffer either, 
because it is not allowed to do that. Therefore I consume infinite memory.




Lines with XXX, means that allocation and memcpy was not needed.


Are you sure about that? Feel free to give an example with buffer sizes 
and buffer positions, and prove that reallocation is uneeded. But please 
be aware how fill_buffer() works and make sure that when reading 
sequentially up to buf_size, seeking within the current pos and 
pos+buf_size is possible.


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

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

Re: [FFmpeg-devel] [PATCH 2/3] avformat/aviobuf: fix checks in ffio_ensure_seekback

2020-09-20 Thread Paul B Mahol
On Sun, Sep 20, 2020 at 03:16:15PM +0200, Marton Balint wrote:
> 
> 
> On Sun, 20 Sep 2020, Paul B Mahol wrote:
> 
> > On Sun, Sep 20, 2020 at 10:52:52AM +0200, Marton Balint wrote:
> > > Signed-off-by: Marton Balint 
> > > ---
> > >  libavformat/aviobuf.c | 7 +--
> > >  1 file changed, 5 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
> > > index 9675425349..aa1d6c0830 100644
> > > --- a/libavformat/aviobuf.c
> > > +++ b/libavformat/aviobuf.c
> > > @@ -999,9 +999,12 @@ int ffio_ensure_seekback(AVIOContext *s, int64_t 
> > > buf_size)
> > >  int filled = s->buf_end - s->buffer;
> > >  ptrdiff_t checksum_ptr_offset = s->checksum_ptr ? s->checksum_ptr - 
> > > s->buffer : -1;
> > > 
> > > -buf_size += s->buf_ptr - s->buffer + max_buffer_size;
> > > +if (buf_size <= s->buf_end - s->buf_ptr)
> > > +return 0;
> > > +
> > > +buf_size += s->buf_ptr - s->buffer + max_buffer_size - 1;
> > > 
> > > -if (buf_size < filled || s->seekable || !s->read_packet)
> > > +if (buf_size <= s->buffer_size || s->seekable || !s->read_packet)
> > >  return 0;
> > >  av_assert0(!s->write_flag);
> > 
> > 
> > Not acceptable change.
> > 
> > Your code does this to chained ogg files:
> > 
> > XXX 10
> > XXX 65307
> > XXX 65307
> > 102031
> > 106287
> > 110527
> > 114745
> > 119319
> > [...]
> 
> This was also the case before the patch, no? So this alone is no reason
> to reject the patch.

Exactly the reson for patch rejection is that it does not improve code at all.

> 
> > 
> > It continues allocating excessive small extra chunks of bytes for no 
> > apparent reason in each and every call
> > which slowly and gradually increases memory usage, but every call causes 
> > unnecessary memcpy calls thus causing
> > almost exponential slowdown of file processing.
> 
> And when I say ffio_ensure_seekback() has a design issue, this is exactly
> what I mean. It is not that suprising, consider this:
> 
> I have 32k buffer, and I read at most 32k at once.
> I want seekback of 64k. Buffer got increased to 96k
> I read 64k.
> I want seekback of 64k. Buffer got increased to 160k.
> I read 64k.
> ... and so on.

My patch exactly does that and it proves it works.

> 
> a read call cannot flush the buffer because I am always whitin my requested
> boundary. ffio_ensure_seekback() cannot flush the buffer either, because it
> is not allowed to do that. Therefore I consume infinite memory.

This explanation is flawed.

> 
> > 
> > Lines with XXX, means that allocation and memcpy was not needed.
> 
> Are you sure about that? Feel free to give an example with buffer sizes and
> buffer positions, and prove that reallocation is uneeded. But please be
> aware how fill_buffer() works and make sure that when reading sequentially
> up to buf_size, seeking within the current pos and pos+buf_size is possible.

Seeking should be possible anywhere between buffer start and buffer end.
current buffer ptr is not important as it just points within buffer.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 2/3] avformat/aviobuf: fix checks in ffio_ensure_seekback

2020-09-20 Thread Marton Balint



On Sun, 20 Sep 2020, Paul B Mahol wrote:


On Sun, Sep 20, 2020 at 03:16:15PM +0200, Marton Balint wrote:



On Sun, 20 Sep 2020, Paul B Mahol wrote:

> On Sun, Sep 20, 2020 at 10:52:52AM +0200, Marton Balint wrote:
> > Signed-off-by: Marton Balint 
> > ---
> >  libavformat/aviobuf.c | 7 +--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> > 
> > diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c

> > index 9675425349..aa1d6c0830 100644
> > --- a/libavformat/aviobuf.c
> > +++ b/libavformat/aviobuf.c
> > @@ -999,9 +999,12 @@ int ffio_ensure_seekback(AVIOContext *s, int64_t 
buf_size)
> >  int filled = s->buf_end - s->buffer;
> >  ptrdiff_t checksum_ptr_offset = s->checksum_ptr ? s->checksum_ptr - 
s->buffer : -1;
> > 
> > -buf_size += s->buf_ptr - s->buffer + max_buffer_size;

> > +if (buf_size <= s->buf_end - s->buf_ptr)
> > +return 0;
> > +
> > +buf_size += s->buf_ptr - s->buffer + max_buffer_size - 1;
> > 
> > -if (buf_size < filled || s->seekable || !s->read_packet)

> > +if (buf_size <= s->buffer_size || s->seekable || !s->read_packet)
> >  return 0;
> >  av_assert0(!s->write_flag);
> 
> 
> Not acceptable change.
> 
> Your code does this to chained ogg files:
> 
> XXX 10

> XXX 65307
> XXX 65307
> 102031
> 106287
> 110527
> 114745
> 119319
> [...]

This was also the case before the patch, no? So this alone is no reason
to reject the patch.


Exactly the reson for patch rejection is that it does not improve code at all.


It might not fix your issue, but it certainly improves the code.





> 
> It continues allocating excessive small extra chunks of bytes for no apparent reason in each and every call

> which slowly and gradually increases memory usage, but every call causes 
unnecessary memcpy calls thus causing
> almost exponential slowdown of file processing.

And when I say ffio_ensure_seekback() has a design issue, this is exactly
what I mean. It is not that suprising, consider this:

I have 32k buffer, and I read at most 32k at once.
I want seekback of 64k. Buffer got increased to 96k
I read 64k.
I want seekback of 64k. Buffer got increased to 160k.
I read 64k.
... and so on.


My patch exactly does that and it proves it works.



a read call cannot flush the buffer because I am always whitin my requested
boundary. ffio_ensure_seekback() cannot flush the buffer either, because it
is not allowed to do that. Therefore I consume infinite memory.


This explanation is flawed.


Please point out where the flaw is.

Thanks,
Marton





> 
> Lines with XXX, means that allocation and memcpy was not needed.


Are you sure about that? Feel free to give an example with buffer sizes and
buffer positions, and prove that reallocation is uneeded. But please be
aware how fill_buffer() works and make sure that when reading sequentially
up to buf_size, seeking within the current pos and pos+buf_size is possible.


Seeking should be possible anywhere between buffer start and buffer end.
current buffer ptr is not important as it just points within buffer.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

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

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

Re: [FFmpeg-devel] [PATCH 1/1] configure: use require_pkg_config to check for wavpack

2020-09-20 Thread James Almer
On 9/20/2020 8:52 AM, Bernd Kuhls wrote:
> Fixes static builds with toolchains needing "-lm" for math functions.
> 
> Signed-off-by: Bernd Kuhls 
> ---
>  configure | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/configure b/configure
> index 5d68695192..4e6c6edd30 100755
> --- a/configure
> +++ b/configure
> @@ -6438,7 +6438,7 @@ enabled libvpx&& {
>  fi
>  }
>  
> -enabled libwavpack&& require libwavpack wavpack/wavpack.h 
> WavpackOpenFileOutput  -lwavpack
> +enabled libwavpack&& require_pkg_config libwavpack wavpack 
> "wavpack/wavpack.h" WavpackOpenFileOutput

For the sake of not breaking compilation with incomplete build
environments, add the pkg_config check while keeping the old check as a
fallback with the addition of $libm_extralibs after -lwavpack, which
should include -lm when present.

This means doing { check_pkg_config ... || require ... }, like with
libsmbclient.

>  enabled libwebp   && {
>  enabled libwebp_encoder  && require_pkg_config libwebp "libwebp >= 
> 0.2.0" webp/encode.h WebPGetEncoderVersion
>  enabled libwebp_anim_encoder && check_pkg_config libwebp_anim_encoder 
> "libwebpmux >= 0.4.0" webp/mux.h WebPAnimEncoderOptionsInit; }
> 

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

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

Re: [FFmpeg-devel] [PATCH 1/1] configure: use require_pkg_config to check for wavpack

2020-09-20 Thread Timo Rothenpieler

Consider just not using libwavpack at all.
The ffmpeg native wavpack code has more features.

There even is a patch on this list for its removal.
___
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/tedcaptionsdec: Fix leak of AVBPrint upon error

2020-09-20 Thread Andreas Rheinhardt
The tedcaptions demuxer uses an AVBPrint whose string is not restricted
to its internal buffer; it therefore needs to be cleaned up, yet this is
not done on error, as parse_file() returned simply returned directly.
This is fixed by going to fail first in such cases.
Furthermore, there is also a second way how this string can leak: By
having more than one subtitle per subtitle block, as the new one simply
overwrites the old one in this case as the AVBPrint is initialized each
time upon encountering a subtitle line. The code has been modified to
simply append the new subtitle to the old one, so that the old one can't
leak any more.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/tedcaptionsdec.c | 73 ++--
 1 file changed, 36 insertions(+), 37 deletions(-)

diff --git a/libavformat/tedcaptionsdec.c b/libavformat/tedcaptionsdec.c
index 3255819e77..6c25d602d6 100644
--- a/libavformat/tedcaptionsdec.c
+++ b/libavformat/tedcaptionsdec.c
@@ -94,25 +94,20 @@ static int parse_string(AVIOContext *pb, int *cur_byte, 
AVBPrint *bp, int full)
 {
 int ret;
 
-av_bprint_init(bp, 0, full ? AV_BPRINT_SIZE_UNLIMITED : 
AV_BPRINT_SIZE_AUTOMATIC);
 ret = expect_byte(pb, cur_byte, '"');
 if (ret < 0)
-goto fail;
+return ret;
 while (*cur_byte > 0 && *cur_byte != '"') {
 if (*cur_byte == '\\') {
 next_byte(pb, cur_byte);
-if (*cur_byte < 0) {
-ret = AVERROR_INVALIDDATA;
-goto fail;
-}
+if (*cur_byte < 0)
+return AVERROR_INVALIDDATA;
 if ((*cur_byte | 32) == 'u') {
 unsigned chr = 0, i;
 for (i = 0; i < 4; i++) {
 next_byte(pb, cur_byte);
-if (!HEX_DIGIT_TEST(*cur_byte)) {
-ret = ERR_CODE(*cur_byte);
-goto fail;
-}
+if (!HEX_DIGIT_TEST(*cur_byte))
+return ERR_CODE(*cur_byte);
 chr = chr * 16 + HEX_DIGIT_VAL(*cur_byte);
 }
 av_bprint_utf8(bp, chr);
@@ -126,22 +121,18 @@ static int parse_string(AVIOContext *pb, int *cur_byte, 
AVBPrint *bp, int full)
 }
 ret = expect_byte(pb, cur_byte, '"');
 if (ret < 0)
-goto fail;
-if (full && !av_bprint_is_complete(bp)) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
-return 0;
+return ret;
+if (full && !av_bprint_is_complete(bp))
+return AVERROR(ENOMEM);
 
-fail:
-av_bprint_finalize(bp, NULL);
-return ret;
+return 0;
 }
 
 static int parse_label(AVIOContext *pb, int *cur_byte, AVBPrint *bp)
 {
 int ret;
 
+av_bprint_init(bp, 0, AV_BPRINT_SIZE_AUTOMATIC);
 ret = parse_string(pb, cur_byte, bp, 0);
 if (ret < 0)
 return ret;
@@ -195,6 +186,8 @@ static int parse_file(AVIOContext *pb, 
FFDemuxSubtitlesQueue *subs)
 int64_t pos, start, duration;
 AVPacket *pkt;
 
+av_bprint_init(&content, 0, AV_BPRINT_SIZE_UNLIMITED);
+
 next_byte(pb, &cur_byte);
 ret = expect_byte(pb, &cur_byte, '{');
 if (ret < 0)
@@ -206,34 +199,34 @@ static int parse_file(AVIOContext *pb, 
FFDemuxSubtitlesQueue *subs)
 if (ret < 0)
 return AVERROR_INVALIDDATA;
 while (1) {
-content.size = 0;
 start = duration = AV_NOPTS_VALUE;
 ret = expect_byte(pb, &cur_byte, '{');
 if (ret < 0)
-return ret;
+goto fail;
 pos = avio_tell(pb) - 1;
 while (1) {
 ret = parse_label(pb, &cur_byte, &label);
 if (ret < 0)
-return ret;
+goto fail;
 if (!strcmp(label.str, "startOfParagraph")) {
 ret = parse_boolean(pb, &cur_byte, &start_of_par);
 if (ret < 0)
-return ret;
+goto fail;
 } else if (!strcmp(label.str, "content")) {
 ret = parse_string(pb, &cur_byte, &content, 1);
 if (ret < 0)
-return ret;
+goto fail;
 } else if (!strcmp(label.str, "startTime")) {
 ret = parse_int(pb, &cur_byte, &start);
 if (ret < 0)
-return ret;
+goto fail;
 } else if (!strcmp(label.str, "duration")) {
 ret = parse_int(pb, &cur_byte, &duration);
 if (ret < 0)
-return ret;
+goto fail;
 } else {
-return AVERROR_INVALIDDATA;
+ret = AVERROR_INVALIDDATA;
+goto fail;
 }
 skip_spaces(pb, &cur_byte);
 if (cur_byte != ',')
@@ -242,18 +235,22 @@ static int parse_file(AVIOContext *pb, 
FFDemuxSubtitlesQueue *subs)
 }
 ret = expect_byte(pb, &cur_byte, '}');
 if

Re: [FFmpeg-devel] [PATCH v2] avutil/pixfmt: improve definition of AVColorRange

2020-09-20 Thread Michael Niedermayer
On Sat, Sep 19, 2020 at 02:42:01PM +0300, Jan Ekström wrote:
> As it was brought up that the current documentation leaves things
> as specific to YCbCr only, ICtCp and RGB are now mentioned.
> Additionally, the specifications on which these definitions of
> narrow and full range are defined are mentioned.
> 
> This way, the documentation of AVColorRange should now match how
> most people seem to read interpret it at this point, and thus
> flagging RGB AVFrames as full range is valid not only according to
> common sense, but also the enum definition.
> ---
>  libavutil/pixfmt.h | 54 +++---
>  1 file changed, 51 insertions(+), 3 deletions(-)
> 
> diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
> index a46acf3c5e..480ac9bb42 100644
> --- a/libavutil/pixfmt.h
> +++ b/libavutil/pixfmt.h
> @@ -530,12 +530,60 @@ enum AVColorSpace {
>  };
>  
>  /**
> - * MPEG vs JPEG YUV range.
> + * Visual content value range.
> + *
> + * These values are based on definitions that can be found in multiple
> + * specifications, such as ITU-T BT.709 (3.4 - Quantization of RGB, luminance
> + * and colour-difference signals), ITU-T BT.2020 (Table 5 - Digital
> + * Representation) as well as ITU-T BT.2100 (Table 9 - Digital 10- and 12-bit
> + * integer representation). At the time of writing, the BT.2100 one is
> + * recommended, as it also defines the full range representation.
> + *
> + * Common definitions:
> + *   - For luminance planes such as Y in YCbCr and I in ICtCp, 'E' is the
> + * original value in range of 0.0 to 1.0.
> + *   - For chrominance planes such as Cb,Cr and Ct,Cp, 'E' is the original
> + * value in range of -0.5 to 0.5.
> + *   - 'n' is the output bit depth.
> + *   - For additional definitions such as rounding and clipping to valid n
> + * bit unsigned integer range, please refer to BT.2100 (Table 9).
>   */
>  enum AVColorRange {
>  AVCOL_RANGE_UNSPECIFIED = 0,
> -AVCOL_RANGE_MPEG= 1, ///< the normal 219*2^(n-8) "MPEG" YUV 
> ranges
> -AVCOL_RANGE_JPEG= 2, ///< the normal 2^n-1   "JPEG" YUV 
> ranges
> +
> +/**
> + * Narrow or limited range content.
> + *
> + * - For RGB and luminance planes:

I suggest to only mention RGB in relation to narrow once this is also
supported by the implementation



> + *
> + *   (219 * E + 16) * 2^(n-8)
> + *
> + *   F.ex. the range of 16-235 for 8 bits
> + *
> + * - For chrominance planes:
> + *
> + *   (224 * E + 128) * 2^(n-8)
> + *
> + *   F.ex. the range of 16-240 for 8 bits
> + */
> +AVCOL_RANGE_MPEG= 1,
> +
> +/**
> + * Full range content.
> + *
> + * - For RGB and luminance planes:
> + *
> + *   (2^n - 1) * E
> + *
> + *   F.ex. the range of 0-255 for 8 bits
> + *
> + * - For chrominance planes:
> + *
> + *   (2^n - 1) * E + 2^(n - 1)
> + *
> + *   F.ex. the range of 1-255 for 8 bits
> + */
> +AVCOL_RANGE_JPEG= 2,
>  AVCOL_RANGE_NB   ///< Not part of ABI
>  };

ok

thanks

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

Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety -- Benjamin Franklin


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] avformat/tedcaptionsdec: Fix leak of AVBPrint upon error

2020-09-20 Thread Nicolas George
Andreas Rheinhardt (12020-09-20):
> The tedcaptions demuxer uses an AVBPrint whose string is not restricted
> to its internal buffer; it therefore needs to be cleaned up, yet this is
> not done on error, as parse_file() returned simply returned directly.
> This is fixed by going to fail first in such cases.
> Furthermore, there is also a second way how this string can leak: By
> having more than one subtitle per subtitle block, as the new one simply
> overwrites the old one in this case as the AVBPrint is initialized each
> time upon encountering a subtitle line. The code has been modified to
> simply append the new subtitle to the old one, so that the old one can't
> leak any more.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/tedcaptionsdec.c | 73 ++--
>  1 file changed, 36 insertions(+), 37 deletions(-)

Should be ok.

I notice that the code calls ff_subtitles_queue_insert() without
checking if the buffer is truncated. It should be fixed too, but that
is separate from this patch.

Regards,

-- 
  Nicolas George


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

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

[FFmpeg-devel] [PATCH] tests/fate-run: Always overwrite output files for md5 tests

2020-09-20 Thread Andreas Rheinhardt
Otherwise the result of such tests will not accurately reflect the
current state.

Signed-off-by: Andreas Rheinhardt 
---
 tests/fate-run.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/fate-run.sh b/tests/fate-run.sh
index 1b283e9c35..58d5fdbb60 100755
--- a/tests/fate-run.sh
+++ b/tests/fate-run.sh
@@ -158,7 +158,7 @@ md5pipe(){
 md5(){
 encfile="${outdir}/${test}.out"
 cleanfiles="$cleanfiles $encfile"
-ffmpeg "$@" $(target_path $encfile)
+ffmpeg -y "$@" $(target_path $encfile)
 do_md5sum $encfile | awk '{print $1}'
 }
 
-- 
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".

Re: [FFmpeg-devel] [PATCH] avformat/tedcaptionsdec: Fix leak of AVBPrint upon error

2020-09-20 Thread Andreas Rheinhardt
Nicolas George:
> Andreas Rheinhardt (12020-09-20):
>> The tedcaptions demuxer uses an AVBPrint whose string is not restricted
>> to its internal buffer; it therefore needs to be cleaned up, yet this is
>> not done on error, as parse_file() returned simply returned directly.
>> This is fixed by going to fail first in such cases.
>> Furthermore, there is also a second way how this string can leak: By
>> having more than one subtitle per subtitle block, as the new one simply
>> overwrites the old one in this case as the AVBPrint is initialized each
>> time upon encountering a subtitle line. The code has been modified to
>> simply append the new subtitle to the old one, so that the old one can't
>> leak any more.
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>>  libavformat/tedcaptionsdec.c | 73 ++--
>>  1 file changed, 36 insertions(+), 37 deletions(-)
> 
> Should be ok.
> 
> I notice that the code calls ff_subtitles_queue_insert() without
> checking if the buffer is truncated. It should be fixed too, but that
> is separate from this patch.
> 
> Regards,
> 
parse_string() checks for this (for the content, not the labels, where
the check is unnecessary).

- 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 v2] avutil/pixfmt: improve definition of AVColorRange

2020-09-20 Thread Jan Ekström
On Sun, Sep 20, 2020 at 5:50 PM Michael Niedermayer
 wrote:
>
> On Sat, Sep 19, 2020 at 02:42:01PM +0300, Jan Ekström wrote:
> > As it was brought up that the current documentation leaves things
> > as specific to YCbCr only, ICtCp and RGB are now mentioned.
> > Additionally, the specifications on which these definitions of
> > narrow and full range are defined are mentioned.
> >
> > This way, the documentation of AVColorRange should now match how
> > most people seem to read interpret it at this point, and thus
> > flagging RGB AVFrames as full range is valid not only according to
> > common sense, but also the enum definition.
> > ---
> >  libavutil/pixfmt.h | 54 +++---
> >  1 file changed, 51 insertions(+), 3 deletions(-)
> >
> > diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
> > index a46acf3c5e..480ac9bb42 100644
> > --- a/libavutil/pixfmt.h
> > +++ b/libavutil/pixfmt.h
> > @@ -530,12 +530,60 @@ enum AVColorSpace {
> >  };
> >
> >  /**
> > - * MPEG vs JPEG YUV range.
> > + * Visual content value range.
> > + *
> > + * These values are based on definitions that can be found in multiple
> > + * specifications, such as ITU-T BT.709 (3.4 - Quantization of RGB, 
> > luminance
> > + * and colour-difference signals), ITU-T BT.2020 (Table 5 - Digital
> > + * Representation) as well as ITU-T BT.2100 (Table 9 - Digital 10- and 
> > 12-bit
> > + * integer representation). At the time of writing, the BT.2100 one is
> > + * recommended, as it also defines the full range representation.
> > + *
> > + * Common definitions:
> > + *   - For luminance planes such as Y in YCbCr and I in ICtCp, 'E' is the
> > + * original value in range of 0.0 to 1.0.
> > + *   - For chrominance planes such as Cb,Cr and Ct,Cp, 'E' is the original
> > + * value in range of -0.5 to 0.5.
> > + *   - 'n' is the output bit depth.
> > + *   - For additional definitions such as rounding and clipping to valid n
> > + * bit unsigned integer range, please refer to BT.2100 (Table 9).
> >   */
> >  enum AVColorRange {
> >  AVCOL_RANGE_UNSPECIFIED = 0,
> > -AVCOL_RANGE_MPEG= 1, ///< the normal 219*2^(n-8) "MPEG" YUV 
> > ranges
> > -AVCOL_RANGE_JPEG= 2, ///< the normal 2^n-1   "JPEG" YUV 
> > ranges
> > +
> > +/**
> > + * Narrow or limited range content.
> > + *
> > + * - For RGB and luminance planes:
>
> I suggest to only mention RGB in relation to narrow once this is also
> supported by the implementation
>

I did wonder if I should leave this out, but I did end up just
following what the specification notes if we were going to be basing
on the specification.

In any case, it can easily be left out. Will do.

>
>
> > + *
> > + *   (219 * E + 16) * 2^(n-8)
> > + *
> > + *   F.ex. the range of 16-235 for 8 bits
> > + *
> > + * - For chrominance planes:
> > + *
> > + *   (224 * E + 128) * 2^(n-8)
> > + *
> > + *   F.ex. the range of 16-240 for 8 bits
> > + */
> > +AVCOL_RANGE_MPEG= 1,
> > +
> > +/**
> > + * Full range content.
> > + *
> > + * - For RGB and luminance planes:
> > + *
> > + *   (2^n - 1) * E
> > + *
> > + *   F.ex. the range of 0-255 for 8 bits
> > + *
> > + * - For chrominance planes:
> > + *
> > + *   (2^n - 1) * E + 2^(n - 1)
> > + *
> > + *   F.ex. the range of 1-255 for 8 bits
> > + */
> > +AVCOL_RANGE_JPEG= 2,
> >  AVCOL_RANGE_NB   ///< Not part of ABI
> >  };
>
> ok
>
> thanks
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Those who would give up essential Liberty, to purchase a little
> temporary Safety, deserve neither Liberty nor Safety -- Benjamin Franklin
> ___
> 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".



-- 
I'm human - no debug
___
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/tedcaptionsdec: Fix leak of AVBPrint upon error

2020-09-20 Thread Nicolas George
Andreas Rheinhardt (12020-09-20):
> parse_string() checks for this (for the content, not the labels, where
> the check is unnecessary).

Oh, even better.

Then ok without reservation.

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH v2] avfilter/vf_scale: translate and verify swscale internal range flag

2020-09-20 Thread Michael Niedermayer
On Sun, Sep 20, 2020 at 01:36:56PM +0300, Jan Ekström wrote:
> This value - while it looks like the actual range of the content -
> is nothing but the internal value of swscale.
> 
> Thus, if we have RGB content, translate the value to 1 which is what
> at least this filter expects for RGB. Swscale will ignore this value
> when set.
> 
> Additionally, after calling sws_setColorspaceDetails double-check
> the configured internal flag for the color range. Warn if this is
> different to the requested value.
> 
> Finally, utilize the translated configured output value as the
> output AVFrame's color_range.
> ---
>  libavfilter/vf_scale.c | 44 +-
>  1 file changed, 43 insertions(+), 1 deletion(-)
> 
> diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
> index 58eee96744..da8ce399cf 100644
> --- a/libavfilter/vf_scale.c
> +++ b/libavfilter/vf_scale.c
> @@ -647,6 +647,8 @@ static int scale_slice(AVFilterLink *link, AVFrame 
> *out_buf, AVFrame *cur_pic, s
>   out,out_stride);
>  }
>  
> +// swscale's internal range flag is 0 for RGB, which we have to override
> +#define NORMALIZE_SWS_RANGE(format_flags, sws_range) (((format_flags) & 
> AV_PIX_FMT_FLAG_RGB) ? 1 : (sws_range))
>  static int scale_frame(AVFilterLink *link, AVFrame *in, AVFrame **frame_out)
>  {
>  AVFilterContext *ctx = link->dst;
> @@ -750,11 +752,19 @@ scale:
>  || in_range != AVCOL_RANGE_UNSPECIFIED
>  || scale->out_range != AVCOL_RANGE_UNSPECIFIED) {
>  int in_full, out_full, brightness, contrast, saturation;
> +int configured_in_full_range_flag, configured_out_full_range_flag;
>  const int *inv_table, *table;
> +const AVPixFmtDescriptor *in_desc  = av_pix_fmt_desc_get(in->format);
> +const AVPixFmtDescriptor *out_desc = 
> av_pix_fmt_desc_get(out->format);
> +av_assert0(in_desc && out_desc);
>  
>  sws_getColorspaceDetails(scale->sws, (int **)&inv_table, &in_full,
>   (int **)&table, &out_full,
>   &brightness, &contrast, &saturation);
> +// translate the internal range flags according to this
> +// filter's expectations for RGB.
> +in_full = NORMALIZE_SWS_RANGE(in_desc->flags, in_full);
> +out_full = NORMALIZE_SWS_RANGE(out_desc->flags, out_full);
>  
>  if (scale->in_color_matrix)
>  inv_table = parse_yuv_type(scale->in_color_matrix, 
> in->colorspace);
> @@ -782,7 +792,39 @@ scale:
>   table, out_full,
>   brightness, contrast, saturation);
>  
> -out->color_range = out_full ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;
> +// double-check what was actually just configured,
> +// since swscale can silently ignore the color range
> +// value in sws_setColorspaceDetails.
> +sws_getColorspaceDetails(scale->sws, (int **)&inv_table,
> + &configured_in_full_range_flag,
> + (int **)&table,
> + &configured_out_full_range_flag,
> + &brightness, &contrast, &saturation);
> +
> +// translate the actually configured internal range flags according
> +// to this filter's expectations for RGB.
> +configured_in_full_range_flag = \
> +NORMALIZE_SWS_RANGE(in_desc->flags,
> +configured_in_full_range_flag);
> +configured_out_full_range_flag = \
> +NORMALIZE_SWS_RANGE(out_desc->flags,
> +configured_out_full_range_flag);
> +
> +if (in_full != configured_in_full_range_flag ||
> +out_full != configured_out_full_range_flag) {
> +av_log(ctx, AV_LOG_WARNING,
> +   "swscale overrode set input/output range value as it "
> +   "considered it an invalid configuration! "
> +   "(input: requested: %s, configured: %s), "
> +   "(output: requested: %s, configured: %s)!\n",
> +   in_full ? "full" : "limited",
> +   configured_in_full_range_flag ? "full" : "limited",
> +   out_full ? "full" : "limited",
> +   configured_out_full_range_flag ? "full" : "limited");
> +}

If i read this correctly, please correct me if i misread this
swscale is setup with some ranges and ignores it.
Is there a reason why swscale should not print a warning in this case ?
iam asking as you print this from one user of swscale.
wouldnt this be relevant to other users too ?


thx

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

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato


signature.asc
Description: PGP 

Re: [FFmpeg-devel] [PATCH 3/3] avformat/aviobuf: increase default read buffer size to 2*max_buffer_size for streamed data

2020-09-20 Thread Michael Niedermayer
On Sun, Sep 20, 2020 at 10:52:53AM +0200, Marton Balint wrote:
> This should increase the effectiveness of ffio_ensure_seekback.
> 
> Note: increasing buffer size to non-streamed or write buffer should also
> work, but they both cause fate failures... The reason for that should be
> checked.
> 
> Signed-off-by: Marton Balint 
> ---
>  libavformat/aviobuf.c | 5 +
>  1 file changed, 5 insertions(+)

this is an interresting idea
have you done some tests/benchmarks that show specific advantages ?

thx

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

Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway


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

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

Re: [FFmpeg-devel] [PATCH 1/3] avdevice/lavfi: fix FIXME and check a/v type by codec_type

2020-09-20 Thread Nicolas George
lance.lmw...@gmail.com (12020-09-18):
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  libavdevice/lavfi.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)

LGTM, thanks.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH 3/3] avformat/swf: Separate mux and demux contexts

2020-09-20 Thread Michael Niedermayer
On Sun, Sep 20, 2020 at 01:53:41PM +0200, Andreas Rheinhardt wrote:
> There was almost no overlap between them: The only field used by both
> was an int named samples_per_frame. Therefore this commit separates
> them.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/swf.h| 33 -
>  libavformat/swfdec.c | 22 +-
>  libavformat/swfenc.c | 35 ++-
>  3 files changed, 43 insertions(+), 47 deletions(-)

LGTM

thx

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

If a bugfix only changes things apparently unrelated to the bug with no
further explanation, that is a good sign that the bugfix is wrong.


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/3] avdevice/lavfi: unref the frame on failure

2020-09-20 Thread Nicolas George
lance.lmw...@gmail.com (12020-09-18):
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  libavdevice/lavfi.c | 19 ---
>  1 file changed, 12 insertions(+), 7 deletions(-)

LGTM, thanks.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH 3/3] avdevice/lavfi: av_malloc -> av_malloc_array

2020-09-20 Thread Nicolas George
lance.lmw...@gmail.com (12020-09-18):
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  libavdevice/lavfi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

LGTM.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH v2] avfilter/vf_scale: translate and verify swscale internal range flag

2020-09-20 Thread Jan Ekström
On Sun, Sep 20, 2020 at 6:03 PM Michael Niedermayer
 wrote:
>
> On Sun, Sep 20, 2020 at 01:36:56PM +0300, Jan Ekström wrote:
> > This value - while it looks like the actual range of the content -
> > is nothing but the internal value of swscale.
> >
> > Thus, if we have RGB content, translate the value to 1 which is what
> > at least this filter expects for RGB. Swscale will ignore this value
> > when set.
> >
> > Additionally, after calling sws_setColorspaceDetails double-check
> > the configured internal flag for the color range. Warn if this is
> > different to the requested value.
> >
> > Finally, utilize the translated configured output value as the
> > output AVFrame's color_range.
> > ---
> >  libavfilter/vf_scale.c | 44 +-
> >  1 file changed, 43 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
> > index 58eee96744..da8ce399cf 100644
> > --- a/libavfilter/vf_scale.c
> > +++ b/libavfilter/vf_scale.c
> > @@ -647,6 +647,8 @@ static int scale_slice(AVFilterLink *link, AVFrame 
> > *out_buf, AVFrame *cur_pic, s
> >   out,out_stride);
> >  }
> >
> > +// swscale's internal range flag is 0 for RGB, which we have to override
> > +#define NORMALIZE_SWS_RANGE(format_flags, sws_range) (((format_flags) & 
> > AV_PIX_FMT_FLAG_RGB) ? 1 : (sws_range))
> >  static int scale_frame(AVFilterLink *link, AVFrame *in, AVFrame 
> > **frame_out)
> >  {
> >  AVFilterContext *ctx = link->dst;
> > @@ -750,11 +752,19 @@ scale:
> >  || in_range != AVCOL_RANGE_UNSPECIFIED
> >  || scale->out_range != AVCOL_RANGE_UNSPECIFIED) {
> >  int in_full, out_full, brightness, contrast, saturation;
> > +int configured_in_full_range_flag, configured_out_full_range_flag;
> >  const int *inv_table, *table;
> > +const AVPixFmtDescriptor *in_desc  = 
> > av_pix_fmt_desc_get(in->format);
> > +const AVPixFmtDescriptor *out_desc = 
> > av_pix_fmt_desc_get(out->format);
> > +av_assert0(in_desc && out_desc);
> >
> >  sws_getColorspaceDetails(scale->sws, (int **)&inv_table, &in_full,
> >   (int **)&table, &out_full,
> >   &brightness, &contrast, &saturation);
> > +// translate the internal range flags according to this
> > +// filter's expectations for RGB.
> > +in_full = NORMALIZE_SWS_RANGE(in_desc->flags, in_full);
> > +out_full = NORMALIZE_SWS_RANGE(out_desc->flags, out_full);
> >
> >  if (scale->in_color_matrix)
> >  inv_table = parse_yuv_type(scale->in_color_matrix, 
> > in->colorspace);
> > @@ -782,7 +792,39 @@ scale:
> >   table, out_full,
> >   brightness, contrast, saturation);
> >
> > -out->color_range = out_full ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;
> > +// double-check what was actually just configured,
> > +// since swscale can silently ignore the color range
> > +// value in sws_setColorspaceDetails.
> > +sws_getColorspaceDetails(scale->sws, (int **)&inv_table,
> > + &configured_in_full_range_flag,
> > + (int **)&table,
> > + &configured_out_full_range_flag,
> > + &brightness, &contrast, &saturation);
> > +
> > +// translate the actually configured internal range flags according
> > +// to this filter's expectations for RGB.
> > +configured_in_full_range_flag = \
> > +NORMALIZE_SWS_RANGE(in_desc->flags,
> > +configured_in_full_range_flag);
> > +configured_out_full_range_flag = \
> > +NORMALIZE_SWS_RANGE(out_desc->flags,
> > +configured_out_full_range_flag);
> > +
> > +if (in_full != configured_in_full_range_flag ||
> > +out_full != configured_out_full_range_flag) {
> > +av_log(ctx, AV_LOG_WARNING,
> > +   "swscale overrode set input/output range value as it "
> > +   "considered it an invalid configuration! "
> > +   "(input: requested: %s, configured: %s), "
> > +   "(output: requested: %s, configured: %s)!\n",
> > +   in_full ? "full" : "limited",
> > +   configured_in_full_range_flag ? "full" : "limited",
> > +   out_full ? "full" : "limited",
> > +   configured_out_full_range_flag ? "full" : "limited");
> > +}
>
> If i read this correctly, please correct me if i misread this
> swscale is setup with some ranges and ignores it.
> Is there a reason why swscale should not print a warning in this case ?
> iam asking as you print this from one user of swscale.
> wouldnt this be relevant to other users too ?
>

Yes, but th

Re: [FFmpeg-devel] [PATCH 4/5] avcodec/ansi: Check nb_args for overflow

2020-09-20 Thread Michael Niedermayer
On Sat, Sep 19, 2020 at 09:47:45PM +0200, Paul B Mahol wrote:
> On Sat, Sep 19, 2020 at 09:31:08PM +0200, Michael Niedermayer wrote:
> > Fixes: Integer overflow (no testcase)
> > 
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/ansi.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> 
> ok

will apply

thx

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

Whats the most studid thing your enemy could do ? Blow himself up
Whats the most studid thing you could do ? Give up your rights and
freedom because your enemy blew himself up.



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/6] avformat/wc3movie: Cleanup on wc3_read_header() failure

2020-09-20 Thread Michael Niedermayer
On Sat, Sep 19, 2020 at 10:34:46AM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > On Sun, Jul 19, 2020 at 07:55:24PM +0200, Andreas Rheinhardt wrote:
> >> James Almer:
> >>> On 7/19/2020 2:42 PM, Michael Niedermayer wrote:
>  Fixes: memleak
>  Fixes: 
>  23660/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6007508031504384
> 
>  Found-by: continuous fuzzing process 
>  https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
>  Signed-off-by: Michael Niedermayer 
>  ---
>   libavformat/wc3movie.c | 32 +++-
>   1 file changed, 23 insertions(+), 9 deletions(-)
> 
>  diff --git a/libavformat/wc3movie.c b/libavformat/wc3movie.c
>  index c59b5bf6cc..76e945d261 100644
>  --- a/libavformat/wc3movie.c
>  +++ b/libavformat/wc3movie.c
>  @@ -139,10 +139,14 @@ static int wc3_read_header(AVFormatContext *s)
>   /* load up the name */
>   buffer = av_malloc(size+1);
>   if (!buffer)
>  -return AVERROR(ENOMEM);
>  +if (!buffer) {
>  +ret = AVERROR(ENOMEM);
>  +goto fail;
>  +}
>   if ((ret = avio_read(pb, buffer, size)) != size) {
>   av_freep(&buffer);
>  -return AVERROR(EIO);
>  +ret =  AVERROR(EIO);
>  +goto fail;
>   }
>   buffer[size] = 0;
>   av_dict_set(&s->metadata, "title", buffer,
>  @@ -164,21 +168,26 @@ static int wc3_read_header(AVFormatContext *s)
>   default:
>   av_log(s, AV_LOG_ERROR, "unrecognized WC3 chunk: %s\n",
>  av_fourcc2str(fourcc_tag));
>  -return AVERROR_INVALIDDATA;
>  +ret = AVERROR_INVALIDDATA;
>  +goto fail;
>   }
>   
>   fourcc_tag = avio_rl32(pb);
>   /* chunk sizes are 16-bit aligned */
>   size = (avio_rb32(pb) + 1) & (~1);
>  -if (avio_feof(pb))
>  -return AVERROR(EIO);
>  +if (avio_feof(pb)) {
>  +ret = AVERROR(EIO);
>  +goto fail;
>  +}
>   
>   } while (fourcc_tag != BRCH_TAG);
>   
>   /* initialize the decoder streams */
>   st = avformat_new_stream(s, NULL);
>  -if (!st)
>  -return AVERROR(ENOMEM);
>  +if (!st) {
>  +ret = AVERROR(ENOMEM);
>  +goto fail;
>  +}
>   avpriv_set_pts_info(st, 33, 1, WC3_FRAME_FPS);
>   wc3->video_stream_index = st->index;
>   st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
>  @@ -188,8 +197,10 @@ static int wc3_read_header(AVFormatContext *s)
>   st->codecpar->height = wc3->height;
>   
>   st = avformat_new_stream(s, NULL);
>  -if (!st)
>  -return AVERROR(ENOMEM);
>  +if (!st) {
>  +ret = AVERROR(ENOMEM);
>  +goto fail;
>  +}
>   avpriv_set_pts_info(st, 33, 1, WC3_FRAME_FPS);
>   wc3->audio_stream_index = st->index;
>   st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
>  @@ -204,6 +215,9 @@ static int wc3_read_header(AVFormatContext *s)
>   st->codecpar->block_align = WC3_AUDIO_BITS * WC3_AUDIO_CHANNELS;
>   
>   return 0;
>  +fail:
>  +wc3_read_close(s);
> >>>
> >>> Wouldn't it be better to instead make avformat_open_input() call
> >>> iformat->read_close() on iformat->read_header() failure?
> >>>
> >>> It may require ensuring all demuxers behave nice with it, but the end
> >>> result would be a lot cleaner.
> >>>
> >>
> >> Problem is: Not all input devices behave nice and it is possible to use
> >> an older libavdevice together with a newer libavformat. You might
> >> remember the patchset where I added a flag to AVInputFormat for this
> >> purpose. I'll resend it soon.
> > 
> > 2 months have passed, the memleak is still open and i dont see a flag or
> > init/deinit() for demuxers.
> > So i suggest to apply this patch as it was. A flag is better but a leak is
> > worst.
> > 
> I agree.

will apply

thx

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

If a bugfix only changes things apparently unrelated to the bug with no
further explanation, that is a good sign that the bugfix is wrong.


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/3] avformat/mov: fix typo in comments

2020-09-20 Thread Michael Niedermayer
On Fri, Sep 18, 2020 at 10:33:37PM +0800, Zhao Zhili wrote:
> From: Zhao Zhili 
> 
> ---
>  libavformat/mov.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 8c1243b48d..9fc0db24d5 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -1473,7 +1473,7 @@ static int mov_read_mvhd(MOVContext *c, AVIOContext 
> *pb, MOVAtom atom)
>  av_log(c->fc, AV_LOG_TRACE, "time scale = %i\n", c->time_scale);
>  
>  c->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* 
> duration */
> -// set the AVCodecContext duration because the duration of individual 
> tracks
> +// set the AVFormatContext duration because the duration of individual 
> tracks
>  // may be inaccurate
>  if (c->time_scale > 0 && !c->trex_data)
>  c->fc->duration = av_rescale(c->duration, AV_TIME_BASE, 
> c->time_scale);

will apply

thx

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

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


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

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

[FFmpeg-devel] [PATCH] avformat/aaxdec: Fix potential integer overflow

2020-09-20 Thread Andreas Rheinhardt
The AAX demuxer reads a 32bit number containing the amount of entries
of an array and stores it in an uint32_t. Yet when iterating over this
array, a loop counter of type int is used. This leads to undefined
behaviour if the amount of entries is not in the range of int; to avoid
this, it is generally good to use the same type for the loop counter as
for the variable it is compared to. This is done in one of the two loops
affected by this.

In the other loop, the undefined behaviour can begin even earlier: Here
the loop counter is multiplied by an uint16_t which can overflow as soon
as the loop counter is > 2^15. Using an unsigned type would avoid the
undefined behaviour, but truncation would still be possible, so use an
uint64_t.

Also use an uint32_t for a variable containing an index in said array.

This fixes Coverity issue #1466767.

Signed-off-by: Andreas Rheinhardt 
---
This is untested as I could only find out that this is a gaming format.

 libavformat/aaxdec.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/aaxdec.c b/libavformat/aaxdec.c
index cfd2e10a15..3db6e9bc6d 100644
--- a/libavformat/aaxdec.c
+++ b/libavformat/aaxdec.c
@@ -51,7 +51,7 @@ typedef struct AAXContext {
 int64_t strings_size;
 char *string_table;
 
-int current_segment;
+uint32_t current_segment;
 
 AAXColumn *xcolumns;
 AAXSegment *segments;
@@ -239,7 +239,7 @@ static int aax_read_header(AVFormatContext *s)
 flag = a->xcolumns[c].flag;
 col_offset = a->xcolumns[c].offset;
 
-for (int r = 0; r < a->nb_segments; r++) {
+for (uint64_t r = 0; r < a->nb_segments; r++) {
 if (flag & COLUMN_FLAG_DEFAULT) {
 data_offset = a->schema_offset + col_offset;
 } else if (flag & COLUMN_FLAG_ROW) {
@@ -330,7 +330,7 @@ static int aax_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 
 pkt->pos = avio_tell(pb);
 
-for (int seg = 0; seg < a->nb_segments; seg++) {
+for (uint32_t seg = 0; seg < a->nb_segments; seg++) {
 int64_t start = a->segments[seg].start;
 int64_t end   = a->segments[seg].end;
 
-- 
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 0/5] avformat/movenc: btrt box support

2020-09-20 Thread Jan Ekström
Various media ingest servers read the incoming stream's advertised bit
rate from this box.

As it is only defined for timed metadata tracks in QTFF, limit it to
just MODE_MP4 (ISOBMFF) for now.

Unifies the MPEG-4 bit rate value calculation, and attempts to utilize
it everywhere matching.

Jan Ekström (5):
  avformat/movenc: split MPEG-4 bit rate value calculation
  avformat/movenc: utilize the maximum bit rate in ISML writing
  avformat/movenc: implement writing of the btrt box
  avformat/movenc: use more fall-back values for average bit rate fields
  avformat/movenc: simplify ISML manifest bit rate setting

 libavformat/movenc.c   | 103 ++---
 tests/fate/mov.mak |   2 +-
 tests/ref/fate/binsub-movtextenc   |   2 +-
 tests/ref/fate/copy-trac3074   |   4 +-
 tests/ref/fate/movenc  | 102 ++--
 tests/ref/lavf-fate/av1.mp4|   4 +-
 tests/ref/lavf-fate/h264.mp4   |   4 +-
 tests/ref/lavf/ismv|   6 +-
 tests/ref/lavf/mp4 |  12 ++--
 tests/ref/vsynth/vsynth1-mpeg4 |   4 +-
 tests/ref/vsynth/vsynth2-mpeg4 |   4 +-
 tests/ref/vsynth/vsynth3-mpeg4 |   4 +-
 tests/ref/vsynth/vsynth_lena-mpeg4 |   4 +-
 13 files changed, 156 insertions(+), 99 deletions(-)

-- 
2.26.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 1/5] avformat/movenc: split MPEG-4 bit rate value calculation

2020-09-20 Thread Jan Ekström
This can now be re-utilized in other places.
---
 libavformat/movenc.c | 39 +--
 1 file changed, 29 insertions(+), 10 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 12471c7d68..1962f2 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -633,12 +633,36 @@ static unsigned compute_avg_bitrate(MOVTrack *track)
 return size * 8 * track->timescale / track->track_duration;
 }
 
+struct mpeg4_bit_rate_values {
+uint32_t buffer_size;  ///< Size of the decoding buffer for the elementary 
stream in bytes.
+uint32_t max_bit_rate; ///< Maximum rate in bits/second over any window of 
one second.
+uint32_t avg_bit_rate; ///< Average rate in bits/second over the entire 
presentation.
+};
+
+static struct mpeg4_bit_rate_values calculate_mpeg4_bit_rates(MOVTrack *track)
+{
+AVCPBProperties *props = \
+(AVCPBProperties*)av_stream_get_side_data(track->st,
+  AV_PKT_DATA_CPB_PROPERTIES,
+  NULL);
+unsigned avg_bit_rate = compute_avg_bitrate(track);
+
+
+return (struct mpeg4_bit_rate_values){
+.buffer_size = props ? props->buffer_size / 8 : 0,
+// (FIXME should be max rate in any 1 sec window)
+.max_bit_rate = props ? \
+FFMAX3(props->max_bitrate, props->avg_bitrate, avg_bit_rate) : \
+FFMAX(track->par->bit_rate, avg_bit_rate),
+.avg_bit_rate = avg_bit_rate,
+};
+}
+
 static int mov_write_esds_tag(AVIOContext *pb, MOVTrack *track) // Basic
 {
-AVCPBProperties *props;
+struct mpeg4_bit_rate_values bit_rates = calculate_mpeg4_bit_rates(track);
 int64_t pos = avio_tell(pb);
 int decoder_specific_info_len = track->vos_len ? 5 + track->vos_len : 0;
-unsigned avg_bitrate;
 
 avio_wb32(pb, 0); // size
 ffio_wfourcc(pb, "esds");
@@ -669,14 +693,9 @@ static int mov_write_esds_tag(AVIOContext *pb, MOVTrack 
*track) // Basic
 else
 avio_w8(pb, 0x11); // flags (= Visualstream)
 
-props = (AVCPBProperties*)av_stream_get_side_data(track->st, 
AV_PKT_DATA_CPB_PROPERTIES,
-  NULL);
-
-avio_wb24(pb, props ? props->buffer_size / 8 : 0); // Buffersize DB
-
-avg_bitrate = compute_avg_bitrate(track);
-avio_wb32(pb, props ? FFMAX3(props->max_bitrate, props->avg_bitrate, 
avg_bitrate) : FFMAX(track->par->bit_rate, avg_bitrate)); // maxbitrate (FIXME 
should be max rate in any 1 sec window)
-avio_wb32(pb, avg_bitrate);
+avio_wb24(pb, bit_rates.buffer_size); // Buffersize DB
+avio_wb32(pb, bit_rates.max_bit_rate); // maxbitrate
+avio_wb32(pb, bit_rates.avg_bit_rate);
 
 if (track->vos_len) {
 // DecoderSpecific info descriptor
-- 
2.26.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 2/5] avformat/movenc: utilize the maximum bit rate in ISML writing

2020-09-20 Thread Jan Ekström
This way we have a single location in movenc which utilizes the
CPB properties.
---
 libavformat/movenc.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 1962f2..31e1ac1589 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -4155,7 +4155,6 @@ static int mov_write_isml_manifest(AVIOContext *pb, 
MOVMuxContext *mov, AVFormat
 int64_t pos = avio_tell(pb);
 int i;
 int64_t manifest_bit_rate = 0;
-AVCPBProperties *props = NULL;
 
 static const uint8_t uuid[] = {
 0xa5, 0xd4, 0x0b, 0x30, 0xe8, 0x14, 0x11, 0xdd,
@@ -4181,6 +4180,8 @@ static int mov_write_isml_manifest(AVIOContext *pb, 
MOVMuxContext *mov, AVFormat
 
 for (i = 0; i < mov->nb_streams; i++) {
 MOVTrack *track = &mov->tracks[i];
+struct mpeg4_bit_rate_values bit_rates = \
+calculate_mpeg4_bit_rates(track);
 const char *type;
 int track_id = track->track_id;
 char track_name_buf[32] = { 0 };
@@ -4196,12 +4197,10 @@ static int mov_write_isml_manifest(AVIOContext *pb, 
MOVMuxContext *mov, AVFormat
 continue;
 }
 
-props = (AVCPBProperties*)av_stream_get_side_data(track->st, 
AV_PKT_DATA_CPB_PROPERTIES, NULL);
-
 if (track->par->bit_rate) {
 manifest_bit_rate = track->par->bit_rate;
-} else if (props) {
-manifest_bit_rate = props->max_bitrate;
+} else {
+manifest_bit_rate = bit_rates.max_bit_rate;
 }
 
 avio_printf(pb, "<%s systemBitrate=\"%"PRId64"\">\n", type,
-- 
2.26.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 3/5] avformat/movenc: implement writing of the btrt box

2020-09-20 Thread Jan Ekström
This is utilized by various media ingests to figure out the bit
rate of the content you are pushing towards it, so write it by
default for video, audio and subtitle tracks. It is only mentioned
for timed metadata sample descriptions in QTFF, so limit it only to
ISOBMFF (MODE_MP4).

Updates the FATE tests which have their results changed due to the
20 extra bytes being written per track.
---
 libavformat/movenc.c   |  29 
 tests/fate/mov.mak |   2 +-
 tests/ref/fate/binsub-movtextenc   |   2 +-
 tests/ref/fate/copy-trac3074   |   4 +-
 tests/ref/fate/movenc  | 102 ++---
 tests/ref/lavf-fate/av1.mp4|   4 +-
 tests/ref/lavf-fate/h264.mp4   |   4 +-
 tests/ref/lavf/mp4 |  12 ++--
 tests/ref/vsynth/vsynth1-mpeg4 |   4 +-
 tests/ref/vsynth/vsynth2-mpeg4 |   4 +-
 tests/ref/vsynth/vsynth3-mpeg4 |   4 +-
 tests/ref/vsynth/vsynth_lena-mpeg4 |   4 +-
 12 files changed, 102 insertions(+), 73 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 31e1ac1589..9bff2c89ca 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1068,6 +1068,21 @@ static int get_samples_per_packet(MOVTrack *track)
 return first_duration;
 }
 
+static int mov_write_btrt_tag(AVIOContext *pb, MOVTrack *track)
+{
+int64_t pos = avio_tell(pb);
+struct mpeg4_bit_rate_values bit_rates = calculate_mpeg4_bit_rates(track);
+
+avio_wb32(pb, 0); /* size */
+ffio_wfourcc(pb, "btrt");
+
+avio_wb32(pb, bit_rates.buffer_size);
+avio_wb32(pb, bit_rates.max_bit_rate);
+avio_wb32(pb, bit_rates.avg_bit_rate);
+
+return update_size(pb, pos);
+}
+
 static int mov_write_audio_tag(AVFormatContext *s, AVIOContext *pb, 
MOVMuxContext *mov, MOVTrack *track)
 {
 int64_t pos = avio_tell(pb);
@@ -1216,6 +1231,10 @@ static int mov_write_audio_tag(AVFormatContext *s, 
AVIOContext *pb, MOVMuxContex
 return ret;
 }
 
+if (track->mode == MODE_MP4 &&
+((ret = mov_write_btrt_tag(pb, track)) < 0))
+return ret;
+
 ret = update_size(pb, pos);
 return ret;
 }
@@ -1731,6 +1750,7 @@ static int mov_write_fiel_tag(AVIOContext *pb, MOVTrack 
*track, int field_order)
 
 static int mov_write_subtitle_tag(AVIOContext *pb, MOVTrack *track)
 {
+int ret = AVERROR_BUG;
 int64_t pos = avio_tell(pb);
 avio_wb32(pb, 0);/* size */
 avio_wl32(pb, track->tag); // store it byteswapped
@@ -1743,6 +1763,10 @@ static int mov_write_subtitle_tag(AVIOContext *pb, 
MOVTrack *track)
 else if (track->par->extradata_size)
 avio_write(pb, track->par->extradata, track->par->extradata_size);
 
+if (track->mode == MODE_MP4 &&
+((ret = mov_write_btrt_tag(pb, track)) < 0))
+return ret;
+
 return update_size(pb, pos);
 }
 
@@ -2046,6 +2070,7 @@ static void find_compressor(char * compressor_name, int 
len, MOVTrack *track)
 
 static int mov_write_video_tag(AVFormatContext *s, AVIOContext *pb, 
MOVMuxContext *mov, MOVTrack *track)
 {
+int ret = AVERROR_BUG;
 int64_t pos = avio_tell(pb);
 char compressor_name[32] = { 0 };
 int avid = 0;
@@ -2226,6 +2251,10 @@ static int mov_write_video_tag(AVFormatContext *s, 
AVIOContext *pb, MOVMuxContex
 ff_mov_cenc_write_sinf_tag(track, pb, mov->encryption_kid);
 }
 
+if (track->mode == MODE_MP4 &&
+((ret = mov_write_btrt_tag(pb, track)) < 0))
+return ret;
+
 /* extra padding for avid stsd */
 /* 
https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFChap2/qtff2.html#//apple_ref/doc/uid/TP4939-CH204-61112
 */
 if (avid)
diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
index 8d3b6c7224..0fd20fef96 100644
--- a/tests/fate/mov.mak
+++ b/tests/fate/mov.mak
@@ -113,7 +113,7 @@ fate-mov-spherical-mono: CMD = run 
ffprobe$(PROGSSUF)$(EXESUF) -show_entries str
 
 fate-mov-gpmf-remux: CMD = md5 -i 
$(TARGET_SAMPLES)/mov/fake-gp-media-with-real-gpmf.mp4 -map 0 -c copy -fflags 
+bitexact -f mp4
 fate-mov-gpmf-remux: CMP = oneline
-fate-mov-gpmf-remux: REF = 8f48e435ee1f6b7e173ea756141eabf3
+fate-mov-gpmf-remux: REF = 6361cf3c2b9e6962c2eafbda138125f4
 
 fate-mov-guess-delay-1: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entries 
stream=has_b_frames -select_streams v 
$(TARGET_SAMPLES)/h264/h264_3bf_nopyramid_nobsrestriction.mp4
 fate-mov-guess-delay-2: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entries 
stream=has_b_frames -select_streams v 
$(TARGET_SAMPLES)/h264/h264_3bf_pyramid_nobsrestriction.mp4
diff --git a/tests/ref/fate/binsub-movtextenc b/tests/ref/fate/binsub-movtextenc
index a8f94b7227..c485a9adb7 100644
--- a/tests/ref/fate/binsub-movtextenc
+++ b/tests/ref/fate/binsub-movtextenc
@@ -1 +1 @@
-fc6d07679ac1f718aa50de687924cd97
+d0370a0627d8891c664d2442bfc8ae53
diff --git a/tests/ref/fate/copy-trac3074 b/tests/ref/fate/copy-trac3074
index ff66900253..b5b0b6a60b 100644
--- a/tests/ref/fate/copy-trac3074
+++ b

[FFmpeg-devel] [PATCH 5/5] avformat/movenc: simplify ISML manifest bit rate setting

2020-09-20 Thread Jan Ekström
The newly calculated average bit rate value is pretty much what is
being done here.
---
 libavformat/movenc.c | 13 +++--
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 0f14e255e9..35d028e6de 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -4200,7 +4200,6 @@ static int mov_write_isml_manifest(AVIOContext *pb, 
MOVMuxContext *mov, AVFormat
 {
 int64_t pos = avio_tell(pb);
 int i;
-int64_t manifest_bit_rate = 0;
 
 static const uint8_t uuid[] = {
 0xa5, 0xd4, 0x0b, 0x30, 0xe8, 0x14, 0x11, 0xdd,
@@ -4243,15 +4242,9 @@ static int mov_write_isml_manifest(AVIOContext *pb, 
MOVMuxContext *mov, AVFormat
 continue;
 }
 
-if (track->par->bit_rate) {
-manifest_bit_rate = track->par->bit_rate;
-} else {
-manifest_bit_rate = bit_rates.max_bit_rate;
-}
-
-avio_printf(pb, "<%s systemBitrate=\"%"PRId64"\">\n", type,
-manifest_bit_rate);
-param_write_int(pb, "systemBitrate", manifest_bit_rate);
+avio_printf(pb, "<%s systemBitrate=\"%"PRIu32"\">\n", type,
+bit_rates.avg_bit_rate);
+param_write_int(pb, "systemBitrate", bit_rates.avg_bit_rate);
 param_write_int(pb, "trackID", track_id);
 param_write_string(pb, "systemLanguage", lang ? lang->value : "und");
 
-- 
2.26.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 4/5] avformat/movenc: use more fall-back values for average bit rate fields

2020-09-20 Thread Jan Ekström
If the average bit rate cannot be calculated, such as in the case
of streamed fragmented mp4, utilize various available parameters
in priority order.

Tests are updated where the esds or btrt or ISML manifest boxes'
output changes.
---
 libavformat/movenc.c | 17 +
 tests/ref/lavf/ismv  |  6 +++---
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 9bff2c89ca..0f14e255e9 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -647,6 +647,23 @@ static struct mpeg4_bit_rate_values 
calculate_mpeg4_bit_rates(MOVTrack *track)
   NULL);
 unsigned avg_bit_rate = compute_avg_bitrate(track);
 
+if (!avg_bit_rate) {
+// if there is no calculate'able average bit rate, such as
+// in the case of fragmented MP4, utilize the following values
+// in priority order:
+//
+// 1. average bit rate property
+// 2. bit rate (usually average over the whole clip)
+// 3. maximum bit rate property
+
+if (props && props->avg_bitrate) {
+avg_bit_rate = props->avg_bitrate;
+} else if (track->par->bit_rate) {
+avg_bit_rate = track->par->bit_rate;
+} else if (props && props->max_bitrate) {
+avg_bit_rate = props->max_bitrate;
+}
+}
 
 return (struct mpeg4_bit_rate_values){
 .buffer_size = props ? props->buffer_size / 8 : 0,
diff --git a/tests/ref/lavf/ismv b/tests/ref/lavf/ismv
index e7361705fa..ac7f72ba33 100644
--- a/tests/ref/lavf/ismv
+++ b/tests/ref/lavf/ismv
@@ -1,9 +1,9 @@
-4c6bc5ac805a76bbbd886a69d2e61554 *tests/data/lavf/lavf.ismv
+48fb8d7a5d19bd60f3a49ccf4b7d6593 *tests/data/lavf/lavf.ismv
 313169 tests/data/lavf/lavf.ismv
 tests/data/lavf/lavf.ismv CRC=0x9d9a638a
-18678627921460328ea3fed238d0d57d *tests/data/lavf/lavf.ismv
+d19cd8e310a2e94fe0a0d11c5dc29217 *tests/data/lavf/lavf.ismv
 322075 tests/data/lavf/lavf.ismv
 tests/data/lavf/lavf.ismv CRC=0xe8130120
-b9a858caf55b1eff2273e746e9f72dc4 *tests/data/lavf/lavf.ismv
+3b6023766845b51b075aed474c00f73c *tests/data/lavf/lavf.ismv
 312546 tests/data/lavf/lavf.ismv
 tests/data/lavf/lavf.ismv CRC=0x9d9a638a
-- 
2.26.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 v3] avutil/pixfmt: improve definition of AVColorRange

2020-09-20 Thread Jan Ekström
As it was brought up that the current documentation leaves things
as specific to YCbCr only, ICtCp and RGB are now mentioned.
Additionally, the specifications on which these definitions of
narrow and full range are defined are mentioned.

This way, the documentation of AVColorRange should now match how
most people seem to read interpret it at this point, and thus
flagging RGB AVFrames as full range is valid not only according to
common sense, but also the enum definition.
---
 libavutil/pixfmt.h | 54 +++---
 1 file changed, 51 insertions(+), 3 deletions(-)

diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index a46acf3c5e..46ef211add 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -530,12 +530,60 @@ enum AVColorSpace {
 };
 
 /**
- * MPEG vs JPEG YUV range.
+ * Visual content value range.
+ *
+ * These values are based on definitions that can be found in multiple
+ * specifications, such as ITU-T BT.709 (3.4 - Quantization of RGB, luminance
+ * and colour-difference signals), ITU-T BT.2020 (Table 5 - Digital
+ * Representation) as well as ITU-T BT.2100 (Table 9 - Digital 10- and 12-bit
+ * integer representation). At the time of writing, the BT.2100 one is
+ * recommended, as it also defines the full range representation.
+ *
+ * Common definitions:
+ *   - For RGB and luminance planes such as Y in YCbCr and I in ICtCp,
+ * 'E' is the original value in range of 0.0 to 1.0.
+ *   - For chrominance planes such as Cb,Cr and Ct,Cp, 'E' is the original
+ * value in range of -0.5 to 0.5.
+ *   - 'n' is the output bit depth.
+ *   - For additional definitions such as rounding and clipping to valid n
+ * bit unsigned integer range, please refer to BT.2100 (Table 9).
  */
 enum AVColorRange {
 AVCOL_RANGE_UNSPECIFIED = 0,
-AVCOL_RANGE_MPEG= 1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges
-AVCOL_RANGE_JPEG= 2, ///< the normal 2^n-1   "JPEG" YUV ranges
+
+/**
+ * Narrow or limited range content.
+ *
+ * - For luminance planes:
+ *
+ *   (219 * E + 16) * 2^(n-8)
+ *
+ *   F.ex. the range of 16-235 for 8 bits
+ *
+ * - For chrominance planes:
+ *
+ *   (224 * E + 128) * 2^(n-8)
+ *
+ *   F.ex. the range of 16-240 for 8 bits
+ */
+AVCOL_RANGE_MPEG= 1,
+
+/**
+ * Full range content.
+ *
+ * - For RGB and luminance planes:
+ *
+ *   (2^n - 1) * E
+ *
+ *   F.ex. the range of 0-255 for 8 bits
+ *
+ * - For chrominance planes:
+ *
+ *   (2^n - 1) * E + 2^(n - 1)
+ *
+ *   F.ex. the range of 1-255 for 8 bits
+ */
+AVCOL_RANGE_JPEG= 2,
 AVCOL_RANGE_NB   ///< Not part of ABI
 };
 
-- 
2.26.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".

Re: [FFmpeg-devel] [PATCH 3/3] avformat/aviobuf: increase default read buffer size to 2*max_buffer_size for streamed data

2020-09-20 Thread Marton Balint



On Sun, 20 Sep 2020, Michael Niedermayer wrote:


On Sun, Sep 20, 2020 at 10:52:53AM +0200, Marton Balint wrote:

This should increase the effectiveness of ffio_ensure_seekback.

Note: increasing buffer size to non-streamed or write buffer should also
work, but they both cause fate failures... The reason for that should be
checked.

Signed-off-by: Marton Balint 
---
 libavformat/aviobuf.c | 5 +
 1 file changed, 5 insertions(+)


this is an interresting idea
have you done some tests/benchmarks that show specific advantages ?


No, it is just a blind attempt for now.

Regards,
Marton
___
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/cbs: allow cbs_read_fragment_content() to discard units

2020-09-20 Thread James Almer
The caller may not need all units in a fragment in reading only scenarios. They
could in fact alter global state stored in the private CodedBitstreamType
fields in an undesirable way.
And unlike preventing decomposition of units, discarding can be done based on
parsed values within the unit.

Signed-off-by: James Almer 
---
 libavcodec/cbs.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index e73e18f398..363385b6f3 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -196,6 +196,11 @@ static int cbs_read_fragment_content(CodedBitstreamContext 
*ctx,
 av_log(ctx->log_ctx, AV_LOG_VERBOSE,
"Decomposition unimplemented for unit %d "
"(type %"PRIu32").\n", i, unit->type);
+} else if (err  == AVERROR(EAGAIN)) {
+av_log(ctx->log_ctx, AV_LOG_VERBOSE,
+   "Discarding unit %d "
+   "(type %"PRIu32").\n", i, unit->type);
+ff_cbs_delete_unit(frag, i--);
 } else if (err < 0) {
 av_log(ctx->log_ctx, AV_LOG_ERROR, "Failed to read unit %d "
"(type %"PRIu32").\n", i, unit->type);
-- 
2.27.0

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

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

[FFmpeg-devel] [PATCH 3/4] avcodec/cbs_av1: add an option to select an operating point

2020-09-20 Thread James Almer
This implements the function drop_obu() as defined in Setion 6.2.1 from the
spec.
In a reading only scenario, units that belong to an operating point the
caller doesn't want should not be parsed.

Signed-off-by: James Almer 
---
 libavcodec/cbs_av1.c | 18 +-
 libavcodec/cbs_av1.h |  5 +
 libavcodec/cbs_av1_syntax_template.c |  7 +++
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
index dcf6c140ae..edacc29ca8 100644
--- a/libavcodec/cbs_av1.c
+++ b/libavcodec/cbs_av1.c
@@ -18,6 +18,7 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/pixfmt.h"
+#include "libavutil/opt.h"
 
 #include "cbs.h"
 #include "cbs_internal.h"
@@ -883,7 +884,7 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx,
 int in_spatial_layer  =
 (priv->operating_point_idc >> (priv->spatial_id + 8)) & 1;
 if (!in_temporal_layer || !in_spatial_layer) {
-// Decoding will drop this OBU at this operating point.
+return AVERROR(EAGAIN); // drop_obu()
 }
 }
 }
@@ -1238,10 +1239,25 @@ static const CodedBitstreamUnitTypeDescriptor 
cbs_av1_unit_types[] = {
 CBS_UNIT_TYPE_END_OF_LIST
 };
 
+#define OFFSET(x) offsetof(CodedBitstreamAV1Context, x)
+static const AVOption cbs_av1_options[] = {
+{ "oppoint",  "Select an operating point of the scalable bitstream", 
OFFSET(operating_point),
+  AV_OPT_TYPE_INT, { .i64 = -1 }, -1, AV1_MAX_OPERATING_POINTS 
- 1, 0 },
+{ NULL }
+};
+
+static const AVClass cbs_av1_class = {
+.class_name = "cbs_av1",
+.item_name  = av_default_item_name,
+.option = cbs_av1_options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
 const CodedBitstreamType ff_cbs_type_av1 = {
 .codec_id  = AV_CODEC_ID_AV1,
 
 .priv_data_size= sizeof(CodedBitstreamAV1Context),
+.priv_class= &cbs_av1_class,
 
 .unit_types= cbs_av1_unit_types,
 
diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h
index 7a0c08c596..27b44d68ff 100644
--- a/libavcodec/cbs_av1.h
+++ b/libavcodec/cbs_av1.h
@@ -416,6 +416,8 @@ typedef struct AV1ReferenceFrameState {
 } AV1ReferenceFrameState;
 
 typedef struct CodedBitstreamAV1Context {
+const AVClass *class;
+
 AV1RawSequenceHeader *sequence_header;
 AVBufferRef  *sequence_header_ref;
 
@@ -443,6 +445,9 @@ typedef struct CodedBitstreamAV1Context {
 int tile_rows;
 
 AV1ReferenceFrameState ref[AV1_NUM_REF_FRAMES];
+
+// AVOptions
+int operating_point;
 } CodedBitstreamAV1Context;
 
 
diff --git a/libavcodec/cbs_av1_syntax_template.c 
b/libavcodec/cbs_av1_syntax_template.c
index bcaa334134..34d09fab68 100644
--- a/libavcodec/cbs_av1_syntax_template.c
+++ b/libavcodec/cbs_av1_syntax_template.c
@@ -186,6 +186,7 @@ static int FUNC(decoder_model_info)(CodedBitstreamContext 
*ctx, RWContext *rw,
 static int FUNC(sequence_header_obu)(CodedBitstreamContext *ctx, RWContext *rw,
  AV1RawSequenceHeader *current)
 {
+CodedBitstreamAV1Context *priv = ctx->priv_data;
 int i, err;
 
 HEADER("Sequence Header");
@@ -253,6 +254,12 @@ static int FUNC(sequence_header_obu)(CodedBitstreamContext 
*ctx, RWContext *rw,
 }
 }
 }
+if (priv->operating_point >= 0) {
+int op_pt = 0;
+if (priv->operating_point <= current->operating_points_cnt_minus_1)
+op_pt = priv->operating_point;
+priv->operating_point_idc = current->operating_point_idc[op_pt];
+}
 
 fb(4, frame_width_bits_minus_1);
 fb(4, frame_height_bits_minus_1);
-- 
2.27.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 1/4] avcodec/cbs: add an AVClass to CodedBitstreamType for option handling

2020-09-20 Thread James Almer
So unit parsing may be configured with caller set options.

Signed-off-by: James Almer 
---
 libavcodec/cbs.c  | 9 +
 libavcodec/cbs_internal.h | 6 ++
 2 files changed, 15 insertions(+)

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 7c1aa005c2..e73e18f398 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -23,6 +23,7 @@
 #include "libavutil/avassert.h"
 #include "libavutil/buffer.h"
 #include "libavutil/common.h"
+#include "libavutil/opt.h"
 
 #include "cbs.h"
 #include "cbs_internal.h"
@@ -101,6 +102,10 @@ int ff_cbs_init(CodedBitstreamContext **ctx_ptr,
 av_freep(&ctx);
 return AVERROR(ENOMEM);
 }
+if (type->priv_class) {
+*(const AVClass **)ctx->priv_data = type->priv_class;
+av_opt_set_defaults(ctx->priv_data);
+}
 }
 
 ctx->decompose_unit_types = NULL;
@@ -123,6 +128,10 @@ void ff_cbs_close(CodedBitstreamContext **ctx_ptr)
 ctx->codec->close(ctx);
 
 av_freep(&ctx->write_buffer);
+
+if (ctx->codec->priv_class && ctx->priv_data)
+av_opt_free(ctx->priv_data);
+
 av_freep(&ctx->priv_data);
 av_freep(ctx_ptr);
 }
diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
index d991e1eedf..10530af69f 100644
--- a/libavcodec/cbs_internal.h
+++ b/libavcodec/cbs_internal.h
@@ -86,6 +86,12 @@ typedef const struct CodedBitstreamUnitTypeDescriptor {
 typedef struct CodedBitstreamType {
 enum AVCodecID codec_id;
 
+// A class for the private data, used to declare private AVOptions.
+// This field is NULL for types that do not declare any options.
+// If this field is non-NULL, the first member of the filter private data
+// must be a pointer to AVClass.
+const AVClass *priv_class;
+
 size_t priv_data_size;
 
 // List of unit type descriptors for this codec.
-- 
2.27.0

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

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

[FFmpeg-devel] [PATCH 4/4] avcodec/av1dec: add an option to select an operating point

2020-09-20 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/av1dec.c | 36 
 libavcodec/av1dec.h |  7 +++
 2 files changed, 43 insertions(+)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 0bb04a3e44..178fbdc2f0 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -19,6 +19,7 @@
  */
 
 #include "libavutil/pixdesc.h"
+#include "libavutil/opt.h"
 #include "avcodec.h"
 #include "av1dec.h"
 #include "bytestream.h"
@@ -343,6 +344,7 @@ static void av1_frame_unref(AVCodecContext *avctx, AV1Frame 
*f)
 ff_thread_release_buffer(avctx, &f->tf);
 av_buffer_unref(&f->hwaccel_priv_buf);
 f->hwaccel_picture_private = NULL;
+f->spatial_id = f->temporal_id = 0;
 }
 
 static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame 
*src)
@@ -360,6 +362,8 @@ static int av1_frame_ref(AVCodecContext *avctx, AV1Frame 
*dst, const AV1Frame *s
 dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data;
 }
 
+dst->spatial_id = src->spatial_id;
+dst->temporal_id = src->temporal_id;
 dst->loop_filter_delta_enabled = src->loop_filter_delta_enabled;
 memcpy(dst->loop_filter_ref_deltas,
src->loop_filter_ref_deltas,
@@ -495,6 +499,8 @@ static av_cold int av1_decode_init(AVCodecContext *avctx)
 if (ret < 0)
 return ret;
 
+av_opt_set_int(s->cbc->priv_data, "oppoint", s->operating_point, 0);
+
 if (avctx->extradata && avctx->extradata_size) {
 ret = ff_cbs_read(s->cbc, &s->current_obu, avctx->extradata,
   avctx->extradata_size);
@@ -578,6 +584,11 @@ static int set_output_frame(AVCodecContext *avctx, AVFrame 
*frame,
 const AVFrame *srcframe = s->cur_frame.tf.f;
 int ret;
 
+// TODO: all layers
+if (s->operating_point_idc &&
+av_log2(s->operating_point_idc >> 8) > s->cur_frame.spatial_id)
+return 0;
+
 ret = av_frame_ref(frame, srcframe);
 if (ret < 0)
 return ret;
@@ -660,6 +671,8 @@ static int av1_decode_frame(AVCodecContext *avctx, void 
*frame,
 for (int i = 0; i < s->current_obu.nb_units; i++) {
 CodedBitstreamUnit *unit = &s->current_obu.units[i];
 AV1RawOBU *obu = unit->content;
+const AV1RawOBUHeader *header = &obu->header;
+int op = 0;
 av_log(avctx, AV_LOG_DEBUG, "Obu idx:%d, obu type:%d.\n", i, 
unit->type);
 
 switch (unit->type) {
@@ -679,6 +692,10 @@ static int av1_decode_frame(AVCodecContext *avctx, void 
*frame,
 goto end;
 }
 
+if (s->operating_point <= s->raw_seq->operating_points_cnt_minus_1)
+op = s->operating_point;
+s->operating_point_idc = s->raw_seq->operating_point_idc[op];
+
 if (s->pix_fmt == AV_PIX_FMT_NONE) {
 ret = get_pixel_format(avctx);
 if (ret < 0) {
@@ -753,6 +770,9 @@ static int av1_decode_frame(AVCodecContext *avctx, void 
*frame,
 goto end;
 }
 
+s->cur_frame.spatial_id  = header->spatial_id;
+s->cur_frame.temporal_id = header->temporal_id;
+
 if (avctx->hwaccel) {
 ret = avctx->hwaccel->start_frame(avctx, unit->data,
   unit->data_size);
@@ -846,6 +866,21 @@ static void av1_decode_flush(AVCodecContext *avctx)
 s->raw_seq = NULL;
 }
 
+#define OFFSET(x) offsetof(AV1DecContext, x)
+#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
+static const AVOption av1_options[] = {
+{ "oppoint",  "Select an operating point of the scalable bitstream", 
OFFSET(operating_point),
+  AV_OPT_TYPE_INT, { .i64 = 0 }, 0, AV1_MAX_OPERATING_POINTS - 
1, VD },
+{ NULL }
+};
+
+static const AVClass av1_class = {
+.class_name = "AV1 decoder",
+.item_name  = av_default_item_name,
+.option = av1_options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
 AVCodec ff_av1_decoder = {
 .name  = "av1",
 .long_name = NULL_IF_CONFIG_SMALL("Alliance for Open Media 
AV1"),
@@ -861,6 +896,7 @@ AVCodec ff_av1_decoder = {
  FF_CODEC_CAP_SETS_PKT_DTS,
 .flush = av1_decode_flush,
 .profiles  = NULL_IF_CONFIG_SMALL(ff_av1_profiles),
+.priv_class= &av1_class,
 .hw_configs= (const AVCodecHWConfigInternal * []) {
 NULL
 },
diff --git a/libavcodec/av1dec.h b/libavcodec/av1dec.h
index 3604870299..67ae4c2c9f 100644
--- a/libavcodec/av1dec.h
+++ b/libavcodec/av1dec.h
@@ -36,6 +36,9 @@ typedef struct AV1Frame {
 AVBufferRef *hwaccel_priv_buf;
 void *hwaccel_picture_private;
 
+int temporal_id;
+int spatial_id;
+
 uint8_t loop_filter_delta_enabled;
 int8_t  loop_filter_ref_deltas[AV1_NUM_REF_FRAMES];
 int8_t  loop_filter_mode_deltas[2];
@@ -67,9 +70,13 @@ typedef struct AV1DecContext {
 uint16_t tg_start;
 uint16_t tg_

Re: [FFmpeg-devel] [PATCH] lavf/srt: fix build fail when used the libsrt 1.4.1

2020-09-20 Thread Gyan Doshi



On 17-09-2020 01:07 pm, Gyan Doshi wrote:



On 15-09-2020 12:47 pm, myp...@gmail.com wrote:

On Tue, Sep 15, 2020 at 2:23 PM Gyan Doshi  wrote:

This should be backported to 4.3 and other releases whose builds fail.

Gyan

Will backporting, thx


Ping.

4.3.1 build with libsrt remains broken.


I'll test and apply this myself, I guess.

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

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

Re: [FFmpeg-devel] [PATCH] avformat/aaxdec: Fix potential integer overflow

2020-09-20 Thread Paul B Mahol
On Sun, Sep 20, 2020 at 06:16:57PM +0200, Andreas Rheinhardt wrote:
> The AAX demuxer reads a 32bit number containing the amount of entries
> of an array and stores it in an uint32_t. Yet when iterating over this
> array, a loop counter of type int is used. This leads to undefined
> behaviour if the amount of entries is not in the range of int; to avoid
> this, it is generally good to use the same type for the loop counter as
> for the variable it is compared to. This is done in one of the two loops
> affected by this.
> 
> In the other loop, the undefined behaviour can begin even earlier: Here
> the loop counter is multiplied by an uint16_t which can overflow as soon
> as the loop counter is > 2^15. Using an unsigned type would avoid the
> undefined behaviour, but truncation would still be possible, so use an
> uint64_t.
> 
> Also use an uint32_t for a variable containing an index in said array.
> 
> This fixes Coverity issue #1466767.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
> This is untested as I could only find out that this is a gaming format.
> 

lgtm

>  libavformat/aaxdec.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/aaxdec.c b/libavformat/aaxdec.c
> index cfd2e10a15..3db6e9bc6d 100644
> --- a/libavformat/aaxdec.c
> +++ b/libavformat/aaxdec.c
> @@ -51,7 +51,7 @@ typedef struct AAXContext {
>  int64_t strings_size;
>  char *string_table;
>  
> -int current_segment;
> +uint32_t current_segment;
>  
>  AAXColumn *xcolumns;
>  AAXSegment *segments;
> @@ -239,7 +239,7 @@ static int aax_read_header(AVFormatContext *s)
>  flag = a->xcolumns[c].flag;
>  col_offset = a->xcolumns[c].offset;
>  
> -for (int r = 0; r < a->nb_segments; r++) {
> +for (uint64_t r = 0; r < a->nb_segments; r++) {
>  if (flag & COLUMN_FLAG_DEFAULT) {
>  data_offset = a->schema_offset + col_offset;
>  } else if (flag & COLUMN_FLAG_ROW) {
> @@ -330,7 +330,7 @@ static int aax_read_packet(AVFormatContext *s, AVPacket 
> *pkt)
>  
>  pkt->pos = avio_tell(pb);
>  
> -for (int seg = 0; seg < a->nb_segments; seg++) {
> +for (uint32_t seg = 0; seg < a->nb_segments; seg++) {
>  int64_t start = a->segments[seg].start;
>  int64_t end   = a->segments[seg].end;
>  
> -- 
> 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 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] Request for immediate take of action

2020-09-20 Thread Paul B Mahol
On Tue, Sep 08, 2020 at 03:28:06PM +0200, Nicolas George wrote:
> Paul B Mahol (12020-09-08):
> > It was reviewed on IRC. Nobody complained about it.
> 
> Show the relevant excerpt of log. Non-trivial reviews should happen on
> the mailing-list anyway.
> 
> > The explanation in commit log is very cryptic.
> 
> I do not owe you my time. All the information is there. Ask specific
> question if you want help understanding it.
> 
> > Are you saying that switch to .activate API for src_movie filter
> > is not possible at all at current time?
> 
> It is possible. Just more complicated than you did, and for a result
> that should be simpler than the current code.


Provide command line you used to find out that my change is wrong.

If I not receive reply within 96h I will push revert.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v3] avutil/pixfmt: improve definition of AVColorRange

2020-09-20 Thread Vittorio Giovara
On Sun, Sep 20, 2020 at 7:12 PM Jan Ekström  wrote:

> As it was brought up that the current documentation leaves things
> as specific to YCbCr only, ICtCp and RGB are now mentioned.
> Additionally, the specifications on which these definitions of
> narrow and full range are defined are mentioned.
>
> This way, the documentation of AVColorRange should now match how
> most people seem to read interpret it at this point, and thus
> flagging RGB AVFrames as full range is valid not only according to
> common sense, but also the enum definition.
> ---
>  libavutil/pixfmt.h | 54 +++---
>  1 file changed, 51 insertions(+), 3 deletions(-)
>
> diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
> index a46acf3c5e..46ef211add 100644
> --- a/libavutil/pixfmt.h
> +++ b/libavutil/pixfmt.h
> @@ -530,12 +530,60 @@ enum AVColorSpace {
>  };
>
>  /**
> - * MPEG vs JPEG YUV range.
> + * Visual content value range.
> + *
> + * These values are based on definitions that can be found in multiple
> + * specifications, such as ITU-T BT.709 (3.4 - Quantization of RGB,
> luminance
> + * and colour-difference signals), ITU-T BT.2020 (Table 5 - Digital
> + * Representation) as well as ITU-T BT.2100 (Table 9 - Digital 10- and
> 12-bit
> + * integer representation). At the time of writing, the BT.2100 one is
> + * recommended, as it also defines the full range representation.
> + *
> + * Common definitions:
> + *   - For RGB and luminance planes such as Y in YCbCr and I in ICtCp,
> + * 'E' is the original value in range of 0.0 to 1.0.
> + *   - For chrominance planes such as Cb,Cr and Ct,Cp, 'E' is the original
> + * value in range of -0.5 to 0.5.
> + *   - 'n' is the output bit depth.
> + *   - For additional definitions such as rounding and clipping to valid n
> + * bit unsigned integer range, please refer to BT.2100 (Table 9).
>   */
>  enum AVColorRange {
>  AVCOL_RANGE_UNSPECIFIED = 0,
> -AVCOL_RANGE_MPEG= 1, ///< the normal 219*2^(n-8) "MPEG" YUV
> ranges
> -AVCOL_RANGE_JPEG= 2, ///< the normal 2^n-1   "JPEG" YUV
> ranges
> +
> +/**
> + * Narrow or limited range content.
> + *
> + * - For luminance planes:
> + *
> + *   (219 * E + 16) * 2^(n-8)
> + *
> + *   F.ex. the range of 16-235 for 8 bits
> + *
> + * - For chrominance planes:
> + *
> + *   (224 * E + 128) * 2^(n-8)
> + *
> + *   F.ex. the range of 16-240 for 8 bits
> + */
>

I might have a minor suggestion: instead of giving the example for 8 bit
only, why not provide the generic formula for any bitdepth?
If you think it's too convoluted or the wrong place for this information,
I'd still recommend adding an example for 10 bit too, since a lot of new
content is produced in 10 bit, and could be a useful reference.

Overall this is a great improvement to the existing documentation, thanks
for writing it down
-- 
Vittorio
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v3] avutil/pixfmt: improve definition of AVColorRange

2020-09-20 Thread Jan Ekström
On Sun, Sep 20, 2020 at 9:34 PM Vittorio Giovara
 wrote:
>
> On Sun, Sep 20, 2020 at 7:12 PM Jan Ekström  wrote:
>
> > As it was brought up that the current documentation leaves things
> > as specific to YCbCr only, ICtCp and RGB are now mentioned.
> > Additionally, the specifications on which these definitions of
> > narrow and full range are defined are mentioned.
> >
> > This way, the documentation of AVColorRange should now match how
> > most people seem to read interpret it at this point, and thus
> > flagging RGB AVFrames as full range is valid not only according to
> > common sense, but also the enum definition.
> > ---
> >  libavutil/pixfmt.h | 54 +++---
> >  1 file changed, 51 insertions(+), 3 deletions(-)
> >
> > diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
> > index a46acf3c5e..46ef211add 100644
> > --- a/libavutil/pixfmt.h
> > +++ b/libavutil/pixfmt.h
> > @@ -530,12 +530,60 @@ enum AVColorSpace {
> >  };
> >
> >  /**
> > - * MPEG vs JPEG YUV range.
> > + * Visual content value range.
> > + *
> > + * These values are based on definitions that can be found in multiple
> > + * specifications, such as ITU-T BT.709 (3.4 - Quantization of RGB,
> > luminance
> > + * and colour-difference signals), ITU-T BT.2020 (Table 5 - Digital
> > + * Representation) as well as ITU-T BT.2100 (Table 9 - Digital 10- and
> > 12-bit
> > + * integer representation). At the time of writing, the BT.2100 one is
> > + * recommended, as it also defines the full range representation.
> > + *
> > + * Common definitions:
> > + *   - For RGB and luminance planes such as Y in YCbCr and I in ICtCp,
> > + * 'E' is the original value in range of 0.0 to 1.0.
> > + *   - For chrominance planes such as Cb,Cr and Ct,Cp, 'E' is the original
> > + * value in range of -0.5 to 0.5.
> > + *   - 'n' is the output bit depth.
> > + *   - For additional definitions such as rounding and clipping to valid n
> > + * bit unsigned integer range, please refer to BT.2100 (Table 9).
> >   */
> >  enum AVColorRange {
> >  AVCOL_RANGE_UNSPECIFIED = 0,
> > -AVCOL_RANGE_MPEG= 1, ///< the normal 219*2^(n-8) "MPEG" YUV
> > ranges
> > -AVCOL_RANGE_JPEG= 2, ///< the normal 2^n-1   "JPEG" YUV
> > ranges
> > +
> > +/**
> > + * Narrow or limited range content.
> > + *
> > + * - For luminance planes:
> > + *
> > + *   (219 * E + 16) * 2^(n-8)
> > + *
> > + *   F.ex. the range of 16-235 for 8 bits
> > + *
> > + * - For chrominance planes:
> > + *
> > + *   (224 * E + 128) * 2^(n-8)
> > + *
> > + *   F.ex. the range of 16-240 for 8 bits
> > + */
> >
>
> I might have a minor suggestion: instead of giving the example for 8 bit
> only, why not provide the generic formula for any bitdepth?

I think I already have the formulas there ;) .

If you generate the doxygen, it even puts the formula into a nice code block.

> If you think it's too convoluted or the wrong place for this information,
> I'd still recommend adding an example for 10 bit too, since a lot of new
> content is produced in 10 bit, and could be a useful reference.
>

I think personally a single example is enough since the formulas and
definition of E and n are already there. But if anyone else feels
heavily for adding the 10 bit example values, I can add them.

Jan
___
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/yuv4mpegenc: simplify writing the header

2020-09-20 Thread Jan Ekström
On Thu, Sep 10, 2020 at 3:00 AM James Almer  wrote:
>
> On 9/9/2020 7:54 PM, Michael Niedermayer wrote:
> > On Thu, Sep 03, 2020 at 03:55:04PM -0300, James Almer wrote:
> >> Actually write it in yuv4_write_header() instead of with the first
> >> packet.
> >>
> >> Signed-off-by: James Almer 
> >> ---
> >>  libavformat/yuv4mpegenc.c | 35 ++-
> >>  1 file changed, 14 insertions(+), 21 deletions(-)
> >
> > This changes the written header
> > for example:
> > ./ffmpeg  -i ~/tickets/2190/clip.yuv -bitexact testbad.y4m
> >
> > YUV4MPEG2 W720 H480 F3:1001 Ip A10:11 C411 XYSCSS=411
> > vs
> > YUV4MPEG2 W720 H480 F3:1001 Ib A10:11 C411 XYSCSS=411
>
> If I'm reading this right, ffmpeg.c changes the output AVCodecParameters
> struct (In this case, field_order) after calling avformat_write_header()
> but before writing a packet, which is wrong.
>
> We could revert this change (And the one by Andreas that came after it),
> but perhaps ffmpeg.c should be fixed to not violate the API instead.

My patch set that moves the encoder initialization later actually
enables moving this logic to before the encoder or the stream are
initialized, and fixes this difference.

Unfortunately, the resulting values which are now available for
general usage in header writing lead to various differences in FATE
tests (mostly tt switching tb) a la:

diff --git a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10
b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10
index 79ce1e2306..8f3f2e5265 100644
--- a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10
+++ b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10
@@ -78,5 +78,5 @@
video|0|34|1.36|34|1.36|1|0.04|N/A|N/A|15|1924096|K_|1
 Strings Metadata
 audio|1|65280|1.36|65280|1.36|1920|0.04|N/A|N/A|7680|2074624|K_|1
 Strings Metadata
-0|mpeg2video|0|video|1/25|[0][0][0][0]|0x|720|608|0|0|0|0|1:1|45:38|yuv422p|5|tv|unknown|unknown|unknown|topleft|tt|N/A|1|N/A|25/1|25/1|1/25|0|0.00|N/A|N/A|3000|N/A|N/A|N/A|N/A|35|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001301
+0|mpeg2video|0|video|1/25|[0][0][0][0]|0x|720|608|0|0|0|0|1:1|45:38|yuv422p|5|tv|unknown|unknown|unknown|topleft|tb|N/A|1|N/A|25/1|25/1|1/25|0|0.00|N/A|N/A|3000|N/A|N/A|N/A|N/A|35|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001301
 
1|pcm_s16le|unknown|audio|1/48000|[0][0][0][0]|0x|s16|48000|2|unknown|16|N/A|0/0|0/0|1/48000|0|0.00|N/A|N/A|1536000|N/A|N/A|N/A|N/A|35|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001301


Patch to test on top of the late_encoder_init set follows (also
included as part of the WIP branch
https://github.com/jeeb/ffmpeg/commits/late_encoder_init_v5 ):

Jan

--->8--
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 8874da9268..0a3b998e7a 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1114,7 +1114,6 @@ static void do_video_out(OutputFile *of,
 int ret, format_video_sync;
 AVPacket pkt;
 AVCodecContext *enc = ost->enc_ctx;
-AVCodecParameters *mux_par = ost->st->codecpar;
 AVRational frame_rate;
 int nb_frames, nb0_frames, i;
 double delta, delta0;
@@ -1276,18 +1275,6 @@ static void do_video_out(OutputFile *of,
 if (!check_recording_time(ost))
 return;

-if (enc->flags & (AV_CODEC_FLAG_INTERLACED_DCT |
AV_CODEC_FLAG_INTERLACED_ME) &&
-ost->top_field_first >= 0)
-in_picture->top_field_first = !!ost->top_field_first;
-
-if (in_picture->interlaced_frame) {
-if (enc->codec->id == AV_CODEC_ID_MJPEG)
-mux_par->field_order = in_picture->top_field_first ?
AV_FIELD_TT:AV_FIELD_BB;
-else
-mux_par->field_order = in_picture->top_field_first ?
AV_FIELD_TB:AV_FIELD_BT;
-} else
-mux_par->field_order = AV_FIELD_PROGRESSIVE;
-
 in_picture->quality = enc->global_quality;
 in_picture->pict_type = 0;

@@ -3432,6 +3419,20 @@ static int
init_output_stream_encode(OutputStream *ost, AVFrame *frame)
 enc_ctx->field_order = AV_FIELD_TT;
 }

+if (frame) {
+if (enc_ctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT |
AV_CODEC_FLAG_INTERLACED_ME) &&
+ost->top_field_first >= 0)
+frame->top_field_first = !!ost->top_field_first;
+
+if (frame->interlaced_frame) {
+if (enc_ctx->codec->id == AV_CODEC_ID_MJPEG)
+enc_ctx->field_order = frame->top_field_first ?
AV_FIELD_TT:AV_FIELD_BB;
+else
+enc_ctx->field_order = frame->top_field_first ?
AV_FIELD_TB:AV_FIELD_BT;
+} else
+enc_ctx->field_order = AV_FIELD_PROGRESSIVE;
+}
+
 if (ost->forced_keyframes) {
 if (!strncmp(ost->forced_keyframes, "expr:", 5)) {
 ret = av_expr_pa

[FFmpeg-devel] [PATCH 4/4] avcodec/photocd: Use ff_set_dimensions()

2020-09-20 Thread Michael Niedermayer
Fixes: out of memory
Fixes: 
25588/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PHOTOCD_fuzzer-6612945080156160

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

diff --git a/libavcodec/photocd.c b/libavcodec/photocd.c
index 057c9d33d4..07f10e28b7 100644
--- a/libavcodec/photocd.c
+++ b/libavcodec/photocd.c
@@ -324,8 +324,9 @@ static int photocd_decode_frame(AVCodecContext *avctx, void 
*data,
 else
 s->resolution = av_clip(4 - s->lowres, 0, 4);
 
-avctx->width  = img_info[s->resolution].width;
-avctx->height = img_info[s->resolution].height;
+ret = ff_set_dimensions(avctx, img_info[s->resolution].width, 
img_info[s->resolution].height);
+if (ret < 0)
+return ret;
 
 if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)
 return ret;
-- 
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 2/4] avformat/vividas: Check for EOF in first loop in track_header()

2020-09-20 Thread Michael Niedermayer
Fixes: timeout (243sec -> a few ms)
Fixes: 
25716/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5764093666131968

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

diff --git a/libavformat/vividas.c b/libavformat/vividas.c
index 36c007b0d2..7917df5d64 100644
--- a/libavformat/vividas.c
+++ b/libavformat/vividas.c
@@ -293,6 +293,8 @@ static int track_header(VividasDemuxContext *viv, 
AVFormatContext *s,  uint8_t *
 
 for (i=0;ihttps://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] avformat/moflex: Check pop_int() for overflow

2020-09-20 Thread Michael Niedermayer
Fixes: signed integer overflow: 2 * 2132811776 cannot be represented in type 
'int'
Fixes: 
25722/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-6221704077246464

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

diff --git a/libavformat/moflex.c b/libavformat/moflex.c
index 257408..937f63cb63 100644
--- a/libavformat/moflex.c
+++ b/libavformat/moflex.c
@@ -62,6 +62,8 @@ static int pop_int(BitReader *br, AVIOContext *pb, int n)
 
 if (ret < 0)
 return ret;
+if (ret > INT_MAX - value - value)
+return AVERROR_INVALIDDATA;
 value = 2 * value + ret;
 }
 
-- 
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/wvdec: Check rate for overflow

2020-09-20 Thread Michael Niedermayer
Fixes: signed integer overflow: 6000 * -2147483648 cannot be represented in 
type 'int'
Fixes: 
25700/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6578316302352384

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

diff --git a/libavformat/wvdec.c b/libavformat/wvdec.c
index b9fc6a59f9..b7d8dbbe78 100644
--- a/libavformat/wvdec.c
+++ b/libavformat/wvdec.c
@@ -192,7 +192,7 @@ static int wv_read_block_header(AVFormatContext *ctx, 
AVIOContext *pb)
 if (id & 0x40)
 avio_skip(pb, 1);
 }
-if (rate == -1) {
+if (rate == -1 || rate * (uint64_t)rate_x >= INT_MAX) {
 av_log(ctx, AV_LOG_ERROR,
"Cannot determine custom sampling rate\n");
 return AVERROR_INVALIDDATA;
-- 
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 3/4 v2] ffmpeg: move A/V non-streamcopy initialization to a later point

2020-09-20 Thread Jan Ekström
On Wed, Sep 16, 2020 at 1:20 PM Jan Ekström  wrote:
>
> On Wed, Sep 16, 2020 at 12:24 AM Michael Niedermayer
>  wrote:
> >
> > On Mon, Sep 14, 2020 at 12:33:14AM +0300, Jan Ekström wrote:
> > > - For video, this means a single initialization point in do_video_out.
> > > - For audio we unfortunately need to do it in two places just
> > >   before the buffer sink is utilized (if av_buffersink_get_samples
> > >   would still work according to its specification after a call to
> > >   avfilter_graph_request_oldest was made, we could at least remove
> > >   the one in transcode_step).
> > >
> > > Other adjustments to make things work:
> > > - As the AVFrame PTS adjustment to encoder time base needs the encoder
> > >   to be initialized, so it is now moved to do_{video,audio}_out,
> > >   right after the encoder has been initialized. Due to this,
> > >   the additional parameter in do_video_out is removed as it is no
> > >   longer necessary.
> > > ---
> > >  fftools/ffmpeg.c | 112 ---
> > >  1 file changed, 77 insertions(+), 35 deletions(-)
> >
> > breaks this:
> > ./ffmpeg -ss 30.0 -i ~/tickets/1745/1745-Sample.mkv -f vob -c:a copy  
> > -bitexact -t 1 -f framecrc -
> > (sample file is linked in the ticket https://trac.ffmpeg.org/ticket/1745)
> >
> > (Too many packets buffered for output stream 0:1. Conversion failed!)
> >
> > thx
>
> With an initial look with -debug_ts -v verbose -max_muxing_queue_size
> 1 , it appears that audio packets start at about -5.5 seconds, and
> video is getting skipped until an exact zero point is hit.
>
> So either the offset is incorrect, or we should also be dropping the
> audio packets as well until zero point is found.
>
> Jan

So, with a further look this stems from a difference in how stream
copy and non-stream copy cases are handled:
- For stream copy by default any packets received after the seek point
are thrown into the muxer, even if we end up way before the actual
seek point. There is `-copypriorss 0` to control that behavior.
- For re-encoding use cases we wait until we hit the wanted seek point.

In this specific example, seeking gets us to 5 or so seconds before
the wanted point.

Before:
- Audio stream packets would get thrown to muxer, as both streams get
initialized at a similar point. Any buffering/sync issues are left to
lavf/the muxer.
- Video stream packets would get thrown out until the seek point was hit.
- So you have ~5.5 seconds of audio only, and then video.

Now:
- Audio stream packets are passed into ffmpeg.c's muxing buffer, as
the video stream has not yet been initialized as the first video frame
has not been decoded.
- Video stream packets still get thrown out until the seek point is hit.
- Since the audio packets contain (1536/48000) seconds of audio, quite
a few have to be buffered (187 according to my testing) for the mux to
succeed. This way larger than the default muxing queue.
- Thus, the remux part fails.

Alternatives:
- Alternative A: To keep the current behavior, we would have to start
decoding those frames, but dropping them out later in the logic. That
way the output stream may be initialized, but no video output would
happen.
- Alternative B: We normalize the behavior according to how stream
copy works by default. Video also gets output if the packets are
copied.
- Alternative C: We normalize the behavior according to how the
re-encoding logic works by default. `-copypriorss 0` would effectively
become the default.

I think in a way I would prefer Alternative C, as I'm not sure how
many people expect to get packets from way before their requested seek
point. Of course, in a perfect world we would do such things with
indexing a la ffms2, where we know exactly how long and how structured
an input is - and to which packet to seek and how much to decode or
drop.

Jan
___
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/photocd: Use ff_set_dimensions()

2020-09-20 Thread Paul B Mahol
On Sun, Sep 20, 2020 at 10:26:08PM +0200, Michael Niedermayer wrote:
> Fixes: out of memory
> Fixes: 
> 25588/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PHOTOCD_fuzzer-6612945080156160
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/photocd.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/photocd.c b/libavcodec/photocd.c
> index 057c9d33d4..07f10e28b7 100644
> --- a/libavcodec/photocd.c
> +++ b/libavcodec/photocd.c
> @@ -324,8 +324,9 @@ static int photocd_decode_frame(AVCodecContext *avctx, 
> void *data,
>  else
>  s->resolution = av_clip(4 - s->lowres, 0, 4);
>  
> -avctx->width  = img_info[s->resolution].width;
> -avctx->height = img_info[s->resolution].height;
> +ret = ff_set_dimensions(avctx, img_info[s->resolution].width, 
> img_info[s->resolution].height);
> +if (ret < 0)
> +return ret;
>  
>  if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)
>  return ret;

Why is this needed at all, dimensions are alway static and completely allocable.
___
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] avformat/moflex: Check pop_int() for overflow

2020-09-20 Thread Paul B Mahol
On Sun, Sep 20, 2020 at 10:26:07PM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 2 * 2132811776 cannot be represented in type 
> 'int'
> Fixes: 
> 25722/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-6221704077246464
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/moflex.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavformat/moflex.c b/libavformat/moflex.c
> index 257408..937f63cb63 100644
> --- a/libavformat/moflex.c
> +++ b/libavformat/moflex.c
> @@ -62,6 +62,8 @@ static int pop_int(BitReader *br, AVIOContext *pb, int n)
>  
>  if (ret < 0)
>  return ret;
> +if (ret > INT_MAX - value - value)
> +return AVERROR_INVALIDDATA;
>  value = 2 * value + ret;

Generally acceptable.
___
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] avformat/vividas: Check for EOF in first loop in track_header()

2020-09-20 Thread Paul B Mahol
On Sun, Sep 20, 2020 at 10:26:06PM +0200, Michael Niedermayer wrote:
> Fixes: timeout (243sec -> a few ms)
> Fixes: 
> 25716/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5764093666131968
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/vividas.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavformat/vividas.c b/libavformat/vividas.c
> index 36c007b0d2..7917df5d64 100644
> --- a/libavformat/vividas.c
> +++ b/libavformat/vividas.c
> @@ -293,6 +293,8 @@ static int track_header(VividasDemuxContext *viv, 
> AVFormatContext *s,  uint8_t *
>  
>  for (i=0;i  int c = avio_r8(pb);
> +if (avio_feof(pb))
> +return AVERROR_EOF;
>  for (j=0;j  if (avio_feof(pb))
>  return AVERROR_EOF;
> -- 

Generally acceptable.
___
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/4] avformat/wvdec: Check rate for overflow

2020-09-20 Thread Paul B Mahol
On Sun, Sep 20, 2020 at 10:26:05PM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 6000 * -2147483648 cannot be represented in 
> type 'int'
> Fixes: 
> 25700/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6578316302352384
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/wvdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/wvdec.c b/libavformat/wvdec.c
> index b9fc6a59f9..b7d8dbbe78 100644
> --- a/libavformat/wvdec.c
> +++ b/libavformat/wvdec.c
> @@ -192,7 +192,7 @@ static int wv_read_block_header(AVFormatContext *ctx, 
> AVIOContext *pb)
>  if (id & 0x40)
>  avio_skip(pb, 1);
>  }
> -if (rate == -1) {
> +if (rate == -1 || rate * (uint64_t)rate_x >= INT_MAX) {
>  av_log(ctx, AV_LOG_ERROR,

AFAIK rate_x should be unsigned type from start.
rate_x can be max (1U << 31)
Otherwise patch is acceptable.

> "Cannot determine custom sampling rate\n");
>  return AVERROR_INVALIDDATA;
> -- 
> 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 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] configure: Add atsc_a53 dependencies for H.264 and HEVC parser

2020-09-20 Thread Carl Eugen Hoyos
Am Sa., 19. Sept. 2020 um 20:18 Uhr schrieb Andreas Rheinhardt
:
>
> They need it because they make use of SEI parsing code.
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  configure | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/configure b/configure
> index 5d68695192..70740a7bc7 100755
> --- a/configure
> +++ b/configure
> @@ -3143,8 +3143,8 @@ wmv3_crystalhd_decoder_select="crystalhd"
>  # parsers
>  aac_parser_select="adts_header"
>  av1_parser_select="cbs_av1"
> -h264_parser_select="golomb h264dsp h264parse"
> -hevc_parser_select="hevcparse"
> +h264_parser_select="atsc_a53 golomb h264dsp h264parse"
> +hevc_parser_select="atsc_a53 hevcparse"

Please push such patches if you tested them, I would
nearly have duplicated your work.

Thank you, Carl Eugen
___
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] configure: Add atsc_a53 dependencies for H.264 and HEVC parser

2020-09-20 Thread James Almer
On 9/19/2020 3:18 PM, Andreas Rheinhardt wrote:
> They need it because they make use of SEI parsing code.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  configure | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/configure b/configure
> index 5d68695192..70740a7bc7 100755
> --- a/configure
> +++ b/configure
> @@ -3143,8 +3143,8 @@ wmv3_crystalhd_decoder_select="crystalhd"
>  # parsers
>  aac_parser_select="adts_header"
>  av1_parser_select="cbs_av1"
> -h264_parser_select="golomb h264dsp h264parse"
> -hevc_parser_select="hevcparse"
> +h264_parser_select="atsc_a53 golomb h264dsp h264parse"
> +hevc_parser_select="atsc_a53 hevcparse"

Add it to hevcparse instead as i asked on IRC, so every module pulling
it also pulls atsc_a53.

>  mpegaudio_parser_select="mpegaudioheader"
>  mpegvideo_parser_select="mpegvideo"
>  mpeg4video_parser_select="h263dsp mpegvideo qpeldsp"
> 

___
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 21/21] avformat/dashdec: Avoid duplicating string

2020-09-20 Thread Steven Liu


> 2020年9月20日 上午12:36,Andreas Rheinhardt  写道:
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
> There is still stuff left to fix in this demuxer after this patchset:
> 1. resolve_content_path() is in bad shape; i.e. it can try to read
> str[-1].
> 2. One can get a crash in get_current_fragment() (or rather in
> ff_dash_fill_tmpl_params()) when one has a representation without fragment
> and without fragment/url template.
> 3. When one has a mismatch between old and new manifests in
> refresh_manifest(), the old representations leak. One could fix this by
> freeing the new representations and restoring the old ones, but this
> feels wrong; freeing the old ones is not possible, because
> refresh_manifests() is called indirectly by the read_packet function of
> an AVFormatContext associated with an old representation, so freeing
> the old representations would free the AVIOContext from within its
> read_packet function. This would lead to use-after-frees.
> 
> libavformat/dashdec.c | 7 +--
> 1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
> index be67192b14..747b4e92e3 100644
> --- a/libavformat/dashdec.c
> +++ b/libavformat/dashdec.c
> @@ -1183,7 +1183,6 @@ static int parse_manifest(AVFormatContext *s, const 
> char *url, AVIOContext *in)
> DASHContext *c = s->priv_data;
> int ret = 0;
> int close_in = 0;
> -uint8_t *new_url = NULL;
> int64_t filesize = 0;
> AVBPrint buf;
> AVDictionary *opts = NULL;
> @@ -1212,11 +1211,8 @@ static int parse_manifest(AVFormatContext *s, const 
> char *url, AVIOContext *in)
> return ret;
> }
> 
> -if (av_opt_get(in, "location", AV_OPT_SEARCH_CHILDREN, &new_url) >= 0) {
> -c->base_url = av_strdup(new_url);
> -} else {
> +if (av_opt_get(in, "location", AV_OPT_SEARCH_CHILDREN, 
> (uint8_t**)&c->base_url) < 0)
> c->base_url = av_strdup(url);
> -}
> 
> filesize = avio_size(in);
> filesize = filesize > 0 ? filesize : DEFAULT_MANIFEST_SIZE;
> @@ -1359,7 +1355,6 @@ cleanup:
> xmlFreeNode(mpd_baseurl_node);
> }
> 
> -av_free(new_url);
> av_bprint_finalize(&buf, NULL);
> if (close_in) {
> avio_close(in);
> -- 
> 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".

Patchset test ok, and lgtm.

Thanks

Steven Liu



___
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] lavf/srt: fix build fail when used the libsrt 1.4.1

2020-09-20 Thread myp...@gmail.com
On Mon, Sep 21, 2020 at 1:27 AM Gyan Doshi  wrote:
>
>
>
> On 17-09-2020 01:07 pm, Gyan Doshi wrote:
> >
> >
> > On 15-09-2020 12:47 pm, myp...@gmail.com wrote:
> >> On Tue, Sep 15, 2020 at 2:23 PM Gyan Doshi  wrote:
> >>> This should be backported to 4.3 and other releases whose builds fail.
> >>>
> >>> Gyan
> >> Will backporting, thx
> >
> > Ping.
> >
> > 4.3.1 build with libsrt remains broken.
>
> I'll test and apply this myself, I guess.
>

Busy with other urgent things last week, sorry, will test /back
porting then push to 4.3.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] lavf/srt: fix build fail when used the libsrt 1.4.1

2020-09-20 Thread myp...@gmail.com
On Mon, Sep 21, 2020 at 1:27 AM Gyan Doshi  wrote:
>
>
>
> On 17-09-2020 01:07 pm, Gyan Doshi wrote:
> >
> >
> > On 15-09-2020 12:47 pm, myp...@gmail.com wrote:
> >> On Tue, Sep 15, 2020 at 2:23 PM Gyan Doshi  wrote:
> >>> This should be backported to 4.3 and other releases whose builds fail.
> >>>
> >>> Gyan
> >> Will backporting, thx
> >
> > Ping.
> >
> > 4.3.1 build with libsrt remains broken.
>
> I'll test and apply this myself, I guess.
>
Done, thx
___
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".