Commit 2cbd734a authored by Måns Rullgård's avatar Måns Rullgård

Maybe fix threaded mpeg*video encoding

This allocates per-thread copies of some MpegEncContext.ac_val which
is used concurrently from the encoding threads.

Originally committed as revision 23933 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 16bfbfd0
...@@ -356,6 +356,9 @@ static void free_picture(MpegEncContext *s, Picture *pic){ ...@@ -356,6 +356,9 @@ static void free_picture(MpegEncContext *s, Picture *pic){
} }
static int init_duplicate_context(MpegEncContext *s, MpegEncContext *base){ static int init_duplicate_context(MpegEncContext *s, MpegEncContext *base){
int y_size = s->b8_stride * (2 * s->mb_height + 1);
int c_size = s->mb_stride * (s->mb_height + 1);
int yc_size = y_size + 2 * c_size;
int i; int i;
// edge emu needs blocksize + filter length - 1 (=17x17 for halfpel / 21x21 for h264) // edge emu needs blocksize + filter length - 1 (=17x17 for halfpel / 21x21 for h264)
...@@ -381,6 +384,14 @@ static int init_duplicate_context(MpegEncContext *s, MpegEncContext *base){ ...@@ -381,6 +384,14 @@ static int init_duplicate_context(MpegEncContext *s, MpegEncContext *base){
for(i=0;i<12;i++){ for(i=0;i<12;i++){
s->pblocks[i] = &s->block[i]; s->pblocks[i] = &s->block[i];
} }
if (s->ac_val_base) {
FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_val_base, yc_size * sizeof(int16_t) * 16, fail);
s->ac_val[0] = s->ac_val_base + s->b8_stride + 1;
s->ac_val[1] = s->ac_val_base + y_size + s->mb_stride + 1;
s->ac_val[2] = s->ac_val[1] + c_size;
}
return 0; return 0;
fail: fail:
return -1; //free() through MPV_common_end() return -1; //free() through MPV_common_end()
...@@ -400,6 +411,7 @@ static void free_duplicate_context(MpegEncContext *s){ ...@@ -400,6 +411,7 @@ static void free_duplicate_context(MpegEncContext *s){
av_freep(&s->me.map); av_freep(&s->me.map);
av_freep(&s->me.score_map); av_freep(&s->me.score_map);
av_freep(&s->blocks); av_freep(&s->blocks);
av_freep(&s->ac_val_base);
s->block= NULL; s->block= NULL;
} }
...@@ -423,6 +435,10 @@ static void backup_duplicate_context(MpegEncContext *bak, MpegEncContext *src){ ...@@ -423,6 +435,10 @@ static void backup_duplicate_context(MpegEncContext *bak, MpegEncContext *src){
COPY(dct_error_sum); COPY(dct_error_sum);
COPY(dct_count[0]); COPY(dct_count[0]);
COPY(dct_count[1]); COPY(dct_count[1]);
COPY(ac_val_base);
COPY(ac_val[0]);
COPY(ac_val[1]);
COPY(ac_val[2]);
#undef COPY #undef COPY
} }
......
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