mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-09 11:00:53 +08:00
[mpp]: add seek reset flow
[h265d]:add seek part code git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@381 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
@@ -184,13 +184,15 @@ RK_S32 h265d_split_init(void **sc)
|
|||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mpp_fetch_timestamp(SplitContext_t *s, RK_S32 off, RK_S32 remove)
|
void mpp_fetch_timestamp(SplitContext_t *s, RK_S32 off)
|
||||||
{
|
{
|
||||||
RK_S32 i;
|
RK_S32 i;
|
||||||
|
|
||||||
s->dts = s->pts = -1;
|
s->dts = s->pts = -1;
|
||||||
s->offset = 0;
|
s->offset = 0;
|
||||||
for (i = 0; i < MPP_PARSER_PTS_NB; i++) {
|
for (i = 0; i < MPP_PARSER_PTS_NB; i++) {
|
||||||
|
h265d_dbg(H265D_DBG_TIME, "s->cur_offset %lld s->cur_frame_offset[%d] %lld s->frame_offset %lld s->next_frame_offset %lld",
|
||||||
|
s->cur_offset, i, s->cur_frame_offset[i], s->frame_offset, s->next_frame_offset);
|
||||||
if ( s->cur_offset + off >= s->cur_frame_offset[i]
|
if ( s->cur_offset + off >= s->cur_frame_offset[i]
|
||||||
&& (s->frame_offset < s->cur_frame_offset[i] ||
|
&& (s->frame_offset < s->cur_frame_offset[i] ||
|
||||||
(!s->frame_offset && !s->next_frame_offset)) // first field/frame
|
(!s->frame_offset && !s->next_frame_offset)) // first field/frame
|
||||||
@@ -199,8 +201,6 @@ void mpp_fetch_timestamp(SplitContext_t *s, RK_S32 off, RK_S32 remove)
|
|||||||
s->dts = s->cur_frame_dts[i];
|
s->dts = s->cur_frame_dts[i];
|
||||||
s->pts = s->cur_frame_pts[i];
|
s->pts = s->cur_frame_pts[i];
|
||||||
s->offset = s->next_frame_offset - s->cur_frame_offset[i];
|
s->offset = s->next_frame_offset - s->cur_frame_offset[i];
|
||||||
/* if (remove)
|
|
||||||
s->cur_frame_offset[i] = INT64_MAX;*/
|
|
||||||
if (s->cur_offset + off < s->cur_frame_end[i])
|
if (s->cur_offset + off < s->cur_frame_end[i])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -231,7 +231,7 @@ RK_S32 h265d_split_frame(void *sc,
|
|||||||
s->fetch_timestamp = 0;
|
s->fetch_timestamp = 0;
|
||||||
s->last_pts = s->pts;
|
s->last_pts = s->pts;
|
||||||
s->last_dts = s->dts;
|
s->last_dts = s->dts;
|
||||||
mpp_fetch_timestamp(s, 0, 0);
|
mpp_fetch_timestamp(s, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->eos) {
|
if (s->eos) {
|
||||||
@@ -275,8 +275,8 @@ RK_S32 h265d_split_reset(void *sc)
|
|||||||
SplitContext_t *s = (SplitContext_t*)sc;
|
SplitContext_t *s = (SplitContext_t*)sc;
|
||||||
buf = s->buffer;
|
buf = s->buffer;
|
||||||
size = s->buffer_size;
|
size = s->buffer_size;
|
||||||
s->fetch_timestamp = 1;
|
|
||||||
memset(s, 0, sizeof(SplitContext_t));
|
memset(s, 0, sizeof(SplitContext_t));
|
||||||
|
s->fetch_timestamp = 1;
|
||||||
s->buffer = buf;
|
s->buffer = buf;
|
||||||
s->buffer_size = size;
|
s->buffer_size = size;
|
||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
@@ -1724,6 +1724,7 @@ MPP_RET h265d_deinit(void *ctx)
|
|||||||
if (s->input_packet) {
|
if (s->input_packet) {
|
||||||
buf = mpp_packet_get_data(s->input_packet);
|
buf = mpp_packet_get_data(s->input_packet);
|
||||||
mpp_free(buf);
|
mpp_free(buf);
|
||||||
|
mpp_packet_deinit(&s->input_packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s) {
|
if (s) {
|
||||||
|
@@ -168,7 +168,7 @@ static void fill_picture_parameters(const HEVCContext *h,
|
|||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frame) {
|
if (frame && (frame->slot_index != 0xff)) {
|
||||||
fill_picture_entry(&pp->RefPicList[i], frame->slot_index, !!(frame->flags & HEVC_FRAME_FLAG_LONG_REF));
|
fill_picture_entry(&pp->RefPicList[i], frame->slot_index, !!(frame->flags & HEVC_FRAME_FLAG_LONG_REF));
|
||||||
pp->PicOrderCntValList[i] = frame->poc;
|
pp->PicOrderCntValList[i] = frame->poc;
|
||||||
mpp_buf_slot_set_flag(h->slots, frame->slot_index, SLOT_HAL_INPUT);
|
mpp_buf_slot_set_flag(h->slots, frame->slot_index, SLOT_HAL_INPUT);
|
||||||
|
@@ -310,7 +310,9 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc)
|
|||||||
#endif
|
#endif
|
||||||
frame->poc = poc;
|
frame->poc = poc;
|
||||||
|
|
||||||
mpp_err("generate_missing_ref frame poc %d slot_index %d", poc, frame->slot_index);
|
mpp_buf_slot_set_flag(s->slots, frame->slot_index, SLOT_CODEC_READY);
|
||||||
|
mpp_buf_slot_set_flag(s->slots, frame->slot_index, SLOT_CODEC_USE);
|
||||||
|
mpp_log("generate_missing_ref frame poc %d slot_index %d", poc, frame->slot_index);
|
||||||
frame->sequence = s->seq_decode;
|
frame->sequence = s->seq_decode;
|
||||||
frame->flags = 0;
|
frame->flags = 0;
|
||||||
|
|
||||||
|
@@ -34,6 +34,7 @@ struct MppDec_t {
|
|||||||
MppBufSlots frame_slots;
|
MppBufSlots frame_slots;
|
||||||
MppBufSlots packet_slots;
|
MppBufSlots packet_slots;
|
||||||
HalTaskGroup tasks;
|
HalTaskGroup tasks;
|
||||||
|
RK_U32 reset_flag;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -210,8 +210,8 @@ static void dump_slots(MppBufSlotsImpl *impl)
|
|||||||
|
|
||||||
for (i = 0; i < impl->count; i++, slot++) {
|
for (i = 0; i < impl->count; i++, slot++) {
|
||||||
SlotStatus status = slot->status;
|
SlotStatus status = slot->status;
|
||||||
mpp_log("slot %2d used %d refer %d decoding %d display %d\n",
|
mpp_log("slot %2d used %d refer %d decoding %d display %d status %08x\n",
|
||||||
i, status.on_used, status.codec_use, status.hal_use, status.queue_use);
|
i, status.on_used, status.codec_use, status.hal_use, status.queue_use, status.val);
|
||||||
}
|
}
|
||||||
|
|
||||||
mpp_log("\nslot operation history:\n\n");
|
mpp_log("\nslot operation history:\n\n");
|
||||||
@@ -425,8 +425,11 @@ MPP_RET mpp_buf_slot_deinit(MppBufSlots slots)
|
|||||||
}
|
}
|
||||||
MppBufSlotEntry *slot = (MppBufSlotEntry *)impl->slots;
|
MppBufSlotEntry *slot = (MppBufSlotEntry *)impl->slots;
|
||||||
RK_S32 i;
|
RK_S32 i;
|
||||||
for (i = 0; i < impl->count; i++, slot++)
|
for (i = 0; i < impl->count; i++, slot++) {
|
||||||
|
if (slot->status.on_used)
|
||||||
|
dump_slots(impl);
|
||||||
mpp_assert(!slot->status.on_used);
|
mpp_assert(!slot->status.on_used);
|
||||||
|
}
|
||||||
|
|
||||||
if (impl->logs)
|
if (impl->logs)
|
||||||
delete impl->logs;
|
delete impl->logs;
|
||||||
|
@@ -82,9 +82,58 @@ void *mpp_dec_parser_thread(void *data)
|
|||||||
/*
|
/*
|
||||||
* wait for stream input
|
* wait for stream input
|
||||||
*/
|
*/
|
||||||
|
if (dec->reset_flag && !wait_on_frame_buffer) {
|
||||||
|
if (!prev_task_done) {
|
||||||
|
HalTaskHnd task_prev = NULL;
|
||||||
|
hal_task_get_hnd(tasks, TASK_PROC_DONE, &task_prev);
|
||||||
|
if (task_prev) {
|
||||||
|
prev_task_done = 1;
|
||||||
|
hal_task_hnd_set_status(task_prev, TASK_IDLE);
|
||||||
|
task_prev = NULL;
|
||||||
|
} else {
|
||||||
|
usleep(5000);
|
||||||
|
wait_on_prev = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
RK_S32 index;
|
||||||
|
parser->reset_lock();
|
||||||
|
curr_task_ready = 0;
|
||||||
|
task_dec->valid = 0;
|
||||||
|
parser_reset(dec->parser);
|
||||||
|
dec->reset_flag = 0;
|
||||||
|
if (packet) {
|
||||||
|
mpp_free(mpp_packet_get_data(packet));
|
||||||
|
mpp_packet_deinit(&packet);
|
||||||
|
packet = NULL;
|
||||||
|
}
|
||||||
|
while (MPP_OK == mpp_buf_slot_dequeue(frame_slots, &index, QUEUE_DISPLAY)) {
|
||||||
|
MppFrame frame;
|
||||||
|
mpp_buf_slot_get_prop(frame_slots, index, SLOT_FRAME, &frame);
|
||||||
|
mpp_frame_deinit(&frame);
|
||||||
|
mpp_buf_slot_clr_flag(frame_slots, index, SLOT_QUEUE_USE);
|
||||||
|
}
|
||||||
|
if (pkt_buf_copyied) {
|
||||||
|
mpp_buf_slot_get_prop(packet_slots, task_dec->input, SLOT_BUFFER, &buffer);
|
||||||
|
if (buffer) {
|
||||||
|
mpp_buffer_put(buffer);
|
||||||
|
buffer = NULL;
|
||||||
|
}
|
||||||
|
mpp_buf_slot_clr_flag(packet_slots, task_dec->input, SLOT_HAL_INPUT);
|
||||||
|
pkt_buf_copyied = 0;
|
||||||
|
task_dec->input = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
curr_task_parsed = 0;
|
||||||
|
parser->reset_unlock();
|
||||||
|
parser->reset_signal();
|
||||||
|
}
|
||||||
|
}
|
||||||
parser->lock();
|
parser->lock();
|
||||||
if (wait_on_task_hnd || wait_on_packet ||
|
if ((wait_on_task_hnd || wait_on_packet ||
|
||||||
wait_on_prev || wait_on_change || wait_on_frame_buffer)
|
wait_on_prev || wait_on_change || wait_on_frame_buffer) && !dec->reset_flag)
|
||||||
parser->wait();
|
parser->wait();
|
||||||
parser->unlock();
|
parser->unlock();
|
||||||
|
|
||||||
@@ -389,7 +438,11 @@ void *mpp_dec_hal_thread(void *data)
|
|||||||
while (MPP_OK == mpp_buf_slot_dequeue(frame_slots, &index, QUEUE_DISPLAY)) {
|
while (MPP_OK == mpp_buf_slot_dequeue(frame_slots, &index, QUEUE_DISPLAY)) {
|
||||||
MppFrame frame;
|
MppFrame frame;
|
||||||
mpp_buf_slot_get_prop(frame_slots, index, SLOT_FRAME, &frame);
|
mpp_buf_slot_get_prop(frame_slots, index, SLOT_FRAME, &frame);
|
||||||
|
if (!dec->reset_flag) {
|
||||||
mpp_put_frame(mpp, frame);
|
mpp_put_frame(mpp, frame);
|
||||||
|
} else {
|
||||||
|
mpp_frame_deinit(&frame);
|
||||||
|
}
|
||||||
mpp_buf_slot_clr_flag(frame_slots, index, SLOT_QUEUE_USE);
|
mpp_buf_slot_clr_flag(frame_slots, index, SLOT_QUEUE_USE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -510,9 +563,9 @@ MPP_RET mpp_dec_reset(MppDec *dec)
|
|||||||
mpp_err_f("found NULL input dec %p\n", dec);
|
mpp_err_f("found NULL input dec %p\n", dec);
|
||||||
return MPP_ERR_NULL_PTR;
|
return MPP_ERR_NULL_PTR;
|
||||||
}
|
}
|
||||||
|
dec->reset_flag = 1;
|
||||||
parser_reset(dec->parser);
|
// parser_reset(dec->parser);
|
||||||
mpp_hal_reset(dec->hal);
|
// mpp_hal_reset(dec->hal);
|
||||||
|
|
||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
@@ -41,6 +41,7 @@
|
|||||||
#include "mpp_dec.h"
|
#include "mpp_dec.h"
|
||||||
#include "vpu.h"
|
#include "vpu.h"
|
||||||
#include "mpp_buffer.h"
|
#include "mpp_buffer.h"
|
||||||
|
#include "mpp_env.h"
|
||||||
|
|
||||||
#ifdef dump
|
#ifdef dump
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
@@ -313,7 +314,7 @@ MPP_RET hal_h265d_init(void *hal, MppHalCfg *cfg)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mpp_env_get_u32("h265h_debug", &h265h_debug, 0);
|
||||||
|
|
||||||
#ifdef dump
|
#ifdef dump
|
||||||
fp = fopen("/data/hal.bin", "wb");
|
fp = fopen("/data/hal.bin", "wb");
|
||||||
@@ -1303,6 +1304,7 @@ MPP_RET hal_h265d_gen_regs(void *hal, HalTaskInfo *syn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
hw_regs = (H265d_REGS_t*)reg_cxt->hw_regs;
|
hw_regs = (H265d_REGS_t*)reg_cxt->hw_regs;
|
||||||
|
memset(hw_regs, 0, sizeof(H265d_REGS_t));
|
||||||
|
|
||||||
uiMaxCUWidth = 1 << (dxva_cxt->pp.log2_diff_max_min_luma_coding_block_size +
|
uiMaxCUWidth = 1 << (dxva_cxt->pp.log2_diff_max_min_luma_coding_block_size +
|
||||||
dxva_cxt->pp.log2_min_luma_coding_block_size_minus3 + 3);
|
dxva_cxt->pp.log2_min_luma_coding_block_size_minus3 + 3);
|
||||||
@@ -1378,6 +1380,8 @@ MPP_RET hal_h265d_gen_regs(void *hal, HalTaskInfo *syn)
|
|||||||
mpp_buf_slot_get_prop(reg_cxt->slots, dxva_cxt->pp.RefPicList[i].Index7Bits, SLOT_BUFFER, &framebuf);
|
mpp_buf_slot_get_prop(reg_cxt->slots, dxva_cxt->pp.RefPicList[i].Index7Bits, SLOT_BUFFER, &framebuf);
|
||||||
if (framebuf != NULL) {
|
if (framebuf != NULL) {
|
||||||
hw_regs->sw_refer_base[i] = mpp_buffer_get_fd(framebuf);
|
hw_regs->sw_refer_base[i] = mpp_buffer_get_fd(framebuf);
|
||||||
|
} else {
|
||||||
|
hw_regs->sw_refer_base[i] = hw_regs->sw_decout_base;
|
||||||
}
|
}
|
||||||
hw_regs->sw_ref_valid |= (1 << i);
|
hw_regs->sw_ref_valid |= (1 << i);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -330,8 +330,8 @@ static RK_S32 get_free_memory_num(vpu_display_mem_pool *p)
|
|||||||
|
|
||||||
static RK_S32 reset_vpu_mem_pool(vpu_display_mem_pool *p)
|
static RK_S32 reset_vpu_mem_pool(vpu_display_mem_pool *p)
|
||||||
{
|
{
|
||||||
(void)p;
|
vpu_display_mem_pool_impl *p_mempool = (vpu_display_mem_pool_impl *)p;
|
||||||
// vpu_display_mem_pool_impl *p_mempool = (vpu_display_mem_pool_impl *)p;
|
mpp_buffer_group_clear(p_mempool->group);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -72,8 +72,9 @@ RK_S32 VpuApi::init(VpuCodecContext *ctx, RK_U8 *extraData, RK_U32 extra_size)
|
|||||||
|
|
||||||
RK_S32 VpuApi::flush(VpuCodecContext *ctx)
|
RK_S32 VpuApi::flush(VpuCodecContext *ctx)
|
||||||
{
|
{
|
||||||
mpp_log_f("in\n");
|
|
||||||
(void)ctx;
|
(void)ctx;
|
||||||
|
mpp_log_f("in\n");
|
||||||
|
mpi->flush(mpp_ctx);
|
||||||
mpp_log_f("ok\n");
|
mpp_log_f("ok\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -127,11 +127,11 @@ static MPP_RET mpi_encode_get_packet(MppCtx ctx, MppPacket *packet)
|
|||||||
|
|
||||||
static MPP_RET mpi_flush(MppCtx ctx)
|
static MPP_RET mpi_flush(MppCtx ctx)
|
||||||
{
|
{
|
||||||
(void)ctx;
|
MpiImpl *p = (MpiImpl *)ctx;
|
||||||
MPI_FUNCTION_ENTER();
|
MPI_FUNCTION_ENTER();
|
||||||
|
MPP_RET ret = p->ctx->reset();
|
||||||
MPI_FUNCTION_LEAVE();
|
MPI_FUNCTION_LEAVE();
|
||||||
return MPP_OK;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static MPP_RET mpi_control(MppCtx ctx, MpiCmd cmd, MppParam param)
|
static MPP_RET mpi_control(MppCtx ctx, MpiCmd cmd, MppParam param)
|
||||||
|
17
mpp/mpp.cpp
17
mpp/mpp.cpp
@@ -260,3 +260,20 @@ MPP_RET Mpp::control(MpiCmd cmd, MppParam param)
|
|||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MPP_RET Mpp::reset()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
Mutex::Autolock autoLock(mPackets->mutex());
|
||||||
|
mPackets->flush();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Mutex::Autolock autoLock(mFrames->mutex());
|
||||||
|
mFrames->flush();
|
||||||
|
}
|
||||||
|
mThreadCodec->reset_lock();
|
||||||
|
mpp_dec_reset(mDec);
|
||||||
|
mThreadCodec->signal();
|
||||||
|
mThreadCodec->reset_wait();
|
||||||
|
mThreadCodec->reset_unlock();
|
||||||
|
return MPP_OK;
|
||||||
|
}
|
||||||
|
@@ -67,6 +67,7 @@ public:
|
|||||||
MPP_RET put_frame(MppFrame frame);
|
MPP_RET put_frame(MppFrame frame);
|
||||||
MPP_RET get_packet(MppPacket *packet);
|
MPP_RET get_packet(MppPacket *packet);
|
||||||
|
|
||||||
|
MPP_RET reset();
|
||||||
MPP_RET control(MpiCmd cmd, MppParam param);
|
MPP_RET control(MpiCmd cmd, MppParam param);
|
||||||
|
|
||||||
mpp_list *mPackets;
|
mpp_list *mPackets;
|
||||||
|
@@ -170,10 +170,16 @@ public:
|
|||||||
void wait() { mCondition.wait(mLock); }
|
void wait() { mCondition.wait(mLock); }
|
||||||
void signal() { mCondition.signal(); }
|
void signal() { mCondition.signal(); }
|
||||||
|
|
||||||
|
void reset_lock() { mResetLock.lock(); }
|
||||||
|
void reset_unlock() { mResetLock.unlock(); }
|
||||||
|
void reset_wait() { mResetCondition.wait(mResetLock); }
|
||||||
|
void reset_signal() { mResetCondition.signal(); }
|
||||||
private:
|
private:
|
||||||
Mutex mLock;
|
Mutex mLock;
|
||||||
Condition mCondition;
|
Condition mCondition;
|
||||||
pthread_t mThread;
|
pthread_t mThread;
|
||||||
|
Mutex mResetLock;
|
||||||
|
Condition mResetCondition;
|
||||||
|
|
||||||
MppThreadStatus mStatus;
|
MppThreadStatus mStatus;
|
||||||
MppThreadFunc mFunction;
|
MppThreadFunc mFunction;
|
||||||
|
Reference in New Issue
Block a user