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 );
618 output(code_int code, GifCtx *ctx) argument
620 if (ctx->cur_bits == CUR_BITS_FINISHED) {
624 ctx->cur_accum &= masks[ ctx->cur_bits ];
626 if( ctx->cur_bits > 0 )
627 ctx->cur_accum |= ((long)code << ctx->cur_bits);
629 ctx->cur_accum = code;
631 ctx->cur_bits += ctx->n_bits;
633 while( ctx->cur_bits >= 8 ) {
634 char_out( (unsigned int)(ctx->cur_accum & 0xff), ctx );
635 ctx->cur_accum >>= 8;
636 ctx->cur_bits -= 8;
643 if ( ctx->free_ent > ctx->maxcode || ctx->clear_flg ) {
645 if( ctx->clear_flg ) {
647 ctx->maxcode = MAXCODE (ctx->n_bits = ctx->g_init_bits);
648 ctx->clear_flg = 0;
652 ++(ctx->n_bits);
653 if ( ctx->n_bits == maxbits )
654 ctx->maxcode = maxmaxcode;
656 ctx->maxcode = MAXCODE(ctx->n_bits);
660 if( code == ctx->EOFCode ) {
664 while( ctx->cur_bits > 0 ) {
665 char_out( (unsigned int)(ctx->cur_accum & 0xff), ctx);
666 ctx->cur_accum >>= 8;
667 ctx->cur_bits -= 8;
671 ctx->cur_bits = CUR_BITS_FINISHED;
673 flush_char(ctx);
681 cl_block (GifCtx *ctx) /* table clear for block compress */ argument
684 cl_hash ( (count_int) hsize, ctx );
685 ctx->free_ent = ctx->ClearCode + 2;
686 ctx->clear_flg = 1;
688 output( (code_int)ctx->ClearCode, ctx);
692 cl_hash(register count_int chsize, GifCtx *ctx) /* reset code table */ argument
696 register count_int *htab_p = ctx->htab+chsize;
736 char_init(GifCtx *ctx) argument
738 ctx->a_count = 0;
746 char_out(int c, GifCtx *ctx) argument
748 ctx->accum[ ctx->a_count++ ] = c;
749 if( ctx->a_count >= 254 )
750 flush_char(ctx);
757 flush_char(GifCtx *ctx) argument
759 if( ctx->a_count > 0 ) {
760 gdPutC( ctx->a_count, ctx->g_outfile );
761 gdPutBuf( ctx->accum, ctx->a_count, ctx->g_outfile );
762 ctx->a_count = 0;