Re: [FFmpeg-devel] [PATCH v1] libavformat/hls: During operation, the user exits and interrupts, causing pls->segment to be released, resulting in a null pointer crash

2020-10-19 Thread Andreas Rheinhardt
徐慧书:
> Andreas Rheinhardt  于2020年10月16日周五 下午9:32写道:
> 
>> javashu2...@gmail.com:
>>> From: bevis 
>>>
>>> Signed-off-by: bevis 
>>> ---
>>>  libavformat/hls.c | 5 +++--
>>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/libavformat/hls.c b/libavformat/hls.c
>>> index 72e28ab94f..0a522a4595 100644
>>> --- a/libavformat/hls.c
>>> +++ b/libavformat/hls.c
>>> @@ -1979,17 +1979,18 @@ static int hls_read_header(AVFormatContext *s)
>>>  pls->ctx->interrupt_callback = s->interrupt_callback;
>>>  url = av_strdup(pls->segments[0]->url);
>>>  ret = av_probe_input_buffer(&pls->pb, &in_fmt, url, NULL, 0, 0);
>>> -av_free(url);
>>>  if (ret < 0) {
>>>  /* Free the ctx - it isn't initialized properly at this
>> point,
>>>   * so avformat_close_input shouldn't be called. If
>>>   * avformat_open_input fails below, it frees and zeros the
>>>   * context, so it doesn't need any special treatment like
>> this. */
>>> -av_log(s, AV_LOG_ERROR, "Error when loading first segment
>> '%s'\n", pls->segments[0]->url);
>>> +av_log(s, AV_LOG_ERROR, "Error when loading first segment
>> '%s'\n", url);
>>>  avformat_free_context(pls->ctx);
>>>  pls->ctx = NULL;
>>> +av_free(url);
>>>  goto fail;
>>>  }
>>> +av_free(url);
>>>  pls->ctx->pb   = &pls->pb;
>>>  pls->ctx->io_open  = nested_io_open;
>>>  pls->ctx->flags   |= s->flags & ~AVFMT_FLAG_CUSTOM_IO;
>>>
>> The change itself seems fine to me (I wonder why this hasn't been
>> noticed when writing/reviewing b5e39880fb), but your commit message is
>> way too long: The first line should be a short description followed by a
>> more detailed description lateron (in the next lines).
>>
>> How exactly did you find this?
>>
>> - 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".
> 
> 
> hi, Andreas,I have already updated and initiated the submission, what else
> do I need to do to submit this fix?

It is fine for me, but I am not the maintainer of the hls demuxer.

- 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 1/1] libavformat/mov: Add bound checks to avoid integer overflow and invalid memory allocation

2020-10-19 Thread zhilizhao(赵志立)


> On Oct 19, 2020, at 10:42 AM, Xiaohui Zhang  wrote:
> 
> From: Zhang Xiaohui 
> 
> Hi, I think function mov_read_cmov fails to perform proper bounds
> checking on atom.size and cmov_len, which may lead to integer
> overflow and invalid memory allocation.
> 
> Signed-off-by: Zhang Xiaohui 
> ---
> libavformat/mov.c | 4 
> 1 file changed, 4 insertions(+)
> 
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 7fd43a8fc5..245c720e42 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -5181,8 +5181,12 @@ static int mov_read_cmov(MOVContext *c, AVIOContext 
> *pb, MOVAtom atom)
> if (avio_rl32(pb) != MKTAG('c','m','v','d'))
> return AVERROR_INVALIDDATA;
> moov_len = avio_rb32(pb); /* uncompressed size */
> +if (atom.size > LONG_MAX + 6 * 4)
> +return AVERROR_INVALIDDATA;

LONG_MAX + 6 * 4 leads to overflow.

> cmov_len = atom.size - 6 * 4;
> 
> +if (cmov_len <= 0)
> +return AVERROR_INVALIDDATA;
> cmov_data = av_malloc(cmov_len);
> if (!cmov_data)
> return AVERROR(ENOMEM);
> -- 
> 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 v2] libavcodec/pthread_frame: fix crash that call method ff_frame_thread_init failed because of mem insufficient

2020-10-19 Thread Andreas Rheinhardt
javashu2...@gmail.com:
> From: bevis 
> 
>   Start planning to submit in two, This is my complete modification. 
> 
> Signed-off-by: bevis 
> ---
>  libavcodec/pthread_frame.c | 25 +
>  1 file changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
> index f8a01ad8cd..3331fa0f6f 100644
> --- a/libavcodec/pthread_frame.c
> +++ b/libavcodec/pthread_frame.c
> @@ -687,7 +687,7 @@ void ff_frame_thread_free(AVCodecContext *avctx, int 
> thread_count)
>  pthread_join(p->thread, NULL);
>  p->thread_init=0;
>  
> -if (codec->close && p->avctx)
> +if (codec->close && p->avctx && p->avctx->priv_data)
>  codec->close(p->avctx);
>  
>  release_delayed_buffers(p);
> @@ -795,6 +795,11 @@ int ff_frame_thread_init(AVCodecContext *avctx)
>  pthread_cond_init(&p->progress_cond, NULL);
>  pthread_cond_init(&p->output_cond, NULL);
>  
> +if (!copy) {
> +err = AVERROR(ENOMEM);
> +goto error;
> +}
> +
>  p->frame = av_frame_alloc();
>  if (!p->frame) {
>  av_freep(©);
> @@ -802,22 +807,18 @@ int ff_frame_thread_init(AVCodecContext *avctx)
>  goto error;
>  }
>  
> -p->parent = fctx;
> -p->avctx  = copy;
> -
> -if (!copy) {
> +AVCodecInternal *internal = av_malloc(sizeof(AVCodecInternal));
> +if (!internal) {
> +av_freep(©);
>  err = AVERROR(ENOMEM);
>  goto error;
>  }
>  
> -*copy = *src;
> +p->parent = fctx;
> +p->avctx  = copy;
>  
> -copy->internal = av_malloc(sizeof(AVCodecInternal));
> -if (!copy->internal) {
> -copy->priv_data = NULL;
> -err = AVERROR(ENOMEM);
> -goto error;
> -}
> +*copy = *src;
> +copy->internal = internal;
>  *copy->internal = *src->internal;
>  copy->internal->thread_ctx = p;
>  copy->internal->last_pkt_props = &p->avpkt;
> 
This will still call the close function even if av_opt_copy() failed or
if init failed; in the former case, you are not allowed to call it at
all and in the latter case you are only allowed to do so if the AVCodec
has the FF_CODEC_CAP_INIT_CLEANUP set.

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

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

[FFmpeg-devel] [PATCH v5 2/9] avformat/s337m: Split read_packet/get_packet

2020-10-19 Thread Nicolas Gaullier
Prepare use of s337m_get_packet from outside.
---
 libavformat/s337m.c | 26 --
 libavformat/s337m.h | 37 +
 2 files changed, 57 insertions(+), 6 deletions(-)
 create mode 100644 libavformat/s337m.h

diff --git a/libavformat/s337m.c b/libavformat/s337m.c
index 36e1047af8..7f6eecb25c 100644
--- a/libavformat/s337m.c
+++ b/libavformat/s337m.c
@@ -21,6 +21,7 @@
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
 #include "spdif.h"
+#include "s337m.h"
 
 #define MARKER_16LE 0x72F81F4E
 #define MARKER_20LE 0x20876FF0E154
@@ -141,18 +142,20 @@ static void bswap_buf24(uint8_t *data, int size)
 FFSWAP(uint8_t, data[0], data[2]);
 }
 
-static int s337m_read_packet(AVFormatContext *s, AVPacket *pkt)
+int ff_s337m_get_packet(AVIOContext *pb, AVPacket *pkt, int size, enum 
AVCodecID *codec, void *avc)
 {
-AVIOContext *pb = s->pb;
 uint64_t state = 0;
 int ret, data_type, data_size, offset;
-enum AVCodecID codec;
-int64_t pos;
+int64_t pos, orig_pos = avio_tell(pb);
 
 while (!IS_LE_MARKER(state)) {
 state = (state << 8) | avio_r8(pb);
 if (avio_feof(pb))
 return AVERROR_EOF;
+if (avio_tell(pb) - orig_pos + 6 >= size) {
+av_log(avc, AV_LOG_ERROR, "s337m : sync bytes not found at packet 
pos=0x%"PRIx64" size=%d\n", orig_pos, size);
+return AVERROR_INVALIDDATA;
+}
 }
 
 if (IS_16LE_MARKER(state)) {
@@ -165,10 +168,10 @@ static int s337m_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 
 pos = avio_tell(pb);
 
-if ((ret = s337m_get_offset_and_codec(s, state, data_type, data_size, 
&offset, &codec)) < 0)
+if ((ret = s337m_get_offset_and_codec(avc, state, data_type, data_size, 
&offset, codec)) < 0)
 return ret;
 
-if ((ret = av_new_packet(pkt, offset)) < 0)
+if (ret = av_new_packet(pkt, FFMIN(offset, size - (pos - orig_pos))) < 0)
 return ret;
 
 pkt->pos = pos;
@@ -182,6 +185,17 @@ static int s337m_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 else
 bswap_buf24(pkt->data, pkt->size);
 
+return 0;
+}
+
+static int s337m_read_packet(AVFormatContext *s, AVPacket *pkt)
+{
+enum AVCodecID codec;
+int ret;
+
+if ((ret = ff_s337m_get_packet(s->pb, pkt, avio_size(s->pb), &codec, s)) < 
0)
+return ret;
+
 if (!s->nb_streams) {
 AVStream *st = avformat_new_stream(s, NULL);
 if (!st) {
diff --git a/libavformat/s337m.h b/libavformat/s337m.h
new file mode 100644
index 00..f7bd0c16f6
--- /dev/null
+++ b/libavformat/s337m.h
@@ -0,0 +1,37 @@
+/*
+ * SMPTE ST 337 common header
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVFORMAT_S337M_H
+#define AVFORMAT_S337M_H
+
+/**
+ * Read s337m packets in a PCM_S16LE/S24LE stereo stream
+ * Returns the first inner packet found
+ * Note that it does not require a clean guard band
+ * @param pb Associated IO context
+ * @param pkt On success, returns a DOLBY E packet
+ * @param size Maximum IO read size available for reading at current position
+ * @param codec Returns AV_CODEC_ID_DOLBY_E
+ * @param avc For av_log
+ * @return = 0 on success (an error is raised if no s337m was found)
+ */
+int ff_s337m_get_packet(AVIOContext *pb, AVPacket *pkt, int size, enum 
AVCodecID *codec, void *avc);
+
+#endif /* AVFORMAT_S337M_H */
-- 
2.27.0.windows.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 v5 1/9] avcodec/dolby_e: set constant frame_size

2020-10-19 Thread Nicolas Gaullier
Fixes pts generation.

Setting frame_size in dolby_e_init() or get_audio_frame_duration()
can result in a bad duration value for the first packet if dolby_e is
muxed in a container having a different sample_rate (ex:
container @48KHz, DolbyE @44.8KHz).
Maybe adding a parser to dolby_e would fix the issue and makes it
possible to set frame_size at decoder init which seems the best place.
---
 libavcodec/dolby_e.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/dolby_e.c b/libavcodec/dolby_e.c
index 429612ec08..b0e6d6aee3 100644
--- a/libavcodec/dolby_e.c
+++ b/libavcodec/dolby_e.c
@@ -577,6 +577,7 @@ static int filter_frame(DBEContext *s, AVFrame *frame)
 reorder = ch_reorder_n;
 
 frame->nb_samples = FRAME_SAMPLES;
+s->avctx->frame_size = FRAME_SAMPLES;
 if ((ret = ff_get_buffer(s->avctx, frame, 0)) < 0)
 return ret;
 
-- 
2.27.0.windows.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 v5 0/9] avformat: wav-s337m support + new probe_stream option

2020-10-19 Thread Nicolas Gaullier
Updates:
* patch 1 : commit msg amended (anton)
* patch 3 : 'if' line split (tomas)

Everthing else: unchanged since v4

For remembering: the test sample 512.wav can be downloaded here:
https://0x0.st/zdW-.wav

Nicolas Gaullier (9):
  avcodec/dolby_e: set constant frame_size
  avformat/s337m: Split read_packet/get_packet
  avformat/s337m: Consider container bit resolution
  avformat/s337m: New ff_s337m_probe()
  avformat/wavdec: s337m support
  avformat/wavdec.c: Reindent after last commit
  avformat/wavdec: fix s337m/spdif probing beyond data_end
  avformat/wavdec: Test s337m
  avformat: Add probe_stream option

 doc/formats.texi|  3 ++
 libavcodec/dolby_e.c|  1 +
 libavformat/avformat.h  |  9 -
 libavformat/options_table.h |  1 +
 libavformat/s337m.c | 73 -
 libavformat/s337m.h | 54 +++
 libavformat/utils.c |  2 +
 libavformat/version.h   |  2 +-
 libavformat/wavdec.c| 53 ++-
 tests/Makefile  |  1 +
 tests/fate/audio.mak|  3 ++
 tests/ref/fate/s337m-wav| 11 ++
 12 files changed, 185 insertions(+), 28 deletions(-)
 create mode 100644 libavformat/s337m.h
 create mode 100644 tests/ref/fate/s337m-wav

-- 
2.27.0.windows.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 v5 5/9] avformat/wavdec: s337m support

2020-10-19 Thread Nicolas Gaullier
Add s337m probing/reading similarly to spdif.
---
 libavformat/wavdec.c | 37 -
 1 file changed, 28 insertions(+), 9 deletions(-)

diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index d6ab0dde35..b755ab5514 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -43,6 +43,7 @@
 #include "riff.h"
 #include "w64.h"
 #include "spdif.h"
+#include "s337m.h"
 
 typedef struct WAVDemuxContext {
 const AVClass *class;
@@ -58,15 +59,17 @@ typedef struct WAVDemuxContext {
 int ignore_length;
 int max_size;
 int spdif;
+int s337m;
 int smv_cur_pt;
 int smv_given_first;
 int unaligned; // e.g. if an odd number of bytes ID3 tag was prepended
 int rifx; // RIFX: integer byte order for parameters is big endian
 } WAVDemuxContext;
 
-static void set_spdif(AVFormatContext *s, WAVDemuxContext *wav)
+static void set_spdif_s337m(AVFormatContext *s, WAVDemuxContext *wav)
 {
-if (CONFIG_SPDIF_DEMUXER && s->streams[0]->codecpar->codec_tag == 1) {
+AVCodecParameters *par = s->streams[0]->codecpar;
+if ((CONFIG_SPDIF_DEMUXER || CONFIG_S337M_DEMUXER) && par->codec_tag == 1) 
{
 enum AVCodecID codec;
 int len = 1<<16;
 int ret = ffio_ensure_seekback(s->pb, len);
@@ -79,10 +82,20 @@ static void set_spdif(AVFormatContext *s, WAVDemuxContext 
*wav)
 int64_t pos = avio_tell(s->pb);
 len = ret = avio_read(s->pb, buf, len);
 if (len >= 0) {
-ret = ff_spdif_probe(buf, len, &codec);
-if (ret > AVPROBE_SCORE_EXTENSION) {
-s->streams[0]->codecpar->codec_id = codec;
-wav->spdif = 1;
+if (CONFIG_SPDIF_DEMUXER) {
+ret = ff_spdif_probe(buf, len, &codec);
+if (ret > AVPROBE_SCORE_EXTENSION) {
+par->codec_id = codec;
+wav->spdif = 1;
+}
+}
+if (CONFIG_S337M_DEMUXER && !wav->spdif
+&& (par->codec_id == AV_CODEC_ID_PCM_S16LE || 
par->codec_id == AV_CODEC_ID_PCM_S24LE) && par->channels == 2) {
+ret = ff_s337m_probe(buf, len, &codec, 
par->bits_per_coded_sample);
+if (ret > AVPROBE_SCORE_EXTENSION) {
+par->codec_id = codec;
+wav->s337m = 1;
+}
 }
 }
 avio_seek(s->pb, pos, SEEK_SET);
@@ -91,7 +104,7 @@ static void set_spdif(AVFormatContext *s, WAVDemuxContext 
*wav)
 }
 
 if (ret < 0)
-av_log(s, AV_LOG_WARNING, "Cannot check for SPDIF\n");
+av_log(s, AV_LOG_WARNING, "Cannot check for SPDIF/S337M\n");
 }
 }
 
@@ -649,7 +662,7 @@ break_loop:
 ff_metadata_conv_ctx(s, NULL, wav_metadata_conv);
 ff_metadata_conv_ctx(s, NULL, ff_riff_info_conv);
 
-set_spdif(s, wav);
+set_spdif_s337m(s, wav);
 
 return 0;
 }
@@ -751,6 +764,10 @@ smv_out:
 wav->data_end = avio_tell(s->pb) + left;
 }
 
+if (CONFIG_S337M_DEMUXER && wav->s337m == 1) {
+size = FFMIN(S337M_MAX_OFFSET, left);
+ret  = ff_s337m_get_packet(s->pb, pkt, size, NULL, s, 
st->codecpar->bits_per_coded_sample);
+} else {
 size = wav->max_size;
 if (st->codecpar->block_align > 1) {
 if (size < st->codecpar->block_align)
@@ -759,6 +776,8 @@ smv_out:
 }
 size = FFMIN(size, left);
 ret  = av_get_packet(s->pb, pkt, size);
+}
+
 if (ret < 0)
 return ret;
 pkt->stream_index = 0;
@@ -947,7 +966,7 @@ static int w64_read_header(AVFormatContext *s)
 
 avio_seek(pb, data_ofs, SEEK_SET);
 
-set_spdif(s, wav);
+set_spdif_s337m(s, wav);
 
 return 0;
 }
-- 
2.27.0.windows.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 v5 7/9] avformat/wavdec: fix s337m/spdif probing beyond data_end

