Commit 716c1f7b authored by Michael Niedermayer's avatar Michael Niedermayer

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

Fixes Ticket273
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent ad2fba86
...@@ -3016,7 +3016,13 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ ...@@ -3016,7 +3016,13 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
h0->last_slice_type = slice_type; h0->last_slice_type = slice_type;
h->slice_num = ++h0->current_slice; 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); 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);
} }
......
...@@ -580,6 +580,8 @@ typedef struct H264Context{ ...@@ -580,6 +580,8 @@ typedef struct H264Context{
int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs
int cur_chroma_format_idc; int cur_chroma_format_idc;
int16_t slice_row[MAX_SLICES]; ///< to detect when MAX_SLICES is too low
}H264Context; }H264Context;
......
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