vf_lavfi: copy AVFrame metadata into vf_lavfi priv

store it as mp_tas and add VFCTRL_GET_METADATA to access it from elsewhere

Signed-off-by: wm4 <wm4@nowhere>

old-configure test by wm4.
This commit is contained in:
Kevin Mitchell 2014-04-13 07:04:23 -07:00 committed by wm4
parent 0a278f92e6
commit f09134b76d
4 changed files with 39 additions and 0 deletions

View File

@ -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

View File

@ -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,

View File

@ -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;
}

View File

@ -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')
}
]