From: Lynne <dev@lynne.ee> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: Re: [FFmpeg-devel] [PATCH v3] libavcodec/flacenc: add backward-compatible 32 bit-per-sample capability Date: Wed, 5 Jan 2022 04:57:46 +0100 (CET) Message-ID: <MscNfjy--3-2@lynne.ee> (raw) In-Reply-To: <20220103202608.56364-1-mvanb1@gmail.com> 3 Jan 2022, 21:26 by mvanb1@gmail.com: > + if (pmax > 0) { > + if (lpc_reduction_tries >= 2) > + return 0; > + lpc_reduction_tries++; > + for (int i = 0; i < order; i++) > + coefs[i] = ((int64_t)coefs[i] * INT32_MAX) / pmax; > + } > + } while (pmax > 0); > + return 1; > +} > Could you invert the return value of the function? Return 0 if there's no overflow and 1 if there is? That's usually how we use return values throughout the code too, and it saves you from having to invert it when you use it. > static void flac_lpc_16_c(int32_t *decoded, const int coeffs[32], > int pred_order, int qlevel, int len) > { > diff --git a/libavcodec/flacdsp.h b/libavcodec/flacdsp.h > index 7bb0dd0e9a..5978a4722a 100644 > --- a/libavcodec/flacdsp.h > +++ b/libavcodec/flacdsp.h > @@ -40,4 +40,7 @@ void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt, int channels, i > void ff_flacdsp_init_arm(FLACDSPContext *c, enum AVSampleFormat fmt, int channels, int bps); > void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int channels, int bps); > > +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); > Could you also move the function to flacenc.c? The flacdsp.c file gets compiled if either is enabled, but if flacenc.c isn't enabled, then this code shouldn't be enabled, to save space. The function isn't likely to get SIMD, and the compiler could do more aggressive optimizations if it's in the same file. > put_sbits(&s->pb, sub->obits, res[0]); > } else if (sub->type == FLAC_SUBFRAME_VERBATIM) { > - while (res < frame_end) > - put_sbits(&s->pb, sub->obits, *res++); > + if (sub->obits < 32) { > + while (res < frame_end) > + put_sbits(&s->pb, sub->obits, *res++); > + } else { > + while (res < frame_end) > + put_bits32(&s->pb, *res++); > + } > } else { > /* warm-up samples */ > - for (i = 0; i < sub->order; i++) > - put_sbits(&s->pb, sub->obits, *res++); > + if (sub->obits < 32) { > + for (i = 0; i < sub->order; i++) > + put_sbits(&s->pb, sub->obits, *res++); > + }else{ > + for (i = 0; i < sub->order; i++) > + put_bits32(&s->pb, *res++); > + } > Small nit, but could you put spaces in the }else{ Apart from that, looks good. _______________________________________________ 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".
next prev parent reply other threads:[~2022-01-05 3:57 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-12-19 20:53 [FFmpeg-devel] [PATCH] " Martijn van Beurden 2021-12-19 21:11 ` Lynne 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 [this message] 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=MscNfjy--3-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