1 /* 2 * Copyright © 2018-2021, VideoLAN and dav1d authors 3 * Copyright © 2018, Two Orioles, LLC 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright notice, this 10 * list of conditions and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright notice, 13 * this list of conditions and the following disclaimer in the documentation 14 * and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 #ifndef DAV1D_SRC_PICTURE_H 29 #define DAV1D_SRC_PICTURE_H 30 31 #include <stdatomic.h> 32 33 #include "src/thread.h" 34 #include "dav1d/picture.h" 35 36 #include "src/thread_data.h" 37 #include "src/ref.h" 38 39 enum PlaneType { 40 PLANE_TYPE_Y, 41 PLANE_TYPE_UV, 42 PLANE_TYPE_BLOCK, 43 PLANE_TYPE_ALL, 44 }; 45 46 enum PictureFlags { 47 PICTURE_FLAG_NEW_SEQUENCE = 1 << 0, 48 PICTURE_FLAG_NEW_OP_PARAMS_INFO = 1 << 1, 49 PICTURE_FLAG_NEW_TEMPORAL_UNIT = 1 << 2, 50 }; 51 52 typedef struct Dav1dThreadPicture { 53 Dav1dPicture p; 54 int visible; 55 // This can be set for inter frames, non-key intra frames, or for invisible 56 // keyframes that have not yet been made visible using the show-existing-frame 57 // mechanism. 58 int showable; 59 enum PictureFlags flags; 60 // [0] block data (including segmentation map and motion vectors) 61 // [1] pixel data 62 atomic_uint *progress; 63 } Dav1dThreadPicture; 64 65 typedef struct Dav1dPictureBuffer { 66 void *data; 67 struct Dav1dPictureBuffer *next; 68 } Dav1dPictureBuffer; 69 70 /* 71 * Allocate a picture with custom border size. 72 */ 73 int dav1d_thread_picture_alloc(Dav1dContext *c, Dav1dFrameContext *f, const int bpc); 74 75 /** 76 * Allocate a picture with identical metadata to an existing picture. 77 * The width is a separate argument so this function can be used for 78 * super-res, where the width changes, but everything else is the same. 79 * For the more typical use case of allocating a new image of the same 80 * dimensions, use src->p.w as width. 81 */ 82 int dav1d_picture_alloc_copy(Dav1dContext *c, Dav1dPicture *dst, const int w, 83 const Dav1dPicture *src); 84 85 /** 86 * Create a copy of a picture. 87 */ 88 void dav1d_picture_ref(Dav1dPicture *dst, const Dav1dPicture *src); 89 void dav1d_thread_picture_ref(Dav1dThreadPicture *dst, 90 const Dav1dThreadPicture *src); 91 void dav1d_thread_picture_move_ref(Dav1dThreadPicture *dst, 92 Dav1dThreadPicture *src); 93 void dav1d_thread_picture_unref(Dav1dThreadPicture *p); 94 95 /** 96 * Move a picture reference. 97 */ 98 void dav1d_picture_move_ref(Dav1dPicture *dst, Dav1dPicture *src); 99 100 int dav1d_default_picture_alloc(Dav1dPicture *p, void *cookie); 101 void dav1d_default_picture_release(Dav1dPicture *p, void *cookie); 102 void dav1d_picture_unref_internal(Dav1dPicture *p); 103 104 struct itut_t35_ctx_context { 105 Dav1dITUTT35 *itut_t35; 106 size_t n_itut_t35; 107 Dav1dRef ref; 108 }; 109 110 void dav1d_picture_free_itut_t35(const uint8_t *data, void *user_data); 111 void dav1d_picture_copy_props(Dav1dPicture *p, 112 Dav1dContentLightLevel *content_light, Dav1dRef *content_light_ref, 113 Dav1dMasteringDisplay *mastering_display, Dav1dRef *mastering_display_ref, 114 Dav1dITUTT35 *itut_t35, Dav1dRef *itut_t35_ref, size_t n_itut_t35, 115 const Dav1dDataProps *props); 116 117 /** 118 * Get event flags from picture flags. 119 */ 120 enum Dav1dEventFlags dav1d_picture_get_event_flags(const Dav1dThreadPicture *p); 121 122 #endif /* DAV1D_SRC_PICTURE_H */ 123