Commit a7494872 authored by Zuxy Meng's avatar Zuxy Meng

Reduce stack usage in svq1_encode_plane(). Reuse context scratch buffer

instead.  Avoid a crash on MinGW.

Originally committed as revision 21162 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 56e29bf2
...@@ -269,6 +269,7 @@ static int svq1_encode_plane(SVQ1Context *s, int plane, unsigned char *src_plane ...@@ -269,6 +269,7 @@ static int svq1_encode_plane(SVQ1Context *s, int plane, unsigned char *src_plane
int block_width, block_height; int block_width, block_height;
int level; int level;
int threshold[6]; int threshold[6];
uint8_t *src = s->scratchbuf + stride * 16;
const int lambda= (s->picture.quality*s->picture.quality) >> (2*FF_LAMBDA_SHIFT); const int lambda= (s->picture.quality*s->picture.quality) >> (2*FF_LAMBDA_SHIFT);
/* figure out the acceptable level thresholds in advance */ /* figure out the acceptable level thresholds in advance */
...@@ -327,8 +328,6 @@ static int svq1_encode_plane(SVQ1Context *s, int plane, unsigned char *src_plane ...@@ -327,8 +328,6 @@ static int svq1_encode_plane(SVQ1Context *s, int plane, unsigned char *src_plane
s->m.me.dia_size= s->avctx->dia_size; s->m.me.dia_size= s->avctx->dia_size;
s->m.first_slice_line=1; s->m.first_slice_line=1;
for (y = 0; y < block_height; y++) { for (y = 0; y < block_height; y++) {
uint8_t src[stride*16];
s->m.new_picture.data[0]= src - y*16*stride; //ugly s->m.new_picture.data[0]= src - y*16*stride; //ugly
s->m.mb_y= y; s->m.mb_y= y;
...@@ -356,8 +355,6 @@ static int svq1_encode_plane(SVQ1Context *s, int plane, unsigned char *src_plane ...@@ -356,8 +355,6 @@ static int svq1_encode_plane(SVQ1Context *s, int plane, unsigned char *src_plane
s->m.first_slice_line=1; s->m.first_slice_line=1;
for (y = 0; y < block_height; y++) { for (y = 0; y < block_height; y++) {
uint8_t src[stride*16];
for(i=0; i<16 && i + 16*y<height; i++){ for(i=0; i<16 && i + 16*y<height; i++){
memcpy(&src[i*stride], &src_plane[(i+16*y)*src_stride], width); memcpy(&src[i*stride], &src_plane[(i+16*y)*src_stride], width);
for(x=width; x<16*block_width; x++) for(x=width; x<16*block_width; x++)
...@@ -521,7 +518,7 @@ static int svq1_encode_frame(AVCodecContext *avctx, unsigned char *buf, ...@@ -521,7 +518,7 @@ static int svq1_encode_frame(AVCodecContext *avctx, unsigned char *buf,
if(!s->current_picture.data[0]){ if(!s->current_picture.data[0]){
avctx->get_buffer(avctx, &s->current_picture); avctx->get_buffer(avctx, &s->current_picture);
avctx->get_buffer(avctx, &s->last_picture); avctx->get_buffer(avctx, &s->last_picture);
s->scratchbuf = av_malloc(s->current_picture.linesize[0] * 16); s->scratchbuf = av_malloc(s->current_picture.linesize[0] * 16 * 2);
} }
temp= s->current_picture; temp= s->current_picture;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment