📄 atmo.cpp
字号:
/****************************************************************************** atmo.cpp : "Atmo Light" video filter****************************************************************************** Copyright (C) 2000-2006 the VideoLAN team* $Id: 7c7e980bd5ccae5f64f08f3f5b54aac925b302e1 $** Authors: André Weber (WeberAndre@gmx.de)** This program 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.** This program 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.*****************************************************************************//****************************************************************************** Preamble*****************************************************************************/#include <stdlib.h> /* malloc(), free() */#include <string.h>#include <math.h> /* sin(), cos() */#ifdef HAVE_CONFIG_H# include "config.h"#endif// #define __ATMO_DEBUG__// [:Zs]+$#include <vlc_common.h>#include <vlc_plugin.h>#include <vlc_vout.h>#include <vlc_playlist.h>#include "vlc_filter.h"#include "AtmoDefs.h"#include "AtmoDynData.h"#include "AtmoLiveView.h"#include "AtmoTools.h"#include "AtmoExternalCaptureInput.h"#include "AtmoConfig.h"#include "AtmoConnection.h"#include "AtmoSerialConnection.h"/****************************************************************************** Local prototypes*****************************************************************************//* directly to vlc related functions required that the module is accepted */static int CreateFilter ( vlc_object_t * );static void DestroyFilter ( vlc_object_t * );static picture_t * Filter( filter_t *, picture_t *);/* callback for global variable state pause / continue / stop events */static void AddStateVariableCallback( filter_t *);static void DelStateVariableCallback( filter_t *);static int StateCallback(vlc_object_t *, char const *, vlc_value_t, vlc_value_t, void *);/* callback for variable crop-update */static void AddCropVariableCallback( filter_t *);static void DelCropVariableCallback( filter_t *);static int CropCallback(vlc_object_t *, char const *, vlc_value_t, vlc_value_t, void *);/* callback for atmo settings variables whose change should be immediately realized and applied to output*/static void DelAtmoSettingsVariablesCallbacks(filter_t *);static void AddAtmoSettingsVariablesCallbacks(filter_t *);static int AtmoSettingsCallback(vlc_object_t *, char const *, vlc_value_t, vlc_value_t, void *);#if defined(__ATMO_DEBUG__)static void atmo_parse_crop(char *psz_cropconfig, video_format_t fmt_in, video_format_t fmt_render, int &i_visible_width, int &i_visible_height, int &i_x_offset, int &i_y_offset );#endif/* function to shutdown the fade thread which is started on pause*/static void CheckAndStopFadeThread(filter_t *);/* extracts a small RGB (BGR) Image from an YUV image */static void ExtractMiniImage_YUV(filter_sys_t *, picture_t *, uint8_t *);#if defined(__ATMO_DEBUG__)void SaveBitmap(filter_sys_t *p_sys, uint8_t *p_pixels, char *psz_filename);#endif/****************************************************************************** External Prototypes for the AtmoCtrlLib.DLL*****************************************************************************//** if effectmode = emLivePicture then the source could be GDI (Screencapture)* or External - this means another application delivers Pixeldata to AtmoWin* Clientsoftware through AtmoCtrlLib.DLL and the COM Api*/#define lvsGDI 0#define lvsExternal 1/*strings for settings menus and hints*/#define MODULE_DESCRIPTION N_ ( \ "This module allows to control an so called AtmoLight device "\ "connected to your computer.\n"\ "AtmoLight is the homegrown version of what Philips calls AmbiLight.\n"\ "If you need further information feel free to visit us at\n\n"\ "http://www.vdr-wiki.de/wiki/index.php/Atmo-plugin\n "\ "http://www.vdr-wiki.de/wiki/index.php/AtmoWin\n\n"\ "You can find there detailed descriptions on how to build it for yourself "\ "and where to get the required parts.\n" \ "You can also have a look at pictures and some movies showing such a device " \ "in live action.")#if defined( __ATMO_DEBUG__ )# define SAVEFRAMES_TEXT N_("Save Debug Frames")# define SAVEFRAMES_LONGTEXT N_("Write every 128th miniframe to a folder.")# define FRAMEPATH_TEXT N_("Debug Frame Folder")# define FRAMEPATH_LONGTEXT N_("The path where the debugframes " \ "should be saved")#endif#define WIDTH_TEXT N_("Extracted Image Width")#define WIDTH_LONGTEXT N_("The width of the mini image for " \ "further processing (64 is default)")#define HEIGHT_TEXT N_("Extracted Image Height")#define HEIGHT_LONGTEXT N_("The height of the mini image for " \ "further processing (48 is default)")#define PCOLOR_TEXT N_("Color when paused")#define PCOLOR_LONGTEXT N_("Set the color to show if the user " \ "pauses the video. (Have light to get " \ "another beer?)")#define PCOLOR_RED_TEXT N_("Pause-Red")#define PCOLOR_RED_LONGTEXT N_("Red component of the pause color")#define PCOLOR_GREEN_TEXT N_("Pause-Green")#define PCOLOR_GREEN_LONGTEXT N_("Green component of the pause color")#define PCOLOR_BLUE_TEXT N_("Pause-Blue")#define PCOLOR_BLUE_LONGTEXT N_("Blue component of the pause color")#define FADESTEPS_TEXT N_("Pause-Fadesteps")#define FADESTEPS_LONGTEXT N_("Number of steps to change current color " \ "to pause color (each step takes 40ms)")#define ECOLOR_RED_TEXT N_("End-Red")#define ECOLOR_RED_LONGTEXT N_("Red component of the shutdown color")#define ECOLOR_GREEN_TEXT N_("End-Green")#define ECOLOR_GREEN_LONGTEXT N_("Green component of the shutdown color")#define ECOLOR_BLUE_TEXT N_("End-Blue")#define ECOLOR_BLUE_LONGTEXT N_("Blue component of the shutdown color")#define EFADESTEPS_TEXT N_("End-Fadesteps")#define EFADESTEPS_LONGTEXT N_("Number of steps to change current color to " \ "end color for dimming up the light in cinema " \ "style... (each step takes 40ms)")#define USEWHITEADJ_TEXT N_("Use Software White adjust")#define USEWHITEADJ_LONGTEXT N_("Should the buildin driver do a white " \ "adjust or your LED stripes? recommend.")#define WHITE_RED_TEXT N_("White Red")#define WHITE_RED_LONGTEXT N_("Red value of a pure white on your "\ "LED stripes.")#define WHITE_GREEN_TEXT N_("White Green")#define WHITE_GREEN_LONGTEXT N_("Green value of a pure white on your "\ "LED stripes.")#define WHITE_BLUE_TEXT N_("White Blue")#define WHITE_BLUE_LONGTEXT N_("Blue value of a pure white on your "\ "LED stripes.")#define SERIALDEV_TEXT N_("Serial Port/Device")#define SERIALDEV_LONGTEXT N_("Name of the serial port where the AtmoLight "\ "controller is attached to.\n" \ "On Windows usually something like COM1 or " \ "COM2. On Linux /dev/ttyS01 f.e.")#define EDGE_TEXT N_("Edge Weightning")#define EDGE_LONGTEXT N_("Increasing this value will result in color "\ "more depending on the border of the frame.")#define BRIGHTNESS_TEXT N_("Brightness")#define BRIGHTNESS_LONGTEXT N_("Overall brightness of your LED stripes")#define DARKNESS_TEXT N_("Darkness Limit")#define DARKNESS_LONGTEXT N_("Pixels with a saturation lower than this will "\ "be ignored. Should be greater than one for "\ "letterboxed videos.")#define HUEWINSIZE_TEXT N_("Hue windowing")#define HUEWINSIZE_LONGTEXT N_("Used for statistics.")#define SATWINSIZE_TEXT N_("Sat windowing")#define SATWINSIZE_LONGTEXT N_("Used for statistics.")#define MEANLENGTH_TEXT N_("Filter length (ms)")#define MEANLENGTH_LONGTEXT N_("Time it takes until a color is completely "\ "changed. This prevents flickering.")#define MEANTHRESHOLD_TEXT N_("Filter threshold")#define MEANTHRESHOLD_LONGTEXT N_("How much a color has to be changed for an "\ "immediate color change.")#define MEANPERCENTNEW_TEXT N_("Filter Smoothness (in %)")#define MEANPERCENTNEW_LONGTEXT N_("Filter Smoothness")/* FIXME: WTF?!! feepk, July 6 '08 */#define FILTERMODE_TEXT N_("Filter mode")#define FILTERMODE_LONGTEXT N_("kind of filtering which should be use to "\ "calcuate the color output")static const int pi_filtermode_values[] = { (int)afmNoFilter, (int)afmCombined, (int)afmPercent};static const char *const ppsz_filtermode_descriptions[] = { N_("No Filtering"), N_("Combined"), N_("Percent")};#define FRAMEDELAY_TEXT N_("Frame delay")#define FRAMEDELAY_LONGTEXT N_("Helps to get the video output and the light "\ "effects in sync. Values around 20ms should " \ "do the trick.")#define CHANNEL_0_ASSIGN_TEXT N_("Channel summary")#define CHANNEL_1_ASSIGN_TEXT N_("Channel left")#define CHANNEL_2_ASSIGN_TEXT N_("Channel right")#define CHANNEL_3_ASSIGN_TEXT N_("Channel top")#define CHANNEL_4_ASSIGN_TEXT N_("Channel bottom")#define CHANNELASSIGN_LONGTEXT N_("Maps the hardware channel X to logical "\ "channel Y to fix wrong wiring :-)")static const int pi_channel_assignment_values[] = { -1, 0, 1, 2, 3, 4};static const char *const ppsz_channel_assignment_descriptions[] = { N_("disabled"), N_("summary"), N_("left"), N_("right"), N_("top"), N_("bottom")};#define ZONE_0_GRADIENT_TEXT N_("Summary gradient")#define ZONE_1_GRADIENT_TEXT N_("Left gradient")#define ZONE_2_GRADIENT_TEXT N_("Right gradient")#define ZONE_3_GRADIENT_TEXT N_("Top gradient")#define ZONE_4_GRADIENT_TEXT N_("Bottom gradient")#define ZONE_X_GRADIENT_LONG_TEXT N_("Defines a small bitmap with 64x48 "\ "pixels, containing a grayscale gradient")#if defined( WIN32 )# define ATMOWINEXE_TEXT N_("Filename of AtmoWinA.exe")# define ATMOWINEXE_LONGTEXT N_("if you want the AtmoLight control "\ "software to be launched by VLC, enter the "\ "complete path of AtmoWinA.exe here.")# define USEBUILDIN_TEXT N_("Use built-in AtmoLight")# define USEBUILDIN_LONGTEXT N_("VLC will directly use your AtmoLight "\ "hardware without running the external "\ "AtmoWinA.exe Userspace driver.")#endif#define CFG_PREFIX "atmo-"/****************************************************************************** Module descriptor*****************************************************************************/vlc_module_begin();set_description( N_("AtmoLight Filter") );set_help( MODULE_DESCRIPTION );set_shortname( N_( "AtmoLight" ));set_capability( "video filter2", 0 );set_category( CAT_VIDEO );set_subcategory( SUBCAT_VIDEO_VFILTER );#if defined(WIN32)set_section( N_("Choose between the built-in AtmoLight "\ "driver or the external" ), 0 );/* only on win32 exists the option to use the buildin driver or the more flexible external driver application*/add_bool(CFG_PREFIX "usebuildin", true, NULL, USEBUILDIN_TEXT, USEBUILDIN_LONGTEXT, false);add_string(CFG_PREFIX "serialdev", "COM1", NULL, SERIALDEV_TEXT, SERIALDEV_LONGTEXT, false );/* on win32 the executeable external driver application for automatic start if needed*/add_file(CFG_PREFIX "atmowinexe", NULL, NULL, ATMOWINEXE_TEXT, ATMOWINEXE_LONGTEXT, false );#elseset_section( N_("Enter the connection of your AtmoLight hardware" ), 0 );add_string(CFG_PREFIX "serialdev", "/dev/ttyS01", NULL, SERIALDEV_TEXT, SERIALDEV_LONGTEXT, false );#endif/* color which is showed if you want durring pausing your movie ... used for both buildin / external*/set_section( N_("Illuminate the room with this color on pause" ), 0 );add_bool(CFG_PREFIX "usepausecolor", false, NULL, PCOLOR_TEXT, PCOLOR_LONGTEXT, false);add_integer_with_range(CFG_PREFIX "pcolor-red", 0, 0, 255, NULL, PCOLOR_RED_TEXT, PCOLOR_RED_LONGTEXT, false);add_integer_with_range(CFG_PREFIX "pcolor-green", 0, 0, 255, NULL, PCOLOR_GREEN_TEXT, PCOLOR_GREEN_LONGTEXT, false);add_integer_with_range(CFG_PREFIX "pcolor-blue", 192, 0, 255, NULL, PCOLOR_BLUE_TEXT, PCOLOR_BLUE_LONGTEXT, false);add_integer_with_range(CFG_PREFIX "fadesteps", 50, 1, 250, NULL, FADESTEPS_TEXT, FADESTEPS_LONGTEXT, false);/* color which is showed if you finished watching your movie ... used for both buildin / external*/set_section( N_("Illuminate the room with this color on shutdown" ), 0 );add_integer_with_range(CFG_PREFIX "ecolor-red", 192, 0, 255, NULL, ECOLOR_RED_TEXT, ECOLOR_RED_LONGTEXT, false);add_integer_with_range(CFG_PREFIX "ecolor-green", 192, 0, 255, NULL, ECOLOR_GREEN_TEXT, ECOLOR_GREEN_LONGTEXT, false);add_integer_with_range(CFG_PREFIX "ecolor-blue", 192, 0, 255, NULL, ECOLOR_BLUE_TEXT, ECOLOR_BLUE_LONGTEXT, false);add_integer_with_range(CFG_PREFIX "efadesteps", 50, 1, 250, NULL, EFADESTEPS_TEXT, EFADESTEPS_LONGTEXT, false);/* settings only for the buildin driver (if external driver app is used these parameters are ignored.) definition of parameters for the buildin filter ...*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -