Revision 81ada1ce libavcodec/common.h

View differences:

libavcodec/common.h
108 108
typedef signed long long INT64;
109 109

  
110 110
#    ifdef HAVE_AV_CONFIG_H
111

  
112 111
#        ifndef INT64_C
113 112
#            define INT64_C(c)     (c ## LL)
114 113
#            define UINT64_C(c)    (c ## ULL)
......
117 116
#        ifdef USE_FASTMEMCPY
118 117
#            include "fastmemcpy.h"
119 118
#        endif
120

  
121 119
#    endif /* HAVE_AV_CONFIG_H */
122 120

  
123 121
#endif /* !CONFIG_WIN32 */
......
220 218
void flush_put_bits(PutBitContext *s);
221 219
void put_string(PutBitContext * pbc, char *s);
222 220

  
223
/* jpeg specific put_bits */
224
void jflush_put_bits(PutBitContext *s);
225

  
226 221
/* bit input */
227 222

  
228 223
typedef struct GetBitContext {
......
383 378
}
384 379
#endif
385 380

  
386
#ifndef ALT_BITSTREAM_WRITER
387
/* for jpeg : escape 0xff with 0x00 after it */
388
static inline void jput_bits(PutBitContext *s, int n, unsigned int value)
389
{
390
    unsigned int bit_buf, b;
391
    int bit_left, i;
392
    
393
    assert(n == 32 || value < (1U << n));
394

  
395
    bit_buf = s->bit_buf;
396
    bit_left = s->bit_left;
397

  
398
    //printf("n=%d value=%x cnt=%d buf=%x\n", n, value, bit_cnt, bit_buf);
399
    /* XXX: optimize */
400
    if (n < bit_left) {
401
        bit_buf = (bit_buf<<n) | value;
402
        bit_left-=n;
403
    } else {
404
	bit_buf<<=bit_left;
405
        bit_buf |= value >> (n - bit_left);
406
        /* handle escape */
407
        for(i=0;i<4;i++) {
408
            b = (bit_buf >> 24);
409
            *(s->buf_ptr++) = b;
410
            if (b == 0xff)
411
                *(s->buf_ptr++) = 0;
412
            bit_buf <<= 8;
413
        }
414

  
415
	bit_left+= 32 - n;
416
        bit_buf = value;
417
    }
418
    
419
    s->bit_buf = bit_buf;
420
    s->bit_left = bit_left;
421
}
422
#endif
423

  
424

  
425
#ifdef ALT_BITSTREAM_WRITER
426
static inline void jput_bits(PutBitContext *s, int n, int value)
427
{
428
    int index= s->index;
429
    uint32_t *ptr= (uint32_t*)(((uint8_t *)s->buf)+(index>>3));
430
    int v= ptr[0];
431
//if(n>24) printf("%d %d\n", n, value);
432
    
433
    v |= be2me_32(value<<(32-n-(index&7) ));
434
    if(((v+0x01010101)^0xFFFFFFFF)&v&0x80808080)
435
    {
436
	/* handle idiotic (m)jpeg escapes */
437
	uint8_t *bPtr= (uint8_t*)ptr;
438
	int numChecked= ((index+n)>>3) - (index>>3);
439
	
440
	v= be2me_32(v);
441

  
442
	*(bPtr++)= v>>24;
443
	if((v&0xFF000000)==0xFF000000 && numChecked>0){
444
		*(bPtr++)= 0x00;
445
		index+=8;
446
	}
447
	*(bPtr++)= (v>>16)&0xFF;
448
	if((v&0x00FF0000)==0x00FF0000 && numChecked>1){
449
		*(bPtr++)= 0x00;
450
		index+=8;
451
	}
452
	*(bPtr++)= (v>>8)&0xFF;
453
	if((v&0x0000FF00)==0x0000FF00 && numChecked>2){
454
		*(bPtr++)= 0x00;
455
		index+=8;
456
	}
457
	*(bPtr++)= v&0xFF;
458
	if((v&0x000000FF)==0x000000FF && numChecked>3){
459
		*(bPtr++)= 0x00;
460
		index+=8;
461
	}
462
	*((uint32_t*)bPtr)= 0;
463
    }
464
    else
465
    {
466
	ptr[0] = v;
467
	ptr[1] = 0;
468
    }
469

  
470
    index+= n;
471
    s->index= index;
472
 }
473
#endif
474 381

  
475 382
static inline uint8_t* pbBufPtr(PutBitContext *s)
476 383
{

Also available in: Unified diff