source: soft/giet_vm/applications/mjpeg/libu.c @ 807

Last change on this file since 807 was 748, checked in by alain, 9 years ago

Modify instrumentation to save results on virtual disk.

File size: 3.8 KB
RevLine 
[723]1/////////////////////////////////////////////////////////////////////////////////////////
2// File   : libu.c   
3// Date   : octobre 2015
4// author : Alain Greiner
5/////////////////////////////////////////////////////////////////////////////////////////
6// This file define the code of the LIBU (line building) thread for MJPEG application.
7// This function execute an infinite loop on a stream of decompressed images.
8// The image size is fbf_width * fbf_height pixels. Each pixel is one byte.
9// The LIBU[index] thread read all blocks of a given image to fill its private
10// bufout[index] buffer, that is part of a FBF_CMA chbuf.
11// For each image:
12// - it checks that buf_out[index] is empty (released by the CMA peripheral).
13// - it move all blocks fom the input MWMR channel to the bufout[index] buffer.
14// - it request the CMA peripheral to display the image stored in bufout[index]
15// - It register the date of display in the date[] array for intrumentation.
16/////////////////////////////////////////////////////////////////////////////////////////
17
18#include <stdio.h>
19#include <mwmr_channel.h>
20#include <stdint.h>
21#include <stdlib.h>
22#include "mjpeg.h"
23
24// macro to use a shared TTY
[748]25#define PRINTF(...) do { lock_acquire( &tty_lock ); \
26                         giet_tty_printf(__VA_ARGS__);  \
27                         lock_release( &tty_lock ); } while(0);
[723]28
29//////////////////////////////////////////////////////////////
30__attribute__ ((constructor)) void libu( unsigned int index )
31//////////////////////////////////////////////////////////////
32{
33    mwmr_channel_t* input = idct_2_libu[index];
34
35    uint32_t time;
36
37    uint8_t  bufin[64];
38    uint32_t line;
39    uint32_t column;
40
41    // get platform parameters
42    uint32_t  x_size;
43    uint32_t  y_size;
44    uint32_t  nprocs;
45    giet_procs_number( &x_size , &y_size , &nprocs );
46
47    // get processor coordinates
48    unsigned int x , y , p;
49    giet_proc_xyp( &x ,&y , &p );
50
51    // private TTY allocation
52    // giet_tty_alloc( 0 );
53
[736]54    PRINTF("\n[MJPEG] thread LIBU[%d] starts on P[%d,%d,%d] / trdid = %x\n",
[748]55           index , x , y , p, (uint32_t)trdid_libu[index] );
[723]56
57    uint32_t image = index;
58
59    while( image < MAX_IMAGES )  // one image per iteration
60    {
61        // check CMA buffer empty
62        giet_fbf_cma_check( index );
63
64        // two loops on blocks to build image
65        for ( line = 0 ; line < nblocks_h ; ++line ) 
66        {
67            for ( column = 0 ; column < nblocks_w ; ++column )
68            {
69                // move one block from input MWMR channel (one byte per pixel
70                mwmr_read( input , (uint32_t*)bufin , 16 );
71
72                // copy block to cma_buf
73                unsigned int i;
74                unsigned int src;
75                unsigned int dst;
76                for ( i = 0; i < 8 ; ++i ) 
77                {
78                    src = (i * 8);
79                    dst = ((line * 8 + i) * fbf_width) + (column * 8);
80
81                    // copy 8 bytes to cma_buf[index]
82                    memcpy( &cma_buf[index][dst] , &bufin[src] , 8 );
83                }
84
85#if (DEBUG_LIBU > 1)
[736]86if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
[748]87PRINTF("\nLIBU[%d] copy block[%d] for image %d\n", 
88         index, line * nblocks_w + column , image );
[723]89#endif
90            }
91
92        } // end loops on blocks
93
94        // request CMA to display image
95        giet_fbf_cma_display( index );
96
97        // get date of display
98        time = giet_proctime();
99
100#if DEBUG_LIBU
[736]101if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
[748]102PRINTF("\nLIBU[%d] completes image %d at cycle %d\n", index , image , time );
[723]103#endif
104        // register date of display for instrumentation
105        date[image] = time;
106
107        image = image + x_size*y_size;
108
109    }  // end while on images
110
[736]111    giet_pthread_exit( "LIBU completed" );
[723]112
113}  // end libu()
114
Note: See TracBrowser for help on using the repository browser.