[FFmpeg-cvslog] h264: improve MAX_SLICES too small check so it gives less false positives.

Michael Niedermayer git at videolan.org
Mon Sep 12 06:15:49 CEST 2011


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Mon Sep 12 06:06:43 2011 +0200| [716c1f7b2ad02a906ad1e47182492554b668f3dc] | committer: Michael Niedermayer

h264: improve MAX_SLICES too small check so it gives less false positives.
Fixes Ticket273

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavcodec/h264.c |    8 +++++++-
 libavcodec/h264.h |    2 ++
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 0703c6b..c656189 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -3016,7 +3016,13 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
 
     h0->last_slice_type = slice_type;
     h->slice_num = ++h0->current_slice;
-    if(h->slice_num >= MAX_SLICES){
+
+    if(h->slice_num)
+        h0->slice_row[(h->slice_num-1)&(MAX_SLICES-1)]= s->resync_mb_y;
+    if (   h0->slice_row[h->slice_num&(MAX_SLICES-1)] + 3 >= s->resync_mb_y
+        && h0->slice_row[h->slice_num&(MAX_SLICES-1)] <= s->resync_mb_y
+        && h->slice_num >= MAX_SLICES) {
+        //in case of ASO this check needs to be updated depending on how we decide to assign slice numbers in this case
         av_log(s->avctx, AV_LOG_WARNING, "Possibly too many slices (%d >= %d), increase MAX_SLICES and recompile if there are artifacts\n", h->slice_num, MAX_SLICES);
     }
 
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index e956d3a..374cd16 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -580,6 +580,8 @@ typedef struct H264Context{
     int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs
 
     int cur_chroma_format_idc;
+
+    int16_t slice_row[MAX_SLICES]; ///< to detect when MAX_SLICES is too low
 }H264Context;
 
 



More information about the ffmpeg-cvslog mailing list