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

uep_rcpcc.h File Reference

#include "Buffer.h"
#include "rcpc.h"
#include "bytes.h"

Go to the source code of this file.

Defines

#define MAXINPUTBITS   1024

Functions

int rcpcc16_encode ()
int rcpcc16_decode ()
int rcpcc16_getK ()
void Makeppx (int Rtype)
void GetRcpcBytes (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)
void rcpcc_coder ()
void rcpcc_decoder ()
double distance ()
void ConvBits2Bytes (int *bit_array, unsigned char *byte_array, int N)
void ConvBytes2Bits (unsigned char *byte_array, int *bit_array, int N)
void MakeCRCBytes (byte *in_bits, int info_dim, int CRC_dim)
int CheckCRC (byte *out_bits, int info_dim, int CRC_dim)
buf_rcpcMakeNewVideoPacket (int Rtype, int N, Buffer *VideoBuff, int CRCBytes, int arq_type)


Define Documentation

#define MAXINPUTBITS   1024
 

Definition at line 29 of file uep_rcpcc.h.


Function Documentation

int CheckCRC byte out_bits,
int  info_dim,
int  CRC_dim
 

Referenced by DecodeVideoPacket().

void ConvBits2Bytes int *  bit_array,
unsigned char *  byte_array,
int  N
 

Referenced by DecodeVideoPacket(), and rcpcc16_encode().

void ConvBytes2Bits unsigned char *  byte_array,
int *  bit_array,
int  N
 

Definition at line 233 of file uep_rcpcc.c.

Referenced by GetRcpcBits().

00234 {
00235   int i, j;
00236 
00237   for (i =0;i< N; i++){
00238     for (j=0; j< 8; j++){
00239       bit_array[i* 8 + j] = (byte_array[i] >> (7-j)) &1;
00240     }
00241   }
00242 }

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 }

double distance  ) 
 

Referenced by rcpcc_decoder().

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

void MakeCRCBytes byte in_bits,
int  info_dim,
int  CRC_dim
 

Referenced by MakeNewVideoPacket().

buf_rcpc* MakeNewVideoPacket int  Rtype,
int  N,
Buffer VideoBuff,
int  CRCBytes,
int  arq_type
 

Definition at line 22 of file Vidpacket.c.

References buf_rcpc::block, bread(), debug, MakeCRCBytes(), rcpcc16_encode(), and rcpcc16_getK().

00023 {
00024   int i, j;
00025   buf_rcpc *a1 = (buf_rcpc *)calloc(1, sizeof(buf_rcpc ));
00026   int K;
00027   unsigned char *vid_char;
00028   int *in_bits;
00029   
00030   /* 
00031    * return the number of bytes needed from the video buffer 
00032    */
00033   K=rcpcc16_getK(Rtype,N,CRCBytes);  
00034   
00035   if (debug >= 2)
00036     printf(" K = %d\n", K);
00037   
00038   vid_char = (unsigned char *)calloc(K+CRCBytes , sizeof(char));
00039   
00040   for(i=0;i<K;i++) {
00041     bread(VideoBuff, &vid_char[i]);
00042   }
00043   
00044   if (debug >= 5) {
00045     printf("vid_char at pack before CRC \n");
00046     for (i=0; i< (K)+ CRCBytes; i++)
00047       printf("%c", vid_char[i]);
00048     printf("\n");
00049   }
00050   
00051   MakeCRCBytes(vid_char, K, CRCBytes);
00052   
00053   
00054   if (debug >= 2) {
00055     printf("vid_char at pack after CRC \n");
00056     for (i=0; i< (K)+ CRCBytes; i++)
00057       printf("%c", vid_char[i]);
00058     printf("\n");
00059   }
00060   
00061   in_bits = (int *)malloc( ((K + CRCBytes) * 8) * sizeof(int));
00062   
00063   if (debug >= 2) 
00064     printf("in_bits\n");
00065   for (i=0; i< ((K+CRCBytes)*8); i++) {
00066     in_bits[i] = (vid_char[i/8] >> (7- (i%8) ) ) & 1;
00067   } 
00068   
00069   if (debug >= 2)
00070     printf(" after making the CRC bits\n");
00071   
00072   for (i=0; i< 4; i++) {
00073     a1->block[i] = (unsigned char *)calloc(N, sizeof(unsigned char));
00074     if (debug >= 2)
00075       printf(" %d\n", a1->block[i] );
00076   }
00077   
00078   if (debug >= 2)
00079     printf(" before RCPC encoder\n");
00080   rcpcc16_encode(in_bits,(K+CRCBytes)*8, a1, Rtype, N);
00081   if (debug >= 2)
00082     printf(" after RCPC encoder\n");
00083   
00084   free(vid_char);
00085   free(in_bits);
00086   
00087   return a1;
00088   
00089 }

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 }

int rcpcc16_decode  ) 
 

Referenced by DecodeVideoPacket().

int rcpcc16_encode  ) 
 

Referenced by MakeNewVideoPacket().

int rcpcc16_getK  ) 
 

Referenced by DecodeVideoPacket(), MakeNewVideoPacket(), and rcpcc16_decode().

void rcpcc_coder  ) 
 

Referenced by rcpcc16_encode().

void rcpcc_decoder  ) 
 

Referenced by rcpcc16_decode().


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