Commit 5307adad authored by Ronald S. Bultje's avatar Ronald S. Bultje Committed by Michael Niedermayer

vp9: only call ff_get_format on stream format changes.

In practice, this means we don't call it N times for N-threaded decoding.
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 94a1c749
......@@ -70,7 +70,13 @@ typedef struct VP9Context {
uint8_t ss_h, ss_v;
uint8_t last_bpp, bpp, bpp_index, bytesperpixel;
uint8_t last_keyframe;
enum AVPixelFormat pix_fmt, last_fmt;
// sb_cols/rows, rows/cols and last_fmt are used for allocating all internal
// arrays, and are thus per-thread. w/h and gf_fmt are synced between threads
// and are therefore per-stream. pix_fmt represents the value in the header
// of the currently processed frame.
int w, h;
enum AVPixelFormat pix_fmt, last_fmt, gf_fmt;
unsigned sb_cols, sb_rows, rows, cols;
ThreadFrame next_refs[8];
struct {
......@@ -78,7 +84,6 @@ typedef struct VP9Context {
uint8_t mblim_lut[64];
} filter_lut;
unsigned tile_row_start, tile_row_end, tile_col_start, tile_col_end;
unsigned sb_cols, sb_rows, rows, cols;
struct {
prob_context p;
uint8_t coef[4][2][2][6][6][3];
......@@ -245,13 +250,11 @@ static int update_size(AVCodecContext *ctx, int w, int h)
enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmtp = pix_fmts;
VP9Context *s = ctx->priv_data;
uint8_t *p;
int bytesperpixel = s->bytesperpixel, res;
int bytesperpixel = s->bytesperpixel, res, cols, rows;
av_assert0(w > 0 && h > 0);
if (s->intra_pred_data[0] && w == ctx->width && h == ctx->height && s->pix_fmt == s->last_fmt)
return 0;
if (!(s->pix_fmt == s->gf_fmt && w == s->w && h == s->h)) {
if ((res = ff_set_dimensions(ctx, w, h)) < 0)
return res;
......@@ -275,6 +278,17 @@ static int update_size(AVCodecContext *ctx, int w, int h)
return res;
ctx->pix_fmt = res;
s->gf_fmt = s->pix_fmt;
s->w = w;
s->h = h;
}
cols = (w + 7) >> 3;
rows = (h + 7) >> 3;
if (s->intra_pred_data[0] && cols == s->cols && rows == s->rows && s->pix_fmt == s->last_fmt)
return 0;
s->last_fmt = s->pix_fmt;
s->sb_cols = (w + 63) >> 6;
s->sb_rows = (h + 63) >> 6;
......@@ -4292,13 +4306,6 @@ static int vp9_decode_update_thread_context(AVCodecContext *dst, const AVCodecCo
int i, res;
VP9Context *s = dst->priv_data, *ssrc = src->priv_data;
// detect size changes in other threads
if (s->intra_pred_data[0] &&
(!ssrc->intra_pred_data[0] || s->cols != ssrc->cols ||
s->rows != ssrc->rows || s->bpp != ssrc->bpp || s->pix_fmt != ssrc->pix_fmt)) {
free_buffers(s);
}
for (i = 0; i < 3; i++) {
if (s->s.frames[i].tf.f->buf[0])
vp9_unref_frame(dst, &s->s.frames[i]);
......@@ -4325,6 +4332,9 @@ static int vp9_decode_update_thread_context(AVCodecContext *dst, const AVCodecCo
s->s.h.segmentation.update_map = ssrc->s.h.segmentation.update_map;
s->s.h.segmentation.absolute_vals = ssrc->s.h.segmentation.absolute_vals;
s->bytesperpixel = ssrc->bytesperpixel;
s->gf_fmt = ssrc->gf_fmt;
s->w = ssrc->w;
s->h = ssrc->h;
s->bpp = ssrc->bpp;
s->bpp_index = ssrc->bpp_index;
s->pix_fmt = ssrc->pix_fmt;
......
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