There are several reasons for doing that: 1. It documents the code for the reader and helps find inconsistencies and bugs. 2. For rej_perms, it guarantees the change will be done even if the output reference can be created by several code paths. 3. It can be used to predict cases where a copy will, or will not happen and optimize buffer allocation (for example not request a rare direct-rendering buffer from a device sink if it will be copied anyway). Note that a filter is still allowed to manage the permissions on its own without using these fields.
Showing the changes to libavfilter/avfilter.h (1 of 3 files). Show all
Unified · Split
| @@ -240,22 +240,29 @@ struct AVFilterPad { · 239 unmodified lines | |||
| 240 | enum AVMediaType type; | 240 | enum AVMediaType type; |
| 241 | 241 | ||
| 242 | /** | 242 | /** |
| 243 | * Input pads: | ||
| 243 | * Minimum required permissions on incoming buffers. Any buffer with | 244 | * Minimum required permissions on incoming buffers. Any buffer with |
| 244 | * insufficient permissions will be automatically copied by the filter | 245 | * insufficient permissions will be automatically copied by the filter |
| 245 | * system to a new buffer which provides the needed access permissions. | 246 | * system to a new buffer which provides the needed access permissions. |
| 246 | * | 247 | * |
| 247 | * Input pads only. | 248 | * Output pads: |
| 249 | * Guaranteed permissions on outgoing buffers. Any buffer pushed on the | ||
| 250 | * link must have at least these permissions; this fact is checked by | ||
| 251 | * asserts. It can be used to optimize buffer allocation. | ||
| 248 | */ | 252 | */ |
| 249 | int min_perms; | 253 | int min_perms; |
| 250 | 254 | ||
| 251 | /** | 255 | /** |
| 256 | * Input pads: | ||
| 252 | * Permissions which are not accepted on incoming buffers. Any buffer | 257 | * Permissions which are not accepted on incoming buffers. Any buffer |
| 253 | * which has any of these permissions set will be automatically copied | 258 | * which has any of these permissions set will be automatically copied |
| 254 | * by the filter system to a new buffer which does not have those | 259 | * by the filter system to a new buffer which does not have those |
| 255 | * permissions. This can be used to easily disallow buffers with | 260 | * permissions. This can be used to easily disallow buffers with |
| 256 | * AV_PERM_REUSE. | 261 | * AV_PERM_REUSE. |
| 257 | * | 262 | * |
| 258 | * Input pads only. | 263 | * Output pads: |
| 264 | * Permissions which are automatically removed on outgoing buffers. It | ||
| 265 | * can be used to optimize buffer allocation. | ||
| 259 | */ | 266 | */ |
| 260 | int rej_perms; | 267 | int rej_perms; |
| 261 | 268 | ||