diff mbox series

[FFmpeg-devel,26/29] avcodec/mjpegdec: use ff_frame_new_side_data

Message ID 20240304130657.30631-26-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/29] lavu/opt: factor per-type dispatch out of av_opt_get() | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov March 4, 2024, 1:06 p.m. UTC
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 mbox series

Patch

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);
+                    }
                 }
             }
         }