mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-06 01:26:49 +08:00
[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:
@@ -26,7 +26,6 @@ add_library(mpp STATIC
|
|||||||
mpp_buffer.cpp
|
mpp_buffer.cpp
|
||||||
mpp_packet.cpp
|
mpp_packet.cpp
|
||||||
mpp_frame.cpp
|
mpp_frame.cpp
|
||||||
mpp_dec.cpp
|
|
||||||
mpp.cpp
|
mpp.cpp
|
||||||
mpi_impl.cpp
|
mpi_impl.cpp
|
||||||
mpi.cpp
|
mpi.cpp
|
||||||
@@ -36,4 +35,4 @@ add_subdirectory(legacy)
|
|||||||
|
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
|
|
||||||
target_link_libraries(mpp mpp_legacy osal)
|
target_link_libraries(mpp mpp_hal mpp_codec mpp_legacy osal)
|
||||||
|
@@ -1,5 +1,13 @@
|
|||||||
# vim: syntax=cmake
|
# vim: syntax=cmake
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# add mpp_dec implement
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
add_library(mpp_codec STATIC
|
||||||
|
mpp_enc.cpp
|
||||||
|
mpp_dec.cpp
|
||||||
|
)
|
||||||
|
|
||||||
add_subdirectory(dec)
|
add_subdirectory(dec)
|
||||||
|
|
||||||
add_subdirectory(enc)
|
add_subdirectory(enc)
|
||||||
|
@@ -24,7 +24,7 @@ extern "C" {
|
|||||||
#endif
|
#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);
|
void *mpp_dec_thread(void *data);
|
||||||
|
|
35
mpp/codec/inc/mpp_enc.h
Normal file
35
mpp/codec/inc/mpp_enc.h
Normal 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__*/
|
@@ -17,11 +17,10 @@
|
|||||||
#define MODULE_TAG "mpp_dec"
|
#define MODULE_TAG "mpp_dec"
|
||||||
|
|
||||||
#include "mpp_log.h"
|
#include "mpp_log.h"
|
||||||
#include "mpp_time.h"
|
|
||||||
|
|
||||||
#include "mpp.h"
|
#include "mpp.h"
|
||||||
#include "mpp_dec.h"
|
#include "mpp_dec.h"
|
||||||
#include "mpp_frame_impl.h"
|
//#include "mpp_frame_impl.h"
|
||||||
#include "mpp_packet.h"
|
#include "mpp_packet.h"
|
||||||
#include "mpp_packet_impl.h"
|
#include "mpp_packet_impl.h"
|
||||||
|
|
||||||
@@ -33,7 +32,6 @@ void *mpp_dec_thread(void *data)
|
|||||||
MppThread *dec = mpp->mTheadCodec;
|
MppThread *dec = mpp->mTheadCodec;
|
||||||
MppThread *hal = mpp->mThreadHal;
|
MppThread *hal = mpp->mThreadHal;
|
||||||
mpp_list *packets = mpp->mPackets;
|
mpp_list *packets = mpp->mPackets;
|
||||||
mpp_list *frames = mpp->mFrames;
|
|
||||||
MppPacketImpl packet;
|
MppPacketImpl packet;
|
||||||
|
|
||||||
while (MPP_THREAD_RUNNING == dec->get_status()) {
|
while (MPP_THREAD_RUNNING == dec->get_status()) {
|
50
mpp/codec/mpp_enc.cpp
Normal file
50
mpp/codec/mpp_enc.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
@@ -1,4 +1,11 @@
|
|||||||
# vim: syntax=cmake
|
# vim: syntax=cmake
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# add mpp_hal implement
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
add_library(mpp_hal STATIC
|
||||||
|
mpp_hal.cpp
|
||||||
|
)
|
||||||
|
|
||||||
add_subdirectory(rkdec/h264d)
|
add_subdirectory(rkdec/h264d)
|
||||||
|
|
||||||
add_subdirectory(rkdec/h265d)
|
add_subdirectory(rkdec/h265d)
|
||||||
|
@@ -66,9 +66,19 @@ typedef struct {
|
|||||||
void *pointers[1];
|
void *pointers[1];
|
||||||
} MppHalDecTask;
|
} MppHalDecTask;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
void HalTaskSetDstBuffer();
|
void HalTaskSetDstBuffer();
|
||||||
void HalTaskSetDpb();
|
void HalTaskSetDpb();
|
||||||
void HalTaskSetDXVA();
|
void HalTaskSetDXVA();
|
||||||
|
|
||||||
|
void *mpp_hal_thread(void *data);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /*__HAL_TASK__*/
|
#endif /*__HAL_TASK__*/
|
||||||
|
|
||||||
|
81
mpp/hal/mpp_hal.cpp
Normal file
81
mpp/hal/mpp_hal.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
88
mpp/mpp.cpp
88
mpp/mpp.cpp
@@ -22,92 +22,14 @@
|
|||||||
|
|
||||||
#include "mpp.h"
|
#include "mpp.h"
|
||||||
#include "mpp_dec.h"
|
#include "mpp_dec.h"
|
||||||
|
#include "mpp_enc.h"
|
||||||
|
#include "mpp_hal.h"
|
||||||
#include "mpp_frame_impl.h"
|
#include "mpp_frame_impl.h"
|
||||||
#include "mpp_packet.h"
|
#include "mpp_packet.h"
|
||||||
#include "mpp_packet_impl.h"
|
#include "mpp_packet_impl.h"
|
||||||
|
|
||||||
#define MPP_TEST_FRAME_SIZE SZ_1M
|
#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)
|
Mpp::Mpp(MppCtxType type, MppCodingType coding)
|
||||||
: mPackets(NULL),
|
: mPackets(NULL),
|
||||||
mFrames(NULL),
|
mFrames(NULL),
|
||||||
@@ -134,7 +56,7 @@ Mpp::Mpp(MppCtxType type, MppCodingType coding)
|
|||||||
mFrames = new mpp_list((node_destructor)mpp_frame_deinit);
|
mFrames = new mpp_list((node_destructor)mpp_frame_deinit);
|
||||||
mTasks = new mpp_list((node_destructor)NULL);
|
mTasks = new mpp_list((node_destructor)NULL);
|
||||||
mTheadCodec = new MppThread(mpp_dec_thread, this);
|
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);
|
mTask = mpp_malloc(MppHalDecTask*, mTaskNum);
|
||||||
mpp_buffer_group_normal_get(&mPacketGroup, MPP_BUFFER_TYPE_NORMAL);
|
mpp_buffer_group_normal_get(&mPacketGroup, MPP_BUFFER_TYPE_NORMAL);
|
||||||
mpp_buffer_group_limited_get(&mFrameGroup, MPP_BUFFER_TYPE_ION);
|
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);
|
mFrames = new mpp_list((node_destructor)NULL);
|
||||||
mPackets = new mpp_list((node_destructor)mpp_packet_deinit);
|
mPackets = new mpp_list((node_destructor)mpp_packet_deinit);
|
||||||
mTasks = new mpp_list((node_destructor)NULL);
|
mTasks = new mpp_list((node_destructor)NULL);
|
||||||
mTheadCodec = new MppThread(thread_enc, this);
|
mTheadCodec = new MppThread(mpp_enc_thread, this);
|
||||||
mThreadHal = new MppThread(thread_hal, this);
|
mThreadHal = new MppThread(mpp_hal_thread, this);
|
||||||
mTask = mpp_malloc(MppHalDecTask*, mTaskNum);
|
mTask = mpp_malloc(MppHalDecTask*, mTaskNum);
|
||||||
mpp_buffer_group_normal_get(&mPacketGroup, MPP_BUFFER_TYPE_NORMAL);
|
mpp_buffer_group_normal_get(&mPacketGroup, MPP_BUFFER_TYPE_NORMAL);
|
||||||
mpp_buffer_group_limited_get(&mFrameGroup, MPP_BUFFER_TYPE_ION);
|
mpp_buffer_group_limited_get(&mFrameGroup, MPP_BUFFER_TYPE_ION);
|
||||||
|
Reference in New Issue
Block a user