The permissions not requested by the filter that created the buffer may be useful for a later filter and avoid a copy.
Unified · Split
| @@ -42,6 +42,10 @@ AVFilterBufferRef *ff_default_get_audio_buffer(AVFilterLink *link, int perms, · 41 unmodified lines | ||
| 42 | 42 | int nb_channels = av_get_channel_layout_nb_channels(link->channel_layout); |
| 43 | 43 | int planes = planar ? nb_channels : 1; |
| 44 | 44 | int linesize; |
| 45 | + int full_perms = AV_PERM_READ | AV_PERM_WRITE | AV_PERM_PRESERVE | | |
| 46 | + AV_PERM_REUSE | AV_PERM_REUSE2 | AV_PERM_ALIGN; | |
| 47 | + | |
| 48 | + av_assert1(!(perms & ~(full_perms | AV_PERM_NEG_LINESIZES))); | |
| 45 | 49 | |
| 46 | 50 | if (!(data = av_mallocz(sizeof(*data) * planes))) |
| 47 | 51 | goto fail; |
| @@ -49,7 +53,7 @@ AVFilterBufferRef *ff_default_get_audio_buffer(AVFilterLink *link, int perms, · 1 unmodified line | ||
| 49 | 53 | if (av_samples_alloc(data, &linesize, nb_channels, nb_samples, link->format, 0) < 0) |
| 50 | 54 | goto fail; |
| 51 | 55 | |
| 52 | − samplesref = avfilter_get_audio_buffer_ref_from_arrays(data, linesize, perms, | |
| 56 | + samplesref = avfilter_get_audio_buffer_ref_from_arrays(data, linesize, full_perms, | |
| 53 | 57 | nb_samples, link->format, |
| 54 | 58 | link->channel_layout); |
| 55 | 59 | if (!samplesref) |