Subversion Repositories shark

Rev

Rev 1562 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1562 trimarchi 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Paolo Gai           <pj@gandalf.sssup.it>
10
 *   (see the web pages for full authors list)
11
 *
12
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
13
 *
14
 * http://www.sssup.it
15
 * http://retis.sssup.it
16
 * http://shark.sssup.it
17
 */
18
 
19
#include "drivers/glib.h"
20
 
21
#include "fsf.h"
22
 
23
#include "config.h"
24
#include "global.h"
25
 
26
extern void *start_file;
27
extern void *end_file;
28
 
29
int Init_Mpeg_Decoder(void *start,void *end);
30
int Decode_Bitstream();
31
 
32
// The decoder task body
33
void *mpeg2decoder(void *arg)
34
{
35
 
36
  int init = 1;
37
 
38
  Init_Mpeg_Decoder(start_file,end_file);
39
 
40
  while(1) {
41
 
42
    if (init == 1) {
43
      Decode_Bitstream();      
44
    }
45
  }
46
 
47
  return 0;
48
 
49
}
50
 
51
 
52
/***************************************************************************
53
 *
54
 * 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).
55
 * When we have come to the end of the big buffer we start over and read it from begining (infinity loop)
56
 *
57
 * Author: Robert Bäckgren
58
 ****************************************************************************/
59
void *readTask(void *arg)
60
{
61
  PORT p = readTaskPort;
62
  struct readDecodeMessage msg;
63
  extern void *end_file;
64
  extern void *actual_file;
65
  extern void *start_file;
66
  int rdsize;
67
 
68
  while(1)
69
    {
70
      rdsize = 2048;
71
      if(actual_file + 2048 > end_file)
72
      {
73
        rdsize = (int)(end_file - actual_file);
74
        msg.size = rdsize;
75
        memcpy(msg.buffer, actual_file, msg.size);
76
        actual_file = start_file;
77
 
78
      }
79
      else
80
        {
81
          msg.size = rdsize;
82
          memcpy(msg.buffer, actual_file, msg.size);
83
          actual_file += msg.size;
84
        }
85
      if(!port_send(p, (void*)&msg,BLOCK))
86
      {
87
        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);
88
      }
89
    }
90
}
91
 
92
 
93
/**************************************************************************************************************
94
 *
95
 * Recive a decoded picture. Send the picture to a function that will display it. Will then remove the picture with free.
96
 * This because the decoder allocate this buffer dynamic (See the readme file)
97
 *
98
 * Author: Robert Bäckgren
99
 *****************************************************************************************************************/
100
void *displayTask(void *arg)
101
{
102
  struct decodeDisplayMessage msg;
103
  PORT p = displayTaskPort;
104
  int i;
105
  int initflag = 1;
106
 
107
  msg.src[0] = NULL;
108
  msg.src[1] = NULL;
109
  msg.src[2] = NULL;
110
  while(1)
111
  {
112
    //      if(port_receive(p, (void*)&msg, NON_BLOCK))
113
    if(port_receive(p, (void*)&msg, BLOCK))
114
      {
1563 trimarchi 115
        if (initflag == 0)
1562 trimarchi 116
          grx_text("",20,20,rgb16(255,255,255),0);
117
        displayTaskFunction(msg.src, msg.frame);
1563 trimarchi 118
        //cprintf("Display");
1562 trimarchi 119
 
120
        for(i = 0; i < 3; i++)
121
          {
122
            if(msg.src[i] != NULL)
123
              {
124
                free(msg.src[i]);
125
                msg.src[i] = NULL;
126
              }
127
          }
128
      }
129
      else
130
        {
131
        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);
132
        initflag = 0;
133
        }
1563 trimarchi 134
    //fsf_schedule_timed_job(NULL, NULL, NULL, NULL, NULL);    
135
    task_endcycle();
1562 trimarchi 136
  }
137
}
138
 
139
/*********************************************************************************************
140
 *
141
 * A dummy task
142
 *
143
 * Author: Robert Bäckgren
144
 ********************************************************************************************/
145
void *overLoadTask(void *arg)
146
{
147
  int i;
148
  char tmp[100];
149
  while(1)
150
    {
151
          for(i = 0; i < 98; i++)
152
            {
153
              sprintf(tmp, "hello from overLoad for the %d time", i);
154
              grx_text(tmp,380,380,rgb16(255,255,255),0);
155
            }
156
          fsf_schedule_timed_job(NULL, NULL, NULL, NULL, NULL);    
157
    }
158
}
159