[FFmpeg-cvslog] frame: allow align=0 (meaning automatic) for av_frame_get_buffer()
Anton Khirnov
git at videolan.org
Thu Sep 28 05:34:39 EEST 2017
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Wed Feb 8 09:46:04 2017 +0100| [4de220d2e3751c459f8739a08ac6ca52e63eba30] | committer: Anton Khirnov
frame: allow align=0 (meaning automatic) for av_frame_get_buffer()
This will avoid every caller from hardcoding some specific alignment,
which may break in the future with new instruction sets.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4de220d2e3751c459f8739a08ac6ca52e63eba30
---
doc/APIchanges | 4 ++++
libavutil/frame.c | 4 ++++
libavutil/frame.h | 4 +++-
libavutil/version.h | 2 +-
4 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index be34c92d3f..9b9f46ef49 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,10 @@ libavutil: 2015-08-28
API changes, most recent first:
+2017-02-xx - xxxxxxx - lavu 55.31.1 - frame.h
+ Allow passing the value of 0 (meaning "automatic") as the required alignment
+ to av_frame_get_buffer().
+
2017-02-xx - xxxxxxx - lavu 55.31.0 - cpu.h
Add av_cpu_max_align() for querying maximum required data alignment.
diff --git a/libavutil/frame.c b/libavutil/frame.c
index aafaa57d8b..aa5820c0e9 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -19,6 +19,7 @@
#include "channel_layout.h"
#include "buffer.h"
#include "common.h"
+#include "cpu.h"
#include "dict.h"
#include "frame.h"
#include "imgutils.h"
@@ -103,6 +104,9 @@ static int get_video_buffer(AVFrame *frame, int align)
if (ret < 0)
return ret;
+ if (align <= 0)
+ align = av_cpu_max_align();
+
for (i = 0; i < 4 && frame->linesize[i]; i++)
frame->linesize[i] = FFALIGN(frame->linesize[i], align);
}
diff --git a/libavutil/frame.h b/libavutil/frame.h
index c718f7bd62..4f63fb0249 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -475,7 +475,9 @@ void av_frame_move_ref(AVFrame *dst, AVFrame *src);
* cases.
*
* @param frame frame in which to store the new buffers.
- * @param align required buffer size alignment
+ * @param align Required buffer size alignment. If equal to 0, alignment will be
+ * chosen automatically for the current CPU. It is highly
+ * recommended to pass 0 here unless you know what you are doing.
*
* @return 0 on success, a negative AVERROR on error.
*/
diff --git a/libavutil/version.h b/libavutil/version.h
index 0fcd19a1eb..0768f9fe99 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -55,7 +55,7 @@
#define LIBAVUTIL_VERSION_MAJOR 55
#define LIBAVUTIL_VERSION_MINOR 31
-#define LIBAVUTIL_VERSION_MICRO 0
+#define LIBAVUTIL_VERSION_MICRO 1
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
More information about the ffmpeg-cvslog
mailing list