shithub: dav1d

Download patch

ref: 93550d8856ef8154e744a0afc4eb89cff584a6f7
parent: ee58d65dd59d424f840c04079ef3c3153f9d9576
author: Steve Lhomme <[email protected]>
date: Fri Jan 11 11:42:27 EST 2019

pass the sequence header corresponding to the picture being allocated

--- a/src/decode.c
+++ b/src/decode.c
@@ -3180,18 +3180,12 @@
     // 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);
--- a/src/picture.c
+++ b/src/picture.c
@@ -99,8 +99,9 @@
 
 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 @@
     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 @@
         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,7 +159,9 @@
 
 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)
 {
@@ -155,7 +168,10 @@
     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 @@
                              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;
 }
 
--- a/src/picture.h
+++ b/src/picture.h
@@ -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 @@
  * 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 *);