Mercurial > libavcodec.hg
comparison svq1enc.c @ 8211:b9e82845e7eb libavcodec
svq1enc: move scratch buffer from stack to context to ensure alignment
author | mru |
---|---|
date | Mon, 24 Nov 2008 19:08:02 +0000 |
parents | e943e1409077 |
children | 7a463923ecd1 |
comparison
equal
deleted
inserted
replaced
8210:e1f9d8919cb5 | 8211:b9e82845e7eb |
---|---|
65 uint32_t *dummy; | 65 uint32_t *dummy; |
66 int16_t (*motion_val8[3])[2]; | 66 int16_t (*motion_val8[3])[2]; |
67 int16_t (*motion_val16[3])[2]; | 67 int16_t (*motion_val16[3])[2]; |
68 | 68 |
69 int64_t rd_total; | 69 int64_t rd_total; |
70 | |
71 uint8_t *scratchbuf; | |
70 } SVQ1Context; | 72 } SVQ1Context; |
71 | 73 |
72 static void svq1_write_header(SVQ1Context *s, int frame_type) | 74 static void svq1_write_header(SVQ1Context *s, int frame_type) |
73 { | 75 { |
74 int i; | 76 int i; |
376 int count[3][6]; | 378 int count[3][6]; |
377 int offset = y * 16 * stride + x * 16; | 379 int offset = y * 16 * stride + x * 16; |
378 uint8_t *decoded= decoded_plane + offset; | 380 uint8_t *decoded= decoded_plane + offset; |
379 uint8_t *ref= ref_plane + offset; | 381 uint8_t *ref= ref_plane + offset; |
380 int score[4]={0,0,0,0}, best; | 382 int score[4]={0,0,0,0}, best; |
381 uint8_t temp[16*stride]; | 383 uint8_t *temp = s->scratchbuf; |
382 | 384 |
383 if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < 3000){ //FIXME check size | 385 if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < 3000){ //FIXME check size |
384 av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n"); | 386 av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n"); |
385 return -1; | 387 return -1; |
386 } | 388 } |
522 } | 524 } |
523 | 525 |
524 if(!s->current_picture.data[0]){ | 526 if(!s->current_picture.data[0]){ |
525 avctx->get_buffer(avctx, &s->current_picture); | 527 avctx->get_buffer(avctx, &s->current_picture); |
526 avctx->get_buffer(avctx, &s->last_picture); | 528 avctx->get_buffer(avctx, &s->last_picture); |
529 s->scratchbuf = av_malloc(s->current_picture.linesize[0] * 16); | |
527 } | 530 } |
528 | 531 |
529 temp= s->current_picture; | 532 temp= s->current_picture; |
530 s->current_picture= s->last_picture; | 533 s->current_picture= s->last_picture; |
531 s->last_picture= temp; | 534 s->last_picture= temp; |
564 av_freep(&s->m.me.scratchpad); | 567 av_freep(&s->m.me.scratchpad); |
565 av_freep(&s->m.me.map); | 568 av_freep(&s->m.me.map); |
566 av_freep(&s->m.me.score_map); | 569 av_freep(&s->m.me.score_map); |
567 av_freep(&s->mb_type); | 570 av_freep(&s->mb_type); |
568 av_freep(&s->dummy); | 571 av_freep(&s->dummy); |
572 av_freep(&s->scratchbuf); | |
569 | 573 |
570 for(i=0; i<3; i++){ | 574 for(i=0; i<3; i++){ |
571 av_freep(&s->motion_val8[i]); | 575 av_freep(&s->motion_val8[i]); |
572 av_freep(&s->motion_val16[i]); | 576 av_freep(&s->motion_val16[i]); |
573 } | 577 } |