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

Reply via email to