diff mbox series

[FFmpeg-devel,03/23] lavu/frame: add side data storing view ID for multi-view video

Message ID 20240914111036.17164-4-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/23] compat: drop gcc, suncc, and pthreads stdatomic emulation | 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 Sept. 14, 2024, 10:45 a.m. UTC
---
 doc/APIchanges            | 3 +++
 fftools/ffprobe.c         | 2 ++
 libavfilter/vf_showinfo.c | 2 ++
 libavutil/frame.c         | 1 +
 libavutil/frame.h         | 9 +++++++++
 libavutil/version.h       | 2 +-
 6 files changed, 18 insertions(+), 1 deletion(-)

Comments

James Almer Sept. 15, 2024, 8:35 p.m. UTC | #1
On 9/14/2024 7:45 AM, Anton Khirnov wrote:
> ---
>   doc/APIchanges            | 3 +++
>   fftools/ffprobe.c         | 2 ++
>   libavfilter/vf_showinfo.c | 2 ++
>   libavutil/frame.c         | 1 +
>   libavutil/frame.h         | 9 +++++++++
>   libavutil/version.h       | 2 +-
>   6 files changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 830a38cd69..189932c99c 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
>   
>   API changes, most recent first:
>   
> +2024-xx-xx - xxxxxxx - lavu 59.37.100 - frame.h
> +  Add AV_FRAME_DATA_VIEW_ID.
> +
>   2024-09-xx - xxxxxxxxxx - lavc 61.13.100 - avcodec.h
>     Add avcodec_get_supported_config() and enum AVCodecConfig; deprecate
>     AVCodec.pix_fmts, AVCodec.sample_fmts, AVCodec.supported_framerates,
> diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
> index bf5ebe3ce0..14b98d22a1 100644
> --- a/fftools/ffprobe.c
> +++ b/fftools/ffprobe.c
> @@ -2920,6 +2920,8 @@ static void print_frame_side_data(WriterContext *w,
>           } else if (sd->type == AV_FRAME_DATA_FILM_GRAIN_PARAMS) {
>               AVFilmGrainParams *fgp = (AVFilmGrainParams *)sd->data;
>               print_film_grain_params(w, fgp);
> +        } else if (sd->type == AV_FRAME_DATA_VIEW_ID) {
> +            print_int("view_id", *(int*)sd->data);
>           }
>           writer_print_section_footer(w);
>       }
> diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
> index f81df9d1bf..77082505f5 100644
> --- a/libavfilter/vf_showinfo.c
> +++ b/libavfilter/vf_showinfo.c
> @@ -857,6 +857,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
>           case AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT:
>               dump_ambient_viewing_environment(ctx, sd);
>               break;
> +        case AV_FRAME_DATA_VIEW_ID:
> +            av_log(ctx, AV_LOG_INFO, "view id: %d\n", *(int*)sd->data);
>           default:
>               if (name)
>                   av_log(ctx, AV_LOG_INFO,
> diff --git a/libavutil/frame.c b/libavutil/frame.c
> index 5cbfc6a48b..891909fc2a 100644
> --- a/libavutil/frame.c
> +++ b/libavutil/frame.c
> @@ -46,6 +46,7 @@ static const AVSideDataDescriptor sd_props[] = {
>       [AV_FRAME_DATA_DETECTION_BBOXES]            = { "Bounding boxes for object detection and classification" },
>       [AV_FRAME_DATA_DOVI_RPU_BUFFER]             = { "Dolby Vision RPU Data" },
>       [AV_FRAME_DATA_DOVI_METADATA]               = { "Dolby Vision Metadata" },
> +    [AV_FRAME_DATA_VIEW_ID]                     = { "View ID" },
>       [AV_FRAME_DATA_STEREO3D]                    = { "Stereo 3D",                                    AV_SIDE_DATA_PROP_GLOBAL },
>       [AV_FRAME_DATA_REPLAYGAIN]                  = { "AVReplayGain",                                 AV_SIDE_DATA_PROP_GLOBAL },
>       [AV_FRAME_DATA_DISPLAYMATRIX]               = { "3x3 displaymatrix",                            AV_SIDE_DATA_PROP_GLOBAL },
> diff --git a/libavutil/frame.h b/libavutil/frame.h
> index 60bb966f8b..cea1c68df5 100644
> --- a/libavutil/frame.h
> +++ b/libavutil/frame.h
> @@ -228,6 +228,15 @@ enum AVFrameSideDataType {
>        * encoding.
>        */
>       AV_FRAME_DATA_VIDEO_HINT,
> +
> +    /**
> +     * This side data must be associated with a video frame.
> +     * The presence of this side data indicates that the video stream is
> +     * composed of multiple views (e.g. stereoscopic 3D content,
> +     * cf. H.264 Annex H or H.265 Annex G).
> +     * The data is an int storing the view ID.

What is the use case for AVFrame->metadata? What gets written there and 
what is expected by library users? Is it documented at all? Because a 
single int like this feels like would fit better there rather than as 
side data.

> +     */
> +    AV_FRAME_DATA_VIEW_ID,
>   };
>   
>   enum AVActiveFormatDescription {
> diff --git a/libavutil/version.h b/libavutil/version.h
> index 25a6f5531b..7900379c12 100644
> --- a/libavutil/version.h
> +++ b/libavutil/version.h
> @@ -79,7 +79,7 @@
>    */
>   
>   #define LIBAVUTIL_VERSION_MAJOR  59
> -#define LIBAVUTIL_VERSION_MINOR  36
> +#define LIBAVUTIL_VERSION_MINOR  37
>   #define LIBAVUTIL_VERSION_MICRO 100
>   
>   #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
Anton Khirnov Sept. 15, 2024, 8:47 p.m. UTC | #2
Quoting James Almer (2024-09-15 22:35:09)
> What is the use case for AVFrame->metadata?

As far as I'm concerned, it's a mistake that should never have existed.

> What gets written there and what is expected by library users? Is it
> documented at all? Because a single int like this feels like would fit
> better there rather than as side data.

Storing native data types in strings, thus forcing all users to convert
back and forth, is a horrible user-hostile approach.
diff mbox series

Patch

diff --git a/doc/APIchanges b/doc/APIchanges
index 830a38cd69..189932c99c 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@  The last version increases of all libraries were on 2024-03-07
 
 API changes, most recent first:
 
+2024-xx-xx - xxxxxxx - lavu 59.37.100 - frame.h
+  Add AV_FRAME_DATA_VIEW_ID.
+
 2024-09-xx - xxxxxxxxxx - lavc 61.13.100 - avcodec.h
   Add avcodec_get_supported_config() and enum AVCodecConfig; deprecate
   AVCodec.pix_fmts, AVCodec.sample_fmts, AVCodec.supported_framerates,
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index bf5ebe3ce0..14b98d22a1 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2920,6 +2920,8 @@  static void print_frame_side_data(WriterContext *w,
         } else if (sd->type == AV_FRAME_DATA_FILM_GRAIN_PARAMS) {
             AVFilmGrainParams *fgp = (AVFilmGrainParams *)sd->data;
             print_film_grain_params(w, fgp);
+        } else if (sd->type == AV_FRAME_DATA_VIEW_ID) {
+            print_int("view_id", *(int*)sd->data);
         }
         writer_print_section_footer(w);
     }
diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index f81df9d1bf..77082505f5 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -857,6 +857,8 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
         case AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT:
             dump_ambient_viewing_environment(ctx, sd);
             break;
+        case AV_FRAME_DATA_VIEW_ID:
+            av_log(ctx, AV_LOG_INFO, "view id: %d\n", *(int*)sd->data);
         default:
             if (name)
                 av_log(ctx, AV_LOG_INFO,
diff --git a/libavutil/frame.c b/libavutil/frame.c
index 5cbfc6a48b..891909fc2a 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -46,6 +46,7 @@  static const AVSideDataDescriptor sd_props[] = {
     [AV_FRAME_DATA_DETECTION_BBOXES]            = { "Bounding boxes for object detection and classification" },
     [AV_FRAME_DATA_DOVI_RPU_BUFFER]             = { "Dolby Vision RPU Data" },
     [AV_FRAME_DATA_DOVI_METADATA]               = { "Dolby Vision Metadata" },
+    [AV_FRAME_DATA_VIEW_ID]                     = { "View ID" },
     [AV_FRAME_DATA_STEREO3D]                    = { "Stereo 3D",                                    AV_SIDE_DATA_PROP_GLOBAL },
     [AV_FRAME_DATA_REPLAYGAIN]                  = { "AVReplayGain",                                 AV_SIDE_DATA_PROP_GLOBAL },
     [AV_FRAME_DATA_DISPLAYMATRIX]               = { "3x3 displaymatrix",                            AV_SIDE_DATA_PROP_GLOBAL },
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 60bb966f8b..cea1c68df5 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -228,6 +228,15 @@  enum AVFrameSideDataType {
      * encoding.
      */
     AV_FRAME_DATA_VIDEO_HINT,
+
+    /**
+     * This side data must be associated with a video frame.
+     * The presence of this side data indicates that the video stream is
+     * composed of multiple views (e.g. stereoscopic 3D content,
+     * cf. H.264 Annex H or H.265 Annex G).
+     * The data is an int storing the view ID.
+     */
+    AV_FRAME_DATA_VIEW_ID,
 };
 
 enum AVActiveFormatDescription {
diff --git a/libavutil/version.h b/libavutil/version.h
index 25a6f5531b..7900379c12 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@ 
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  59
-#define LIBAVUTIL_VERSION_MINOR  36
+#define LIBAVUTIL_VERSION_MINOR  37
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \