comparison snow.c @ 5662:77297fe0311c libavcodec

allocate slice buffer after parsing the header containing needed parameters argh i really wish i had never accepted these slice patches ...
author michael
date Sun, 09 Sep 2007 12:33:34 +0000
parents 5da86360c38b
children 4264b8bb3659
comparison
equal deleted inserted replaced
5661:5da86360c38b 5662:77297fe0311c
578 int i; 578 int i;
579 slice_buffer_flush(buf); 579 slice_buffer_flush(buf);
580 580
581 for (i = buf->data_count - 1; i >= 0; i--) 581 for (i = buf->data_count - 1; i >= 0; i--)
582 { 582 {
583 assert(buf->data_stack[i]);
584 av_freep(&buf->data_stack[i]); 583 av_freep(&buf->data_stack[i]);
585 } 584 }
586 assert(buf->data_stack);
587 av_freep(&buf->data_stack); 585 av_freep(&buf->data_stack);
588 assert(buf->line);
589 av_freep(&buf->line); 586 av_freep(&buf->line);
590 } 587 }
591 588
592 #ifdef __sgi 589 #ifdef __sgi
593 // Avoid a name clash on SGI IRIX 590 // Avoid a name clash on SGI IRIX
4396 } 4393 }
4397 4394
4398 static int decode_init(AVCodecContext *avctx) 4395 static int decode_init(AVCodecContext *avctx)
4399 { 4396 {
4400 SnowContext *s = avctx->priv_data; 4397 SnowContext *s = avctx->priv_data;
4401 int block_size;
4402 4398
4403 avctx->pix_fmt= PIX_FMT_YUV420P; 4399 avctx->pix_fmt= PIX_FMT_YUV420P;
4404 4400
4405 common_init(avctx); 4401 common_init(avctx);
4406 4402
4407 block_size = MB_SIZE >> s->block_max_depth;
4408
4409 slice_buffer_init(&s->sb, s->plane[0].height, block_size + s->spatial_decomposition_count * 8 + 1, s->plane[0].width, s->spatial_idwt_buffer);
4410 return 0; 4403 return 0;
4411 } 4404 }
4412 4405
4413 static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size){ 4406 static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size){
4414 SnowContext *s = avctx->priv_data; 4407 SnowContext *s = avctx->priv_data;
4420 ff_init_range_decoder(c, buf, buf_size); 4413 ff_init_range_decoder(c, buf, buf_size);
4421 ff_build_rac_states(c, 0.05*(1LL<<32), 256-8); 4414 ff_build_rac_states(c, 0.05*(1LL<<32), 256-8);
4422 4415
4423 s->current_picture.pict_type= FF_I_TYPE; //FIXME I vs. P 4416 s->current_picture.pict_type= FF_I_TYPE; //FIXME I vs. P
4424 decode_header(s); 4417 decode_header(s);
4418
4419 // realloc slice buffer for the case that spatial_decomposition_count changed
4420 slice_buffer_destroy(&s->sb);
4421 slice_buffer_init(&s->sb, s->plane[0].height, (MB_SIZE >> s->block_max_depth) + s->spatial_decomposition_count * 8 + 1, s->plane[0].width, s->spatial_idwt_buffer);
4425 4422
4426 for(plane_index=0; plane_index<3; plane_index++){ 4423 for(plane_index=0; plane_index<3; plane_index++){
4427 Plane *p= &s->plane[plane_index]; 4424 Plane *p= &s->plane[plane_index];
4428 p->fast_mc= p->diag_mc && p->htaps==6 && p->hcoeff[0]==40 4425 p->fast_mc= p->diag_mc && p->htaps==6 && p->hcoeff[0]==40
4429 && p->hcoeff[1]==-10 4426 && p->hcoeff[1]==-10