* [FFmpeg-devel] [PATCH] fftools/ffmpeg_demux: ensure the display_rotation option is honored (PR #20276)
@ 2025-08-18 15:24 James Almer via ffmpeg-devel
0 siblings, 0 replies; only message in thread
From: James Almer via ffmpeg-devel @ 2025-08-18 15:24 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: James Almer
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 <jamrial@gmail.com>
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 <jamrial@gmail.com>
---
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 <jamrial@gmail.com>
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 <jamrial@gmail.com>
---
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".
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-08-18 15:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-18 15:24 [FFmpeg-devel] [PATCH] fftools/ffmpeg_demux: ensure the display_rotation option is honored (PR #20276) James Almer via ffmpeg-devel
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