Re: [FFmpeg-devel] [PATCH] avformat/dhav: also support ZLAV packets

2020-10-31 Thread Michael Keeley
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Paul B Mahol
> Sent: Saturday, 24 October 2020 9:03 pm
> To: FFmpeg development discussions and patches
> Cc: Michael Keeley
> Subject: Re: [FFmpeg-devel] [PATCH] avformat/dhav: also support ZLAV
> packets
> 
> LGTM
> 

Thanks for the feedback.
Is there anything more I need to do here, or will someone merge it?

Cheers,
Mike.

> On Sat, Oct 24, 2020 at 2:32 AM Michael Keeley 
> wrote:
> 
> > Some DVRs (e.g. D7008FH made by Zhuhai Ltd) output the same format
> .dav
> > file,
> > but use ZLAV/zlav tags to delimit the packets instead of DHAV/dhav.
> >
> > Signed-off-by: Michael Keeley 
> > ---
> >  Changelog |  1 +
> >  libavformat/dhav.c| 31 ++-
> >  libavformat/version.h |  2 +-
> >  3 files changed, 24 insertions(+), 10 deletions(-)
> >



___
ffmpeg-devel mailing list
ffmpeg-devel@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/concatdec: Check filename length before use

2020-10-31 Thread Michael Niedermayer
On Thu, Oct 29, 2020 at 04:22:23PM +0100, Andreas Rheinhardt wrote:
> Nicolas George:
> > Michael Niedermayer (12020-10-28):
> >> Fixes: out array read
> >> Fixes: 
> >> 26610/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-5631838049271808
> >>
> >> Found-by: continuous fuzzing process 
> >> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> >> Signed-off-by: Michael Niedermayer 
> >> ---
> >>  libavformat/concatdec.c | 3 ++-
> >>  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > This is not the first time such a fix is proposed. If strcmp() does not
> > behave intelligently, then we need an extra function for the task, but
> > duplicating the test all over the place is not a good idea.
> > 
> We already have av_strstart() which would also allow us to avoid
> computing strlen(proto) at all.

patch with av_strstart() posted, av_strstart() was available since
a long time so it should have no negative impact on backporting

thx

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

Elect your leaders based on what they did after the last election, not
based on what they say before an election.



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] avcodec/mpc8: Unobfuscate sign-extension

2020-10-31 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/mpc8.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c
> index 03838a9351..631bac2753 100644
> --- a/libavcodec/mpc8.c
> +++ b/libavcodec/mpc8.c
> @@ -384,7 +384,7 @@ static int mpc8_decode_frame(AVCodecContext * avctx, void 
> *data,
>  for(j = 0; j < SAMPLES_PER_BAND; j += 2){
>  t = get_vlc2(gb, q3_vlc[res - 3].table, MPC8_Q3_BITS, 2) 
> + q3_offsets[res - 3];
>  c->Q[ch][off + j + 1] = t >> 4;
> -c->Q[ch][off + j + 0] = (t & 8) ? (t & 0xF) - 16 : (t & 
> 0xF);
> +c->Q[ch][off + j + 0] = sign_extend(t, 4);
>  }
>  break;
>  case 5:
> 
Will apply this tomorrow unless there are objections.

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

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

Re: [FFmpeg-devel] [PATCH v2] fate: Add test for Musepack SV8 decoding

2020-10-31 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> While the FATE suite contains a sample file for Musepack 8, it did not
> use it to test the decoder; it is only used in the mpc8-demux test that
> tests the demuxer via streamcopy. Therefore this commit adds an actual
> encoder test.
> 
> The test uses the framecrc output, because Musepack SV8 is an encoder
> that returns multiple frames for a single packet, so that timing
> information in the test output is valueable. Output seeking has been
> used in order to limit the size of the ref file as well as to test this
> codepath for the first time.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
> For a short period of time, I pondered using the pcm_s16le_planar
> encoder (which would not need any format conversions), but given that
> one can't really put this in a file I instead opted for this.
> 
>  tests/fate/mpc.mak   |   5 ++
>  tests/ref/fate/musepack8 | 141 +++
>  2 files changed, 146 insertions(+)
>  create mode 100644 tests/ref/fate/musepack8
> 
> diff --git a/tests/fate/mpc.mak b/tests/fate/mpc.mak
> index 294dffeabf..3a3abfeaa5 100644
> --- a/tests/fate/mpc.mak
> +++ b/tests/fate/mpc.mak
> @@ -9,5 +9,10 @@ fate-musepack7: CMD = pcm -i 
> $(TARGET_SAMPLES)/musepack/inside-mp7.mpc
>  fate-musepack7: CMP = oneoff
>  fate-musepack7: REF = $(SAMPLES)/musepack/inside-mp7.pcm
>  
> +FATE_MPC-$(call ALLYES, FILE_PROTOCOL MPC8_DEMUXER MPC8_DECODER  \
> +ARESAMPLE_FILTER PCM_S16LE_ENCODER  \
> + FRAMECRC_MUXER PIPE_PROTOCOL) += fate-musepack8
> +fate-musepack8: CMD = framecrc -i $(TARGET_SAMPLES)/musepack/inside-mp8.mpc 
> -ss 8.4 -af aresample -c:a pcm_s16le
> +
>  FATE_SAMPLES_AVCONV += $(FATE_MPC-yes)
>  fate-mpc: $(FATE_MPC-yes)

Will apply this tomorrow unless there are objections.

- 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 4/6] avcodec/mobiclip: Bound planar prediction value

2020-10-31 Thread Michael Niedermayer
Alternatively we could wrap around or error out. Wrap around would look
most messy as downstream computations would need to wrap as well.
I did not find a official specification which would list what to do
with huge values.

Fixes: signed integer overflow: 2 * 1073741952 cannot be represented in type 
'int'
Fixes: 
26765/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MOBICLIP_fuzzer-6594926936326144

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

diff --git a/libavcodec/mobiclip.c b/libavcodec/mobiclip.c
index 9fa88e84a0..87a9a47da9 100644
--- a/libavcodec/mobiclip.c
+++ b/libavcodec/mobiclip.c
@@ -900,7 +900,7 @@ static int predict_intra(AVCodecContext *avctx, AVFrame 
*frame, int ax, int ay,
 uint8_t *left = frame->data[plane] + ay * frame->linesize[plane] + 
FFMAX(ax - 1, 0);
 int bottommost = frame->data[plane][(ay + size - 1) * 
frame->linesize[plane] + FFMAX(ax - 1, 0)];
 int rightmost = frame->data[plane][FFMAX(ay - 1, 0) * 
frame->linesize[plane] + ax + size - 1];
-int avg = (bottommost + rightmost + 1) / 2 + 2 * get_se_golomb(gb);
+int avg = (bottommost + rightmost + 1) / 2 + 2 * 
av_clip(get_se_golomb(gb), -(1<<16), 1<<16);
 int r6 = adjust(avg - bottommost, size);
 int r9 = adjust(avg - rightmost, size);
 int shift = adjust(size, size) == 8 ? 3 : 2;
-- 
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/6] avformat/mov: Avoid overflow in end computation in mov_read_custom()

2020-10-31 Thread Michael Niedermayer
Fixes: signed integer overflow: 18 + 9223372036854775799 cannot be represented 
in type 'long'
Fixes: 
26731/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5696846019952640

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

diff --git a/libavformat/mov.c b/libavformat/mov.c
index c8a38ec4df..8a66fb9674 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4385,7 +4385,7 @@ static int mov_read_keys(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 
 static int mov_read_custom(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
-int64_t end = avio_tell(pb) + atom.size;
+int64_t end = av_sat_add64(avio_tell(pb), atom.size);
 uint8_t *key = NULL, *val = NULL, *mean = NULL;
 int i;
 int ret = 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 5/6] avformat/bintext: Check width

2020-10-31 Thread Michael Niedermayer
Fixes: division by 0
Fixes: 
26780/clusterfuzz-testcase-minimized-ffmpeg_dem_ADF_fuzzer-5117945027756032

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

diff --git a/libavformat/bintext.c b/libavformat/bintext.c
index 7dab5f377d..810d870637 100644
--- a/libavformat/bintext.c
+++ b/libavformat/bintext.c
@@ -293,6 +293,8 @@ static int adf_read_header(AVFormatContext *s)
 bin->fsize = avio_size(pb) - 1 - 192 - 4096;
 st->codecpar->width = 80<<3;
 ff_sauce_read(s, >fsize, _width, 0);
+if (st->codecpar->width < 8)
+return AVERROR_INVALIDDATA;
 if (!bin->width)
 calculate_height(st->codecpar, bin->fsize);
 avio_seek(pb, 1 + 192 + 4096, SEEK_SET);
-- 
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/6] avformat/mov: Use av_sat_add64() in mov_read_sidx()

2020-10-31 Thread Michael Niedermayer
This avoids a potential integer overflow, no testcase is known

Signed-off-by: Michael Niedermayer 
---
 libavformat/mov.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 8a66fb9674..3abb9d3e99 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -5023,7 +5023,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 static int mov_read_sidx(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
 int64_t stream_size = avio_size(pb);
-int64_t offset = avio_tell(pb) + atom.size, pts, timestamp;
+int64_t offset = av_sat_add64(avio_tell(pb), atom.size), pts, timestamp;
 uint8_t version, is_complete;
 unsigned i, j, track_id, item_count;
 AVStream *st = NULL;
-- 
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/6] avformat/concatdec: use av_strstart()

