diff options
author | Clément Bœsch <clement@stupeflix.com> | 2014-07-16 16:42:42 +0200 |
---|---|---|
committer | Clément Bœsch <clement@stupeflix.com> | 2014-08-18 14:13:57 +0200 |
commit | b0352b1997a83f1b6b27919b94aab539f099b25b (patch) | |
tree | 5d7f4f64a17d8f0ec623eb101755f6e9fe036ff8 /libavutil | |
parent | c5f43c8888400f5fab6f7d2ad27e961e8d2616a5 (diff) | |
download | ffmpeg-b0352b1997a83f1b6b27919b94aab539f099b25b.tar.gz |
avcodec: export motion vectors in frame side data on demand
The reasoning behind this addition is that various third party
applications are interested in getting some motion information out of a
video "for free" when it is available.
It was considered to export other information as well (such as the intra
information about the block, or the quantization) but the structure
might have ended up into a half full-generic, half full of codec
specific cruft. If more information is necessary, it should either be
added in the "flags" field of the AVMotionVector structure, or in
another side-data.
This commit also includes an example exporting them in a CSV stream.
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/Makefile | 1 | ||||
-rw-r--r-- | libavutil/frame.c | 1 | ||||
-rw-r--r-- | libavutil/frame.h | 7 | ||||
-rw-r--r-- | libavutil/motion_vector.h | 50 | ||||
-rw-r--r-- | libavutil/version.h | 2 |
5 files changed, 60 insertions, 1 deletions
diff --git a/libavutil/Makefile b/libavutil/Makefile index d3a92457f6..48ae0efa43 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -38,6 +38,7 @@ HEADERS = adler32.h \ mathematics.h \ md5.h \ mem.h \ + motion_vector.h \ murmur3.h \ dict.h \ old_pix_fmts.h \ diff --git a/libavutil/frame.c b/libavutil/frame.c index 12eac5540b..4dc8e4ea5d 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -683,6 +683,7 @@ const char *av_frame_side_data_name(enum AVFrameSideDataType type) case AV_FRAME_DATA_DOWNMIX_INFO: return "Metadata relevant to a downmix procedure"; case AV_FRAME_DATA_REPLAYGAIN: return "AVReplayGain"; case AV_FRAME_DATA_DISPLAYMATRIX: return "3x3 displaymatrix"; + case AV_FRAME_DATA_MOTION_VECTORS: return "Motion vectors"; } return NULL; } diff --git a/libavutil/frame.h b/libavutil/frame.h index dbbdd29d1b..2391d3e48e 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -87,6 +87,13 @@ enum AVFrameSideDataType { * in ETSI TS 101 154 using AVActiveFormatDescription enum. */ AV_FRAME_DATA_AFD, + /** + * Motion vectors exported by some codecs (on demand through the export_mvs + * flag set in the libavcodec AVCodecContext flags2 option). + * The data is the AVMotionVector struct defined in + * libavutil/motion_vector.h. + */ + AV_FRAME_DATA_MOTION_VECTORS, }; enum AVActiveFormatDescription { diff --git a/libavutil/motion_vector.h b/libavutil/motion_vector.h new file mode 100644 index 0000000000..245e5116a3 --- /dev/null +++ b/libavutil/motion_vector.h @@ -0,0 +1,50 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_MOTION_VECTOR_H +#define AVUTIL_MOTION_VECTOR_H + +#include <stdint.h> + +typedef struct AVMotionVector { + /** + * Where the current macroblock comes from; negative value when it comes + * from the past, positive value when it comes from the future. + * XXX: set exact relative ref frame reference instead of a +/- 1 "direction". + */ + int32_t source; + /** + * Width and height of the block. + */ + uint8_t w, h; + /** + * Absolute source position. + */ + uint16_t src_x, src_y; + /** + * Absolute destination position. + */ + uint16_t dst_x, dst_y; + /** + * Extra flag information. + * Currently unused. + */ + uint64_t flags; +} AVMotionVector; + +#endif /* AVUTIL_MOTION_VECTOR_H */ diff --git a/libavutil/version.h b/libavutil/version.h index b86609b08a..d42209dcc9 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -56,7 +56,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 54 -#define LIBAVUTIL_VERSION_MINOR 4 +#define LIBAVUTIL_VERSION_MINOR 5 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ |