filter_chain: introduce dedicated filter_chain_NewVideo() for video filters
[vlc.git] / modules / stream_out / transcode / transcode.h
1 #ifdef HAVE_CONFIG_H
2 #include "config.h"
3 #endif
4
5 #include <vlc_common.h>
6
7 #include <vlc_sout.h>
8 #include <vlc_filter.h>
9 #include <vlc_es.h>
10 #include <vlc_codec.h>
11
12 #include <vlc_picture_fifo.h>
13
14 /*100ms is around the limit where people are noticing lipsync issues*/
15 #define MASTER_SYNC_MAX_DRIFT 100000
16
17 struct sout_stream_sys_t
18 {
19     sout_stream_id_sys_t *id_video;
20     block_t         *p_buffers;
21     vlc_mutex_t     lock_out;
22     vlc_cond_t      cond;
23     bool            b_abort;
24     picture_fifo_t *pp_pics;
25     vlc_thread_t    thread;
26
27     /* Audio */
28     vlc_fourcc_t    i_acodec;   /* codec audio (0 if not transcode) */
29     char            *psz_aenc;
30     char            *psz_alang;
31     config_chain_t  *p_audio_cfg;
32     uint32_t        i_sample_rate;
33     uint32_t        i_channels;
34     int             i_abitrate;
35
36     char            *psz_af;
37
38     /* Video */
39     vlc_fourcc_t    i_vcodec;   /* codec video (0 if not transcode) */
40     char            *psz_venc;
41     config_chain_t  *p_video_cfg;
42     int             i_vbitrate;
43     double          f_scale;
44     unsigned int    i_width, i_maxwidth;
45     unsigned int    i_height, i_maxheight;
46     bool            b_deinterlace;
47     char            *psz_deinterlace;
48     config_chain_t  *p_deinterlace_cfg;
49     int             i_threads;
50     bool            b_high_priority;
51     bool            b_hurry_up;
52     unsigned int    fps_num,fps_den;
53
54     char            *psz_vf2;
55
56     /* SPU */
57     vlc_fourcc_t    i_scodec;   /* codec spu (0 if not transcode) */
58     char            *psz_senc;
59     bool            b_soverlay;
60     config_chain_t  *p_spu_cfg;
61     spu_t           *p_spu;
62     filter_t        *p_spu_blend;
63
64     /* OSD Menu */
65     vlc_fourcc_t    i_osdcodec; /* codec osd menu (0 if not transcode) */
66     char            *psz_osdenc;
67     config_chain_t  *p_osd_cfg;
68     bool            b_osd;   /* true when osd es is registered */
69
70     /* Sync */
71     bool            b_master_sync;
72     /* i_master drift is how much audio buffer is ahead of calculated pts */
73     mtime_t         i_master_drift;
74 };
75
76 struct aout_filters;
77
78 struct sout_stream_id_sys_t
79 {
80     bool            b_transcode;
81
82     /* id of the out stream */
83     void *id;
84
85     /* Decoder */
86     decoder_t       *p_decoder;
87
88     union
89     {
90          struct
91          {
92              filter_chain_t  *p_f_chain; /**< Video filters */
93              filter_chain_t  *p_uf_chain; /**< User-specified video filters */
94              video_format_t  fmt_input_video;
95          };
96          struct
97          {
98              struct aout_filters    *p_af_chain; /**< Audio filters */
99              audio_format_t  fmt_audio;
100          };
101
102     };
103
104     /* Encoder */
105     encoder_t       *p_encoder;
106
107     /* Sync */
108     date_t          next_input_pts; /**< Incoming calculated PTS */
109     date_t          next_output_pts; /**< output calculated PTS */
110     int             i_input_frame_interval;
111     int             i_output_frame_interval;
112 };
113
114 /* OSD */
115
116 int transcode_osd_new( sout_stream_t *p_stream, sout_stream_id_sys_t *id );
117 void transcode_osd_close( sout_stream_t *p_stream, sout_stream_id_sys_t *id);
118 int transcode_osd_process( sout_stream_t *p_stream, sout_stream_id_sys_t *id,
119                                   block_t *in, block_t **out );
120 bool transcode_osd_add    ( sout_stream_t *, es_format_t *, sout_stream_id_sys_t *);
121
122 /* SPU */
123
124 int  transcode_spu_new    ( sout_stream_t *, sout_stream_id_sys_t * );
125 void transcode_spu_close  ( sout_stream_t *, sout_stream_id_sys_t * );
126 int  transcode_spu_process( sout_stream_t *, sout_stream_id_sys_t *,
127                                    block_t *, block_t ** );
128 bool transcode_spu_add    ( sout_stream_t *, es_format_t *, sout_stream_id_sys_t *);
129
130 /* AUDIO */
131
132 int  transcode_audio_new    ( sout_stream_t *, sout_stream_id_sys_t * );
133 void transcode_audio_close  ( sout_stream_id_sys_t * );
134 int  transcode_audio_process( sout_stream_t *, sout_stream_id_sys_t *,
135                                      block_t *, block_t ** );
136 bool transcode_audio_add    ( sout_stream_t *, es_format_t *,
137                                 sout_stream_id_sys_t *);
138
139 /* VIDEO */
140
141 int  transcode_video_new    ( sout_stream_t *, sout_stream_id_sys_t * );
142 void transcode_video_close  ( sout_stream_t *, sout_stream_id_sys_t * );
143 int  transcode_video_process( sout_stream_t *, sout_stream_id_sys_t *,
144                                      block_t *, block_t ** );
145 bool transcode_video_add    ( sout_stream_t *, es_format_t *,
146                                 sout_stream_id_sys_t *);