CRC computation isn't fast enough? What should I use then? A sum of byte values?

Jonathan Campbell
CASTUS

On 09/02/2016 04:50 AM, Michael Niedermayer wrote:
On Thu, Sep 01, 2016 at 06:59:46PM -0700, Jonathan Campbell wrote:
I finished the consistent noise generation patch for AC-3 decoding.

Set AVOption "cons_noisegen" to 1 (true) to enable it.

Git repository:
https://github.com/joncampbell123/FFmpeg.git

commit dbd086586f0ad1591ea2013293bbb6e4dbfd0455
Author: Jonathan Campbell <jonat...@castus.tv>
Date:   Thu Sep 1 18:46:16 2016 -0700

     AC-3 consistent noise generation: avopt -cons_noisegen <number>

     When -cons_noisegen 1, the linear feedback generator used for AC-3
     dithering is seeded with the contents of the AC-3 frame. Seeding from
     the AC-3 frame ensures the dithering noise comes out exactly the same
     when given the same AC-3 frame data, which can then be used by
     non-linear editing software to reliably decode discontinuous
segments of
     an AC-3 bitstream without gaps or discontinuities.

Jonathan Campbell

Patch follows, hope Thunderbird doesn't garble it:

diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index fac189b..28048d7 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -1419,6 +1419,19 @@ static int ac3_decode_frame(AVCodecContext *
avctx, void *data,
                              (const uint16_t *) buf, cnt);
      } else
          memcpy(s->input_buffer, buf, FFMIN(buf_size,
AC3_FRAME_BUFFER_SIZE));
+
+    /* if consistent noise generation is enabled, seed the linear
feedback generator
+     * with the contents of the AC-3 frame so that the noise is
identical across
+     * decodes given the same AC-3 frame data, for use with
non-linear edititing software. */
+    if (s->consistent_noise_generation) {
+        const AVCRC *avcrc = av_crc_get_table(AV_CRC_32_IEEE);
+
+        if (avcrc != NULL)
+            av_lfg_init(&s->dith_state, av_crc(avcrc, 0,
s->input_buffer, FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE)));
av_lfg_init involves md5 which is slow and not apropriate to be
executed per frame, this would double the time to decode a frame

  965641 decicycles in rndint,      64 runs,      0 skips
2375023 decicycles in FRAME,      64 runs,      0 skips


write/use a faster way to init the LFG please


[...]



_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to