/VLC-1.1.0-iOS/modules/video_filter/atmo/atmo.cpp
C++ | 2818 lines | 1796 code | 431 blank | 591 comment | 234 complexity | 7c8c2a02d18db3dcb3edd714a69ab632 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
Large files files are truncated, but you can click here to view the full file
- /*****************************************************************************
- * atmo.cpp : "Atmo Light" video filter
- *****************************************************************************
- * Copyright (C) 2000-2006 the VideoLAN team
- * $Id: a3f5ed95e67ede0a7ca272ed574bf7a6af87b372 $
- *
- * 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
- *****************************************************************************/
- #define __STDC_FORMAT_MACROS 1
- #include <stdlib.h> /* malloc(), free() */
- #include <string.h>
- #include <math.h> /* sin(), cos() */
- #include <assert.h>
- #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 "AtmoClassicConnection.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 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
- #define CLASSIC_ATMO_NUM_ZONES 5
- /*
- 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.")
- #define DRIVER_TEXT N_("Device type")
- #define DRIVER_LONGTEXT N_("Choose your preferred hardware from " \
- "the list, or choose AtmoWin Software " \
- "to delegate processing to the external " \
- "process - with more options")
- static const int pi_device_type_values[] = {
- #if defined( WIN32 )
- 0, /* use AtmoWinA.exe userspace driver */
- #endif
- 1, /* AtmoLight classic */
- 2, /* Quattro AtmoLight */
- 3, /* DMX Device */
- 4, /* MoMoLight device */
- 5 /* fnordlicht */
- };
- static const char *const ppsz_device_type_descriptions[] = {
- #if defined( WIN32 )
- N_("AtmoWin Software"),
- #endif
- N_("Classic AtmoLight"),
- N_("Quattro AtmoLight"),
- N_("DMX"),
- N_("MoMoLight"),
- N_("fnordlicht")
- };
- #define DMX_CHANNELS_TEXT N_("Count of AtmoLight channels")
- #define DMX_CHANNELS_LONGTEXT N_("How many AtmoLight channels, should be " \
- "emulated with that DMX device")
- #define DMX_CHBASE_TEXT N_("DMX address for each channel")
- #define DMX_CHBASE_LONGTEXT N_("Define here the DMX base address for each " \
- "channel use , or ; to separate the values")
- #define MOMO_CHANNELS_TEXT N_("Count of channels")
- #define MOMO_CHANNELS_LONGTEXT N_("Depending on your MoMoLight hardware " \
- "choose 3 or 4 channels")
- #define FNORDLICHT_AMOUNT_TEXT N_("Count of fnordlicht's")
- #define FNORDLICHT_AMOUNT_LONGTEXT N_("Depending on the amount your " \
- "fnordlicht hardware " \
- "choose 1 to 4 channels")
- #if defined( WIN32 )
- # define DEFAULT_DEVICE 0
- #else
- # define DEFAULT_DEVICE 1
- #endif
- #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 SHOW_DOTS_TEXT N_("Mark analyzed pixels")
- #define SHOW_DOTS_LONGTEXT N_("makes the sample grid visible on screen as "\
- "white pixels")
- #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 ZONE_TOP_TEXT N_("Number of zones on top")
- #define ZONE_TOP_LONGTEXT N_("Number of zones on the top of the screen")
- #define ZONE_BOTTOM_TEXT N_("Number of zones on bottom")
- #define ZONE_BOTTOM_LONGTEXT N_("Number of zones on the bottom of the screen")
- #define ZONE_LR_TEXT N_("Zones on left / right side")
- #define ZONE_LR_LONGTEXT N_("left and right side having allways the " \
- "same number of zones")
- #define ZONE_SUMMARY_TEXT N_("Calculate a average zone")
- #define ZONE_SUMMARY_LONGTEXT N_("it contains the average of all pixels " \
- "in the sample image (only useful for " \
- "single channel AtmoLight)")
- #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")
- #define FILTERMODE_TEXT N_("Output Color filter mode")
- #define FILTERMODE_LONGTEXT N_("defines the how the output color should " \
- "be calculated based on previous color")
- 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 (ms)")
- #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 0: summary")
- #define CHANNEL_1_ASSIGN_TEXT N_("Channel 1: left")
- #define CHANNEL_2_ASSIGN_TEXT N_("Channel 2: right")
- #define CHANNEL_3_ASSIGN_TEXT N_("Channel 3: top")
- #define CHANNEL_4_ASSIGN_TEXT N_("Channel 4: bottom")
- #define CHANNELASSIGN_LONGTEXT N_("Maps the hardware channel X to logical "\
- "zone Y to fix wrong wiring :-)")
- static const int pi_zone_assignment_values[] = {
- -1,
- 4,
- 3,
- 1,
- 0,
- 2
- };
- static const char *const ppsz_zone_assignment_descriptions[] = {
- N_("disabled"),
- N_("Zone 4:summary"),
- N_("Zone 3:left"),
- N_("Zone 1:right"),
- N_("Zone 0:top"),
- N_("Zone 2:bottom")
- };
- #define CHANNELS_ASSIGN_TEXT N_("Channel / Zone Assignment")
- #define CHANNELS_ASSIGN_LONGTEXT N_("for devices with more than five " \
- "channels / zones write down here for each channel " \
- "the zone number to show and separate the values with " \
- ", or ; and use -1 to not use some channels. For the " \
- "classic AtmoLight the sequence 4,3,1,0,2 would set the " \
- "default channel/zone mapping. " \
- "Having only two zones on top, and one zone on left and " \
- "right and no summary zone the mapping for classic " \
- "AtmoLight would be -1,3,2,1,0")
- #define ZONE_0_GRADIENT_TEXT N_("Zone 0: Top gradient")
- #define ZONE_1_GRADIENT_TEXT N_("Zone 1: Right gradient")
- #define ZONE_2_GRADIENT_TEXT N_("Zone 2: Bottom gradient")
- #define ZONE_3_GRADIENT_TEXT N_("Zone 3: Left gradient")
- #define ZONE_4_GRADIENT_TEXT N_("Zone 4: Summary gradient")
- #define ZONE_X_GRADIENT_LONG_TEXT N_("Defines a small bitmap with 64x48 "\
- "pixels, containing a grayscale gradient")
- #define GRADIENT_PATH_TEXT N_("Gradient bitmap searchpath")
- #define GRADIENT_PATH_LONGTEXT N_("Now preferred option to assign gradient "\
- "bitmaps, put them as zone_0.bmp, zone_1.bmp etc. into one folder and "\
- "set the foldername here")
- #if defined( WIN32 )
- # define ATMOWINEXE_TEXT N_("Filename of AtmoWin*.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.")
- #endif
- #define CFG_PREFIX "atmo-"
- /*****************************************************************************
- * Module descriptor
- *****************************************************************************/
- vlc_module_begin ()
- set_description( N_("AtmoLight Filter") )
- set_help( MODULE_DESCRIPTION )
- set_shortname( N_( "AtmoLight" ))
- set_category( CAT_VIDEO )
- set_subcategory( SUBCAT_VIDEO_VFILTER )
- set_capability( "video filter2", 0 )
- set_section( N_("Choose Devicetype and Connection" ), 0 )
- add_integer( CFG_PREFIX "device", DEFAULT_DEVICE, NULL,
- DRIVER_TEXT, DRIVER_LONGTEXT, false )
- change_integer_list( pi_device_type_values,
- ppsz_device_type_descriptions, 0 )
- #if defined(WIN32)
- 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 )
- #else
- add_string(CFG_PREFIX "serialdev", "/dev/ttyUSB0", 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)
- set_section( N_("DMX options" ), 0 )
- add_integer_with_range(CFG_PREFIX "dmx-channels", 5, 1, 64, NULL,
- DMX_CHANNELS_TEXT, DMX_CHANNELS_LONGTEXT, false)
- add_string(CFG_PREFIX "dmx-chbase", "0,3,6,9,12", NULL,
- DMX_CHBASE_TEXT, DMX_CHBASE_LONGTEXT, false )
- set_section( N_("MoMoLight options" ), 0 )
- add_integer_with_range(CFG_PREFIX "momo-channels", 3, 3, 4, NULL,
- MOMO_CHANNELS_TEXT, MOMO_CHANNELS_LONGTEXT, false)
- /* 2,2,4 means 2 is the default value, 1 minimum amount,
- 4 maximum amount
- */
- set_section( N_("fnordlicht options" ), 0 )
- add_integer_with_range(CFG_PREFIX "fnordlicht-amount", 2, 1, 4, NULL,
- FNORDLICHT_AMOUNT_TEXT,
- FNORDLICHT_AMOUNT_LONGTEXT, false)
- /*
- instead of redefining the original AtmoLight zones with gradient
- bitmaps, we can now define the layout of the zones useing these
- parameters - the function with the gradient bitmaps would still
- work (but for most cases its no longer required)
- short description whats this means - f.e. the classic atmo would
- have this layout
- zones-top = 1 - zone 0
- zones-lr = 1 - zone 1 und zone 3
- zones-bottom = 1 - zone 2
- zone-summary = true - zone 4
- Z0
- ,------------,
- | |
- Z3| Z4 | Z1
- |____________|
- Z2
- the zone numbers will be counted clockwise starting at top / left
- if you want to split the light at the top, without having a bottom zone
- (which is my private config)
- zones-top = 2 - zone 0, zone 1
- zones-lr = 1 - zone 2 und zone 3
- zones-bottom = 0
- zone-summary = false
- Z0 Z1
- ,------------,
- | |
- Z3| | Z2
- |____________|
- */
- set_section( N_("Zone Layout for the build-in Atmo" ), 0 )
- add_integer_with_range(CFG_PREFIX "zones-top", 1, 0, 16, NULL,
- ZONE_TOP_TEXT, ZONE_TOP_LONGTEXT, false)
- add_integer_with_range(CFG_PREFIX "zones-bottom", 1, 0, 16, NULL,
- ZONE_BOTTOM_TEXT, ZONE_BOTTOM_LONGTEXT, false)
- add_integer_with_range(CFG_PREFIX "zones-lr", 1, 0, 16, NULL,
- ZONE_LR_TEXT, ZONE_LR_LONGTEXT, false)
- add_bool(CFG_PREFIX "zone-summary", false, NULL,
- ZONE_SUMMARY_TEXT, ZONE_SUMMARY_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 ...
- */
- set_section( N_("Settings for the built-in Live Video Processor only" ), 0 )
- add_integer_with_range(CFG_PREFIX "edgeweightning", 3, 1, 30, NULL,
- EDGE_TEXT, EDGE_LONGTEXT, false)
- add_integer_with_range(CFG_PREFIX "brightness", 100, 50, 300, NULL,
- BRIGHTNESS_TEXT, BRIGHTNESS_LONGTEXT, false)
- add_integer_with_range(CFG_PREFIX "darknesslimit", 3, 0, 10, NULL,
- DARKNESS_TEXT, DARKNESS_LONGTEXT, false)
- add_integer_with_range(CFG_PREFIX "huewinsize", 3, 0, 5, NULL,
- HUEWINSIZE_TEXT, HUEWINSIZE_LONGTEXT, false)
- add_integer_with_range(CFG_PREFIX "satwinsize", 3, 0, 5, NULL,
- SATWINSIZE_TEXT, SATWINSIZE_LONGTEXT, false)
- add_integer(CFG_PREFIX "filtermode", (int)afmCombined, NULL,
- FILTERMODE_TEXT, FILTERMODE_LONGTEXT, false )
- change_integer_list(pi_filtermode_values, ppsz_filtermode_descriptions, NULL )
- add_integer_with_range(CFG_PREFIX "meanlength", 300, 300, 5000, NULL,
- MEANLENGTH_TEXT, MEANLENGTH_LONGTEXT, false)
- add_integer_with_range(CFG_PREFIX "meanthreshold", 40, 1, 100, NULL,
- MEANTHRESHOLD_TEXT, MEANTHRESHOLD_LONGTEXT, false)
- add_integer_with_range(CFG_PREFIX "percentnew", 50, 1, 100, NULL,
- MEANPERCENTNEW_TEXT, MEANPERCENTNEW_LONGTEXT, false)
- add_integer_with_range(CFG_PREFIX "framedelay", 18, 0, 200, NULL,
- FRAMEDELAY_TEXT, FRAMEDELAY_LONGTEXT, false)
- /*
- output channel reordering
- */
- set_section( N_("Change channel assignment (fixes wrong wiring)" ), 0 )
- add_integer( CFG_PREFIX "channel_0", 4, NULL,
- CHANNEL_0_ASSIGN_TEXT, CHANNELASSIGN_LONGTEXT, false )
- change_integer_list( pi_zone_assignment_values,
- ppsz_zone_assignment_descriptions, 0 )
- add_integer( CFG_PREFIX "channel_1", 3, NULL,
- CHANNEL_1_ASSIGN_TEXT, CHANNELASSIGN_LONGTEXT, false )
- change_integer_list( pi_zone_assignment_values,
- ppsz_zone_assignment_descriptions, 0 )
- add_integer( CFG_PREFIX "channel_2", 1, NULL,
- CHANNEL_2_ASSIGN_TEXT, CHANNELASSIGN_LONGTEXT, false )
- change_integer_list( pi_zone_assignment_values,
- ppsz_zone_assignment_descriptions, 0 )
- add_integer( CFG_PREFIX "channel_3", 0, NULL,
- CHANNEL_3_ASSIGN_TEXT, CHANNELASSIGN_LONGTEXT, false )
- change_integer_list( pi_zone_assignment_values,
- ppsz_zone_assignment_descriptions, 0 )
- add_integer( CFG_PREFIX "channel_4", 2, NULL,
- CHANNEL_4_ASSIGN_TEXT, CHANNELASSIGN_LONGTEXT, false )
- change_integer_list( pi_zone_assignment_values,
- ppsz_zone_assignment_descriptions, 0 )
- add_string(CFG_PREFIX "channels", NULL, NULL,
- CHANNELS_ASSIGN_TEXT, CHANNELS_ASSIGN_LONGTEXT, false )
- /*
- LED color white calibration
- */
- set_section( N_("Adjust the white light to your LED stripes" ), 0 )
- add_bool(CFG_PREFIX "whiteadj", true, NULL,
- USEWHITEADJ_TEXT, USEWHITEADJ_LONGTEXT, false)
- add_integer_with_range(CFG_PREFIX "white-red", 255, 0, 255, NULL,
- WHITE_RED_TEXT, WHITE_RED_LONGTEXT, false)
- add_integer_with_range(CFG_PREFIX "white-green", 255, 0, 255, NULL,
- WHITE_GREEN_TEXT, WHITE_GREEN_LONGTEXT, false)
- add_integer_with_range(CFG_PREFIX "white-blue", 255, 0, 255, NULL,
- WHITE_BLUE_TEXT, WHITE_BLUE_LONGTEXT, false)
- /* end of definition of parameter for the buildin filter ... part 1 */
- /*
- only for buildin (external has own definition) per default the calucation
- used linear gradients for assigning a priority to the pixel - depending
- how near they are to the border ...for changing this you can create 64x48
- Pixel BMP files - which contain your own grayscale... (you can produce funny
- effects with this...) the images MUST not compressed, should have 24-bit per
- pixel, or a simple 256 color grayscale palette
- */
- set_section( N_("Change gradients" ), 0 )
- add_file(CFG_PREFIX "gradient_zone_0", NULL, NULL,
- ZONE_0_GRADIENT_TEXT, ZONE_X_GRADIENT_LONG_TEXT, true )
- add_file(CFG_PREFIX "gradient_zone_1", NULL, NULL,
- ZONE_1_GRADIENT_TEXT, ZONE_X_GRADIENT_LONG_TEXT, true )
- add_file(CFG_PREFIX "gradient_zone_2", NULL, NULL,
- ZONE_2_GRADIENT_TEXT, ZONE_X_GRADIENT_LONG_TEXT, true )
- add_file(CFG_PREFIX "gradient_zone_3", NULL, NULL,
- ZONE_3_GRADIENT_TEXT, ZONE_X_GRADIENT_LONG_TEXT, true )
- add_file(CFG_PREFIX "gradient_zone_4", NULL, NULL,
- ZONE_4_GRADIENT_TEXT, ZONE_X_GRADIENT_LONG_TEXT, true )
- add_directory(CFG_PREFIX "gradient_path", NULL, NULL,
- GRADIENT_PATH_TEXT, GRADIENT_PATH_LONGTEXT, false )
- #if defined(__ATMO_DEBUG__)
- add_bool(CFG_PREFIX "saveframes", false, NULL,
- SAVEFRAMES_TEXT, SAVEFRAMES_LONGTEXT, false)
- add_string(CFG_PREFIX "framepath", "", NULL,
- FRAMEPATH_TEXT, FRAMEPATH_LONGTEXT, false )
- #endif
- /*
- may be later if computers gets more power ;-) than now we increase
- the samplesize from which we do the stats for output color calculation
- */
- add_integer_with_range(CFG_PREFIX "width", 64, 64, 512, NULL,
- WIDTH_TEXT, WIDTH_LONGTEXT, true)
- add_integer_with_range(CFG_PREFIX "height", 48, 48, 384, NULL,
- HEIGHT_TEXT, HEIGHT_LONGTEXT, true)
- add_bool(CFG_PREFIX "showdots", false, NULL,
- SHOW_DOTS_TEXT, SHOW_DOTS_LONGTEXT, false)
- add_shortcut( "atmo" )
- set_callbacks( CreateFilter, DestroyFilter )
- vlc_module_end ()
- static const char *const ppsz_filter_options[] = {
- "device",
- "serialdev",
- "edgeweightning",
- "brightness",
- "darknesslimit",
- "huewinsize",
- "satwinsize",
- "filtermode",
- "meanlength",
- "meanthreshold",
- "percentnew",
- "framedelay",
- "zones-top",
- "zones-bottom",
- "zones-lr",
- "zone-summary",
- "channel_0",
- "channel_1",
- "channel_2",
- "channel_3",
- "channel_4",
- "channels",
- "whiteadj",
- "white-red",
- "white-green",
- "white-blue",
- "usepausecolor",
- "pcolor-red",
- "pcolor-green",
- "pcolor-blue",
- "fadesteps",
- "ecolor-red",
- "ecolor-green",
- "ecolor-blue",
- "efadesteps",
- "dmx-channels",
- "dmx-chbase",
- "momo-channels",
- "fnordlicht-amount",
- #if defined(WIN32 )
- "atmowinexe",
- #endif
- #if defined(__ATMO_DEBUG__)
- "saveframes" ,
- "framepath",
- #endif
- "width",
- "height",
- "showdots",
- "gradient_zone_0",
- "gradient_zone_1",
- "gradient_zone_2",
- "gradient_zone_3",
- "gradient_zone_4",
- "gradient_path",
- NULL
- };
- /*****************************************************************************
- * fadethread_t: Color Fading Thread
- *****************************************************************************
- * changes slowly the color of the output if videostream gets paused...
- *****************************************************************************
- */
- typedef struct
- {
- VLC_COMMON_MEMBERS
- filter_t *p_filter;
- /* tell the thread which color should be the target of fading */
- uint8_t ui_red;
- uint8_t ui_green;
- uint8_t ui_blue;
- /* how many steps should happen until this */
- int i_steps;
- } fadethread_t;
- static void *FadeToColorThread(vlc_object_t *);
- /*****************************************************************************
- * filter_sys_t: AtmoLight filter method descriptor
- *****************************************************************************
- * It describes the AtmoLight specific properties of an video filter.
- *****************************************************************************/
- struct filter_sys_t
- {
- /*
- special for the access of the p_fadethread member all other members
- need no special protection so far!
- */
- vlc_mutex_t filter_lock;
- bool b_enabled;
- int32_t i_AtmoOldEffect;
- bool b_pause_live;
- bool b_show_dots;
- int32_t i_device_type;
- int32_t i_atmo_width;
- int32_t i_atmo_height;
- /* used to disable fadeout if less than 50 frames are processed
- used to avoid long time waiting when switch quickly between
- deinterlaceing modes, where the output filter chains is rebuild
- on each switch
- */
- int32_t i_frames_processed;
- #if defined(__ATMO_DEBUG__)
- bool b_saveframes;
- uint32_t ui_frame_counter;
- char sz_framepath[MAX_PATH];
- #endif
- /* light color durring movie pause ... */
- bool b_usepausecolor;
- uint8_t ui_pausecolor_red;
- uint8_t ui_pausecolor_green;
- uint8_t ui_pausecolor_blue;
- int i_fadesteps;
- /* light color on movie finish ... */
- uint8_t ui_endcolor_red;
- uint8_t ui_endcolor_green;
- uint8_t ui_endcolor_blue;
- int i_endfadesteps;
- fadethread_t *p_fadethread;
- /* Variables for buildin driver only... */
- /* is only present and initialized if the internal driver is used*/
- CAtmoConfig *p_atmo_config;
- /* storage for temporal settings "volatile" */
- CAtmoDynData *p_atmo_dyndata;
- /* initialized for buildin driver with AtmoCreateTransferBuffers */
- BITMAPINFOHEADER mini_image_format;
- /* is only use buildin driver! */
- uint8_t *p_atmo_transfer_buffer;
- /* end buildin driver */
- /*
- contains the real output size of the video calculated on
- change event of the variable "crop" from vout
- */
- int32_t i_crop_x_offset;
- int32_t i_crop_y_offset;
- int32_t i_crop_width;
- int32_t i_crop_height;
- void (*pf_extract_mini_image) (filter_sys_t *p_sys,
- picture_t *p_inpic,
- uint8_t *p_transfer_dest);
- #if defined( WIN32 )
- /* External Library as wrapper arround COM Stuff */
- HINSTANCE h_AtmoCtrl;
- int32_t (*pf_ctrl_atmo_initialize) (void);
- void (*pf_ctrl_atmo_finalize) (int32_t what);
- int32_t (*pf_ctrl_atmo_switch_effect) (int32_t);
- int32_t (*pf_ctrl_atmo_set_live_source) (int32_t);
- void (*pf_ctrl_atmo_create_transfer_buffers) (int32_t, int32_t,
- int32_t , int32_t);
- uint8_t* (*pf_ctrl_atmo_lock_transfer_buffer) (void);
- void (*pf_ctrl_atmo_send_pixel_data) (void);
- void (*pf_ctrl_atmo_get_image_size)(int32_t *,int32_t *);
- #endif
- };
- /*
- initialize previously configured Atmo Light environment
- - if internal is enabled try to access the device on the serial port
- - if not internal is enabled and we are on win32 try to initialize
- the previously loaded DLL ...
- Return Values may be: -1 (failed for some reason - filter will be disabled)
- 1 Ok. lets rock
- */
- static int32_t AtmoInitialize(filter_t *p_filter, bool b_for_thread)
- {
- filter_sys_t *p_sys = p_filter->p_sys;
- if(p_sys->p_atmo_config)
- {
- if(b_for_thread == false)
- {
- /* open com port */
- /* setup Output Threads ... */
- msg_Dbg( p_filter, "open atmo device...");
- if(CAtmoTools::RecreateConnection(p_sys->p_atmo_dyndata)
- == ATMO_TRUE)
- {
- return 1;
- } else {
- msg_Err( p_filter,"failed to open atmo device, "\
- "some other software/driver may use it?");
- }
- }
- #if defined(WIN32)
- } else if(p_sys->pf_ctrl_atmo_initialize)
- {
- /* on win32 with active ctrl dll */
- return p_sys->pf_ctrl_atmo_initialize();
- #endif
- }
- return -1;
- }
- /*
- prepare the shutdown of the effect threads,
- for build in filter - close the serialport after finishing the threads...
- cleanup possible loaded DLL...
- */
- static void AtmoFinalize(filter_t *p_filter, int32_t what)
- {
- filter_sys_t *p_sys = p_filter->p_sys;
- if(p_sys->p_atmo_config)
- {
- if(what == 1)
- {
- CAtmoDynData *p_atmo_dyndata = p_sys->p_atmo_dyndata;
- if(p_atmo_dyndata)
- {
- p_atmo_dyndata->LockCriticalSection();
- CAtmoInput *p_input = p_atmo_dyndata->getLiveInput();
- p_atmo_dyndata->setLiveInput( NULL );
- if(p_input != NULL)
- {
- p_input->Terminate();
- delete p_input;
- msg_Dbg( p_filter, "input thread died peacefully");
- }
- CThread *p_effect_thread = p_atmo_dyndata->getEffectThread();
- p_atmo_dyndata->setEffectThread(NULL);
- if(p_effect_thread != NULL)
- {
- /*
- forced the thread to die...
- and wait for termination of the thread
- */
- p_effect_thread->Terminate();
- delete p_effect_thread;
- msg_Dbg( p_filter, "effect thread died peacefully");
- }
- CAtmoPacketQueue *p_queue =
- p_atmo_dyndata->getLivePacketQueue();
- p_atmo_dyndata->setLivePacketQueue( NULL );
- if(p_queue != NULL)
- {
- delete p_queue;
- msg_Dbg( p_filter, "packetqueue removed");
- }
- /*
- close serial port if it is open (all OS specific is inside
- CAtmoSerialConnection implemented / defined)
- */
- CAtmoConnection *p_atmo_connection =
- p_atmo_dyndata->getAtmoConnection();
- p_atmo_dyndata->setAtmoConnection(NULL);
- if(p_atmo_connection) {
- p_atmo_connection->CloseConnection();
- delete p_atmo_connection;
- }
- p_atmo_dyndata->UnLockCriticalSection();
- }
- }
- #if defined(WIN32)
- } else if(p_sys->pf_ctrl_atmo_finalize)
- {
- /* on win32 with active ctrl dll */
- p_sys->pf_ctrl_atmo_finalize(what);
- #endif
- }
- }
- /*
- switch the current light effect to LiveView
- */
- static int32_t AtmoSwitchEffect(filter_t *p_filter, int32_t newMode)
- {
- filter_sys_t *p_sys = p_filter->p_sys;
- msg_Dbg( p_filter, "AtmoSwitchEffect %d", newMode );
- if(p_sys->p_atmo_config)
- {
- return CAtmoTools::SwitchEffect(p_sys->p_atmo_dyndata, emLivePicture);
- #if defined(WIN32)
- } else if(p_sys->pf_ctrl_atmo_switch_effect)
- {
- /* on win32 with active ctrl dll */
- return p_sys->pf_ctrl_atmo_switch_effect( newMode );
- #endif
- }
- return emDisabled;
- }
- /*
- set the current live picture source, does only something on win32,
- with the external libraries - if the buildin effects are used nothing
- happens...
- */
- static int32_t AtmoSetLiveSource(filter_t *p_filter, int32_t newSource)
- {
- filter_sys_t *p_sys = p_filter->p_sys;
- msg_Dbg( p_filter, "AtmoSetLiveSource %d", newSource );
- if(p_sys->p_atmo_config)
- {
- /*
- buildin driver
- doesnt know different sources so this
- function call would just do nothing special
- in this case
- */
- #if defined(WIN32)
- } else if(p_sys->pf_ctrl_atmo_set_live_source)
- {
- /* on win32 with active ctrl dll */
- return p_sys->pf_ctrl_atmo_set_live_source(newSource);
- #endif
- }
- return lvsGDI;
- }
- /*
- setup the pixel transferbuffers which is used to transfer pixeldata from
- the filter to the effect thread, and possible accross the process
- boundaries on win32, with the external DLL
- */
- static void AtmoCreateTransferBuffers(filter_t *p_filter,
- int32_t FourCC,
- int32_t bytePerPixel,
- int32_t width,
- int32_t height)
- {
- filter_sys_t *p_sys = p_filter->p_sys;
- if(p_sys->p_atmo_config)
- {
- /*
- we need a buffer where the image is stored (only for transfer
- to the processing thread)
- */
- free( p_sys->p_atmo_transfer_buffer );
- p_sys->p_atmo_transfer_buffer = (uint8_t *)malloc(bytePerPixel *
- width * height);
- memset(&p_sys->mini_image_format,0,sizeof(BITMAPINFOHEADER));
- p_sys->mini_image_format.biSize = sizeof(BITMAPINFOHEADER);
- p_sys->mini_image_format.biWidth = width;
- p_sys->mini_image_format.biHeight = height;
- p_sys->mini_image_format.biBitCount = bytePerPixel*8;
- p_sys->mini_image_format.biCompression = FourCC;
- #if defined(WIN32)
- } else if(p_sys->pf_ctrl_atmo_create_transfer_buffers)
- {
- /* on win32 with active ctrl dll */
- p_sys->pf_ctrl_atmo_create_transfer_buffers(FourCC,
- bytePerPixel,
- width,
- height);
- #endif
- }
- }
- /*
- acquire the transfer buffer pointer the buildin version only
- returns the pointer to the allocated buffer ... the
- external version on win32 has to do some COM stuff to lock the
- Variant Byte array which is behind the buffer
- */
- static uint8_t* AtmoLockTransferBuffer(filter_t *p_filter)
- {
- filter_sys_t *p_sys = p_filter->p_sys;
- if(p_sys->p_atmo_config)
- {
- return p_sys->p_atmo_transfer_buffer;
- #if defined(WIN32)
- } else if(p_sys->pf_ctrl_atmo_lock_transfer_buffer)
- {
- /* on win32 with active ctrl dll */
- return p_sys->pf_ctrl_atmo_lock_transfer_buffer();
- #endif
- }
- return NULL;
- }
- /*
- send the content of current pixel buffer got with AtmoLockTransferBuffer
- to the processing threads
- - build in version - will forward the data to AtmoExternalCaptureInput Thread
- - win32 external - will do the same, but across the process boundaries via
- COM to the AtmoWinA.exe Process
- */
- static void AtmoSendPixelData(filter_t *p_filter)
- {
- filter_sys_t *p_sys = p_filter->p_sys;
- if(p_sys->p_atmo_config && p_sys->p_atmo_transfer_buffer)
- {
- CAtmoDynData *p_atmo_dyndata = p_sys->p_atmo_dyndata;
- if(p_atmo_dyndata &&
- (p_atmo_dyndata->getLivePictureSource() == lpsExtern))
- {
- /*
- the cast will go Ok because we are inside videolan there is only
- this kind of effect thread implemented!
- */
- CAtmoExternalCaptureInput *p_atmo_external_capture_input_thread =
- (CAtmoExternalCaptureInput *)p_atmo_dyndata->getLiveInput();
- if(p_atmo_external_capture_input_thread)
- {
- /*
- the same as above inside videolan only this single kind of
- input exists so we can cast without further tests!
- this call will do a 1:1 copy of this buffer, and wakeup
- the thread from normal sleeping
- */
- p_atmo_external_capture_input_thread->
- DeliverNewSourceDataPaket(&p_sys->mini_image_format,
- p_sys->p_atmo_transfer_buffer);
- }
- }
- #if defined(WIN32)
- } else if(p_sys->pf_ctrl_atmo_send_pixel_data)
- {
- /* on win32 with active ctrl dll */
- p_sys->pf_ctrl_atmo_send_pixel_data();
- #endif
- } else
- {
- msg_Warn( p_filter, "AtmoSendPixelData no method");
- }
- }
- /*
- Shutdown AtmoLight finally - is call from DestroyFilter
- does the cleanup restores the effectmode on the external Software
- (only win32) and possible setup the final light ...
- */
- static void Atmo_Shutdown(filter_t *p_filter)
- {
- filter_sys_t *p_sys = p_filter->p_sys;
- if(p_sys->b_enabled == true)
- {
- msg_Dbg( p_filter, "shut down atmo!");
- /*
- if there is a still running show pause color thread kill him!
- */
- CheckAndStopFadeThread(p_filter);
- // perpare spawn fadeing thread
- vlc_mutex_lock( &p_sys->filter_lock );
- /*
- fade to end color (in case of external AtmoWin Software
- assume that the static color will equal to this
- one to get a soft change and no flash!
- */
- p_sys->b_pause_live = true;
- p_sys->p_fadethread = (fadethread_t *)vlc_object_create( p_filter,
- sizeof(fadethread_t) );
- p_sys->p_fadethread->p_filter = p_filter;
- p_sys->p_fadethread->ui_red = p_sys->ui_endcolor_red;
- p_sys->p_fadethread->ui_green = p_sys->ui_endcolor_green;
- p_sys->p_fadethread->ui_blue = p_sys->ui_endcolor_blue;
- if(p_sys->i_frames_processed < 50)
- p_sys->p_fadethread->i_steps = 1;
- else
- p_sys->p_fadethread->i_steps = p_sys->i_endfadesteps;
- if( vlc_thread_create( p_sys->p_fadethread,
- "AtmoLight fadeing",
- FadeToColorThread,
- VLC_THREAD_PRIORITY_LOW ) )
- {
- msg_Err( p_filter, "cannot create FadeToColorThread" );
- vlc_object_release( p_sys->p_fadethread );
- p_sys->p_fadethread = NULL;
- vlc_mutex_unlock( &p_sys->filter_lock );
- } else {
- vlc_mutex_unlock( &p_sys->filter_lock );
- /* wait for the thread... */
- vlc_thread_join(p_sys->p_fadethread);
- vlc_object_release(p_sys->p_fadethread);
- p_sys->p_fadethread = NULL;
- }
- /*
- the following happens only useing the
- external AtmoWin Device Software
- */
- if( !p_sys->p_atmo_config )
- {
- if(p_sys->i_AtmoOldEffect != emLivePicture)
- AtmoSwitchEffect( p_filter, p_sys->i_AtmoOldEffect);
- else
- AtmoSetLiveSource( p_filter, lvsGDI );
- }
- /* close device connection etc. */
- AtmoFinalize(p_filter, 1);
- /* disable filter method .. */
- p_sys->b_enabled = false;
- }
- }
- /*
- depending on mode setup imagesize to 64x48(classic), or defined
- resolution of external atmowin.exe on windows
- */
- static void Atmo_SetupImageSize(filter_t *p_filter)
- {
- filter_sys_t *p_sys = p_filter->p_sys;
- /*
- size of extracted image by default 64x48 (other imagesizes are
- currently ignored by AtmoWin)
- */
- p_sys->i_atmo_width = var_CreateGetIntegerCommand( p_filter,
- CFG_PREFIX "width");
- p_sys->i_atmo_height = var_CreateGetIntegerCommand( p_filter,
- CFG_PREFIX "height");
- if(p_sys->p_atmo_config)
- {
- #if defined(WIN32)
- } else if(p_sys->pf_ctrl_atmo_get_image_size)
- {
- /* on win32 with active ctrl dll */
- p_sys->pf_ctrl_atmo_get_image_size( &p_sys->i_atmo_width,
- &p_sys->i_atmo_height );
- #endif
- }
- msg_Dbg(p_filter,"sample image size %d * %d pixels", p_sys->i_atmo_width,
- p_sys->i_atmo_height);
- }
- /*
- initialize the zone and channel mapping for the buildin atmolight adapter
- */
- static void Atmo_SetupBuildZones(filter_t *p_filter)
- {
- filter_sys_t *p_sys = p_filter->p_sys;
- p_sys->p_atmo_dyndata->LockCriticalSection();
- CAtmoConfig *p_atmo_config = p_sys->p_atmo_config;
- CAtmoChannelAssignment *p_channel_assignment =
- p_atmo_config->getChannelAssignment(0);
- // channel 0 - zone 4
- p_channel_assignment->setZoneIndex( 0, var_CreateGetIntegerCommand(
- p_filter, CFG_PREFIX "channel_0")
- );
- // channel 1 - zone 3
- p_channel_assignment->setZoneIndex( 1, var_CreateGetIntegerCommand(
- p_filter, CFG_PREFIX "channel_1")
- );
- // channel 2 - zone 1
- p_channel_assignment->setZoneIndex( 2, var_CreateGetIntegerCommand(
- p_filter, CFG_PREFIX "channel_2")
- );
- // channel 3 - zone 0
- p_channel_assignment->setZoneIndex( 3, var_CreateGetIntegerCommand(
- p_filter, CFG_PREFIX "channel_3")
- );
- // channel 4 - zone 2
- p_channel_assignment->setZoneIndex( 4, var_CreateGetIntegerCommand(
- p_filter, CFG_PREFIX "channel_4")
- );
- char *psz_channels = var_CreateGetStringCommand(
- p_filter,
- CFG_PREFIX "channels"
- );
- if( psz_channels && strlen(psz_channels) > 0 )
- {
- msg_Dbg( p_filter, "deal with new zone mapping %s", psz_channels );
- int channel = 0;
- char *psz_temp = psz_channels;
- char *psz_start = psz_temp;
- while( *psz_temp )
- {
- if(*psz_temp == ',' || *psz_temp == ';')
- {
- *psz_temp = 0;
- if(*psz_start)
- {
- int zone = atoi( psz_start );
- if( zone < -1 ||
- zone >= p_channel_assignment->getSize()) {
- msg_Warn( p_filter, "Zone %d out of range -1..%d",
- zone, p_channel_assignment->getSize()-1 );
- } else {
- p_channel_assignment->setZoneIndex( channel, zone );
- channel++;
- }
- }
- psz_start = psz_temp;
- psz_start++;
- }
- psz_temp++;
- }
- /*
- process the rest of the string
- */
- if( *psz_start && !*psz_temp )
- {
- int zone = atoi( psz_start );
- if( zone < -1 ||
- zone >= p_channel_assignment->getSize()) {
- msg_Warn( p_filter, "Zone %d out of range -1..%d",
- zone, p_channel_assignment->getSize()-1 );
- } else {
- p_channel_assignment->setZoneIndex( channel, zone );
- }
- }
- }
- free( psz_channels );
- for(int i=0;i< p_channel_assignment->getSize() ;i++)
- msg_Info( p_filter, "map zone %d to hardware channel %d",
- p_channel_assignment->getZoneIndex( i ),
- i
- );
- p_sys->p_atmo_dyndata->getAtmoConnection()
- ->SetChannelAssignment( p_channel_assignment );
- /*
- calculate the default gradients for each zone!
- depending on the zone layout set before, this now
- supports also multiple gradients on each side
- (older versions could do this only with external
- gradient bitmaps)
- */
- p_sys->p_atmo_dyndata->CalculateDefaultZones();
- /*
- first try to load the old style defined gradient bitmaps
- this could only be done for the first five zones
- - should be deprecated -
- */
- CAtmoZoneDefinition *p_zone;
- char psz_gradient_var_name[30];
- char *psz_gradient_file;
- for(int i=0;i<CLASSIC_ATMO_NUM_ZONES;i++)
- {
- sprintf(psz_gradient_var_name, CFG_PREFIX "gradient_zone_%d", i);
- psz_gradient_file = var_CreateGetStringCommand(
- p_filter,
- psz_gradient_var_name
- );
- if(psz_gradient_file && strlen(psz_gradient_file)>0)
- {
- msg_Dbg( p_filter, "loading gradientfile %s for "\
- "zone %d", psz_gradient_file, i);
- p_zone = p_atmo_config->getZoneDefinition(i);
- if( p_zone )
- {
- int i_res = p_zone->LoadGradientFromBitmap(psz_gradient_file);
- if(i_res != ATMO_LOAD_GRADIENT_OK)
- {
- msg_Err( p_filter,"failed to load gradient '%s' with "\
- "error %d",psz_gradient_file,i_res);
- }
- }
- }
- free( psz_gradient_file );
- }
- /*
- the new approach try to load a gradient bitmap for each zone
- from a previously defined folder containing
- zone_0.bmp
- zone_1.bmp
- zone_2.bmp etc.
- */
- char *psz_gradient_path = var_CreateGetStringCommand(
- p_filter,
- CFG_PREFIX "gradient_path"
- );
- if( psz_gradient_path && strlen(psz_gradient_path) > 0 )
- {
- char *psz_file_name = (char *)malloc( strlen(psz_gradient_path) + 16 );
- assert( psz_file_name );
- for(int i=0; i < p_atmo_config->getZoneCount(); i++ )
- {
- p_zone = p_atmo_config->getZoneDefinition(i);
- if( p_zone )
- {
- sprintf(psz_file_name, "%s%szone_%d.bmp",
- psz_gradient_path, DIR_SEP, i );
- int i_res = p_zone->LoadGradientFromBitmap( psz_file_name );
- if( i_res == ATMO_LOAD_GRADIENT_OK )
- {
- msg_Dbg( p_filter, "loaded gradientfile %s for "\
- "zone %d", psz_file_name, i);
- }
- if( (i_res != ATMO_LOAD_GRADIENT_OK) &&
- (i_res != ATMO_LOAD_GRADIENT_FILENOTFOND) )
- {
- msg_Err( p_filter,"failed to load gradient '%s' with "\
- "error %d",psz_file_name,i_res);
- }
- }
- }
- free( psz_file_name );
- }
- free…
Large files files are truncated, but you can click here to view the full file