From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/flacenc: Don't reload bits_per_raw_sample Date: Tue, 27 Dec 2022 23:47:39 +0100 Message-ID: <GV1P250MB073781D95063DBCB07D413508FED9@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM> (raw) In-Reply-To: <GV1P250MB073744E0C70DD7FFE1268A208FED9@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM> This has the advantage of allowing the compiler to check bits_per_raw_sample only once on little-endian hardware. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/flacenc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index adaaa77b79..cdb823a290 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -1574,23 +1574,24 @@ static int write_frame(FlacEncodeContext *s, AVPacket *avpkt) static int update_md5_sum(FlacEncodeContext *s, const void *samples) { const uint8_t *buf = samples; + int bits_per_raw_sample = s->avctx->bits_per_raw_sample; int buf_size = s->frame.blocksize * s->channels * - ((s->avctx->bits_per_raw_sample + 7) / 8); + ((bits_per_raw_sample + 7) / 8); if (HAVE_BIGENDIAN || - s->avctx->bits_per_raw_sample > 16 && s->avctx->bits_per_raw_sample <= 24) { + bits_per_raw_sample > 16 && bits_per_raw_sample <= 24) { av_fast_malloc(&s->md5_buffer, &s->md5_buffer_size, buf_size); if (!s->md5_buffer) return AVERROR(ENOMEM); buf = s->md5_buffer; } - if (s->avctx->bits_per_raw_sample <= 16) { + if (bits_per_raw_sample <= 16) { #if HAVE_BIGENDIAN s->bdsp.bswap16_buf((uint16_t *) s->md5_buffer, samples, buf_size / 2); #endif - } else if (s->avctx->bits_per_raw_sample <= 24) { + } else if (bits_per_raw_sample <= 24) { int i; const int32_t *samples0 = samples; uint8_t *tmp = s->md5_buffer; @@ -1600,7 +1601,7 @@ static int update_md5_sum(FlacEncodeContext *s, const void *samples) AV_WL24(tmp + 3*i, v); } } else { - /* s->avctx->bits_per_raw_sample <= 32 */ + /* bits_per_raw_sample <= 32 */ #if HAVE_BIGENDIAN s->bdsp.bswap_buf((uint32_t *) s->md5_buffer, samples, s->frame.blocksize * s->channels); -- 2.34.1 _______________________________________________ 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".
prev parent reply other threads:[~2022-12-27 22:47 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-12-27 22:41 [FFmpeg-devel] [PATCH 1/3] avcodec/bswapdsp: Don't presume src to be naturally aligned Andreas Rheinhardt 2022-12-27 22:47 ` [FFmpeg-devel] [PATCH 2/3] avcodec/flacenc: Don't copy buffer if avoidable Andreas Rheinhardt 2022-12-27 22:47 ` Andreas Rheinhardt [this message]
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=GV1P250MB073781D95063DBCB07D413508FED9@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM \ --to=andreas.rheinhardt@outlook.com \ --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