2020-10-31 Thread Michael Niedermayer
Fixes: out array read
Fixes: 
26610/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-5631838049271808

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

diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index 4b56b61404..6d5b9914f9 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -113,7 +113,8 @@ static int add_file(AVFormatContext *avf, char *filename, 
ConcatFile **rfile,
 ConcatFile *file;
 char *url = NULL;
 const char *proto;
-size_t url_len, proto_len;
+const char *ptr;
+size_t url_len;
 int ret;
 
 if (cat->safe > 0 && !safe_filename(filename)) {
@@ -122,9 +123,8 @@ static int add_file(AVFormatContext *avf, char *filename, 
ConcatFile **rfile,
 }
 
 proto = avio_find_protocol_name(filename);
-proto_len = proto ? strlen(proto) : 0;
-if (proto && !memcmp(filename, proto, proto_len) &&
-(filename[proto_len] == ':' || filename[proto_len] == ',')) {
+if (proto && av_strstart(filename, proto, ) &&
+(*ptr == ':' || *ptr == ',')) {
 url = filename;
 filename = NULL;
 } else {
-- 
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/6] avformat/avidec: Use av_sat_sub64() in check_stream_max_drift()

2020-10-31 Thread Michael Niedermayer
Fixes: signed integer overflow: 8833900919969684211 - -9223372036854775808 
cannot be represented in type 'long'
Fixes: 
26726/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-5669377724383232

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

diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 578cf68ce1..6ebc72c5f9 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -1674,18 +1674,19 @@ static int check_stream_max_drift(AVFormatContext *s)
 AVIStream *ast = st->priv_data;
 
 if (idx[i] && min_dts != INT64_MAX / 2) {
-int64_t dts;
+int64_t dts, delta_dts;
 dts = av_rescale_q(st->internal->index_entries[idx[i] - 
1].timestamp /
FFMAX(ast->sample_size, 1),
st->time_base, AV_TIME_BASE_Q);
+delta_dts = av_sat_sub64(dts, min_dts);
 max_dts = FFMAX(max_dts, dts);
 max_buffer = FFMAX(max_buffer,
-   av_rescale(dts - min_dts,
+   av_rescale(delta_dts,
   st->codecpar->bit_rate,
   AV_TIME_BASE));
 }
 }
-if (max_dts - min_dts > 2 * AV_TIME_BASE ||
+if (av_sat_sub64(max_dts, min_dts) > 2 * AV_TIME_BASE ||
 max_buffer > 1024 * 1024 * 8 * 8) {
 av_free(idx);
 return 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".

Re: [FFmpeg-devel] [PATCH] avformat/dv: fix timestamps of audio packets in case of dropped corrupt audio frames

2020-10-31 Thread Dave Rice


> On Oct 31, 2020, at 5:15 PM, Marton Balint  wrote:
> On Sat, 31 Oct 2020, Dave Rice wrote:
>>> On Oct 31, 2020, at 3:47 PM, Marton Balint  wrote:
>>> On Sat, 31 Oct 2020, Dave Rice wrote:
 Hi Marton,
> On Oct 31, 2020, at 12:56 PM, Marton Balint  wrote:
> Fixes out of sync timestamps in ticket #8762.
 Although Michael’s recent patch does address the issue documented in 8762, 
 I haven’t found this patch to fix the issue. I tried with -c:a copy and 
 with -c:a pcm_s16le with some sample files that exhibit this issue but 
 each output was out of sync. I put an output at 
 https://gist.github.com/dericed/659bd843bd38b6f24a60198b5e345795. That 
 output notes that 3597 packages of video are read and 3586 packets of 
 audio. In the resulting file, at the end of the timeline the audio is 9 
 frames out of sync and my output video stream is 00:02:00.020 and output 
 audio stream is 00:01:59.653.
 Beyond copying or encoding the audio, are there other options I should use 
 to test this?
>>> Well, it depends on what you want. After this patch you should get a file 
>>> which has audio packets synced to video, but the audio stream is sparse, 
>>> not every video packet has a corresponding audio packet. (It looks like our 
>>> MOV muxer does not support muxing of sparse audio therefore does not 
>>> produce proper timestamps. But MKV does, please try that.)
>>> You can also make ffmpeg generate the missing audio based on packet 
>>> timestamps. Swresample has an async=1 option, so something like this should 
>>> get you synced audio with continous audio packets:
>>> ffmpeg -y -i 167052_12.dv -c:v copy \
>>> -af aresample=async=1:min_hard_comp=0.01 -c:a pcm_s16le 167052_12.mov
>> 
>> Thank you for this. With the patch and async, the result is synced and the 
>> resulting audio was the same as Michael’s patch.
>> 
>> Could you explain why you used min_hard_comp here? IIUC min_hard_comp is a 
>> set a threshold between the strategies of trim/fill or stretch/squeeze to 
>> align the audio to time; however, the async documentation says "Setting this 
>> to 1 will enable filling and trimming, larger values represent the maximum 
>> amount in samples that the data may be stretched or squeezed” so I thought 
>> that async=1 would not permit stretch/squeeze anyway.
> 
> It is documented poorly, but if you check the source code you will see that 
> async=1 implicitly sets min_comp to 0.001 enabling trimming/dropping. 
> min_hard_comp decides the threshold when silence injection actually happens, 
> and the default for that is 0.1, which is more than a frame, therefore not 
> acceptable if we want to maintain <1 frame accuracy. Or at least that is how 
> I think it should work.

Thanks for the explanation.
I’ve tested this patch with larger sample sets and really appreciate that the 
audio timestamps are now properly ordered. For instance with 
https://archive.org/download/dvr-007/DVR_007.dv, before the patch the 
timestamps for audio around 20 - 30 seconds get severely jumbled which makes it 
difficult to use astats metadata. While the documentation could be better, as 
I’ve seen many forums entries of ffmpeg users struggling to keep dv from tape 
transfers in sync, I don’t think that’s blocking. I’d really like to see this 
merged.

Although this patch resolves the issue, I think Michael’s patch is interesting 
too as it would allow access to the audio dif blocks of dv frames with no audio 
source pack metadata. I’d have to test more to find an instance where the 
'dvaudio_concealment pass’ option of Michael’s patch provides a different 
result than the added silence from async.

Thanks so much.
Dave

> Regards,
> Marton
> 
> Signed-off-by: Marton Balint 
> ---
> libavformat/dv.c   | 16 ++--
> tests/ref/seek/lavf-dv | 18 +-
> 2 files changed, 11 insertions(+), 23 deletions(-)
> diff --git a/libavformat/dv.c b/libavformat/dv.c
> index 3e0d12c0e3..26a78139f5 100644
> --- a/libavformat/dv.c
> +++ b/libavformat/dv.c
> @@ -49,7 +49,6 @@ struct DVDemuxContext {
>   uint8_t   audio_buf[4][8192];
>   int   ach;
>   int   frames;
> -uint64_t  abytes;
> };
> static inline uint16_t dv_audio_12to16(uint16_t sample)
> @@ -258,7 +257,7 @@ static int dv_extract_audio_info(DVDemuxContext *c, 
> const uint8_t *frame)
>   c->ast[i] = avformat_new_stream(c->fctx, NULL);
>   if (!c->ast[i])
>   break;
> -avpriv_set_pts_info(c->ast[i], 64, 1, 3);
> +avpriv_set_pts_info(c->ast[i], 64, c->sys->time_base.num, 
> c->sys->time_base.den);
>   c->ast[i]->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
>   c->ast[i]->codecpar->codec_id   = AV_CODEC_ID_PCM_S16LE;
> @@ -387,8 +386,7 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, 
> 

Re: [FFmpeg-devel] [PATCH] avformat/dv: fix timestamps of audio packets in case of dropped corrupt audio frames

2020-10-31 Thread Marton Balint



On Sat, 31 Oct 2020, Dave Rice wrote:




On Oct 31, 2020, at 3:47 PM, Marton Balint  wrote:
On Sat, 31 Oct 2020, Dave Rice wrote:


Hi Marton,


On Oct 31, 2020, at 12:56 PM, Marton Balint  wrote:
Fixes out of sync timestamps in ticket #8762.


Although Michael’s recent patch does address the issue documented in 8762, I 
haven’t found this patch to fix the issue. I tried with -c:a copy and with -c:a 
pcm_s16le with some sample files that exhibit this issue but each output was 
out of sync. I put an output at 
https://gist.github.com/dericed/659bd843bd38b6f24a60198b5e345795. That output 
notes that 3597 packages of video are read and 3586 packets of audio. In the 
resulting file, at the end of the timeline the audio is 9 frames out of sync 
and my output video stream is 00:02:00.020 and output audio stream is 
00:01:59.653.

Beyond copying or encoding the audio, are there other options I should use to 
test this?


Well, it depends on what you want. After this patch you should get a file which 
has audio packets synced to video, but the audio stream is sparse, not every 
video packet has a corresponding audio packet. (It looks like our MOV muxer 
does not support muxing of sparse audio therefore does not produce proper 
timestamps. But MKV does, please try that.)

You can also make ffmpeg generate the missing audio based on packet timestamps. 
Swresample has an async=1 option, so something like this should get you synced 
audio with continous audio packets:
ffmpeg -y -i 167052_12.dv -c:v copy \
-af aresample=async=1:min_hard_comp=0.01 -c:a pcm_s16le 167052_12.mov


Thank you for this. With the patch and async, the result is synced and the 
resulting audio was the same as Michael’s patch.

Could you explain why you used min_hard_comp here? IIUC min_hard_comp is 
a set a threshold between the strategies of trim/fill or stretch/squeeze 
to align the audio to time; however, the async documentation says 
"Setting this to 1 will enable filling and trimming, larger values 
represent the maximum amount in samples that the data may be stretched 
or squeezed” so I thought that async=1 would not permit stretch/squeeze 
anyway.


It is documented poorly, but if you check the source code you will see 
that async=1 implicitly sets min_comp to 0.001 enabling trimming/dropping. 
min_hard_comp decides the threshold when silence injection actually 
happens, and the default for that is 0.1, which is more than a frame, 
therefore not acceptable if we want to maintain <1 frame accuracy. Or at 
least that is how I think it should work.


Regards,
Marton




Signed-off-by: Marton Balint 
---
libavformat/dv.c   | 16 ++--
tests/ref/seek/lavf-dv | 18 +-
2 files changed, 11 insertions(+), 23 deletions(-)
diff --git a/libavformat/dv.c b/libavformat/dv.c
index 3e0d12c0e3..26a78139f5 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -49,7 +49,6 @@ struct DVDemuxContext {
   uint8_t   audio_buf[4][8192];
   int   ach;
   int   frames;
-uint64_t  abytes;
};
static inline uint16_t dv_audio_12to16(uint16_t sample)
@@ -258,7 +257,7 @@ static int dv_extract_audio_info(DVDemuxContext *c, const 
uint8_t *frame)
   c->ast[i] = avformat_new_stream(c->fctx, NULL);
   if (!c->ast[i])
   break;
-avpriv_set_pts_info(c->ast[i], 64, 1, 3);
+avpriv_set_pts_info(c->ast[i], 64, c->sys->time_base.num, 
c->sys->time_base.den);
   c->ast[i]->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
   c->ast[i]->codecpar->codec_id   = AV_CODEC_ID_PCM_S16LE;
@@ -387,8 +386,7 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket 
*pkt,
   for (i = 0; i < c->ach; i++) {
   c->audio_pkt[i].pos  = pos;
   c->audio_pkt[i].size = size;
-c->audio_pkt[i].pts  = c->abytes * 3 * 8 /
-   c->ast[i]->codecpar->bit_rate;
+c->audio_pkt[i].pts  = (c->sys->height == 720) ? (c->frames & ~1) : 
c->frames;
   ppcm[i] = c->audio_buf[i];
   }
   if (c->ach)
@@ -401,10 +399,7 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket 
*pkt,
   c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
   } else {
   c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
-c->abytes   += size;
   }
-} else {
-c->abytes += size;
   }

   /* Now it's time to return video packet */
@@ -444,13 +439,6 @@ static int64_t dv_frame_offset(AVFormatContext *s, 
DVDemuxContext *c,
void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset)
{
   c->frames = frame_offset;
-if (c->ach) {
-if (c->sys) {
-c->abytes = av_rescale_q(c->frames, c->sys->time_base,
- (AVRational) { 8, 
c->ast[0]->codecpar->bit_rate });
-} else
-av_log(c->fctx, AV_LOG_ERROR, "cannot adjust audio bytes\n");
-}
   c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
   c->audio_pkt[2].size = 

Re: [FFmpeg-devel] [PATCH] avformat/dv: fix timestamps of audio packets in case of dropped corrupt audio frames

2020-10-31 Thread Dave Rice

> On Oct 31, 2020, at 3:47 PM, Marton Balint  wrote:
> On Sat, 31 Oct 2020, Dave Rice wrote:
> 
>> Hi Marton,
>> 
>>> On Oct 31, 2020, at 12:56 PM, Marton Balint  wrote:
>>> Fixes out of sync timestamps in ticket #8762.
>> 
>> Although Michael’s recent patch does address the issue documented in 8762, I 
>> haven’t found this patch to fix the issue. I tried with -c:a copy and with 
>> -c:a pcm_s16le with some sample files that exhibit this issue but each 
>> output was out of sync. I put an output at 
>> https://gist.github.com/dericed/659bd843bd38b6f24a60198b5e345795. That 
>> output notes that 3597 packages of video are read and 3586 packets of audio. 
>> In the resulting file, at the end of the timeline the audio is 9 frames out 
>> of sync and my output video stream is 00:02:00.020 and output audio stream 
>> is 00:01:59.653.
>> 
>> Beyond copying or encoding the audio, are there other options I should use 
>> to test this?
> 
> Well, it depends on what you want. After this patch you should get a file 
> which has audio packets synced to video, but the audio stream is sparse, not 
> every video packet has a corresponding audio packet. (It looks like our MOV 
> muxer does not support muxing of sparse audio therefore does not produce 
> proper timestamps. But MKV does, please try that.)
> 
> You can also make ffmpeg generate the missing audio based on packet 
> timestamps. Swresample has an async=1 option, so something like this should 
> get you synced audio with continous audio packets:
> ffmpeg -y -i 167052_12.dv -c:v copy \
> -af aresample=async=1:min_hard_comp=0.01 -c:a pcm_s16le 167052_12.mov

Thank you for this. With the patch and async, the result is synced and the 
resulting audio was the same as Michael’s patch.

Could you explain why you used min_hard_comp here? IIUC min_hard_comp is a set 
a threshold between the strategies of trim/fill or stretch/squeeze to align the 
audio to time; however, the async documentation says "Setting this to 1 will 
enable filling and trimming, larger values represent the maximum amount in 
samples that the data may be stretched or squeezed” so I thought that async=1 
would not permit stretch/squeeze anyway.

> Regards,
> Marton
> 
> 
>> 
>>> Signed-off-by: Marton Balint 
>>> ---
>>> libavformat/dv.c   | 16 ++--
>>> tests/ref/seek/lavf-dv | 18 +-
>>> 2 files changed, 11 insertions(+), 23 deletions(-)
>>> diff --git a/libavformat/dv.c b/libavformat/dv.c
>>> index 3e0d12c0e3..26a78139f5 100644
>>> --- a/libavformat/dv.c
>>> +++ b/libavformat/dv.c
>>> @@ -49,7 +49,6 @@ struct DVDemuxContext {
>>>uint8_t   audio_buf[4][8192];
>>>int   ach;
>>>int   frames;
>>> -uint64_t  abytes;
>>> };
>>> static inline uint16_t dv_audio_12to16(uint16_t sample)
>>> @@ -258,7 +257,7 @@ static int dv_extract_audio_info(DVDemuxContext *c, 
>>> const uint8_t *frame)
>>>c->ast[i] = avformat_new_stream(c->fctx, NULL);
>>>if (!c->ast[i])
>>>break;
>>> -avpriv_set_pts_info(c->ast[i], 64, 1, 3);
>>> +avpriv_set_pts_info(c->ast[i], 64, c->sys->time_base.num, 
>>> c->sys->time_base.den);
>>>c->ast[i]->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
>>>c->ast[i]->codecpar->codec_id   = AV_CODEC_ID_PCM_S16LE;
>>> @@ -387,8 +386,7 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, 
>>> AVPacket *pkt,
>>>for (i = 0; i < c->ach; i++) {
>>>c->audio_pkt[i].pos  = pos;
>>>c->audio_pkt[i].size = size;
>>> -c->audio_pkt[i].pts  = c->abytes * 3 * 8 /
>>> -   c->ast[i]->codecpar->bit_rate;
>>> +c->audio_pkt[i].pts  = (c->sys->height == 720) ? (c->frames & ~1) 
>>> : c->frames;
>>>ppcm[i] = c->audio_buf[i];
>>>}
>>>if (c->ach)
>>> @@ -401,10 +399,7 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, 
>>> AVPacket *pkt,
>>>c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
>>>} else {
>>>c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
>>> -c->abytes   += size;
>>>}
>>> -} else {
>>> -c->abytes += size;
>>>}
>>> 
>>>/* Now it's time to return video packet */
>>> @@ -444,13 +439,6 @@ static int64_t dv_frame_offset(AVFormatContext *s, 
>>> DVDemuxContext *c,
>>> void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset)
>>> {
>>>c->frames = frame_offset;
>>> -if (c->ach) {
>>> -if (c->sys) {
>>> -c->abytes = av_rescale_q(c->frames, c->sys->time_base,
>>> - (AVRational) { 8, 
>>> c->ast[0]->codecpar->bit_rate });
>>> -} else
>>> -av_log(c->fctx, AV_LOG_ERROR, "cannot adjust audio bytes\n");
>>> -}
>>>c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
>>>c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
>>> }
>>> diff --git a/tests/ref/seek/lavf-dv b/tests/ref/seek/lavf-dv
>>> index 

Re: [FFmpeg-devel] [PATCH] avformat/dv: fix timestamps of audio packets in case of dropped corrupt audio frames

2020-10-31 Thread Marton Balint



On Sat, 31 Oct 2020, Dave Rice wrote:


Hi Marton,


On Oct 31, 2020, at 12:56 PM, Marton Balint  wrote:

Fixes out of sync timestamps in ticket #8762.


Although Michael’s recent patch does address the issue documented in 
8762, I haven’t found this patch to fix the issue. I tried with -c:a 
copy and with -c:a pcm_s16le with some sample files that exhibit this 
issue but each output was out of sync. I put an output at 
https://gist.github.com/dericed/659bd843bd38b6f24a60198b5e345795. That 
output notes that 3597 packages of video are read and 3586 packets of 
audio. In the resulting file, at the end of the timeline the audio is 9 
frames out of sync and my output video stream is 00:02:00.020 and output 
audio stream is 00:01:59.653.


Beyond copying or encoding the audio, are there other options I should 
use to test this?


Well, it depends on what you want. After this patch you should get a file 
which has audio packets synced to video, but the audio stream is sparse, 
not every video packet has a corresponding audio packet. (It looks like 
our MOV muxer does not support muxing of sparse audio therefore does not 
produce proper timestamps. But MKV does, please try that.)


You can also make ffmpeg generate the missing audio based on packet 
timestamps. Swresample has an async=1 option, so something like this 
should get you synced audio with continous audio packets:

ffmpeg -y -i 167052_12.dv -c:v copy \
-af aresample=async=1:min_hard_comp=0.01 -c:a pcm_s16le 167052_12.mov

Regards,
Marton





Signed-off-by: Marton Balint 
---
libavformat/dv.c   | 16 ++--
tests/ref/seek/lavf-dv | 18 +-
2 files changed, 11 insertions(+), 23 deletions(-)

diff --git a/libavformat/dv.c b/libavformat/dv.c
index 3e0d12c0e3..26a78139f5 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -49,7 +49,6 @@ struct DVDemuxContext {
uint8_t   audio_buf[4][8192];
int   ach;
int   frames;
-uint64_t  abytes;
};

static inline uint16_t dv_audio_12to16(uint16_t sample)
@@ -258,7 +257,7 @@ static int dv_extract_audio_info(DVDemuxContext *c, const 
uint8_t *frame)
c->ast[i] = avformat_new_stream(c->fctx, NULL);
if (!c->ast[i])
break;
-avpriv_set_pts_info(c->ast[i], 64, 1, 3);
+avpriv_set_pts_info(c->ast[i], 64, c->sys->time_base.num, 
c->sys->time_base.den);
c->ast[i]->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
c->ast[i]->codecpar->codec_id   = AV_CODEC_ID_PCM_S16LE;

@@ -387,8 +386,7 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket 
*pkt,
for (i = 0; i < c->ach; i++) {
c->audio_pkt[i].pos  = pos;
c->audio_pkt[i].size = size;
-c->audio_pkt[i].pts  = c->abytes * 3 * 8 /
-   c->ast[i]->codecpar->bit_rate;
+c->audio_pkt[i].pts  = (c->sys->height == 720) ? (c->frames & ~1) : 
c->frames;
ppcm[i] = c->audio_buf[i];
}
if (c->ach)
@@ -401,10 +399,7 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket 
*pkt,
c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
} else {
c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
-c->abytes   += size;
}
-} else {
-c->abytes += size;
}

