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);
182 BumpPixel(GifCtx *ctx) in BumpPixel() argument
187 ++(ctx->curx); in BumpPixel()
194 if( ctx->curx == ctx->Width ) { in BumpPixel()
195 ctx->curx = 0; in BumpPixel()
197 if( !ctx->Interlace ) in BumpPixel()
198 ++(ctx->cury); in BumpPixel()
200 switch( ctx->Pass ) { in BumpPixel()
203 ctx->cury += 8; in BumpPixel()
204 if( ctx->cury >= ctx->Height ) { in BumpPixel()
205 ++(ctx->Pass); in BumpPixel()
206 ctx->cury = 4; in BumpPixel()
211 ctx->cury += 8; in BumpPixel()
212 if( ctx->cury >= ctx->Height ) { in BumpPixel()
213 ++(ctx->Pass); in BumpPixel()
214 ctx->cury = 2; in BumpPixel()
219 ctx->cury += 4; in BumpPixel()
220 if( ctx->cury >= ctx->Height ) { in BumpPixel()
221 ++(ctx->Pass); in BumpPixel()
222 ctx->cury = 1; in BumpPixel()
227 ctx->cury += 2; in BumpPixel()
238 GIFNextPixel(gdImagePtr im, GifCtx *ctx) in GIFNextPixel() argument
242 if( ctx->CountDown == 0 ) in GIFNextPixel()
245 --(ctx->CountDown); in GIFNextPixel()
247 r = gdImageGetPixel(im, ctx->curx, ctx->cury); in GIFNextPixel()
249 BumpPixel(ctx); in GIFNextPixel()
266 GifCtx ctx; in GIFEncode() local
268 memset(&ctx, 0, sizeof(ctx)); in GIFEncode()
269 ctx.Interlace = GInterlace; in GIFEncode()
270 ctx.in_count = 1; in GIFEncode()
274 RWidth = ctx.Width = GWidth; in GIFEncode()
275 RHeight = ctx.Height = GHeight; in GIFEncode()
283 ctx.CountDown = (long)ctx.Width * (long)ctx.Height; in GIFEncode()
288 ctx.Pass = 0; in GIFEncode()
301 ctx.curx = ctx.cury = 0; in GIFEncode()
378 gifPutWord( ctx.Width, fp ); in GIFEncode()
379 gifPutWord( ctx.Height, fp ); in GIFEncode()
384 if( ctx.Interlace ) in GIFEncode()
397 compress( InitCodeSize+1, fp, im, &ctx ); in GIFEncode()
455 #define HashTabOf(i) ctx->htab[i]
456 #define CodeTabOf(i) ctx->codetab[i]
489 output(code_int code, GifCtx *ctx);
492 compress(int init_bits, gdIOCtxPtr outfile, gdImagePtr im, GifCtx *ctx) argument
506 ctx->g_init_bits = init_bits;
507 ctx->g_outfile = outfile;
512 ctx->offset = 0;
513 ctx->out_count = 0;
514 ctx->clear_flg = 0;
515 ctx->in_count = 1;
516 ctx->maxcode = MAXCODE(ctx->n_bits = ctx->g_init_bits);
518 ctx->ClearCode = (1 << (init_bits - 1));
519 ctx->EOFCode = ctx->ClearCode + 1;
520 ctx->free_ent = ctx->ClearCode + 2;
522 char_init(ctx);
524 ent = GIFNextPixel( im, ctx );
532 cl_hash( (count_int) hsize_reg, ctx ); /* clear hash table */
534 output( (code_int)ctx->ClearCode, ctx );
539 while ( (c = GIFNextPixel( im, ctx )) != EOF ) { /* } */
542 ++(ctx->in_count);
566 output ( (code_int) ent, ctx );
567 ++(ctx->out_count);
570 if ( (unsigned) ctx->free_ent < (unsigned) maxmaxcode) {
572 if ( ctx->free_ent < maxmaxcode ) { /* } */
574 CodeTabOf (i) = ctx->free_ent++; /* code -> hashtable */
577 cl_block(ctx);
582 output( (code_int)ent, ctx );
583 ++(ctx->out_count);
584 output( (code_int) ctx->EOFCode, ctx );
610 output(code_int code, GifCtx *ctx) argument
612 ctx->cur_accum &= masks[ ctx->cur_bits ];
614 if( ctx->cur_bits > 0 )
615 ctx->cur_accum |= ((long)code << ctx->cur_bits);
617 ctx->cur_accum = code;
619 ctx->cur_bits += ctx->n_bits;
621 while( ctx->cur_bits >= 8 ) {
622 char_out( (unsigned int)(ctx->cur_accum & 0xff), ctx );
623 ctx->cur_accum >>= 8;
624 ctx->cur_bits -= 8;
631 if ( ctx->free_ent > ctx->maxcode || ctx->clear_flg ) {
633 if( ctx->clear_flg ) {
635 ctx->maxcode = MAXCODE (ctx->n_bits = ctx->g_init_bits);
636 ctx->clear_flg = 0;
640 ++(ctx->n_bits);
641 if ( ctx->n_bits == maxbits )
642 ctx->maxcode = maxmaxcode;
644 ctx->maxcode = MAXCODE(ctx->n_bits);
648 if( code == ctx->EOFCode ) {
652 while( ctx->cur_bits > 0 ) {
653 char_out( (unsigned int)(ctx->cur_accum & 0xff), ctx);
654 ctx->cur_accum >>= 8;
655 ctx->cur_bits -= 8;
658 flush_char(ctx);
667 cl_block (GifCtx *ctx) /* table clear for block compress */ argument
670 cl_hash ( (count_int) hsize, ctx );
671 ctx->free_ent = ctx->ClearCode + 2;
672 ctx->clear_flg = 1;
674 output( (code_int)ctx->ClearCode, ctx);
678 cl_hash(register count_int chsize, GifCtx *ctx) /* reset code table */ argument
682 register count_int *htab_p = ctx->htab+chsize;
722 char_init(GifCtx *ctx) argument
724 ctx->a_count = 0;
732 char_out(int c, GifCtx *ctx) argument
734 ctx->accum[ ctx->a_count++ ] = c;
735 if( ctx->a_count >= 254 )
736 flush_char(ctx);
743 flush_char(GifCtx *ctx) argument
745 if( ctx->a_count > 0 ) {
746 gdPutC( ctx->a_count, ctx->g_outfile );
747 gdPutBuf( ctx->accum, ctx->a_count, ctx->g_outfile );
748 ctx->a_count = 0;