Commit c6666894 authored by James Almer's avatar James Almer

avcodec: add an AVCodecContext field to signal types of packet, frame, and...

avcodec: add an AVCodecContext field to signal types of packet, frame, and coded stream side data to export

Add an initial mvs flag to is, analog to the export_mvs flags2 one.
Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
parent 5dda6c17
...@@ -15,6 +15,9 @@ libavutil: 2017-10-21 ...@@ -15,6 +15,9 @@ libavutil: 2017-10-21
API changes, most recent first: API changes, most recent first:
2020-02-21 - xxxxxxxxxx - lavc 58.73.100 - avcodec.h
Add AVCodecContext.export_side_data and AV_CODEC_EXPORT_DATA_MVS.
2020-02-13 - xxxxxxxxxx - lavu 56.41.100 - tx.h 2020-02-13 - xxxxxxxxxx - lavu 56.41.100 - tx.h
Add AV_TX_INT32_FFT and AV_TX_INT32_MDCT Add AV_TX_INT32_FFT and AV_TX_INT32_MDCT
......
...@@ -788,6 +788,15 @@ Do not skip samples and export skip information as frame side data. ...@@ -788,6 +788,15 @@ Do not skip samples and export skip information as frame side data.
Do not reset ASS ReadOrder field on flush. Do not reset ASS ReadOrder field on flush.
@end table @end table
@item export_side_data @var{flags} (@emph{decoding/encoding,audio,video,subtitles})
Possible values:
@table @samp
@item mvs
Export motion vectors into frame side-data (see @code{AV_FRAME_DATA_MOTION_VECTORS})
for codecs that support it. See also @file{doc/examples/export_mvs.c}.
@end table
@item error @var{integer} (@emph{encoding,video}) @item error @var{integer} (@emph{encoding,video})
@item qns @var{integer} (@emph{encoding,video}) @item qns @var{integer} (@emph{encoding,video})
......
...@@ -1103,6 +1103,14 @@ typedef struct RcOverride{ ...@@ -1103,6 +1103,14 @@ typedef struct RcOverride{
*/ */
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE (1 << 20) #define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE (1 << 20)
/* Exported side data.
These flags can be passed in AVCodecContext.export_side_data before initialization.
*/
/**
* Export motion vectors through frame side data
*/
#define AV_CODEC_EXPORT_DATA_MVS (1 << 0)
/** /**
* Pan Scan area. * Pan Scan area.
* This specifies the area which should be displayed. * This specifies the area which should be displayed.
...@@ -3400,6 +3408,16 @@ typedef struct AVCodecContext { ...@@ -3400,6 +3408,16 @@ typedef struct AVCodecContext {
* - encoding: set by user * - encoding: set by user
*/ */
int64_t max_samples; int64_t max_samples;
/**
* Bit set of AV_CODEC_EXPORT_DATA_* flags, which affects the kind of
* metadata exported in frame, packet, or coded stream side data by
* decoders and encoders.
*
* - decoding: set by user
* - encoding: set by user
*/
int export_side_data;
} AVCodecContext; } AVCodecContext;
#if FF_API_CODEC_GET_SET #if FF_API_CODEC_GET_SET
......
...@@ -211,7 +211,7 @@ static int alloc_picture_tables(AVCodecContext *avctx, Picture *pic, int encodin ...@@ -211,7 +211,7 @@ static int alloc_picture_tables(AVCodecContext *avctx, Picture *pic, int encodin
#if FF_API_DEBUG_MV #if FF_API_DEBUG_MV
avctx->debug_mv || avctx->debug_mv ||
#endif #endif
(avctx->flags2 & AV_CODEC_FLAG2_EXPORT_MVS)) { (avctx->export_side_data & AV_CODEC_EXPORT_DATA_MVS)) {
int mv_size = 2 * (b8_array_size + 4) * sizeof(int16_t); int mv_size = 2 * (b8_array_size + 4) * sizeof(int16_t);
int ref_index_size = 4 * mb_array_size; int ref_index_size = 4 * mb_array_size;
......
...@@ -105,7 +105,7 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t *mbskip_ ...@@ -105,7 +105,7 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t *mbskip_
int *low_delay, int *low_delay,
int mb_width, int mb_height, int mb_stride, int quarter_sample) int mb_width, int mb_height, int mb_stride, int quarter_sample)
{ {
if ((avctx->flags2 & AV_CODEC_FLAG2_EXPORT_MVS) && mbtype_table && motion_val[0]) { if ((avctx->export_side_data & AV_CODEC_EXPORT_DATA_MVS) && mbtype_table && motion_val[0]) {
const int shift = 1 + quarter_sample; const int shift = 1 + quarter_sample;
const int scale = 1 << shift; const int scale = 1 << shift;
const int mv_sample_log2 = avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_SVQ3 ? 2 : 1; const int mv_sample_log2 = avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_SVQ3 ? 2 : 1;
......
...@@ -78,6 +78,8 @@ static const AVOption avcodec_options[] = { ...@@ -78,6 +78,8 @@ static const AVOption avcodec_options[] = {
{"export_mvs", "export motion vectors through frame side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_EXPORT_MVS}, INT_MIN, INT_MAX, V|D, "flags2"}, {"export_mvs", "export motion vectors through frame side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_EXPORT_MVS}, INT_MIN, INT_MAX, V|D, "flags2"},
{"skip_manual", "do not skip samples and export skip information as frame side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_SKIP_MANUAL}, INT_MIN, INT_MAX, A|D, "flags2"}, {"skip_manual", "do not skip samples and export skip information as frame side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_SKIP_MANUAL}, INT_MIN, INT_MAX, A|D, "flags2"},
{"ass_ro_flush_noop", "do not reset ASS ReadOrder field on flush", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_RO_FLUSH_NOOP}, INT_MIN, INT_MAX, S|D, "flags2"}, {"ass_ro_flush_noop", "do not reset ASS ReadOrder field on flush", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_RO_FLUSH_NOOP}, INT_MIN, INT_MAX, S|D, "flags2"},
{"export_side_data", "Export metadata as side data", OFFSET(export_side_data), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT}, 0, UINT_MAX, A|V|S|D|E, "export_side_data"},
{"mvs", "export motion vectors through frame side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_MVS}, INT_MIN, INT_MAX, V|D, "export_side_data"},
{"time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, INT_MAX}, {"time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, INT_MAX},
{"g", "set the group of picture (GOP) size", OFFSET(gop_size), AV_OPT_TYPE_INT, {.i64 = 12 }, INT_MIN, INT_MAX, V|E}, {"g", "set the group of picture (GOP) size", OFFSET(gop_size), AV_OPT_TYPE_INT, {.i64 = 12 }, INT_MIN, INT_MAX, V|E},
{"ar", "set audio sampling rate (in Hz)", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, A|D|E}, {"ar", "set audio sampling rate (in Hz)", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, A|D|E},
......
...@@ -334,6 +334,7 @@ static int update_context_from_user(AVCodecContext *dst, AVCodecContext *src) ...@@ -334,6 +334,7 @@ static int update_context_from_user(AVCodecContext *dst, AVCodecContext *src)
dst->slice_flags = src->slice_flags; dst->slice_flags = src->slice_flags;
dst->flags2 = src->flags2; dst->flags2 = src->flags2;
dst->export_side_data = src->export_side_data;
copy_fields(skip_loop_filter, subtitle_header); copy_fields(skip_loop_filter, subtitle_header);
......
...@@ -502,7 +502,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, ...@@ -502,7 +502,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
); );
av_assert0(!s->avmv); av_assert0(!s->avmv);
if (s->avctx->flags2 & AV_CODEC_FLAG2_EXPORT_MVS) { if (s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_MVS) {
s->avmv = av_malloc_array(s->b_width * s->b_height, sizeof(AVMotionVector) << (s->block_max_depth*2)); s->avmv = av_malloc_array(s->b_width * s->b_height, sizeof(AVMotionVector) << (s->block_max_depth*2));
} }
s->avmv_index = 0; s->avmv_index = 0;
......
...@@ -947,6 +947,9 @@ FF_ENABLE_DEPRECATION_WARNINGS ...@@ -947,6 +947,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
&& avctx->codec_descriptor->type == AVMEDIA_TYPE_VIDEO) && avctx->codec_descriptor->type == AVMEDIA_TYPE_VIDEO)
av_log(avctx, AV_LOG_WARNING, av_log(avctx, AV_LOG_WARNING,
"gray decoding requested but not enabled at configuration time\n"); "gray decoding requested but not enabled at configuration time\n");
if (avctx->flags2 & AV_CODEC_FLAG2_EXPORT_MVS) {
avctx->export_side_data |= AV_CODEC_EXPORT_DATA_MVS;
}
if ( avctx->codec->init && (!(avctx->active_thread_type&FF_THREAD_FRAME) if ( avctx->codec->init && (!(avctx->active_thread_type&FF_THREAD_FRAME)
|| avci->frame_thread_encoder)) { || avci->frame_thread_encoder)) {
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "libavutil/version.h" #include "libavutil/version.h"
#define LIBAVCODEC_VERSION_MAJOR 58 #define LIBAVCODEC_VERSION_MAJOR 58
#define LIBAVCODEC_VERSION_MINOR 72 #define LIBAVCODEC_VERSION_MINOR 73
#define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
......
...@@ -4,6 +4,7 @@ stream=0, decode=0 ...@@ -4,6 +4,7 @@ stream=0, decode=0
bt=4000000 bt=4000000
flags=0x00000000 flags=0x00000000
flags2=0x00000000 flags2=0x00000000
export_side_data=0x00000000
time_base=0/1 time_base=0/1
g=12 g=12
ar=0 ar=0
...@@ -146,6 +147,7 @@ stream=0, decode=1 ...@@ -146,6 +147,7 @@ stream=0, decode=1
bt=4000000 bt=4000000
flags=0x00000000 flags=0x00000000
flags2=0x00000000 flags2=0x00000000
export_side_data=0x00000000
time_base=0/1 time_base=0/1
g=12 g=12
ar=0 ar=0
......
...@@ -4,6 +4,7 @@ stream=0, decode=0 ...@@ -4,6 +4,7 @@ stream=0, decode=0
bt=4000000 bt=4000000
flags=0x00000000 flags=0x00000000
flags2=0x00000000 flags2=0x00000000
export_side_data=0x00000000
time_base=0/1 time_base=0/1
g=12 g=12
ar=0 ar=0
...@@ -146,6 +147,7 @@ stream=0, decode=1 ...@@ -146,6 +147,7 @@ stream=0, decode=1
bt=4000000 bt=4000000
flags=0x00000000 flags=0x00000000
flags2=0x00000000 flags2=0x00000000
export_side_data=0x00000000
time_base=0/1 time_base=0/1
g=12 g=12
ar=0 ar=0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment