diff options
author | wm4 <nfxjfg@googlemail.com> | 2017-07-22 23:05:13 +0200 |
---|---|---|
committer | wm4 <nfxjfg@googlemail.com> | 2017-08-08 13:35:09 +0200 |
commit | caa12027baf1180453846c58da08fc87accc0ff6 (patch) | |
tree | 2a5a5cd1ecb176dc9f368ad40144f818ae79c0e6 /libavutil/frame.h | |
parent | 45759540a5597bb6811afc749baa637f778a5ca0 (diff) | |
download | ffmpeg-caa12027baf1180453846c58da08fc87accc0ff6.tar.gz |
lavc, lavu: move frame cropping to a convenience function
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Merged from Libav commit 47399ccdfd.
Diffstat (limited to 'libavutil/frame.h')
-rw-r--r-- | libavutil/frame.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/libavutil/frame.h b/libavutil/frame.h index 5a987a1dfa..013043c250 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -773,6 +773,40 @@ AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, */ void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type); + +/** + * Flags for frame cropping. + */ +enum { + /** + * Apply the maximum possible cropping, even if it requires setting the + * AVFrame.data[] entries to unaligned pointers. Passing unaligned data + * to Libav API is generally not allowed, and causes undefined behavior + * (such as crashes). You can pass unaligned data only to Libav APIs that + * are explicitly documented to accept it. Use this flag only if you + * absolutely know what you are doing. + */ + AV_FRAME_CROP_UNALIGNED = 1 << 0, +}; + +/** + * Crop the given video AVFrame according to its crop_left/crop_top/crop_right/ + * crop_bottom fields. If cropping is successful, the function will adjust the + * data pointers and the width/height fields, and set the crop fields to 0. + * + * In all cases, the cropping boundaries will be rounded to the inherent + * alignment of the pixel format. In some cases, such as for opaque hwaccel + * formats, the left/top cropping is ignored. The crop fields are set to 0 even + * if the cropping was rounded or ignored. + * + * @param frame the frame which should be cropped + * @param flags Some combination of AV_FRAME_CROP_* flags, or 0. + * + * @return >= 0 on success, a negative AVERROR on error. If the cropping fields + * were invalid, AVERROR(ERANGE) is returned, and nothing is changed. + */ +int av_frame_apply_cropping(AVFrame *frame, int flags); + /** * @return a string identifying the side data type */ |