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

vid_putbits.c File Reference

#include "vid_sim.h"
#include "video_codec.h"
#include "al_sending.h"

Go to the source code of this file.

Functions

void initbits ()
void putbits (int n, int val)
int alignbits ()
int bitcount ()
void BitPrint (int length, int val, char *bit)

Variables

video_codecVidSt


Function Documentation

int alignbits  ) 
 

Definition at line 115 of file vid_putbits.c.

References video_codec::outcnt, putbits(), and VidSt.

Referenced by code_video().

00116 {
00117   int ret_value;
00118   
00119   if ((VidSt->outcnt)!=8) {
00120     ret_value = (VidSt->outcnt);        /* outcnt is reset in call to putbits () */
00121     putbits ((VidSt->outcnt), 0);
00122     return ret_value;
00123   }
00124   else
00125     return 0;
00126 }

int bitcount  ) 
 

Definition at line 130 of file vid_putbits.c.

References video_codec::bytecnt, video_codec::outcnt, and VidSt.

Referenced by AR_Encode(), bit_in_psc_layer(), bit_opp_bits(), encoder_flush(), and UpdateQuantizer().

00131 {
00132   return 8*(VidSt->bytecnt) + (8-(VidSt->outcnt));
00133 }

void BitPrint int  length,
int  val,
char *  bit
 

Definition at line 137 of file vid_putbits.c.

Referenced by putbits().

00138 {
00139   int m;
00140   
00141   m = length;
00142   bit[0] = '"';
00143   while (m--) {
00144     bit[length-m] = (val & (1<<m)) ? '1' : '0';
00145   }
00146   bit[length+1] = '"';
00147   bit[length+2] = '\n';
00148   bit[length+3] = '\0';
00149   return;
00150 }

void initbits  ) 
 

Definition at line 64 of file vid_putbits.c.

References video_codec::bytecnt, video_codec::outcnt, and VidSt.

Referenced by code_video().

00065 {
00066   (VidSt->outcnt) = 8;
00067   (VidSt->bytecnt) = 0;
00068 }

void putbits int  n,
int  val
 

Definition at line 73 of file vid_putbits.c.

References al_send_byte(), BitPrint(), video_codec::bytecnt, video_codec::label, video_codec::outbfr, video_codec::outcnt, video_codec::output, video_codec::simbuffer, video_codec::streamfile, video_codec::tf, video_codec::trace, and VidSt.

Referenced by alignbits(), bit_in_psc_layer(), CodeCoeff(), CountBitsMB(), CountBitsPicture(), CountBitsSlice(), put_cbpcm_inter(), put_cbpcm_intra(), put_cbpy(), put_coeff(), and put_mv().

00074 {
00075   int i;
00076   unsigned int mask;
00077   char bitstring[32];
00078 
00079   if ((VidSt->trace)) {
00080     if (n > 0) {
00081       BitPrint(n,val,bitstring);
00082       fprintf((VidSt->tf),bitstring);
00083     }
00084   }
00085 
00086   mask = 1 << (n-1); /* selects first (leftmost) bit */
00087 
00088   for (i=0; i<n; i++) {
00089     (VidSt->outbfr) <<= 1;
00090 
00091     if (val & mask)
00092       (VidSt->outbfr)|= 1;
00093 
00094     mask >>= 1; /* select next bit */
00095     (VidSt->outcnt)--;
00096 
00097     if ((VidSt->outcnt)==0) /* 8 bit buffer full */ {
00098       putc((VidSt->outbfr),(VidSt->streamfile));
00099 
00100       if (al_send_byte((VidSt->output), (VidSt->outbfr)) == 0)
00101         printf("!: \"%s\" overwrote AL-buffer!\n", (VidSt->label));
00102 
00103       (VidSt->simbuffer)++;
00104 
00105       (VidSt->outcnt) = 8;
00106       (VidSt->bytecnt)++;
00107     }
00108   }
00109 }


Variable Documentation

video_codec* VidSt
 

Definition at line 16 of file vid_wrapper.c.


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