/* Now it's time to return video packet */
@@ -444,13 +439,6 @@ static int64_t dv_frame_offset(AVFormatContext *s, 
DVDemuxContext *c,
void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset)
{
c->frames = frame_offset;
-if (c->ach) {
-if (c->sys) {
-c->abytes = av_rescale_q(c->frames, c->sys->time_base,
- (AVRational) { 8, 
c->ast[0]->codecpar->bit_rate });
-} else
-av_log(c->fctx, AV_LOG_ERROR, "cannot adjust audio bytes\n");
-}
c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
}
diff --git a/tests/ref/seek/lavf-dv b/tests/ref/seek/lavf-dv
index ff5abe..f63e4460be 100644
--- a/tests/ref/seek/lavf-dv
+++ b/tests/ref/seek/lavf-dv
@@ -7,9 +7,9 @@ ret: 0 st: 0 flags:0  ts: 0.80
ret: 0 st: 0 flags:1 dts: 0.80 pts: 0.80 pos:288 size:144000
ret: 0 st: 0 flags:1  ts:-0.32
ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:  0 size:144000
-ret: 0 st: 1 flags:0  ts: 2.576667
+ret: 0 st: 1 flags:0  ts: 2.56
ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3456000 size:144000
-ret: 0 st: 1 flags:1  ts: 1.470833
+ret: 0 st: 1 flags:1  ts: 1.48
ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3456000 size:144000
ret: 0 st:-1 flags:0  ts: 0.365002
ret: 0 st: 0 flags:1 dts: 0.36 pts: 0.36 pos:1296000 size:144000
@@ -19,9 +19,9 @@ ret: 0 st: 0 flags:0  ts: 2.16
ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 

