1 /*****************************************************************************
2 * image.c : wrapper for image reading/writing facilities
3 *****************************************************************************
4 * Copyright (C) 2004 the VideoLAN team
7 * Author: Gildas Bazin <gbazin@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
26 * This file contains the functions to handle the image_handler_t type
29 /*****************************************************************************
31 *****************************************************************************/
34 #include <vlc/decoder.h>
35 #include <vlc_filter.h>
36 #include <vlc_image.h>
37 #include <vlc_stream.h>
40 static picture_t *ImageRead( image_handler_t *, block_t *,
41 video_format_t *, video_format_t * );
42 static picture_t *ImageReadUrl( image_handler_t *, const char *,
43 video_format_t *, video_format_t * );
44 static block_t *ImageWrite( image_handler_t *, picture_t *,
45 video_format_t *, video_format_t * );
46 static int ImageWriteUrl( image_handler_t *, picture_t *,
47 video_format_t *, video_format_t *, const char * );
49 static picture_t *ImageConvert( image_handler_t *, picture_t *,
50 video_format_t *, video_format_t * );
51 static picture_t *ImageFilter( image_handler_t *, picture_t *,
52 video_format_t *, const char *psz_module );
54 static decoder_t *CreateDecoder( vlc_object_t *, video_format_t * );
55 static void DeleteDecoder( decoder_t * );
56 static encoder_t *CreateEncoder( vlc_object_t *, video_format_t *,
58 static void DeleteEncoder( encoder_t * );
59 static filter_t *CreateFilter( vlc_object_t *, es_format_t *,
60 video_format_t *, const char * );
61 static void DeleteFilter( filter_t * );
63 static vlc_fourcc_t Ext2Fourcc( const char * );
64 /*static const char *Fourcc2Ext( vlc_fourcc_t );*/
67 * Create an image_handler_t instance
70 image_handler_t *__image_HandlerCreate( vlc_object_t *p_this )
72 image_handler_t *p_image = malloc( sizeof(image_handler_t) );
74 memset( p_image, 0, sizeof(image_handler_t) );
75 p_image->p_parent = p_this;
77 p_image->pf_read = ImageRead;
78 p_image->pf_read_url = ImageReadUrl;
79 p_image->pf_write = ImageWrite;
80 p_image->pf_write_url = ImageWriteUrl;
81 p_image->pf_convert = ImageConvert;
82 p_image->pf_filter = ImageFilter;
88 * Delete the image_handler_t instance
91 void image_HandlerDelete( image_handler_t *p_image )
93 if( !p_image ) return;
95 if( p_image->p_dec ) DeleteDecoder( p_image->p_dec );
96 if( p_image->p_enc ) DeleteEncoder( p_image->p_enc );
97 if( p_image->p_filter ) DeleteFilter( p_image->p_filter );
108 static picture_t *ImageRead( image_handler_t *p_image, block_t *p_block,
109 video_format_t *p_fmt_in,
110 video_format_t *p_fmt_out )
112 picture_t *p_pic = NULL, *p_tmp;
114 /* Check if we can reuse the current decoder */
115 if( p_image->p_dec &&
116 p_image->p_dec->fmt_in.i_codec != p_fmt_in->i_chroma )
118 DeleteDecoder( p_image->p_dec );
122 /* Start a decoder */
123 if( !p_image->p_dec )
125 p_image->p_dec = CreateDecoder( p_image->p_parent, p_fmt_in );
126 if( !p_image->p_dec ) return NULL;
129 p_block->i_pts = p_block->i_dts = mdate();
130 while( (p_tmp = p_image->p_dec->pf_decode_video( p_image->p_dec, &p_block ))
134 p_pic->pf_release( p_pic );
140 msg_Warn( p_image->p_parent, "no image decoded" );
144 if( !p_fmt_out->i_chroma )
145 p_fmt_out->i_chroma = p_image->p_dec->fmt_out.video.i_chroma;
146 if( !p_fmt_out->i_width && p_fmt_out->i_height )
147 p_fmt_out->i_width = p_fmt_out->i_height
148 * p_image->p_dec->fmt_out.video.i_aspect
149 / VOUT_ASPECT_FACTOR;
150 if( !p_fmt_out->i_height && p_fmt_out->i_width )
151 p_fmt_out->i_height = p_fmt_out->i_width * VOUT_ASPECT_FACTOR
152 / p_image->p_dec->fmt_out.video.i_aspect;
153 if( !p_fmt_out->i_width )
154 p_fmt_out->i_width = p_image->p_dec->fmt_out.video.i_width;
155 if( !p_fmt_out->i_height )
156 p_fmt_out->i_height = p_image->p_dec->fmt_out.video.i_height;
158 /* Check if we need chroma conversion or resizing */
159 if( p_image->p_dec->fmt_out.video.i_chroma != p_fmt_out->i_chroma ||
160 p_image->p_dec->fmt_out.video.i_width != p_fmt_out->i_width ||
161 p_image->p_dec->fmt_out.video.i_height != p_fmt_out->i_height )
163 if( p_image->p_filter )
164 if( p_image->p_filter->fmt_in.video.i_chroma !=
165 p_image->p_dec->fmt_out.video.i_chroma ||
166 p_image->p_filter->fmt_out.video.i_chroma != p_fmt_out->i_chroma )
168 /* We need to restart a new filter */
169 DeleteFilter( p_image->p_filter );
170 p_image->p_filter = 0;
174 if( !p_image->p_filter )
177 CreateFilter( p_image->p_parent, &p_image->p_dec->fmt_out,
180 if( !p_image->p_filter )
182 p_pic->pf_release( p_pic );
188 /* Filters should handle on-the-fly size changes */
189 p_image->p_filter->fmt_in = p_image->p_dec->fmt_out;
190 p_image->p_filter->fmt_out = p_image->p_dec->fmt_out;
191 p_image->p_filter->fmt_out.i_codec = p_fmt_out->i_chroma;
192 p_image->p_filter->fmt_out.video = *p_fmt_out;
195 p_pic = p_image->p_filter->pf_video_filter( p_image->p_filter, p_pic );
196 *p_fmt_out = p_image->p_filter->fmt_out.video;
198 else *p_fmt_out = p_image->p_dec->fmt_out.video;
203 static picture_t *ImageReadUrl( image_handler_t *p_image, const char *psz_url,
204 video_format_t *p_fmt_in,
205 video_format_t *p_fmt_out )
209 stream_t *p_stream = NULL;
212 p_stream = stream_UrlNew( p_image->p_parent, psz_url );
216 msg_Dbg( p_image->p_parent, "could not open %s for reading",
221 i_size = stream_Size( p_stream );
223 p_block = block_New( p_image->p_parent, i_size );
225 stream_Read( p_stream, p_block->p_buffer, i_size );
226 stream_Delete( p_stream );
228 if( !p_fmt_in->i_chroma )
230 /* Try to guess format from file name */
231 p_fmt_in->i_chroma = Ext2Fourcc( psz_url );
234 p_pic = ImageRead( p_image, p_block, p_fmt_in, p_fmt_out );
244 void PicRelease( picture_t *p_pic ){};
246 static block_t *ImageWrite( image_handler_t *p_image, picture_t *p_pic,
247 video_format_t *p_fmt_in,
248 video_format_t *p_fmt_out )
251 void (*pf_release)( picture_t * );
253 /* Check if we can reuse the current encoder */
254 if( p_image->p_enc &&
255 ( p_image->p_enc->fmt_out.i_codec != p_fmt_out->i_chroma ||
256 p_image->p_enc->fmt_out.video.i_width != p_fmt_out->i_width ||
257 p_image->p_enc->fmt_out.video.i_height != p_fmt_out->i_height ) )
259 DeleteEncoder( p_image->p_enc );
263 /* Start an encoder */
264 if( !p_image->p_enc )
266 p_image->p_enc = CreateEncoder( p_image->p_parent,
267 p_fmt_in, p_fmt_out );
268 if( !p_image->p_enc ) return NULL;
271 /* Check if we need chroma conversion or resizing */
272 if( p_image->p_enc->fmt_in.video.i_chroma != p_fmt_in->i_chroma ||
273 p_image->p_enc->fmt_in.video.i_width != p_fmt_in->i_width ||
274 p_image->p_enc->fmt_in.video.i_height != p_fmt_in->i_height )
276 picture_t *p_tmp_pic;
278 if( p_image->p_filter )
279 if( p_image->p_filter->fmt_in.video.i_chroma != p_fmt_in->i_chroma ||
280 p_image->p_filter->fmt_out.video.i_chroma !=
281 p_image->p_enc->fmt_in.video.i_chroma )
283 /* We need to restart a new filter */
284 DeleteFilter( p_image->p_filter );
285 p_image->p_filter = 0;
289 if( !p_image->p_filter )
292 es_format_Init( &fmt_in, VIDEO_ES, p_fmt_in->i_chroma );
293 fmt_in.video = *p_fmt_in;
296 CreateFilter( p_image->p_parent, &fmt_in,
297 &p_image->p_enc->fmt_in.video, NULL );
299 if( !p_image->p_filter )
306 /* Filters should handle on-the-fly size changes */
307 p_image->p_filter->fmt_in.i_codec = p_fmt_in->i_chroma;
308 p_image->p_filter->fmt_out.video = *p_fmt_in;
309 p_image->p_filter->fmt_out.i_codec =p_image->p_enc->fmt_in.i_codec;
310 p_image->p_filter->fmt_out.video = p_image->p_enc->fmt_in.video;
313 pf_release = p_pic->pf_release;
314 p_pic->pf_release = PicRelease; /* Small hack */
316 p_image->p_filter->pf_video_filter( p_image->p_filter, p_pic );
317 p_pic->pf_release = pf_release;
319 p_block = p_image->p_enc->pf_encode_video( p_image->p_enc, p_tmp_pic );
321 p_image->p_filter->pf_vout_buffer_del( p_image->p_filter, p_tmp_pic );
325 p_block = p_image->p_enc->pf_encode_video( p_image->p_enc, p_pic );
330 msg_Dbg( p_image->p_parent, "no image encoded" );
337 static int ImageWriteUrl( image_handler_t *p_image, picture_t *p_pic,
338 video_format_t *p_fmt_in, video_format_t *p_fmt_out,
339 const char *psz_url )
344 if( !p_fmt_out->i_chroma )
346 /* Try to guess format from file name */
347 p_fmt_out->i_chroma = Ext2Fourcc( psz_url );
350 file = utf8_fopen( psz_url, "wb" );
353 msg_Dbg( p_image->p_parent, "could not open file %s for writing",
358 p_block = ImageWrite( p_image, p_pic, p_fmt_in, p_fmt_out );
362 fwrite( p_block->p_buffer, sizeof(char), p_block->i_buffer, file );
363 block_Release( p_block );
368 return p_block ? VLC_SUCCESS : VLC_EGENERIC;
372 * Convert an image to a different format
376 static picture_t *ImageConvert( image_handler_t *p_image, picture_t *p_pic,
377 video_format_t *p_fmt_in,
378 video_format_t *p_fmt_out )
380 void (*pf_release)( picture_t * );
383 if( !p_fmt_out->i_width && !p_fmt_out->i_height &&
384 p_fmt_out->i_sar_num && p_fmt_out->i_sar_den &&
385 p_fmt_out->i_sar_num * p_fmt_in->i_sar_den !=
386 p_fmt_out->i_sar_den * p_fmt_in->i_sar_num )
389 p_fmt_in->i_sar_num * (int64_t)p_fmt_out->i_sar_den *
390 p_fmt_in->i_width / p_fmt_in->i_sar_den / p_fmt_out->i_sar_num;
391 p_fmt_out->i_visible_width =
392 p_fmt_in->i_sar_num * (int64_t)p_fmt_out->i_sar_den *
393 p_fmt_in->i_visible_width / p_fmt_in->i_sar_den /
394 p_fmt_out->i_sar_num;
397 if( !p_fmt_out->i_chroma ) p_fmt_out->i_chroma = p_fmt_in->i_chroma;
398 if( !p_fmt_out->i_width )
399 p_fmt_out->i_width = p_fmt_out->i_visible_width = p_fmt_in->i_width;
400 if( !p_fmt_out->i_height )
401 p_fmt_out->i_height = p_fmt_out->i_visible_height = p_fmt_in->i_height;
402 if( !p_fmt_out->i_sar_num ) p_fmt_out->i_sar_num = p_fmt_in->i_sar_num;
403 if( !p_fmt_out->i_sar_den ) p_fmt_out->i_sar_den = p_fmt_in->i_sar_den;
404 if( !p_fmt_out->i_aspect ) p_fmt_out->i_aspect = p_fmt_in->i_aspect;
406 if( p_image->p_filter )
407 if( p_image->p_filter->fmt_in.video.i_chroma != p_fmt_in->i_chroma ||
408 p_image->p_filter->fmt_out.video.i_chroma != p_fmt_out->i_chroma )
410 /* We need to restart a new filter */
411 DeleteFilter( p_image->p_filter );
412 p_image->p_filter = NULL;
416 if( !p_image->p_filter )
419 es_format_Init( &fmt_in, VIDEO_ES, p_fmt_in->i_chroma );
420 fmt_in.video = *p_fmt_in;
423 CreateFilter( p_image->p_parent, &fmt_in, p_fmt_out, NULL );
425 if( !p_image->p_filter )
432 /* Filters should handle on-the-fly size changes */
433 p_image->p_filter->fmt_in.video = *p_fmt_in;
434 p_image->p_filter->fmt_out.video = *p_fmt_out;
437 pf_release = p_pic->pf_release;
438 p_pic->pf_release = PicRelease; /* Small hack */
439 p_pif = p_image->p_filter->pf_video_filter( p_image->p_filter, p_pic );
440 p_pic->pf_release = pf_release;
442 if( p_fmt_in->i_chroma == p_fmt_out->i_chroma &&
443 p_fmt_in->i_width == p_fmt_out->i_width &&
444 p_fmt_in->i_height == p_fmt_out->i_height )
446 /* Duplicate image */
447 p_pif = p_image->p_filter->pf_vout_buffer_new( p_image->p_filter );
448 if( p_pif ) vout_CopyPicture( p_image->p_parent, p_pif, p_pic );
455 * Filter an image with a psz_module filter
459 static picture_t *ImageFilter( image_handler_t *p_image, picture_t *p_pic,
460 video_format_t *p_fmt, const char *psz_module )
462 void (*pf_release)( picture_t * );
466 if( !p_image->p_filter )
469 es_format_Init( &fmt, VIDEO_ES, p_fmt->i_chroma );
473 CreateFilter( p_image->p_parent, &fmt, &fmt.video, psz_module );
475 if( !p_image->p_filter )
482 /* Filters should handle on-the-fly size changes */
483 p_image->p_filter->fmt_in.video = *p_fmt;
484 p_image->p_filter->fmt_out.video = *p_fmt;
487 pf_release = p_pic->pf_release;
488 p_pic->pf_release = PicRelease; /* Small hack */
489 p_pif = p_image->p_filter->pf_video_filter( p_image->p_filter, p_pic );
490 p_pic->pf_release = pf_release;
501 vlc_fourcc_t i_codec;
506 { VLC_FOURCC('j','p','e','g'), "jpeg" },
507 { VLC_FOURCC('j','p','e','g'), "jpg" },
508 { VLC_FOURCC('l','j','p','g'), "ljpg" },
509 { VLC_FOURCC('p','n','g',' '), "png" },
510 { VLC_FOURCC('p','g','m',' '), "pgm" },
511 { VLC_FOURCC('p','g','m','y'), "pgmyuv" },
512 { VLC_FOURCC('p','b','m',' '), "pbm" },
513 { VLC_FOURCC('p','a','m',' '), "pam" },
514 { VLC_FOURCC('t','g','a',' '), "tga" },
515 { VLC_FOURCC('b','m','p',' '), "bmp" },
516 { VLC_FOURCC('p','n','m',' '), "pnm" },
517 { VLC_FOURCC('x','p','m',' '), "xpm" },
518 { VLC_FOURCC('x','c','f',' '), "xcf" },
519 { VLC_FOURCC('p','c','x',' '), "pcx" },
520 { VLC_FOURCC('g','i','f',' '), "gif" },
521 { VLC_FOURCC('t','i','f','f'), "tif" },
522 { VLC_FOURCC('t','i','f','f'), "tiff" },
523 { VLC_FOURCC('l','b','m',' '), "lbm" },
527 static vlc_fourcc_t Ext2Fourcc( const char *psz_name )
531 psz_name = strrchr( psz_name, '.' );
532 if( !psz_name ) return 0;
535 for( i = 0; ext_table[i].i_codec; i++ )
538 for( j = 0; toupper(ext_table[i].psz_ext[j]) == toupper(psz_name[j]);
541 if( !ext_table[i].psz_ext[j] && !psz_name[j] )
542 return ext_table[i].i_codec;
550 static const char *Fourcc2Ext( vlc_fourcc_t i_codec )
554 for( i = 0; ext_table[i].i_codec != 0; i++ )
556 if( ext_table[i].i_codec == i_codec ) return ext_table[i].psz_ext;
563 static void video_release_buffer( picture_t *p_pic )
565 if( p_pic && p_pic->p_data_orig ) free( p_pic->p_data_orig );
566 if( p_pic && p_pic->p_sys ) free( p_pic->p_sys );
567 if( p_pic ) free( p_pic );
570 static picture_t *video_new_buffer( decoder_t *p_dec )
572 picture_t *p_pic = malloc( sizeof(picture_t) );
574 p_dec->fmt_out.video.i_chroma = p_dec->fmt_out.i_codec;
575 vout_AllocatePicture( VLC_OBJECT(p_dec), p_pic,
576 p_dec->fmt_out.video.i_chroma,
577 p_dec->fmt_out.video.i_width,
578 p_dec->fmt_out.video.i_height,
579 p_dec->fmt_out.video.i_aspect );
581 if( !p_pic->i_planes )
587 p_pic->pf_release = video_release_buffer;
588 p_pic->i_status = RESERVED_PICTURE;
594 static void video_del_buffer( decoder_t *p_dec, picture_t *p_pic )
596 if( p_pic && p_pic->p_data_orig ) free( p_pic->p_data_orig );
597 if( p_pic && p_pic->p_sys ) free( p_pic->p_sys );
598 if( p_pic ) free( p_pic );
601 static void video_link_picture( decoder_t *p_dec, picture_t *p_pic )
605 static void video_unlink_picture( decoder_t *p_dec, picture_t *p_pic )
609 static decoder_t *CreateDecoder( vlc_object_t *p_this, video_format_t *fmt )
613 p_dec = vlc_object_create( p_this, VLC_OBJECT_DECODER );
616 msg_Err( p_this, "out of memory" );
620 p_dec->p_module = NULL;
621 es_format_Init( &p_dec->fmt_in, VIDEO_ES, fmt->i_chroma );
622 es_format_Init( &p_dec->fmt_out, VIDEO_ES, 0 );
623 p_dec->fmt_in.video = *fmt;
624 p_dec->b_pace_control = VLC_TRUE;
626 p_dec->pf_vout_buffer_new = video_new_buffer;
627 p_dec->pf_vout_buffer_del = video_del_buffer;
628 p_dec->pf_picture_link = video_link_picture;
629 p_dec->pf_picture_unlink = video_unlink_picture;
631 vlc_object_attach( p_dec, p_this );
633 /* Find a suitable decoder module */
634 p_dec->p_module = module_Need( p_dec, "decoder", "$codec", 0 );
635 if( !p_dec->p_module )
637 msg_Err( p_dec, "no suitable decoder module for fourcc `%4.4s'.\n"
638 "VLC probably does not support this image format.",
639 (char*)&p_dec->fmt_in.i_codec );
641 DeleteDecoder( p_dec );
648 static void DeleteDecoder( decoder_t * p_dec )
650 vlc_object_detach( p_dec );
652 if( p_dec->p_module ) module_Unneed( p_dec, p_dec->p_module );
654 es_format_Clean( &p_dec->fmt_in );
655 es_format_Clean( &p_dec->fmt_out );
657 vlc_object_destroy( p_dec );
661 static encoder_t *CreateEncoder( vlc_object_t *p_this, video_format_t *fmt_in,
662 video_format_t *fmt_out )
666 p_enc = vlc_object_create( p_this, VLC_OBJECT_ENCODER );
669 msg_Err( p_this, "out of memory" );
673 p_enc->p_module = NULL;
674 es_format_Init( &p_enc->fmt_in, VIDEO_ES, fmt_in->i_chroma );
675 p_enc->fmt_in.video = *fmt_in;
676 if( fmt_out->i_width > 0 && fmt_out->i_height > 0 )
678 p_enc->fmt_in.video.i_width = fmt_out->i_width;
679 p_enc->fmt_in.video.i_height = fmt_out->i_height;
681 if( fmt_out->i_visible_width > 0 &&
682 fmt_out->i_visible_height > 0 )
684 p_enc->fmt_in.video.i_visible_width = fmt_out->i_visible_width;
685 p_enc->fmt_in.video.i_visible_height = fmt_out->i_visible_height;
689 p_enc->fmt_in.video.i_visible_width = fmt_out->i_width;
690 p_enc->fmt_in.video.i_visible_height = fmt_out->i_height;
693 else if( fmt_out->i_sar_num && fmt_out->i_sar_den &&
694 fmt_out->i_sar_num * fmt_in->i_sar_den !=
695 fmt_out->i_sar_den * fmt_in->i_sar_num )
697 p_enc->fmt_in.video.i_width =
698 fmt_in->i_sar_num * (int64_t)fmt_out->i_sar_den * fmt_in->i_width /
699 fmt_in->i_sar_den / fmt_out->i_sar_num;
700 p_enc->fmt_in.video.i_visible_width =
701 fmt_in->i_sar_num * (int64_t)fmt_out->i_sar_den *
702 fmt_in->i_visible_width / fmt_in->i_sar_den / fmt_out->i_sar_num;
705 p_enc->fmt_in.video.i_frame_rate = 25;
706 p_enc->fmt_in.video.i_frame_rate_base = 1;
708 es_format_Init( &p_enc->fmt_out, VIDEO_ES, fmt_out->i_chroma );
709 p_enc->fmt_out.video = *fmt_out;
710 p_enc->fmt_out.video.i_width = p_enc->fmt_in.video.i_width;
711 p_enc->fmt_out.video.i_height = p_enc->fmt_in.video.i_height;
713 vlc_object_attach( p_enc, p_this );
715 /* Find a suitable decoder module */
716 p_enc->p_module = module_Need( p_enc, "encoder", 0, 0 );
717 if( !p_enc->p_module )
719 msg_Err( p_enc, "no suitable encoder module for fourcc `%4.4s'.\n"
720 "VLC probably does not support this image format.",
721 (char*)&p_enc->fmt_out.i_codec );
723 DeleteEncoder( p_enc );
726 p_enc->fmt_in.video.i_chroma = p_enc->fmt_in.i_codec;
731 static void DeleteEncoder( encoder_t * p_enc )
733 vlc_object_detach( p_enc );
735 if( p_enc->p_module ) module_Unneed( p_enc, p_enc->p_module );
737 es_format_Clean( &p_enc->fmt_in );
738 es_format_Clean( &p_enc->fmt_out );
740 vlc_object_destroy( p_enc );
744 static filter_t *CreateFilter( vlc_object_t *p_this, es_format_t *p_fmt_in,
745 video_format_t *p_fmt_out,
746 const char *psz_module )
750 p_filter = vlc_object_create( p_this, VLC_OBJECT_FILTER );
751 vlc_object_attach( p_filter, p_this );
753 p_filter->pf_vout_buffer_new =
754 (picture_t *(*)(filter_t *))video_new_buffer;
755 p_filter->pf_vout_buffer_del =
756 (void (*)(filter_t *, picture_t *))video_del_buffer;
758 p_filter->fmt_in = *p_fmt_in;
759 p_filter->fmt_out = *p_fmt_in;
760 p_filter->fmt_out.i_codec = p_fmt_out->i_chroma;
761 p_filter->fmt_out.video = *p_fmt_out;
762 p_filter->p_module = module_Need( p_filter, "video filter2",
765 if( !p_filter->p_module )
767 msg_Dbg( p_filter, "no video filter found" );
768 DeleteFilter( p_filter );
775 static void DeleteFilter( filter_t * p_filter )
777 vlc_object_detach( p_filter );
779 if( p_filter->p_module ) module_Unneed( p_filter, p_filter->p_module );
781 es_format_Clean( &p_filter->fmt_in );
782 es_format_Clean( &p_filter->fmt_out );
784 vlc_object_destroy( p_filter );