From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ffmpeg-devel-bounces@ffmpeg.org>
Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100])
	by master.gitmailbox.com (Postfix) with ESMTP id 6E5284990C
	for <ffmpegdev@gitmailbox.com>; Fri, 23 Feb 2024 14:41:36 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F084568C75C;
	Fri, 23 Feb 2024 16:41:27 +0200 (EET)
Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CC82268C66F
 for <ffmpeg-devel@ffmpeg.org>; Fri, 23 Feb 2024 16:41:20 +0200 (EET)
Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key;
 unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256
 header.s=mail header.b=hfq9DN/+; dkim-atps=neutral
Received: from localhost (mail1.khirnov.net [IPv6:::1])
 by mail1.khirnov.net (Postfix) with ESMTP id 668B54D22
 for <ffmpeg-devel@ffmpeg.org>; Fri, 23 Feb 2024 15:41:20 +0100 (CET)
Received: from mail1.khirnov.net ([IPv6:::1])
 by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP
 id E0crx6GZOw39 for <ffmpeg-devel@ffmpeg.org>;
 Fri, 23 Feb 2024 15:41:19 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail;
 t=1708699279; bh=DJfLlaeuoxLKxjUOmHwZSJbJyXOS/iO4msJB3PJRKWo=;
 h=From:To:Subject:Date:In-Reply-To:References:From;
 b=hfq9DN/+HnJfUMDfQ4X7qFg303gwQ5y7sKPAkhz82Z8rd5MfULwGeA+d7jUF1RrQJ
 9VPEZxXdkt9wCDSztPZt0klTzr9jEpuVu4BG0YP+2RQmICWZ6ulvOtfexfO63U5XJT
 T8YyBzVJTTKagZ3h/ZW9x3BQH9HBPOQ9mcRkQmrEqBs40eo+w2k4d8vQc6RtHHPt8C
 yRYi+j/ReL4es7tIbY/D0XpwAU5ZMv43VDVe9TlEaBdpYT+cGtgd+9vLfmzXau0Tbp
 FndB4q72CyEc/iVwUzP91BG5LZ/+jJV4l6zpMvM3is5oSarjvguvOO4fe9/UWlIeJ4
 qtS5zDDgRpLDA==
Received: from libav.khirnov.net (libav.khirnov.net
 [IPv6:2a00:c500:561:201::7])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
 client-signature RSA-PSS (2048 bits) client-digest SHA256)
 (Client CN "libav.khirnov.net",
 Issuer "smtp.khirnov.net SMTP CA" (verified OK))
 by mail1.khirnov.net (Postfix) with ESMTPS id C47F84D03
 for <ffmpeg-devel@ffmpeg.org>; Fri, 23 Feb 2024 15:41:19 +0100 (CET)
Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1])
 by libav.khirnov.net (Postfix) with ESMTP id 77C183A2743
 for <ffmpeg-devel@ffmpeg.org>; Fri, 23 Feb 2024 15:31:23 +0100 (CET)
From: Anton Khirnov <anton@khirnov.net>
To: ffmpeg-devel@ffmpeg.org
Date: Fri, 23 Feb 2024 14:58:57 +0100
Message-ID: <20240223143115.16521-36-anton@khirnov.net>
X-Mailer: git-send-email 2.42.0
In-Reply-To: <20240223143115.16521-1-anton@khirnov.net>
References: <20240223143115.16521-1-anton@khirnov.net>
MIME-Version: 1.0
Subject: [FFmpeg-devel] [PATCH 35/38] avcodec/mjpegdec: use
 ff_frame_new_side_data
X-BeenThere: ffmpeg-devel@ffmpeg.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org>
List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe>
List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel>
List-Post: <mailto:ffmpeg-devel@ffmpeg.org>
List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help>
List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe>
Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: ffmpeg-devel-bounces@ffmpeg.org
Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org>
Archived-At: <https://master.gitmailbox.com/ffmpegdev/20240223143115.16521-36-anton@khirnov.net/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>

From: Niklas Haas <git@haasn.dev>

For consistency, even though this can't (yet) be overriden at the packet
level.
---
 libavcodec/mjpegdec.c | 66 ++++++++++++++++++++++---------------------
 1 file changed, 34 insertions(+), 32 deletions(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 43b36d0a8f..4ef565fe2d 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -2865,42 +2865,44 @@ the_end:
             if (orientation >= 2 && orientation <= 8) {
                 int32_t *matrix;
 
-                sd = av_frame_new_side_data(frame, AV_FRAME_DATA_DISPLAYMATRIX, sizeof(int32_t) * 9);
-                if (!sd) {
+                ret = ff_frame_new_side_data(avctx, frame, AV_FRAME_DATA_DISPLAYMATRIX, sizeof(int32_t) * 9, &sd);
+                if (ret < 0) {
                     av_log(avctx, AV_LOG_ERROR, "Could not allocate frame side data\n");
-                    return AVERROR(ENOMEM);
+                    return ret;
                 }
 
-                matrix = (int32_t *)sd->data;
+                if (sd) {
+                    matrix = (int32_t *)sd->data;
 
-                switch (orientation) {
-                case 2:
-                    av_display_rotation_set(matrix, 0.0);
-                    av_display_matrix_flip(matrix, 1, 0);
-                    break;
-                case 3:
-                    av_display_rotation_set(matrix, 180.0);
-                    break;
-                case 4:
-                    av_display_rotation_set(matrix, 180.0);
-                    av_display_matrix_flip(matrix, 1, 0);
-                    break;
-                case 5:
-                    av_display_rotation_set(matrix, 90.0);
-                    av_display_matrix_flip(matrix, 1, 0);
-                    break;
-                case 6:
-                    av_display_rotation_set(matrix, 90.0);
-                    break;
-                case 7:
-                    av_display_rotation_set(matrix, -90.0);
-                    av_display_matrix_flip(matrix, 1, 0);
-                    break;
-                case 8:
-                    av_display_rotation_set(matrix, -90.0);
-                    break;
-                default:
-                    av_assert0(0);
+                    switch (orientation) {
+                    case 2:
+                        av_display_rotation_set(matrix, 0.0);
+                        av_display_matrix_flip(matrix, 1, 0);
+                        break;
+                    case 3:
+                        av_display_rotation_set(matrix, 180.0);
+                        break;
+                    case 4:
+                        av_display_rotation_set(matrix, 180.0);
+                        av_display_matrix_flip(matrix, 1, 0);
+                        break;
+                    case 5:
+                        av_display_rotation_set(matrix, 90.0);
+                        av_display_matrix_flip(matrix, 1, 0);
+                        break;
+                    case 6:
+                        av_display_rotation_set(matrix, 90.0);
+                        break;
+                    case 7:
+                        av_display_rotation_set(matrix, -90.0);
+                        av_display_matrix_flip(matrix, 1, 0);
+                        break;
+                    case 8:
+                        av_display_rotation_set(matrix, -90.0);
+                        break;
+                    default:
+                        av_assert0(0);
+                    }
                 }
             }
         }
-- 
2.42.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".