This will avoid every caller from hardcoding some specific alignment, which may break in the future with new instruction sets.
Unified · Split
| @@ -13,6 +13,10 @@ libavutil: 2015-08-28 · 12 unmodified lines | |||
| 13 | 13 | ||
| 14 | API changes, most recent first: | 14 | API changes, most recent first: |
| 15 | 15 | ||
| 16 | 2017-02-xx - xxxxxxx - lavu 55.31.1 - frame.h | ||
| 17 | Allow passing the value of 0 (meaning "automatic") as the required alignment | ||
| 18 | to av_frame_get_buffer(). | ||
| 19 | |||
| 16 | 2017-02-xx - xxxxxxx - lavu 55.31.0 - cpu.h | 20 | 2017-02-xx - xxxxxxx - lavu 55.31.0 - cpu.h |
| 17 | Add av_cpu_max_align() for querying maximum required data alignment. | 21 | Add av_cpu_max_align() for querying maximum required data alignment. |
| 18 | 22 | ||
| @@ -19,6 +19,7 @@ · 18 unmodified lines | |||
| 19 | #include "channel_layout.h" | 19 | #include "channel_layout.h" |
| 20 | #include "buffer.h" | 20 | #include "buffer.h" |
| 21 | #include "common.h" | 21 | #include "common.h" |
| 22 | #include "cpu.h" | ||
| 22 | #include "dict.h" | 23 | #include "dict.h" |
| 23 | #include "frame.h" | 24 | #include "frame.h" |
| 24 | #include "imgutils.h" | 25 | #include "imgutils.h" |
| @@ -103,6 +104,9 @@ static int get_video_buffer(AVFrame *frame, int align) · 78 unmodified lines | |||
| 103 | if (ret < 0) | 104 | if (ret < 0) |
| 104 | return ret; | 105 | return ret; |
| 105 | 106 | ||
| 107 | if (align <= 0) | ||
| 108 | align = av_cpu_max_align(); | ||
| 109 | |||
| 106 | for (i = 0; i < 4 && frame->linesize[i]; i++) | 110 | for (i = 0; i < 4 && frame->linesize[i]; i++) |
| 107 | frame->linesize[i] = FFALIGN(frame->linesize[i], align); | 111 | frame->linesize[i] = FFALIGN(frame->linesize[i], align); |
| 108 | } | 112 | } |
| @@ -475,7 +475,9 @@ void av_frame_move_ref(AVFrame *dst, AVFrame *src); · 474 unmodified lines | |||
| 475 | * cases. | 475 | * cases. |
| 476 | * | 476 | * |
| 477 | * @param frame frame in which to store the new buffers. | 477 | * @param frame frame in which to store the new buffers. |
| 478 | * @param align required buffer size alignment | 478 | * @param align Required buffer size alignment. If equal to 0, alignment will be |
| 479 | * chosen automatically for the current CPU. It is highly | ||
| 480 | * recommended to pass 0 here unless you know what you are doing. | ||
| 479 | * | 481 | * |
| 480 | * @return 0 on success, a negative AVERROR on error. | 482 | * @return 0 on success, a negative AVERROR on error. |
| 481 | */ | 483 | */ |
| @@ -55,7 +55,7 @@ · 54 unmodified lines | |||
| 55 | 55 | ||
| 56 | #define LIBAVUTIL_VERSION_MAJOR 55 | 56 | #define LIBAVUTIL_VERSION_MAJOR 55 |
| 57 | #define LIBAVUTIL_VERSION_MINOR 31 | 57 | #define LIBAVUTIL_VERSION_MINOR 31 |
| 58 | #define LIBAVUTIL_VERSION_MICRO 0 | 58 | #define LIBAVUTIL_VERSION_MICRO 1 |
| 59 | 59 | ||
| 60 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ | 60 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ |
| 61 | LIBAVUTIL_VERSION_MINOR, \ | 61 | LIBAVUTIL_VERSION_MINOR, \ |