Re: [FFmpeg-devel] [PATCH] avformat/dv: fix timestamps of audio packets in case of dropped corrupt audio frames

2020-10-31 Thread Carl Eugen Hoyos
Am Sa., 31. Okt. 2020 um 19:43 Uhr schrieb Dave Rice :
>
> Hi Marton,
>
> > On Oct 31, 2020, at 12:56 PM, Marton Balint  wrote:
> >
> > Fixes out of sync timestamps in ticket #8762.
>
> Although Michael’s recent patch does address the issue documented in 8762, I 
> haven’t found this patch to fix the issue. I tried with -c:a copy and with 
> -c:a pcm_s16le with some sample files that exhibit this issue but each output 
> was out of sync. I put an output at 
> https://gist.github.com/dericed/659bd843bd38b6f24a60198b5e345795. That output 
> notes that 3597 packages of video are read and 3586 packets of audio. In the 
> resulting file, at the end of the timeline the audio is 9 frames out of sync 
> and my output video stream is 00:02:00.020 and output audio stream is 
> 00:01:59.653.
>
> Beyond copying or encoding the audio, are there other options I should use to 
> test this?

Maybe I misunderstand the issue but if audio is missing and you don't
re-encode (and
force the missing audio to be inserted), you will always run into
issues because of how
audio is generally interpreted in multimedia files.

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

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

Re: [FFmpeg-devel] [PATCH] avformat/dv: fix timestamps of audio packets in case of dropped corrupt audio frames

2020-10-31 Thread Dave Rice
Hi Marton,

> On Oct 31, 2020, at 12:56 PM, Marton Balint  wrote:
> 
> Fixes out of sync timestamps in ticket #8762.

Although Michael’s recent patch does address the issue documented in 8762, I 
haven’t found this patch to fix the issue. I tried with -c:a copy and with -c:a 
pcm_s16le with some sample files that exhibit this issue but each output was 
out of sync. I put an output at 
https://gist.github.com/dericed/659bd843bd38b6f24a60198b5e345795. That output 
notes that 3597 packages of video are read and 3586 packets of audio. In the 
resulting file, at the end of the timeline the audio is 9 frames out of sync 
and my output video stream is 00:02:00.020 and output audio stream is 
00:01:59.653.

Beyond copying or encoding the audio, are there other options I should use to 
test this?

> Signed-off-by: Marton Balint 
> ---
> libavformat/dv.c   | 16 ++--
> tests/ref/seek/lavf-dv | 18 +-
> 2 files changed, 11 insertions(+), 23 deletions(-)
> 
> diff --git a/libavformat/dv.c b/libavformat/dv.c
> index 3e0d12c0e3..26a78139f5 100644
> --- a/libavformat/dv.c
> +++ b/libavformat/dv.c
> @@ -49,7 +49,6 @@ struct DVDemuxContext {
> uint8_t   audio_buf[4][8192];
> int   ach;
> int   frames;
> -uint64_t  abytes;
> };
> 
> static inline uint16_t dv_audio_12to16(uint16_t sample)
> @@ -258,7 +257,7 @@ static int dv_extract_audio_info(DVDemuxContext *c, const 
> uint8_t *frame)
> c->ast[i] = avformat_new_stream(c->fctx, NULL);
> if (!c->ast[i])
> break;
> -avpriv_set_pts_info(c->ast[i], 64, 1, 3);
> +avpriv_set_pts_info(c->ast[i], 64, c->sys->time_base.num, 
> c->sys->time_base.den);
> c->ast[i]->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
> c->ast[i]->codecpar->codec_id   = AV_CODEC_ID_PCM_S16LE;
> 
> @@ -387,8 +386,7 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket 
> *pkt,
> for (i = 0; i < c->ach; i++) {
> c->audio_pkt[i].pos  = pos;
> c->audio_pkt[i].size = size;
> -c->audio_pkt[i].pts  = c->abytes * 3 * 8 /
> -   c->ast[i]->codecpar->bit_rate;
> +c->audio_pkt[i].pts  = (c->sys->height == 720) ? (c->frames & ~1) : 
> c->frames;
> ppcm[i] = c->audio_buf[i];
> }
> if (c->ach)
> @@ -401,10 +399,7 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket 
> *pkt,
> c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
> } else {
> c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
> -c->abytes   += size;
> }
> -} else {
> -c->abytes += size;
> }
> 
> /* Now it's time to return video packet */
> @@ -444,13 +439,6 @@ static int64_t dv_frame_offset(AVFormatContext *s, 
> DVDemuxContext *c,
> void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset)
> {
> c->frames = frame_offset;
> -if (c->ach) {
> -if (c->sys) {
> -c->abytes = av_rescale_q(c->frames, c->sys->time_base,
> - (AVRational) { 8, 
> c->ast[0]->codecpar->bit_rate });
> -} else
> -av_log(c->fctx, AV_LOG_ERROR, "cannot adjust audio bytes\n");
> -}
> c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
> c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
> }
> diff --git a/tests/ref/seek/lavf-dv b/tests/ref/seek/lavf-dv
> index ff5abe..f63e4460be 100644
> --- a/tests/ref/seek/lavf-dv
> +++ b/tests/ref/seek/lavf-dv
> @@ -7,9 +7,9 @@ ret: 0 st: 0 flags:0  ts: 0.80
> ret: 0 st: 0 flags:1 dts: 0.80 pts: 0.80 pos:288 
> size:144000
> ret: 0 st: 0 flags:1  ts:-0.32
> ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:  0 
> size:144000
> -ret: 0 st: 1 flags:0  ts: 2.576667
> +ret: 0 st: 1 flags:0  ts: 2.56
> ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3456000 
> size:144000
> -ret: 0 st: 1 flags:1  ts: 1.470833
> +ret: 0 st: 1 flags:1  ts: 1.48
> ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3456000 
> size:144000
> ret: 0 st:-1 flags:0  ts: 0.365002
> ret: 0 st: 0 flags:1 dts: 0.36 pts: 0.36 pos:1296000 
> size:144000
> @@ -19,9 +19,9 @@ ret: 0 st: 0 flags:0  ts: 2.16
> ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3456000 
> size:144000
> ret: 0 st: 0 flags:1  ts: 1.04
> ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3456000 
> size:144000
> -ret: 0 st: 1 flags:0  ts:-0.058333
> +ret: 0 st: 1 flags:0  ts:-0.04
> ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:  0 
> size:144000
> -ret: 0 st: 1 flags:1  ts: 2.835833
> +ret: 0 st: 1 flags:1  ts: 2.84
> ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3456000 
> size:144000
> ret: 0 st:-1 flags:0  ts: 

