[FFmpeg-devel] [PATCH 1/3] lavu/frame: add av_frame_check_align().
Nicolas George
george at nsup.org
Tue May 9 16:19:42 EEST 2017
Signed-off-by: Nicolas George <george at nsup.org>
---
doc/APIchanges | 3 +++
libavutil/frame.c | 18 ++++++++++++++++++
libavutil/frame.h | 8 ++++++++
libavutil/version.h | 2 +-
4 files changed, 30 insertions(+), 1 deletion(-)
Added "const" and the version bump.
diff --git a/doc/APIchanges b/doc/APIchanges
index 09b1a49798..939d7d5f69 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2015-08-28
API changes, most recent first:
+2017-xx-xx - xxxxxxxxxx - lavu 55.63.100 - frame.h
+ Add av_frame_check_align().
+
2017-xx-xx - xxxxxxx - lavc 57.95.100 / 57.31.0 - avcodec.h
Add AVCodecContext.apply_cropping to control whether cropping
is handled by libavcodec or the caller.
diff --git a/libavutil/frame.c b/libavutil/frame.c
index 24d5d5f184..e8467a1cd6 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -781,3 +781,21 @@ const char *av_frame_side_data_name(enum AVFrameSideDataType type)
}
return NULL;
}
+
+int av_frame_check_align(const AVFrame *frame, unsigned align)
+{
+ unsigned mask = (1 << align) - 1;
+ unsigned i;
+ int ret;
+
+ av_assert1(align < 16);
+ for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
+ if (((intptr_t)frame->data[i] & mask))
+ return 0;
+ if (!frame->extended_data || frame->extended_data == frame->data)
+ return 1;
+ for (i = AV_NUM_DATA_POINTERS; i < frame->channels; i++)
+ if (((intptr_t)frame->extended_data[i] & mask))
+ return 0;
+ return 1;
+}
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 26261d7e40..196d311e29 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -772,6 +772,14 @@ void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type);
const char *av_frame_side_data_name(enum AVFrameSideDataType type);
/**
+ * Check if the data pointers of a frame are aligned enough.
+ * Test if all frame data pointers have the alignment lower bits cleared,
+ * i.e. are a multiple of 1<<alignment.
+ * @return >0 if aligned, 0 if not
+ */
+int av_frame_check_align(const AVFrame *frame, unsigned align);
+
+/**
* @}
*/
diff --git a/libavutil/version.h b/libavutil/version.h
index 6762bf300a..fb61dcc666 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -80,7 +80,7 @@
#define LIBAVUTIL_VERSION_MAJOR 55
-#define LIBAVUTIL_VERSION_MINOR 62
+#define LIBAVUTIL_VERSION_MINOR 63
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
--
2.11.0
More information about the ffmpeg-devel
mailing list