ref: c4be071d739c356d67f2a9f5d9ea3963a69dd662
parent: b716083c7a5a689072cb8f61fc70e31546e8e45e
author: Ronald S. Bultje <rsbultje@gmail.com>
date: Tue Nov 20 11:32:59 EST 2018
Merge dav1d_picture_alloc() and dav1d_picture_alloc_copy() Also ensure we apply film-grain to delayed pictures.
--- a/src/decode.c
+++ b/src/decode.c
@@ -3112,11 +3112,8 @@
f->sr_cur.p.p.fullrange = f->seq_hdr.color_range;
if (f->frame_hdr.super_res.enabled) {
- res = dav1d_picture_alloc(&f->cur, f->frame_hdr.width[0],
- f->frame_hdr.height, f->seq_hdr.layout,
- f->seq_hdr.bpc, &c->allocator);
+ res = dav1d_picture_alloc_copy(&f->cur, f->frame_hdr.width[0], &f->sr_cur.p);
if (res < 0) goto error;
- f->cur.poc = f->frame_hdr.frame_offset;
} else {
dav1d_picture_ref(&f->cur, &f->sr_cur.p);
}
--- a/src/lib.c
+++ b/src/lib.c
@@ -187,7 +187,7 @@
}
// Apply film grain to a new copy of the image to avoid corrupting refs
- int res = dav1d_picture_alloc_copy(out, in);
+ int res = dav1d_picture_alloc_copy(out, in->p.w, in);
if (res < 0)
return res;
@@ -233,14 +233,11 @@
if (++c->frame_thread.next == c->n_fc)
c->frame_thread.next = 0;
if (out_delayed->p.data[0]) {
- if (out_delayed->visible && !out_delayed->flushed) {
- dav1d_picture_ref(out, &out_delayed->p);
- }
+ if (out_delayed->visible && !out_delayed->flushed)
+ dav1d_picture_ref(&c->out, &out_delayed->p);
dav1d_thread_picture_unref(out_delayed);
- if (out->data[0]) {
- return 0;
- }
- // else continue
+ if (c->out.data[0])
+ return output_image(c, out, &c->out);
}
} while (++flush_count < c->n_fc);
return -EAGAIN;
--- a/src/picture.c
+++ b/src/picture.c
@@ -150,13 +150,6 @@
return 0;
}
-int dav1d_picture_alloc(Dav1dPicture *const p, const int w, const int h,
- const enum Dav1dPixelLayout layout, const int bpc,
- Dav1dPicAllocator *const p_allocator)
-{
- return picture_alloc_with_edges(p, w, h, layout, bpc, p_allocator, 0, NULL);
-}
-
int dav1d_thread_picture_alloc(Dav1dThreadPicture *const p,
const int w, const int h,
const enum Dav1dPixelLayout layout, const int bpc,
@@ -180,12 +173,13 @@
return res;
}
-int dav1d_picture_alloc_copy(Dav1dPicture *const dst,
+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;
- int res = dav1d_picture_alloc(dst, src->p.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->p.layout,
+ src->p.bpc, &pic_ctx->allocator,
+ 0, NULL);
if (!res) {
dst->poc = src->poc;
--- a/src/picture.h
+++ b/src/picture.h
@@ -54,10 +54,6 @@
/*
* Allocate a picture with custom border size.
*/
-int dav1d_picture_alloc(Dav1dPicture *p, int w, int h,
- enum Dav1dPixelLayout layout, int bpc,
- Dav1dPicAllocator *);
-
int dav1d_thread_picture_alloc(Dav1dThreadPicture *p, int w, int h,
enum Dav1dPixelLayout layout, int bpc,
struct thread_data *t, int visible,
@@ -65,8 +61,13 @@
/**
* Allocate a picture with identical metadata to an existing picture.
+ * The width is a separate argument so this function can be used for
+ * super-res, where the width changes, but everything else is the same.
+ * For the more typical use case of allocating a new image of the same
+ * dimensions, use src->p.w as width.
*/
-int dav1d_picture_alloc_copy(Dav1dPicture *dst, const Dav1dPicture *src);
+int dav1d_picture_alloc_copy(Dav1dPicture *dst, const int w,
+ const Dav1dPicture *src);
/**
* Create a copy of a picture.