Re: [FFmpeg-devel] [PATCH] swscale/x86/yuv2rgb: fix crashes when loading alpha from unaligned buffers

2020-10-31 Thread Marton Balint



On Wed, 28 Oct 2020, Marton Balint wrote:


Regression since fc6a5883d6af8cae0e96af84dda0ad74b360a084 on SSSE3 enabled
CPUs.

Fixes ticket #8955.

Signed-off-by: Marton Balint 
---
libswscale/x86/yuv_2_rgb.asm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libswscale/x86/yuv_2_rgb.asm b/libswscale/x86/yuv_2_rgb.asm
index 003dff1f25..2f0b4130df 100644
--- a/libswscale/x86/yuv_2_rgb.asm
+++ b/libswscale/x86/yuv_2_rgb.asm
@@ -286,7 +286,7 @@ cglobal %1_420_%2%3, GPR_num, GPR_num, reg_num, parameters
%ifidn %1, yuv
pcmpeqd m3, m3 ; Set alpha empty
%else
-mova m3, [pa_2indexq + 2 * indexq] ; Load alpha
+movu m3, [pa_2indexq + 2 * indexq] ; Load alpha
%endif
mova m5, m_blue
mova m6, m_red


Will apply...

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

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

[FFmpeg-devel] [PATCH] avformat/dv: fix timestamps of audio packets in case of dropped corrupt audio frames

2020-10-31 Thread Marton Balint
Fixes out of sync timestamps in ticket #8762.

Signed-off-by: Marton Balint 
---
 libavformat/dv.c   | 16 ++--
 tests/ref/seek/lavf-dv | 18 +-
 2 files changed, 11 insertions(+), 23 deletions(-)

diff --git a/libavformat/dv.c b/libavformat/dv.c
index 3e0d12c0e3..26a78139f5 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -49,7 +49,6 @@ struct DVDemuxContext {
 uint8_t   audio_buf[4][8192];
 int   ach;
 int   frames;
-uint64_t  abytes;
 };
 
 static inline uint16_t dv_audio_12to16(uint16_t sample)
@@ -258,7 +257,7 @@ static int dv_extract_audio_info(DVDemuxContext *c, const 
uint8_t *frame)
 c->ast[i] = avformat_new_stream(c->fctx, NULL);
 if (!c->ast[i])
 break;
-avpriv_set_pts_info(c->ast[i], 64, 1, 3);
+avpriv_set_pts_info(c->ast[i], 64, c->sys->time_base.num, 
c->sys->time_base.den);
 c->ast[i]->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
 c->ast[i]->codecpar->codec_id   = AV_CODEC_ID_PCM_S16LE;
 
@@ -387,8 +386,7 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket 
*pkt,
 for (i = 0; i < c->ach; i++) {
 c->audio_pkt[i].pos  = pos;
 c->audio_pkt[i].size = size;
-c->audio_pkt[i].pts  = c->abytes * 3 * 8 /
-   c->ast[i]->codecpar->bit_rate;
+c->audio_pkt[i].pts  = (c->sys->height == 720) ? (c->frames & ~1) : 
c->frames;
 ppcm[i] = c->audio_buf[i];
 }
 if (c->ach)
@@ -401,10 +399,7 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket 
*pkt,
 c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
 } else {
 c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
-c->abytes   += size;
 }
-} else {
-c->abytes += size;
 }
 
 /* Now it's time to return video packet */
@@ -444,13 +439,6 @@ static int64_t dv_frame_offset(AVFormatContext *s, 
DVDemuxContext *c,
 void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset)
 {
 c->frames = frame_offset;
-if (c->ach) {
-if (c->sys) {
-c->abytes = av_rescale_q(c->frames, c->sys->time_base,
- (AVRational) { 8, 
c->ast[0]->codecpar->bit_rate });
-} else
-av_log(c->fctx, AV_LOG_ERROR, "cannot adjust audio bytes\n");
-}
 c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
 c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
 }
diff --git a/tests/ref/seek/lavf-dv b/tests/ref/seek/lavf-dv
index ff5abe..f63e4460be 100644
--- a/tests/ref/seek/lavf-dv
+++ b/tests/ref/seek/lavf-dv
@@ -7,9 +7,9 @@ ret: 0 st: 0 flags:0  ts: 0.80
 ret: 0 st: 0 flags:1 dts: 0.80 pts: 0.80 pos:288 
size:144000
 ret: 0 st: 0 flags:1  ts:-0.32
 ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:  0 
size:144000
-ret: 0 st: 1 flags:0  ts: 2.576667
+ret: 0 st: 1 flags:0  ts: 2.56
 ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3456000 
size:144000
-ret: 0 st: 1 flags:1  ts: 1.470833
+ret: 0 st: 1 flags:1  ts: 1.48
 ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3456000 
size:144000
 ret: 0 st:-1 flags:0  ts: 0.365002
 ret: 0 st: 0 flags:1 dts: 0.36 pts: 0.36 pos:1296000 
size:144000
@@ -19,9 +19,9 @@ ret: 0 st: 0 flags:0  ts: 2.16
 ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3456000 
size:144000
 ret: 0 st: 0 flags:1  ts: 1.04
 ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3456000 
size:144000
-ret: 0 st: 1 flags:0  ts:-0.058333
+ret: 0 st: 1 flags:0  ts:-0.04
 ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:  0 
size:144000
-ret: 0 st: 1 flags:1  ts: 2.835833
+ret: 0 st: 1 flags:1  ts: 2.84
 ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3456000 
size:144000
 ret: 0 st:-1 flags:0  ts: 1.730004
 ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3456000 
size:144000
@@ -31,10 +31,10 @@ ret: 0 st: 0 flags:0  ts:-0.48
 ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:  0 
size:144000
 ret: 0 st: 0 flags:1  ts: 2.40
 ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3456000 
size:144000
-ret: 0 st: 1 flags:0  ts: 1.306667
-ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3456000 
size:144000
-ret: 0 st: 1 flags:1  ts: 0.200833
+ret: 0 st: 1 flags:0  ts: 1.32
 ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3456000 
size:144000
+ret: 0 st: 1 flags:1  ts: 0.20
+ret: 0 st: 0 flags:1 dts: 0.20 pts: 0.20 pos: 72 
size:144000
 ret: 0 st:-1 flags:0  ts:-0.904994
 ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:  0 
size:144000
 

Re: [FFmpeg-devel] [PATCH] avformat/dv: allow returning damaged audio

2020-10-31 Thread Marton Balint



On Sat, 31 Oct 2020, Carl Eugen Hoyos wrote:


Am Do., 29. Okt. 2020 um 22:59 Uhr schrieb Michael Niedermayer
:


