| 571 | | |
|---|
| 572 | | /***************************************************************************** |
|---|
| 573 | | * OpenDeinterlace: probe the filter and return score |
|---|
| 574 | | *****************************************************************************/ |
|---|
| 575 | | int E_(OpenDeinterlace)( vlc_object_t *p_this ) |
|---|
| 576 | | { |
|---|
| 577 | | filter_t *p_filter = (filter_t*)p_this; |
|---|
| 578 | | filter_sys_t *p_sys; |
|---|
| 579 | | |
|---|
| 580 | | /* Check if we can handle that formats */ |
|---|
| 581 | | if( E_(GetFfmpegChroma)( p_filter->fmt_in.video.i_chroma ) < 0 ) |
|---|
| 582 | | { |
|---|
| 583 | | return VLC_EGENERIC; |
|---|
| 584 | | } |
|---|
| 585 | | |
|---|
| 586 | | /* Allocate the memory needed to store the decoder's structure */ |
|---|
| 587 | | if( ( p_filter->p_sys = p_sys = |
|---|
| 588 | | (filter_sys_t *)malloc(sizeof(filter_sys_t)) ) == NULL ) |
|---|
| 589 | | { |
|---|
| 590 | | msg_Err( p_filter, "out of memory" ); |
|---|
| 591 | | return VLC_EGENERIC; |
|---|
| 592 | | } |
|---|
| 593 | | |
|---|
| 594 | | /* Misc init */ |
|---|
| 595 | | p_sys->i_src_ffmpeg_chroma = |
|---|
| 596 | | E_(GetFfmpegChroma)( p_filter->fmt_in.video.i_chroma ); |
|---|
| 597 | | p_filter->pf_video_filter = Deinterlace; |
|---|
| 598 | | |
|---|
| 599 | | msg_Dbg( p_filter, "deinterlacing" ); |
|---|
| 600 | | |
|---|
| 601 | | /* libavcodec needs to be initialized for some chroma conversions */ |
|---|
| 602 | | E_(InitLibavcodec)(p_this); |
|---|
| 603 | | |
|---|
| 604 | | return VLC_SUCCESS; |
|---|
| 605 | | } |
|---|
| 606 | | |
|---|
| 607 | | /***************************************************************************** |
|---|
| 608 | | * CloseDeinterlace: clean up the filter |
|---|
| 609 | | *****************************************************************************/ |
|---|
| 610 | | void E_(CloseDeinterlace)( vlc_object_t *p_this ) |
|---|
| 611 | | { |
|---|
| 612 | | filter_t *p_filter = (filter_t*)p_this; |
|---|
| 613 | | filter_sys_t *p_sys = p_filter->p_sys; |
|---|
| 614 | | |
|---|
| 615 | | free( p_sys ); |
|---|
| 616 | | } |
|---|
| 617 | | |
|---|
| 618 | | /***************************************************************************** |
|---|
| 619 | | * Do the processing here |
|---|
| 620 | | *****************************************************************************/ |
|---|
| 621 | | static picture_t *Deinterlace( filter_t *p_filter, picture_t *p_pic ) |
|---|
| 622 | | { |
|---|
| 623 | | filter_sys_t *p_sys = p_filter->p_sys; |
|---|
| 624 | | AVPicture src_pic, dest_pic; |
|---|
| 625 | | picture_t *p_pic_dst; |
|---|
| 626 | | int i; |
|---|
| 627 | | |
|---|
| 628 | | /* Request output picture */ |
|---|
| 629 | | p_pic_dst = p_filter->pf_vout_buffer_new( p_filter ); |
|---|
| 630 | | if( !p_pic_dst ) |
|---|
| 631 | | { |
|---|
| 632 | | msg_Warn( p_filter, "can't get output picture" ); |
|---|
| 633 | | return NULL; |
|---|
| 634 | | } |
|---|
| 635 | | |
|---|
| 636 | | /* Prepare the AVPictures for the conversion */ |
|---|
| 637 | | for( i = 0; i < p_pic->i_planes; i++ ) |
|---|
| 638 | | { |
|---|
| 639 | | src_pic.data[i] = p_pic->p[i].p_pixels; |
|---|
| 640 | | src_pic.linesize[i] = p_pic->p[i].i_pitch; |
|---|
| 641 | | } |
|---|
| 642 | | for( i = 0; i < p_pic_dst->i_planes; i++ ) |
|---|
| 643 | | { |
|---|
| 644 | | dest_pic.data[i] = p_pic_dst->p[i].p_pixels; |
|---|
| 645 | | dest_pic.linesize[i] = p_pic_dst->p[i].i_pitch; |
|---|
| 646 | | } |
|---|
| 647 | | |
|---|
| 648 | | avpicture_deinterlace( &dest_pic, &src_pic, p_sys->i_src_ffmpeg_chroma, |
|---|
| 649 | | p_filter->fmt_in.video.i_width, |
|---|
| 650 | | p_filter->fmt_in.video.i_height ); |
|---|
| 651 | | |
|---|
| 652 | | p_pic_dst->date = p_pic->date; |
|---|
| 653 | | p_pic_dst->b_force = p_pic->b_force; |
|---|
| 654 | | p_pic_dst->i_nb_fields = p_pic->i_nb_fields; |
|---|
| 655 | | p_pic_dst->b_progressive = VLC_TRUE; |
|---|
| 656 | | p_pic_dst->b_top_field_first = p_pic->b_top_field_first; |
|---|
| 657 | | |
|---|
| 658 | | p_pic->pf_release( p_pic ); |
|---|
| 659 | | return p_pic_dst; |
|---|
| 660 | | } |
|---|