1 /* 2 * Copyright 2015 Rockchip Electronics Co. LTD 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef __MPP_FRAME_IMPL_H__ 18 #define __MPP_FRAME_IMPL_H__ 19 20 #include "mpp_time.h" 21 #include "mpp_frame.h" 22 23 typedef struct MppFrameImpl_t MppFrameImpl; 24 25 typedef union MppFrameStatus_u { 26 /* total 64 bit frame status for internal flow */ 27 RK_U64 val; 28 29 struct { 30 /* bit 0 ~ 7 common frame status flag for both encoder and decoder */ 31 32 /* 33 * data status flag 34 * 0 - pixel data is invalid 35 * 1 - pixel data is valid 36 */ 37 RK_U32 valid : 1; 38 39 /* reference status flag */ 40 /* 41 * 0 - inter frame 42 * 1 - intra frame 43 */ 44 RK_U32 is_intra : 1; 45 46 /* 47 * Valid when is_intra is true 48 * 0 - normal intra frame 49 * 1 - IDR frame 50 */ 51 RK_U32 is_idr : 1; 52 53 /* 54 * 0 - mark as reference frame 55 * 1 - mark as non-refernce frame 56 */ 57 RK_U32 is_non_ref : 1; 58 59 /* 60 * Valid when is_non_ref is false 61 * 0 - mark as short-term reference frame 62 * 1 - mark as long-term refernce frame 63 */ 64 RK_U32 is_lt_ref : 1; 65 RK_U32 is_b_frame : 1; 66 67 /* 68 * frame usage flag for decoder / encoder flow 69 * 0 - mark as general frame 70 * 1 - mark as used by decoder 71 * 2 - mark as used by encoder 72 * 4 - mark as used by vproc 73 */ 74 RK_U32 usage : 3; 75 }; 76 } MppFrameStatus; 77 78 struct MppFrameImpl_t { 79 const char *name; 80 81 /* 82 * dimension parameter for display 83 */ 84 RK_U32 width; 85 RK_U32 height; 86 RK_U32 hor_stride; 87 RK_U32 ver_stride; 88 RK_U32 hor_stride_pixel; 89 RK_U32 fbc_hdr_stride; 90 RK_U32 offset_x; 91 RK_U32 offset_y; 92 93 /* 94 * interlaced related mode status 95 * 96 * 0 - frame 97 * 1 - top field 98 * 2 - bottom field 99 * 3 - paired top and bottom field 100 * 4 - deinterlaced flag 101 * 7 - deinterlaced paired field 102 */ 103 RK_U32 mode; 104 /* 105 * current decoded frame whether to display 106 * 107 * 0 - reserve 108 * 1 - discard 109 */ 110 RK_U32 discard; 111 /* 112 * send decoded frame belong which view 113 */ 114 RK_U32 viewid; 115 /* 116 * poc - picture order count 117 */ 118 RK_U32 poc; 119 /* 120 * pts - display time stamp 121 * dts - decode time stamp 122 */ 123 RK_S64 pts; 124 RK_S64 dts; 125 126 /* 127 * eos - end of stream 128 * info_change - set when buffer resized or frame infomation changed 129 */ 130 RK_U32 eos; 131 RK_U32 info_change; 132 RK_U32 errinfo; 133 MppFrameColorRange color_range; 134 MppFrameColorPrimaries color_primaries; 135 MppFrameColorTransferCharacteristic color_trc; 136 137 /** 138 * YUV colorspace type. 139 * It must be accessed using av_frame_get_colorspace() and 140 * av_frame_set_colorspace(). 141 * - encoding: Set by user 142 * - decoding: Set by libavcodec 143 */ 144 MppFrameColorSpace colorspace; 145 MppFrameChromaLocation chroma_location; 146 147 MppFrameFormat fmt; 148 149 MppFrameRational sar; 150 MppFrameMasteringDisplayMetadata mastering_display; 151 MppFrameContentLightMetadata content_light; 152 MppFrameHdrDynamicMeta *hdr_dynamic_meta; 153 154 /* 155 * buffer information 156 * NOTE: buf_size only access internally 157 */ 158 MppBuffer buffer; 159 size_t buf_size; 160 161 /* 162 * meta data information 163 */ 164 MppTask task; 165 MppMeta meta; 166 MppStopwatch stopwatch; 167 168 /* 169 * frame buffer compression (FBC) information 170 * 171 * NOTE: some constraint on fbc data 172 * 1. FBC config need two addresses but only one buffer. 173 * The second address should be represented by base + offset form. 174 * 2. FBC has header address and payload address 175 * Both addresses should be 4K aligned. 176 * 3. The header section size is default defined by: 177 * header size = aligned(aligned(width, 16) * aligned(height, 16) / 16, 4096) 178 * 4. The stride in header section is defined by: 179 * stride = aligned(width, 16) 180 */ 181 RK_U32 fbc_offset; 182 size_t fbc_size; 183 184 /* 185 * frame buffer contain downsacle pic 186 * 187 * downscale pic is no fbc fmt the downscale pic size 188 * w/2 x h / 2 189 */ 190 RK_U32 thumbnail_en; 191 192 /* 193 * frame status info for internal flow 194 */ 195 MppFrameStatus status; 196 }; 197 198 #ifdef __cplusplus 199 extern "C" { 200 #endif 201 202 MppFrame mpp_frame_dup(MppFrame src); 203 MPP_RET mpp_frame_copy(MppFrame dst, MppFrame src); 204 MPP_RET mpp_frame_info_cmp(MppFrame frame0, MppFrame frame1); 205 RK_U32 mpp_frame_get_fbc_offset(MppFrame frame); 206 RK_U32 mpp_frame_get_fbc_stride(MppFrame frame); 207 size_t mpp_frame_get_fbc_size(MppFrame frame); 208 void mpp_frame_set_fbc_size(MppFrame frame, size_t size); 209 210 MppFrameStatus *mpp_frame_get_status(MppFrame frame); 211 212 /* 213 * Debug for frame process timing 214 */ 215 void mpp_frame_set_stopwatch_enable(MppFrame frame, RK_S32 enable); 216 MppStopwatch mpp_frame_get_stopwatch(const MppFrame frame); 217 218 MPP_RET __check_is_mpp_frame(void *frame); 219 220 #ifdef __cplusplus 221 } 222 #endif 223 224 #endif /*__MPP_FRAME_IMPL_H__*/ 225