Blame |
Last modification |
View Log
| RSS feed
/*
* Project: S.Ha.R.K.
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* Paolo Gai <pj@gandalf.sssup.it>
* (see the web pages for full authors list)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://shark.sssup.it
*/
#include "drivers/glib.h"
#include "fsf.h"
#include "config.h"
#include "global.h"
extern void *start_file
;
extern void *end_file
;
int Init_Mpeg_Decoder
(void *start
,void *end
);
int Decode_Bitstream
();
// The decoder task body
void *mpeg2decoder
(void *arg
)
{
int init
= 1;
Init_Mpeg_Decoder
(start_file
,end_file
);
while(1) {
if (init
== 1) {
Decode_Bitstream
();
}
}
return 0;
}
/***************************************************************************
*
* Reads a buffer of 2048 bytes size from a big buffer then sends it to a port that the decoder is connected to(see main).
* When we have come to the end of the big buffer we start over and read it from begining (infinity loop)
*
* Author: Robert Bäckgren
****************************************************************************/
void *readTask
(void *arg
)
{
PORT p
= readTaskPort
;
struct readDecodeMessage msg
;
extern void *end_file
;
extern void *actual_file
;
extern void *start_file
;
int rdsize
;
while(1)
{
rdsize
= 2048;
if(actual_file
+ 2048 > end_file
)
{
rdsize
= (int)(end_file
- actual_file
);
msg.
size = rdsize
;
memcpy(msg.
buffer, actual_file
, msg.
size);
actual_file
= start_file
;
}
else
{
msg.
size = rdsize
;
memcpy(msg.
buffer, actual_file
, msg.
size);
actual_file
+= msg.
size;
}
if(!port_send
(p
, (void*)&msg
,BLOCK
))
{
//grx_text("\n\n readTask ******************** E R R O R E R R O R E R R O R **********************\n",0,0,rgb16(255,255,255),0);
}
}
}
/**************************************************************************************************************
*
* Recive a decoded picture. Send the picture to a function that will display it. Will then remove the picture with free.
* This because the decoder allocate this buffer dynamic (See the readme file)
*
* Author: Robert Bäckgren
*****************************************************************************************************************/
void *displayTask
(void *arg
)
{
struct decodeDisplayMessage msg
;
PORT p
= displayTaskPort
;
int i
;
int initflag
= 1;
msg.
src[0] = NULL
;
msg.
src[1] = NULL
;
msg.
src[2] = NULL
;
while(1)
{
// if(port_receive(p, (void*)&msg, NON_BLOCK))
if(port_receive
(p
, (void*)&msg
, BLOCK
))
{
if (initflag
== 0)
grx_text
("",20,20,rgb16
(255,255,255),0);
displayTaskFunction
(msg.
src, msg.
frame);
//cprintf("Display");
for(i
= 0; i
< 3; i
++)
{
if(msg.
src[i
] != NULL
)
{
free(msg.
src[i
]);
msg.
src[i
] = NULL
;
}
}
}
else
{
//grx_text(" displayTask ******************** E R R O R E R R O R E R R O R **********************",20,20,rgb16(255,255,255),0);
initflag
= 0;
}
//fsf_schedule_timed_job(NULL, NULL, NULL, NULL, NULL);
task_endcycle
();
}
}
/*********************************************************************************************
*
* A dummy task
*
* Author: Robert Bäckgren
********************************************************************************************/
void *overLoadTask
(void *arg
)
{
int i
=0;
char tmp
[100];
while(1)
{
//for(i = 0; i < 98; i++)
// {
sprintf(tmp
, "hello from overLoad for the %d time", i
);
grx_text
(tmp
,380,380+exec_shadow
*10,rgb16
(255,255,255),0);
//cprintf(tmp);
// }
i
++;
//fsf_schedule_timed_job(NULL, NULL, NULL, NULL, NULL);
task_endcycle
();
}
}