Originally committed as revision 2366 to svn://svn.ffmpeg.org/ffmpeg/trunktags/v0.5
| @@ -904,7 +904,7 @@ static int AC3_encode_init(AVCodecContext *avctx) | |||||
| /* output the AC3 frame header */ | /* output the AC3 frame header */ | ||||
| static void output_frame_header(AC3EncodeContext *s, unsigned char *frame) | static void output_frame_header(AC3EncodeContext *s, unsigned char *frame) | ||||
| { | { | ||||
| init_put_bits(&s->pb, frame, AC3_MAX_CODED_FRAME_SIZE, NULL, NULL); | |||||
| init_put_bits(&s->pb, frame, AC3_MAX_CODED_FRAME_SIZE); | |||||
| put_bits(&s->pb, 16, 0x0b77); /* frame header */ | put_bits(&s->pb, 16, 0x0b77); /* frame header */ | ||||
| put_bits(&s->pb, 16, 0); /* crc1: will be filled later */ | put_bits(&s->pb, 16, 0); /* crc1: will be filled later */ | ||||
| @@ -488,7 +488,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, | |||||
| int size; | int size; | ||||
| int mb_x, mb_y; | int mb_x, mb_y; | ||||
| init_put_bits(&a->pb, buf, buf_size, NULL, NULL); | |||||
| init_put_bits(&a->pb, buf, buf_size); | |||||
| *p = *pict; | *p = *pict; | ||||
| p->pict_type= I_TYPE; | p->pict_type= I_TYPE; | ||||
| @@ -74,7 +74,7 @@ const uint8_t ff_h264_lps_state[64]= { | |||||
| * @param buf_size size of buf in bits | * @param buf_size size of buf in bits | ||||
| */ | */ | ||||
| void ff_init_cabac_encoder(CABACContext *c, uint8_t *buf, int buf_size){ | void ff_init_cabac_encoder(CABACContext *c, uint8_t *buf, int buf_size){ | ||||
| init_put_bits(&c->pb, buf, buf_size, NULL, NULL); | |||||
| init_put_bits(&c->pb, buf, buf_size); | |||||
| c->low= 0; | c->low= 0; | ||||
| c->range= 0x1FE; | c->range= 0x1FE; | ||||
| @@ -44,18 +44,11 @@ const uint8_t ff_log2_tab[256]={ | |||||
| 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 | 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 | ||||
| }; | }; | ||||
| void init_put_bits(PutBitContext *s, | |||||
| uint8_t *buffer, int buffer_size, | |||||
| void *opaque, | |||||
| void (*write_data)(void *, uint8_t *, int)) | |||||
| void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size) | |||||
| { | { | ||||
| s->buf = buffer; | s->buf = buffer; | ||||
| s->buf_end = s->buf + buffer_size; | s->buf_end = s->buf + buffer_size; | ||||
| s->data_out_size = 0; | s->data_out_size = 0; | ||||
| if(write_data!=NULL) | |||||
| { | |||||
| fprintf(stderr, "write Data callback is not supported\n"); | |||||
| } | |||||
| #ifdef ALT_BITSTREAM_WRITER | #ifdef ALT_BITSTREAM_WRITER | ||||
| s->index=0; | s->index=0; | ||||
| ((uint32_t*)(s->buf))[0]=0; | ((uint32_t*)(s->buf))[0]=0; | ||||
| @@ -261,10 +261,7 @@ typedef struct PutBitContext { | |||||
| int64_t data_out_size; /* in bytes */ | int64_t data_out_size; /* in bytes */ | ||||
| } PutBitContext; | } PutBitContext; | ||||
| void init_put_bits(PutBitContext *s, | |||||
| uint8_t *buffer, int buffer_size, | |||||
| void *opaque, | |||||
| void (*write_data)(void *, uint8_t *, int)); | |||||
| void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size); | |||||
| int64_t get_bit_count(PutBitContext *s); /* XXX: change function name */ | int64_t get_bit_count(PutBitContext *s); /* XXX: change function name */ | ||||
| void align_put_bits(PutBitContext *s); | void align_put_bits(PutBitContext *s); | ||||
| @@ -344,13 +344,13 @@ static inline void dv_decode_video_segment(DVVideoDecodeContext *s, | |||||
| buf_ptr = buf_ptr1; | buf_ptr = buf_ptr1; | ||||
| block1 = &s->block[0][0]; | block1 = &s->block[0][0]; | ||||
| mb1 = mb_data; | mb1 = mb_data; | ||||
| init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80, NULL, NULL); | |||||
| init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80); | |||||
| vs_bit_count = 0; | vs_bit_count = 0; | ||||
| for(mb_index = 0; mb_index < 5; mb_index++) { | for(mb_index = 0; mb_index < 5; mb_index++) { | ||||
| /* skip header */ | /* skip header */ | ||||
| quant = buf_ptr[3] & 0x0f; | quant = buf_ptr[3] & 0x0f; | ||||
| buf_ptr += 4; | buf_ptr += 4; | ||||
| init_put_bits(&pb, mb_bit_buffer, 80, NULL, NULL); | |||||
| init_put_bits(&pb, mb_bit_buffer, 80); | |||||
| mb_bit_count = 0; | mb_bit_count = 0; | ||||
| mb = mb1; | mb = mb1; | ||||
| block = block1; | block = block1; | ||||
| @@ -758,13 +758,13 @@ encode_vs: | |||||
| uint8_t* p = dif + i*80 + 4; | uint8_t* p = dif + i*80 + 4; | ||||
| for (j=0; j<6; j++) { | for (j=0; j<6; j++) { | ||||
| enc_blk->qno = QNO; | enc_blk->qno = QNO; | ||||
| init_put_bits(&enc_blk->pb, p, block_sizes[j]/8, NULL, NULL); | |||||
| init_put_bits(&enc_blk->pb, p, block_sizes[j]/8); | |||||
| enc_blk++; | enc_blk++; | ||||
| p += block_sizes[j]/8; | p += block_sizes[j]/8; | ||||
| } | } | ||||
| } | } | ||||
| init_put_bits(&extra_vs, extra_vs_data, sizeof(extra_vs_data), NULL, NULL); | |||||
| init_put_bits(&extra_vs, extra_vs_data, sizeof(extra_vs_data)); | |||||
| free_vs_bits = 0; | free_vs_bits = 0; | ||||
| enc_blk = &enc_blks[0]; | enc_blk = &enc_blks[0]; | ||||
| for (i=0; i<5; i++) { | for (i=0; i<5; i++) { | ||||
| @@ -772,7 +772,7 @@ encode_vs: | |||||
| EncBlockInfo* enc_blk2 = enc_blk; | EncBlockInfo* enc_blk2 = enc_blk; | ||||
| int free_mb_bits = 0; | int free_mb_bits = 0; | ||||
| init_put_bits(&extra_mb, extra_mb_data, sizeof(extra_mb_data), NULL, NULL); | |||||
| init_put_bits(&extra_mb, extra_mb_data, sizeof(extra_mb_data)); | |||||
| dif[i*80 + 3] = enc_blk->qno; | dif[i*80 + 3] = enc_blk->qno; | ||||
| for (j=0; j<6; j++) { | for (j=0; j<6; j++) { | ||||
| @@ -599,7 +599,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, | |||||
| if(!f->ac){ | if(!f->ac){ | ||||
| used_count += put_cabac_terminate(c, 1); | used_count += put_cabac_terminate(c, 1); | ||||
| //printf("pos=%d\n", used_count); | //printf("pos=%d\n", used_count); | ||||
| init_put_bits(&f->pb, buf + used_count, buf_size - used_count, NULL, NULL); | |||||
| init_put_bits(&f->pb, buf + used_count, buf_size - used_count); | |||||
| } | } | ||||
| if(1){ | if(1){ | ||||
| @@ -1709,7 +1709,7 @@ void h263_encode_init(MpegEncContext *s) | |||||
| if(s->flags & CODEC_FLAG_GLOBAL_HEADER){ | if(s->flags & CODEC_FLAG_GLOBAL_HEADER){ | ||||
| s->avctx->extradata= av_malloc(1024); | s->avctx->extradata= av_malloc(1024); | ||||
| init_put_bits(&s->pb, s->avctx->extradata, 1024, NULL, NULL); | |||||
| init_put_bits(&s->pb, s->avctx->extradata, 1024); | |||||
| mpeg4_encode_visual_object_header(s); | mpeg4_encode_visual_object_header(s); | ||||
| mpeg4_encode_vol_header(s, 0, 0); | mpeg4_encode_vol_header(s, 0, 0); | ||||
| @@ -2612,8 +2612,8 @@ static inline void memsetw(short *tab, int val, int n) | |||||
| void ff_mpeg4_init_partitions(MpegEncContext *s) | void ff_mpeg4_init_partitions(MpegEncContext *s) | ||||
| { | { | ||||
| init_put_bits(&s->tex_pb, s->tex_pb_buffer, PB_BUFFER_SIZE, NULL, NULL); | |||||
| init_put_bits(&s->pb2 , s->pb2_buffer , PB_BUFFER_SIZE, NULL, NULL); | |||||
| init_put_bits(&s->tex_pb, s->tex_pb_buffer, PB_BUFFER_SIZE); | |||||
| init_put_bits(&s->pb2 , s->pb2_buffer , PB_BUFFER_SIZE); | |||||
| } | } | ||||
| void ff_mpeg4_merge_partitions(MpegEncContext *s) | void ff_mpeg4_merge_partitions(MpegEncContext *s) | ||||
| @@ -4231,7 +4231,7 @@ int main(){ | |||||
| dsputil_init(&dsp, &avctx); | dsputil_init(&dsp, &avctx); | ||||
| init_put_bits(&pb, temp, SIZE, NULL, NULL); | |||||
| init_put_bits(&pb, temp, SIZE); | |||||
| printf("testing unsigned exp golomb\n"); | printf("testing unsigned exp golomb\n"); | ||||
| for(i=0; i<COUNT; i++){ | for(i=0; i<COUNT; i++){ | ||||
| START_TIMER | START_TIMER | ||||
| @@ -958,7 +958,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, | |||||
| AVFrame * const p= &s->picture; | AVFrame * const p= &s->picture; | ||||
| int i, size; | int i, size; | ||||
| init_put_bits(&s->pb, buf, buf_size, NULL, NULL); | |||||
| init_put_bits(&s->pb, buf, buf_size); | |||||
| *p = *pict; | *p = *pict; | ||||
| p->pict_type= FF_I_TYPE; | p->pict_type= FF_I_TYPE; | ||||
| @@ -661,7 +661,7 @@ static int encode_picture_lossless(AVCodecContext *avctx, unsigned char *buf, in | |||||
| AVFrame * const p= (AVFrame*)&s->current_picture; | AVFrame * const p= (AVFrame*)&s->current_picture; | ||||
| const int predictor= avctx->prediction_method+1; | const int predictor= avctx->prediction_method+1; | ||||
| init_put_bits(&s->pb, buf, buf_size, NULL, NULL); | |||||
| init_put_bits(&s->pb, buf, buf_size); | |||||
| *p = *pict; | *p = *pict; | ||||
| p->pict_type= FF_I_TYPE; | p->pict_type= FF_I_TYPE; | ||||
| @@ -765,7 +765,7 @@ static int MPA_encode_frame(AVCodecContext *avctx, | |||||
| } | } | ||||
| compute_bit_allocation(s, smr, bit_alloc, &padding); | compute_bit_allocation(s, smr, bit_alloc, &padding); | ||||
| init_put_bits(&s->pb, frame, MPA_MAX_CODED_FRAME_SIZE, NULL, NULL); | |||||
| init_put_bits(&s->pb, frame, MPA_MAX_CODED_FRAME_SIZE); | |||||
| encode_frame(s, bit_alloc, padding); | encode_frame(s, bit_alloc, padding); | ||||
| @@ -1601,7 +1601,7 @@ int MPV_encode_picture(AVCodecContext *avctx, | |||||
| return -1; | return -1; | ||||
| } | } | ||||
| init_put_bits(&s->pb, buf, buf_size, NULL, NULL); | |||||
| init_put_bits(&s->pb, buf, buf_size); | |||||
| s->picture_in_gop_number++; | s->picture_in_gop_number++; | ||||
| @@ -3326,9 +3326,9 @@ static void encode_picture(MpegEncContext *s, int picture_number) | |||||
| PutBitContext pb[2], pb2[2], tex_pb[2]; | PutBitContext pb[2], pb2[2], tex_pb[2]; | ||||
| for(i=0; i<2; i++){ | for(i=0; i<2; i++){ | ||||
| init_put_bits(&pb [i], bit_buf [i], 3000, NULL, NULL); | |||||
| init_put_bits(&pb2 [i], bit_buf2 [i], 3000, NULL, NULL); | |||||
| init_put_bits(&tex_pb[i], bit_buf_tex[i], 3000, NULL, NULL); | |||||
| init_put_bits(&pb [i], bit_buf [i], 3000); | |||||
| init_put_bits(&pb2 [i], bit_buf2 [i], 3000); | |||||
| init_put_bits(&tex_pb[i], bit_buf_tex[i], 3000); | |||||
| } | } | ||||
| s->picture_number = picture_number; | s->picture_number = picture_number; | ||||