2020-10-19 Thread Nicolas Gaullier
---
 libavformat/wavdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index 5b287680e2..9f48ff067b 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -80,7 +80,7 @@ static void set_spdif_s337m(AVFormatContext *s, 
WAVDemuxContext *wav)
 ret = AVERROR(ENOMEM);
 } else {
 int64_t pos = avio_tell(s->pb);
-len = ret = avio_read(s->pb, buf, len);
+len = ret = avio_read(s->pb, buf, FFMIN(len, wav->data_end - 
pos));
 if (len >= 0) {
 if (CONFIG_SPDIF_DEMUXER) {
 ret = ff_spdif_probe(buf, len, &codec);
-- 
2.27.0.windows.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 v5 4/9] avformat/s337m: New ff_s337m_probe()

2020-10-19 Thread Nicolas Gaullier
Similar to ff_spdif_probe() with just an additional checking of
the bit resolution of the container as it may be 16 or 24 for s337m.
---
 libavformat/s337m.c | 32 
 libavformat/s337m.h | 16 
 2 files changed, 48 insertions(+)

diff --git a/libavformat/s337m.c b/libavformat/s337m.c
index 0a96b648ff..db444df8e2 100644
--- a/libavformat/s337m.c
+++ b/libavformat/s337m.c
@@ -134,6 +134,38 @@ static int s337m_probe(const AVProbeData *p)
 return 0;
 }
 
+int ff_s337m_probe(const uint8_t *buf, int size, enum AVCodecID *codec, int 
container_word_bits)
+{
+int pos = 0;
+int consecutive_codes = 0;
+
+if ( size < S337M_MIN_OFFSET)
+return 0;
+size = FFMIN(3 * S337M_MAX_OFFSET, size);
+if (container_word_bits != 16 && container_word_bits != 24)
+return AVERROR_INVALIDDATA;
+
+do {
+uint64_t state;
+int data_type, data_size, offset;
+while (pos < size - 12 && !buf[pos]) {
+pos++;
+}
+if (pos >= size - 12 || pos < S337M_PROBE_GUARDBAND_MIN_BYTES || pos % 
(container_word_bits == 16 ? 4 : 6))
+return 0;
+state = container_word_bits == 16 ? AV_RB32(buf + pos) : AV_RB48(buf + 
pos);
+if (!IS_LE_MARKER(state))
+return 0;
+data_type = container_word_bits == 16 ? AV_RL16(buf + pos + 4) : 
AV_RL24(buf + pos + 6);
+data_size = container_word_bits == 16 ? AV_RL16(buf + pos + 6) : 
AV_RL24(buf + pos + 9);
+if (s337m_get_offset_and_codec(NULL, state, data_type, data_size, 
container_word_bits, &offset, codec))
+return 0;
+pos = ++consecutive_codes * (offset + 4*(container_word_bits == 16 ? 4 
: 6));
+} while (consecutive_codes < 3);
+
+return AVPROBE_SCORE_MAX;
+}
+
 static int s337m_read_header(AVFormatContext *s)
 {
 s->ctx_flags |= AVFMTCTX_NOHEADER;
diff --git a/libavformat/s337m.h b/libavformat/s337m.h
index af2c4c85a3..94e79dce5d 100644
--- a/libavformat/s337m.h
+++ b/libavformat/s337m.h
@@ -21,6 +21,22 @@
 #ifndef AVFORMAT_S337M_H
 #define AVFORMAT_S337M_H
 
+#define S337M_MIN_OFFSET 1601*4
+#define S337M_MAX_OFFSET 2002*6
+
+#define S337M_PROBE_GUARDBAND_MIN_BYTES 0
+
+/**
+ * Detect s337m packets in a PCM_S16LE/S24LE stereo stream
+ * Requires 3 samples with enough (S337M_PROBE_GUARDBAND_MIN_BYTES) and clean 
(set to zero) guard band
+ * @param p_buf Buffer
+ * @param size Buffer size
+ * @param codec Returns AV_CODEC_ID_DOLBY_E upon successful probing
+ * @param container_word_bits 16 or 24
+ * @return = AVPROBE_SCORE
+ */
+int ff_s337m_probe(const uint8_t *p_buf, int size, enum AVCodecID *codec, int 
container_word_bits);
+
 /**
  * Read s337m packets in a PCM_S16LE/S24LE stereo stream
  * Returns the first inner packet found
-- 
2.27.0.windows.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 v5 3/9] avformat/s337m: Consider container bit resolution

2020-10-19 Thread Nicolas Gaullier
Prepare the support of s337m in muxers other than raw (ex: wav).
For example, this forbids reading 16 bits DolbyE stream from a 24 bit wav file.
---
 libavformat/s337m.c | 21 +++--
 libavformat/s337m.h |  3 ++-
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/libavformat/s337m.c b/libavformat/s337m.c
index 7f6eecb25c..0a96b648ff 100644
--- a/libavformat/s337m.c
+++ b/libavformat/s337m.c
@@ -34,7 +34,7 @@
 
 static int s337m_get_offset_and_codec(void *avc,
   uint64_t state,
-  int data_type, int data_size,
+  int data_type, int data_size, int 
container_word_bits,
   int *offset, enum AVCodecID *codec)
 {
 int word_bits;
@@ -55,6 +55,12 @@ static int s337m_get_offset_and_codec(void *avc,
 avpriv_report_missing_feature(avc, "Data type %#x in SMPTE 337M", 
data_type & 0x1F);
 return AVERROR_PATCHWELCOME;
 }
+if (container_word_bits &&
+!(container_word_bits == 16 && word_bits == 16) &&
+!(container_word_bits == 24 && word_bits == 20) &&
+!(container_word_bits == 24 && word_bits == 24)) {
+return AVERROR_INVALIDDATA;
+}
 
 if (codec)
 *codec = AV_CODEC_ID_DOLBY_E;
@@ -104,7 +110,7 @@ static int s337m_probe(const AVProbeData *p)
 data_size = AV_RL24(buf + 3);
 }
 
-if (s337m_get_offset_and_codec(NULL, state, data_type, data_size, 
&offset, NULL))
+if (s337m_get_offset_and_codec(NULL, state, data_type, data_size, 0, 
&offset, NULL))
 continue;
 
 i = IS_16LE_MARKER(state) ? 0 : IS_20LE_MARKER(state) ? 1 : 2;
@@ -142,13 +148,16 @@ static void bswap_buf24(uint8_t *data, int size)
 FFSWAP(uint8_t, data[0], data[2]);
 }
 
-int ff_s337m_get_packet(AVIOContext *pb, AVPacket *pkt, int size, enum 
AVCodecID *codec, void *avc)
+int ff_s337m_get_packet(AVIOContext *pb, AVPacket *pkt, int size, enum 
AVCodecID *codec, void *avc, int container_word_bits)
 {
 uint64_t state = 0;
 int ret, data_type, data_size, offset;
 int64_t pos, orig_pos = avio_tell(pb);
 
-while (!IS_LE_MARKER(state)) {
+if (container_word_bits && container_word_bits != 16 && 
container_word_bits != 24)
+return AVERROR_INVALIDDATA;
+while ((container_word_bits == 24 || !IS_16LE_MARKER(state))
+&& (container_word_bits == 16 || !IS_20LE_MARKER(state) && 
!IS_24LE_MARKER(state))) {
 state = (state << 8) | avio_r8(pb);
 if (avio_feof(pb))
 return AVERROR_EOF;
@@ -168,7 +177,7 @@ int ff_s337m_get_packet(AVIOContext *pb, AVPacket *pkt, int 
size, enum AVCodecID
 
 pos = avio_tell(pb);
 
-if ((ret = s337m_get_offset_and_codec(avc, state, data_type, data_size, 
&offset, codec)) < 0)
+if ((ret = s337m_get_offset_and_codec(avc, state, data_type, data_size, 
container_word_bits, &offset, codec)) < 0)
 return ret;
 
 if (ret = av_new_packet(pkt, FFMIN(offset, size - (pos - orig_pos))) < 0)
@@ -193,7 +202,7 @@ static int s337m_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 enum AVCodecID codec;
 int ret;
 
-if ((ret = ff_s337m_get_packet(s->pb, pkt, avio_size(s->pb), &codec, s)) < 
0)
+if ((ret = ff_s337m_get_packet(s->pb, pkt, avio_size(s->pb), &codec, s, 
0)) < 0)
 return ret;
 
 if (!s->nb_streams) {
diff --git a/libavformat/s337m.h b/libavformat/s337m.h
index f7bd0c16f6..af2c4c85a3 100644
--- a/libavformat/s337m.h
+++ b/libavformat/s337m.h
@@ -30,8 +30,9 @@
  * @param size Maximum IO read size available for reading at current position
  * @param codec Returns AV_CODEC_ID_DOLBY_E
  * @param avc For av_log
+ * @param container_word_bits 16,24, or 0 for autodetect
  * @return = 0 on success (an error is raised if no s337m was found)
  */
-int ff_s337m_get_packet(AVIOContext *pb, AVPacket *pkt, int size, enum 
AVCodecID *codec, void *avc);
+int ff_s337m_get_packet(AVIOContext *pb, AVPacket *pkt, int size, enum 
AVCodecID *codec, void *avc, int container_word_bits);
 
 #endif /* AVFORMAT_S337M_H */
-- 
2.27.0.windows.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 v5 6/9] avformat/wavdec.c: Reindent after last commit

2020-10-19 Thread Nicolas Gaullier
---
 libavformat/wavdec.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index b755ab5514..5b287680e2 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -768,14 +768,14 @@ smv_out:
 size = FFMIN(S337M_MAX_OFFSET, left);
 ret  = ff_s337m_get_packet(s->pb, pkt, size, NULL, s, 
st->codecpar->bits_per_coded_sample);
 } else {
-size = wav->max_size;
-if (st->codecpar->block_align > 1) {
-if (size < st->codecpar->block_align)
-size = st->codecpar->block_align;
-size = (size / st->codecpar->block_align) * st->codecpar->block_align;
-}
-size = FFMIN(size, left);
-ret  = av_get_packet(s->pb, pkt, size);
+size = wav->max_size;
+if (st->codecpar->block_align > 1) {
+if (size < st->codecpar->block_align)
+size = st->codecpar->block_align;
+size = (size / st->codecpar->block_align) * 
st->codecpar->block_align;
+}
+size = FFMIN(size, left);
+ret  = av_get_packet(s->pb, pkt, size);
 }
 
 if (ret < 0)
-- 
2.27.0.windows.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 v5 8/9] avformat/wavdec: Test s337m

2020-10-19 Thread Nicolas Gaullier
Test s337m probing in wav container.
Test dolby_e demuxing for 20 bits with program config '5.1+2'.
---
 tests/Makefile   |  1 +
 tests/fate/audio.mak |  3 +++
 tests/ref/fate/s337m-wav | 11 +++
 3 files changed, 15 insertions(+)
 create mode 100644 tests/ref/fate/s337m-wav

diff --git a/tests/Makefile b/tests/Makefile
index 7844901e53..97dbdab275 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -75,6 +75,7 @@ ENCDEC2 = $(call ALLYES, $(firstword $(1))_ENCODER $(lastword 
$(1))_DECODER  \
  $(firstword $(3))_MUXER   $(lastword $(3))_DEMUXER)
 
 DEMDEC  = $(call ALLYES, $(1)_DEMUXER $(2:%=%_DECODER))
+DEMDEMDEC = $(call ALLYES, $(1)_DEMUXER $(2)_DEMUXER $(3:%=%_DECODER))
 ENCMUX  = $(call ALLYES, $(1:%=%_ENCODER) $(2)_MUXER)
 
 DEMMUX  = $(call ALLYES, $(1)_DEMUXER $(2)_MUXER)
diff --git a/tests/fate/audio.mak b/tests/fate/audio.mak
index fd9905ca0a..f2e030789a 100644
--- a/tests/fate/audio.mak
+++ b/tests/fate/audio.mak
@@ -24,6 +24,9 @@ fate-dolby-e: CMD = pcm -i $(TARGET_SAMPLES)/dolby_e/16-11
 fate-dolby-e: CMP = oneoff
 fate-dolby-e: REF = $(SAMPLES)/dolby_e/16-11.pcm
 
+FATE_SAMPLES_AUDIO-$(call DEMDEMDEC, WAV, S337M, DOLBY_E) += fate-s337m-wav
+fate-s337m-wav: CMD = framecrc -i $(TARGET_SAMPLES)/dolby_e/512.wav -vn -c:a 
copy
+
 FATE_SAMPLES_AUDIO-$(call DEMDEC, DSS, DSS_SP) += fate-dss-lp fate-dss-sp
 fate-dss-lp: CMD = framecrc -i $(TARGET_SAMPLES)/dss/lp.dss -frames 30 -af 
aresample
 fate-dss-sp: CMD = framecrc -i $(TARGET_SAMPLES)/dss/sp.dss -frames 30
diff --git a/tests/ref/fate/s337m-wav b/tests/ref/fate/s337m-wav
new file mode 100644
index 00..16bfd06cae
--- /dev/null
+++ b/tests/ref/fate/s337m-wav
@@ -0,0 +1,11 @@
+#tb 0: 1/48000
+#media_type 0: audio
+#codec_id 0: dolby_e
+#sample_rate 0: 44800
+#channel_layout 0: 63f
+#channel_layout_name 0: 7.1
+0,  0,  0, 1920,11496, 0x05a9c147
+0,   1920,   1920, 1920,11496, 0x1d44d2b4
+0,   3840,   3840, 1920,11496, 0x4e078953
+0,   5760,   5760, 1920,11496, 0x1c73b1a1
+0,   7680,   7680, 1920,11262, 0xfa179fc8
-- 
2.27.0.windows.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 v5 9/9] avformat: Add probe_stream option

2020-10-19 Thread Nicolas Gaullier
Allows user to disable codec auto-detection.
Probe requests are ignored, including spdif/s337m submux detection in wavdec.
Note: this option is required to pass-through dolby_e data from a wav file.
---
 doc/formats.texi| 3 +++
 libavformat/avformat.h  | 9 -
 libavformat/options_table.h | 1 +
 libavformat/utils.c | 2 ++
 libavformat/version.h   | 2 +-
 libavformat/wavdec.c| 2 +-
 6 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/doc/formats.texi b/doc/formats.texi
index fc80ce1d2b..7de49503e8 100644
--- a/doc/formats.texi
+++ b/doc/formats.texi
@@ -31,6 +31,9 @@ latency. Must be an integer not lesser than 32. It is 500 
by default.
 Set the maximum number of buffered packets when probing a codec.
 Default is 2500 packets.
 
