From 4dc165b0cb23d01382e3779914ffb14643335db3 Mon Sep 17 00:00:00 2001 From: ChenHengming Date: Tue, 20 Oct 2015 22:37:23 +0000 Subject: [PATCH] [mpp_enc]: add basic mpp_enc function git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@405 6e48237b-75ef-9749-8fc9-41990f28c85a --- mpp/codec/inc/mpp_enc.h | 14 +++++++++++++- mpp/codec/mpp_enc.cpp | 32 ++++++++++++++++++++++++++++++++ mpp/mpp.cpp | 6 +++--- mpp/mpp.h | 3 ++- 4 files changed, 50 insertions(+), 5 deletions(-) diff --git a/mpp/codec/inc/mpp_enc.h b/mpp/codec/inc/mpp_enc.h index 1b7eb144..d320897b 100644 --- a/mpp/codec/inc/mpp_enc.h +++ b/mpp/codec/inc/mpp_enc.h @@ -17,7 +17,13 @@ #ifndef __MPP_ENC_H__ #define __MPP_ENC_H__ -#include "rk_type.h" +#include "rk_mpi.h" + +typedef struct MppEnc_t MppEnc; + +struct MppEnc_t { + MppCodingType coding; +}; #ifdef __cplusplus extern "C" { @@ -29,6 +35,12 @@ extern "C" { void *mpp_enc_control_thread(void *data); void *mpp_enc_hal_thread(void *data); + +MPP_RET mpp_enc_init(MppEnc **enc, MppCodingType coding); +MPP_RET mpp_enc_deinit(MppEnc *enc); + +MPP_RET mpp_enc_reset(MppEnc *enc); + #ifdef __cplusplus } #endif diff --git a/mpp/codec/mpp_enc.cpp b/mpp/codec/mpp_enc.cpp index 21a1d54f..271fc7b3 100644 --- a/mpp/codec/mpp_enc.cpp +++ b/mpp/codec/mpp_enc.cpp @@ -114,3 +114,35 @@ void *mpp_enc_hal_thread(void *data) return NULL; } +MPP_RET mpp_enc_init(MppEnc **enc, MppCodingType coding) +{ + MppEnc *p = mpp_calloc(MppEnc, 1); + if (NULL == p) { + mpp_err_f("failed to malloc context\n"); + return MPP_ERR_NULL_PTR; + } + + p->coding = coding; + *enc = p; + + return MPP_OK; +} + +MPP_RET mpp_enc_deinit(MppEnc *enc) +{ + if (NULL == enc) { + mpp_err_f("found NULL input\n"); + return MPP_ERR_NULL_PTR; + } + + mpp_free(enc); + return MPP_OK; +} + +MPP_RET mpp_enc_reset(MppEnc *enc) +{ + (void)enc; + return MPP_OK; +} + + diff --git a/mpp/mpp.cpp b/mpp/mpp.cpp index 98862d04..95b25164 100644 --- a/mpp/mpp.cpp +++ b/mpp/mpp.cpp @@ -77,7 +77,7 @@ Mpp::Mpp(MppCtxType type, MppCodingType coding) mPackets = new mpp_list((node_destructor)mpp_packet_deinit); mTasks = new mpp_list((node_destructor)NULL); - mpp_dec_init(&mEnc, coding); + mpp_enc_init(&mEnc, coding); mThreadCodec = new MppThread(mpp_enc_control_thread, this); mThreadHal = new MppThread(mpp_enc_hal_thread, this); @@ -130,7 +130,7 @@ void Mpp::clear() mDec = NULL; } else { - mpp_dec_deinit(mEnc); + mpp_enc_deinit(mEnc); mEnc = NULL; } } @@ -286,7 +286,7 @@ MPP_RET Mpp::reset() mThreadCodec->signal(); mThreadCodec->reset_wait(); } else { - mpp_dec_reset(mEnc); + mpp_enc_reset(mEnc); } mThreadCodec->reset_unlock(); diff --git a/mpp/mpp.h b/mpp/mpp.h index 165e3a6e..587cf17b 100644 --- a/mpp/mpp.h +++ b/mpp/mpp.h @@ -19,6 +19,7 @@ #include "mpp_list.h" #include "mpp_dec.h" +#include "mpp_enc.h" #define MPP_DBG_FUNCTION (0x00000001) #define MPP_DBG_PACKET (0x00000002) @@ -107,7 +108,7 @@ public: RK_U32 mStatus; MppDec *mDec; - MppDec *mEnc; + MppEnc *mEnc; private: void clear();