[FFmpeg-devel] [PATCH 12/14] avcodec/ffv1, ffv1dec: Store index of slice context
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Sat Apr 24 14:14:44 EEST 2021
instead of searching the index again and again each time a slice is
decoded.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
libavcodec/ffv1.c | 3 ++-
libavcodec/ffv1.h | 1 +
libavcodec/ffv1dec.c | 8 +++-----
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
index 47bb032876..8e7542f918 100644
--- a/libavcodec/ffv1.c
+++ b/libavcodec/ffv1.c
@@ -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;
diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
index f5ac8090bd..7f97b2c6f7 100644
--- a/libavcodec/ffv1.h
+++ b/libavcodec/ffv1.h
@@ -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;
diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
index c16fc81927..060efc25ab 100644
--- a/libavcodec/ffv1dec.c
+++ b/libavcodec/ffv1dec.c
@@ -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;
--
2.27.0
More information about the ffmpeg-devel
mailing list