+@item probe_streams @var{bool} (@emph{input})
+Enable codec auto-detection if set to 1. Default is 1.
+
 @item packetsize @var{integer} (@emph{output})
 Set packet size.
 
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index c8c0b6c08d..a146daa21c 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1118,7 +1118,7 @@ typedef struct AVStream {
 /**
  * stream probing state
  * -1   -> probing finished
- *  0   -> no probing requested
+ *  0   -> no probing requested or request cancelled by probe_streams 
being set to 0
  * rest -> perform probing with request_probe being the minimum score to 
accept.
  */
 int request_probe;
@@ -1951,6 +1951,13 @@ typedef struct AVFormatContext {
  * - decoding: set by user
  */
 int max_probe_packets;
+
+/**
+ * Enable codec auto-detect.
+ * - encoding: unused
+ * - decoding: set by user
+ */
+int probe_streams;
 } AVFormatContext;
 
 #if FF_API_FORMAT_GET_SET
diff --git a/libavformat/options_table.h b/libavformat/options_table.h
index b4141564c8..1a75ad7f93 100644
--- a/libavformat/options_table.h
+++ b/libavformat/options_table.h
@@ -112,6 +112,7 @@ static const AVOption avformat_options[] = {
 {"max_streams", "maximum number of streams", OFFSET(max_streams), 
AV_OPT_TYPE_INT, { .i64 = 1000 }, 0, INT_MAX, D },
 {"skip_estimate_duration_from_pts", "skip duration calculation in 
estimate_timings_from_pts", OFFSET(skip_estimate_duration_from_pts), 
AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, D},
 {"max_probe_packets", "Maximum number of packets to probe a codec", 
OFFSET(max_probe_packets), AV_OPT_TYPE_INT, { .i64 = 2500 }, 0, INT_MAX, D },
+{"probe_streams", "codec auto-detection", OFFSET(probe_streams), 
AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, D},
 {NULL},
 };
 
diff --git a/libavformat/utils.c b/libavformat/utils.c
index a2e701ea1a..1c08081e21 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -675,6 +675,8 @@ static void force_codec_ids(AVFormatContext *s, AVStream 
*st)
 
 static int probe_codec(AVFormatContext *s, AVStream *st, const AVPacket *pkt)
 {
+if (!s->probe_streams)
+st->request_probe = 0;
 if (st->request_probe>0) {
 AVProbeData *pd = &st->probe_data;
 int end;
diff --git a/libavformat/version.h b/libavformat/version.h
index 40f84a220d..9bde0c37f9 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@
 // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
-#define LIBAVFORMAT_VERSION_MINOR  59
+#define LIBAVFORMAT_VERSION_MINOR  60
 #define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index 9f48ff067b..00cf8c9ab2 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -69,7 +69,7 @@ typedef struct WAVDemuxContext {
 static void set_spdif_s337m(AVFormatContext *s, WAVDemuxContext *wav)
 {
 AVCodecParameters *par = s->streams[0]->codecpar;
-if ((CONFIG_SPDIF_DEMUXER || CONFIG_S337M_DEMUXER) && par->codec_tag == 1) 
{
+if ((CONFIG_SPDIF_DEMUXER || CONFIG_S337M_DEMUXER) && par->codec_tag == 1 
&& s->probe_streams) {
 enum AVCodecID codec;
 int len = 1<<16;
 int ret = ffio_ensure_seekback(s->pb, len);
-- 
2.27.0.windows.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] libavformat/hls: add support for SAMPLE-AES decryption in HLS demuxer

2020-10-19 Thread Nachiket Tarate



From: ffmpeg-devel  on behalf of Steven Liu 

Sent: Monday, October 19, 2020 7:43 AM
To: FFmpeg development discussions and patches
Subject: Re: [FFmpeg-devel] [PATCH] libavformat/hls: add support for SAMPLE-AES 
decryption in HLS demuxer

Nachiket Tarate  于2020年10月18日周日 上午8:07写道:
>
> ___
> From: ffmpeg-devel  on behalf of Michael 
> Niedermayer 
> Sent: Thursday, October 15, 2020 11:35 PM
> To: FFmpeg development discussions and patches
> Subject: Re: [FFmpeg-devel] [PATCH] libavformat/hls: add support for 
> SAMPLE-AES decryption in HLS demuxer
>
> On Thu, Oct 15, 2020 at 10:15:13PM +0530, Nachiket Tarate wrote:
> > Apple HTTP Live Streaming Sample Encryption:
> >
> > https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption
> >
> > Signed-off-by: Nachiket Tarate 
> > ---
> >  libavformat/Makefile |   2 +-
> >  libavformat/hls.c|  93 ++-
> >  libavformat/hls_sample_aes.c | 497 +++
> >  libavformat/hls_sample_aes.h |  64 +
> >  libavformat/mpegts.c |  15 ++
> >  5 files changed, 657 insertions(+), 14 deletions(-)
> >  create mode 100644 libavformat/hls_sample_aes.c
> >  create mode 100644 libavformat/hls_sample_aes.h
>
> This seems to break fate (segfault)
> I guess patchwork will notice it too but as i already tested and noticed ...
>
> --- ./tests/ref/fate/segment-mp4-to-ts  2020-10-10 18:08:06.500253003 +0200
> +++ tests/data/fate/segment-mp4-to-ts   2020-10-15 20:03:24.586303460 +0200
> @@ -128,5 +128,3 @@
>  0, 428400, 435600, 3600,  156, 0xd2c3406c, F=0x0, S=1,   
>  1, 0x00e000e0
>  0, 432000, 439200, 3600,  330, 0x150d9b60, F=0x0, S=1,   
>  1, 0x00e000e0
>  0, 435600, 446400, 3600,  324, 0x558194ee, F=0x0, S=1,   
>  1, 0x00e000e0
> -0, 439200, 442800, 3600,  191, 0x108e54d1, F=0x0, S=1,   
>  1, 0x00e000e0
> -0, 442800, 45, 3600,  233, 0xac5b6486, F=0x0
> Test segment-mp4-to-ts failed. Look at tests/data/fate/segment-mp4-to-ts.err 
> for details.
> tests/Makefile:255: recipe for target 'fate-segment-mp4-to-ts' failed
> make: *** [fate-segment-mp4-to-ts] Error 139
>
>
> I ran FATE with samples again but I didn't get segfault. Can you please help 
> me to reproduce it ?

https://patchwork.ffmpeg.org/project/ffmpeg/patch/sg2pr01mb269339627c977c841e26b05df2...@sg2pr01mb2693.apcprd01.prod.exchangelabs.com/
fate failed message here.

TESTsegment-mp4-to-ts
--- 
/Users/liuqi/multimedia/upstream_ffmpeg/ffmpeg/tests/ref/fate/segment-mp4-to-ts
2020-10-19 09:24:15.0 +0800
+++ tests/data/fate/segment-mp4-to-ts 2020-10-19 10:09:43.0 +0800
@@ -128,5 +128,3 @@
 0, 428400, 435600, 3600,  156, 0xd2c3406c, F=0x0,
S=1,1, 0x00e000e0
 0, 432000, 439200, 3600,  330, 0x150d9b60, F=0x0,
S=1,1, 0x00e000e0
 0, 435600, 446400, 3600,  324, 0x558194ee, F=0x0,
S=1,1, 0x00e000e0
-0, 439200, 442800, 3600,  191, 0x108e54d1, F=0x0,
S=1,1, 0x00e000e0
-0, 442800, 45, 3600,  233, 0xac5b6486, F=0x0
Test segment-mp4-to-ts failed. Look at
tests/data/fate/segment-mp4-to-ts.err for details.
make: *** [fate-segment-mp4-to-ts] Error 134
(base) liuqi05:ufbuild liuqi$ history |grep make | tail -n 5
  318  make -j6
  319  make fate-rsync
  320  make fate

(base) liuqi05:ufbuild liuqi$ ./ffmpeg
ffmpeg version N-99556-gf7e2f090ed Copyright (c) 2000-2020 the FFmpeg developers
  built with Apple clang version 12.0.0 (clang-1200.0.32.2)
  configuration: --cc=clang --quiet --enable-htmlpages
--enable-libx264 --enable-libxml2 --enable-gpl --extra-ldflags='-O0
-g3 -fsanitize=address -Wno-error -fPIC -I/usr/local/include'
--extra-ldflags='-O0 -g3 -fsanitize=address -Wno-error -fPIC
-L/usr/local/lib' --enable-libfreetype --enable-fontconfig
--enable-libspeex --enable-libopus --enable-libzmq --enable-libx265
--enable-libass --enable-videotoolbox --disable-optimizations
--enable-audiotoolbox --enable-opengl --disable-stripping
--samples=../../fate-suite/


need use samples --samples=../../fate-suite/
and make fate-rsync

after above two step, you can make fate reproduce it.


Actually, I did

make fate-rsync SAMPLES=fate-suite/
make fate SAMPLES=fate-suite/

It is same.

But segmentation fault didn't occur while executing segment-mp4-to-ts.

Any idea ?

--
Best Regards,
Nachiket Tarate

___
ffmpeg-devel mailing list
ffmpeg-devel@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] libavformat/hls: add support for SAMPLE-AES decryption in HLS demuxer

2020-10-19 Thread Steven Liu


> 2020年10月19日 下午4:10,Nachiket Tarate  写道:
> 
> 
> 
> 
> From: ffmpeg-devel  on behalf of Steven Liu 
> 
> Sent: Monday, October 19, 2020 7:43 AM
> To: FFmpeg development discussions and patches
> Subject: Re: [FFmpeg-devel] [PATCH] libavformat/hls: add support for 
> SAMPLE-AES decryption in HLS demuxer
> 
> Nachiket Tarate  于2020年10月18日周日 上午8:07写道:
>> 
>> ___
>> From: ffmpeg-devel  on behalf of Michael 
>> Niedermayer 
>> Sent: Thursday, October 15, 2020 11:35 PM
>> To: FFmpeg development discussions and patches
>> Subject: Re: [FFmpeg-devel] [PATCH] libavformat/hls: add support for 
>> SAMPLE-AES decryption in HLS demuxer
>> 
>> On Thu, Oct 15, 2020 at 10:15:13PM +0530, Nachiket Tarate wrote:
>>> Apple HTTP Live Streaming Sample Encryption:
>>> 
>>> https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption
>>> 
>>> Signed-off-by: Nachiket Tarate 
>>> ---
>>> libavformat/Makefile |   2 +-
>>> libavformat/hls.c|  93 ++-
>>> libavformat/hls_sample_aes.c | 497 +++
>>> libavformat/hls_sample_aes.h |  64 +
>>> libavformat/mpegts.c |  15 ++
>>> 5 files changed, 657 insertions(+), 14 deletions(-)
>>> create mode 100644 libavformat/hls_sample_aes.c
>>> create mode 100644 libavformat/hls_sample_aes.h
>> 
>> This seems to break fate (segfault)
>> I guess patchwork will notice it too but as i already tested and noticed ...
>> 
>> --- ./tests/ref/fate/segment-mp4-to-ts  2020-10-10 18:08:06.500253003 +0200
>> +++ tests/data/fate/segment-mp4-to-ts   2020-10-15 20:03:24.586303460 +0200
>> @@ -128,5 +128,3 @@
>> 0, 428400, 435600, 3600,  156, 0xd2c3406c, F=0x0, S=1,   
>>  1, 0x00e000e0
>> 0, 432000, 439200, 3600,  330, 0x150d9b60, F=0x0, S=1,   
>>  1, 0x00e000e0
>> 0, 435600, 446400, 3600,  324, 0x558194ee, F=0x0, S=1,   
>>  1, 0x00e000e0
>> -0, 439200, 442800, 3600,  191, 0x108e54d1, F=0x0, S=1,  
>>   1, 0x00e000e0
>> -0, 442800, 45, 3600,  233, 0xac5b6486, F=0x0
>> Test segment-mp4-to-ts failed. Look at tests/data/fate/segment-mp4-to-ts.err 
>> for details.
>> tests/Makefile:255: recipe for target 'fate-segment-mp4-to-ts' failed
>> make: *** [fate-segment-mp4-to-ts] Error 139
>> 
>> 
>> I ran FATE with samples again but I didn't get segfault. Can you please help 
>> me to reproduce it ?
> 
> https://patchwork.ffmpeg.org/project/ffmpeg/patch/sg2pr01mb269339627c977c841e26b05df2...@sg2pr01mb2693.apcprd01.prod.exchangelabs.com/
> fate failed message here.
> 
> TESTsegment-mp4-to-ts
> --- 
> /Users/liuqi/multimedia/upstream_ffmpeg/ffmpeg/tests/ref/fate/segment-mp4-to-ts
> 2020-10-19 09:24:15.0 +0800
> +++ tests/data/fate/segment-mp4-to-ts 2020-10-19 10:09:43.0 +0800
> @@ -128,5 +128,3 @@
> 0, 428400, 435600, 3600,  156, 0xd2c3406c, F=0x0,
> S=1,1, 0x00e000e0
> 0, 432000, 439200, 3600,  330, 0x150d9b60, F=0x0,
> S=1,1, 0x00e000e0
> 0, 435600, 446400, 3600,  324, 0x558194ee, F=0x0,
> S=1,1, 0x00e000e0
> -0, 439200, 442800, 3600,  191, 0x108e54d1, F=0x0,
> S=1,1, 0x00e000e0
> -0, 442800, 45, 3600,  233, 0xac5b6486, F=0x0
> Test segment-mp4-to-ts failed. Look at
> tests/data/fate/segment-mp4-to-ts.err for details.
> make: *** [fate-segment-mp4-to-ts] Error 134
> (base) liuqi05:ufbuild liuqi$ history |grep make | tail -n 5
>  318  make -j6
>  319  make fate-rsync
>  320  make fate
> 
> (base) liuqi05:ufbuild liuqi$ ./ffmpeg
> ffmpeg version N-99556-gf7e2f090ed Copyright (c) 2000-2020 the FFmpeg 
> developers
>  built with Apple clang version 12.0.0 (clang-1200.0.32.2)
>  configuration: --cc=clang --quiet --enable-htmlpages
> --enable-libx264 --enable-libxml2 --enable-gpl --extra-ldflags='-O0
> -g3 -fsanitize=address -Wno-error -fPIC -I/usr/local/include'
> --extra-ldflags='-O0 -g3 -fsanitize=address -Wno-error -fPIC
> -L/usr/local/lib' --enable-libfreetype --enable-fontconfig
> --enable-libspeex --enable-libopus --enable-libzmq --enable-libx265
> --enable-libass --enable-videotoolbox --disable-optimizations
> --enable-audiotoolbox --enable-opengl --disable-stripping
> --samples=../../fate-suite/
> 
> 
> need use samples --samples=../../fate-suite/
> and make fate-rsync
> 
> after above two step, you can make fate reproduce it.
> 
> 
> Actually, I did
> 
> make fate-rsync SAMPLES=fate-suite/
> make fate SAMPLES=fate-suite/
> 
> It is same.
> 
> But segmentation fault didn't occur while executing segment-mp4-to-ts.
What your configure options?

> 
> Any idea ?
> 
> --
> Best Regards,
> Nachiket Tarate
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-

Re: [FFmpeg-devel] [PATCH 0/5] Fix adpcm_swf support in WAV.

2020-10-19 Thread Zane van Iperen


On 16/10/20 4:22 pm, Zane van Iperen wrote:
> 
> adpcm_swf support in WAV is completely broken. block_align isn't set 
> correctly, so
> the demuxer gives incorrect packets to the decoder. The encoder doesn't 
> provide a
> value for block_align, so it's set to 1.
> 
> All of this has no bearing on (de)muxing to FLV.
> 
> See https://trac.ffmpeg.org/ticket/5829.
> 

Ping 2. I will apply this tomorrow (+FATE fix).

Zane

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

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

[FFmpeg-devel] [PATCH 5/5] avcodec/on2avc: Remove redundant code for freeing

2020-10-19 Thread Andreas Rheinhardt
This decoder has the FF_CODEC_CAP_INIT_CLEANUP set.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/on2avc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/on2avc.c b/libavcodec/on2avc.c
index 3b566e1e4b..2453343be9 100644
--- a/libavcodec/on2avc.c
+++ b/libavcodec/on2avc.c
@@ -978,7 +978,6 @@ static av_cold int on2avc_decode_init(AVCodecContext *avctx)
 return 0;
 vlc_fail:
 av_log(avctx, AV_LOG_ERROR, "Cannot init VLC\n");
-on2avc_free_vlcs(c);
 return AVERROR(ENOMEM);
 }
 
-- 
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 4/5] avcodec/on2avc: Avoid indirection when calling float dsp function

2020-10-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/on2avc.c | 35 ++-
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/libavcodec/on2avc.c b/libavcodec/on2avc.c
index 625e733ca3..3b566e1e4b 100644
--- a/libavcodec/on2avc.c
+++ b/libavcodec/on2avc.c
@@ -46,7 +46,8 @@ enum WindowTypes {
 
 typedef struct On2AVCContext {
 AVCodecContext *avctx;
-AVFloatDSPContext *fdsp;
+void (*vector_fmul_window)(float *dst, const float *src0,
+   const float *src1, const float *win, int len);
 FFTContext mdct, mdct_half, mdct_small;
 FFTContext fft128, fft256, fft512, fft1024;
 void (*wtf)(struct On2AVCContext *ctx, float *out, float *in, int size);
@@ -720,7 +721,7 @@ static int on2avc_reconstruct_channel_ext(On2AVCContext *c, 
AVFrame *dst, int of
 }
 
 memcpy(out, saved, 448 * sizeof(float));
-c->fdsp->vector_fmul_window(wout, saved + 448, buf, c->short_win, 64);
+c->vector_fmul_window(wout, saved + 448, buf, c->short_win, 64);
 memcpy(wout + 128,  buf + 64, 448 * sizeof(float));
 memcpy(saved,   buf + 512,448 * sizeof(float));
 memcpy(saved + 448, buf + 7*128 + 64,  64 * sizeof(float));
@@ -756,20 +757,20 @@ static int on2avc_reconstruct_channel(On2AVCContext *c, 
int channel,
  c->prev_window_type == WINDOW_TYPE_LONG_STOP) &&
 (c->window_type == WINDOW_TYPE_LONG ||
  c->window_type == WINDOW_TYPE_LONG_START)) {
-c->fdsp->vector_fmul_window(out, saved, buf, c->long_win, 512);
+c->vector_fmul_window(out, saved, buf, c->long_win, 512);
 } else {
 float *wout = out + 448;
 memcpy(out, saved, 448 * sizeof(float));
 
 if (c->window_type == WINDOW_TYPE_8SHORT) {
-c->fdsp->vector_fmul_window(wout + 0*128, saved + 448,  buf + 
0*128, c->short_win, 64);
-c->fdsp->vector_fmul_window(wout + 1*128, buf + 0*128 + 64, buf + 
1*128, c->short_win, 64);
-c->fdsp->vector_fmul_window(wout + 2*128, buf + 1*128 + 64, buf + 
2*128, c->short_win, 64);
-c->fdsp->vector_fmul_window(wout + 3*128, buf + 2*128 + 64, buf + 
3*128, c->short_win, 64);
-c->fdsp->vector_fmul_window(temp, buf + 3*128 + 64, buf + 
4*128, c->short_win, 64);
+c->vector_fmul_window(wout + 0*128, saved + 448,  buf + 0*128, 
c->short_win, 64);
+c->vector_fmul_window(wout + 1*128, buf + 0*128 + 64, buf + 1*128, 
c->short_win, 64);
+c->vector_fmul_window(wout + 2*128, buf + 1*128 + 64, buf + 2*128, 
c->short_win, 64);
+c->vector_fmul_window(wout + 3*128, buf + 2*128 + 64, buf + 3*128, 
c->short_win, 64);
+c->vector_fmul_window(temp, buf + 3*128 + 64, buf + 4*128, 
c->short_win, 64);
 memcpy(wout + 4*128, temp, 64 * sizeof(float));
 } else {
-c->fdsp->vector_fmul_window(wout, saved + 448, buf, c->short_win, 
64);
+c->vector_fmul_window(wout, saved + 448, buf, c->short_win, 64);
 memcpy(wout + 128, buf + 64, 448 * sizeof(float));
 }
 }
@@ -778,9 +779,9 @@ static int on2avc_reconstruct_channel(On2AVCContext *c, int 
channel,
 switch (c->window_type) {
 case WINDOW_TYPE_8SHORT:
 memcpy(saved,   temp + 64, 64 * sizeof(float));
-c->fdsp->vector_fmul_window(saved + 64,  buf + 4*128 + 64, buf + 
5*128, c->short_win, 64);
-c->fdsp->vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 
6*128, c->short_win, 64);
-c->fdsp->vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 
7*128, c->short_win, 64);
+c->vector_fmul_window(saved + 64,  buf + 4*128 + 64, buf + 5*128, 
c->short_win, 64);
+c->vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, 
c->short_win, 64);
+c->vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, 
c->short_win, 64);
 memcpy(saved + 448, buf + 7*128 + 64,  64 * sizeof(float));
 break;
 case WINDOW_TYPE_LONG_START:
@@ -906,6 +907,7 @@ static av_cold void on2avc_free_vlcs(On2AVCContext *c)
 static av_cold int on2avc_decode_init(AVCodecContext *avctx)
 {
 On2AVCContext *c = avctx->priv_data;
+AVFloatDSPContext *fdsp;
 int i;
 
 if (avctx->channels > 2U) {
@@ -952,9 +954,11 @@ static av_cold int on2avc_decode_init(AVCodecContext 
*avctx)
 ff_fft_init(&c->fft256,  7, 0);
 ff_fft_init(&c->fft512,  8, 1);
 ff_fft_init(&c->fft1024, 9, 1);
-c->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
-if (!c->fdsp)
+fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
+if (!fdsp)
 return AVERROR(ENOMEM);
+c->vector_fmul_window = fdsp->vector_fmul_window;
+av_free(fdsp);
 
 if (init_vlc(&c->scale_diff, 9, ON2AVC_SCALE_DIFFS,
  ff_on2avc_scale_diff_bits,  1, 1,
@@ -975,7 +979,6 @@ static av_cold int on2avc_

Re: [FFmpeg-devel] [PATCHv2] Document community process

2020-10-19 Thread Thilo Borgmann
Am 12.10.20 um 09:35 schrieb Jean-Baptiste Kempf:
> General Assembly + Main Elections
> ---
>  doc/dev_community/community.md | 80 ++
>  1 file changed, 80 insertions(+)
>  create mode 100644 doc/dev_community/community.md

pushed. Thx!

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

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

Re: [FFmpeg-devel] [PATCH 4/5] avcodec/on2avc: Avoid indirection when calling float dsp function

2020-10-19 Thread Anton Khirnov
Quoting Andreas Rheinhardt (2020-10-19 13:07:05)
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/on2avc.c | 35 ++-
>  1 file changed, 18 insertions(+), 17 deletions(-)
> 

I don't quite see the point of this. I cannot imagine it is measurably
faster, the memory savings should also be negligible.
And strictly speaking, it is API abuse as the functions are tied to the
context. It is conceivable that they could be compiled at runtime and
freeing the context would invalidate them.

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

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

Re: [FFmpeg-devel] [PATCH v3] Unbreak av_malloc_max(0) API/ABI

2020-10-19 Thread Joakim Tjernlund
On Sat, 2020-10-17 at 19:52 +0200, Andreas Rheinhardt wrote:
> Joakim Tjernlund:
> > On Fri, 2020-10-16 at 01:38 +0200, Andreas Rheinhardt wrote:
> > > CAUTION: This email originated from outside of the organization. Do not 
> > > click links or open attachments unless you recognize the sender and know 
> > > the content is safe.
> > > 
> > > 
> > > Joakim Tjernlund:
> > > > From 
> > > > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugs.chromium.org%2Fp%2Fchromium%2Fissues%2Fdetail%3Fid%3D1095962&data=04%7C01%7Cjoakim.tjernlund%40infinera.com%7C96ae5fc7646d4c878d4508d872c57b85%7C285643de5f5b4b03a1530ae2dc8aaf77%7C1%7C1%7C637385539798829478%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=T7f337WCuCELJ6dn8imCFI%2FU6NQEnBeYQlbt0xV8Pvc%3D&reserved=0
> > > > 
> > > > This seems to be caused by the custom handling of "av_max_alloc(0)" in
> > > > Chromium's ffmpeg fork to mean unlimited (added in [1]).
> > > > 
> > > > Upstream ffmpeg doesn't treat 0 as a special value; versions before 4.3 
> > > > seemingly worked
> > > > because 32 was subtracted from max_alloc_size (set to 0 by Chromium) 
> > > > resulting in an
> > > > integer underflow, making the effective limit be SIZE_MAX - 31.
> > > > 
> > > > Now that the above underflow doesn't happen, the tab just crashes. The 
> > > > upstream change
> > > > for no longer subtracting 32 from max_alloc_size was included in ffmpeg 
> > > > 4.3. [2]
> > > > 
> > > > [1] 
> > > > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fchromium-review.googlesource.com%2Fc%2Fchromium%2Fthird_party%2Fffmpeg%2F%2B%2F73563&data=04%7C01%7Cjoakim.tjernlund%40infinera.com%7C96ae5fc7646d4c878d4508d872c57b85%7C285643de5f5b4b03a1530ae2dc8aaf77%7C1%7C1%7C637385539798829478%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=naVuSqIeUOCQqtm9D3SdOTT2FVoEkbqSAm7cXujILBM%3D&reserved=0
> > > > [2] 
> > > > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FFFmpeg%2FFFmpeg%2Fcommit%2F731c77589841&data=04%7C01%7Cjoakim.tjernlund%40infinera.com%7C96ae5fc7646d4c878d4508d872c57b85%7C285643de5f5b4b03a1530ae2dc8aaf77%7C1%7C1%7C637385539798829478%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=rpeQH9PlbJlftXyfriVaMH%2BGtIkc6QNsls4KN%2B9Eeo0%3D&reserved=0
> > > > ---
> > > > 
> > > > Restore av_malloc_max(0) to MAX_INT fixing MS Teams, Discord older 
> > > > chromium etc.
> > > > 
> > > > Signed-off-by: Joakim Tjernlund 
> > > > ---
> > > > 
> > > >  v2: Cover the full API range 0-31
> > > > 
> > > >  v3: Closer compat with < 4.3 ffmpeg
> > > > 
> > > >  libavutil/mem.c | 2 ++
> > > >  1 file changed, 2 insertions(+)
> > > > 
> > > > diff --git a/libavutil/mem.c b/libavutil/mem.c
> > > > index cfb6d8a..bd1fb85 100644
> > > > --- a/libavutil/mem.c
> > > > +++ b/libavutil/mem.c
> > > > @@ -71,6 +71,8 @@ void  free(void *ptr);
> > > >  static size_t max_alloc_size= INT_MAX;
> > > > 
> > > >  void av_max_alloc(size_t max){
> > > > +if (max < 32)
> > > > +max = SIZE_MAX - max; /* be compatible to older(< 4.3) 
> > > > versions */
> > > >  max_alloc_size = max;
> > > >  }
> > > > 
> > > > 
> > > For full compatibility it should be SIZE_MAX - 32 + max.
> > > 
> > OK, v4 sent.
> > 
> > >  But why don't you go the way of fixing the broken apps?
> > 
> > Because they are binary apps, in my case from Microsoft.
> > Their MS Teams is based on a Chromium/Electron framework that(I hope) will
> > be updated at some point.
> > 
> And have you already reported this issue to them?

I tried that once earlier and didn't find howto. One would think MS would have 
some Teams presence on
github. Turns out they do but not for reporting bugs on Teams itself.
Anyhow, I got in touch with a MS dev. that may be able to help out. I do 
suspect this buried far
down in electron framework and it will take time until all layers has been 
update and released.

Now about the v4 patch, what is the verdict ?

 Jocke
___
ffmpeg-devel mailing list
ffmpeg-devel@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/5] avcodec/adpcm_swf: set block_align when encoding

2020-10-19 Thread Anton Khirnov
Quoting Zane van Iperen (2020-10-16 08:22:41)
> Allows it to be muxed to WAVs.
> 
> Signed-off-by: Zane van Iperen 
> ---
>  libavcodec/adpcmenc.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)

Looks sane

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

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

Re: [FFmpeg-devel] [PATCH 4/5] avcodec/adpcmenc: cosmetics

2020-10-19 Thread Anton Khirnov
Quoting Zane van Iperen (2020-10-16 08:22:50)
> Signed-off-by: Zane van Iperen 
> ---
>  libavcodec/adpcmenc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Sure

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

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

Re: [FFmpeg-devel] [PATCH 0/5] Fix adpcm_swf support in WAV.

2020-10-19 Thread Anton Khirnov
Quoting Zane van Iperen (2020-10-18 04:13:57)
> 
> 
> On 16/10/20 4:22 pm, Zane van Iperen wrote:
> > 
> > adpcm_swf support in WAV is completely broken. block_align isn't set 
> > correctly, so
> > the demuxer gives incorrect packets to the decoder. The encoder doesn't 
> > provide a
> > value for block_align, so it's set to 1.
> > 
> > All of this has no bearing on (de)muxing to FLV.
> > 
> > See https://trac.ffmpeg.org/ticket/5829.
> > 
> 
> Ping. I'd really like another set of eyes on this, especially because 
> I'm tweaking
> the behaviour of the WAV muxer.

I am no expert on the intricacies of wav, but it looks simple enough.
I'm just wondering if ff_put_wav_header() is not a better place for the
check.

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

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

[FFmpeg-devel] [PATCH 5/7] avformat/utils: Move +1 to avoid overflow

2020-10-19 Thread Michael Niedermayer
Fixes: signed integer overflow: 9223372036854775807 + 1 cannot be represented 
in type 'long'
Fixes: Timeout
Fixes: 
26434/clusterfuzz-testcase-minimized-ffmpeg_dem_MV_fuzzer-5752845451919360

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

diff --git a/libavformat/utils.c b/libavformat/utils.c
index a2e701ea1a..49ccc91b82 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -253,7 +253,7 @@ int ffio_limit(AVIOContext *s, int size)
 remaining= FFMAX(remaining, 0);
 }
 
-if (s->maxsize>= 0 && remaining+1 < size) {
+if (s->maxsize>= 0 && remaining < size - (int64_t)1) {
 av_log(NULL, remaining ? AV_LOG_ERROR : AV_LOG_DEBUG, "Truncating 
packet of size %d to %"PRId64"\n", size, remaining+1);
 size = remaining+1;
 }
-- 
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/7] avcodec/vp9dsp_template: Fix some overflows in iadst8_1d()

2020-10-19 Thread Michael Niedermayer
Fixes: signed integer overflow: 190587 * 11585 cannot be represented in type 
'int'
Fixes: 
26407/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP9_fuzzer-5086348408782848

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

diff --git a/libavcodec/vp9dsp_template.c b/libavcodec/vp9dsp_template.c
index bfabe63536..3acf94c583 100644
--- a/libavcodec/vp9dsp_template.c
+++ b/libavcodec/vp9dsp_template.c
@@ -1275,10 +1275,10 @@ static av_always_inline void iadst8_1d(const dctcoef 
*in, ptrdiff_t stride,
 t6 =   (dctint)((1U << 13) + t4a - t6a) >> 14;
 t7 =   (dctint)((1U << 13) + t5a - t7a) >> 14;
 
-out[3] = -(((t2 + t3) * 11585 + (1 << 13)) >> 14);
-out[4] =   ((t2 - t3) * 11585 + (1 << 13)) >> 14;
-out[2] =   ((t6 + t7) * 11585 + (1 << 13)) >> 14;
-out[5] = -(((t6 - t7) * 11585 + (1 << 13)) >> 14);
+out[3] = -((dctint)((t2 + t3) * 11585U + (1 << 13)) >> 14);
+out[4] =   (dctint)((t2 - t3) * 11585U + (1 << 13)) >> 14;
+out[2] =   (dctint)((t6 + t7) * 11585U + (1 << 13)) >> 14;
+out[5] = -((dctint)((t6 - t7) * 11585U + (1 << 13)) >> 14);
 }
 
 itxfm_wrap(8, 5)
-- 
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/7] avcodec/fits: Check bscale

2020-10-19 Thread Michael Niedermayer
Fixes: division by 0
Fixes: 
26208/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FITS_fuzzer-6270472117026816

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

diff --git a/libavcodec/fits.c b/libavcodec/fits.c
index ad73ab70de..25c33e06c8 100644
--- a/libavcodec/fits.c
+++ b/libavcodec/fits.c
@@ -187,6 +187,8 @@ int avpriv_fits_header_parse_line(void *avcl, FITSHeader 
*header, const uint8_t
 header->blank = t;
 header->blank_found = 1;
 } else if (!strcmp(keyword, "BSCALE") && sscanf(value, "%lf", &d) == 
1) {
+if (d <= 0)
+return AVERROR_INVALIDDATA;
 header->bscale = d;
 } else if (!strcmp(keyword, "BZERO") && sscanf(value, "%lf", &d) == 1) 
{
 header->bzero = d;
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH 3/7] avutil/common: Implement av_sat_add64_c() with fewer branches

2020-10-19 Thread Michael Niedermayer
No benchmark because this is not used in any speed relevant pathes nor is it
used where __builtin_add_overflow is available.
So I do not know how to realistically benchmark it.

Signed-off-by: Michael Niedermayer 
---
 libavutil/common.h | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/libavutil/common.h b/libavutil/common.h
index 92b721a59c..a48c0648f8 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -303,11 +303,10 @@ static av_always_inline int64_t av_sat_add64_c(int64_t a, 
int64_t b) {
 int64_t tmp;
 return !__builtin_add_overflow(a, b, &tmp) ? tmp : (tmp < 0 ? INT64_MAX : 
INT64_MIN);
 #else
-if (b >= 0 && a >= INT64_MAX - b)
-return INT64_MAX;
-if (b <= 0 && a <= INT64_MIN - b)
-return INT64_MIN;
-return a + b;
+int64_t s = a+(uint64_t)b;
+if ((int64_t)(a^b | ~s^b) >= 0)
+return b < 0 ? INT64_MIN : INT64_MAX;
+return s;
 #endif
 }
 
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH 7/7] avformat/nistspheredec: Check bps

2020-10-19 Thread Michael Niedermayer
Fixes: left shift of 90 by 3 places cannot be represented in type 'int'
Fixes: 
26437/clusterfuzz-testcase-minimized-ffmpeg_dem_NISTSPHERE_fuzzer-4886896091856896

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

diff --git a/libavformat/nistspheredec.c b/libavformat/nistspheredec.c
index 3ef3843d5e..079369929f 100644
--- a/libavformat/nistspheredec.c
+++ b/libavformat/nistspheredec.c
@@ -109,6 +109,8 @@ static int nist_read_header(AVFormatContext *s)
 sscanf(buffer, "%*s %*s %"SCNd64, &st->duration);
 } else if (!memcmp(buffer, "sample_n_bytes", 14)) {
 sscanf(buffer, "%*s %*s %d", &bps);
+if (bps > INT_MAX/8U)
+return AVERROR_INVALIDDATA;
 } else if (!memcmp(buffer, "sample_rate", 11)) {
 sscanf(buffer, "%*s %*s %d", &st->codecpar->sample_rate);
 } else if (!memcmp(buffer, "sample_sig_bits", 15)) {
-- 
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 4/7] avformat/sbgdec: Check for timestamp overflow in parse_time_sequence()

