hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
 * Copyright 2020 Rockchip Electronics Co. LTD
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 
#ifndef __MPP_ENC_IMPL_H__
#define __MPP_ENC_IMPL_H__
 
#include "enc_impl.h"
#include "mpp_enc_hal.h"
#include "mpp_enc_ref.h"
#include "mpp_enc_refs.h"
#include "mpp_device.h"
 
#include "rc.h"
#include "hal_info.h"
 
typedef union MppEncHeaderStatus_u {
    RK_U32 val;
    struct {
        RK_U32          ready           : 1;
 
        RK_U32          added_by_ctrl   : 1;
        RK_U32          added_by_mode   : 1;
        RK_U32          added_by_change : 1;
    };
} MppEncHeaderStatus;
 
typedef struct RcApiStatus_t {
    RK_U32              rc_api_inited   : 1;
    RK_U32              rc_api_updated  : 1;
    RK_U32              rc_api_user_cfg : 1;
} RcApiStatus;
 
typedef struct MppEncImpl_t {
    MppCodingType       coding;
    EncImpl             impl;
    MppEncHal           enc_hal;
 
    /* device from hal */
    MppDev              dev;
    HalInfo             hal_info;
    RK_S64              time_base;
    RK_S64              time_end;
    RK_S32              frame_count;
    RK_S32              hal_info_updated;
 
    /*
     * Rate control plugin parameters
     */
    RcApiStatus         rc_status;
    RK_S32              rc_api_updated;
    RK_S32              rc_cfg_updated;
    RcApiBrief          rc_brief;
    RcCtx               rc_ctx;
 
    /*
     * thread input / output context
     */
    MppThread           *thread_enc;
    void                *mpp;
 
    MppPort             input;
    MppPort             output;
    MppTask             task_in;
    MppTask             task_out;
    MppFrame            frame;
    MppPacket           packet;
    RK_U32              low_delay_part_mode;
    RK_U32              low_delay_output;
    /* output callback for slice output */
    MppCbCtx            output_cb;
 
    /* base task information */
    HalTaskGroup        tasks;
    HalTaskHnd          hnd;
    EncAsyncTaskInfo    *async;
    RK_U32              task_idx;
    RK_S64              task_pts;
    MppBuffer           frm_buf;
    MppBuffer           pkt_buf;
    MppBuffer           md_info;
 
    // internal status and protection
    Mutex               lock;
    RK_U32              reset_flag;
    sem_t               enc_reset;
 
    RK_U32              wait_count;
    RK_U32              work_count;
    RK_U32              status_flag;
    RK_U32              notify_flag;
 
    /* control process */
    RK_U32              cmd_send;
    RK_U32              cmd_recv;
    MpiCmd              cmd;
    void                *param;
    MPP_RET             *cmd_ret;
    sem_t               cmd_start;
    sem_t               cmd_done;
 
    // legacy support for MPP_ENC_GET_EXTRA_INFO
    MppPacket           hdr_pkt;
    void                *hdr_buf;
    RK_U32              hdr_len;
    MppEncHeaderStatus  hdr_status;
    MppEncHeaderMode    hdr_mode;
    MppEncSeiMode       sei_mode;
 
    /* information for debug prefix */
    const char          *version_info;
    RK_S32              version_length;
    char                *rc_cfg_info;
    RK_S32              rc_cfg_pos;
    RK_S32              rc_cfg_length;
    RK_S32              rc_cfg_size;
 
    /* cpb parameters */
    MppEncRefs          refs;
    MppEncRefFrmUsrCfg  frm_cfg;
 
    /* two-pass deflicker parameters */
    RK_U32              support_hw_deflicker;
    EncRcTaskInfo       rc_info_prev;
 
    /* Encoder configure set */
    MppEncCfgSet        cfg;
} MppEncImpl;
 
#ifdef __cplusplus
extern "C" {
#endif
 
void *mpp_enc_thread(void *data);
void *mpp_enc_async_thread(void *data);
MPP_RET mpp_enc_callback(const char *caller, void *ctx, RK_S32 cmd, void *param);
 
#ifdef __cplusplus
}
#endif
 
#endif /*__MPP_ENC_IMPL_H__*/