Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Michael Niedermayer <michael@niedermayer.cc>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH] Add 32 bit-per-sample capability to FLAC encoder
Date: Fri, 17 Dec 2021 12:43:30 +0100
Message-ID: <20211217114330.GI2829255@pb2> (raw)
In-Reply-To: <20211216194321.18669-1-mvanb1@gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 2097 bytes --]

On Thu, Dec 16, 2021 at 08:43:21PM +0100, Martijn van Beurden wrote:

[...]

> @@ -972,7 +1007,25 @@ static int encode_residual_ch(FlacEncodeContext *s, int ch)
>      for (i = 0; i < sub->order; i++)
>          sub->coefs[i] = coefs[sub->order-1][i];
>  
> -    if (s->bps_code * 4 + s->options.lpc_coeff_precision + av_log2(opt_order) <= 32) {
> +    if (s->avctx->bits_per_raw_sample > 24) {
> +        if (!ff_flacdsp_lpc_encode_c_32_overflow_detect(res, smp, n, sub->order,
> +                                                       sub->coefs, sub->shift)) {
> +            /* The found LPC coefficients produce predictions that overflow
> +             * 32-bit signed integer or produce residuals that do not fall
> +             * between -2^30 and 2^30. First try again with slightly smaller
> +             * coefficients so that the prediction undershoots, if that
> +             * doesn't help return a verbatim subframe instead */
> +            for (i = 0; i < sub->order; i++) {
> +                sub->coefs[i] = sub->coefs[i]*0.98;
                                                 ^^^^
This is ugly, the amount of actual overflow should be known at this point
so no arbitrary downscale should be needed here
                                                 
                                                 

> +                if (!ff_flacdsp_lpc_encode_c_32_overflow_detect(res, smp, n, sub->order,
> +                                                                sub->coefs, sub->shift)) {
> +                    sub->type = sub->type_code = FLAC_SUBFRAME_VERBATIM;
> +                    memcpy(res, smp, n * sizeof(int32_t));
> +                    return subframe_count_exact(s, sub, 0);

How often does this occur ?

thx

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

  parent reply	other threads:[~2021-12-17 11:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-16 19:43 Martijn van Beurden
2021-12-16 21:09 ` Paul B Mahol
2021-12-17  6:13   ` Martijn van Beurden
2021-12-17 11:34   ` Michael Niedermayer
2021-12-17 11:43 ` Michael Niedermayer [this message]
2021-12-17 20:08   ` 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=20211217114330.GI2829255@pb2 \
    --to=michael@niedermayer.cc \
    --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