Main Page | Class List | File List | Class Members | File Members

VidDepacket.c File Reference

#include <math.h>
#include "rcpcc_hg16.h"
#include "uep_rcpcc.h"

Go to the source code of this file.

Functions

void Makeppx (int Rtype)
void GetRcpcBits (buf_rcpc *b1, int *rcpc_bits1, int *rcpc_bits2, int Rtype, int N)
unsigned char * DecodeVideoPacket (int Rtype, int N, buf_rcpc *b1, int *CRC_flag, int *K, int CRCBytes, int arq_type)

Variables

int debug
int ppx [4][8][4]


Function Documentation

unsigned char* DecodeVideoPacket int  Rtype,
int  N,
buf_rcpc b1,
int *  CRC_flag,
int *  K,
int  CRCBytes,
int  arq_type
 

Definition at line 109 of file VidDepacket.c.

References CheckCRC(), ConvBits2Bytes(), buf_rcpc::count, GetRcpcBits(), Makeppx(), ppx, rcpcc16_decode(), rcpcc16_getK(), and TAILBITS.

00112 {
00113   int *out_bits;
00114   int i, j;
00115   int *rcpc_bits1;
00116   int *rcpc_bits2;
00117   int step  = 32 - Rtype;
00118   int new_Rtype;
00119   unsigned char *info_bytes;
00120 
00121 
00122   /* bits on the current row */
00123   rcpc_bits1= (int *)malloc(N * 8  *sizeof(int));  
00124   if (rcpc_bits1 == NULL) {
00125     printf("DecodeVideoPacket () - error can't malloc rcpc_bits1\n");
00126   }
00127 
00128   /* bits on all rows */
00129   rcpc_bits2= (int *)malloc(N * 8 * (b1->count) *sizeof(int)); 
00130   if (rcpc_bits2 == NULL) {
00131     printf("DecodeVideoPacket () - error can't malloc rcpc_bits2\n");
00132   }
00133 
00134   (*K)=rcpcc16_getK(Rtype,N,CRCBytes);
00135 
00136   info_bytes = (unsigned char *)calloc((*K)+CRCBytes, sizeof(unsigned char ));
00137   if (info_bytes == NULL)
00138     printf("DecodeVideoPacket () - error can't calloc info_bytes");
00139   out_bits = (int *)calloc( ( (*K)  + CRCBytes) * 8 + TAILBITS, sizeof(int) );
00140   if (out_bits == NULL)
00141     printf("DecodeVideoPacket () - error can't calloc out_bits\n");
00142 
00143 
00144   Makeppx(Rtype);
00145   
00146   GetRcpcBits(b1, rcpc_bits1, rcpc_bits2, Rtype, N );
00147 
00148 
00149   if ((b1->count) == 1) {  
00150 
00151     rcpcc16_decode(rcpc_bits1, out_bits, Rtype, N, ppx[0],CRCBytes);
00152 
00153     ConvBits2Bytes(out_bits, info_bytes, (*K)+CRCBytes);
00154     
00155     *CRC_flag = CheckCRC(info_bytes, (*K), CRCBytes);
00156     
00157   } else if ((b1->count) > 1)  { 
00158 
00159     /* 
00160      * Do Type I ARQ 
00161      */
00162     if((arq_type == 3) || (arq_type == 1)) {
00163 
00164       rcpcc16_decode(rcpc_bits1, out_bits, Rtype, N, ppx[b1->count - 1],CRCBytes);
00165 
00166       ConvBits2Bytes(out_bits, info_bytes, (*K)+CRCBytes);
00167       
00168       *CRC_flag = CheckCRC(info_bytes, (*K), CRCBytes);
00169 
00170     }
00171     /* 
00172      * Do Type II ARQ
00173      */
00174     if (((*CRC_flag == 0) && (arq_type == 3)) || (arq_type==2)) {
00175       for (i=0; i< ( (*K)  + CRCBytes) * 8 + TAILBITS ; i++)
00176         out_bits[i]= 0;
00177       
00178       new_Rtype = Rtype - step*( (b1->count) -1);
00179       
00180       rcpcc16_decode(rcpc_bits2, out_bits, new_Rtype,
00181                      (b1->count)*N, px[new_Rtype],CRCBytes);
00182       
00183       ConvBits2Bytes(out_bits, info_bytes, *K+CRCBytes);
00184       
00185       *CRC_flag = CheckCRC(info_bytes,  (*K), CRCBytes);
00186 
00187     }
00188   }
00189 
00190 
00191   free(out_bits);
00192   free(rcpc_bits1);
00193   free(rcpc_bits2);
00194   
00195   return info_bytes;
00196 }

