xref: /OK3568_Linux_fs/external/mpp/mpp/base/inc/mpp_packet_impl.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
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_PACKET_IMPL_H__
18 #define __MPP_PACKET_IMPL_H__
19 
20 #include "mpp_packet.h"
21 
22 #define MPP_PACKET_FLAG_EOS             (0x00000001)
23 #define MPP_PACKET_FLAG_EXTRA_DATA      (0x00000002)
24 #define MPP_PACKET_FLAG_INTERNAL        (0x00000004)
25 
26 #define MPP_PKT_SEG_CNT_DEFAULT         8
27 
28 typedef union MppPacketStatus_t {
29     RK_U32  val;
30     struct {
31         RK_U32  eos         : 1;
32         RK_U32  extra_data  : 1;
33         RK_U32  internal    : 1;
34         /* packet is inputed on reset mark as discard */
35         RK_U32  discard     : 1;
36 
37         /* for slice input output */
38         RK_U32  partition   : 1;
39         RK_U32  soi         : 1;
40         RK_U32  eoi         : 1;
41     };
42 } MppPacketStatus;
43 
44 /*
45  * mpp_packet_imp structure
46  *
47  * data     : pointer
48  * size     : total buffer size
49  * offset   : valid data start offset
50  * length   : valid data length
51  * pts      : packet pts
52  * dts      : packet dts
53  */
54 typedef struct MppPacketImpl_t {
55     const char      *name;
56 
57     void            *data;
58     void            *pos;
59     size_t          size;
60     size_t          length;
61 
62     RK_S64          pts;
63     RK_S64          dts;
64 
65     MppPacketStatus status;
66     RK_U32          flag;
67 
68     MppBuffer       buffer;
69     MppMeta         meta;
70     MppTask         task;
71 
72     RK_U32          segment_nb;
73     RK_U32          segment_buf_cnt;
74     MppPktSeg       segments_def[MPP_PKT_SEG_CNT_DEFAULT];
75     MppPktSeg       *segments_ext;
76     MppPktSeg       *segments;
77 } MppPacketImpl;
78 
79 #ifdef __cplusplus
80 extern "C" {
81 #endif
82 /*
83  * mpp_packet_reset is only used internelly and should NOT be used outside
84  */
85 MPP_RET mpp_packet_reset(MppPacketImpl *packet);
86 MPP_RET mpp_packet_copy(MppPacket dst, MppPacket src);
87 MPP_RET mpp_packet_append(MppPacket dst, MppPacket src);
88 
89 MPP_RET mpp_packet_set_status(MppPacket packet, MppPacketStatus status);
90 MPP_RET mpp_packet_get_status(MppPacket packet, MppPacketStatus *status);
91 void    mpp_packet_set_task(MppPacket packet, MppTask task);
92 MppTask mpp_packet_get_task(MppPacket packet);
93 
94 void    mpp_packet_reset_segment(MppPacket packet);
95 void    mpp_packet_set_segment_nb(MppPacket packet, RK_U32 segment_nb);
96 MPP_RET mpp_packet_add_segment_info(MppPacket packet, RK_S32 type, RK_S32 offset, RK_S32 len);
97 void    mpp_packet_copy_segment_info(MppPacket dst, MppPacket src);
98 
99 /* pointer check function */
100 MPP_RET check_is_mpp_packet(void *ptr);
101 
102 #ifdef __cplusplus
103 }
104 #endif
105 
106 #endif /*__MPP_PACKET_IMPL_H__*/
107