[PATCH] Bonk decoder and demuxer
Hi, patches attached.
On Thu, Apr 28, 2016 at 01:13:34PM +0200, Paul B Mahol wrote:
Hi,
patches attached. [...]
+static int bonk_probe(AVProbeData *p) +{ + int i; + + for (i = 0; i < p->buf_size - 5; i++) { + if (!p->buf[i] && AV_RL32(p->buf + i + 1) == MKTAG('B','O','N','K')) + return AVPROBE_SCORE_MAX; + else if (!p->buf[i]) + break; + } + + return 0; +} +
this fails probetest tools/probetest 256 4096 testing size=1 testing size=2 testing size=4 testing size=8 testing size=16 testing size=32 testing size=64 testing size=128 testing size=256 testing size=512 Failure of bonk probing code with score=100 type=3 p=8B2 size=512 testing size=1024 testing size=2048 [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Avoid a single point of failure, be that a person or equipment.
Hi, I did a quick test, but it's not bitexact here: https://www.datafilehost.com/d/4820b89a Regards
I did a quick test, but it's not bitexact here:
also it deadlocks with mono files: https://www.datafilehost.com/d/b702c504
On 4/28/16, Piotr Bandurski <ami_stuff@o2.pl> wrote:
I did a quick test, but it's not bitexact here:
also it deadlocks with mono files:
Did you used lossless mode with this one? If not, could you provide source of this file? _______________________________________________
ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
also it deadlocks with mono files:
Did you used lossless mode with this one? If not, could you provide source of this file?
this file should be lossless as well, but just in case here is source wav file: https://www.datafilehost.com/d/e308e5e3
Dana 28. 4. 2016. 18:47 osoba "Piotr Bandurski" <ami_stuff@o2.pl> napisala je:
Hi,
I did a quick test, but it's not bitexact here:
You sure this is lossless file?
Regards
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
I did a quick test, but it's not bitexact here:
You sure this is lossless file?
Yes.
On 4/28/2016 8:13 AM, Paul B Mahol wrote:
+static av_cold int bonk_init(AVCodecContext *avctx) +{ + BonkContext *s = avctx->priv_data; + int i; + + avctx->sample_fmt = AV_SAMPLE_FMT_S16; + if (avctx->extradata_size < 17) + return AVERROR(EINVAL); + + if (avctx->channels < 1 || avctx->channels > 2) + return AVERROR_INVALIDDATA; + + s->nb_samples = AV_RL32(avctx->extradata + 1) / avctx->channels; + if (!s->nb_samples) + s->nb_samples = UINT64_MAX; + s->lossless = avctx->extradata[10] != 0; + s->mid_side = avctx->extradata[11] != 0; + s->n_taps = AV_RL16(avctx->extradata + 12); + if (!s->n_taps || s->n_taps > 2048) + return AVERROR(EINVAL); + + s->down_sampling = avctx->extradata[14]; + if (!s->down_sampling) + return AVERROR(EINVAL); + if (!avctx->channels || avctx->channels > 2)
You already checked this above. [...]
+static int bonk_read_header(AVFormatContext *s) +{ + AVStream *st; + int ret, i; + + for (i = 0; !avio_feof(s->pb); i++) { + int b = avio_r8(s->pb); + if (!b && avio_rl32(s->pb) == MKTAG('B','O','N','K')) + break; + else if (!b) + return AVERROR_INVALIDDATA; + } + + st = avformat_new_stream(s, NULL); + if (!st) + return AVERROR(ENOMEM); + if ((ret = ff_get_extradata(s, st->codecpar, s->pb, 17)) < 0) + return ret; + st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; + st->codecpar->codec_id = AV_CODEC_ID_BONK; + st->codecpar->sample_rate = AV_RL32(st->codecpar->extradata + 5); + st->codecpar->channels = st->codecpar->extradata[9];
And you forgot to check these two here :P Especially channels since the next line could end up in a division by 0.
+ st->duration = AV_RL32(st->codecpar->extradata + 1) / st->codecpar->channels; + st->need_parsing = AVSTREAM_PARSE_FULL_RAW; + avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); + + return 0; +}
On 4/28/16, Paul B Mahol <onemda@gmail.com> wrote:
Hi,
patches attached.
Improved version attached.
Improved version attached.
I found another bug, this time in lossy mode - the file encoded as "joint stereo" decodes after a few seconds into noise: https://www.datafilehost.com/d/c2e8b332
I found another bug, this time in lossy mode - the file encoded as "joint stereo" decodes after a few seconds into noise:
There seems to be infinite loop while decoding fuzzed file: https://www.datafilehost.com/d/eab97154 Please fix it as well in your next version of the patch.
Improved version attached.
I found another bug, this time in lossy mode - the file encoded as "joint stereo" decodes after a few seconds into noise:
here are a few more samples: https://www.datafilehost.com/d/e4825eb4 quantization: 1.15 downsampling ratio: 1:1/2:1/3:1/10:1 predictor size: 282 enable join stereo in file "down_2_1.bonk" noise stars around 2:30
Improved version attached.
I found another bug, this time in lossy mode - the file encoded as "joint stereo" decodes after a few seconds into noise:
here are a few more samples:
https://www.datafilehost.com/d/e4825eb4
quantization: 1.15 downsampling ratio: 1:1/2:1/3:1/10:1 predictor size: 282 enable join stereo
in file "down_2_1.bonk" noise stars around 2:30
hmm it has actually not much to do with "join stereo" option, because the same problem happens with mono files: https://www.datafilehost.com/d/09128a25
> Improved version attached.
I found another bug, this time in lossy mode - the file encoded as "joint stereo" decodes after a few seconds into noise:
here are a few more samples:
https://www.datafilehost.com/d/e4825eb4
quantization: 1.15 downsampling ratio: 1:1/2:1/3:1/10:1 predictor size: 282 enable join stereo
in file "down_2_1.bonk" noise stars around 2:30
hmm it has actually not much to do with "join stereo" option, because the same problem happens with mono files:
these mono files hangs with ffmpeg's bonk decoder: https://www.datafilehost.com/d/b94fd994 all of the files I shared so far were encoded with use of this converter: https://www.freac.org/ for lossy files which I shared it's still possible that there is some bug in encoder and original bonk decoder is just more tolerant for the erros in the stream and can recover better from them, but this is just my theory (in case ffmpeg's decoder is really not buggy)
> > > Improved version attached.
I found another bug, this time in lossy mode - the file encoded as "joint stereo" decodes after a few seconds into noise:
here are a few more samples:
https://www.datafilehost.com/d/e4825eb4
quantization: 1.15 downsampling ratio: 1:1/2:1/3:1/10:1 predictor size: 282 enable join stereo
in file "down_2_1.bonk" noise stars around 2:30
hmm it has actually not much to do with "join stereo" option, because the same problem happens with mono files:
these mono files hangs with ffmpeg's bonk decoder:
there is actually no hang, I used wrong binary for the test (with applied v1 version of your patch, so it's fixed)
On 5/5/16, Piotr Bandurski <ami_stuff@o2.pl> wrote:
> > > > Improved version attached.
I found another bug, this time in lossy mode - the file encoded as "joint stereo" decodes after a few seconds into noise:
here are a few more samples:
https://www.datafilehost.com/d/e4825eb4
quantization: 1.15 downsampling ratio: 1:1/2:1/3:1/10:1 predictor size: 282 enable join stereo
in file "down_2_1.bonk" noise stars around 2:30
hmm it has actually not much to do with "join stereo" option, because the same problem happens with mono files:
these mono files hangs with ffmpeg's bonk decoder:
there is actually no hang, I used wrong binary for the test (with applied v1 version of your patch, so it's fixed)
I fixed hangs/crashes but cant locate noise bug anywhere.
On 5/5/16, Piotr Bandurski <ami_stuff@o2.pl> wrote:
> > > > > Improved version attached.
I found another bug, this time in lossy mode - the file encoded as "joint stereo" decodes after a few seconds into noise:
here are a few more samples:
https://www.datafilehost.com/d/e4825eb4
quantization: 1.15 downsampling ratio: 1:1/2:1/3:1/10:1 predictor size: 282 enable join stereo
in file "down_2_1.bonk" noise stars around 2:30
hmm it has actually not much to do with "join stereo" option, because the same problem happens with mono files:
these mono files hangs with ffmpeg's bonk decoder:
there is actually no hang, I used wrong binary for the test (with applied v1 version of your patch, so it's fixed)
I fixed hangs/crashes but cant locate noise bug anywhere.
It must be a bug in fre:ac implementation - I located another bug with lossless 6khz file with predictor set to 512 fre:ac file decodes into noise with bonk and ffmpeg. I created similar sample with bonk (-l -s 512) and it decodes correctly with ffmpeg. There is also some unrelated thing - bonk encoder doesn't like wav files generated by ffmpeg, but I don't know if this is a bug in ffmpeg or bonk. so summarizing - LGTM from me for your decoder.
On 5/5/16, Piotr Bandurski <ami_stuff@o2.pl> wrote:
> > > > > > Improved version attached. > > I found another bug, this time in lossy mode - the file encoded as > "joint stereo" decodes after a few seconds into noise: > > https://www.datafilehost.com/d/c2e8b332
here are a few more samples:
https://www.datafilehost.com/d/e4825eb4
quantization: 1.15 downsampling ratio: 1:1/2:1/3:1/10:1 predictor size: 282 enable join stereo
in file "down_2_1.bonk" noise stars around 2:30
hmm it has actually not much to do with "join stereo" option, because the same problem happens with mono files:
these mono files hangs with ffmpeg's bonk decoder:
there is actually no hang, I used wrong binary for the test (with applied v1 version of your patch, so it's fixed)
I fixed hangs/crashes but cant locate noise bug anywhere.
It must be a bug in fre:ac implementation - I located another bug with lossless 6khz file with predictor set to 512 fre:ac file decodes into noise with bonk and ffmpeg.
I created similar sample with bonk (-l -s 512) and it decodes correctly with ffmpeg.
There is also some unrelated thing - bonk encoder doesn't like wav files generated by ffmpeg, but I don't know if this is a bug in ffmpeg or bonk.
so summarizing - LGTM from me for your decoder.
I was able to isolate this and it looks like it's really a bug in encoder (see "bonkdec_bug_qualization_1_15_down_10_1_pred_282.wav") just original decoder is able to better handle this https://www.datafilehost.com/d/8ca9e3c1 qualization 1.15 downsampling 10:1 predictor ...
Hi,
On 5/5/16, Piotr Bandurski <ami_stuff@o2.pl> wrote:
> > > > > > > Improved version attached. > > > > I found another bug, this time in lossy mode - the file encoded as > > "joint stereo" decodes after a few seconds into noise: > > > > https://www.datafilehost.com/d/c2e8b332 > > here are a few more samples: > > https://www.datafilehost.com/d/e4825eb4 > > quantization: 1.15 > downsampling ratio: 1:1/2:1/3:1/10:1 > predictor size: 282 > enable join stereo > > > in file "down_2_1.bonk" noise stars around 2:30
hmm it has actually not much to do with "join stereo" option, because the same problem happens with mono files:
these mono files hangs with ffmpeg's bonk decoder:
there is actually no hang, I used wrong binary for the test (with applied v1 version of your patch, so it's fixed)
I fixed hangs/crashes but cant locate noise bug anywhere.
[...] I was able to isolate this and it looks like it's really a bug in encoder (see "bonkdec_bug_qualization_1_15_down_10_1_pred_282.wav") just original decoder is able to better handle this
https://www.datafilehost.com/d/8ca9e3c1
qualization 1.15 downsampling 10:1 predictor ...
LGTM? Regards
participants (4)
-
James Almer -
Michael Niedermayer -
Paul B Mahol -
Piotr Bandurski