[mpp]: separate mpp_dec / mpp_enc / mpp_hal modules

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@173 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
ChenHengming
2015-08-27 08:37:01 +00:00
parent ac2bd93769
commit fa58085605
10 changed files with 199 additions and 89 deletions

View File

@@ -26,7 +26,6 @@ add_library(mpp STATIC
mpp_buffer.cpp
mpp_packet.cpp
mpp_frame.cpp
mpp_dec.cpp
mpp.cpp
mpi_impl.cpp
mpi.cpp
@@ -36,4 +35,4 @@ add_subdirectory(legacy)
add_subdirectory(test)
target_link_libraries(mpp mpp_legacy osal)
target_link_libraries(mpp mpp_hal mpp_codec mpp_legacy osal)

View File

@@ -1,5 +1,13 @@
# vim: syntax=cmake
# ----------------------------------------------------------------------------
# add mpp_dec implement
# ----------------------------------------------------------------------------
add_library(mpp_codec STATIC
mpp_enc.cpp
mpp_dec.cpp
)
add_subdirectory(dec)
add_subdirectory(enc)

View File

@@ -24,7 +24,7 @@ extern "C" {
#endif
/*
* main thread for all decoder. This thread will connet parser / hal / mpp
* main thread for all decoder. This thread will connect parser / hal / mpp
*/
void *mpp_dec_thread(void *data);

35
mpp/codec/inc/mpp_enc.h Normal file
View File

@@ -0,0 +1,35 @@
/*
* Copyright 2010 Rockchip Electronics S.LSI 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_H__
#define __MPP_ENC_H__
#include "rk_type.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* main thread for all encoder. This thread will connect encoder / hal / mpp
*/
void *mpp_enc_thread(void *data);
#ifdef __cplusplus
}
#endif
#endif /*__MPP_ENC_H__*/

View File

@@ -17,11 +17,10 @@
#define MODULE_TAG "mpp_dec"
#include "mpp_log.h"
#include "mpp_time.h"
#include "mpp.h"
#include "mpp_dec.h"
#include "mpp_frame_impl.h"
//#include "mpp_frame_impl.h"
#include "mpp_packet.h"
#include "mpp_packet_impl.h"
@@ -33,7 +32,6 @@ void *mpp_dec_thread(void *data)
MppThread *dec = mpp->mTheadCodec;
MppThread *hal = mpp->mThreadHal;
mpp_list *packets = mpp->mPackets;
mpp_list *frames = mpp->mFrames;
MppPacketImpl packet;
while (MPP_THREAD_RUNNING == dec->get_status()) {

50
mpp/codec/mpp_enc.cpp Normal file
View File

@@ -0,0 +1,50 @@
/*
* Copyright 2010 Rockchip Electronics S.LSI 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.
*/
#define MODULE_TAG "mpp_enc"
#include "mpp_log.h"
#include "mpp_mem.h"
#include "mpp.h"
#include "mpp_enc.h"
#include "mpp_frame_impl.h"
#include "mpp_packet.h"
#include "mpp_packet_impl.h"
void *mpp_enc_thread(void *data)
{
Mpp *mpp = (Mpp*)data;
MppThread *thd_enc = mpp->mTheadCodec;
mpp_list *packets = mpp->mPackets;
mpp_list *frames = mpp->mFrames;
MppFrameImpl frame;
MppPacket packet;
size_t size = SZ_1M;
char *buf = mpp_malloc(char, size);
while (MPP_THREAD_RUNNING == thd_enc->get_status()) {
if (frames->list_size()) {
frames->del_at_head(&frame, sizeof(frame));
mpp_packet_init(&packet, buf, size);
packets->add_at_tail(&packet, sizeof(packet));
}
}
mpp_free(buf);
return NULL;
}

View File

@@ -1,4 +1,11 @@
# vim: syntax=cmake
# ----------------------------------------------------------------------------
# add mpp_hal implement
# ----------------------------------------------------------------------------
add_library(mpp_hal STATIC
mpp_hal.cpp
)
add_subdirectory(rkdec/h264d)
add_subdirectory(rkdec/h265d)

View File

@@ -66,9 +66,19 @@ typedef struct {
void *pointers[1];
} MppHalDecTask;
#ifdef __cplusplus
extern "C" {
#endif
void HalTaskSetDstBuffer();
void HalTaskSetDpb();
void HalTaskSetDXVA();
void *mpp_hal_thread(void *data);
#ifdef __cplusplus
}
#endif
#endif /*__HAL_TASK__*/

81
mpp/hal/mpp_hal.cpp Normal file
View File

@@ -0,0 +1,81 @@
/*
* Copyright 2010 Rockchip Electronics S.LSI 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.
*/
#define MODULE_TAG "mpp_hal"
#include "mpp_log.h"
#include "mpp.h"
#include "mpp_hal.h"
#include "mpp_frame_impl.h"
#define MPP_TEST_FRAME_SIZE SZ_1M
void *mpp_hal_thread(void *data)
{
Mpp *mpp = (Mpp*)data;
MppThread *hal = mpp->mThreadHal;
mpp_list *frames = mpp->mFrames;
mpp_list *tasks = mpp->mTasks;
while (MPP_THREAD_RUNNING == hal->get_status()) {
/*
* hal thread wait for dxva interface intput firt
*/
hal->lock();
if (0 == tasks->list_size())
hal->wait();
hal->unlock();
// get_config
// register genertation
if (tasks->list_size()) {
MppHalDecTask *task;
mpp->mTasks->del_at_head(&task, sizeof(task));
mpp->mTaskGetCount++;
/*
* wait previous register set done
*/
// hal->get_regs;
/*
* send current register set to hardware
*/
// hal->put_regs;
/*
* mark previous buffer is complete
*/
// signal()
// mark frame in output queue
// wait up output thread to get a output frame
// for test
MppBuffer buffer;
mpp_buffer_get(mpp->mFrameGroup, &buffer, MPP_TEST_FRAME_SIZE);
MppFrame frame;
mpp_frame_init(&frame);
mpp_frame_set_buffer(frame, buffer);
frames->add_at_tail(&frame, sizeof(frame));
mpp->mFramePutCount++;
}
}
return NULL;
}

View File

@@ -22,92 +22,14 @@
#include "mpp.h"
#include "mpp_dec.h"
#include "mpp_enc.h"
#include "mpp_hal.h"
#include "mpp_frame_impl.h"
#include "mpp_packet.h"
#include "mpp_packet_impl.h"
#define MPP_TEST_FRAME_SIZE SZ_1M
void *thread_hal(void *data)
{
Mpp *mpp = (Mpp*)data;
MppThread *codec = mpp->mTheadCodec;
MppThread *hal = mpp->mThreadHal;
mpp_list *frames = mpp->mFrames;
mpp_list *tasks = mpp->mTasks;
while (MPP_THREAD_RUNNING == hal->get_status()) {
/*
* hal thread wait for dxva interface intput firt
*/
hal->lock();
if (0 == tasks->list_size())
hal->wait();
hal->unlock();
// get_config
// register genertation
if (tasks->list_size()) {
MppHalDecTask *task;
mpp->mTasks->del_at_head(&task, sizeof(task));
mpp->mTaskGetCount++;
/*
* wait previous register set done
*/
// hal->get_regs;
/*
* send current register set to hardware
*/
// hal->put_regs;
/*
* mark previous buffer is complete
*/
// signal()
// mark frame in output queue
// wait up output thread to get a output frame
// for test
MppBuffer buffer;
mpp_buffer_get(mpp->mFrameGroup, &buffer, MPP_TEST_FRAME_SIZE);
MppFrame frame;
mpp_frame_init(&frame);
mpp_frame_set_buffer(frame, buffer);
frames->add_at_tail(&frame, sizeof(frame));
mpp->mFramePutCount++;
}
}
return NULL;
}
static void *thread_enc(void *data)
{
Mpp *mpp = (Mpp*)data;
MppThread *thd_enc = mpp->mTheadCodec;
MppThread *thd_hal = mpp->mThreadHal;
mpp_list *packets = mpp->mPackets;
mpp_list *frames = mpp->mFrames;
MppFrameImpl frame;
MppPacket packet;
size_t size = SZ_1M;
char *buf = mpp_malloc(char, size);
while (MPP_THREAD_RUNNING == thd_enc->get_status()) {
if (frames->list_size()) {
frames->del_at_head(&frame, sizeof(frame));
mpp_packet_init(&packet, buf, size);
packets->add_at_tail(&packet, sizeof(packet));
}
}
mpp_free(buf);
return NULL;
}
Mpp::Mpp(MppCtxType type, MppCodingType coding)
: mPackets(NULL),
mFrames(NULL),
@@ -134,7 +56,7 @@ Mpp::Mpp(MppCtxType type, MppCodingType coding)
mFrames = new mpp_list((node_destructor)mpp_frame_deinit);
mTasks = new mpp_list((node_destructor)NULL);
mTheadCodec = new MppThread(mpp_dec_thread, this);
mThreadHal = new MppThread(thread_hal, this);
mThreadHal = new MppThread(mpp_hal_thread, this);
mTask = mpp_malloc(MppHalDecTask*, mTaskNum);
mpp_buffer_group_normal_get(&mPacketGroup, MPP_BUFFER_TYPE_NORMAL);
mpp_buffer_group_limited_get(&mFrameGroup, MPP_BUFFER_TYPE_ION);
@@ -144,8 +66,8 @@ Mpp::Mpp(MppCtxType type, MppCodingType coding)
mFrames = new mpp_list((node_destructor)NULL);
mPackets = new mpp_list((node_destructor)mpp_packet_deinit);
mTasks = new mpp_list((node_destructor)NULL);
mTheadCodec = new MppThread(thread_enc, this);
mThreadHal = new MppThread(thread_hal, this);
mTheadCodec = new MppThread(mpp_enc_thread, this);
mThreadHal = new MppThread(mpp_hal_thread, this);
mTask = mpp_malloc(MppHalDecTask*, mTaskNum);
mpp_buffer_group_normal_get(&mPacketGroup, MPP_BUFFER_TYPE_NORMAL);
mpp_buffer_group_limited_get(&mFrameGroup, MPP_BUFFER_TYPE_ION);