| 480 | } |
| 481 | |
| 482 | av_cold int ff_snow_common_init(AVCodecContext *avctx){ |
| 483 | static AVOnce init_static_once = AV_ONCE_INIT; |
| 484 | SnowContext *s = avctx->priv_data; |
| 485 | int width, height; |
| 486 | int i; |
| 487 | |
| 488 | s->avctx= avctx; |
| 489 | s->max_ref_frames=1; //just make sure it's not an invalid value in case of no initial keyframe |
| 490 | s->spatial_decomposition_count = 1; |
| 491 | |
| 492 | ff_videodsp_init(&s->vdsp, 8); |
| 493 | ff_dwt_init(&s->dwt); |
| 494 | |
| 495 | init_qpel(s); |
| 496 | |
| 497 | #define mcfh(dx,dy)\ |
| 498 | s->hdsp.put_pixels_tab [0][dy/4+dx/8]=\ |
| 499 | s->hdsp.put_no_rnd_pixels_tab[0][dy/4+dx/8]=\ |
| 500 | mc_block_hpel ## dx ## dy ## 16;\ |
| 501 | s->hdsp.put_pixels_tab [1][dy/4+dx/8]=\ |
| 502 | s->hdsp.put_no_rnd_pixels_tab[1][dy/4+dx/8]=\ |
| 503 | mc_block_hpel ## dx ## dy ## 8; |
| 504 | |
| 505 | mcfh(0, 0) |
| 506 | mcfh(8, 0) |
| 507 | mcfh(0, 8) |
| 508 | mcfh(8, 8) |
| 509 | |
| 510 | // dec += FFMAX(s->chroma_h_shift, s->chroma_v_shift); |
| 511 | |
| 512 | width= s->avctx->width; |
| 513 | height= s->avctx->height; |
| 514 | |
| 515 | if (!FF_ALLOCZ_TYPED_ARRAY(s->spatial_idwt_buffer, width * height) || |
| 516 | !FF_ALLOCZ_TYPED_ARRAY(s->spatial_dwt_buffer, width * height) || //FIXME this does not belong here |
| 517 | !FF_ALLOCZ_TYPED_ARRAY(s->temp_dwt_buffer, width) || |
| 518 | !FF_ALLOCZ_TYPED_ARRAY(s->temp_idwt_buffer, width) || |
| 519 | !FF_ALLOCZ_TYPED_ARRAY(s->run_buffer, ((width + 1) >> 1) * ((height + 1) >> 1) + 1)) |
| 520 | return AVERROR(ENOMEM); |
| 521 | |
| 522 | for(i=0; i<MAX_REF_FRAMES; i++) { |
| 523 | s->last_picture[i] = av_frame_alloc(); |
| 524 | if (!s->last_picture[i]) |
| 525 | return AVERROR(ENOMEM); |
| 526 | } |
| 527 | |
| 528 | s->mconly_picture = av_frame_alloc(); |
| 529 | s->current_picture = av_frame_alloc(); |
| 530 | if (!s->mconly_picture || !s->current_picture) |
| 531 | return AVERROR(ENOMEM); |
| 532 | |
| 533 | ff_thread_once(&init_static_once, snow_static_init); |
| 534 | |
| 535 | return 0; |
| 536 | } |
| 537 | |
| 538 | int ff_snow_common_init_after_header(AVCodecContext *avctx) { |
| 539 | SnowContext *s = avctx->priv_data; |
no test coverage detected