The permissions not requested by the filter that created the buffer may be useful for a later filter and avoid a copy.
Showing the changes to libavfilter/audio.c (1 of 1 file). Show all
Unified · Split
| @@ -42,6 +42,10 @@ AVFilterBufferRef *ff_default_get_audio_buffer(AVFilterLink *link, int perms, · 41 unmodified lines | |||
| 42 | int nb_channels = av_get_channel_layout_nb_channels(link->channel_layout); | 42 | int nb_channels = av_get_channel_layout_nb_channels(link->channel_layout); |
| 43 | int planes = planar ? nb_channels : 1; | 43 | int planes = planar ? nb_channels : 1; |
| 44 | int linesize; | 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 | if (!(data = av_mallocz(sizeof(*data) * planes))) | 50 | if (!(data = av_mallocz(sizeof(*data) * planes))) |
| 47 | goto fail; | 51 | goto fail; |
| @@ -49,7 +53,7 @@ AVFilterBufferRef *ff_default_get_audio_buffer(AVFilterLink *link, int perms, · 1 unmodified line | |||
| 49 | if (av_samples_alloc(data, &linesize, nb_channels, nb_samples, link->format, 0) < 0) | 53 | if (av_samples_alloc(data, &linesize, nb_channels, nb_samples, link->format, 0) < 0) |
| 50 | goto fail; | 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 | nb_samples, link->format, | 57 | nb_samples, link->format, |
| 54 | link->channel_layout); | 58 | link->channel_layout); |
| 55 | if (!samplesref) | 59 | if (!samplesref) |