[FFmpeg-devel] [PATCH v4 13/22] avdevice: change device capabilities option type

Diederick Niehorster dcnieho at gmail.com
Fri Mar 25 16:10:32 EET 2022


Changes fps option from AVRational to double. This since any device
capability query results are returned in AVOptionRanges, which hold the
value as doubles, which can't contain AVRationals.

Also updated documentation of other capabilities, some had the wrong
option type listed.

micro version bump as this capabilities API is unused for now.

Signed-off-by: Diederick Niehorster <dcnieho at gmail.com>
---
 libavdevice/avdevice.c | 4 ++--
 libavdevice/avdevice.h | 6 +++---
 libavdevice/internal.h | 4 +++-
 libavdevice/version.h  | 2 +-
 4 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c
index db412985b2..33061b4408 100644
--- a/libavdevice/avdevice.c
+++ b/libavdevice/avdevice.c
@@ -51,8 +51,8 @@ const AVOption ff_device_capabilities[] = {
         {.str = NULL}, -1, INT_MAX, E|D|V },
     { "frame_size", "frame size", OFFSET(frame_width), AV_OPT_TYPE_IMAGE_SIZE,
         {.str = NULL}, -1, INT_MAX, E|D|V },
-    { "fps", "fps", OFFSET(fps), AV_OPT_TYPE_RATIONAL,
-        {.dbl = -1}, -1, INT_MAX, E|D|V },
+    { "fps", "fps", OFFSET(fps), AV_OPT_TYPE_DOUBLE,
+        {.dbl = NAN}, 0, INT_MAX, E|D|V },
     { NULL }
 };
 
diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h
index 6d45c74616..a815d65f12 100644
--- a/libavdevice/avdevice.h
+++ b/libavdevice/avdevice.h
@@ -360,7 +360,7 @@ int avdevice_dev_to_app_control_message(struct AVFormatContext *s,
  *                      type: AV_OPT_TYPE_INT (AVCodecID value)
  *  - Capabilities valid for audio devices:
  *    - sample_format:  supported sample formats.
- *                      type: AV_OPT_TYPE_INT (AVSampleFormat value)
+ *                      type: AV_OPT_TYPE_SAMPLE_FMT
  *    - sample_rate:    supported sample rates.
  *                      type: AV_OPT_TYPE_INT
  *    - channels:       supported number of channels.
@@ -369,13 +369,13 @@ int avdevice_dev_to_app_control_message(struct AVFormatContext *s,
  *                      type: AV_OPT_TYPE_INT64
  *  - Capabilities valid for video devices:
  *    - pixel_format:   supported pixel formats.
- *                      type: AV_OPT_TYPE_INT (AVPixelFormat value)
+ *                      type: AV_OPT_TYPE_PIXEL_FMT
  *    - window_size:    supported window sizes (describes size of the window size presented to the user).
  *                      type: AV_OPT_TYPE_IMAGE_SIZE
  *    - frame_size:     supported frame sizes (describes size of provided video frames).
  *                      type: AV_OPT_TYPE_IMAGE_SIZE
  *    - fps:            supported fps values
- *                      type: AV_OPT_TYPE_RATIONAL
+ *                      type: AV_OPT_TYPE_DOUBLE
  *
  * Value of the capability may be set by user using av_opt_set() function
  * and AVDeviceCapabilitiesQuery object. Following queries will
diff --git a/libavdevice/internal.h b/libavdevice/internal.h
index eee493a4c7..5f0bd403dd 100644
--- a/libavdevice/internal.h
+++ b/libavdevice/internal.h
@@ -50,7 +50,9 @@ struct AVDeviceCapabilitiesQuery {
     int window_height;
     int frame_width;
     int frame_height;
-    AVRational fps;
+    // NB: an AVRational cannot be represented in the AVOptionRange
+    // output of av_opt_query_ranges, so we store fps as double instead
+    double fps;
 };
 
 /**
diff --git a/libavdevice/version.h b/libavdevice/version.h
index d789b3fd7b..9853069a2d 100644
--- a/libavdevice/version.h
+++ b/libavdevice/version.h
@@ -31,7 +31,7 @@
 #include "version_major.h"
 
 #define LIBAVDEVICE_VERSION_MINOR   1
-#define LIBAVDEVICE_VERSION_MICRO 100
+#define LIBAVDEVICE_VERSION_MICRO 101
 
 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
                                                LIBAVDEVICE_VERSION_MINOR, \
-- 
2.28.0.windows.1



More information about the ffmpeg-devel mailing list