+static const AVOption dv_options[] = {
+{ "dvaudio_concealment", "", OFFSET(dvaudio_concealment), AV_OPT_TYPE_INT  , {.i64 = 
AUDIO_CONCEAL_DROP}, 0, INT_MAX, DEC, "dvaudio_concealment"},
+{ "drop","", 0  , AV_OPT_TYPE_CONST, {.i64 = 
AUDIO_CONCEAL_DROP}, 0, INT_MAX, DEC, "dvaudio_concealment"},
+{ "pass","", 0  , AV_OPT_TYPE_CONST, {.i64 = 
AUDIO_CONCEAL_PASS}, 0, INT_MAX, DEC, "dvaudio_concealment"},


Am I correct that the current lavc option "ec" only works for video?

Shouldn't its documentation be extended so it also works for audio
(to avoid adding a new option)?


This is demuxer not decoder, so ec cannot be used.

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

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

Re: [FFmpeg-devel] [PATCH] avformat/dv: allow returning damaged audio

2020-10-31 Thread Marton Balint



On Thu, 29 Oct 2020, Michael Niedermayer wrote:


These potentially damaged packets are marked as corrupt.
The packet length is predicted based on packet length history,
allowing prediction of the common pattern used in NTSC.

Fixes: Ticket8762


Sync loss is because of invalid timestamps, this is a possible workaround 
for the ticket ignoring the core problem. I will post a patch to fix the 
timestamps, it does not seem hard.


Regards,
Marton



Tested-by: Dave Rice 
Signed-off-by: Michael Niedermayer 
---
libavformat/dv.c | 60 ++--
1 file changed, 53 insertions(+), 7 deletions(-)

diff --git a/libavformat/dv.c b/libavformat/dv.c
index 3e0d12c0e3..3499cba6f8 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -34,12 +34,20 @@
#include "libavcodec/dv_profile.h"
#include "libavcodec/dv.h"
#include "libavutil/channel_layout.h"
+#include "libavutil/opt.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mathematics.h"
#include "libavutil/timecode.h"
#include "dv.h"
#include "libavutil/avassert.h"

+#define AS_HASH_SIZE 16
+
+enum AudioConceal {
+AUDIO_CONCEAL_PASS = 1,
+AUDIO_CONCEAL_DROP = 0,
+};
+
struct DVDemuxContext {
const AVDVProfile*  sys;/* Current DV profile. E.g.: 525/60, 625/50 */
AVFormatContext*  fctx;
@@ -50,6 +58,9 @@ struct DVDemuxContext {
int   ach;
int   frames;
uint64_t  abytes;
+uint8_t   as_pack[AS_HASH_SIZE][5];
+uint8_t   as_hash;
+int   dvaudio_concealment;
};

static inline uint16_t dv_audio_12to16(uint16_t sample)
@@ -72,7 +83,7 @@ static inline uint16_t dv_audio_12to16(uint16_t sample)
return result;
}

-static const uint8_t *dv_extract_pack(const uint8_t *frame, enum dv_pack_type 
t)
+static const uint8_t *dv_extract_pack(DVDemuxContext *d, const uint8_t *frame, 
enum dv_pack_type t)
{
int offs;
int c;
@@ -101,6 +112,17 @@ static const uint8_t *dv_extract_pack(const uint8_t 
*frame, enum dv_pack_type t)
break;
}

+if (t == dv_audio_source || t == dv_audio_control) {
+int index = (d->as_hash>>1) & (AS_HASH_SIZE-1);
+if (frame[offs] == t) {
+memcpy(d->as_pack[index], [offs], sizeof(d->as_pack[index]));
+} else if (d->as_pack[index][0] && d->dvaudio_concealment == 
AUDIO_CONCEAL_PASS) {
+return d->as_pack[index];
+} else if (d->as_pack[0][0] && d->dvaudio_concealment == 
AUDIO_CONCEAL_PASS) {
+return d->as_pack[0];
+}
+}
+
return frame[offs] == t ? [offs] : NULL;
}

