From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/flashsv: Avoid copying packet Date: Fri, 11 Mar 2022 16:44:23 +0100 Message-ID: <AM7PR03MB6660918E362242F545F0172D8F0C9@AM7PR03MB6660.eurprd03.prod.outlook.com> (raw) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/flashsv.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index 00f77f4902..5f0bc0c6df 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -44,7 +44,7 @@ #include "internal.h" typedef struct BlockInfo { - uint8_t *pos; + const uint8_t *pos; int size; } BlockInfo; @@ -59,7 +59,8 @@ typedef struct FlashSVContext { int ver; const uint32_t *pal; int is_keyframe; - uint8_t *keyframedata; + const uint8_t *keyframedata; + AVBufferRef *keyframedata_buf; uint8_t *keyframe; BlockInfo *blocks; uint8_t *deflate_block; @@ -138,7 +139,7 @@ static av_cold int flashsv_decode_init(AVCodecContext *avctx) return 0; } -static int flashsv2_prime(FlashSVContext *s, uint8_t *src, int size) +static int flashsv2_prime(FlashSVContext *s, const uint8_t *src, int size) { z_stream zs; int zret; // Zlib return code @@ -355,10 +356,10 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, /* we care for keyframes only in Screen Video v2 */ s->is_keyframe = (avpkt->flags & AV_PKT_FLAG_KEY) && (s->ver == 2); if (s->is_keyframe) { - int err; - if ((err = av_reallocp(&s->keyframedata, avpkt->size)) < 0) + int err = av_buffer_replace(&s->keyframedata_buf, avpkt->buf); + if (err < 0) return err; - memcpy(s->keyframedata, avpkt->data, avpkt->size); + s->keyframedata = avpkt->data; } if(s->ver == 2 && !s->blocks) s->blocks = av_mallocz((v_blocks + !!v_part) * (h_blocks + !!h_part) * @@ -566,7 +567,7 @@ static av_cold int flashsv2_decode_end(AVCodecContext *avctx) { FlashSVContext *s = avctx->priv_data; - av_freep(&s->keyframedata); + av_buffer_unref(&s->keyframedata_buf); av_freep(&s->blocks); av_freep(&s->keyframe); av_freep(&s->deflate_block); -- 2.32.0 _______________________________________________ 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 reply other threads:[~2022-03-11 15:44 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-03-11 15:44 Andreas Rheinhardt [this message] 2022-03-11 15:59 ` [FFmpeg-devel] [PATCH 2/2] avcodec/flashsv: Avoid deflating data Andreas Rheinhardt
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=AM7PR03MB6660918E362242F545F0172D8F0C9@AM7PR03MB6660.eurprd03.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