diff mbox series

[FFmpeg-devel,1/2] lavc: add new minimize_copies hwaccel_flag

Message ID 20221205222559.107006-1-timo@rothenpieler.org
State New
Headers show
Series [FFmpeg-devel,1/2] lavc: add new minimize_copies hwaccel_flag | 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

Timo Rothenpieler Dec. 5, 2022, 10:25 p.m. UTC
---
 doc/APIchanges             |  3 +++
 libavcodec/avcodec.h       | 11 +++++++++++
 libavcodec/options_table.h |  1 +
 libavcodec/version.h       |  2 +-
 4 files changed, 16 insertions(+), 1 deletion(-)

Comments

Philip Langdale Dec. 6, 2022, 11:42 p.m. UTC | #1
On Mon,  5 Dec 2022 23:25:58 +0100
Timo Rothenpieler <timo@rothenpieler.org> wrote:

> ---
>  doc/APIchanges             |  3 +++
>  libavcodec/avcodec.h       | 11 +++++++++++
>  libavcodec/options_table.h |  1 +
>  libavcodec/version.h       |  2 +-
>  4 files changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index ab7ce15fae..9c1f905a61 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -14,6 +14,9 @@ libavutil:     2021-04-27
>  
>  API changes, most recent first:
>  
> +2022-12-xx - xxxxxxxxxx - lavc 59.54.101 - avcodec.h
> +  Add AV_HWACCEL_FLAG_MINIMIZE_COPIES.
> +
>  2022-11-xx - xxxxxxxxxx - lavu 57.43.100 - tx.h
>    Add AV_TX_FLOAT_DCT, AV_TX_DOUBLE_DCT and AV_TX_INT32_DCT.
>  
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 3edd8e2636..a72551bb5e 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -2253,6 +2253,17 @@ typedef struct AVHWAccel {
>   */
>  #define AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH (1 << 2)
>  
> +/**
> + * Hardware acceleration can have a limited number of direct output
> surfaces.
> + * For some processing chains, this can be okay, but others will run
> into the
> + * limit and in turn produce very confusing errors.
> + *
> + * Thus, the hwaccel will by default make a safety copy. If a users
> really
> + * wants to minimize the amount of copies, they can set this flag
> and ensure
> + * their chain does not exhaust the surface pool.
> + */
> +#define AV_HWACCEL_FLAG_MINIMIZE_COPIES (1 << 3)

I would soften the statement about making a safety copy to make it
clear that only hwaccels where limits are relevant will make safety
copies. Otherwise people will think every other hwaccel has suddenly
started doing it.

Otherwise, LGTM.

--phil
Andreas Rheinhardt Dec. 7, 2022, 3:05 a.m. UTC | #2
Timo Rothenpieler:
> ---
>  doc/APIchanges             |  3 +++
>  libavcodec/avcodec.h       | 11 +++++++++++
>  libavcodec/options_table.h |  1 +
>  libavcodec/version.h       |  2 +-
>  4 files changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index ab7ce15fae..9c1f905a61 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -14,6 +14,9 @@ libavutil:     2021-04-27
>  
>  API changes, most recent first:
>  
> +2022-12-xx - xxxxxxxxxx - lavc 59.54.101 - avcodec.h
> +  Add AV_HWACCEL_FLAG_MINIMIZE_COPIES.
> +
>  2022-11-xx - xxxxxxxxxx - lavu 57.43.100 - tx.h
>    Add AV_TX_FLOAT_DCT, AV_TX_DOUBLE_DCT and AV_TX_INT32_DCT.
>  
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 3edd8e2636..a72551bb5e 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -2253,6 +2253,17 @@ typedef struct AVHWAccel {
>   */
>  #define AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH (1 << 2)
>  
> +/**
> + * Hardware acceleration can have a limited number of direct output surfaces.
> + * For some processing chains, this can be okay, but others will run into the
> + * limit and in turn produce very confusing errors.
> + *
> + * Thus, the hwaccel will by default make a safety copy. If a users really
> + * wants to minimize the amount of copies, they can set this flag and ensure
> + * their chain does not exhaust the surface pool.
> + */
> +#define AV_HWACCEL_FLAG_MINIMIZE_COPIES (1 << 3)
> +
>  /**
>   * @}
>   */
> diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
> index cd02f5096f..05e8948bc2 100644
> --- a/libavcodec/options_table.h
> +++ b/libavcodec/options_table.h
> @@ -399,6 +399,7 @@ static const AVOption avcodec_options[] = {
>  {"ignore_level", "ignore level even if the codec level used is unknown or higher than the maximum supported level reported by the hardware driver", 0, AV_OPT_TYPE_CONST, { .i64 = AV_HWACCEL_FLAG_IGNORE_LEVEL }, INT_MIN, INT_MAX, V | D, "hwaccel_flags" },
>  {"allow_high_depth", "allow to output YUV pixel formats with a different chroma sampling than 4:2:0 and/or other than 8 bits per component", 0, AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH }, INT_MIN, INT_MAX, V | D, "hwaccel_flags"},
>  {"allow_profile_mismatch", "attempt to decode anyway if HW accelerated decoder's supported profiles do not exactly match the stream", 0, AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH }, INT_MIN, INT_MAX, V | D, "hwaccel_flags"},
> +{"minimize_copies", "minimize number of frame copies at cost of risking surface pool exhaustion", 0, AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_MINIMIZE_COPIES }, INT_MIN, INT_MAX, V | D, "hwaccel_flags"},
>  {"extra_hw_frames", "Number of extra hardware frames to allocate for the user", OFFSET(extra_hw_frames), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, V|D },
>  {"discard_damaged_percentage", "Percentage of damaged samples to discard a frame", OFFSET(discard_damaged_percentage), AV_OPT_TYPE_INT, {.i64 = 95 }, 0, 100, V|D },
>  {NULL},
> diff --git a/libavcodec/version.h b/libavcodec/version.h
> index d149bc6c46..9e66920593 100644
> --- a/libavcodec/version.h
> +++ b/libavcodec/version.h
> @@ -30,7 +30,7 @@
>  #include "version_major.h"
>  
>  #define LIBAVCODEC_VERSION_MINOR  54
> -#define LIBAVCODEC_VERSION_MICRO 100
> +#define LIBAVCODEC_VERSION_MICRO 101