void GetRcpcBits buf_rcpc b1,
int *  rcpc_bits1,
int *  rcpc_bits2,
int  Rtype,
int  N
 

Definition at line 45 of file VidDepacket.c.

References buf_rcpc::block, ConvBytes2Bits(), buf_rcpc::count, debug, max_arq(), and ppx.

Referenced by DecodeVideoPacket().

00046 {
00047   
00048   int j,i,k;
00049   int step = 32 - Rtype;
00050   int *temp_bits[4];
00051   int buff[8][4];
00052   int co[4];
00053   int co2 = 0;
00054   int new_Rtype = Rtype - step * ((b1->count) - 1) ;
00055   int loopmax; 
00056 
00057   ConvBytes2Bits(b1->block[ (b1->count) - 1], rcpc_bits1, N);
00058   if (debug >= 5)
00059                 printf(" into GetRcpcBits\n");  
00060  
00061   /* don't loop to b1->count, use max of b1->count and max_arq(rtype)+1.  The 
00062      reason is that a bufrcpc structure may have inadvertantly gotten 
00063      an ARQ that exceeded its count for its rate type and we don't want 
00064      to use this information which will cause a crash */
00065 
00066   if (b1->count > max_arq(Rtype) + 1)
00067     loopmax = max_arq(Rtype) + 1;
00068   else 
00069     loopmax = b1->count;
00070 
00071   for (i=0; i<  loopmax; i++){
00072     temp_bits[i] = (int *) malloc(10 *  N * 8 *sizeof(int) );
00073     if (temp_bits[i] == NULL)
00074       printf("GetRcpcbits () - error can't malloc temp_bits[%d]\n",i);
00075  
00076     ConvBytes2Bits(b1->block[i], temp_bits[i], N);
00077     co[i] = 0;
00078   }
00079   
00080   while ( co2 <  N * 8 * loopmax ){
00081     for (i=0; i< 8; i++){
00082       for (j=0; j< 4; j++){
00083         buff[i][j]= 0;
00084         
00085         for (k=0; k< loopmax; k++)
00086           {
00087             if (ppx[k][i][j] ==1)
00088               {
00089                 buff[i][j] = temp_bits[k][co[k]];
00090                 co[k]++;
00091               }
00092           }
00093         if ((px[new_Rtype][i][j] == 1 ) &&( co2 <   N * 8 * (b1->count)) )
00094           {
00095             rcpc_bits2[co2] =  buff[i][j];
00096             co2++;
00097           }
00098       }
00099     }
00100   }
00101 
00102   if (debug >= 5)
00103                 printf(" end of GetRcpcBits\n");
00104   for (i=0; i<  loopmax; i++){
00105     free(temp_bits[i]);
00106   }
00107 }

void Makeppx int  Rtype  ) 
 

Definition at line 8 of file VidDepacket.c.

References debug, and ppx.

Referenced by DecodeVideoPacket().

00009 {
00010   int i, j, k;
00011   int step = 32- Rtype;
00012   int row = 0;
00013   while (Rtype >=0)
00014     {
00015       if (row == 0){
00016         for (i=0; i<8; i++)
00017           for (j=0; j< 4; j++)
00018             ppx[row][i][j] = px[Rtype][i][j];
00019       }
00020       else 
00021         {
00022           for (i=0; i<8; i++)
00023             for (j=0; j< 4; j++)
00024               ppx[row][i][j] = px[Rtype][i][j] - px[Rtype + step][i][j];
00025         }
00026       Rtype = Rtype - step;
00027       row ++;
00028     }
00029   
00030   if (debug >= 5) {
00031     printf("ppx\n");
00032     for (i=0; i< 4; i++){
00033       printf("row %d\n", i);
00034       for (j=0; j < 8; j++){ 
00035         for (k=0; k< 4; k++)
00036           printf("%d ", ppx[i][j][k]);
00037         if (j <=6)
00038           printf(", ");
00039       } 
00040       printf("\n ");
00041     }
00042   }
00043 }


Variable Documentation

int debug
 

Definition at line 23 of file main.c.

int ppx[4][8][4] [static]
 

Definition at line 6 of file VidDepacket.c.

Referenced by DecodeVideoPacket(), GetRcpcBits(), and Makeppx().


Generated on Sun Jul 16 16:27:48 2006 by  doxygen 1.3.9.1