Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
thrControl.c
Package: DSP-C6000-DM642DEMO.rar [view]
Upload User: dahaojd
Upload Date: 2008-01-29
Package Size: 14357k
Code Size: 4k
Category:
DSP program
Development Platform:
C/C++
- /*
- * Copyright 2002 by Texas Instruments Incorporated.
- * All rights reserved. Property of Texas Instruments Incorporated.
- * Restricted rights to use, duplicate or disclose this code are
- * granted through contract.
- *
- */
- /* "@(#) RF5_IEK 2.00.01 11-26-02 (swat-c18)" */
- /*
- * ======== thrControl.c ========
- * This file shows an example of sending messages from one thread to the
- * other using mailbox.
- */
- #include <std.h>
- // DSP/BIOS includes
- #include <mbx.h>
- #include <tsk.h>
- // RF includes
- #include <utl.h>
- // application includes
- #include "appResources.h" // application-wide common info
- #include "appThreads.h" // thread-wide common info
- #include "thrControl.h"
- #include "appmain.h"
- #include "tskProcess.h" /* contains thread specific information */
- // global variables to be modified by GEL
- #define NUMCONTROLS 1 // same as the number of processing channels
- typedef struct ExternalControl
- {
- Int frameRatio[NUMCONTROLS];
- Int quality[NUMCONTROLS];
- } ExternalControl;
- #pragma DATA_ALIGN(externalControl, 128);
- ExternalControl externalControl; // GEL script writes here
- ExternalControl externalControlPrev; // this is a local copy
- /*
- * ======== thrControlInit ========
- *
- */
- Void thrControlInit()
- {
- UTL_assert( NUMCONTROLS == 1 );
- // set the default frame ratio
- externalControl.frameRatio[0] = 1; // live video channel
- externalControl.quality[0] = 85;
- externalControlPrev = externalControl;
- }
- void thrControlSet( int FrameRatio, int Quality )
- {
- UTL_assert( NUMCONTROLS == 1 );
- // Keep the quality reasonable. File size increases
- // about 60% between quality factors 95 and 100.
- // Keep it 1-90.
- if( (Quality-=10) < 1 )
- Quality = 1;
- // set the default frame ratio
- externalControl.frameRatio[0] = FrameRatio;
- externalControl.quality[0] = Quality;
- }
- /*
- * ======== thrControlStartup ========
- *
- */
- Void thrControlStartup()
- {
- Int chanNum;
- CtrlMsg txMsg;
- // send message to initialize the frame ratio
- for( chanNum = 0; chanNum < NUMCONTROLS; chanNum++)
- {
- // Set-up initial values for frame ratio
- txMsg.cmd = MSGFRAMECHANGE;
- txMsg.arg1 = chanNum;
- txMsg.arg2 = externalControl.frameRatio[chanNum];
- // Send the request
- MBX_post( &mbxProcess, &txMsg, 0 );
- // Set-up initial values for new quality
- txMsg.cmd = MSGQUALCHANGE;
- txMsg.arg1 = chanNum;
- txMsg.arg2 = 0; // JPEG encoder cell index
- txMsg.arg3 = externalControl.quality[chanNum];
- // Send the request
- MBX_post( &mbxProcess, &txMsg, 0 );
- }
- }
- /*
- * ======== thrControlRun ========
- *
- * Main function of Control task.
- */
- Void thrControlRun()
- {
- Int chanNum;
- CtrlMsg txMsg;
- // Main loop
- while (TRUE)
- {
- // check for changes
- for( chanNum = 0; chanNum < NUMCONTROLS; chanNum++)
- {
- // See if user requested a frame ratio change.
- if( externalControl.frameRatio[chanNum] !=
- externalControlPrev.frameRatio[chanNum] )
- {
- // new value entered
- externalControlPrev.frameRatio[chanNum] =
- externalControl.frameRatio[chanNum];
- // send message to tell which channel has ratio changed
- txMsg.cmd = MSGFRAMECHANGE;
- txMsg.arg1 = chanNum;
- txMsg.arg2 = externalControl.frameRatio[chanNum];
- MBX_post( &mbxProcess, &txMsg, 0 );
- }
- // See if user requested a quality change.
- if( externalControl.quality[chanNum] !=
- externalControlPrev.quality[chanNum] )
- {
- // new value entered
- externalControlPrev.quality[chanNum] =
- externalControl.quality[chanNum];
- // send message to tell which channel has ratio changed
- txMsg.cmd = MSGQUALCHANGE;
- txMsg.arg1 = chanNum;
- txMsg.arg2 = 0; // JPEG encoder cell index
- txMsg.arg3 = externalControl.quality[chanNum];
- MBX_post( &mbxProcess, &txMsg, 0 );
- }
- }
- // suspend self for 500 ticks, and then poll again
- TSK_sleep( 500 );
- }
- }