[FFmpeg-devel] [PATCH v3 24/34] avdevice: change device capabilities option type

Diederick Niehorster dcnieho at gmail.com
Tue Jul 6 12:20:10 EEST 2021


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 cb139e6d4a..73c6738383 100644
--- a/libavdevice/avdevice.c
+++ b/libavdevice/avdevice.c
@@ -50,8 +50,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 44c4f185a2..758c650636 100644
--- a/libavdevice/avdevice.h
+++ b/libavdevice/avdevice.h
@@ -344,7 +344,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.
@@ -353,13 +353,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 e0361aebc1..0df40ef4c7 100644
--- a/libavdevice/version.h
+++ b/libavdevice/version.h
@@ -29,7 +29,7 @@
 
 #define LIBAVDEVICE_VERSION_MAJOR  59
 #define LIBAVDEVICE_VERSION_MINOR   3
-#define LIBAVDEVICE_VERSION_MICRO 101
+#define LIBAVDEVICE_VERSION_MICRO 102
 
 #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