2020-10-19 Thread Michael Niedermayer
Fixes: signed integer overflow: 345801500790256 + 642568637304000 
cannot be represented in type 'long'
Fixes: 
26430/clusterfuzz-testcase-minimized-ffmpeg_dem_BRSTM_fuzzer-5761175004119040

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

diff --git a/libavformat/sbgdec.c b/libavformat/sbgdec.c
index c11244ef3d..4d6ae7abc5 100644
--- a/libavformat/sbgdec.c
+++ b/libavformat/sbgdec.c
@@ -538,6 +538,9 @@ static int parse_time_sequence(struct sbg_parser *p, int 
inblock)
 return AVERROR_INVALIDDATA;
 }
 ts.type = p->current_time.type;
+
+if (av_sat_add64(p->current_time.t, rel_ts) != p->current_time.t + 
(uint64_t)rel_ts)
+return AVERROR_INVALIDDATA;
 ts.t= p->current_time.t + rel_ts;
 r = parse_fade(p, &fade);
 if (r < 0)
-- 
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 6/7] avformat/ifv: Check that total frames do not overflow

2020-10-19 Thread Michael Niedermayer
Fixes: Infinite loop
Fixes: 
26392/clusterfuzz-testcase-minimized-ffmpeg_dem_GIF_fuzzer-5713658237419520
Fixes: 
26435/clusterfuzz-testcase-minimized-ffmpeg_dem_SUBVIEWER_fuzzer-6548251853193216

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

diff --git a/libavformat/ifv.c b/libavformat/ifv.c
index f95e9b0e52..4e904fa828 100644
--- a/libavformat/ifv.c
+++ b/libavformat/ifv.c
@@ -210,6 +210,7 @@ static int ifv_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 }
 
 if (!ev) {
+uint64_t vframes, aframes;
 if (ifv->is_audio_present && !ea) {
 /*read new video and audio indexes*/
 
@@ -217,8 +218,12 @@ static int ifv_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 ifv->next_audio_index = ifv->total_aframes;
 
 avio_skip(s->pb, 0x1c);
-ifv->total_vframes += avio_rl32(s->pb);
-ifv->total_aframes += avio_rl32(s->pb);
+vframes = ifv->total_vframes + (uint64_t)avio_rl32(s->pb);
+aframes = ifv->total_aframes + (uint64_t)avio_rl32(s->pb);
+if (vframes > INT_MAX || aframes > INT_MAX)
+return AVERROR_INVALIDDATA;
+ifv->total_vframes = vframes;
+ifv->total_aframes = aframes;
 avio_skip(s->pb, 0xc);
 
 if (avio_feof(s->pb))
@@ -240,7 +245,10 @@ static int ifv_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 ifv->next_video_index = ifv->total_vframes;
 
 avio_skip(s->pb, 0x1c);
-ifv->total_vframes += avio_rl32(s->pb);
+vframes = ifv->total_vframes + (uint64_t)avio_rl32(s->pb);
+if (vframes > INT_MAX)
+return AVERROR_INVALIDDATA;
+ifv->total_vframes = vframes;
 avio_skip(s->pb, 0x10);
 
 if (avio_feof(s->pb))
-- 
2.17.1

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

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

Re: [FFmpeg-devel] [PATCH 4/7] avformat/sbgdec: Check for timestamp overflow in parse_time_sequence()

2020-10-19 Thread Nicolas George
Michael Niedermayer (12020-10-19):
> Fixes: signed integer overflow: 345801500790256 + 642568637304000 
> cannot be represented in type 'long'
> Fixes: 
> 26430/clusterfuzz-testcase-minimized-ffmpeg_dem_BRSTM_fuzzer-5761175004119040
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/sbgdec.c | 3 +++
>  1 file changed, 3 insertions(+)

No objection.

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 2/3] avcodec/hevcpred_template: Fix diagonal chroma availability in 4:2:2 edge case in intra_pred

2020-10-19 Thread Anton Khirnov
Quoting Michael Niedermayer (2020-10-16 13:30:28)
> Fixes: pixel decode issue.ts
> Fixes: raw frame.hevc

This is useless when there is no indication as to where to get these
files.

If those are valid files that we did not handle properly before then we
need new tests to cover this case.

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

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

Re: [FFmpeg-devel] [PATCH 2/3] ffmpeg.c: refine picking default video stream

2020-10-19 Thread Anton Khirnov
Quoting James Almer (2020-10-14 19:26:51)
> On 10/14/2020 2:09 PM, Michael Niedermayer wrote:
> > On Wed, Oct 14, 2020 at 10:53:10AM +0200, Anton Khirnov wrote:
> >> Use a floating-point score value to take into account bitrate, when
> >> multiple streams with the same resolution are present.
> >>
> >> Stop accessing private AVStream.codec_info_nb_frames field, as the
> >> sample in question
> >> http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket2639/Thailand-Wave.wmv
> >> is now handled by the above change.
> >> ---
> >>  fftools/ffmpeg_opt.c | 23 ++-
> >>  1 file changed, 18 insertions(+), 5 deletions(-)
> > 
> > Breaks:
> > -i tickets/4496/08_lect_01.rm  file.avi
> > 
> > as refernce here is what ffmpeg shows about the streams:
> > Stream #0:0: Audio: sipr (sipr / 0x72706973), 8000 Hz, mono, flt, 4 kb/s
> > Stream #0:1: Audio: sipr (sipr / 0x72706973), 8000 Hz, mono, flt, 8 kb/s
> > Stream #0:2: Audio: cook (cook / 0x6B6F6F63), 22050 Hz, mono, fltp, 4 
> > kb/s
> > Stream #0:3: Audio: sipr (sipr / 0x72706973), 8000 Hz, mono, flt, 4 kb/s
> > Stream #0:4: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 252 
> > kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
> > Stream #0:5: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 252 
> > kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
> > Stream #0:6: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 252 
> > kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
> > Stream #0:7: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 252 
> > kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
> > Stream #0:8: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 252 
> > kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
> > Stream #0:9: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 252 
> > kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
> > Stream #0:10: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 252 
> > kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
> > Stream #0:11: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 252 
> > kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
> > Stream #0:12: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 252 
> > kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
> > Stream #0:13: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 252 
> > kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
> > 
> > sample should be here according to the ticket:
> > https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket2152/
> > 
> > I dont think you can reliably detect non empty streams from the header alone
> > in every case.
> > 
> > thx
> 
> This whole chunk of code is apparently done because
> av_find_best_stream() can't be used here (The list of input streams is
> in a custom struct InputStream instead of an AVFormatContext).
> codec_info_nb_frames is evidently needed to detect non-empty streams, so
> either making it or a replacement public or hand crafting a dummy
> AVFormatContext with the input streams then using av_find_best_stream()
> are two options for this.
> 
> I personally think the latter option is a good solution.
> av_find_best_stream() does not seem to care about its contents beyond
> nb_streams and the streams list.

That seems immensely hacky to me tbh.

I am also not very comfortable with making codec_info_nb_frames
officially public, as that hardcodes internal workings of
find_stream_info() into the public API, making it harder to change
later.

More generally, I do not think it is reasonable to demand that the
automatic mapping code in ffmpeg.c magically choose the best stream for
all pathological cases. Files with empty streams are IMO pathological,
and the user can always override the mapping manually.

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

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

Re: [FFmpeg-devel] [PATCH 2/3] ffmpeg.c: refine picking default video stream

