ref: 515f5af5a0a161984941c6626c06b345e47a1da4
parent: 9a33184db45f00f4b929a2696229015258e66f3c
author: James Almer <[email protected]>
date: Fri Feb 8 08:16:45 EST 2019
Simplify dav1d_thread_picture_alloc() It's called from a single function in the entire codebase, so no point passing so many individual arguments to it when almost all of them are derived from a single struct.
--- a/src/decode.c
+++ b/src/decode.c
@@ -3185,13 +3185,7 @@
c->n_tile_data = 0;
// allocate frame
- res = dav1d_thread_picture_alloc(c, &f->sr_cur, f->frame_hdr->width[1],
- f->frame_hdr->height,
- f->seq_hdr, f->seq_hdr_ref,
- f->frame_hdr, f->frame_hdr_ref,
- bpc, &f->tile[0].data.m,
- c->n_fc > 1 ? &f->frame_thread.td : NULL,
- f->frame_hdr->show_frame, &c->allocator);
+ res = dav1d_thread_picture_alloc(c, f, bpc);
if (res < 0) goto error;
if (f->frame_hdr->super_res.enabled) {
--- a/src/picture.c
+++ b/src/picture.c
@@ -38,6 +38,7 @@
#include "common/mem.h"
#include "common/validate.h"
+#include "src/internal.h"
#include "src/log.h"
#include "src/picture.h"
#include "src/ref.h"
@@ -152,27 +153,23 @@
return 0;
}
-int dav1d_thread_picture_alloc(Dav1dContext *const c, Dav1dThreadPicture *const p,
- const int w, const int h,
- Dav1dSequenceHeader *seq_hdr, Dav1dRef *seq_hdr_ref,
- Dav1dFrameHeader *frame_hdr, Dav1dRef *frame_hdr_ref,
- const int bpc, const Dav1dDataProps *props,
- struct thread_data *const t, const int visible,
- Dav1dPicAllocator *const p_allocator)
+int dav1d_thread_picture_alloc(Dav1dContext *const c, Dav1dFrameContext *const f,
+ const int bpc)
{
- p->t = t;
+ Dav1dThreadPicture *const p = &f->sr_cur;
+ p->t = c->n_fc > 1 ? &f->frame_thread.td : NULL;
const int res =
- picture_alloc_with_edges(c, &p->p, w, h,
- seq_hdr, seq_hdr_ref,
- frame_hdr, frame_hdr_ref,
- bpc, props, p_allocator,
- t != NULL ? sizeof(atomic_int) * 2 : 0,
+ picture_alloc_with_edges(c, &p->p, f->frame_hdr->width[1], f->frame_hdr->height,
+ f->seq_hdr, f->seq_hdr_ref,
+ f->frame_hdr, f->frame_hdr_ref,
+ bpc, &f->tile[0].data.m, &c->allocator,
+ p->t != NULL ? sizeof(atomic_int) * 2 : 0,
(void **) &p->progress);
if (res) return res;
- p->visible = visible;
- if (t) {
+ p->visible = f->frame_hdr->show_frame;
+ if (p->t) {
atomic_init(&p->progress[0], 0);
atomic_init(&p->progress[1], 0);
}
--- a/src/picture.h
+++ b/src/picture.h
@@ -55,12 +55,7 @@
/*
* Allocate a picture with custom border size.
*/
-int dav1d_thread_picture_alloc(Dav1dContext *c, Dav1dThreadPicture *p, int w, int h,
- Dav1dSequenceHeader *seq_hdr, Dav1dRef *seq_hdr_ref,
- Dav1dFrameHeader *frame_hdr, Dav1dRef *frame_hdr_ref,
- int bpc, const Dav1dDataProps *props,
- struct thread_data *t, int visible,
- Dav1dPicAllocator *);
+int dav1d_thread_picture_alloc(Dav1dContext *c, Dav1dFrameContext *f, const int bpc);
/**
* Allocate a picture with identical metadata to an existing picture.