@@ -131,10 +131,11 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f)
if (!fs)
goto memfail;
- f->slice_context[i++] = fs;
+ f->slice_context[i] = fs;
memcpy(fs, f, sizeof(*fs));
memset(fs->rc_stat2, 0, sizeof(fs->rc_stat2));
+ fs->slice_index = i++;
fs->slice_width = sxe - sxs;
fs->slice_height = sye - sys;
fs->slice_x = sxs;
@@ -127,6 +127,7 @@ typedef struct FFV1Context {
int quant_table_count;
struct FFV1Context *slice_context[MAX_SLICES];
+ int slice_index;
int slice_count;
int max_slice_count;
int num_v_slices;
@@ -230,19 +230,17 @@ static int decode_slice(AVCodecContext *c, void *arg)
int width, height, x, y, ret;
const int ps = av_pix_fmt_desc_get(c->pix_fmt)->comp[0].step;
AVFrame * const p = f->cur;
- int i, si;
+ int i, si = fs->slice_index;
- for( si=0; fs != f->slice_context[si]; si ++)
- ;
+ av_assert1(si >= 0 && si < MAX_SLICES && f->slice_context[si] == fs);
if(f->fsrc && !p->key_frame)
ff_thread_await_progress(&f->last_picture, si, 0);
if(f->fsrc && !p->key_frame) {
FFV1Context *fssrc = f->fsrc->slice_context[si];
- FFV1Context *fsdst = f->slice_context[si];
+ FFV1Context *fsdst = fs;
av_assert1(fsdst->plane_count == fssrc->plane_count);
- av_assert1(fsdst == fs);
if (!p->key_frame)
fsdst->slice_damaged |= fssrc->slice_damaged;
instead of searching the index again and again each time a slice is decoded. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/ffv1.c | 3 ++- libavcodec/ffv1.h | 1 + libavcodec/ffv1dec.c | 8 +++----- 3 files changed, 6 insertions(+), 6 deletions(-)