[FFmpeg-cvslog] mpegvideoenc: fix multislice fate tests with threading disabled.

Ronald S. Bultje git at videolan.org
Sat Jun 4 06:40:00 CEST 2011


ffmpeg | branch: master | Ronald S. Bultje <rsbultje at gmail.com> | Thu Jun  2 14:24:58 2011 -0700| [83a8b3002f3399c52b3900ca2f068d51e97713ec] | committer: Ronald S. Bultje

mpegvideoenc: fix multislice fate tests with threading disabled.

The MPEG encoding code assumes that n_threads == n_slices, and thus it
should use n_slices even if threading itself is disabled.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=83a8b3002f3399c52b3900ca2f068d51e97713ec
---

 libavcodec/mpegvideo.c     |    6 +++---
 libavcodec/mpegvideo_enc.c |    4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index dfb2289..6a45da8 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -586,7 +586,7 @@ av_cold int MPV_common_init(MpegEncContext *s)
         return -1;
     }
 
-    if((s->avctx->active_thread_type & FF_THREAD_SLICE) &&
+    if((s->encoding || (s->avctx->active_thread_type & FF_THREAD_SLICE)) &&
        (s->avctx->thread_count > MAX_THREADS || (s->avctx->thread_count > s->mb_height && s->mb_height))){
         av_log(s->avctx, AV_LOG_ERROR, "too many threads\n");
         return -1;
@@ -750,7 +750,7 @@ av_cold int MPV_common_init(MpegEncContext *s)
     s->thread_context[0]= s;
 
     if (s->width && s->height) {
-    if (HAVE_THREADS && s->avctx->active_thread_type&FF_THREAD_SLICE) {
+    if (s->encoding || (HAVE_THREADS && s->avctx->active_thread_type&FF_THREAD_SLICE)) {
         threads = s->avctx->thread_count;
 
         for(i=1; i<threads; i++){
@@ -782,7 +782,7 @@ void MPV_common_end(MpegEncContext *s)
 {
     int i, j, k;
 
-    if (HAVE_THREADS && s->avctx->active_thread_type&FF_THREAD_SLICE) {
+    if (s->encoding || (HAVE_THREADS && s->avctx->active_thread_type&FF_THREAD_SLICE)) {
         for(i=0; i<s->avctx->thread_count; i++){
             free_duplicate_context(s->thread_context[i]);
         }
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 237ea64..b5a1872 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1226,7 +1226,7 @@ int MPV_encode_picture(AVCodecContext *avctx,
 {
     MpegEncContext *s = avctx->priv_data;
     AVFrame *pic_arg = data;
-    int i, stuffing_count, context_count = avctx->active_thread_type&FF_THREAD_SLICE ? avctx->thread_count : 1;
+    int i, stuffing_count, context_count = avctx->thread_count;
 
     for(i=0; i<context_count; i++){
         int start_y= s->thread_context[i]->start_mb_y;
@@ -2759,7 +2759,7 @@ static int encode_picture(MpegEncContext *s, int picture_number)
 {
     int i;
     int bits;
-    int context_count = (s->avctx->active_thread_type & FF_THREAD_SLICE) ? s->avctx->thread_count : 1;
+    int context_count = s->avctx->thread_count;
 
     s->picture_number = picture_number;
 



More information about the ffmpeg-cvslog mailing list