| 73 | | picture_t *p_pic = (picture_t *)p_filter->p_owner; |
|---|
| 74 | | p_filter->p_owner = NULL; |
|---|
| 75 | | return p_pic; |
|---|
| | 70 | filter_t *p_filter1; |
|---|
| | 71 | if( !( p_filter1 = |
|---|
| | 72 | filter_chain_AppendFilter( p_chain, NULL, NULL, NULL, p_fmt_mid )) ) |
|---|
| | 73 | return VLC_EGENERIC; |
|---|
| | 74 | if( !filter_chain_AppendFilter( p_chain, NULL, NULL, p_fmt_mid, NULL ) ) |
|---|
| | 75 | { |
|---|
| | 76 | filter_chain_DeleteFilter( p_chain, p_filter1 ); |
|---|
| | 77 | return VLC_EGENERIC; |
|---|
| | 78 | } |
|---|
| | 79 | return VLC_SUCCESS; |
|---|
| 81 | | vlc_object_detach( p_filter ); |
|---|
| 82 | | if( p_filter->p_module ) module_Unneed( p_filter, p_filter->p_module ); |
|---|
| 83 | | vlc_object_release( p_filter ); |
|---|
| 84 | | } |
|---|
| 85 | | |
|---|
| 86 | | /* FIXME: this is almost like CreateFilter in src/misc/image.c */ |
|---|
| 87 | | static filter_t *CreateFilter( vlc_object_t *p_this, video_format_t *fmt_in, |
|---|
| 88 | | video_format_t *fmt_out ) |
|---|
| 89 | | { |
|---|
| 90 | | filter_t *p_filter = vlc_object_create( p_this, sizeof(filter_t) ); |
|---|
| 91 | | vlc_object_attach( p_filter, p_this ); |
|---|
| 92 | | |
|---|
| 93 | | p_filter->pf_vout_buffer_new = get_pic; |
|---|
| 94 | | |
|---|
| 95 | | p_filter->fmt_in = *fmt_in; |
|---|
| 96 | | p_filter->fmt_out = *fmt_out; |
|---|
| 97 | | |
|---|
| 98 | | p_filter->p_module = module_Need( p_filter, "video filter2", NULL, 0 ); |
|---|
| 99 | | |
|---|
| 100 | | if( !p_filter->p_module ) |
|---|
| 101 | | { |
|---|
| 102 | | DeleteFilter( p_filter ); |
|---|
| 103 | | return NULL; |
|---|
| 104 | | } |
|---|
| 105 | | |
|---|
| 106 | | return p_filter; |
|---|
| 107 | | } |
|---|
| 108 | | |
|---|
| 109 | | static int CreateChain( vlc_object_t *p_this, filter_sys_t *p_sys ) |
|---|
| 110 | | { |
|---|
| 111 | | p_sys->p_filter1 = CreateFilter( p_this, &p_filter->fmt_in.video, |
|---|
| 112 | | &p_sys->fmt_mid ); |
|---|
| 113 | | if( p_sys->p_filter1 ) |
|---|
| 114 | | { |
|---|
| 115 | | p_sys->p_filter2 = CreateFilter( p_this, &p_sys->fmt_mid, |
|---|
| 116 | | &p_filter->fmt_out.video ); |
|---|
| 117 | | if( p_sys->p_filter2 ) |
|---|
| 118 | | return VLC_SUCCESS; |
|---|
| 119 | | DeleteFilter( p_sys->p_filter1 ); |
|---|
| 120 | | } |
|---|
| 121 | | return VLC_EGENERIC; |
|---|
| | 84 | /* Not sure about all of this ... it should work */ |
|---|
| | 85 | p_filter->pf_vout_buffer_new = ((filter_t*)p_data)->pf_vout_buffer_new; |
|---|
| | 86 | p_filter->pf_vout_buffer_del = ((filter_t*)p_data)->pf_vout_buffer_del; |
|---|
| | 87 | p_filter->p_owner = ((filter_t*)p_data)->p_owner; |
|---|
| | 88 | return VLC_SUCCESS; |
|---|
| 154 | | if( p_filter->fmt_in.i_width != p_filter->fmt_out.i_width || |
|---|
| 155 | | p_filter->fmt_in.i_height != p_filter->fmt_out.i_height || |
|---|
| 156 | | p_filter->fmt_in.i_visible_width != p_filter->fmt_out.i_visible_width || |
|---|
| 157 | | p_filter->fmt_in.i_visible_height != p_filter->fmt_out.i_visible_height ) |
|---|
| | 122 | p_sys->p_chain = filter_chain_New( p_filter, "video filter2", false, AllocInit, NULL, p_filter ); |
|---|
| | 123 | if( !p_sys->p_chain ) |
|---|
| | 124 | { |
|---|
| | 125 | free( p_sys ); |
|---|
| | 126 | return VLC_EGENERIC; |
|---|
| | 127 | } |
|---|
| | 128 | filter_chain_Reset( p_sys->p_chain, &p_filter->fmt_in, &p_filter->fmt_out ); |
|---|
| | 129 | |
|---|
| | 130 | if( p_filter->fmt_in.video.i_width != p_filter->fmt_out.video.i_width || |
|---|
| | 131 | p_filter->fmt_in.video.i_height != p_filter->fmt_out.video.i_height || |
|---|
| | 132 | p_filter->fmt_in.video.i_visible_width != p_filter->fmt_out.video.i_visible_width || |
|---|
| | 133 | p_filter->fmt_in.video.i_visible_height != p_filter->fmt_out.video.i_visible_height ) |
|---|
| 160 | | p_sys->fmt_mid = p_filter->fmt_out.video; |
|---|
| 161 | | p_sys->fmt_mid.i_chroma = p_filter->fmt_in.video.i_chroma; |
|---|
| 162 | | if( CreateChain( p_this, p_sys ) == VLC_SUCCESS ) |
|---|
| | 136 | es_format_Copy( &fmt_mid, &p_filter->fmt_out ); |
|---|
| | 137 | fmt_mid.video.i_chroma = p_filter->fmt_out.video.i_chroma; |
|---|
| | 138 | if( CreateChain( p_sys->p_chain, &fmt_mid ) == VLC_SUCCESS ) |
|---|
| | 139 | { |
|---|
| | 140 | es_format_Clean( &fmt_mid ); |
|---|
| | 141 | p_filter->pf_video_filter = Chain; |
|---|
| 166 | | p_sys->fmt_mid = p_filter->fmt_in.video; |
|---|
| 167 | | p_sys->fmt_mid.i_chroma = p_filter->fmt_out.video.i_chroma; |
|---|
| 168 | | if( CreateChain( p_this, p_sys ) == VLC_SUCCESS ) |
|---|
| | 146 | es_format_Clean( &fmt_mid ); |
|---|
| | 147 | es_format_Copy( &fmt_mid, &p_filter->fmt_in ); |
|---|
| | 148 | fmt_mid.video.i_chroma = p_filter->fmt_out.video.i_chroma; |
|---|
| | 149 | if( CreateChain( p_sys->p_chain, &fmt_mid ) == VLC_SUCCESS ) |
|---|
| | 150 | { |
|---|
| | 151 | es_format_Clean( &fmt_mid ); |
|---|
| | 152 | p_filter->pf_video_filter = Chain; |
|---|
| 211 | | picture_t *p_outpic = p_filter->pf_vout_buffer_new( p_filter ); |
|---|
| 212 | | if( !p_outpic ) |
|---|
| 213 | | { |
|---|
| 214 | | msg_Warn( p_filter, "can't get output picture" ); |
|---|
| 215 | | if( p_pic->pf_release ) |
|---|
| 216 | | p_pic->pf_release( p_pic ); |
|---|
| 217 | | return NULL; |
|---|
| 218 | | } |
|---|
| 219 | | |
|---|
| 220 | | |
|---|
| 221 | | if( !p_sys->p_tmp ) |
|---|
| 222 | | { |
|---|
| 223 | | picture_t *p_tmp = malloc( sizeof( picture_t ) ); |
|---|
| 224 | | if( !p_tmp ) |
|---|
| 225 | | return NULL; |
|---|
| 226 | | vout_AllocatePicture( VLC_OBJECT( p_vout ), p_tmp, |
|---|
| 227 | | p_sys->fmt_mid.i_chroma, |
|---|
| 228 | | p_sys->fmt_mid.i_width, |
|---|
| 229 | | p_sys->fmt_mid.i_height, |
|---|
| 230 | | p_sys->fmt_mid.i_aspect ); |
|---|
| 231 | | p_sys->p_tmp = p_tmp; |
|---|
| 232 | | p_tmp->pf_release = NULL; |
|---|
| 233 | | p_tmp->i_status = RESERVED_PICTURE; |
|---|
| 234 | | p_tmp->p_sys = NULL; |
|---|
| 235 | | } |
|---|
| 236 | | |
|---|
| 237 | | p_sys->p_filter1->p_owner = (filter_owner_sys_t*)p_sys->p_tmp; |
|---|
| 238 | | if( !p_sys->p_filter1->pf_video_filter( p_sys->p_filter1, p_pic ) ) |
|---|
| 239 | | { |
|---|
| 240 | | if( p_pic->pf_release ) |
|---|
| 241 | | p_pic->pf_release( p_pic ); |
|---|
| 242 | | return NULL; |
|---|
| 243 | | } |
|---|
| 244 | | if( p_pic->pf_release ) |
|---|
| 245 | | p_pic->pf_release( p_pic ); |
|---|
| 246 | | p_sys->p_filter2->p_owner = (filter_owner_sys_t*)p_outpic; |
|---|
| 247 | | return p_sys->p_filter2->pf_video_filter( p_sys->p_filter2, p_sys->p_tmp ); |
|---|
| | 193 | return filter_chain_VideoFilter( p_filter->p_sys->p_chain, p_pic ); |
|---|