2 * AtmoLiveView.cpp: this effect outputs colors as result of a picture
3 * content (most complex effect) see thread.c of the linux VDR version -
4 * to fully understand what happens here..
6 * See the README.txt file for copyright information and how to reach the author(s).
11 #include "AtmoLiveView.h"
12 #include "AtmoOutputFilter.h"
13 #include "AtmoTools.h"
15 #if defined(_ATMO_VLC_PLUGIN_)
16 # include <vlc_common.h>
18 # include "AtmoGdiDisplayCaptureInput.h"
21 #include "AtmoExternalCaptureInput.h"
25 #if defined(_ATMO_VLC_PLUGIN_)
27 CAtmoLiveView::CAtmoLiveView(CAtmoDynData *pAtmoDynData) :
28 CThread(pAtmoDynData->getAtmoFilter())
30 this->m_pAtmoDynData = pAtmoDynData;
35 CAtmoLiveView::CAtmoLiveView(CAtmoDynData *pAtmoDynData)
37 this->m_pAtmoDynData = pAtmoDynData;
43 CAtmoLiveView::~CAtmoLiveView(void)
48 DWORD CAtmoLiveView::Execute(void)
50 #if defined(_ATMO_VLC_PLUGIN_)
59 int i_frame_counter = -1;
61 pColorPacket ColorPacket;
62 pColorPacket PreviousPacket = NULL;
64 CAtmoConnection *pAtmoConnection = this->m_pAtmoDynData->getAtmoConnection();
65 if((pAtmoConnection == NULL) || (pAtmoConnection->isOpen() == ATMO_FALSE)) return 0;
67 CAtmoConfig *pAtmoConfig = this->m_pAtmoDynData->getAtmoConfig();
70 this object does post processing of the pixel data
71 like jump /scenechange detection fading over the colors
73 CAtmoOutputFilter *filter = new CAtmoOutputFilter( this->m_pAtmoDynData->getAtmoConfig() );
74 CAtmoPacketQueue *pPacketQueue = this->m_pAtmoDynData->getLivePacketQueue();
76 int frameDelay = pAtmoConfig->getLiveView_FrameDelay();
78 #if defined(_ATMO_VLC_PLUGIN_)
80 because time function of vlc are working with us values instead of ms
82 frameDelay = frameDelay * 1000;
86 wait for the first frame to go in sync with the other thread
90 if( pPacketQueue->WaitForNextPacket(3000) )
93 do_sleep( frameDelay );
94 #if defined(_ATMO_VLC_PLUGIN_)
95 msg_Dbg( m_pAtmoThread, "First Packet got %d ms", (get_time - t) / 1000 );
99 while(this->m_bTerminated == ATMO_FALSE)
102 if(i_frame_counter == 50) i_frame_counter = 0;
104 /* grab current Packet from InputQueue (working as FIFO)! */
105 #if defined(_ATMO_VLC_PLUGIN_)
106 ColorPacket = pPacketQueue->GetNextPacket(get_time - frameDelay, (i_frame_counter == 0), m_pAtmoThread, packet_time);
108 ColorPacket = pPacketQueue->GetNextPacket(get_time - frameDelay, (i_frame_counter == 0), packet_time);
113 create a packet copy - for later reuse if the input is slower than 25fps
115 if(PreviousPacket && (PreviousPacket->numColors == ColorPacket->numColors))
116 CopyColorPacket(ColorPacket, PreviousPacket)
118 delete (char *)PreviousPacket;
119 DupColorPacket(PreviousPacket, ColorPacket )
123 packet queue was empty for the given point of time
125 if(i_frame_counter == 0)
127 #if defined(_ATMO_VLC_PLUGIN_)
128 msg_Dbg( m_pAtmoThread, "wait for delayed packet..." );
131 if( pPacketQueue->WaitForNextPacket(200) )
134 do_sleep( frameDelay );
135 #if defined(_ATMO_VLC_PLUGIN_)
136 msg_Dbg( m_pAtmoThread, "got delayed packet %d ms", (mdate() - t) / 1000 );
142 reuse previous color packet
144 DupColorPacket(ColorPacket, PreviousPacket)
151 /* pass it through the outputfilters! */
152 // Info Filtering will possible free the colorpacket and alloc a new one!
153 ColorPacket = filter->Filtering(ColorPacket);
155 /* apply gamma correction - only if the hardware isnt capable doing this */
156 ColorPacket = CAtmoTools::ApplyGamma(pAtmoConfig, ColorPacket);
159 apply white calibration - only if it is not
162 if(pAtmoConfig->isUseSoftwareWhiteAdj())
163 ColorPacket = CAtmoTools::WhiteCalibration(pAtmoConfig, ColorPacket);
165 /* send color data to the the hardware... */
166 pAtmoConnection->SendData(ColorPacket);
168 delete (char *)ColorPacket;
172 calculate RunTime of thread abbove (doesn't work well - so
173 this threads comes out of sync with Image producer and the
174 framerate (25fps) drifts away
176 #if defined(_ATMO_VLC_PLUGIN_)
177 ticks = ((mdate() - ticks) + 999)/1000;
179 ticks = GetTickCount() - ticks;
183 if( ThreadSleep( 40 - ticks ) == ATMO_FALSE )
188 #if defined(_ATMO_VLC_PLUGIN_)
189 msg_Dbg( m_pAtmoThread, "DWORD CAtmoLiveView::Execute(void) terminates");
190 pPacketQueue->ShowQueueStatus( m_pAtmoThread );
193 delete (char *)PreviousPacket;