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
// Copyright 2019 Fuzhou Rockchip Electronics Co., Ltd. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
 
#ifndef EASYMEDIA_MPP_INC_H_
#define EASYMEDIA_MPP_INC_H_
 
#include <rk_mpi.h>
 
#include "buffer.h"
#include "image.h"
 
namespace easymedia
{
// mpp_packet_impl.h which define MPP_PACKET_FLAG_INTRA is not exposed,
// here define the same MPP_PACKET_FLAG_INTRA.
#ifndef MPP_PACKET_FLAG_INTRA
    #define MPP_PACKET_FLAG_INTRA (0x00000008)
#endif
 
    MppFrameFormat ConvertToMppPixFmt(const PixelFormat& fmt);
    PixelFormat ConvertToPixFmt(const MppFrameFormat& mfmt);
    const char* MppAcceptImageFmts();
    MppCodingType GetMPPCodingType(const std::string& data_type);
    MppEncRcQuality GetMPPRCQuality(const char* quality);
    MppEncRcMode GetMPPRCMode(const char* rc_mode);
 
    struct MPPContext {
        MPPContext();
        ~MPPContext();
        MppCtx ctx;
        MppApi* mpi;
        MppBufferGroup frame_group;
    };
 
    // no time-consuming, init a mppbuffer with MediaBuffer
    MPP_RET init_mpp_buffer(MppBuffer& buffer, const std::shared_ptr<MediaBuffer>& mb, size_t frame_size);
    // may time-consuming
    MPP_RET init_mpp_buffer_with_content(MppBuffer& buffer, const std::shared_ptr<MediaBuffer>& mb);
 
    MPP_RET mpi_enc_gen_ref_cfg(MppEncRefCfg ref, RK_S32 gop_mode = 2, RK_S32 gop_len = 0, RK_S32 vi_len = 0);
 
} // namespace easymedia
 
#endif // EASYMEDIA_MPP_INC_H_