From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 6A5884960E for ; Mon, 18 Aug 2025 15:24:34 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 1A2D068D47D; Mon, 18 Aug 2025 18:24:30 +0300 (EEST) Received: from c1ad6a1ecdc3 (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 85EF068C069 for ; Mon, 18 Aug 2025 18:24:28 +0300 (EEST) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] =?utf-8?q?=5BPATCH=5D_fftools/ffmpeg=5Fdemux=3A_e?= =?utf-8?q?nsure_the_display=5Frotation_option_is_honored_=28PR_=2320276?= =?utf-8?q?=29?= X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: James Almer via ffmpeg-devel Reply-To: FFmpeg development discussions and patches Cc: James Almer Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Message-Id: <20250818152430.1A2D068D47D@ffbox0-bg.ffmpeg.org> Date: Mon, 18 Aug 2025 18:24:30 +0300 (EEST) Archived-At: List-Archive: List-Post: PR #20276 opened by James Almer (jamrial) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20276 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20276.patch If requested, it should have priotity over any coded value Fixes trac ticket #11649. >From e90c889ee2cefbe173a2f61e1433b18c33436a0c Mon Sep 17 00:00:00 2001 From: James Almer Date: Mon, 18 Aug 2025 11:16:23 -0300 Subject: [PATCH 1/2] avcodec/mjpegdec: use ff_frame_new_side_data() to export display matrix Otherwise, the user requested priority of packet side data will be ignored. Signed-off-by: James Almer --- libavcodec/mjpegdec.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 87d1d02077..b6bf1ab224 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -2876,15 +2876,15 @@ the_end: AVFrameSideData *sd = NULL; 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) { + int32_t *matrix = (int32_t *)sd->data; switch (orientation) { case 2: -- 2.49.1 >From 66563b40f34741a725d8bbd17ae352ed109af8b1 Mon Sep 17 00:00:00 2001 From: James Almer Date: Mon, 18 Aug 2025 12:22:09 -0300 Subject: [PATCH 2/2] fftools/ffmpeg_demux: ensure the display_rotation option is honored If requested, it should have priotity over any coded value. Fixes ticket #11649. Signed-off-by: James Almer --- fftools/ffmpeg_demux.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 78d8ff6b7d..a67d71387a 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -67,6 +67,7 @@ typedef struct DemuxStream { int reinit_filters; int autorotate; int apply_cropping; + int force_display_matrix; int drop_changed; @@ -1183,6 +1184,7 @@ static int add_display_matrix_to_stream(const OptionsContext *o, AVFormatContext *ctx, InputStream *ist) { AVStream *st = ist->st; + DemuxStream *ds = ds_from_ist(ist); AVPacketSideData *sd; double rotation = DBL_MAX; int hflip = -1, vflip = -1; @@ -1217,6 +1219,8 @@ static int add_display_matrix_to_stream(const OptionsContext *o, hflip_set ? hflip : 0, vflip_set ? vflip : 0); + ds->force_display_matrix = 1; + return 0; } @@ -1455,6 +1459,13 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st, AVDictiona av_dict_set_int(&ds->decoder_opts, "apply_cropping", ds->apply_cropping && ds->apply_cropping != CROP_CONTAINER, 0); + if (ds->force_display_matrix) { + char buf[32]; + if (av_dict_get(ds->decoder_opts, "side_data_prefer_packet", NULL, 0)) + snprintf(buf, sizeof(buf), ","); + av_strlcat(buf, "displaymatrix", sizeof(buf)); + av_dict_set(&ds->decoder_opts, "side_data_prefer_packet", buf, AV_DICT_APPEND); + } /* Attached pics are sparse, therefore we would not want to delay their decoding * till EOF. */ if (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC) -- 2.49.1 _______________________________________________ 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".