2020-10-19 Thread Anton Khirnov
Quoting Gyan Doshi (2020-10-14 20:43:59)
> 
> 
> On 14-10-2020 02:23 pm, Anton Khirnov wrote:
> > Use a floating-point score value to take into account bitrate, when
> > multiple streams with the same resolution are present.
> >
> > Stop accessing private AVStream.codec_info_nb_frames field, as the
> > sample in question
> > http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket2639/Thailand-Wave.wmv
> > is now handled by the above change.
> > ---
> >   fftools/ffmpeg_opt.c | 23 ++-
> >   1 file changed, 18 insertions(+), 5 deletions(-)
> >
> > diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
> > index a0d1b06f2d..afef23919c 100644
> > --- a/fftools/ffmpeg_opt.c
> > +++ b/fftools/ffmpeg_opt.c
> > @@ -19,6 +19,7 @@
> >* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
> > 02110-1301 USA
> >*/
> >   
> > +#include 
> >   #include 
> >   
> >   #include "ffmpeg.h"
> > @@ -2208,15 +2209,27 @@ static int open_output_file(OptionsContext *o, 
> > const char *filename)
> >   char *subtitle_codec_name = NULL;
> >   /* pick the "best" stream of each type */
> >   
> > -/* video: highest resolution */
> > +/* video */
> >   if (!o->video_disable && av_guess_codec(oc->oformat, NULL, 
> > filename, NULL, AVMEDIA_TYPE_VIDEO) != AV_CODEC_ID_NONE) {
> > -int best_score = 0, idx = -1;
> > +double best_score = 0.0;
> > +int idx = -1;
> >   int qcr = avformat_query_codec(oc->oformat, 
> > oc->oformat->video_codec, 0);
> >   for (i = 0; i < nb_input_streams; i++) {
> > -int score;
> > +double score;
> >   ist = input_streams[i];
> > -score = ist->st->codecpar->width * 
> > ist->st->codecpar->height + 1*!!ist->st->codec_info_nb_frames
> > -   + 500*!!(ist->st->disposition & 
> > AV_DISPOSITION_DEFAULT);
> > +
> > +/* base score is just the area in pixels */
> > +score = (double)ist->st->codecpar->width * 
> > ist->st->codecpar->height;
> > +/* add a fractional part favoring higher bitrate among 
> > same-area streams */
> > +if (ist->st->codecpar->bit_rate) {
> > +const double bitrate_max = 100e6; // cap at 100Mb/s
> > +const double bitrate = 
> > FFMIN(ist->st->codecpar->bit_rate, bitrate_max - 1.0);
> > +score += bitrate / bitrate_max;
> > +}
> 
> > +/* default streams get max score */
> > +if (ist->st->disposition & AV_DISPOSITION_DEFAULT)
> > +score = DBL_MAX;
> 
> This is actually a mistake that shouldn't ever been committed.
> 
> A default disposition only has relevance among companion video streams 
> from the same input. It does and should not apply to inter-input 
> comparisons.
> Only a handful of demuxers set disposition. Default audio selection is 
> already broken with respect to its documented behaviour for, I believe, 
> a couple of years now.
> 
> The saner way is to select best stream from each input and then select 
> from that shortlist without considering disposition.

Watches pelcome. I am not bringing about world peace here, I just want
ffmpeg.c to be a well-behaved user application and stop accessing lavf
internals.

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

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

Re: [FFmpeg-devel] [PATCH 2/3] ffmpeg.c: refine picking default video stream

2020-10-19 Thread Jean-Baptiste Kempf
On Mon, 19 Oct 2020, at 16:44, Anton Khirnov wrote:
> > The saner way is to select best stream from each input and then select 
> > from that shortlist without considering disposition.
> 
> Watches pelcome. I am not bringing about world peace here, I just want
> ffmpeg.c to be a well-behaved user application and stop accessing lavf
> internals.

Yes, please, please, please.

-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
___
ffmpeg-devel mailing list
ffmpeg-devel@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/6 v2] avdevice/alldevices: stop using deprecated linked list API

2020-10-19 Thread Anton Khirnov
Quoting James Almer (2020-10-14 16:19:00)
> Signed-off-by: James Almer 
> ---
>  libavdevice/alldevices.c | 72 
>  libavdevice/avdevice.c   | 46 -
>  2 files changed, 72 insertions(+), 46 deletions(-)

Looks ok

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

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

Re: [FFmpeg-devel] [PATCH] libavformat/hls: add support for SAMPLE-AES decryption in HLS demuxer

2020-10-19 Thread Nachiket Tarate



From: ffmpeg-devel  on behalf of Steven Liu 

Sent: Monday, October 19, 2020 3:17 PM
To: FFmpeg development discussions and patches
Cc: Steven Liu
Subject: Re: [FFmpeg-devel] [PATCH] libavformat/hls: add support for SAMPLE-AES 
decryption in HLS demuxer



> 2020年10月19日 下午4:10,Nachiket Tarate  写道:
>
>
>
> 
> From: ffmpeg-devel  on behalf of Steven Liu 
> 
> Sent: Monday, October 19, 2020 7:43 AM
> To: FFmpeg development discussions and patches
> Subject: Re: [FFmpeg-devel] [PATCH] libavformat/hls: add support for 
> SAMPLE-AES decryption in HLS demuxer
>
> Nachiket Tarate  于2020年10月18日周日 上午8:07写道:
>>
>> ___
>> From: ffmpeg-devel  on behalf of Michael 
>> Niedermayer 
>> Sent: Thursday, October 15, 2020 11:35 PM
>> To: FFmpeg development discussions and patches
>> Subject: Re: [FFmpeg-devel] [PATCH] libavformat/hls: add support for 
>> SAMPLE-AES decryption in HLS demuxer
>>
>> On Thu, Oct 15, 2020 at 10:15:13PM +0530, Nachiket Tarate wrote:
>>> Apple HTTP Live Streaming Sample Encryption:
>>>
>>> https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption
>>>
>>> Signed-off-by: Nachiket Tarate 
>>> ---
>>> libavformat/Makefile |   2 +-
>>> libavformat/hls.c|  93 ++-
>>> libavformat/hls_sample_aes.c | 497 +++
>>> libavformat/hls_sample_aes.h |  64 +
>>> libavformat/mpegts.c |  15 ++
>>> 5 files changed, 657 insertions(+), 14 deletions(-)
>>> create mode 100644 libavformat/hls_sample_aes.c
>>> create mode 100644 libavformat/hls_sample_aes.h
>>
>> This seems to break fate (segfault)
>> I guess patchwork will notice it too but as i already tested and noticed ...
>>
>> --- ./tests/ref/fate/segment-mp4-to-ts  2020-10-10 18:08:06.500253003 +0200
>> +++ tests/data/fate/segment-mp4-to-ts   2020-10-15 20:03:24.586303460 +0200
>> @@ -128,5 +128,3 @@
>> 0, 428400, 435600, 3600,  156, 0xd2c3406c, F=0x0, S=1,   
>>  1, 0x00e000e0
>> 0, 432000, 439200, 3600,  330, 0x150d9b60, F=0x0, S=1,   
>>  1, 0x00e000e0
>> 0, 435600, 446400, 3600,  324, 0x558194ee, F=0x0, S=1,   
>>  1, 0x00e000e0
>> -0, 439200, 442800, 3600,  191, 0x108e54d1, F=0x0, S=1,  
>>   1, 0x00e000e0
>> -0, 442800, 45, 3600,  233, 0xac5b6486, F=0x0
>> Test segment-mp4-to-ts failed. Look at tests/data/fate/segment-mp4-to-ts.err 
>> for details.
>> tests/Makefile:255: recipe for target 'fate-segment-mp4-to-ts' failed
>> make: *** [fate-segment-mp4-to-ts] Error 139
>>
>>
>> I ran FATE with samples again but I didn't get segfault. Can you please help 
>> me to reproduce it ?
>
> https://patchwork.ffmpeg.org/project/ffmpeg/patch/sg2pr01mb269339627c977c841e26b05df2...@sg2pr01mb2693.apcprd01.prod.exchangelabs.com/
> fate failed message here.
>
> TESTsegment-mp4-to-ts
> --- 
> /Users/liuqi/multimedia/upstream_ffmpeg/ffmpeg/tests/ref/fate/segment-mp4-to-ts
> 2020-10-19 09:24:15.0 +0800
> +++ tests/data/fate/segment-mp4-to-ts 2020-10-19 10:09:43.0 +0800
> @@ -128,5 +128,3 @@
> 0, 428400, 435600, 3600,  156, 0xd2c3406c, F=0x0,
> S=1,1, 0x00e000e0
> 0, 432000, 439200, 3600,  330, 0x150d9b60, F=0x0,
> S=1,1, 0x00e000e0
> 0, 435600, 446400, 3600,  324, 0x558194ee, F=0x0,
> S=1,1, 0x00e000e0
> -0, 439200, 442800, 3600,  191, 0x108e54d1, F=0x0,
> S=1,1, 0x00e000e0
> -0, 442800, 45, 3600,  233, 0xac5b6486, F=0x0
> Test segment-mp4-to-ts failed. Look at
> tests/data/fate/segment-mp4-to-ts.err for details.
> make: *** [fate-segment-mp4-to-ts] Error 134
> (base) liuqi05:ufbuild liuqi$ history |grep make | tail -n 5
>  318  make -j6
>  319  make fate-rsync
>  320  make fate
>
> (base) liuqi05:ufbuild liuqi$ ./ffmpeg
> ffmpeg version N-99556-gf7e2f090ed Copyright (c) 2000-2020 the FFmpeg 
> developers
>  built with Apple clang version 12.0.0 (clang-1200.0.32.2)
>  configuration: --cc=clang --quiet --enable-htmlpages
> --enable-libx264 --enable-libxml2 --enable-gpl --extra-ldflags='-O0
> -g3 -fsanitize=address -Wno-error -fPIC -I/usr/local/include'
> --extra-ldflags='-O0 -g3 -fsanitize=address -Wno-error -fPIC
> -L/usr/local/lib' --enable-libfreetype --enable-fontconfig
> --enable-libspeex --enable-libopus --enable-libzmq --enable-libx265
> --enable-libass --enable-videotoolbox --disable-optimizations
> --enable-audiotoolbox --enable-opengl --disable-stripping
> --samples=../../fate-suite/
>
>
> need use samples --samples=../../fate-suite/
> and make fate-rsync
>
> after above two step, you can make fate reproduce it.
>
>
> Actually, I did
>
> make fate-rsync SAMPLES=fate-suite/
> make fate SAMPLES=fate-suite/
>
> It is same.
>
> But segmentation fault didn't occur while executing segment-mp4-to-ts.

What your configure options

Re: [FFmpeg-devel] [PATCH 4/6] avformat/options: use the iterate API in format_child_class_next()

2020-10-19 Thread Anton Khirnov
Quoting James Almer (2020-10-10 05:45:27)
> Signed-off-by: James Almer 
> ---
>  libavformat/options.c | 23 +--
>  1 file changed, 13 insertions(+), 10 deletions(-)
> 

Looks good

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

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

Re: [FFmpeg-devel] [PATCH 5/6] tools/target_dem_fuzzer: switch to the iterate API

2020-10-19 Thread Anton Khirnov
Quoting James Almer (2020-10-10 05:45:52)
> Signed-off-by: James Almer 
> ---
>  tools/target_dem_fuzzer.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)

LGTM

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

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

Re: [FFmpeg-devel] [PATCH 6/6] tools/target_dec_fuzzer: remove calls to avcodec_register*()

2020-10-19 Thread Anton Khirnov
Quoting James Almer (2020-10-10 05:46:17)
> They are no-ops.
> 
> Signed-off-by: James Almer 
> ---
>  tools/target_dec_fuzzer.c | 3 ---
>  1 file changed, 3 deletions(-)

Not exactly no-ops yet, but looks ok anyway.

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

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

Re: [FFmpeg-devel] [PATCH 6/6] tools/target_dec_fuzzer: remove calls to avcodec_register*()

2020-10-19 Thread James Almer
On 10/19/2020 11:59 AM, Anton Khirnov wrote:
> Quoting James Almer (2020-10-10 05:46:17)
>> They are no-ops.
>>
>> Signed-off-by: James Almer 
>> ---
>>  tools/target_dec_fuzzer.c | 3 ---
>>  1 file changed, 3 deletions(-)
> 
> Not exactly no-ops yet, but looks ok anyway.

Yeah, i wrote that comment thinking about their effect in this tool,
since nothing needs the AVCodec->next pointers initialized.

I'll remove it and apply patches 1, 4, 5 and 6. Thanks.
___
ffmpeg-devel mailing list
ffmpeg-devel@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] avformat/mvi: Check count for overflow

2020-10-19 Thread Michael Niedermayer
Fixes: left shift of 21378748 by 10 places cannot be represented in type 'int'
Fixes: 
26449/clusterfuzz-testcase-minimized-ffmpeg_dem_MVI_fuzzer-5680463374712832

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

diff --git a/libavformat/mvi.c b/libavformat/mvi.c
index ff5c08bf51..06c9cfe3f0 100644
--- a/libavformat/mvi.c
+++ b/libavformat/mvi.c
@@ -123,6 +123,8 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
 count = (mvi->audio_size_counter + mvi->audio_frame_size + 512) >> 
MVI_FRAC_BITS;
 if (count > mvi->audio_size_left)
 count = mvi->audio_size_left;
+if ((int64_t)count << MVI_FRAC_BITS > INT_MAX)
+return AVERROR_INVALIDDATA;
 if ((ret = av_get_packet(pb, pkt, count)) < 0)
 return ret;
 pkt->stream_index = MVI_AUDIO_STREAM_INDEX;
-- 
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/genh: Check block_align

2020-10-19 Thread Michael Niedermayer
Fixes: infinite loop
Fixes: 
26440/clusterfuzz-testcase-minimized-ffmpeg_dem_GENH_fuzzer-5632134020333568

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

diff --git a/libavformat/genh.c b/libavformat/genh.c
index 61adf49964..544d063aa4 100644
--- a/libavformat/genh.c
+++ b/libavformat/genh.c
@@ -144,6 +144,9 @@ static int genh_read_header(AVFormatContext *s)
 }
 }
 
+if (st->codecpar->block_align <= 0)
+return AVERROR_INVALIDDATA;
+
 avio_skip(s->pb, start_offset - avio_tell(s->pb));
 
 avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH 3/4] avformat/jacosubdec: Use 64bit inside get_shift()

2020-10-19 Thread Michael Niedermayer
Fixes: signed integer overflow: 1 * 30 cannot be represented in type 
'int'
Fixes: 
26448/clusterfuzz-testcase-minimized-ffmpeg_dem_JACOSUB_fuzzer-5638440374501376

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

diff --git a/libavformat/jacosubdec.c b/libavformat/jacosubdec.c
index 3414eb3938..e70ceeaafd 100644
--- a/libavformat/jacosubdec.c
+++ b/libavformat/jacosubdec.c
@@ -136,6 +136,7 @@ static int get_shift(int timeres, const char *buf)
 {
 int sign = 1;
 int a = 0, b = 0, c = 0, d = 0;
+int64_t ret;
 #define SSEP "%*1[.:]"
 int n = sscanf(buf, "%d"SSEP"%d"SSEP"%d"SSEP"%d", &a, &b, &c, &d);
 #undef SSEP
@@ -145,13 +146,16 @@ static int get_shift(int timeres, const char *buf)
 a = FFABS(a);
 }
 
+ret = 0;
 switch (n) {
-case 4: return sign * ((a*3600 + b*60 + c) * timeres + d);
-case 3: return sign * (( a*60 + b) * timeres + c);
-case 2: return sign * ((a) * timeres + b);
+case 4: ret = sign * (((int64_t)a*3600 + b*60 + c) * timeres + d);
+case 3: ret = sign * (( (int64_t)a*60 + b) * timeres + c);
+case 2: ret = sign * (((int64_t)a) * timeres + b);
 }
+if ((int)ret != ret)
+ret = 0;
 
-return 0;
+return ret;
 }
 
 static int jacosub_read_header(AVFormatContext *s)
-- 
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/wtvdec: Check dir_length

2020-10-19 Thread Michael Niedermayer
Fixes: Infinite loop
Fixes: 
26445/clusterfuzz-testcase-minimized-ffmpeg_dem_WTV_fuzzer-5125558331244544

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

diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
index 83f510b92f..77908e6392 100644
--- a/libavformat/wtvdec.c
+++ b/libavformat/wtvdec.c
@@ -273,6 +273,11 @@ static AVIOContext * wtvfile_open2(AVFormatContext *s, 
const uint8_t *buf, int b
"bad filename length, remaining directory entries 
ignored\n");
 break;
 }
+if (dir_length == 0) {
+av_log(s, AV_LOG_ERROR,
+   "bad dir length, remaining directory entries ignored\n");
+break;
+}
 if (48 + (int64_t)name_size > buf_end - buf) {
 av_log(s, AV_LOG_ERROR, "filename exceeds buffer size; remaining 
directory entries ignored\n");
 break;
-- 
2.17.1

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

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

Re: [FFmpeg-devel] [PATCH] avfilter: add vf_overlay_cuda

2020-10-19 Thread Maximiliano Lira Del Canto

Hi Yaroslav


First of all, thanks for your wonderful work!, works as described, I 
started to use it in another Open source project "Opencast".


Well I started to make some tests and I wrote a more comprehensive 
example in Stack Overflow of it:


https://stackoverflow.com/questions/63471028/how-to-use-the-ffmpeg-overlay-cuda-filter-to-make-a-sbs-video


Because of my exhaustive testing, I found some bugs with the filter:

- You can't use images as a lower source.

- If you try to generate an still mp4 movie (For example a blank color 
background and try to overlay it, gives you an error.


- Transparent PNG gives blurry image with artifacts when is use for an 
overlay.



Another error, that I think it comes from the GPU used. If I use a 
latest generation Quadro or Geforce RTX, the filter works without 
problems. but if I use a more older model (Quadro K6000, Kepler), it 
gives you this error:


   [overlay_cuda @ 0x72356c0] cu->cuModuleLoadData(&ctx->cu_module,
   vf_overlay_cuda_ptx) failed -> CUDA_ERROR_INVALID_PTX: a PTX JIT
   compilation failed
   [Parsed_overlay_cuda_6 @ 0x72355c0] Failed to configure output pad
   on Parsed_overlay_cuda_6

I think this goes to an issue with the Compute Capability version 
supported. The K6000 only supports up to version 3.5



If you want, I can make a more complete report on the FFMPEG bug tracker.


Best Regards

Max.



___
ffmpeg-devel mailing list
ffmpeg-devel@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] [PATCHv2] Document community process

2020-10-19 Thread Michael Niedermayer
On Mon, Oct 12, 2020 at 09:35:57AM +0200, Jean-Baptiste Kempf wrote:
> General Assembly + Main Elections
> ---
>  doc/dev_community/community.md | 80 ++
>  1 file changed, 80 insertions(+)
>  create mode 100644 doc/dev_community/community.md
> 
> diff --git a/doc/dev_community/community.md b/doc/dev_community/community.md
> new file mode 100644
> index 00..2ce3aa0b30
> --- /dev/null
> +++ b/doc/dev_community/community.md
> @@ -0,0 +1,80 @@
> +# FFmpeg project
> +
> +## Organisation
> +
> +The FFmpeg project is organized through a community working on global 
> consensus.
> +
> +Decisions are taken by the ensemble of active members, through voting and
> +are aided by two committees.
> +
> +## General Assembly
> +
> +The ensemble of active members is called the General Assembly (GA).
> +
> +The General Assembly is sovereign and legitimate for all its decisions
> +regarding the FFmpeg project.
> +
> +The General Assembly is made up of active contributors.
> +
> +Contributors are considered "active contributors" if they have pushed more
> +than 20 patches in the last 36 months in the main FFmpeg repository, or
> +if they have been voted in by the GA.
> +
> +Additional members are added to the General Assembly through a vote after
> +proposal by a member of the General Assembly.
> +They are part of the GA for two years, after which they need a confirmation 
> by
> +the GA.
> +
> +## Voting
> +

> +Voting is done using a ranked voting system, currently running on 
> https://vote.ffmpeg.org/ .

I think Voting should be defined more precissely


thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable


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] [PATCHv2] Document community process

2020-10-19 Thread Jean-Baptiste Kempf
Yo,

On Mon, 19 Oct 2020, at 19:02, Michael Niedermayer wrote:
> > +## Voting
> > +
> 
> > +Voting is done using a ranked voting system, currently running on 
> > https://vote.ffmpeg.org/ .
> 
> I think Voting should be defined more precissely

That's a good point. What would like to see here? The algo used? The software 
used?

--
Jean-Baptiste Kempf -  President
+33 672 704 734
 

___
ffmpeg-devel mailing list
ffmpeg-devel@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 3/6] ffmpeg: move A/V non-streamcopy initialization to a later point

