Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/5] avcodec/magicyuvenc: Avoid unnecessary av_frame_clone()
@ 2022-02-22 23:10 Andreas Rheinhardt
  2022-02-22 23:14 ` [FFmpeg-devel] [PATCH 2/5] avcodec/magicyuvenc: Add const where appropriate Andreas Rheinhardt
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Andreas Rheinhardt @ 2022-02-22 23:10 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

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".

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-02-24 14:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-22 23:10 [FFmpeg-devel] [PATCH 1/5] avcodec/magicyuvenc: Avoid unnecessary av_frame_clone() Andreas Rheinhardt
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

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