A new public define needs a minor bump.

>  
>  #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
>                                                 LIBAVCODEC_VERSION_MINOR, \
diff mbox series

Patch

diff --git a/doc/APIchanges b/doc/APIchanges
index ab7ce15fae..9c1f905a61 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,9 @@  libavutil:     2021-04-27
 
 API changes, most recent first:
 
+2022-12-xx - xxxxxxxxxx - lavc 59.54.101 - avcodec.h
+  Add AV_HWACCEL_FLAG_MINIMIZE_COPIES.
+
 2022-11-xx - xxxxxxxxxx - lavu 57.43.100 - tx.h
   Add AV_TX_FLOAT_DCT, AV_TX_DOUBLE_DCT and AV_TX_INT32_DCT.
 
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 3edd8e2636..a72551bb5e 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2253,6 +2253,17 @@  typedef struct AVHWAccel {
  */
 #define AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH (1 << 2)
 
+/**
+ * Hardware acceleration can have a limited number of direct output surfaces.
+ * For some processing chains, this can be okay, but others will run into the
+ * limit and in turn produce very confusing errors.
+ *
+ * Thus, the hwaccel will by default make a safety copy. If a users really
+ * wants to minimize the amount of copies, they can set this flag and ensure
+ * their chain does not exhaust the surface pool.
+ */
+#define AV_HWACCEL_FLAG_MINIMIZE_COPIES (1 << 3)
+
 /**
  * @}
  */
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index cd02f5096f..05e8948bc2 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -399,6 +399,7 @@  static const AVOption avcodec_options[] = {
 {"ignore_level", "ignore level even if the codec level used is unknown or higher than the maximum supported level reported by the hardware driver", 0, AV_OPT_TYPE_CONST, { .i64 = AV_HWACCEL_FLAG_IGNORE_LEVEL }, INT_MIN, INT_MAX, V | D, "hwaccel_flags" },
 {"allow_high_depth", "allow to output YUV pixel formats with a different chroma sampling than 4:2:0 and/or other than 8 bits per component", 0, AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH }, INT_MIN, INT_MAX, V | D, "hwaccel_flags"},
 {"allow_profile_mismatch", "attempt to decode anyway if HW accelerated decoder's supported profiles do not exactly match the stream", 0, AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH }, INT_MIN, INT_MAX, V | D, "hwaccel_flags"},
+{"minimize_copies", "minimize number of frame copies at cost of risking surface pool exhaustion", 0, AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_MINIMIZE_COPIES }, INT_MIN, INT_MAX, V | D, "hwaccel_flags"},
 {"extra_hw_frames", "Number of extra hardware frames to allocate for the user", OFFSET(extra_hw_frames), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, V|D },
 {"discard_damaged_percentage", "Percentage of damaged samples to discard a frame", OFFSET(discard_damaged_percentage), AV_OPT_TYPE_INT, {.i64 = 95 }, 0, 100, V|D },
 {NULL},
diff --git a/libavcodec/version.h b/libavcodec/version.h
index d149bc6c46..9e66920593 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -30,7 +30,7 @@ 
 #include "version_major.h"
 
 #define LIBAVCODEC_VERSION_MINOR  54
-#define LIBAVCODEC_VERSION_MICRO 100
+#define LIBAVCODEC_VERSION_MICRO 101
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                LIBAVCODEC_VERSION_MINOR, \