mirror of
https://github.com/mpv-player/mpv
synced 2025-03-24 04:08:19 +00:00
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:
parent
0a278f92e6
commit
f09134b76d
@ -2744,6 +2744,17 @@ fi
|
|||||||
echores "$_avcodec_has_replaygain_side_data"
|
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"
|
echocheck "libavutil QP API"
|
||||||
_avutil_has_qp_api=no
|
_avutil_has_qp_api=no
|
||||||
statement_check libavutil/frame.h 'av_frame_get_qp_table(NULL, NULL, NULL)' && _avutil_has_qp_api=yes
|
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_chroma_pos_api
|
||||||
$def_avcodec_has_metadata_update_side_data
|
$def_avcodec_has_metadata_update_side_data
|
||||||
$def_avcodec_has_replaygain_side_data
|
$def_avcodec_has_replaygain_side_data
|
||||||
|
$def_avutil_has_avframe_metadata
|
||||||
$def_libpostproc
|
$def_libpostproc
|
||||||
$def_libavdevice
|
$def_libavdevice
|
||||||
$def_libavfilter
|
$def_libavfilter
|
||||||
|
@ -120,6 +120,7 @@ enum vf_ctrl {
|
|||||||
VFCTRL_INIT_OSD, // Filter OSD renderer present?
|
VFCTRL_INIT_OSD, // Filter OSD renderer present?
|
||||||
VFCTRL_SET_DEINTERLACE, // Set deinterlacing status
|
VFCTRL_SET_DEINTERLACE, // Set deinterlacing status
|
||||||
VFCTRL_GET_DEINTERLACE, // Get 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
|
/* Hack to make the OSD state object available to vf_sub which
|
||||||
* access OSD/subtitle state outside of normal OSD draw time. */
|
* access OSD/subtitle state outside of normal OSD draw time. */
|
||||||
VFCTRL_SET_OSD_OBJ,
|
VFCTRL_SET_OSD_OBJ,
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "common/msg.h"
|
#include "common/msg.h"
|
||||||
#include "options/m_option.h"
|
#include "options/m_option.h"
|
||||||
#include "common/av_opts.h"
|
#include "common/av_opts.h"
|
||||||
|
#include "common/tags.h"
|
||||||
|
|
||||||
#include "video/img_format.h"
|
#include "video/img_format.h"
|
||||||
#include "video/mp_image.h"
|
#include "video/mp_image.h"
|
||||||
@ -66,6 +67,8 @@ struct vf_priv_s {
|
|||||||
AVRational timebase_out;
|
AVRational timebase_out;
|
||||||
AVRational par_in;
|
AVRational par_in;
|
||||||
|
|
||||||
|
struct mp_tags* metadata;
|
||||||
|
|
||||||
// for the lw wrapper
|
// for the lw wrapper
|
||||||
void *old_priv;
|
void *old_priv;
|
||||||
void (*lw_recreate_cb)(struct vf_instance *vf);
|
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;
|
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)
|
static int filter_ext(struct vf_instance *vf, struct mp_image *mpi)
|
||||||
{
|
{
|
||||||
struct vf_priv_s *p = vf->priv;
|
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);
|
av_frame_free(&frame);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
get_metadata_from_av_frame(vf,frame);
|
||||||
|
|
||||||
vf_add_output_frame(vf, av_to_mp(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:
|
case VFCTRL_SEEK_RESET:
|
||||||
reset(vf);
|
reset(vf);
|
||||||
return CONTROL_OK;
|
return CONTROL_OK;
|
||||||
|
case VFCTRL_GET_METADATA:{
|
||||||
|
*(struct mp_tags*) data = *vf->priv->metadata;
|
||||||
|
return CONTROL_OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return CONTROL_UNKNOWN;
|
return CONTROL_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
6
wscript
6
wscript
@ -396,6 +396,12 @@ Libav libraries ({0}). Aborting.".format(" ".join(libav_pkg_config_checks))
|
|||||||
'func': check_statement('libavcodec/avcodec.h',
|
'func': check_statement('libavcodec/avcodec.h',
|
||||||
'enum AVPacketSideDataType type = AV_PKT_DATA_REPLAYGAIN',
|
'enum AVPacketSideDataType type = AV_PKT_DATA_REPLAYGAIN',
|
||||||
use='libav')
|
use='libav')
|
||||||
|
},{
|
||||||
|
'name': 'avframe-metadata',
|
||||||
|
'desc': 'libavutil AVFrame metadata',
|
||||||
|
'func': check_statement('libavutil/frame.h',
|
||||||
|
'av_frame_get_metadata(NULL)',
|
||||||
|
use='libav')
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user