2020-10-19 Thread Jan Ekström
On Sat, Oct 17, 2020 at 3:32 AM Jan Ekström  wrote:
>
> On Fri, Oct 16, 2020, 22:47 Michael Niedermayer  
> wrote:
>>
>> On Fri, Oct 16, 2020 at 04:16:46PM +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(-)
>>
>> This breaks:
>>
>> ./ffmpeg -ss 30.0 -i ~/tickets/1745/1745-Sample.mkv -f vob -c:a copy  -f 
>> framecrc -
>
>
> I put the first attempt at a fix for this as a separate commit in this patch 
> set since it clearly is separate from this change by itself, as well as if 
> someone would give a better recommendation on how to handle it, it would be 
> simpler to adjust.
>

In case it was not obvious from this reply, my initial attempt to
improve this handling would be
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20201016131649.4361-7-jee...@gmail.com/
.

As noted, I decided that this would be another change in the behavior
and this at least until there's been some review/discussion about it,
it should be a separate change from this one. That is why this test
case fails with just this patch of this patch set applied. I did not
specifically ignore it because you were nice enough to point at it
previously.

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/4] avformat/wtvdec: Check dir_length

2020-10-19 Thread Peter Ross
On Mon, Oct 19, 2020 at 05:59:53PM +0200, Michael Niedermayer wrote:
> Fixes: Infinite loop
> Fixes: 
> 26445/clusterfuzz-testcase-minimized-ffmpeg_dem_WTV_fuzzer-5125558331244544
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/wtvdec.c | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
> index 83f510b92f..77908e6392 100644
> --- a/libavformat/wtvdec.c
> +++ b/libavformat/wtvdec.c
> @@ -273,6 +273,11 @@ static AVIOContext * wtvfile_open2(AVFormatContext *s, 
> const uint8_t *buf, int b
> "bad filename length, remaining directory entries 
> ignored\n");
>  break;
>  }
> +if (dir_length == 0) {
> +av_log(s, AV_LOG_ERROR,
> +   "bad dir length, remaining directory entries ignored\n");
> +break;
> +}
>  if (48 + (int64_t)name_size > buf_end - buf) {
>  av_log(s, AV_LOG_ERROR, "filename exceeds buffer size; remaining 
> directory entries ignored\n");
>  break;
> -- 

looks good

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


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] [PATCHv2] Document community process

2020-10-19 Thread Michael Niedermayer
On Mon, Oct 19, 2020 at 07:22:48PM +0200, Jean-Baptiste Kempf wrote:
> Yo,
> 
> On Mon, 19 Oct 2020, at 19:02, Michael Niedermayer wrote:
> > > +## Voting
> > > +
> > 
> > > +Voting is done using a ranked voting system, currently running on 
> > > https://vote.ffmpeg.org/ .
> > 
> > I think Voting should be defined more precissely
> 
> That's a good point. What would like to see here? The algo used? The software 
> used?

I dont know what is best.

What is the goal having this information there serves ?
I think there are 3 or 4 levels/classes of information that could be provided
at highest level, listing the properties of the vote system

A.
(this is not intended to be an exhaustive list but rather list the points
 which actually change the real world behavior of the vote)
For example does it conform to to the condorcet criterion for single winner
elections
Or with multiwinner elections, is there some sort of proportionality, that is
can 51% of voters control all seats or can any 20% of voters generally 
control one of 5 seats.

B.
at the next lower level, the academic algorithm could be referenced, this 
would give enough information to reproduce most votes but ties and corner
cases might not be fully defined

C.
nipickingly precissely define the algorithm so that any list of ballots
produces a clear and reproducable result or failure, tie resolution rules, ...

D.
Refer to an actual implementation

Possible goals:
understanding on the readers side of the general vote algorithm behavior, not 
leaving it a black box.
reproducability
avoiding disputes
keeping the text simple
allowing changes if things turn out to go wrong in some way

thx

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

The real ebay dictionary, page 1
"Used only once"- "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."


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 v2 2/6] avcodec/adpcm_swf: support decoding multiple fixed-sized blocks at once

2020-10-19 Thread Zane van Iperen
For incoming packets from WAV.

Signed-off-by: Zane van Iperen 
---
 libavcodec/adpcm.c | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index f7da3dcf89..fef1e6714c 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -880,7 +880,7 @@ static int get_nb_samples(AVCodecContext *avctx, 
GetByteContext *gb,
 }
 case AV_CODEC_ID_ADPCM_SWF:
 {
-int buf_bits   = buf_size * 8 - 2;
+int buf_bits   = (avctx->block_align ? avctx->block_align : 
buf_size) * 8 - 2;
 int nbits  = (bytestream2_get_byte(gb) >> 6) + 2;
 int block_hdr_size = 22 * ch;
 int block_size = block_hdr_size + nbits * ch * 4095;
@@ -889,6 +889,9 @@ static int get_nb_samples(AVCodecContext *avctx, 
GetByteContext *gb,
 nb_samples = nblocks * 4096;
 if (bits_left >= block_hdr_size)
 nb_samples += 1 + (bits_left - block_hdr_size) / (nbits * ch);
+
+if (avctx->block_align)
+nb_samples *= buf_size / avctx->block_align;
 break;
 }
 case AV_CODEC_ID_ADPCM_THP:
@@ -1767,9 +1770,17 @@ static int adpcm_decode_frame(AVCodecContext *avctx, 
void *data,
 }
 break;
 case AV_CODEC_ID_ADPCM_SWF:
-adpcm_swf_decode(avctx, buf, buf_size, samples);
+{
+const int nb_blocks  = avctx->block_align ? avpkt->size / 
avctx->block_align : 1;
+const int block_size = avctx->block_align ? avctx->block_align : 
avpkt->size;
+
+for (int block = 0; block < nb_blocks; block++) {
+adpcm_swf_decode(avctx, buf + block * block_size, block_size, 
samples);
+samples += nb_samples / nb_blocks;
+}
 bytestream2_seek(&gb, 0, SEEK_END);
 break;
+}
 case AV_CODEC_ID_ADPCM_YAMAHA:
 for (n = nb_samples >> (1 - st); n > 0; n--) {
 int v = bytestream2_get_byteu(&gb);
-- 
2.28.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 v2 0/6] Fix adpcm_swf support in WAV.

2020-10-19 Thread Zane van Iperen
adpcm_swf support in WAV is completely broken. block_align isn't set correctly, 
so
the demuxer gives incorrect packets to the decoder. The encoder doesn't provide 
a
value for block_align, so it's set to 1.

All of this has no bearing on (de)muxing to FLV.

See https://trac.ffmpeg.org/ticket/5829.

v2: [1]
  - Fix FATE failure
  - Move block_size check into ff_put_wav_header()
  - Allow a custom block size now that [2] is merged.

[1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-October/271262.html
[2]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-October/271001.html

Zane van Iperen (6):
  avformat/riff: prevent muxing adpcm_swf with a variable block size
  avcodec/adpcm_swf: support decoding multiple fixed-sized blocks at
once
  avcodec/adpcm_swf: set block_align when encoding
  avcodec/adpcm_swf: support custom block size for encoding
  avcodec/adpcmenc: cosmetics
  fate: add test for adpcm_swf in wav

 libavcodec/adpcm.c | 15 +--
 libavcodec/adpcmenc.c  |  9 -
 libavformat/riffenc.c  |  6 ++
 tests/fate/acodec.mak  |  4 
 tests/ref/acodec/adpcm-swf-wav |  4 
 5 files changed, 31 insertions(+), 7 deletions(-)
 create mode 100644 tests/ref/acodec/adpcm-swf-wav

-- 
2.28.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 v2 1/6] avformat/riff: prevent muxing adpcm_swf with a variable block size

2020-10-19 Thread Zane van Iperen
Prefer to error than to create a broken file. Closes ticket #5829.

Effectively disables remuxing adpcm_swf from flv -> wav.

Signed-off-by: Zane van Iperen 
---
 libavformat/riffenc.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c
index 04a21fcffa..33e0b6fc0a 100644
--- a/libavformat/riffenc.c
+++ b/libavformat/riffenc.c
@@ -65,6 +65,12 @@ int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb,
 if (!par->codec_tag || par->codec_tag > 0x)
 return -1;
 
+if (par->codec_id == AV_CODEC_ID_ADPCM_SWF && par->block_align == 0) {
+av_log(s, AV_LOG_ERROR, "%s can only be written to WAVE with a 
constant frame size\n",
+   avcodec_get_name(s->streams[0]->codecpar->codec_id));
+return AVERROR(EINVAL);
+}
+
 /* We use the known constant frame size for the codec if known, otherwise
  * fall back on using AVCodecContext.frame_size, which is not as reliable
  * for indicating packet duration. */
-- 
2.28.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 v2 4/6] avcodec/adpcm_swf: support custom block size for encoding

2020-10-19 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavcodec/adpcmenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index 5b485e7d26..42b83c2b48 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -153,7 +153,7 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
"22050 or 44100\n");
 return AVERROR(EINVAL);
 }
-avctx->frame_size = 512 * (avctx->sample_rate / 11025);
+avctx->frame_size  = (s->block_size / 2) * (avctx->sample_rate / 
11025);
 avctx->block_align = (2 + avctx->channels * (22 + 4 * 
(avctx->frame_size - 1)) + 7) / 8;
 break;
 case AV_CODEC_ID_ADPCM_IMA_SSI:
-- 
2.28.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 v2 3/6] avcodec/adpcm_swf: set block_align when encoding

2020-10-19 Thread Zane van Iperen
Allows it to be muxed to WAVs.

Signed-off-by: Zane van Iperen 
---
 libavcodec/adpcmenc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index b2be83b84e..5b485e7d26 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -154,6 +154,7 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
 return AVERROR(EINVAL);
 }
 avctx->frame_size = 512 * (avctx->sample_rate / 11025);
+avctx->block_align = (2 + avctx->channels * (22 + 4 * 
(avctx->frame_size - 1)) + 7) / 8;
 break;
 case AV_CODEC_ID_ADPCM_IMA_SSI:
 avctx->frame_size  = s->block_size * 2 / avctx->channels;
@@ -550,9 +551,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 samples_p = (int16_t **)frame->extended_data;
 st = avctx->channels == 2;
 
-if (avctx->codec_id == AV_CODEC_ID_ADPCM_SWF)
-pkt_size = (2 + avctx->channels * (22 + 4 * (frame->nb_samples - 1)) + 
7) / 8;
-else if (avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_SSI ||
+if (avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_SSI ||
  avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_APM)
 pkt_size = (frame->nb_samples * avctx->channels) / 2;
 else
-- 
2.28.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 v2 6/6] fate: add test for adpcm_swf in wav

2020-10-19 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 tests/fate/acodec.mak  | 4 
 tests/ref/acodec/adpcm-swf-wav | 4 
 2 files changed, 8 insertions(+)
 create mode 100644 tests/ref/acodec/adpcm-swf-wav

diff --git a/tests/fate/acodec.mak b/tests/fate/acodec.mak
index 50932095dc..8ac71b1b27 100644
--- a/tests/fate/acodec.mak
+++ b/tests/fate/acodec.mak
@@ -52,6 +52,7 @@ FATE_ACODEC_ADPCM-$(call ENCDEC, ADPCM_IMA_SSI, KVAG) += 
ima_ssi
 FATE_ACODEC_ADPCM-$(call ENCDEC, ADPCM_IMA_WAV, WAV)  += ima_wav
 FATE_ACODEC_ADPCM-$(call ENCDEC, ADPCM_MS,  WAV)  += ms
 FATE_ACODEC_ADPCM-$(call ENCDEC, ADPCM_SWF, FLV)  += swf
+FATE_ACODEC_ADPCM-$(call ENCDEC, ADPCM_SWF, WAV)  += swf-wav
 FATE_ACODEC_ADPCM-$(call ENCDEC, ADPCM_YAMAHA,  WAV)  += yamaha
 
 FATE_ACODEC_ADPCM := $(FATE_ACODEC_ADPCM-yes:%=fate-acodec-adpcm-%)
@@ -70,6 +71,9 @@ fate-acodec-adpcm-ms:  FMT = wav
 fate-acodec-adpcm-swf: FMT = flv
 fate-acodec-adpcm-yamaha:  FMT = wav
 
+fate-acodec-adpcm-swf-wav: FMT   = wav
+fate-acodec-adpcm-swf-wav: CODEC = adpcm_swf
+
 FATE_ACODEC_ADPCM_TRELLIS-$(call ENCDEC, ADPCM_ADX, ADX)  += adx
 FATE_ACODEC_ADPCM_TRELLIS-$(call ENCDEC, ADPCM_IMA_QT,  AIFF) += ima_qt
 FATE_ACODEC_ADPCM_TRELLIS-$(call ENCDEC, ADPCM_IMA_WAV, WAV)  += ima_wav
diff --git a/tests/ref/acodec/adpcm-swf-wav b/tests/ref/acodec/adpcm-swf-wav
new file mode 100644
index 00..553e0bac54
--- /dev/null
+++ b/tests/ref/acodec/adpcm-swf-wav
@@ -0,0 +1,4 @@
+af5ffee897bad0174f4c7fc16c54aa5d *tests/data/fate/acodec-adpcm-swf-wav.wav
+266948 tests/data/fate/acodec-adpcm-swf-wav.wav
+628089745a7059ae4055c2515b6d668b *tests/data/fate/acodec-adpcm-swf-wav.out.wav
+stddev:  933.58 PSNR: 36.93 MAXDIFF:51119 bytes:  1058400/  1064960
-- 
2.28.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 v2 5/6] avcodec/adpcmenc: cosmetics

2020-10-19 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavcodec/adpcmenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index 42b83c2b48..6ecdab96d6 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -552,7 +552,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 st = avctx->channels == 2;
 
 if (avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_SSI ||
- avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_APM)
+avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_APM)
 pkt_size = (frame->nb_samples * avctx->channels) / 2;
 else
 pkt_size = avctx->block_align;
-- 
2.28.0


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

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

Re: [FFmpeg-devel] [PATCH v3 1/8] avcodec/movtextenc: Fix potential use of uninitialized value

2020-10-19 Thread Philip Langdale
On Sat, 17 Oct 2020 09:37:38 +0200
Andreas Rheinhardt  wrote:

> Background colour was never initialized if no style was available.
> Use a sane default of zero (i.e. completely transparent).
> 
> Fixes Coverity issue #1461471.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
> No change for this patch since last time; I am just resending all
> because I have added a few patches that I intend to backport and that
> therefore should be applied before "Simplify writing to AVBPrint".
> 
>  libavcodec/movtextenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
> index 5f60b8db61..11db240ab7 100644
> --- a/libavcodec/movtextenc.c
> +++ b/libavcodec/movtextenc.c
> @@ -205,7 +205,7 @@ static int
> encode_sample_description(AVCodecContext *avctx) ASS *ass;
>  ASSStyle *style;
>  int i, j;
> -uint32_t tsmb_size, tsmb_type, back_color, style_color;
> +uint32_t tsmb_size, tsmb_type, back_color = 0, style_color;
>  uint16_t style_start, style_end, fontID, count;
>  int font_names_total_len = 0;
>  MovTextContext *s = avctx->priv_data;

This movtextenc series looks good. Sorry I missed it earlier.

Thanks!


--phil
___
ffmpeg-devel mailing list
ffmpeg-devel@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] libavformat/hls: add support for SAMPLE-AES decryption in HLS demuxer

2020-10-19 Thread Steven Liu


