Showing the changes to libavfilter (3 of 3 files). Show all
Unified · Split
| @@ -22,15 +22,13 @@ · 21 unmodified lines | ||
| 22 | 22 | #include "libavutil/avassert.h" |
| 23 | 23 | #include "libavutil/channel_layout.h" |
| 24 | 24 | #include "libavutil/common.h" |
| 25 | +#include "libavutil/cpu.h" | |
| 25 | 26 | |
| 26 | 27 | #include "audio.h" |
| 27 | 28 | #include "avfilter.h" |
| 28 | 29 | #include "framepool.h" |
| 29 | 30 | #include "internal.h" |
| 30 | 31 | |
| 31 | −#define BUFFER_ALIGN 0 | |
| 32 | − | |
| 33 | − | |
| 34 | 32 | AVFrame *ff_null_get_audio_buffer(AVFilterLink *link, int nb_samples) |
| 35 | 33 | { |
| 36 | 34 | return ff_get_audio_buffer(link->dst->outputs[0], nb_samples); |
| @@ -41,12 +39,13 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink *link, int nb_samples) · 4 unmodified lines | ||
| 41 | 39 | AVFrame *frame = NULL; |
| 42 | 40 | int channels = link->channels; |
| 43 | 41 | int channel_layout_nb_channels = av_get_channel_layout_nb_channels(link->channel_layout); |
| 42 | + int align = av_cpu_max_align(); | |
| 44 | 43 | |
| 45 | 44 | av_assert0(channels == channel_layout_nb_channels || !channel_layout_nb_channels); |
| 46 | 45 | |
| 47 | 46 | if (!link->frame_pool) { |
| 48 | 47 | link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, channels, |
| 49 | − nb_samples, link->format, BUFFER_ALIGN); | |
| 48 | + nb_samples, link->format, align); | |
| 50 | 49 | if (!link->frame_pool) |
| 51 | 50 | return NULL; |
| 52 | 51 | } else { |
| @@ -62,11 +61,11 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink *link, int nb_samples) · 9 unmodified lines | ||
| 62 | 61 | } |
| 63 | 62 | |
| 64 | 63 | if (pool_channels != channels || pool_nb_samples < nb_samples || |
| 65 | − pool_format != link->format || pool_align != BUFFER_ALIGN) { | |
| 64 | + pool_format != link->format || pool_align != align) { | |
| 66 | 65 | |
| 67 | 66 | ff_frame_pool_uninit((FFFramePool **)&link->frame_pool); |
| 68 | 67 | link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, channels, |
| 69 | − nb_samples, link->format, BUFFER_ALIGN); | |
| 68 | + nb_samples, link->format, align); | |
| 70 | 69 | if (!link->frame_pool) |
| 71 | 70 | return NULL; |
| 72 | 71 | } |
| @@ -76,27 +76,25 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef* (*alloc)(size_t size), · 75 unmodified lines | ||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | if (!pool->linesize[0]) { |
| 79 | − for(i = 1; i <= align; i += i) { | |
| 80 | − ret = av_image_fill_linesizes(pool->linesize, pool->format, | |
| 81 | − FFALIGN(pool->width, i)); | |
| 82 | − if (ret < 0) { | |
| 83 | − goto fail; | |
| 84 | − } | |
| 85 | − if (!(pool->linesize[0] & (pool->align - 1))) | |
| 86 | − break; | |
| 79 | + ret = av_image_fill_linesizes(pool->linesize, pool->format, | |
| 80 | + FFALIGN(pool->width, align)); | |
| 81 | + if (ret < 0) { | |
| 82 | + goto fail; | |
| 87 | 83 | } |
| 88 | 84 | |
| 89 | 85 | for (i = 0; i < 4 && pool->linesize[i]; i++) { |
| 90 | 86 | pool->linesize[i] = FFALIGN(pool->linesize[i], pool->align); |
| 87 | + if ((pool->linesize[i] & (pool->align - 1))) | |
| 88 | + goto fail; | |
| 91 | 89 | } |
| 92 | 90 | } |
| 93 | 91 | |
| 94 | 92 | for (i = 0; i < 4 && pool->linesize[i]; i++) { |
| 95 | − int h = FFALIGN(pool->height, 32); | |
| 93 | + int h = pool->height; | |
| 96 | 94 | if (i == 1 || i == 2) |
| 97 | 95 | h = AV_CEIL_RSHIFT(h, desc->log2_chroma_h); |
| 98 | 96 | |
| 99 | − pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h + 16 + 16 - 1, | |
| 97 | + pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h + align, | |
| 100 | 98 | alloc); |
| 101 | 99 | if (!pool->pools[i]) |
| 102 | 100 | goto fail; |
| @@ -24,6 +24,7 @@ · 23 unmodified lines | ||
| 24 | 24 | #include <stdio.h> |
| 25 | 25 | |
| 26 | 26 | #include "libavutil/buffer.h" |
| 27 | +#include "libavutil/cpu.h" | |
| 27 | 28 | #include "libavutil/hwcontext.h" |
| 28 | 29 | #include "libavutil/imgutils.h" |
| 29 | 30 | |
| @@ -32,9 +33,6 @@ · 2 unmodified lines | ||
| 32 | 33 | #include "internal.h" |
| 33 | 34 | #include "video.h" |
| 34 | 35 | |
| 35 | −#define BUFFER_ALIGN 32 | |
| 36 | − | |
| 37 | − | |
| 38 | 36 | AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, int h) |
| 39 | 37 | { |
| 40 | 38 | return ff_get_video_buffer(link->dst->outputs[0], w, h); |
| @@ -46,6 +44,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h) · 5 unmodified lines | ||
| 46 | 44 | int pool_width = 0; |
| 47 | 45 | int pool_height = 0; |
| 48 | 46 | int pool_align = 0; |
| 47 | + int align = av_cpu_max_align(); | |
| 49 | 48 | enum AVPixelFormat pool_format = AV_PIX_FMT_NONE; |
| 50 | 49 | |
| 51 | 50 | if (link->hw_frames_ctx && |
| @@ -65,7 +64,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h) · 13 unmodified lines | ||
| 65 | 64 | |
| 66 | 65 | if (!link->frame_pool) { |
| 67 | 66 | link->frame_pool = ff_frame_pool_video_init(av_buffer_allocz, w, h, |
| 68 | − link->format, BUFFER_ALIGN); | |
| 67 | + link->format, align); | |
| 69 | 68 | if (!link->frame_pool) |
| 70 | 69 | return NULL; |
| 71 | 70 | } else { |
| @@ -76,11 +75,11 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h) · 4 unmodified lines | ||
| 76 | 75 | } |
| 77 | 76 | |
| 78 | 77 | if (pool_width != w || pool_height != h || |
| 79 | − pool_format != link->format || pool_align != BUFFER_ALIGN) { | |
| 78 | + pool_format != link->format || pool_align != align) { | |
| 80 | 79 | |
| 81 | 80 | ff_frame_pool_uninit((FFFramePool **)&link->frame_pool); |
| 82 | 81 | link->frame_pool = ff_frame_pool_video_init(av_buffer_allocz, w, h, |
| 83 | − link->format, BUFFER_ALIGN); | |
| 82 | + link->format, align); | |
| 84 | 83 | if (!link->frame_pool) |
| 85 | 84 | return NULL; |
| 86 | 85 | } |