Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 1/5] avcodec/magicyuvenc: Avoid unnecessary av_frame_clone()
Date: Wed, 23 Feb 2022 00:10:34 +0100
Message-ID: <AM7PR03MB66602D3222786A979F95023B8F3B9@AM7PR03MB6660.eurprd03.prod.outlook.com> (raw)

It is unnecessary and unchecked; the intention seems to be to ensure
that the frame's data is writable, but it does not provide this.
This will be fixed in a latter commit.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/magicyuvenc.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/libavcodec/magicyuvenc.c b/libavcodec/magicyuvenc.c
index ab32d4cee3..4440ab3ce2 100644
--- a/libavcodec/magicyuvenc.c
+++ b/libavcodec/magicyuvenc.c
@@ -452,32 +452,30 @@ static int magy_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     }
 
     if (s->correlate) {
+        uint8_t *const data[4] = { frame->data[1], frame->data[0],
+                                   frame->data[2], frame->data[3] };
+        const int linesize[4]  = { frame->linesize[1], frame->linesize[0],
+                                   frame->linesize[2], frame->linesize[3] };
         uint8_t *r, *g, *b;
-        AVFrame *p = av_frame_clone(frame);
 
-        g = p->data[0];
-        b = p->data[1];
-        r = p->data[2];
+        g = frame->data[0];
+        b = frame->data[1];
+        r = frame->data[2];
 
         for (i = 0; i < height; i++) {
             s->llvidencdsp.diff_bytes(b, b, g, width);
             s->llvidencdsp.diff_bytes(r, r, g, width);
-            g += p->linesize[0];
-            b += p->linesize[1];
-            r += p->linesize[2];
+            g += frame->linesize[0];
+            b += frame->linesize[1];
+            r += frame->linesize[2];
         }
 
-        FFSWAP(uint8_t*, p->data[0], p->data[1]);
-        FFSWAP(int, p->linesize[0], p->linesize[1]);
-
         for (i = 0; i < s->planes; i++) {
             for (slice = 0; slice < s->nb_slices; slice++) {
-                s->predict(s, p->data[i], s->slices[i], p->linesize[i],
-                               p->width, p->height);
+                s->predict(s, data[i], s->slices[i], linesize[i],
+                           frame->width, frame->height);
             }
         }
-
-        av_frame_free(&p);
     } else {
         for (i = 0; i < s->planes; i++) {
             for (slice = 0; slice < s->nb_slices; slice++) {
-- 
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".

             reply	other threads:[~2022-02-22 23:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-22 23:10 Andreas Rheinhardt [this message]
2022-02-22 23:14 ` [FFmpeg-devel] [PATCH 2/5] avcodec/magicyuvenc: Add const where appropriate Andreas Rheinhardt
2022-02-23  8:56   ` Paul B Mahol
2022-02-22 23:16 ` [FFmpeg-devel] [PATCH 3/5] avcodec/magicyuvenc: Don't modify input frame Andreas Rheinhardt
2022-02-23  8:54   ` Paul B Mahol
2022-02-22 23:16 ` [FFmpeg-devel] [PATCH 4/5] avcodec/libopenjpegenc: Don't clone AVFrame unnecessarily Andreas Rheinhardt
2022-02-24  9:44   ` Andreas Rheinhardt
2022-02-24 14:30     ` Michael Bradshaw
2022-02-22 23:16 ` [FFmpeg-devel] [PATCH 5/5] avcodec/magicyuvenc: Remove unused context variable Andreas Rheinhardt
2022-02-23  8:56 ` [FFmpeg-devel] [PATCH 1/5] avcodec/magicyuvenc: Avoid unnecessary av_frame_clone() Paul B Mahol

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=AM7PR03MB66602D3222786A979F95023B8F3B9@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