[FFmpeg-cvslog] Merge commit 'e0652795292223f8bc8e5bac019c1fca7323d23c'

Clément Bœsch git at videolan.org
Tue Jun 21 10:24:49 CEST 2016


ffmpeg | branch: master | Clément Bœsch <clement at stupeflix.com> | Tue Jun 21 10:19:13 2016 +0200| [04aefe205b285a07646c99a834dcea04cd8a0110] | committer: Clément Bœsch

Merge commit 'e0652795292223f8bc8e5bac019c1fca7323d23c'

* commit 'e0652795292223f8bc8e5bac019c1fca7323d23c':
  h264: remove an artificial restriction on the number of slice threads

Tested with multiple runs of fate-h264 THREADS=50 THREAD_TYPE=slice

Merged-by: Clément Bœsch <clement at stupeflix.com>

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

 libavcodec/h264.c       |    7 ++-----
 libavcodec/h264.h       |    3 ---
 libavcodec/h264_slice.c |   18 +-----------------
 3 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 9d2caba..9292168 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -312,7 +312,6 @@ static int h264_init_context(AVCodecContext *avctx, H264Context *h)
     h->cur_chroma_format_idc = -1;
 
     h->picture_structure     = PICT_FRAME;
-    h->slice_context_count   = 1;
     h->workaround_bugs       = avctx->workaround_bugs;
     h->flags                 = avctx->flags;
     h->poc.prev_poc_msb      = 1 << 16;
@@ -330,7 +329,7 @@ static int h264_init_context(AVCodecContext *avctx, H264Context *h)
 
     avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
 
-    h->nb_slice_ctx = (avctx->active_thread_type & FF_THREAD_SLICE) ?  H264_MAX_THREADS : 1;
+    h->nb_slice_ctx = (avctx->active_thread_type & FF_THREAD_SLICE) ? avctx->thread_count : 1;
     h->slice_ctx = av_mallocz_array(h->nb_slice_ctx, sizeof(*h->slice_ctx));
     if (!h->slice_ctx) {
         h->nb_slice_ctx = 0;
@@ -883,9 +882,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size)
 
     h->nal_unit_type= 0;
 
