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>
This commit is contained in:
James Almer
2025-08-18 12:22:09 -03:00
parent ae14930176
commit 70a6ad6c74

View File

@@ -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,15 @@ 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))
buf[0] = ',';
else
buf[0] = '\0';
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)