Commit 93550d88 authored by Steve Lhomme's avatar Steve Lhomme Committed by Ronald S. Bultje

pass the sequence header corresponding to the picture being allocated

parent ee58d65d
......@@ -3180,19 +3180,13 @@ int dav1d_submit_frame(Dav1dContext *const c) {
// allocate frame
res = dav1d_thread_picture_alloc(&f->sr_cur, f->frame_hdr->width[1],
f->frame_hdr->height,
f->seq_hdr->layout, bpc,
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);
if (res < 0) goto error;
dav1d_data_props_copy(&f->sr_cur.p.m, &f->tile[0].data.m);
f->sr_cur.p.frame_hdr = f->frame_hdr;
f->sr_cur.p.frame_hdr_ref = f->frame_hdr_ref;
dav1d_ref_inc(f->frame_hdr_ref);
f->sr_cur.p.seq_hdr = f->seq_hdr;
f->sr_cur.p.seq_hdr_ref = f->seq_hdr_ref;
dav1d_ref_inc(f->seq_hdr_ref);
if (f->frame_hdr->super_res.enabled) {
res = dav1d_picture_alloc_copy(&f->cur, f->frame_hdr->width[0], &f->sr_cur.p);
if (res < 0) goto error;
......
......@@ -99,8 +99,9 @@ static void free_buffer(const uint8_t *const data, void *const user_data) {
static int picture_alloc_with_edges(Dav1dPicture *const p,
const int w, const int h,
const enum Dav1dPixelLayout layout,
const int bpc,
Dav1dSequenceHeader *seq_hdr, Dav1dRef *seq_hdr_ref,
Dav1dFrameHeader *frame_hdr, Dav1dRef *frame_hdr_ref,
const int bpc, const Dav1dDataProps *props,
Dav1dPicAllocator *const p_allocator,
const size_t extra, void **const extra_ptr)
{
......@@ -122,7 +123,9 @@ static int picture_alloc_with_edges(Dav1dPicture *const p,
p->m.offset = -1;
p->m.user_data.data = NULL;
p->m.user_data.ref = NULL;
p->p.layout = layout;
p->seq_hdr = seq_hdr;
p->frame_hdr = frame_hdr;
p->p.layout = seq_hdr->layout;
p->p.bpc = bpc;
int res = p_allocator->alloc_picture_callback(p, p_allocator->cookie);
if (res < 0) {
......@@ -140,6 +143,14 @@ static int picture_alloc_with_edges(Dav1dPicture *const p,
return -ENOMEM;
}
p->seq_hdr_ref = seq_hdr_ref;
if (seq_hdr_ref) dav1d_ref_inc(seq_hdr_ref);
p->frame_hdr_ref = frame_hdr_ref;
if (frame_hdr_ref) dav1d_ref_inc(frame_hdr_ref);
dav1d_data_props_copy(&p->m, props);
if (extra && extra_ptr)
*extra_ptr = &pic_ctx->extra_ptr;
......@@ -148,14 +159,19 @@ static int picture_alloc_with_edges(Dav1dPicture *const p,
int dav1d_thread_picture_alloc(Dav1dThreadPicture *const p,
const int w, const int h,
const enum Dav1dPixelLayout layout, const int bpc,
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)
{
p->t = t;
const int res =
picture_alloc_with_edges(&p->p, w, h, layout, bpc, p_allocator,
picture_alloc_with_edges(&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,
(void **) &p->progress);
if (res) return res;
......@@ -172,22 +188,11 @@ int dav1d_picture_alloc_copy(Dav1dPicture *const dst, const int w,
const Dav1dPicture *const src)
{
struct pic_ctx_context *const pic_ctx = src->ref->user_data;
const int res = picture_alloc_with_edges(dst, w, src->p.h, src->p.layout,
src->p.bpc, &pic_ctx->allocator,
const int res = picture_alloc_with_edges(dst, w, src->p.h,
src->seq_hdr, src->seq_hdr_ref,
src->frame_hdr, src->frame_hdr_ref,
src->p.bpc, &src->m, &pic_ctx->allocator,
0, NULL);
if (!res) {
dst->p = src->p;
dav1d_data_props_copy(&dst->m, &src->m);
dst->p.w = w;
dst->frame_hdr = src->frame_hdr;
dst->frame_hdr_ref = src->frame_hdr_ref;
if (dst->frame_hdr_ref) dav1d_ref_inc(dst->frame_hdr_ref);
dst->seq_hdr = src->seq_hdr;
dst->seq_hdr_ref = src->seq_hdr_ref;
if (dst->seq_hdr_ref) dav1d_ref_inc(dst->seq_hdr_ref);
}
return res;
}
......
......@@ -34,6 +34,7 @@
#include "dav1d/picture.h"
#include "src/thread_data.h"
#include "src/ref.h"
enum PlaneType {
PLANE_TYPE_Y,
......@@ -55,7 +56,9 @@ typedef struct Dav1dThreadPicture {
* Allocate a picture with custom border size.
*/
int dav1d_thread_picture_alloc(Dav1dThreadPicture *p, int w, int h,
enum Dav1dPixelLayout layout, int bpc,
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 *);
......
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