demux: heif: send extradata with avif
[vlc.git] / modules / stream_out / transcode / transcode.h
blobfae4f8137d45ffa9847efee2c6405b420d4202e1
1 #include <vlc_picture_fifo.h>
2 #include <vlc_filter.h>
3 #include <vlc_codec.h>
4 #include "encoder/encoder.h"
6 /*100ms is around the limit where people are noticing lipsync issues*/
7 #define MASTER_SYNC_MAX_DRIFT VLC_TICK_FROM_MS(100)
9 typedef struct
11 char *psz_filters;
12 union
14 struct
16 char *psz_deinterlace;
17 config_chain_t *p_deinterlace_cfg;
18 char *psz_spu_sources;
19 } video;
21 } sout_filters_config_t;
23 static inline
24 void sout_filters_config_init( sout_filters_config_t *p_cfg )
26 memset( p_cfg, 0, sizeof(*p_cfg) );
29 static inline
30 void sout_filters_config_clean( sout_filters_config_t *p_cfg )
32 free( p_cfg->psz_filters );
33 if( p_cfg->video.psz_deinterlace )
35 free( p_cfg->video.psz_deinterlace );
36 config_ChainDestroy( p_cfg->video.p_deinterlace_cfg );
38 free( p_cfg->video.psz_spu_sources );
41 typedef struct sout_stream_id_sys_t sout_stream_id_sys_t;
43 typedef struct
45 sout_stream_id_sys_t *id_video;
47 bool b_soverlay;
49 /* Audio */
50 transcode_encoder_config_t aenc_cfg;
51 sout_filters_config_t afilters_cfg;
53 /* Video */
54 transcode_encoder_config_t venc_cfg;
55 sout_filters_config_t vfilters_cfg;
57 /* SPU */
58 transcode_encoder_config_t senc_cfg;
60 /* Sync */
61 bool b_master_sync;
62 sout_stream_id_sys_t *id_master_sync;
64 } sout_stream_sys_t;
66 struct aout_filters;
68 struct sout_stream_id_sys_t
70 bool b_transcode;
71 bool b_error;
73 /* id of the out stream */
74 void *downstream_id;
75 void *(*pf_transcode_downstream_add)( sout_stream_t *,
76 const es_format_t *orig,
77 const es_format_t *current );
79 /* Decoder */
80 decoder_t *p_decoder;
82 struct
84 vlc_mutex_t lock;
85 union
87 struct {
88 picture_t *first;
89 picture_t **last;
90 } pic;
91 struct {
92 subpicture_t *first;
93 subpicture_t **last;
94 } spu;
95 struct {
96 block_t *first;
97 block_t **last;
98 } audio;
100 } fifo;
102 union
104 struct
106 int (*pf_drift_validate)(void *cbdata, vlc_tick_t);
108 struct
110 void (*pf_send_subpicture)(void *cbdata, subpicture_t *);
111 int (*pf_get_output_dimensions)(void *cbdata, unsigned *, unsigned *);
112 vlc_tick_t (*pf_get_master_drift)(void *cbdata);
115 void *callback_data;
117 union
119 struct
121 filter_chain_t *p_f_chain; /**< Video filters */
122 filter_chain_t *p_uf_chain; /**< User-specified video filters */
123 filter_t *p_spu_blender;
124 spu_t *p_spu;
125 video_format_t fmt_input_video;
127 struct
129 struct aout_filters *p_af_chain; /**< Audio filters */
130 audio_format_t fmt_input_audio;
133 es_format_t decoder_out; /* only rw from pf_*_format_update() */
134 const sout_filters_config_t *p_filterscfg;
136 /* Encoder */
137 const transcode_encoder_config_t *p_enccfg;
138 transcode_encoder_t *encoder;
140 /* Sync */
141 date_t next_input_pts; /**< Incoming calculated PTS */
142 vlc_tick_t i_drift; /** how much buffer is ahead of calculated PTS */
145 struct decoder_owner
147 decoder_t dec;
148 vlc_object_t *p_obj;
149 sout_stream_id_sys_t *id;
152 static inline struct decoder_owner *dec_get_owner( decoder_t *p_dec )
154 return container_of( p_dec, struct decoder_owner, dec );
157 static inline void es_format_SetMeta( es_format_t *p_dst, const es_format_t *p_src )
159 p_dst->i_group = p_src->i_group;
160 p_dst->i_id = p_src->i_id;
161 if( p_src->psz_language )
163 free( p_dst->psz_language );
164 p_dst->psz_language = strdup( p_src->psz_language );
166 if( p_src->psz_description )
168 free( p_dst->psz_description );
169 p_dst->psz_description = strdup( p_src->psz_description );
173 /* SPU */
175 void transcode_spu_clean ( sout_stream_t *, sout_stream_id_sys_t * );
176 int transcode_spu_process( sout_stream_t *, sout_stream_id_sys_t *,
177 block_t *, block_t ** );
178 int transcode_spu_init ( sout_stream_t *, const es_format_t *, sout_stream_id_sys_t *);
180 /* AUDIO */
182 void transcode_audio_clean ( sout_stream_id_sys_t * );
183 int transcode_audio_process( sout_stream_t *, sout_stream_id_sys_t *,
184 block_t *, block_t ** );
185 int transcode_audio_init ( sout_stream_t *, const es_format_t *,
186 sout_stream_id_sys_t *);
188 /* VIDEO */
190 void transcode_video_clean ( sout_stream_t *, sout_stream_id_sys_t * );
191 int transcode_video_process( sout_stream_t *, sout_stream_id_sys_t *,
192 block_t *, block_t ** );
193 int transcode_video_get_output_dimensions( sout_stream_t *, sout_stream_id_sys_t *,
194 unsigned *w, unsigned *h );
195 void transcode_video_push_spu( sout_stream_t *, sout_stream_id_sys_t *, subpicture_t * );
196 int transcode_video_init ( sout_stream_t *, const es_format_t *,
197 sout_stream_id_sys_t *);