[FFmpeg-cvslog] avcodec/psymodel: Use av_memdup() where appropriate
Andreas Rheinhardt
git at videolan.org
Fri Jun 6 18:31:14 EEST 2025
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Tue Jun 3 17:19:48 2025 +0200| [28c0a189b6d915f28d97af172cb4332e101118c0] | committer: Andreas Rheinhardt
avcodec/psymodel: Use av_memdup() where appropriate
Also "fixes" the inverted order of arguments in the av_malloc_array()
calls and therefore part of ticket #11620.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=28c0a189b6d915f28d97af172cb4332e101118c0
---
libavcodec/psymodel.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/libavcodec/psymodel.c b/libavcodec/psymodel.c
index 890b13e1c8..1720e9b09b 100644
--- a/libavcodec/psymodel.c
+++ b/libavcodec/psymodel.c
@@ -37,8 +37,8 @@ av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, int num_lens,
ctx->avctx = avctx;
ctx->ch = av_calloc(avctx->ch_layout.nb_channels, 2 * sizeof(ctx->ch[0]));
ctx->group = av_calloc(num_groups, sizeof(ctx->group[0]));
- ctx->bands = av_malloc_array (sizeof(ctx->bands[0]), num_lens);
- ctx->num_bands = av_malloc_array (sizeof(ctx->num_bands[0]), num_lens);
+ ctx->bands = av_memdup(bands, num_lens * sizeof(ctx->bands[0]));
+ ctx->num_bands = av_memdup(num_bands, num_lens * sizeof(ctx->num_bands[0]));
ctx->cutoff = avctx->cutoff;
if (!ctx->ch || !ctx->group || !ctx->bands || !ctx->num_bands) {
@@ -46,9 +46,6 @@ av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, int num_lens,
return AVERROR(ENOMEM);
}
- memcpy(ctx->bands, bands, sizeof(ctx->bands[0]) * num_lens);
- memcpy(ctx->num_bands, num_bands, sizeof(ctx->num_bands[0]) * num_lens);
-
/* assign channels to groups (with virtual channels for coupling) */
for (i = 0; i < num_groups; i++) {
/* NOTE: Add 1 to handle the AAC chan_config without modification.
More information about the ffmpeg-cvslog
mailing list