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

Vidpacket.c File Reference

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

Go to the source code of this file.

Functions

buf_rcpcMakeNewVideoPacket (int Rtype, int N, Buffer *VideoBuff, int CRCBytes, int arq_type)

Variables

int debug


Function Documentation

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 }


Variable Documentation

int debug
 

Definition at line 23 of file main.c.


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