> 2020年10月19日 下午4:10,Nachiket Tarate  写道:
> 
> 
> 
> 
> From: ffmpeg-devel  on behalf of Steven Liu 
> 
> Sent: Monday, October 19, 2020 7:43 AM
> To: FFmpeg development discussions and patches
> Subject: Re: [FFmpeg-devel] [PATCH] libavformat/hls: add support for 
> SAMPLE-AES decryption in HLS demuxer
> 
> Nachiket Tarate  于2020年10月18日周日 上午8:07写道:
>> 
>> ___
>> From: ffmpeg-devel  on behalf of Michael 
>> Niedermayer 
>> Sent: Thursday, October 15, 2020 11:35 PM
>> To: FFmpeg development discussions and patches
>> Subject: Re: [FFmpeg-devel] [PATCH] libavformat/hls: add support for 
>> SAMPLE-AES decryption in HLS demuxer
>> 
>> On Thu, Oct 15, 2020 at 10:15:13PM +0530, Nachiket Tarate wrote:
>>> Apple HTTP Live Streaming Sample Encryption:
>>> 
>>> https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption
>>> 
>>> Signed-off-by: Nachiket Tarate 
>>> ---
>>> libavformat/Makefile |   2 +-
>>> libavformat/hls.c|  93 ++-
>>> libavformat/hls_sample_aes.c | 497 +++
>>> libavformat/hls_sample_aes.h |  64 +
>>> libavformat/mpegts.c |  15 ++
>>> 5 files changed, 657 insertions(+), 14 deletions(-)
>>> create mode 100644 libavformat/hls_sample_aes.c
>>> create mode 100644 libavformat/hls_sample_aes.h
>> 
>> This seems to break fate (segfault)
>> I guess patchwork will notice it too but as i already tested and noticed ...
>> 
>> --- ./tests/ref/fate/segment-mp4-to-ts  2020-10-10 18:08:06.500253003 +0200
>> +++ tests/data/fate/segment-mp4-to-ts   2020-10-15 20:03:24.586303460 +0200
>> @@ -128,5 +128,3 @@
>> 0, 428400, 435600, 3600,  156, 0xd2c3406c, F=0x0, S=1,   
>>  1, 0x00e000e0
>> 0, 432000, 439200, 3600,  330, 0x150d9b60, F=0x0, S=1,   
>>  1, 0x00e000e0
>> 0, 435600, 446400, 3600,  324, 0x558194ee, F=0x0, S=1,   
>>  1, 0x00e000e0
>> -0, 439200, 442800, 3600,  191, 0x108e54d1, F=0x0, S=1,  
>>   1, 0x00e000e0
>> -0, 442800, 45, 3600,  233, 0xac5b6486, F=0x0
>> Test segment-mp4-to-ts failed. Look at tests/data/fate/segment-mp4-to-ts.err 
>> for details.
>> tests/Makefile:255: recipe for target 'fate-segment-mp4-to-ts' failed
>> make: *** [fate-segment-mp4-to-ts] Error 139
>> 
>> 
>> I ran FATE with samples again but I didn't get segfault. Can you please help 
>> me to reproduce it ?
> 
> https://patchwork.ffmpeg.org/project/ffmpeg/patch/sg2pr01mb269339627c977c841e26b05df2...@sg2pr01mb2693.apcprd01.prod.exchangelabs.com/
> fate failed message here.
> 
> TESTsegment-mp4-to-ts
> --- 
> /Users/liuqi/multimedia/upstream_ffmpeg/ffmpeg/tests/ref/fate/segment-mp4-to-ts
> 2020-10-19 09:24:15.0 +0800
> +++ tests/data/fate/segment-mp4-to-ts 2020-10-19 10:09:43.0 +0800
> @@ -128,5 +128,3 @@
> 0, 428400, 435600, 3600,  156, 0xd2c3406c, F=0x0,
> S=1,1, 0x00e000e0
> 0, 432000, 439200, 3600,  330, 0x150d9b60, F=0x0,
> S=1,1, 0x00e000e0
> 0, 435600, 446400, 3600,  324, 0x558194ee, F=0x0,
> S=1,1, 0x00e000e0
> -0, 439200, 442800, 3600,  191, 0x108e54d1, F=0x0,
> S=1,1, 0x00e000e0
> -0, 442800, 45, 3600,  233, 0xac5b6486, F=0x0
> Test segment-mp4-to-ts failed. Look at
> tests/data/fate/segment-mp4-to-ts.err for details.
> make: *** [fate-segment-mp4-to-ts] Error 134
> (base) liuqi05:ufbuild liuqi$ history |grep make | tail -n 5
>  318  make -j6
>  319  make fate-rsync
>  320  make fate
> 
> (base) liuqi05:ufbuild liuqi$ ./ffmpeg
> ffmpeg version N-99556-gf7e2f090ed Copyright (c) 2000-2020 the FFmpeg 
> developers
>  built with Apple clang version 12.0.0 (clang-1200.0.32.2)
>  configuration: --cc=clang --quiet --enable-htmlpages
> --enable-libx264 --enable-libxml2 --enable-gpl --extra-ldflags='-O0
> -g3 -fsanitize=address -Wno-error -fPIC -I/usr/local/include'
> --extra-ldflags='-O0 -g3 -fsanitize=address -Wno-error -fPIC
> -L/usr/local/lib' --enable-libfreetype --enable-fontconfig
> --enable-libspeex --enable-libopus --enable-libzmq --enable-libx265
> --enable-libass --enable-videotoolbox --disable-optimizations
> --enable-audiotoolbox --enable-opengl --disable-stripping
> --samples=../../fate-suite/
> 
> 
> need use samples --samples=../../fate-suite/
> and make fate-rsync
> 
> after above two step, you can make fate reproduce it.
> 
> 
> Actually, I did
> 
> make fate-rsync SAMPLES=fate-suite/
> make fate SAMPLES=fate-suite/
> 
> It is same.
> 
> But segmentation fault didn't occur while executing segment-mp4-to-ts.

make fate-segment-mp4-to-ts

What about just run this test?
> 
> Any idea ?
> 
> --
> Best Regards,
> Nachiket Tarate
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit

Re: [FFmpeg-devel] [PATCH] avformat/dashdec: check the root url length

2020-10-19 Thread Steven Liu
Steven Liu  于2020年8月17日周一 下午8:30写道:
>
> if the length of the root url is 0, unnecessary process the root_url
>
> Signed-off-by: Steven Liu 
> ---
>  libavformat/dashdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
> index c5a5ff607b..387d97fe42 100644
> --- a/libavformat/dashdec.c
> +++ b/libavformat/dashdec.c
> @@ -776,7 +776,7 @@ static int resolve_content_path(AVFormatContext *s, const 
> char *url, int *max_ur
>  size = strlen(root_url);
>  isRootHttp = ishttp(root_url);
>
> -if (root_url[size - 1] != token) {
> +if (size > 0 && root_url[size - 1] != token) {
>  av_strlcat(root_url, "/", size + 2);
>  size += 2;
>  }
> --
> 2.25.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".

pushed


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

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

Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: compute video_keyframe_size after write keyframe

2020-10-19 Thread Steven Liu
Steven Liu  于2020年9月18日周五 上午9:53写道:
>
> fix ticket: 8636
> When write keyframe and the keyframe is the frist packet of the segment,
> then compute the size of the keyframe which have been write into segment
> first packet. and set the start position of the segment, should not use
> avio_tell(vs->out) to get the keyframe position, because it can be set
> to 0 if close at above of the workflow, that maybe inaccurate, but the
> start_pos can be used here, because start_pos is set after write
> the previous packet.
>
> Signed-off-by: Steven Liu 
> ---
>  libavformat/hlsenc.c | 11 ++-
>  1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index cb31d6aed7..8687d7c12c 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -2572,13 +2572,14 @@ static int hls_write_packet(AVFormatContext *s, 
> AVPacket *pkt)
>
>  vs->packets_written++;
>  if (oc->pb) {
> +int64_t keyframe_pre_pos = avio_tell(oc->pb);
>  ret = ff_write_chained(oc, stream_index, pkt, s, 0);
> -vs->video_keyframe_size += pkt->size;
> -if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) && (pkt->flags 
> & AV_PKT_FLAG_KEY)) {
> -vs->video_keyframe_size = avio_tell(oc->pb);
> -} else {
> -vs->video_keyframe_pos = avio_tell(vs->out);
> +if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) &&
> +(pkt->flags & AV_PKT_FLAG_KEY) && !keyframe_pre_pos) {
> +av_write_frame(oc, NULL); /* Flush any buffered data */
> +vs->video_keyframe_size = avio_tell(oc->pb) - keyframe_pre_pos;
>  }
> +vs->video_keyframe_pos = vs->start_pos;
>  if (hls->ignore_io_errors)
>  ret = 0;
>  }
> --
> 2.25.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".

Pushed


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

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

Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: support CODECS Attribute in hevc EXT-X-STREAM-INF

2020-10-19 Thread Steven Liu
Steven Liu  于2020年10月13日周二 下午3:06写道:
>
> fix ticket: 8904
> parse the SPS from extradata and get profile_tier_level
> write the profile_tier_level info into CODECS Attribute
>
> HLS CODECS Attribute reference to 
> :https://developer.apple.com/documentation/http_live_streaming/hls_authoring_specification_for_apple_devices/hls_authoring_specification_for_apple_devices_appendixes
>
> Signed-off-by: Steven Liu 
> ---
>  libavformat/hlsenc.c | 48 
>  1 file changed, 48 insertions(+)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index cb31d6aed7..7a51b8b320 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -46,6 +46,7 @@
>
>  #include "avformat.h"
>  #include "avio_internal.h"
> +#include "avc.h"
>  #if CONFIG_HTTP_PROTOCOL
>  #include "http.h"
>  #endif
> @@ -337,6 +338,49 @@ static void write_codec_attr(AVStream *st, VariantStream 
> *vs)
>  } else {
>  goto fail;
>  }
> +} else if (st->codecpar->codec_id == AV_CODEC_ID_HEVC) {
> +uint8_t *data = st->codecpar->extradata;
> +int profile = FF_PROFILE_UNKNOWN;
> +int level = FF_LEVEL_UNKNOWN;
> +
> +if (st->codecpar->profile != FF_PROFILE_UNKNOWN)
> +profile = st->codecpar->profile;
> +if (st->codecpar->level != FF_LEVEL_UNKNOWN)
> +level = st->codecpar->level;
> +
> +/* check the boundary of data which from current position is small 
> than extradata_size */
> +while (data && (data - st->codecpar->extradata + 5) < 
> st->codecpar->extradata_size) {
> +/* get HEVC SPS NAL and seek to profile_tier_level */
> +if (!(data[0] | data[1] | data[2]) && data[3] == 1 && ((data[4] 
> & 0x42) == 0x42)) {
> +int remain_size = 0;
> +int rbsp_size = 0;
> +/* skip start code + nalu header */
> +data += 6;
> +/* process by reference General NAL unit syntax */
> +remain_size = st->codecpar->extradata_size - (data - 
> st->codecpar->extradata);
> +uint8_t *rbsp_buf = ff_nal_unit_extract_rbsp(data, 
> remain_size, &rbsp_size, 0);
> +if (!rbsp_buf)
> +return;
> +if (rbsp_size < 13) {
> +av_freep(&rbsp_buf);
> +break;
> +}
> +/* skip sps_video_parameter_set_id   u(4),
> + *  sps_max_sub_layers_minus1u(3),
> + *  and sps_temporal_id_nesting_flag u(1) */
> +profile = rbsp_buf[1] & 0x1f;
> +/* skip 8 + 8 + 32 + 4 + 43 + 1 bit */
> +level = rbsp_buf[12];
> +av_freep(&rbsp_buf);
> +break;
> +}
> +data++;
> +}
> +if (st->codecpar->codec_tag == MKTAG('h','v','c','1') &&
> +profile != FF_PROFILE_UNKNOWN &&
> +level != FF_LEVEL_UNKNOWN) {
> +snprintf(attr, sizeof(attr), "%s.%d.4.L%d.B01", 
> av_fourcc2str(st->codecpar->codec_tag), profile, level);
> +}
>  } else if (st->codecpar->codec_id == AV_CODEC_ID_MP2) {
>  snprintf(attr, sizeof(attr), "mp4a.40.33");
>  } else if (st->codecpar->codec_id == AV_CODEC_ID_MP3) {
> @@ -2247,6 +2291,10 @@ static int hls_write_header(AVFormatContext *s)
>  continue;
>  }
>  avpriv_set_pts_info(outer_st, inner_st->pts_wrap_bits, 
> inner_st->time_base.num, inner_st->time_base.den);
> +if (outer_st->codecpar->codec_id == AV_CODEC_ID_HEVC &&
> +outer_st->codecpar->codec_tag != MKTAG('h','v','c','1')) {
> +av_log(s, AV_LOG_WARNING, "Stream HEVC is not hvc1, you 
> should use tag:v hvc1 to set it.\n");
> +}
>  write_codec_attr(outer_st, vs);
>
>  }
> --
> 2.25.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".

Pushed


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

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

[FFmpeg-devel] [PATCH v3 4/4] Fix potential illegal instruction error.

2020-10-19 Thread Shiyou Yin
MSA2 optimizations are attached to MSA macros in generic_macros_msa.h.
It's difficult to do runtime check for them. Remove this part of code
can make it more robust.
Impact on performance is not obvious(167fps==>166fps).
---
 configure   |  7 +--
 libavutil/mips/generic_macros_msa.h | 37 -
 2 files changed, 1 insertion(+), 43 deletions(-)

diff --git a/configure b/configure
index 8e451ca..f1f8ee9 100755
--- a/configure
+++ b/configure
@@ -450,7 +450,6 @@ Optimization options (experts only):
   --disable-mipsdspdisable MIPS DSP ASE R1 optimizations
   --disable-mipsdspr2  disable MIPS DSP ASE R2 optimizations
   --disable-msadisable MSA optimizations
-  --disable-msa2   disable MSA2 optimizations
   --disable-mipsfpudisable floating point MIPS optimizations
   --disable-mmidisable Loongson SIMD optimizations
   --disable-fast-unaligned consider unaligned accesses slow
@@ -2023,7 +2022,6 @@ ARCH_EXT_LIST_MIPS="
 mipsdsp
 mipsdspr2
 msa
-msa2
 "
 
 ARCH_EXT_LIST_LOONGSON="
@@ -2560,7 +2558,6 @@ mipsdsp_deps="mips"
 mipsdspr2_deps="mips"
 mmi_deps_any="loongson2 loongson3"
 msa_deps="mipsfpu"
-msa2_deps="msa"
 
 cpunop_deps="i686"
 x86_64_select="i686"
@@ -5886,9 +5883,8 @@ elif enabled mips; then
 enabled mipsdsp && check_inline_asm_flags mipsdsp '"addu.qb $t0, $t1, 
$t2"' '-mdsp'
 enabled mipsdspr2 && check_inline_asm_flags mipsdspr2 '"absq_s.qb $t0, 
$t1"' '-mdspr2'
 
-# MSA and MSA2 can be detected at runtime so we supply extra flags here
+# MSA can be detected at runtime so we supply extra flags here
 enabled mipsfpu && enabled msa && check_inline_asm msa '"addvi.b $w0, $w1, 
1"' '-mmsa' && append MSAFLAGS '-mmsa'
-enabled msa && enabled msa2 && check_inline_asm msa2 '"nxbits.any.b $w0, 
$w0"' '-mmsa2' && append MSAFLAGS '-mmsa2'
 
 # loongson2 have no switch cflag so we can only probe toolchain ability
 enabled loongson2 && check_inline_asm loongson2 '"dmult.g $8, $9, $10"' && 
disable loongson3
@@ -7312,7 +7308,6 @@ if enabled mips; then
 echo "MIPS DSP R1 enabled   ${mipsdsp-no}"
 echo "MIPS DSP R2 enabled   ${mipsdspr2-no}"
 echo "MIPS MSA enabled  ${msa-no}"
-echo "MIPS MSA2 enabled ${msa2-no}"
 echo "LOONGSON MMI enabled  ${mmi-no}"
 fi
 if enabled ppc; then
diff --git a/libavutil/mips/generic_macros_msa.h 
b/libavutil/mips/generic_macros_msa.h
index bb25e9f..1486f72 100644
--- a/libavutil/mips/generic_macros_msa.h
+++ b/libavutil/mips/generic_macros_msa.h
@@ -25,10 +25,6 @@
 #include 
 #include 
 
-#if HAVE_MSA2
-#include 
-#endif
-
 #define ALIGNMENT   16
 #define ALLOC_ALIGNED(align) __attribute__ ((aligned((align) << 1)))
 
@@ -1119,15 +1115,6 @@
  unsigned absolute diff values, even-odd pairs are added
  together to generate 8 halfword results.
 */
-#if HAVE_MSA2
-#define SAD_UB2_UH(in0, in1, ref0, ref1) \
-( {  \
-v8u16 sad_m = { 0 }; \
-sad_m += __builtin_msa2_sad_adj2_u_w2x_b((v16u8) in0, (v16u8) ref0); \
-sad_m += __builtin_msa2_sad_adj2_u_w2x_b((v16u8) in1, (v16u8) ref1); \
-sad_m;   \
-} )
-#else
 #define SAD_UB2_UH(in0, in1, ref0, ref1)\
 ( { \
 v16u8 diff0_m, diff1_m; \
@@ -1141,7 +1128,6 @@
 \
 sad_m;  \
 } )
-#endif // #if HAVE_MSA2
 
 /* Description : Insert specified word elements from input vectors to 1
  destination vector
@@ -2183,12 +2169,6 @@
  extracted and interleaved with same vector 'in0' to generate
  4 word elements keeping sign intact
 */
-#if HAVE_MSA2
-#define UNPCK_R_SH_SW(in, out)   \
-{\
-out = (v4i32) __builtin_msa2_w2x_lo_s_h((v8i16) in); \
-}
-#else
 #define UNPCK_R_SH_SW(in, out)   \
 {\
 v8i16 sign_m;\
@@ -2196,7 +2176,6 @@
 sign_m = __msa_clti_s_h((v8i16) in, 0);  \
 out = (v4i32) __msa_ilvr_h(sign_m, (v8i16) in);  \
 }
-#endif // #if HAVE_MSA2
 
 /* Description : Sign extend byte elements from input vector and return
  halfword results in pair of vectors
@@ -2209,13 +2188,6 @@
  Then interleaved left with same vector 'in0' to
  generate 8 signed halfword elements in 'out1'
 */
-#if HAVE_MSA2
-#define UNPCK_SB_SH(in, out0, out1)   \

[FFmpeg-devel] MIPS: Optimize H264 decoding.

2020-10-19 Thread Shiyou Yin
H264 decoding speed: 154fps ==> 165fps, 5.14x ==> 5.53x (tested on 3A4000)

V2: Fixed a build error in [PATCH 2/3].
"Error: opcode not supported on this processor: mips32r2 (mips32r2) `dsbh 
$10,$10'"

V3: Add a fix patch to make MSA optimization more robust.

[PATCH v3 1/4] avcodec/mips: Restore the initialization sequence of.
[PATCH v3 2/4] avcodec/mips: Refine get_cabac_inline_mips.
[PATCH v3 3/4] avcodec/mips: Optimize function.
[PATCH v3 4/4] Fix potential illegal instruction error.

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

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

[FFmpeg-devel] [PATCH v3 3/4] avcodec/mips: Optimize function ff_h264_loop_filter_strength_msa.

2020-10-19 Thread Shiyou Yin
From: gxw 

Speed of decoding H264: 5.45x ==> 5.53x

Signed-off-by: Shiyou Yin 
---
 libavcodec/mips/Makefile|   3 +-
 libavcodec/mips/h264_deblock_msa.c  | 153 
 libavcodec/mips/h264dsp_init_mips.c |   2 +
 libavcodec/mips/h264dsp_mips.h  |   4 +
 4 files changed, 161 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/mips/h264_deblock_msa.c

diff --git a/libavcodec/mips/Makefile b/libavcodec/mips/Makefile
index 2be4d9b..81a73a4 100644
--- a/libavcodec/mips/Makefile
+++ b/libavcodec/mips/Makefile
@@ -57,7 +57,8 @@ MSA-OBJS-$(CONFIG_VP8_DECODER)+= 
mips/vp8_mc_msa.o \
  mips/vp8_lpf_msa.o
 MSA-OBJS-$(CONFIG_VP3DSP) += mips/vp3dsp_idct_msa.o
 MSA-OBJS-$(CONFIG_H264DSP)+= mips/h264dsp_msa.o\
- mips/h264idct_msa.o
+ mips/h264idct_msa.o   \
+ mips/h264_deblock_msa.o
 MSA-OBJS-$(CONFIG_H264QPEL)   += mips/h264qpel_msa.o
 MSA-OBJS-$(CONFIG_H264CHROMA) += mips/h264chroma_msa.o
 MSA-OBJS-$(CONFIG_H264PRED)   += mips/h264pred_msa.o
