xine_plugin.c
来自「linux下的MPEG1」· C语言 代码 · 共 927 行 · 第 1/3 页
C
927 行
/* * Copyright (C) 2000-2004 the xine project * * This file is part of xine, a free video player. * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * * $Id: xine_plugin.c,v 1.52 2006/07/12 21:08:46 dsalt Exp $ * * advanced video deinterlacer plugin * Jun/2003 by Miguel Freitas * * heavily based on tvtime.sf.net by Billy Biggs *//*#define LOG*/#include "xine_internal.h"#include "post.h"#include "xineutils.h"#include "xine_buffer.h"#include <pthread.h>#include "tvtime.h"#include "speedy.h"#include "deinterlace.h"#include "plugins/plugins.h"/* plugin class initialization function */static void *deinterlace_init_plugin(xine_t *xine, void *);/* plugin catalog information */static const post_info_t deinterlace_special_info = { XINE_POST_TYPE_VIDEO_FILTER };const plugin_info_t xine_plugin_info[] EXPORTED = { /* type, API, "name", version, special_info, init_function */ { PLUGIN_POST | PLUGIN_MUST_PRELOAD, 9, "tvtime", XINE_VERSION_CODE, &deinterlace_special_info, &deinterlace_init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL }};typedef struct post_plugin_deinterlace_s post_plugin_deinterlace_t;#define MAX_NUM_METHODS 30static const char *enum_methods[MAX_NUM_METHODS];static char *enum_pulldown[] = { "none", "vektor", NULL };static char *enum_framerate[] = { "full", "half_top", "half_bottom", NULL };static void *help_string;/* * this is the struct used by "parameters api" */typedef struct deinterlace_parameters_s { int method; int enabled; int pulldown; int framerate_mode; int judder_correction; int use_progressive_frame_flag; int chroma_filter; int cheap_mode;} deinterlace_parameters_t;/* * description of params struct */START_PARAM_DESCR( deinterlace_parameters_t )PARAM_ITEM( POST_PARAM_TYPE_INT, method, enum_methods, 0, 0, 0, "deinterlace method" )PARAM_ITEM( POST_PARAM_TYPE_BOOL, enabled, NULL, 0, 1, 0, "enable/disable" )PARAM_ITEM( POST_PARAM_TYPE_INT, pulldown, enum_pulldown, 0, 0, 0, "pulldown algorithm" )PARAM_ITEM( POST_PARAM_TYPE_INT, framerate_mode, enum_framerate, 0, 0, 0, "framerate output mode" )PARAM_ITEM( POST_PARAM_TYPE_BOOL, judder_correction, NULL, 0, 1, 0, "make frames evenly spaced for film mode (24 fps)" )PARAM_ITEM( POST_PARAM_TYPE_BOOL, use_progressive_frame_flag, NULL, 0, 1, 0, "disable deinterlacing when progressive_frame flag is set" )PARAM_ITEM( POST_PARAM_TYPE_BOOL, chroma_filter, NULL, 0, 1, 0, "apply chroma filter after deinterlacing" )PARAM_ITEM( POST_PARAM_TYPE_BOOL, cheap_mode, NULL, 0, 1, 0, "skip image format conversion - cheaper but not 100% correct" )END_PARAM_DESCR( param_descr )#define NUM_RECENT_FRAMES 2#define FPS_24_DURATION 3754#define FRAMES_TO_SYNC 20/* plugin structure */struct post_plugin_deinterlace_s { post_plugin_t post; xine_post_in_t parameter_input; /* private data */ int cur_method; int enabled; int pulldown; int framerate_mode; int judder_correction; int use_progressive_frame_flag; int chroma_filter; int cheap_mode; tvtime_t *tvtime; int tvtime_changed; int tvtime_last_filmmode; int vo_deinterlace_enabled; int framecounter; uint8_t rff_pattern; vo_frame_t *recent_frame[NUM_RECENT_FRAMES]; pthread_mutex_t lock;};typedef struct post_class_deinterlace_s { post_class_t class; deinterlace_parameters_t init_param;} post_class_deinterlace_t;static void _flush_frames(post_plugin_deinterlace_t *this) { int i; for( i = 0; i < NUM_RECENT_FRAMES; i++ ) { if( this->recent_frame[i] ) { this->recent_frame[i]->free(this->recent_frame[i]); this->recent_frame[i] = NULL; } } this->tvtime_changed++;}static int set_parameters (xine_post_t *this_gen, void *param_gen) { post_plugin_deinterlace_t *this = (post_plugin_deinterlace_t *)this_gen; deinterlace_parameters_t *param = (deinterlace_parameters_t *)param_gen; pthread_mutex_lock (&this->lock); if( this->enabled != param->enabled || this->cheap_mode != param->cheap_mode ) _flush_frames(this); this->cur_method = param->method; this->enabled = param->enabled; this->pulldown = param->pulldown; this->framerate_mode = param->framerate_mode; this->judder_correction = param->judder_correction; this->use_progressive_frame_flag = param->use_progressive_frame_flag; this->chroma_filter = param->chroma_filter; this->cheap_mode = param->cheap_mode; this->tvtime_changed++; pthread_mutex_unlock (&this->lock); return 1;}static int get_parameters (xine_post_t *this_gen, void *param_gen) { post_plugin_deinterlace_t *this = (post_plugin_deinterlace_t *)this_gen; deinterlace_parameters_t *param = (deinterlace_parameters_t *)param_gen; param->method = this->cur_method; param->enabled = this->enabled; param->pulldown = this->pulldown; param->framerate_mode = this->framerate_mode; param->judder_correction = this->judder_correction; param->use_progressive_frame_flag = this->use_progressive_frame_flag; param->chroma_filter = this->chroma_filter; param->cheap_mode = this->cheap_mode; return 1;} static xine_post_api_descr_t * get_param_descr (void) { return ¶m_descr;}static char * get_static_help (void) { return _("Advanced tvtime/deinterlacer plugin with pulldown detection\n" "This plugin aims to provide deinterlacing mechanisms comparable " "to high quality progressive DVD players and so called " "line-doublers, for use with computer monitors, projectors and " "other progressive display devices.\n" "\n" "Parameters\n" "\n" " Method: Select deinterlacing method/algorithm to use, see below for " "explanation of each method.\n" "\n" " Enabled: Enable/disable the plugin.\n" "\n" " Pulldown: Choose the 2-3 pulldown detection algorithm. 24 FPS films " "that have being converted to NTSC can be detected and intelligently " "reconstructed to their original (non-interlaced) frames.\n" "\n" " Framerate_mode: Selecting 'full' will deinterlace every field " "to an unique frame for television quality and beyond. This feature will " "effetively double the frame rate, improving smoothness. Note, however, " "that full 59.94 FPS is not possible with plain 2.4 Linux kernel (that " "use a timer interrupt frequency of 100Hz). Newer RedHat and 2.6 kernels " "use higher HZ settings (512 and 1000, respectively) and should work fine.\n" "\n" " Judder_correction: Once 2-3 pulldown is enabled and a film material " "is detected, it is possible to reduce the frame rate to original rate " "used (24 FPS). This will make the frames evenly spaced in time, " "matching the speed they were shot and eliminating the judder effect.\n" "\n" " Use_progressive_frame_flag: Well mastered MPEG2 streams uses a flag " "to indicate progressive material. This setting control whether we trust " "this flag or not (some rare and buggy mpeg2 streams set it wrong).\n" "\n" " Chroma_filter: DVD/MPEG2 use an interlaced image format that has " "a very poor vertical chroma resolution. Upsampling the chroma for purposes " "of deinterlacing may cause some artifacts to occur (eg. color stripes). Use " "this option to blur the chroma vertically after deinterlacing to remove " "the artifacts. Warning: cpu intensive.\n" "\n" " Cheap_mode: This will skip the expensive YV12->YUY2 image conversion, " "tricking tvtime/dscaler routines like if they were still handling YUY2 " "images. Of course, this is not correct, not all pixels will be evaluated " "by the algorithms to decide the regions to deinterlace and chroma will be " "processed separately. Nevertheless, it allows people with not so fast " "systems to try deinterlace algorithms, in a tradeoff between quality " "and cpu usage.\n" "\n" "* Uses several algorithms from tvtime and dscaler projects.\n" "Deinterlacing methods: (Not all methods are available for all plataforms)\n" "\n" );}static char * get_help (void) { return (char *)help_string;}static xine_post_api_t post_api = { set_parameters, get_parameters, get_param_descr, get_help,};/* plugin class functions */static post_plugin_t *deinterlace_open_plugin(post_class_t *class_gen, int inputs, xine_audio_port_t **audio_target, xine_video_port_t **video_target);static char *deinterlace_get_identifier(post_class_t *class_gen);static char *deinterlace_get_description(post_class_t *class_gen);static void deinterlace_class_dispose(post_class_t *class_gen);/* plugin instance functions */static void deinterlace_dispose(post_plugin_t *this_gen);/* replaced video_port functions */static int deinterlace_get_property(xine_video_port_t *port_gen, int property);static int deinterlace_set_property(xine_video_port_t *port_gen, int property, int value);static void deinterlace_flush(xine_video_port_t *port_gen);static void deinterlace_open(xine_video_port_t *port_gen, xine_stream_t *stream);static void deinterlace_close(xine_video_port_t *port_gen, xine_stream_t *stream);/* frame intercept check */static int deinterlace_intercept_frame(post_video_port_t *port, vo_frame_t *frame);/* replaced vo_frame functions */static int deinterlace_draw(vo_frame_t *frame, xine_stream_t *stream);static void *deinterlace_init_plugin(xine_t *xine, void *data){ post_class_deinterlace_t *class = (post_class_deinterlace_t *)xine_xmalloc(sizeof(post_class_deinterlace_t)); uint32_t config_flags = xine_mm_accel(); int i; if (!class) return NULL; class->class.open_plugin = deinterlace_open_plugin; class->class.get_identifier = deinterlace_get_identifier; class->class.get_description = deinterlace_get_description; class->class.dispose = deinterlace_class_dispose; setup_speedy_calls(xine_mm_accel(),0);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?