diff mbox series

[FFmpeg-devel,v6,2/2] ffmpeg: Deprecate display rotation override with a metadata key

Message ID 20220926055753.88407-3-thilo.borgmann@mail.de
State New
Headers show
Series ffmpeg: Add display_{rotation, hflip, vflip} options | 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

Thilo Borgmann Sept. 26, 2022, 5:57 a.m. UTC
From: Jan Ekström <jeebjp@gmail.com>

Now that we have proper options for defining display matrix
overrides, this should no longer be required.

fftools does not have its own versioning, so for now the define is
just set to 1 and disables the functionality if set to zero.
---
 fftools/ffmpeg.c     |  2 ++
 fftools/ffmpeg.h     |  5 +++++
 fftools/ffmpeg_opt.c | 10 ++++++++++
 3 files changed, 17 insertions(+)

Comments

Anton Khirnov Oct. 4, 2022, 8:52 a.m. UTC | #1
Quoting Thilo Borgmann (2022-09-26 07:57:53)
> diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
> index f07858333d..3f2409ee28 100644
> --- a/fftools/ffmpeg_opt.c
> +++ b/fftools/ffmpeg_opt.c
> @@ -2859,16 +2859,26 @@ static void of_add_metadata(AVFormatContext *oc, const OptionsContext *o)
>              for (int j = 0; j < oc->nb_streams; j++) {
>                  OutputStream *ost = output_streams[nb_output_streams - oc->nb_streams + j];
>                  if ((ret = check_stream_specifier(oc, oc->streams[j], stream_spec)) > 0) {
> +#if FFMPEG_ROTATION_METADATA
>                      if (!strcmp(o->metadata[i].u.str, "rotate")) {
>                          char *tail;
>                          double theta = av_strtod(val, &tail);
>                          if (!*tail) {
>                              ost->rotate_overridden = 1;
>                              ost->rotate_override_value = theta;
> +
> +                        av_log(NULL, AV_LOG_WARNING,
> +                               "Conversion of a 'rotate' metadata key to a "
> +                               "proper display matrix rotation is deprecated. "

Also, the user has no idea what a "proper display matrix rotation" is.
Make it something like
"Using 'rotate' metadata to specify rotation is deprecated.

> +                               "See -display_rotation for setting rotation "
> +                               "instead.");

Missing newline.
diff mbox series

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 0e1477299d..65b0b83a18 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2831,12 +2831,14 @@  static int init_output_stream_streamcopy(OutputStream *ost)
         }
     }
 
+#if FFMPEG_ROTATION_METADATA
     if (ost->rotate_overridden) {
         uint8_t *sd = av_stream_new_side_data(ost->st, AV_PKT_DATA_DISPLAYMATRIX,
                                               sizeof(int32_t) * 9);
         if (sd)
             av_display_rotation_set((int32_t *)sd, -ost->rotate_override_value);
     }
+#endif
 
     switch (par->codec_type) {
     case AVMEDIA_TYPE_AUDIO:
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index c529baacc4..529d94bea8 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -53,6 +53,7 @@ 
 #define FFMPEG_OPT_PSNR 1
 #define FFMPEG_OPT_MAP_CHANNEL 1
 #define FFMPEG_OPT_MAP_SYNC 1
+#define FFMPEG_ROTATION_METADATA 1
 
 enum VideoSyncMethod {
     VSYNC_AUTO = -1,
@@ -536,11 +537,15 @@  typedef struct OutputStream {
     int is_cfr;
     int force_fps;
     int top_field_first;
+#if FFMPEG_ROTATION_METADATA
     int rotate_overridden;
+#endif
     int autoscale;
     int bitexact;
     int bits_per_raw_sample;
+#if FFMPEG_ROTATION_METADATA
     double rotate_override_value;
+#endif
 
     AVRational frame_aspect_ratio;
 
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index f07858333d..3f2409ee28 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -2859,16 +2859,26 @@  static void of_add_metadata(AVFormatContext *oc, const OptionsContext *o)
             for (int j = 0; j < oc->nb_streams; j++) {
                 OutputStream *ost = output_streams[nb_output_streams - oc->nb_streams + j];
                 if ((ret = check_stream_specifier(oc, oc->streams[j], stream_spec)) > 0) {
+#if FFMPEG_ROTATION_METADATA
                     if (!strcmp(o->metadata[i].u.str, "rotate")) {
                         char *tail;
                         double theta = av_strtod(val, &tail);
                         if (!*tail) {
                             ost->rotate_overridden = 1;
                             ost->rotate_override_value = theta;
+
+                        av_log(NULL, AV_LOG_WARNING,
+                               "Conversion of a 'rotate' metadata key to a "
+                               "proper display matrix rotation is deprecated. "
+                               "See -display_rotation for setting rotation "
+                               "instead.");
                         }
                     } else {
+#endif
                         av_dict_set(&oc->streams[j]->metadata, o->metadata[i].u.str, *val ? val : NULL, 0);
+#if FFMPEG_ROTATION_METADATA
                     }
+#endif
                 } else if (ret < 0)
                     exit_program(1);
             }