diff --git a/mpp/CMakeLists.txt b/mpp/CMakeLists.txt index a3a679c6..4ee4a70d 100644 --- a/mpp/CMakeLists.txt +++ b/mpp/CMakeLists.txt @@ -26,6 +26,7 @@ add_library(mpp STATIC mpp_buffer.cpp mpp_packet.cpp mpp_frame.cpp + mpp_dec.cpp mpp.cpp mpi_impl.cpp mpi.cpp diff --git a/mpp/mpp.cpp b/mpp/mpp.cpp index c0e67891..3a287678 100644 --- a/mpp/mpp.cpp +++ b/mpp/mpp.cpp @@ -21,6 +21,7 @@ #include "mpp_time.h" #include "mpp.h" +#include "mpp_dec.h" #include "mpp_frame_impl.h" #include "mpp_packet.h" #include "mpp_packet_impl.h" @@ -83,82 +84,6 @@ void *thread_hal(void *data) return NULL; } -static void *thread_dec(void *data) -{ - Mpp *mpp = (Mpp*)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()) { - RK_U32 packet_ready = 0; - /* - * wait for stream input - */ - dec->lock(); - if (0 == packets->list_size()) - dec->wait(); - dec->unlock(); - - if (packets->list_size()) { - mpp->mPacketLock.lock(); - /* - * packet will be destroyed outside, here just copy the content - */ - packets->del_at_head(&packet, sizeof(packet)); - mpp->mPacketGetCount++; - packet_ready = 1; - mpp->mPacketLock.unlock(); - } - - if (packet_ready) { - /* - * 1. send packet data to parser - * - * parser functioin input / output - * input: packet data - * dxva output slot - * output: dxva output slot - * buffer usage informatioin - */ - - // decoder->parser->parse; - - /* - * 2. do buffer operation according to usage information - * - * possible case: - * a. normal case - * - wait and alloc a normal frame buffer - * b. field mode case - * - two field may reuse a same buffer, no need to alloc - * c. info change case - * - need buffer in different side, need to send a info change - * frame to hal loop. - */ - - //MppBuffer buffer; - //mpp_buffer_get(mpp->mFrameGroup, &buffer, MPP_TEST_FRAME_SIZE); - - - /* - * 3. send dxva output information and buffer information to hal thread - * combinate video codec dxva output and buffer information - */ - - // hal->wait_prev_done; - // hal->send_config; - mpp->mTasks->add_at_tail(&mpp->mTask[0], sizeof(mpp->mTask[0])); - mpp->mTaskPutCount++; - hal->signal(); - } - } - - return NULL; -} - static void *thread_enc(void *data) { Mpp *mpp = (Mpp*)data; @@ -208,7 +133,7 @@ Mpp::Mpp(MppCtxType type, MppCodingType coding) mPackets = new mpp_list((node_destructor)NULL); mFrames = new mpp_list((node_destructor)mpp_frame_deinit); mTasks = new mpp_list((node_destructor)NULL); - mTheadCodec = new MppThread(thread_dec, this); + mTheadCodec = new MppThread(mpp_dec_thread, this); mThreadHal = new MppThread(thread_hal, this); mTask = mpp_malloc(MppHalDecTask*, mTaskNum); mpp_buffer_group_normal_get(&mPacketGroup, MPP_BUFFER_TYPE_NORMAL); diff --git a/mpp/mpp_dec.cpp b/mpp/mpp_dec.cpp new file mode 100644 index 00000000..505d422a --- /dev/null +++ b/mpp/mpp_dec.cpp @@ -0,0 +1,105 @@ +/* + * 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_dec" + +#include "mpp_log.h" +#include "mpp_time.h" + +#include "mpp.h" +#include "mpp_dec.h" +#include "mpp_frame_impl.h" +#include "mpp_packet.h" +#include "mpp_packet_impl.h" + +#define MPP_TEST_FRAME_SIZE SZ_1M + +void *mpp_dec_thread(void *data) +{ + Mpp *mpp = (Mpp*)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()) { + RK_U32 packet_ready = 0; + /* + * wait for stream input + */ + dec->lock(); + if (0 == packets->list_size()) + dec->wait(); + dec->unlock(); + + if (packets->list_size()) { + mpp->mPacketLock.lock(); + /* + * packet will be destroyed outside, here just copy the content + */ + packets->del_at_head(&packet, sizeof(packet)); + mpp->mPacketGetCount++; + packet_ready = 1; + mpp->mPacketLock.unlock(); + } + + if (packet_ready) { + /* + * 1. send packet data to parser + * + * parser functioin input / output + * input: packet data + * dxva output slot + * output: dxva output slot + * buffer usage informatioin + */ + + // decoder->parser->parse; + + /* + * 2. do buffer operation according to usage information + * + * possible case: + * a. normal case + * - wait and alloc a normal frame buffer + * b. field mode case + * - two field may reuse a same buffer, no need to alloc + * c. info change case + * - need buffer in different side, need to send a info change + * frame to hal loop. + */ + + //MppBuffer buffer; + //mpp_buffer_get(mpp->mFrameGroup, &buffer, MPP_TEST_FRAME_SIZE); + + + /* + * 3. send dxva output information and buffer information to hal thread + * combinate video codec dxva output and buffer information + */ + + // hal->wait_prev_done; + // hal->send_config; + mpp->mTasks->add_at_tail(&mpp->mTask[0], sizeof(mpp->mTask[0])); + mpp->mTaskPutCount++; + hal->signal(); + } + } + + return NULL; +} +