summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xold-configure12
-rw-r--r--video/filter/vf.h1
-rw-r--r--video/filter/vf_lavfi.c20
-rw-r--r--wscript6
4 files changed, 39 insertions, 0 deletions
diff --git a/old-configure b/old-configure
index cf267f2e05..98ffaf8c00 100755
--- a/old-configure
+++ b/old-configure
@@ -2744,6 +2744,17 @@ fi
echores "$_avcodec_has_replaygain_side_data"
+echocheck "libavutil AVFrame metadata"
+_avutil_has_avframe_metadata=no
+statement_check libavutil/frame.h 'av_frame_get_metadata(NULL)' && _avutil_has_avframe_metadata=yes
+if test "$_avutil_has_avframe_metadata" = yes ; then
+ def_avutil_has_avframe_metadata='#define HAVE_AVFRAME_METADATA 1'
+else
+ def_avutil_has_avframe_metadata='#define HAVE_AVFRAME_METADATA 0'
+fi
+echores "$_avutil_has_avframe_metadata"
+
+
echocheck "libavutil QP API"
_avutil_has_qp_api=no
statement_check libavutil/frame.h 'av_frame_get_qp_table(NULL, NULL, NULL)' && _avutil_has_qp_api=yes
@@ -3373,6 +3384,7 @@ $def_avutil_has_qp_api
$def_avcodec_has_chroma_pos_api
$def_avcodec_has_metadata_update_side_data
$def_avcodec_has_replaygain_side_data
+$def_avutil_has_avframe_metadata
$def_libpostproc
$def_libavdevice
$def_libavfilter
diff --git a/video/filter/vf.h b/video/filter/vf.h
index 6bc887bbb2..968e6da225 100644
--- a/video/filter/vf.h
+++ b/video/filter/vf.h
@@ -120,6 +120,7 @@ enum vf_ctrl {
VFCTRL_INIT_OSD, // Filter OSD renderer present?
VFCTRL_SET_DEINTERLACE, // Set deinterlacing status
VFCTRL_GET_DEINTERLACE, // Get deinterlacing status
+ VFCTRL_GET_METADATA, // Get frame metadata from lavfi filters (e.g., cropdetect)
/* Hack to make the OSD state object available to vf_sub which
* access OSD/subtitle state outside of normal OSD draw time. */
VFCTRL_SET_OSD_OBJ,
diff --git a/video/filter/vf_lavfi.c b/video/filter/vf_lavfi.c
index dde1547abf..abcaa79c2c 100644
--- a/video/filter/vf_lavfi.c
+++ b/video/filter/vf_lavfi.c
@@ -39,6 +39,7 @@
#include "common/msg.h"
#include "options/m_option.h"
#include "common/av_opts.h"
+#include "common/tags.h"
#include "video/img_format.h"
#include "video/mp_image.h"
@@ -66,6 +67,8 @@ struct vf_priv_s {
AVRational timebase_out;
AVRational par_in;
+ struct mp_tags* metadata;
+
// for the lw wrapper
void *old_priv;
void (*lw_recreate_cb)(struct vf_instance *vf);
@@ -266,6 +269,17 @@ static struct mp_image *av_to_mp(struct vf_instance *vf, AVFrame *av_frame)
return img;
}
+static void get_metadata_from_av_frame(struct vf_instance *vf, AVFrame *frame)
+{
+#if HAVE_AVFRAME_METADATA
+ struct vf_priv_s *p = vf->priv;
+ if (!p->metadata)
+ p->metadata = talloc_zero(p, struct mp_tags);
+
+ mp_tags_copy_from_av_dictionary(p->metadata, av_frame_get_metadata(frame));
+#endif
+}
+
static int filter_ext(struct vf_instance *vf, struct mp_image *mpi)
{
struct vf_priv_s *p = vf->priv;
@@ -287,6 +301,8 @@ static int filter_ext(struct vf_instance *vf, struct mp_image *mpi)
av_frame_free(&frame);
break;
}
+ get_metadata_from_av_frame(vf,frame);
+
vf_add_output_frame(vf, av_to_mp(vf, frame));
}
@@ -307,6 +323,10 @@ static int control(vf_instance_t *vf, int request, void *data)
case VFCTRL_SEEK_RESET:
reset(vf);
return CONTROL_OK;
+ case VFCTRL_GET_METADATA:{
+ *(struct mp_tags*) data = *vf->priv->metadata;
+ return CONTROL_OK;
+ }
}
return CONTROL_UNKNOWN;
}
diff --git a/wscript b/wscript
index 4be9a321ad..07a2b65b4c 100644
--- a/wscript
+++ b/wscript
@@ -396,6 +396,12 @@ Libav libraries ({0}). Aborting.".format(" ".join(libav_pkg_config_checks))
'func': check_statement('libavcodec/avcodec.h',
'enum AVPacketSideDataType type = AV_PKT_DATA_REPLAYGAIN',
use='libav')
+ },{
+ 'name': 'avframe-metadata',
+ 'desc': 'libavutil AVFrame metadata',
+ 'func': check_statement('libavutil/frame.h',
+ 'av_frame_get_metadata(NULL)',
+ use='libav')
}
]