@@ -116,7 +138,7 @@ static const int dv_audio_frequency[3] = {
 * 3. Audio is always returned as 16-bit linear samples: 12-bit nonlinear 
samples
 *are converted into 16-bit linear ones.
 */
-static int dv_extract_audio(const uint8_t *frame, uint8_t **ppcm,
+static int dv_extract_audio(DVDemuxContext *c, const uint8_t *frame, uint8_t 
**ppcm,
const AVDVProfile *sys)
{
int size, chan, i, j, d, of, smpls, freq, quant, half_ch;
@@ -124,7 +146,7 @@ static int dv_extract_audio(const uint8_t *frame, uint8_t 
**ppcm,
const uint8_t *as_pack;
uint8_t *pcm, ipcm;

-as_pack = dv_extract_pack(frame, dv_audio_source);
+as_pack = dv_extract_pack(c, frame, dv_audio_source);
if (!as_pack)/* No audio ? */
return 0;

@@ -137,6 +159,7 @@ static int dv_extract_audio(const uint8_t *frame, uint8_t 
**ppcm,

if (freq >= FF_ARRAY_ELEMS(dv_audio_frequency))
return AVERROR_INVALIDDATA;
+c->as_hash = 2*c->as_hash + smpls;

size= (sys->audio_min_samples[freq] + smpls) * 4; /* 2ch, 2bytes */
half_ch = sys->difseg_size / 2;
@@ -153,6 +176,9 @@ static int dv_extract_audio(const uint8_t *frame, uint8_t 
**ppcm,
/* for each DIF channel */
for (chan = 0; chan < sys->n_difchan; chan++) {
av_assert0(ipcm<4);
+c->audio_pkt[ipcm].flags &= ~AV_PKT_FLAG_CORRUPT;
+if (as_pack >= c->as_pack[0] && as_pack < c->as_pack[AS_HASH_SIZE])
+c->audio_pkt[ipcm].flags |= AV_PKT_FLAG_CORRUPT;
pcm = ppcm[ipcm++];
if (!pcm)
break;
@@ -224,7 +250,7 @@ static int dv_extract_audio_info(DVDemuxContext *c, const 
uint8_t *frame)
const uint8_t *as_pack;
int freq, stype, smpls, quant, i, ach;

-as_pack = dv_extract_pack(frame, dv_audio_source);
+as_pack = dv_extract_pack(c, frame, dv_audio_source);
if (!as_pack || !c->sys) {/* No audio ? */
c->ach = 0;
return 0;
@@ -292,7 +318,7 @@ static int dv_extract_video_info(DVDemuxContext *c, const 
uint8_t *frame)
c->vst->avg_frame_rate = av_inv_q(c->vst->time_base);

/* finding out SAR is a little bit messy */
-vsc_pack = dv_extract_pack(frame, dv_video_control);
+vsc_pack = dv_extract_pack(c, frame, dv_video_control);
apt  = frame[4] & 0x07;
is16_9   = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 ||
 (!apt 

[FFmpeg-devel] [PATCH] avcodec/cbs_av1: infer ref_order_hint when not coded in the bitstream

2020-10-31 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/cbs_av1_syntax_template.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavcodec/cbs_av1_syntax_template.c 
b/libavcodec/cbs_av1_syntax_template.c
index f351b1de24..dc3d8d1048 100644
--- a/libavcodec/cbs_av1_syntax_template.c
+++ b/libavcodec/cbs_av1_syntax_template.c
@@ -1490,13 +1490,19 @@ static int 
FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw,
 fb(8, refresh_frame_flags);
 
 if (!frame_is_intra || current->refresh_frame_flags != all_frames) {
-if (current->error_resilient_mode && seq->enable_order_hint) {
+if (seq->enable_order_hint) {
 for (i = 0; i < AV1_NUM_REF_FRAMES; i++) {
-fbs(order_hint_bits, ref_order_hint[i], 1, i);
+if (current->error_resilient_mode)
+fbs(order_hint_bits, ref_order_hint[i], 1, i);
+else
+infer(ref_order_hint[i], priv->ref[i].order_hint);
 if (current->ref_order_hint[i] != priv->ref[i].order_hint)
 priv->ref[i].valid = 0;
 }
 }
+} else if (seq->enable_order_hint) {
+for (i = 0; i < AV1_NUM_REF_FRAMES; i++)
+infer(ref_order_hint[i], priv->ref[i].order_hint);
 }
 
 if (current->frame_type == AV1_FRAME_KEY ||
-- 
2.29.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 2/2] avformat/apngdec: Check for incomplete reads in append_extradata()

2020-10-31 Thread Andreas Rheinhardt
Michael Niedermayer:
> Fixes: OOM
> Fixes: 
> 26608/clusterfuzz-testcase-minimized-ffmpeg_dem_APNG_fuzzer-4839491644424192
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/apngdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/apngdec.c b/libavformat/apngdec.c
> index 0f1d04a365..4e1d21031f 100644
> --- a/libavformat/apngdec.c
> +++ b/libavformat/apngdec.c
> @@ -138,7 +138,7 @@ static int append_extradata(AVCodecParameters *par, 
> AVIOContext *pb, int len)
>  par->extradata = new_extradata;
>  par->extradata_size = new_size;
>  
> -if ((ret = avio_read(pb, par->extradata + previous_size, len)) < 0)
> +if ((ret = ffio_read_size(pb, par->extradata + previous_size, len)) < 0)
>  return ret;
>  
>  return previous_size;
> 
There is a second avio_read() call that does not check whether it has
read all it wanted. It can not really lead to OOM (as the extradata size
in this case is 29), but it is not nice to not return an error in this
case. I therefore resurrected my old patchset:
https://ffmpeg.org/pipermail/ffmpeg-devel/2020-October/271779.html

- 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] Ticket #8750 Add inline function for the vec_xl intrinsic in non-VSX environments

2020-10-31 Thread Andriy Gelman
On Fri, 16. Oct 00:02, Andriy Gelman wrote:
> On Fri, 09. Oct 20:17, Andriy Gelman wrote:
> > From: Chip Kerchner 
> > 
> > ---
> >  libswscale/ppc/yuv2rgb_altivec.c | 10 ++
> >  1 file changed, 10 insertions(+)
> > 
> > diff --git a/libswscale/ppc/yuv2rgb_altivec.c 
> > b/libswscale/ppc/yuv2rgb_altivec.c
> > index 536545293d..930ef6b98f 100644
> > --- a/libswscale/ppc/yuv2rgb_altivec.c
> > +++ b/libswscale/ppc/yuv2rgb_altivec.c
> > @@ -283,6 +283,16 @@ static inline void cvtyuvtoRGB(SwsContext *c, vector 
> > signed short Y,
> >   * 
> > --
> >   */
> >  
> > +#if !HAVE_VSX
> > +static inline vector unsigned char vec_xl(signed long long offset, const 
> > ubyte *addr)
> > +{
> > +const vector unsigned char *v_addr = (const vector unsigned char *) 
> > (addr + offset);
> > +vector unsigned char align_perm = vec_lvsl(offset, addr);
> > +
> > +return (vector unsigned char) vec_perm(v_addr[0], v_addr[1], 
> > align_perm);
> > +}
> > +#endif /* !HAVE_VSX */
> > +
> >  #define DEFCSP420_CVT(name, out_pixels)
> >\
> >  static int altivec_ ## name(SwsContext *c, const unsigned char **in,   
> >\
> >  int *instrides, int srcSliceY, int srcSliceH,  
> >\
> 
> Ping.
> This patch fixes PPC64 build on patchwork.
> 

ping

-- 
Andriy
___
ffmpeg-devel mailing list
ffmpeg-devel@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] avformat/apngdec: Remove goto fail that does nothing

2020-10-31 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/apngdec.c | 32 
 1 file changed, 12 insertions(+), 20 deletions(-)

diff --git a/libavformat/apngdec.c b/libavformat/apngdec.c
index 6b2ce2e251..bf8343faf3 100644
--- a/libavformat/apngdec.c
+++ b/libavformat/apngdec.c
@@ -151,17 +151,17 @@ static int apng_read_header(AVFormatContext *s)
 uint32_t len, tag;
 AVStream *st;
 int acTL_found = 0;
-int64_t ret = AVERROR_INVALIDDATA;
+int64_t ret;
 
 /* verify PNGSIG */
 if (avio_rb64(pb) != PNGSIG)
-return ret;
+return AVERROR_INVALIDDATA;
 
 /* parse IHDR (must be first chunk) */
 len = avio_rb32(pb);
 tag = avio_rl32(pb);
 if (len != 13 || tag != MKTAG('I', 'H', 'D', 'R'))
-return ret;
+return AVERROR_INVALIDDATA;
 
 st = avformat_new_stream(s, NULL);
 if (!st)
@@ -193,11 +193,9 @@ static int apng_read_header(AVFormatContext *s)
 int64_t size   = avio_size(pb);
 int64_t offset = avio_tell(pb);
 if (size < 0) {
-ret = size;
-goto fail;
+return size;
 } else if (offset < 0) {
-ret = offset;
-goto fail;
+return offset;
 } else if ((ret = ffio_ensure_seekback(pb, size - offset)) < 0) {
 av_log(s, AV_LOG_WARNING, "Could not ensure seekback, will not 
loop\n");
 ctx->num_play = 1;
@@ -205,20 +203,18 @@ static int apng_read_header(AVFormatContext *s)
 }
 if ((ctx->num_play == 1 || !acTL_found) &&
 ((ret = ffio_ensure_seekback(pb, 4 /* len */ + 4 /* tag */)) < 0))
-goto fail;
+return ret;
 
 len = avio_rb32(pb);
-if (len > INT_MAX - 12) {
-ret = AVERROR_INVALIDDATA;
-goto fail;
-}
+if (len > INT_MAX - 12)
+return AVERROR_INVALIDDATA;
 
 tag = avio_rl32(pb);
 switch (tag) {
 case MKTAG('a', 'c', 'T', 'L'):
 if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0 ||
 (ret = append_extradata(st->codecpar, pb, len + 12)) < 0)
-goto fail;
+return ret;
 acTL_found = 1;
 ctx->num_frames = AV_RB32(st->codecpar->extradata + ret + 8);
 ctx->num_play   = AV_RB32(st->codecpar->extradata + ret + 12);
@@ -227,21 +223,17 @@ static int apng_read_header(AVFormatContext *s)
 break;
 case MKTAG('f', 'c', 'T', 'L'):
 if (!acTL_found || len != 26) {
-   ret = AVERROR_INVALIDDATA;
-   goto fail;
+return AVERROR_INVALIDDATA;
 }
 if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0)
-goto fail;
+return ret;
 return 0;
 default:
 if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0 ||
 (ret = append_extradata(st->codecpar, pb, len + 12)) < 0)
-goto fail;
+return ret;
 }
 }
-
-fail:
-return ret;
 }
 
 static int decode_fctl_chunk(AVFormatContext *s, APNGDemuxContext *ctx, 
AVPacket *pkt)
-- 
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 v3 3/4] avformat/apngdec: Check fcTL chunk length when reading header

2020-10-31 Thread Andreas Rheinhardt
Reading the header terminates when an fcTL chunk is encountered in which
case read_header returned success without checking the length of said
chunk. Yet when read_packet processes this chunk, it checks for the
length to be 26 and errors out otherwise. So do so when reading the header,
too.

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

diff --git a/libavformat/apngdec.c b/libavformat/apngdec.c
index d8d0de190f..6b2ce2e251 100644
--- a/libavformat/apngdec.c
+++ b/libavformat/apngdec.c
@@ -226,7 +226,7 @@ static int apng_read_header(AVFormatContext *s)
 ctx->num_frames, ctx->num_play);
 break;
 case MKTAG('f', 'c', 'T', 'L'):
-if (!acTL_found) {
+if (!acTL_found || len != 26) {
ret = AVERROR_INVALIDDATA;
goto fail;
 }
-- 
2.25.1

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

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

Re: [FFmpeg-devel] [PATCH] avformat/rtsp: don't overwrite session control uri

2020-10-31 Thread Andriy Gelman
On Wed, 21. Oct 13:39, Andriy Gelman wrote:
> On Sat, 10. Oct 19:22, Andriy Gelman wrote:
> > From: Andriy Gelman 
> > 
> > Fixes #1941
> > 
> > Currently the session control uri gets overwritten by the media's uri
> > when mpegts is signalled in the media description. This happens because
> > s->nb_streams doesn't count mpegts which is instead part of the private
> > context in RTSPStream.
> > 
> > Instead use rt->nb_rtsp_streams which counts all of the media streams
> > signalled in the sdp.
> > 
> > This solution was originally proposed by user "tpol" on trac:
> > https://trac.ffmpeg.org/ticket/1941
> > 
> > Signed-off-by: Andriy Gelman 
> > ---
> >  libavformat/rtsp.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> > index e9fca034b4..4d5459ac41 100644
> > --- a/libavformat/rtsp.c
> > +++ b/libavformat/rtsp.c
> > @@ -542,7 +542,7 @@ static void sdp_parse_line(AVFormatContext *s, 
> > SDPParseState *s1,
> >  break;
> >  case 'a':
> >  if (av_strstart(p, "control:", )) {
> > -if (s->nb_streams == 0) {
> > +if (rt->nb_rtsp_streams == 0) {
> >  if (!strncmp(p, "rtsp://", 7))
> >  av_strlcpy(rt->control_uri, p,
> > sizeof(rt->control_uri));
> > -- 
> > 2.28.0
> > 
> 
> ping
> 

ping
Will apply this Monday if no one objects.

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

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

Re: [FFmpeg-devel] [PATCH 1/2] libavformat/aviobuf: Forward error from avio_read in ffio_read_size()

2020-10-31 Thread Andreas Rheinhardt
Michael Niedermayer:
> Suggested-by: Andreas Rheinhardt
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/aviobuf.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
> index 80a5a565a4..3cc440e4e7 100644
> --- a/libavformat/aviobuf.c
> +++ b/libavformat/aviobuf.c
> @@ -686,6 +686,8 @@ int avio_read(AVIOContext *s, unsigned char *buf, int 
> size)
>  int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
>  {
>  int ret = avio_read(s, buf, size);
> +if (ret < 0 && ret != AVERROR_EOF)
> +return ret;
>  if (ret != size)
>  return AVERROR_INVALIDDATA;
>  return ret;
> 
Maybe first check for ret == size. After all, that is supposed to be the
common case.

- 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 v3 2/4] avformat/apngdec: Fix size/overflow checks

2020-10-31 Thread Andreas Rheinhardt
apng data consists of parts containing a small header (including a
four-byte size field) and a data part; the size field does not account
for everything and is actually twelve bytes short of the actual size. In
order to make sure that the size fits into an int, the size field is
checked for being > INT_MAX; yet this does not account for the + 12 and
upon conversion to int (which happens when calling append_extradata()),
the size parameter can still wrap around. In this case the currently
used check would lead to undefined signed integer overflow.

Furthermore, append_extradata() appends the new data to the already
existing extradata and therefore needs to make sure that the combined
size of new and old data as well as padding fits into an int. The check
used for this is "if (old_size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE -
new_size)". If new_size is > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE
the right side becomes negative if the types are signed (as they are
now); yet changing this to "if (new_size > INT_MAX -
AV_INPUT_BUFFER_PADDING_SIZE - old_size)" is better as this also works
for unsigned types (where it is of course presumed that INT_MAX is
replaced by the corresponding maximum for the new type).

Both of these issues have been fixed.

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

diff --git a/libavformat/apngdec.c b/libavformat/apngdec.c
index 23d7e15393..d8d0de190f 100644
--- a/libavformat/apngdec.c
+++ b/libavformat/apngdec.c
@@ -127,7 +127,7 @@ static int append_extradata(AVCodecParameters *par, 
AVIOContext *pb, int len)
 int new_size, ret;
 uint8_t *new_extradata;
 
-if (previous_size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE - len)
+if (len > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE - previous_size)
 return AVERROR_INVALIDDATA;
 
 new_size = previous_size + len;
@@ -208,7 +208,7 @@ static int apng_read_header(AVFormatContext *s)
 goto fail;
 
 len = avio_rb32(pb);
-if (len > 0x7fff) {
+if (len > INT_MAX - 12) {
 ret = AVERROR_INVALIDDATA;
 goto fail;
 }
-- 
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 v3 1/4] avformat/apngdec: Return error for incomplete header

2020-10-31 Thread Andreas Rheinhardt
If avio_read() could read anything, it returns the number of bytes read,
even if it could not read as much as the caller desired.
apng_read_header() only checked the return value of its avio_read() calls
for being negative and this meant that it was possible for an incomplete
header to not be detected. The return value of the last successfull call
has been returned instead. This commit changes this.

Fixes: OOM
Fixes: 
26608/clusterfuzz-testcase-minimized-ffmpeg_dem_APNG_fuzzer-4839491644424192

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

diff --git a/libavformat/apngdec.c b/libavformat/apngdec.c
index 0f1d04a365..23d7e15393 100644
--- a/libavformat/apngdec.c
+++ b/libavformat/apngdec.c
@@ -138,7 +138,7 @@ static int append_extradata(AVCodecParameters *par, 
AVIOContext *pb, int len)
 par->extradata = new_extradata;
 par->extradata_size = new_size;
 
-if ((ret = avio_read(pb, par->extradata + previous_size, len)) < 0)
+if ((ret = ffio_read_size(pb, par->extradata + previous_size, len)) < 0)
 return ret;
 
 return previous_size;
@@ -185,10 +185,10 @@ static int apng_read_header(AVFormatContext *s)
 AV_WL32(st->codecpar->extradata+4,  tag);
 AV_WB32(st->codecpar->extradata+8,  st->codecpar->width);
 AV_WB32(st->codecpar->extradata+12, st->codecpar->height);
-if ((ret = avio_read(pb, st->codecpar->extradata+16, 9)) < 0)
-goto fail;
+if ((ret = ffio_read_size(pb, st->codecpar->extradata + 16, 9)) < 0)
+return ret;
 
-while (!avio_feof(pb)) {
+while (1) {
 if (acTL_found && ctx->num_play != 1) {
 int64_t size   = avio_size(pb);
 int64_t offset = avio_tell(pb);
-- 
2.25.1

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

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

Re: [FFmpeg-devel] [PATCH v3] Add support for playing Audible AAXC (.aaxc) files

2020-10-31 Thread Carl Eugen Hoyos
Am Mi., 8. Apr. 2020 um 05:59 Uhr schrieb Vesselin Bontchev
:

> +static int mov_aaxc_crypto(MOVContext *c)

This function does return error codes in some cases
but they are ignored in the calling function.

> +fail:
> +
> +return ret;

This does not look like a useful hunk to me, use a
fail block if cleanup is necessary.

The comments in the function do not look useful to me.

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

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

Re: [FFmpeg-devel] [PATCH] avformat/dv: allow returning damaged audio

2020-10-31 Thread Carl Eugen Hoyos
Am Do., 29. Okt. 2020 um 22:59 Uhr schrieb Michael Niedermayer
:

> +static const AVOption dv_options[] = {
> +{ "dvaudio_concealment", "", OFFSET(dvaudio_concealment), 
> AV_OPT_TYPE_INT  , {.i64 = AUDIO_CONCEAL_DROP}, 0, INT_MAX, DEC, 
> "dvaudio_concealment"},
> +{ "drop","", 0  , 
> AV_OPT_TYPE_CONST, {.i64 = AUDIO_CONCEAL_DROP}, 0, INT_MAX, DEC, 
> "dvaudio_concealment"},
> +{ "pass","", 0  , 
> AV_OPT_TYPE_CONST, {.i64 = AUDIO_CONCEAL_PASS}, 0, INT_MAX, DEC, 
> "dvaudio_concealment"},

Am I correct that the current lavc option "ec" only works for video?

Shouldn't its documentation be extended so it also works for audio
(to avoid adding a new option)?

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

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

Re: [FFmpeg-devel] [PATCH] Moves yuv2yuvX_sse3 to yasm, unrolls main loop and other small optimizations for ~20% speedup.

2020-10-31 Thread Carl Eugen Hoyos
Am Di., 27. Okt. 2020 um 09:56 Uhr schrieb Alan Kelly
:

> --- /dev/null
> +++ b/libswscale/x86/yuv2yuvX.asm
> @@ -0,0 +1,105 @@
> +;**
> +;* x86-optimized yuv2yuvX
> +;* Copyright 2020 Google LLC

Either the commit message ("move a function") or this
copyright statement is wrong, please fix this.

Please do not commit as-is...

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

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

Re: [FFmpeg-devel] [PATCH 1/4] avformat/apngdec: Check for incomplete reads in append_extradata()

2020-10-31 Thread Michael Niedermayer
On Fri, Oct 30, 2020 at 11:48:11PM +0100, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > On Thu, Oct 29, 2020 at 02:25:49PM +0100, Andreas Rheinhardt wrote:
> >> Michael Niedermayer:
> >>> Fixes: OOM
> >>> Fixes: 
> >>> 26608/clusterfuzz-testcase-minimized-ffmpeg_dem_APNG_fuzzer-4839491644424192
> >>>
> >>> Found-by: continuous fuzzing process 
> >>> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> >>> Signed-off-by: Michael Niedermayer 
> >>> ---
> >>>  libavformat/apngdec.c | 2 ++
> >>>  1 file changed, 2 insertions(+)
> >>>
> >>> diff --git a/libavformat/apngdec.c b/libavformat/apngdec.c
> >>> index 0f1d04a365..2e79fdd85c 100644
> >>> --- a/libavformat/apngdec.c
> >>> +++ b/libavformat/apngdec.c
> >>> @@ -140,6 +140,8 @@ static int append_extradata(AVCodecParameters *par, 
> >>> AVIOContext *pb, int len)
> >>>  
> >>>  if ((ret = avio_read(pb, par->extradata + previous_size, len)) < 0)
> >>>  return ret;
> >>> +if (ret < len)
> >>> +return AVERROR_INVALIDDATA;
> >>>  
> >>>  return previous_size;
> >>>  }
> >>>
> >> Reminds me of
> >> https://ffmpeg.org/pipermail/ffmpeg-devel/2020-January/255671.html. But
> >> how can this fix an OOM scenario? If avio_read() couldn't read
> >> everything it should read, then we are at the end of the file and the
> >> avio_feof() check will make sure that this is the last iteration of the
> >> loop. Or is this a file that is being written to while it is read? (In
> >> which case an earlier reading attempt might have failed, but a new one
> >> might succeed because there is new data.)
> > 
> > The OOM occurs when the gigiabyte? sized uninitialized extradata is copied
> > and moved around later outside the demuxer
> > 
> 
> Yeah, I've forgotten: In this case the demuxer does not indicate an
> error at all (which is precisely what I wanted to fix).
> 

> > If you prefer your patch from january that should achieve the same.
> > 
> Actually I think one should use ffio_read_size() here (and one should
> also adapt ffio_read_size() to forward the error if avio_read() returned
> an error, unless said error was AVERROR_EOF).

ok, patches doing that posted

thx

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

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


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

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

[FFmpeg-devel] [PATCH 2/2] avformat/apngdec: Check for incomplete reads in append_extradata()

2020-10-31 Thread Michael Niedermayer
Fixes: OOM
Fixes: 
26608/clusterfuzz-testcase-minimized-ffmpeg_dem_APNG_fuzzer-4839491644424192

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

diff --git a/libavformat/apngdec.c b/libavformat/apngdec.c
index 0f1d04a365..4e1d21031f 100644
--- a/libavformat/apngdec.c
+++ b/libavformat/apngdec.c
@@ -138,7 +138,7 @@ static int append_extradata(AVCodecParameters *par, 
AVIOContext *pb, int len)
 par->extradata = new_extradata;
 par->extradata_size = new_size;
 
-if ((ret = avio_read(pb, par->extradata + previous_size, len)) < 0)
+if ((ret = ffio_read_size(pb, par->extradata + previous_size, len)) < 0)
 return ret;
 
 return previous_size;
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH 1/2] libavformat/aviobuf: Forward error from avio_read in ffio_read_size()

2020-10-31 Thread Michael Niedermayer
Suggested-by: Andreas Rheinhardt
Signed-off-by: Michael Niedermayer 
---
 libavformat/aviobuf.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 80a5a565a4..3cc440e4e7 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -686,6 +686,8 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size)
 int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
 {
 int ret = avio_read(s, buf, size);
+if (ret < 0 && ret != AVERROR_EOF)
+return ret;
 if (ret != size)
 return AVERROR_INVALIDDATA;
 return ret;
-- 
2.17.1

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

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