Lines Matching refs:ctx

90 static void BumpPixel (GifCtx *ctx);
91 static int GIFNextPixel (gdImagePtr im, GifCtx *ctx);
93 static void compress (int init_bits, gdIOCtx *outfile, gdImagePtr im, GifCtx *ctx);
94 static void output (code_int code, GifCtx *ctx);
95 static void cl_block (GifCtx *ctx);
96 static void cl_hash (register count_int chsize, GifCtx *ctx);
97 static void char_init (GifCtx *ctx);
98 static void char_out (int c, GifCtx *ctx);
99 static void flush_char (GifCtx *ctx);
196 BumpPixel(GifCtx *ctx) in BumpPixel() argument
201 ++(ctx->curx); in BumpPixel()
208 if( ctx->curx == ctx->Width ) { in BumpPixel()
209 ctx->curx = 0; in BumpPixel()
211 if( !ctx->Interlace ) in BumpPixel()
212 ++(ctx->cury); in BumpPixel()
214 switch( ctx->Pass ) { in BumpPixel()
217 ctx->cury += 8; in BumpPixel()
218 if( ctx->cury >= ctx->Height ) { in BumpPixel()
219 ++(ctx->Pass); in BumpPixel()
220 ctx->cury = 4; in BumpPixel()
225 ctx->cury += 8; in BumpPixel()
226 if( ctx->cury >= ctx->Height ) { in BumpPixel()
227 ++(ctx->Pass); in BumpPixel()
228 ctx->cury = 2; in BumpPixel()
233 ctx->cury += 4; in BumpPixel()
234 if( ctx->cury >= ctx->Height ) { in BumpPixel()
235 ++(ctx->Pass); in BumpPixel()
236 ctx->cury = 1; in BumpPixel()
241 ctx->cury += 2; in BumpPixel()
252 GIFNextPixel(gdImagePtr im, GifCtx *ctx) in GIFNextPixel() argument
256 if( ctx->CountDown == 0 ) in GIFNextPixel()
259 --(ctx->CountDown); in GIFNextPixel()
261 r = gdImageGetPixel(im, ctx->curx, ctx->cury); in GIFNextPixel()
263 BumpPixel(ctx); in GIFNextPixel()
280 GifCtx ctx; in GIFEncode() local
282 memset(&ctx, 0, sizeof(ctx)); in GIFEncode()
283 ctx.Interlace = GInterlace; in GIFEncode()
284 ctx.in_count = 1; in GIFEncode()
288 RWidth = ctx.Width = GWidth; in GIFEncode()
289 RHeight = ctx.Height = GHeight; in GIFEncode()
297 ctx.CountDown = (long)ctx.Width * (long)ctx.Height; in GIFEncode()
302 ctx.Pass = 0; in GIFEncode()
315 ctx.curx = ctx.cury = 0; in GIFEncode()
392 gifPutWord( ctx.Width, fp ); in GIFEncode()
393 gifPutWord( ctx.Height, fp ); in GIFEncode()
398 if( ctx.Interlace ) in GIFEncode()
411 compress( InitCodeSize+1, fp, im, &ctx ); in GIFEncode()
469 #define HashTabOf(i) ctx->htab[i]
470 #define CodeTabOf(i) ctx->codetab[i]
503 output(code_int code, GifCtx *ctx);
506 compress(int init_bits, gdIOCtxPtr outfile, gdImagePtr im, GifCtx *ctx) argument
520 ctx->g_init_bits = init_bits;
521 ctx->g_outfile = outfile;
526 ctx->offset = 0;
527 ctx->out_count = 0;
528 ctx->clear_flg = 0;
529 ctx->in_count = 1;
530 ctx->maxcode = MAXCODE(ctx->n_bits = ctx->g_init_bits);
532 ctx->ClearCode = (1 << (init_bits - 1));
533 ctx->EOFCode = ctx->ClearCode + 1;
534 ctx->free_ent = ctx->ClearCode + 2;
536 char_init(ctx);
538 ent = GIFNextPixel( im, ctx );
546 cl_hash( (count_int) hsize_reg, ctx ); /* clear hash table */
548 output( (code_int)ctx->ClearCode, ctx );
551 while ( (c = GIFNextPixel( im, ctx )) != (unsigned) EOF ) {
553 while ( (c = GIFNextPixel( im, ctx )) != EOF ) { /* } */
556 ++(ctx->in_count);
580 output ( (code_int) ent, ctx );
581 ++(ctx->out_count);
584 if ( (unsigned) ctx->free_ent < (unsigned) maxmaxcode) {
586 if ( ctx->free_ent < maxmaxcode ) { /* } */
588 CodeTabOf (i) = ctx->free_ent++; /* code -> hashtable */
591 cl_block(ctx);
596 output( (code_int)ent, ctx );
597 ++(ctx->out_count);
598 output( (code_int) ctx->EOFCode, ctx );
632 output(code_int code, GifCtx *ctx) argument
634 if (ctx->cur_bits == CUR_BITS_FINISHED) {
638 ctx->cur_accum &= masks[ ctx->cur_bits ];
640 if( ctx->cur_bits > 0 )
641 ctx->cur_accum |= ((long)code << ctx->cur_bits);
643 ctx->cur_accum = code;
645 ctx->cur_bits += ctx->n_bits;
647 while( ctx->cur_bits >= 8 ) {
648 char_out( (unsigned int)(ctx->cur_accum & 0xff), ctx );
649 ctx->cur_accum >>= 8;
650 ctx->cur_bits -= 8;
657 if ( ctx->free_ent > ctx->maxcode || ctx->clear_flg ) {
659 if( ctx->clear_flg ) {
661 ctx->maxcode = MAXCODE (ctx->n_bits = ctx->g_init_bits);
662 ctx->clear_flg = 0;
666 ++(ctx->n_bits);
667 if ( ctx->n_bits == maxbits )
668 ctx->maxcode = maxmaxcode;
670 ctx->maxcode = MAXCODE(ctx->n_bits);
674 if( code == ctx->EOFCode ) {
678 while( ctx->cur_bits > 0 ) {
679 char_out( (unsigned int)(ctx->cur_accum & 0xff), ctx);
680 ctx->cur_accum >>= 8;
681 ctx->cur_bits -= 8;
685 ctx->cur_bits = CUR_BITS_FINISHED;
687 flush_char(ctx);
695 cl_block (GifCtx *ctx) /* table clear for block compress */ argument
698 cl_hash ( (count_int) hsize, ctx );
699 ctx->free_ent = ctx->ClearCode + 2;
700 ctx->clear_flg = 1;
702 output( (code_int)ctx->ClearCode, ctx);
706 cl_hash(register count_int chsize, GifCtx *ctx) /* reset code table */ argument
710 register count_int *htab_p = ctx->htab+chsize;
750 char_init(GifCtx *ctx) argument
752 ctx->a_count = 0;
760 char_out(int c, GifCtx *ctx) argument
762 ctx->accum[ ctx->a_count++ ] = c;
763 if( ctx->a_count >= 254 )
764 flush_char(ctx);
771 flush_char(GifCtx *ctx) argument
773 if( ctx->a_count > 0 ) {
774 gdPutC( ctx->a_count, ctx->g_outfile );
775 gdPutBuf( ctx->accum, ctx->a_count, ctx->g_outfile );
776 ctx->a_count = 0;