From 189db9c9829b970b3e28006c9f00d6960f71cff1 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 26 May 2011 01:55:12 +0200 Subject: [PATCH] ffv1: fix 16bits multithreading fixes ticket237 Signed-off-by: Michael Niedermayer --- libavcodec/ffv1.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 4e0e5f7b62..a0a4a1d009 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -1146,6 +1146,7 @@ static int encode_slice(AVCodecContext *c, void *arg){ int x= fs->slice_x; int y= fs->slice_y; AVFrame * const p= &f->picture; + const int ps= (c->bits_per_raw_sample>8)+1; if(f->colorspace==0){ const int chroma_width = -((-width )>>f->chroma_h_shift); @@ -1153,12 +1154,12 @@ static int encode_slice(AVCodecContext *c, void *arg){ const int cx= x>>f->chroma_h_shift; const int cy= y>>f->chroma_v_shift; - encode_plane(fs, p->data[0] + x + y*p->linesize[0], width, height, p->linesize[0], 0); + encode_plane(fs, p->data[0] + ps*x + y*p->linesize[0], width, height, p->linesize[0], 0); - encode_plane(fs, p->data[1] + cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1); - encode_plane(fs, p->data[2] + cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1); + encode_plane(fs, p->data[1] + ps*cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1); + encode_plane(fs, p->data[2] + ps*cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1); }else{ - encode_rgb_frame(fs, (uint32_t*)(p->data[0]) + x + y*(p->linesize[0]/4), width, height, p->linesize[0]/4); + encode_rgb_frame(fs, (uint32_t*)(p->data[0]) + ps*x + y*(p->linesize[0]/4), width, height, p->linesize[0]/4); } emms_c(); @@ -1475,6 +1476,7 @@ static int decode_slice(AVCodecContext *c, void *arg){ int height= fs->slice_height; int x= fs->slice_x; int y= fs->slice_y; + const int ps= (c->bits_per_raw_sample>8)+1; AVFrame * const p= &f->picture; av_assert1(width && height); @@ -1483,12 +1485,12 @@ static int decode_slice(AVCodecContext *c, void *arg){ const int chroma_height= -((-height)>>f->chroma_v_shift); const int cx= x>>f->chroma_h_shift; const int cy= y>>f->chroma_v_shift; - decode_plane(fs, p->data[0] + x + y*p->linesize[0], width, height, p->linesize[0], 0); + decode_plane(fs, p->data[0] + ps*x + y*p->linesize[0], width, height, p->linesize[0], 0); - decode_plane(fs, p->data[1] + cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1); - decode_plane(fs, p->data[2] + cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[2], 1); + decode_plane(fs, p->data[1] + ps*cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1); + decode_plane(fs, p->data[2] + ps*cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[2], 1); }else{ - decode_rgb_frame(fs, (uint32_t*)p->data[0] + x + y*(p->linesize[0]/4), width, height, p->linesize[0]/4); + decode_rgb_frame(fs, (uint32_t*)p->data[0] + ps*x + y*(p->linesize[0]/4), width, height, p->linesize[0]/4); } emms_c();