Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Lynne <dev@lynne.ee>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH] libavcodec/flacenc: add backward-compatible 32 bit-per-sample capability
Date: Sun, 19 Dec 2021 22:11:34 +0100 (CET)
Message-ID: <MrJXGWj--g-2@lynne.ee> (raw)
In-Reply-To: <20211219205318.9362-1-mvanb1@gmail.com>

19 Dec 2021, 21:53 by mvanb1@gmail.com:

> Enables creation of FLAC files with up to 32 bits-per-sample, up from the
> previous limit of 24 bit. This is a feature requested for RAWcooked, the
> archiving community has a need for storing files with 32-bit integer audio
> samples. See https://github.com/MediaArea/RAWcooked/issues/356
>
> Restrictions to the encoder are added so created files are compatible with
> existing decoders. Stereo decorrelation is disabled on 32 bit-per-sample,
> because a side channel would need 33 bit-per-sample, causing problems in
> existing 32 bit datapaths. Also only LPC encoding is enabled, because
> decoders capable of processing 24-bit files already use 64-bit processing
> for LPC, but not for fixed subframes.
>
> Furthermore, predictions and residuals are checked for causing integer
> overflow, reverting to a verbatim (store) subframe in case no LPC coeffs
> can be found that do not cause overflow.
>
> ffmpeg's FLAC decoder has been forward-compatible with this change since
> commit c720b9ce98 (May 2015). libFLAC is forward-compatible since release
> 1.2.1 (September 2007), the flac command line tool however blocks 32-bit
> files out of caution, it having been untested until now.
> ---
>  libavcodec/flacdsp.c | 47 ++++++++++++++++++++++
>  libavcodec/flacdsp.h |  3 ++
>  libavcodec/flacenc.c | 95 +++++++++++++++++++++++++++++++++++++-------
>  3 files changed, 130 insertions(+), 15 deletions(-)
>
> diff --git a/libavcodec/flacdsp.c b/libavcodec/flacdsp.c
> index bc9a5dbed9..422f6578ba 100644
> --- a/libavcodec/flacdsp.c
> +++ b/libavcodec/flacdsp.c
> @@ -43,6 +43,53 @@
>  #define PLANAR 1
>  #include "flacdsp_template.c"
>  
> +#define ZIGZAG_32BIT_MAX  0x3FFFFFFF
> +#define ZIGZAG_32BIT_MIN -0x3FFFFFFF
> +
> +int ff_flacdsp_lpc_encode_c_32_overflow_detect(int32_t *res, const int32_t *smp, int len,
> +                                               int order, int32_t *coefs, int shift)
> +{
> +    /* This function checks for every prediction and every residual
> +     * whether they cause integer overflow in existing decoders. In
> +     * case the prediction exceeds int32_t limits, prediction
> +     * coefficients are lowered accordingly. If the residual exceeds
> +     * ZIGZAG_32BIT_MAX and _MIN or coefficients have been lowered
> +     * twice but the prediction still overflows, give up */
>

What happens if there's an overflow and the prediction coefficients
are lowered? Is there a loss of bits? What about if it gives up?

I'm really concerned about arbitrary data not being lossless in a codec
that's meant to be always lossless. If that can happen, I think 32-bit
encoding should be disabled unless -strict -1 is used.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

  reply	other threads:[~2021-12-19 21:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-19 20:53 Martijn van Beurden
2021-12-19 21:11 ` Lynne [this message]
2021-12-19 21:41   ` Martijn van Beurden
2021-12-19 23:05     ` Lynne
2021-12-20  8:11       ` [FFmpeg-devel] [PATCH v2] " Martijn van Beurden
2021-12-20 11:25         ` Martijn van Beurden
2022-01-03 20:26           ` [FFmpeg-devel] [PATCH v3] " Martijn van Beurden
2022-01-05  3:57             ` Lynne
2022-01-08 14:24               ` [FFmpeg-devel] [PATCH v4] " Martijn van Beurden

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MrJXGWj--g-2@lynne.ee \
    --to=dev@lynne.ee \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git