xref: /rockchip-linux_mpp/mpp/base/inc/mpp_packet_impl.h (revision 437bfbeb9567cca9cd9080e3f6954aa9d6a94f18)
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 #define MPP_PACKET_FLAG_INTRA           (0x00000010)
26 #define MPP_PACKET_FLAG_PARTITION       (0x00000020)
27 #define MPP_PACKET_FLAG_EOI             (0x00000040)
28 
29 #define MPP_PKT_SEG_CNT_DEFAULT         8
30 
31 typedef void (*ReleaseCb)(void *ctx, void *arg);
32 
33 typedef union MppPacketStatus_t {
34     RK_U32  val;
35     struct {
36         RK_U32  eos         : 1;
37         RK_U32  extra_data  : 1;
38         RK_U32  internal    : 1;
39         /* packet is inputed on reset mark as discard */
40         RK_U32  discard     : 1;
41 
42         /* for slice input output */
43         RK_U32  partition   : 1;
44         RK_U32  soi         : 1;
45         RK_U32  eoi         : 1;
46     };
47 } MppPacketStatus;
48 
49 /*
50  * mpp_packet_imp structure
51  *
52  * data     : pointer
53  * size     : total buffer size
54  * offset   : valid data start offset
55  * length   : valid data length
56  * pts      : packet pts
57  * dts      : packet dts
58  */
59 typedef struct MppPacketImpl_t {
60     const char      *name;
61 
62     void            *data;
63     void            *pos;
64     size_t          size;
65     size_t          length;
66 
67     RK_S64          pts;
68     RK_S64          dts;
69 
70     MppPacketStatus status;
71     RK_U32          flag;
72 
73     MppBuffer       buffer;
74     MppMeta         meta;
75     MppTask         task;
76 
77     RK_U32          segment_nb;
78     RK_U32          segment_buf_cnt;
79     MppPktSeg       segments_def[MPP_PKT_SEG_CNT_DEFAULT];
80     MppPktSeg       *segments_ext;
81     MppPktSeg       *segments;
82 
83     /* release callback info */
84     ReleaseCb       release;
85     void            *release_ctx;
86     void            *release_arg;
87 } MppPacketImpl;
88 
89 #ifdef __cplusplus
90 extern "C" {
91 #endif
92 /*
93  * mpp_packet_reset is only used internelly and should NOT be used outside
94  */
95 MPP_RET mpp_packet_reset(MppPacketImpl *packet);
96 MPP_RET mpp_packet_copy(MppPacket dst, MppPacket src);
97 MPP_RET mpp_packet_append(MppPacket dst, MppPacket src);
98 
99 MPP_RET mpp_packet_set_status(MppPacket packet, MppPacketStatus status);
100 MPP_RET mpp_packet_get_status(MppPacket packet, MppPacketStatus *status);
101 void    mpp_packet_set_task(MppPacket packet, MppTask task);
102 MppTask mpp_packet_get_task(MppPacket packet);
103 
104 void    mpp_packet_reset_segment(MppPacket packet);
105 void    mpp_packet_set_segment_nb(MppPacket packet, RK_U32 segment_nb);
106 MPP_RET mpp_packet_add_segment_info(MppPacket packet, RK_S32 type, RK_S32 offset, RK_S32 len);
107 void    mpp_packet_copy_segment_info(MppPacket dst, MppPacket src);
108 void    mpp_packet_set_release(MppPacket packet, ReleaseCb release, void *ctx, void *arg);
109 
110 /* pointer check function */
111 MPP_RET check_is_mpp_packet_f(void *ptr, const char *caller);
112 #define check_is_mpp_packet(ptr) check_is_mpp_packet_f(ptr, __FUNCTION__)
113 
114 #ifdef __cplusplus
115 }
116 #endif
117 
118 #endif /*__MPP_PACKET_IMPL_H__*/
119