diff --git a/libavcodec/mips/h264_deblock_msa.c 
b/libavcodec/mips/h264_deblock_msa.c
new file mode 100644
index 000..4fed55c
--- /dev/null
+++ b/libavcodec/mips/h264_deblock_msa.c
@@ -0,0 +1,153 @@
+/*
+ * MIPS SIMD optimized H.264 deblocking code
+ *
+ * Copyright (c) 2020 Loongson Technology Corporation Limited
+ *Gu Xiwei 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/bit_depth_template.c"
+#include "h264dsp_mips.h"
+#include "libavutil/mips/generic_macros_msa.h"
+#include "libavcodec/mips/h264dsp_mips.h"
+
+#define h264_loop_filter_strength_iteration_msa(edges, step, mask_mv, dir, \
+d_idx, mask_dir)   \
+do {   \
+int b_idx = 0; \
+int step_x4 = step << 2; \
+int d_idx_12 = d_idx + 12; \
+int d_idx_52 = d_idx + 52; \
+int d_idx_x4 = d_idx << 2; \
+int d_idx_x4_48 = d_idx_x4 + 48; \
+int dir_x32  = dir * 32; \
+uint8_t *ref_t = (uint8_t*)ref; \
+uint8_t *mv_t  = (uint8_t*)mv; \
+uint8_t *nnz_t = (uint8_t*)nnz; \
+uint8_t *bS_t  = (uint8_t*)bS; \
+mask_mv <<= 3; \
+for (; b_idx < edges; b_idx += step) { \
+out &= mask_dir; \
+if (!(mask_mv & b_idx)) { \
+if (bidir) { \
+ref_2 = LD_SB(ref_t + d_idx_12); \
+ref_3 = LD_SB(ref_t + d_idx_52); \
+ref_0 = LD_SB(ref_t + 12); \
+ref_1 = LD_SB(ref_t + 52); \
+ref_2 = (v16i8)__msa_ilvr_w((v4i32)ref_3, (v4i32)ref_2); \
+ref_0 = (v16i8)__msa_ilvr_w((v4i32)ref_0, (v4i32)ref_0); \
+ref_1 = (v16i8)__msa_ilvr_w((v4i32)ref_1, (v4i32)ref_1); \
+ref_3 = (v16i8)__msa_shf_h((v8i16)ref_2, 0x4e); \
+ref_0 -= ref_2; \
+ref_1 -= ref_3; \
+ref_0 = (v16i8)__msa_or_v((v16u8)ref_0, (v16u8)ref_1); \
+\
+tmp_2 = LD_SH(mv_t + d_idx_x4_48);   \
+tmp_3 = LD_SH(mv_t + 48); \
+tmp_4 = LD_SH(mv_t + 208); \
+tmp_5 = tmp_2 - tmp_3; \
+tmp_6 = tmp_2 - tmp_4; \
+SAT_SH2_SH(tmp_5, tmp_6, 7); \
+tmp_0 = __msa_pckev_b((v16i8)tmp_6, (v16i8)tmp_5); \
+tmp_0 += cnst_1; \
+tmp_0 = (v16i8)__msa_subs_u_b((v16u8)tmp_0, (v16u8)cnst_0);\
+tmp_0 = (v16i8)__msa_sat_s_h((v8i16)tmp_0, 7); \
+tmp_0 = __msa_pckev_b(tmp_0, tmp_0); \
+out   = (v16i8)__msa_or_v((v16u8)ref_0, (v16u8)tmp_0); \
+\
+tmp_2 = LD_SH(mv_t + 208 + d_idx_x4); \
+tmp_5 = tmp_2 - tmp_3; \
+tmp_6 = tmp_2 - tmp_4; \
+SAT_SH2_SH(tmp_5, tmp_6, 7); \
+tmp_1 = __msa_pckev_b((v16i8)tmp_6, (v16i8)tmp_5); \
+tmp_1 += cnst_1; \
+tmp_1 = (v16i8)__msa_subs

[FFmpeg-devel] [PATCH v3 1/4] avcodec/mips: Restore the initialization sequence of MSA and MMI in ff_h264chroma_init_mips.

2020-10-19 Thread Shiyou Yin
The MSA version has been refined in commit 93218c2 and ce0a52e,
and is better than MMI version now.
Speed of decoding H264: 5.14x ==> 5.23x (tested on 3A4000).
---
 libavcodec/mips/h264chroma_init_mips.c | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/libavcodec/mips/h264chroma_init_mips.c 
b/libavcodec/mips/h264chroma_init_mips.c
index 6bb19d3..755cc04 100644
--- a/libavcodec/mips/h264chroma_init_mips.c
+++ b/libavcodec/mips/h264chroma_init_mips.c
@@ -28,7 +28,15 @@ av_cold void ff_h264chroma_init_mips(H264ChromaContext *c, 
int bit_depth)
 int cpu_flags = av_get_cpu_flags();
 int high_bit_depth = bit_depth > 8;
 
-/* MMI apears to be faster than MSA here */
+if (have_mmi(cpu_flags)) {
+if (!high_bit_depth) {
+c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_mmi;
+c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_mmi;
+c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_mmi;
+c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_mmi;
+}
+}
+
 if (have_msa(cpu_flags)) {
 if (!high_bit_depth) {
 c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_msa;
@@ -40,13 +48,4 @@ av_cold void ff_h264chroma_init_mips(H264ChromaContext *c, 
int bit_depth)
 c->avg_h264_chroma_pixels_tab[2] = ff_avg_h264_chroma_mc2_msa;
 }
 }
-
-if (have_mmi(cpu_flags)) {
-if (!high_bit_depth) {
-c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_mmi;
-c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_mmi;
-c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_mmi;
-c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_mmi;
-}
-}
 }
-- 
2.1.0

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

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

[FFmpeg-devel] [PATCH v3 2/4] avcodec/mips: Refine get_cabac_inline_mips.

2020-10-19 Thread Shiyou Yin
1. Refined function get_cabac_inline_mips.
2. Optimize function get_cabac_bypass and get_cabac_bypass_sign.

Speed of decoding h264: 5.23x ==> 5.45x(tested on 3A4000).
---
 libavcodec/mips/cabac.h | 131 +---
 1 file changed, 102 insertions(+), 29 deletions(-)

diff --git a/libavcodec/mips/cabac.h b/libavcodec/mips/cabac.h
index 3d09e93..0ee7594 100644
--- a/libavcodec/mips/cabac.h
+++ b/libavcodec/mips/cabac.h
@@ -2,7 +2,8 @@
  * Loongson SIMD optimized h264chroma
  *
  * Copyright (c) 2018 Loongson Technology Corporation Limited
- * Copyright (c) 2018 Shiyou Yin 
+ * Contributed by Shiyou Yin 
+ *Gu Xiwei(guxiwei...@loongson.cn)
  *
  * This file is part of FFmpeg.
  *
@@ -25,18 +26,18 @@
 #define AVCODEC_MIPS_CABAC_H
 
 #include "libavcodec/cabac.h"
-#include "libavutil/mips/asmdefs.h"
+#include "libavutil/mips/mmiutils.h"
 #include "config.h"
 
 #define get_cabac_inline get_cabac_inline_mips
 static av_always_inline int get_cabac_inline_mips(CABACContext *c,
- uint8_t * const state){
+  uint8_t * const state){
 mips_reg tmp0, tmp1, tmp2, bit;
 
 __asm__ volatile (
 "lbu  %[bit],0(%[state])   \n\t"
 "and  %[tmp0],   %[c_range], 0xC0  \n\t"
-PTR_ADDU "%[tmp0],   %[tmp0],%[tmp0]   \n\t"
+PTR_SLL  "%[tmp0],   %[tmp0],0x01  \n\t"
 PTR_ADDU "%[tmp0],   %[tmp0],%[tables] \n\t"
 PTR_ADDU "%[tmp0],   %[tmp0],%[bit]\n\t"
 /* tmp1: RangeLPS */
@@ -44,18 +45,11 @@ static av_always_inline int 
get_cabac_inline_mips(CABACContext *c,
 
 PTR_SUBU "%[c_range],%[c_range], %[tmp1]   \n\t"
 PTR_SLL  "%[tmp0],   %[c_range], 0x11  \n\t"
-PTR_SUBU "%[tmp0],   %[tmp0],%[c_low]  \n\t"
-
-/* tmp2: lps_mask */
-PTR_SRA  "%[tmp2],   %[tmp0],0x1F  \n\t"
-/* If tmp0 < 0, lps_mask ==  0x*/
-/* If tmp0 >= 0, lps_mask ==  0x*/
+"slt  %[tmp2],   %[tmp0],%[c_low]  \n\t"
 "beqz %[tmp2],   1f\n\t"
-PTR_SLL  "%[tmp0],   %[c_range], 0x11  \n\t"
+"move %[c_range],%[tmp1]   \n\t"
+"not  %[bit],%[bit]\n\t"
 PTR_SUBU "%[c_low],  %[c_low],   %[tmp0]   \n\t"
-PTR_SUBU "%[tmp0],   %[tmp1],%[c_range]\n\t"
-PTR_ADDU "%[c_range],%[c_range], %[tmp0]   \n\t"
-"xor  %[bit],%[bit], %[tmp2]   \n\t"
 
 "1:\n\t"
 /* tmp1: *state */
@@ -70,23 +64,18 @@ static av_always_inline int 
get_cabac_inline_mips(CABACContext *c,
 PTR_SLL  "%[c_range],%[c_range], %[tmp2]   \n\t"
 PTR_SLL  "%[c_low],  %[c_low],   %[tmp2]   \n\t"
 
-"and  %[tmp0],   %[c_low],   %[cabac_mask] \n\t"
-"bnez %[tmp0],   1f\n\t"
-PTR_ADDIU"%[tmp0],   %[c_low],   -0x01 \n\t"
+"and  %[tmp1],   %[c_low],   %[cabac_mask] \n\t"
+"bnez %[tmp1],   1f\n\t"
+PTR_ADDIU"%[tmp0],   %[c_low],   -0X01 \n\t"
 "xor  %[tmp0],   %[c_low],   %[tmp0]   \n\t"
 PTR_SRA  "%[tmp0],   %[tmp0],0x0f  \n\t"
 PTR_ADDU "%[tmp0],   %[tmp0],%[tables] \n\t"
+/* tmp2: ff_h264_norm_shift[x >> (CABAC_BITS - 1)] */
 "lbu  %[tmp2],   %[norm_off](%[tmp0])  \n\t"
-#if CABAC_BITS == 16
-"lbu  %[tmp0],   0(%[c_bytestream])\n\t"
-"lbu  %[tmp1],   1(%[c_bytestream])\n\t"
-PTR_SLL  "%[tmp0],   %[tmp0],0x09  \n\t"
-PTR_SLL  "%[tmp1],   %[tmp1],0x01  \n\t"
-PTR_ADDU "%[tmp0],   %[tmp0],%[tmp1]   \n\t"
-#else
-"lbu  %[tmp0],   0(%[c_bytestream])\n\t"
+
+"lhu  %[tmp0],   0(%[c_bytestream])\n\t"
+"wsbh %[tmp0],   %[tmp0]   \n\t"
 PTR_SLL  "%[tmp0],   %[tmp0],0x01  \n\t"
-#endif
 PTR_SUBU "%[tmp0],   %[tmp0],%[cabac_mask] \n\t"
 
 "li   %[tmp1],   0x07  \n\t"
@@ -94,10 +83,13 @@ static av_always_inline int 
get_cabac_inline_mips(CABACContext *c,
  

Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: process hls_time value too small sence

2020-10-19 Thread Steven Liu
Steven Liu  于2020年8月18日周二 上午10:44写道:
>
> The target duration will be a negative value when there are
> some b frames after prevous frame, the pts after current packet
> is large than the pts of current packet, so the target duration
> will compute as 0.04 - 0.08, then the value of the target
> duration will be -0.04. so hls muxer should check the pts after
> current packet minus the pts of current packet, hls muxer can split
> the stream as a segment if the target duration is neither negative nor
> zero, hls muxer cannot split the stream as a segment if the
> target duration is either negative or zero then get the next packet
> until the target duration is not negative or zero.
>
> Signed-off-by: Steven Liu 
> Suggested-by: Zhili Zhao 
> ---
>  libavformat/hlsenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index cb31d6aed7..4471858222 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -2398,9 +2398,9 @@ static int hls_write_packet(AVFormatContext *s, 
> AVPacket *pkt)
>  vs->duration = (double)(pkt->pts - vs->end_pts) * 
> st->time_base.num / st->time_base.den;
>  }
>  }
> -
>  }
>
> +can_split = can_split && (pkt->pts - vs->end_pts > 0);
>  if (vs->packets_written && can_split && av_compare_ts(pkt->pts - 
> vs->start_pts, st->time_base,
>end_pts, 
> AV_TIME_BASE_Q) >= 0) {
>  int64_t new_start_pos;
> --
> 2.25.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".

pushed


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

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

Re: [FFmpeg-devel] [PATCH 2/3] ffmpeg.c: refine picking default video stream

2020-10-19 Thread Gyan Doshi



On 19-10-2020 08:14 pm, Anton Khirnov wrote:

Quoting Gyan Doshi (2020-10-14 20:43:59)


On 14-10-2020 02:23 pm, Anton Khirnov wrote:

Use a floating-point score value to take into account bitrate, when
multiple streams with the same resolution are present.

Stop accessing private AVStream.codec_info_nb_frames field, as the
sample in question
http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket2639/Thailand-Wave.wmv
is now handled by the above change.
---
   fftools/ffmpeg_opt.c | 23 ++-
   1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index a0d1b06f2d..afef23919c 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
USA
*/
   
+#include 

   #include 
   
   #include "ffmpeg.h"

@@ -2208,15 +2209,27 @@ static int open_output_file(OptionsContext *o, const 
char *filename)
   char *subtitle_codec_name = NULL;
   /* pick the "best" stream of each type */
   
-/* video: highest resolution */

+/* video */
   if (!o->video_disable && av_guess_codec(oc->oformat, NULL, filename, 
NULL, AVMEDIA_TYPE_VIDEO) != AV_CODEC_ID_NONE) {
-int best_score = 0, idx = -1;
+double best_score = 0.0;
+int idx = -1;
   int qcr = avformat_query_codec(oc->oformat, 
oc->oformat->video_codec, 0);
   for (i = 0; i < nb_input_streams; i++) {
-int score;
+double score;
   ist = input_streams[i];
-score = ist->st->codecpar->width * ist->st->codecpar->height + 
1*!!ist->st->codec_info_nb_frames
-   + 500*!!(ist->st->disposition & 
AV_DISPOSITION_DEFAULT);
+
+/* base score is just the area in pixels */
+score = (double)ist->st->codecpar->width * 
ist->st->codecpar->height;
+/* add a fractional part favoring higher bitrate among 
same-area streams */
+if (ist->st->codecpar->bit_rate) {
+const double bitrate_max = 100e6; // cap at 100Mb/s
+const double bitrate = FFMIN(ist->st->codecpar->bit_rate, 
bitrate_max - 1.0);
+score += bitrate / bitrate_max;
+}
+/* default streams get max score */
+if (ist->st->disposition & AV_DISPOSITION_DEFAULT)
+score = DBL_MAX;

This is actually a mistake that shouldn't ever been committed.

A default disposition only has relevance among companion video streams
from the same input. It does and should not apply to inter-input
comparisons.
Only a handful of demuxers set disposition. Default audio selection is
already broken with respect to its documented behaviour for, I believe,
a couple of years now.

The saner way is to select best stream from each input and then select
from that shortlist without considering disposition.

Watches pelcome. I am not bringing about world peace here, I just want
ffmpeg.c to be a well-behaved user application and stop accessing lavf
internals.


Will do in a couple of weeks.  So, this patch LGTM then.

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 2/3] ffmpeg.c: refine picking default video stream

2020-10-19 Thread James Almer
On 10/19/2020 11:42 AM, Anton Khirnov wrote:
> Quoting James Almer (2020-10-14 19:26:51)
>> On 10/14/2020 2:09 PM, Michael Niedermayer wrote:
>>> On Wed, Oct 14, 2020 at 10:53:10AM +0200, Anton Khirnov wrote:
 Use a floating-point score value to take into account bitrate, when
 multiple streams with the same resolution are present.

 Stop accessing private AVStream.codec_info_nb_frames field, as the
 sample in question
 http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket2639/Thailand-Wave.wmv
 is now handled by the above change.
 ---
  fftools/ffmpeg_opt.c | 23 ++-
  1 file changed, 18 insertions(+), 5 deletions(-)
>>>
>>> Breaks:
>>> -i tickets/4496/08_lect_01.rm  file.avi
>>>
>>> as refernce here is what ffmpeg shows about the streams:
>>> Stream #0:0: Audio: sipr (sipr / 0x72706973), 8000 Hz, mono, flt, 4 kb/s
>>> Stream #0:1: Audio: sipr (sipr / 0x72706973), 8000 Hz, mono, flt, 8 kb/s
>>> Stream #0:2: Audio: cook (cook / 0x6B6F6F63), 22050 Hz, mono, fltp, 4 
>>> kb/s
>>> Stream #0:3: Audio: sipr (sipr / 0x72706973), 8000 Hz, mono, flt, 4 kb/s
>>> Stream #0:4: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 252 
>>> kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
>>> Stream #0:5: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 252 
>>> kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
>>> Stream #0:6: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 252 
>>> kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
>>> Stream #0:7: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 252 
>>> kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
>>> Stream #0:8: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 252 
>>> kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
>>> Stream #0:9: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 252 
>>> kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
>>> Stream #0:10: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 252 
>>> kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
>>> Stream #0:11: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 252 
>>> kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
>>> Stream #0:12: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 252 
>>> kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
>>> Stream #0:13: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 252 
>>> kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
>>>
>>> sample should be here according to the ticket:
>>> https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket2152/
>>>
>>> I dont think you can reliably detect non empty streams from the header alone
>>> in every case.
>>>
>>> thx
>>
>> This whole chunk of code is apparently done because
>> av_find_best_stream() can't be used here (The list of input streams is
>> in a custom struct InputStream instead of an AVFormatContext).
>> codec_info_nb_frames is evidently needed to detect non-empty streams, so
>> either making it or a replacement public or hand crafting a dummy
>> AVFormatContext with the input streams then using av_find_best_stream()
>> are two options for this.
>>
>> I personally think the latter option is a good solution.
>> av_find_best_stream() does not seem to care about its contents beyond
>> nb_streams and the streams list.
> 
> That seems immensely hacky to me tbh.

If it prevents regressions like these while using public API... It'd not
be the only case of dummy contexts used for some specific purpose in the
codebase, too. But i agree it's kinda hacky and probably not ideal for
what's technically the main reference library implementation.

> 
> I am also not very comfortable with making codec_info_nb_frames
> officially public, as that hardcodes internal workings of
> find_stream_info() into the public API, making it harder to change
> later.
> 
> More generally, I do not think it is reasonable to demand that the
> automatic mapping code in ffmpeg.c magically choose the best stream for
> all pathological cases. Files with empty streams are IMO pathological,
> and the user can always override the mapping manually.

It's not just an empty stream per se. The first command line Michael
posted did a seek to a few seconds before EOF. At that point the stream
that would be chosen by looking at dimensions and bitrate alone had no
frames left, but other video streams did. codec_info_nb_frames ensured
one of them would be chosen instead of the otherwise best stream, as
would have done av_find_best_stream().

That being said, using internal fields is a problem, so I'll not be
against a solution like this patch that does a best effort attempt
without frame count knowledge.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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