Changeset c0b61e8a89d47587b3df91c38910e3732b291ca4
- Timestamp:
- 06/15/08 13:05:55
(3 months ago)
- Author:
- Antoine Cellerier <dionoea@videolan.org>
- git-committer:
- Antoine Cellerier <dionoea@videolan.org> 1213527955 +0200
- git-parent:
[95addd57388b78fdfb6a58c90437085de8bbbc33]
- git-author:
- Antoine Cellerier <dionoea@videolan.org> 1213287808 +0200
- Message:
Use filter chain in mosaic bridge too.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r3561b9b |
rc0b61e8 |
|
| 62 | 62 | int i_chroma; /* force image format chroma */ |
|---|
| 63 | 63 | |
|---|
| 64 | | filter_t **pp_vfilters; |
|---|
| 65 | | int i_vfilters; |
|---|
| | 64 | filter_chain_t *p_vf2; |
|---|
| 66 | 65 | }; |
|---|
| 67 | 66 | |
|---|
| … | … | |
| 305 | 304 | } |
|---|
| 306 | 305 | |
|---|
| | 306 | static int video_filter_buffer_allocation_init( filter_t *p_filter, void *p_data ) |
|---|
| | 307 | { |
|---|
| | 308 | p_filter->pf_vout_buffer_new = video_new_buffer_filter; |
|---|
| | 309 | p_filter->pf_vout_buffer_del = video_del_buffer_filter; |
|---|
| | 310 | p_filter->p_owner = p_data; |
|---|
| | 311 | return VLC_SUCCESS; |
|---|
| | 312 | } |
|---|
| | 313 | |
|---|
| 307 | 314 | static sout_stream_id_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt ) |
|---|
| 308 | 315 | { |
|---|
| … | … | |
| 310 | 317 | bridge_t *p_bridge; |
|---|
| 311 | 318 | bridged_es_t *p_es; |
|---|
| 312 | | char *psz_chain, *psz_parser; |
|---|
| | 319 | char *psz_chain; |
|---|
| 313 | 320 | int i; |
|---|
| 314 | 321 | |
|---|
| … | … | |
| 420 | 427 | psz_chain = var_GetNonEmptyString( p_stream, CFG_PREFIX "vfilter" ); |
|---|
| 421 | 428 | msg_Dbg( p_stream, "psz_chain: %s\n", psz_chain ); |
|---|
| 422 | | { |
|---|
| 423 | | config_chain_t *p_cfg; |
|---|
| 424 | | for( p_cfg = p_stream->p_cfg; p_cfg != NULL; p_cfg = p_cfg->p_next ) |
|---|
| 425 | | { |
|---|
| 426 | | msg_Dbg( p_stream, " - %s\n", p_cfg->psz_value ); |
|---|
| 427 | | } |
|---|
| 428 | | } |
|---|
| 429 | | p_sys->i_vfilters = 0; |
|---|
| 430 | | p_sys->pp_vfilters = NULL; |
|---|
| 431 | | psz_parser = psz_chain; |
|---|
| 432 | | while( psz_parser && *psz_parser ) |
|---|
| 433 | | { |
|---|
| 434 | | config_chain_t *p_cfg; |
|---|
| 435 | | char *psz_name; |
|---|
| 436 | | filter_t **pp_vfilter; |
|---|
| 437 | | psz_parser = config_ChainCreate( &psz_name, &p_cfg, psz_parser ); |
|---|
| 438 | | p_sys->i_vfilters++; |
|---|
| 439 | | p_sys->pp_vfilters = |
|---|
| 440 | | (filter_t **)realloc( p_sys->pp_vfilters, |
|---|
| 441 | | p_sys->i_vfilters * sizeof(filter_t *) ); |
|---|
| 442 | | pp_vfilter = p_sys->pp_vfilters+(p_sys->i_vfilters - 1); |
|---|
| 443 | | *pp_vfilter = vlc_object_create( p_stream, VLC_OBJECT_FILTER ); |
|---|
| 444 | | vlc_object_attach( *pp_vfilter, p_stream ); |
|---|
| 445 | | (*pp_vfilter)->pf_vout_buffer_new = video_new_buffer_filter; |
|---|
| 446 | | (*pp_vfilter)->pf_vout_buffer_del = video_del_buffer_filter; |
|---|
| 447 | | (*pp_vfilter)->fmt_in = p_sys->p_decoder->fmt_out; |
|---|
| | 429 | if( psz_chain ) |
|---|
| | 430 | { |
|---|
| | 431 | p_sys->p_vf2 = filter_chain_New( p_stream, "video filter2", false, |
|---|
| | 432 | video_filter_buffer_allocation_init, |
|---|
| | 433 | NULL, p_sys->p_decoder->p_owner ); |
|---|
| | 434 | es_format_t fmt; |
|---|
| | 435 | es_format_Copy( &fmt, &p_sys->p_decoder->fmt_out ); |
|---|
| 448 | 436 | if( p_sys->i_chroma ) |
|---|
| 449 | | (*pp_vfilter)->fmt_in.video.i_chroma = p_sys->i_chroma; |
|---|
| 450 | | (*pp_vfilter)->fmt_out = (*pp_vfilter)->fmt_in; |
|---|
| 451 | | (*pp_vfilter)->p_cfg = p_cfg; |
|---|
| 452 | | (*pp_vfilter)->p_module = |
|---|
| 453 | | module_Need( *pp_vfilter, "video filter2", psz_name, true ); |
|---|
| 454 | | if( (*pp_vfilter)->p_module ) |
|---|
| 455 | | { |
|---|
| 456 | | /* It worked! */ |
|---|
| 457 | | (*pp_vfilter)->p_owner = (filter_owner_sys_t *) |
|---|
| 458 | | p_sys->p_decoder->p_owner; |
|---|
| 459 | | msg_Err( p_stream, "Added video filter %s to the chain", |
|---|
| 460 | | psz_name ); |
|---|
| 461 | | } |
|---|
| 462 | | else |
|---|
| 463 | | { |
|---|
| 464 | | /* Crap ... we didn't find a filter */ |
|---|
| 465 | | msg_Warn( p_stream, |
|---|
| 466 | | "no video filter matching name \"%s\" found", |
|---|
| 467 | | psz_name ); |
|---|
| 468 | | vlc_object_detach( *pp_vfilter ); |
|---|
| 469 | | vlc_object_release( *pp_vfilter ); |
|---|
| 470 | | p_sys->i_vfilters--; |
|---|
| 471 | | } |
|---|
| 472 | | } |
|---|
| 473 | | free( psz_chain ); |
|---|
| | 437 | fmt.video.i_chroma = p_sys->i_chroma; |
|---|
| | 438 | filter_chain_Reset( p_sys->p_vf2, &fmt, &fmt ); |
|---|
| | 439 | filter_chain_AppendFromString( p_sys->p_vf2, psz_chain ); |
|---|
| | 440 | free( psz_chain ); |
|---|
| | 441 | } |
|---|
| 474 | 442 | |
|---|
| 475 | 443 | return (sout_stream_id_t *)p_sys; |
|---|
| … | … | |
| 483 | 451 | bridged_es_t *p_es; |
|---|
| 484 | 452 | bool b_last_es = true; |
|---|
| 485 | | filter_t **pp_vfilter, **pp_end; |
|---|
| 486 | 453 | int i; |
|---|
| 487 | 454 | |
|---|
| … | … | |
| 514 | 481 | |
|---|
| 515 | 482 | /* Destroy user specified video filters */ |
|---|
| 516 | | pp_vfilter = p_sys->pp_vfilters; |
|---|
| 517 | | pp_end = pp_vfilter + p_sys->i_vfilters; |
|---|
| 518 | | for( ; pp_vfilter < pp_end; pp_vfilter++ ) |
|---|
| 519 | | { |
|---|
| 520 | | vlc_object_detach( *pp_vfilter ); |
|---|
| 521 | | if( (*pp_vfilter)->p_module ) |
|---|
| 522 | | module_Unneed( *pp_vfilter, (*pp_vfilter)->p_module ); |
|---|
| 523 | | vlc_object_release( *pp_vfilter ); |
|---|
| 524 | | } |
|---|
| 525 | | free( p_sys->pp_vfilters ); |
|---|
| | 483 | filter_chain_Delete( p_sys->p_vf2 ); |
|---|
| 526 | 484 | |
|---|
| 527 | 485 | vlc_mutex_lock( p_sys->p_lock ); |
|---|
| … | … | |
| 682 | 640 | p_pic->pf_release( p_pic ); |
|---|
| 683 | 641 | |
|---|
| 684 | | if( p_sys->pp_vfilters ) |
|---|
| 685 | | { |
|---|
| 686 | | /* Apply user specified video filters */ |
|---|
| 687 | | filter_t **pp_vfilter = p_sys->pp_vfilters; |
|---|
| 688 | | filter_t **pp_end = pp_vfilter + p_sys->i_vfilters; |
|---|
| 689 | | for( ; pp_vfilter < pp_end; pp_vfilter++ ) |
|---|
| 690 | | { |
|---|
| 691 | | (*pp_vfilter)->fmt_in.i_codec = p_new_pic->format.i_chroma; |
|---|
| 692 | | (*pp_vfilter)->fmt_out.i_codec = p_new_pic->format.i_chroma; |
|---|
| 693 | | (*pp_vfilter)->fmt_in.video = p_new_pic->format; |
|---|
| 694 | | (*pp_vfilter)->fmt_out.video = p_new_pic->format; |
|---|
| 695 | | p_new_pic = (*pp_vfilter)->pf_video_filter( *pp_vfilter, |
|---|
| 696 | | p_new_pic ); |
|---|
| 697 | | if( !p_new_pic ) |
|---|
| 698 | | { |
|---|
| 699 | | msg_Err( p_stream, "video filter failed" ); |
|---|
| 700 | | break; |
|---|
| 701 | | } |
|---|
| 702 | | } |
|---|
| 703 | | if( !p_new_pic ) continue; |
|---|
| 704 | | } |
|---|
| | 642 | if( p_sys->p_vf2 ) |
|---|
| | 643 | p_new_pic = filter_chain_VideoFilter( p_sys->p_vf2, p_new_pic ); |
|---|
| 705 | 644 | |
|---|
| 706 | 645 | PushPicture( p_stream, p_new_pic ); |
|---|
| rbb03e12 |
rc0b61e8 |
|
| 177 | 177 | |
|---|
| 178 | 178 | int filter_chain_AppendFromString( filter_chain_t *p_chain, |
|---|
| 179 | | const char *psz_string ) |
|---|
| | 179 | const char *psz_string ) |
|---|
| 180 | 180 | { |
|---|
| 181 | 181 | config_chain_t *p_cfg = NULL; |
|---|