-    if(!h->slice_context_count)
-         h->slice_context_count= 1;
-    h->max_contexts = h->slice_context_count;
+    h->max_contexts = h->nb_slice_ctx;
     if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS)) {
         h->current_slice = 0;
         if (!h->first_field)
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index 8e92f62..c4d2921 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -49,7 +49,6 @@
 #include "videodsp.h"
 
 #define H264_MAX_PICTURE_COUNT 36
-#define H264_MAX_THREADS       32
 
 #define MAX_SPS_COUNT          32
 #define MAX_PPS_COUNT         256
@@ -623,8 +622,6 @@ typedef struct H264Context {
      */
     int max_contexts;
 
-    int slice_context_count;
-
     /**
      *  1 if the single thread fallback warning has already been
      *  displayed, 0 otherwise.
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index ccc7e65..6e7b940 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -917,9 +917,6 @@ static int init_dimensions(H264Context *h)
 static int h264_slice_header_init(H264Context *h)
 {
     const SPS *sps = h->ps.sps;
-    int nb_slices = (HAVE_THREADS &&
-                     h->avctx->active_thread_type & FF_THREAD_SLICE) ?
-                    h->avctx->thread_count : 1;
     int i, ret;
 
     ff_set_sar(h->avctx, sps->sar);
@@ -981,19 +978,6 @@ static int h264_slice_header_init(H264Context *h)
                       sps->chroma_format_idc);
     ff_videodsp_init(&h->vdsp, sps->bit_depth_luma);
 
-    if (nb_slices > H264_MAX_THREADS || (nb_slices > h->mb_height && h->mb_height)) {
-        int max_slices;
-        if (h->mb_height)
-            max_slices = FFMIN(H264_MAX_THREADS, h->mb_height);
-        else
-            max_slices = H264_MAX_THREADS;
-        av_log(h->avctx, AV_LOG_WARNING, "too many threads/slices %d,"
-               " reducing to %d\n", nb_slices, max_slices);
-        nb_slices = max_slices;
-    }
-    h->slice_context_count = nb_slices;
-    h->max_contexts = FFMIN(h->max_contexts, nb_slices);
-
     if (!HAVE_THREADS || !(h->avctx->active_thread_type & FF_THREAD_SLICE)) {
         ret = ff_h264_slice_context_init(h, &h->slice_ctx[0]);
         if (ret < 0) {
@@ -1001,7 +985,7 @@ static int h264_slice_header_init(H264Context *h)
             goto fail;
         }
     } else {
-        for (i = 0; i < h->slice_context_count; i++) {
+        for (i = 0; i < h->nb_slice_ctx; i++) {
             H264SliceContext *sl = &h->slice_ctx[i];
 
             sl->h264               = h;


======================================================================

diff --cc libavcodec/h264.c
index 9d2caba,b8dfbf6..9292168
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@@ -305,14 -283,8 +305,13 @@@ static int h264_init_context(AVCodecCon
      int i;
  
      h->avctx                 = avctx;
 +    h->backup_width          = -1;
 +    h->backup_height         = -1;
 +    h->backup_pix_fmt        = AV_PIX_FMT_NONE;
 +    h->current_sps_id        = -1;
 +    h->cur_chroma_format_idc = -1;
  
      h->picture_structure     = PICT_FRAME;
-     h->slice_context_count   = 1;
      h->workaround_bugs       = avctx->workaround_bugs;
      h->flags                 = avctx->flags;
      h->poc.prev_poc_msb      = 1 << 16;
@@@ -878,14 -806,9 +877,12 @@@ static int decode_nal_units(H264Contex
      AVCodecContext *const avctx = h->avctx;
      unsigned context_count = 0;
      int nals_needed = 0; ///< number of NALs that need decoding before the next frame thread starts
 +    int idr_cleared=0;
      int i, ret = 0;
  
 +    h->nal_unit_type= 0;
 +
-     if(!h->slice_context_count)
-          h->slice_context_count= 1;
-     h->max_contexts = h->slice_context_count;
+     h->max_contexts = h->nb_slice_ctx;
      if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS)) {
          h->current_slice = 0;
          if (!h->first_field)
diff --cc libavcodec/h264.h
index 8e92f62,cb38664..c4d2921
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@@ -48,8 -48,7 +48,7 @@@
  #include "rectangle.h"
  #include "videodsp.h"
  
 -#define H264_MAX_PICTURE_COUNT 32
 +#define H264_MAX_PICTURE_COUNT 36
- #define H264_MAX_THREADS       32
  
  #define MAX_SPS_COUNT          32
  #define MAX_PPS_COUNT         256
@@@ -623,14 -592,6 +622,12 @@@ typedef struct H264Context 
       */
      int max_contexts;
  
-     int slice_context_count;
- 
 +    /**
 +     *  1 if the single thread fallback warning has already been
 +     *  displayed, 0 otherwise.
 +     */
 +    int single_decode_warning;
 +
      /** @} */
  
      /**
diff --cc libavcodec/h264_slice.c
index ccc7e65,e0e3577..6e7b940
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@@ -998,10 -878,10 +982,10 @@@ static int h264_slice_header_init(H264C
          ret = ff_h264_slice_context_init(h, &h->slice_ctx[0]);
          if (ret < 0) {
              av_log(h->avctx, AV_LOG_ERROR, "context_init() failed.\n");
 -            return ret;
 +            goto fail;
          }
      } else {
-         for (i = 0; i < h->slice_context_count; i++) {
+         for (i = 0; i < h->nb_slice_ctx; i++) {
              H264SliceContext *sl = &h->slice_ctx[i];
  
              sl->h264               = h;



More information about the ffmpeg-cvslog mailing list