mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-12-26 11:17:44 +01:00
fix[parser]: Ensure the DTS is transmitted to the frame
Support Codec list: - [x] H.264 - [x] H.265 - [x] m2vd - [x] m4vd - [x] H.263 - [x] AV1 - [x] AVS - [x] AVS2 - [x] JPEG - [x] VP8 - [x] VP9 Signed-off-by: Rimon Xu <rimon.xu@rock-chips.com> Change-Id: Ieff2ef14482256031fcc699e6894a546c9b29502
This commit is contained in:
parent
c1f1c12dcf
commit
7e060500df
14 changed files with 30 additions and 0 deletions
|
|
@ -620,6 +620,7 @@ static MPP_RET set_output_frame(Av1CodecContext *ctx)
|
|||
fill_hdr_meta_to_frame(frame, MPP_VIDEO_CodingAV1);
|
||||
}
|
||||
mpp_frame_set_pts(frame, s->pts);
|
||||
mpp_frame_set_dts(frame, s->dts);
|
||||
mpp_buf_slot_set_flag(s->slots, s->cur_frame.slot_index, SLOT_QUEUE_USE);
|
||||
mpp_buf_slot_enqueue(s->slots, s->cur_frame.slot_index, QUEUE_DISPLAY);
|
||||
s->cur_frame.ref->is_output = 1;
|
||||
|
|
@ -772,6 +773,7 @@ static MPP_RET get_current_frame(Av1CodecContext *ctx)
|
|||
mpp_frame_set_errinfo(frame->f, 0);
|
||||
mpp_frame_set_discard(frame->f, 0);
|
||||
mpp_frame_set_pts(frame->f, s->pts);
|
||||
mpp_frame_set_dts(frame->f, s->dts);
|
||||
|
||||
mpp_frame_set_color_trc(frame->f, ctx->color_trc);
|
||||
mpp_frame_set_color_primaries(frame->f, ctx->color_primaries);
|
||||
|
|
@ -952,6 +954,7 @@ MPP_RET av1d_parser_frame(Av1CodecContext *ctx, HalDecTask *task)
|
|||
size = (RK_S32)mpp_packet_get_length(ctx->pkt);
|
||||
|
||||
s->pts = mpp_packet_get_pts(ctx->pkt);
|
||||
s->dts = mpp_packet_get_dts(ctx->pkt);
|
||||
|
||||
s->current_obu.data = data;
|
||||
s->current_obu.data_size = size;
|
||||
|
|
|
|||
|
|
@ -150,6 +150,7 @@ typedef struct AV1Context_t {
|
|||
HalDecTask *task;
|
||||
RK_S32 eos; ///< current packet contains an EOS/EOB NAL
|
||||
RK_S64 pts;
|
||||
RK_S64 dts;
|
||||
const MppDecHwCap *hw_info;
|
||||
} AV1Context;
|
||||
|
||||
|
|
|
|||
|
|
@ -270,6 +270,7 @@ static MPP_RET avsd_prepare(void *decoder, MppPacket pkt, HalDecTask *task)
|
|||
mpp_packet_set_data(p_dec->task_pkt, p_dec->streambuf);
|
||||
mpp_packet_set_length(p_dec->task_pkt, length);
|
||||
mpp_packet_set_pts(p_dec->task_pkt, mpp_packet_get_pts(pkt));
|
||||
mpp_packet_set_dts(p_dec->task_pkt, mpp_packet_get_dts(pkt));
|
||||
// set input packet length to 0 here
|
||||
mpp_packet_set_length(pkt, 0);
|
||||
/* this step will enable the task and goto parse stage */
|
||||
|
|
|
|||
|
|
@ -671,6 +671,7 @@ MPP_RET avsd_parser_split(AvsdCtx_t *p, MppPacket *dst, MppPacket *src)
|
|||
RK_U32 src_len = (RK_U32)mpp_packet_get_length(src);
|
||||
RK_U32 src_eos = mpp_packet_get_eos(src);
|
||||
RK_S64 src_pts = mpp_packet_get_pts(src);
|
||||
RK_S64 src_dts = mpp_packet_get_dts(src);
|
||||
RK_U8 *dst_buf = (RK_U8 *)mpp_packet_get_data(dst);
|
||||
RK_U32 dst_len = (RK_U32)mpp_packet_get_length(dst);
|
||||
RK_U32 src_pos = 0;
|
||||
|
|
@ -692,6 +693,7 @@ MPP_RET avsd_parser_split(AvsdCtx_t *p, MppPacket *dst, MppPacket *src)
|
|||
p->state == PB_PICUTRE_START_CODE) {
|
||||
p->vop_header_found = 1;
|
||||
mpp_packet_set_pts(dst, src_pts);
|
||||
mpp_packet_set_dts(dst, src_dts);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ typedef struct {
|
|||
size_t stream_size;
|
||||
MppPacket task_pkt;
|
||||
RK_S64 task_pts;
|
||||
RK_S64 task_dts;
|
||||
RK_U32 task_eos;
|
||||
|
||||
// runtime parameter
|
||||
|
|
@ -222,6 +223,7 @@ MPP_RET h263d_prepare(void *dec, MppPacket pkt, HalDecTask *task)
|
|||
mpp_packet_set_pos(pkt, pos + length);
|
||||
// always use latest pts for current packet
|
||||
p->task_pts = mpp_packet_get_pts(pkt);
|
||||
p->task_dts = mpp_packet_get_dts(pkt);
|
||||
p->task_eos = mpp_packet_get_eos(pkt);
|
||||
/* this step will enable the task and goto parse stage */
|
||||
task->valid = 1;
|
||||
|
|
@ -259,10 +261,12 @@ MPP_RET h263d_prepare(void *dec, MppPacket pkt, HalDecTask *task)
|
|||
task->valid = 1;
|
||||
}
|
||||
p->task_pts = mpp_packet_get_pts(p->task_pkt);
|
||||
p->task_dts = mpp_packet_get_dts(p->task_pkt);
|
||||
p->task_eos = mpp_packet_get_eos(p->task_pkt);
|
||||
}
|
||||
|
||||
mpp_packet_set_pts(p->task_pkt, p->task_pts);
|
||||
mpp_packet_set_dts(p->task_pkt, p->task_dts);
|
||||
task->input_packet = p->task_pkt;
|
||||
task->flags.eos = p->task_eos;
|
||||
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ typedef struct {
|
|||
// dpb/output information
|
||||
RK_S32 output;
|
||||
RK_S64 pts;
|
||||
RK_S64 dts;
|
||||
|
||||
// syntax for hal
|
||||
h263d_dxva2_picture_context_t *syntax;
|
||||
|
|
@ -435,6 +436,7 @@ MPP_RET mpp_h263_parser_decode(H263dParser ctx, MppPacket pkt)
|
|||
p->width = p->hdr_curr.width;
|
||||
p->height = p->hdr_curr.height;
|
||||
p->pts = mpp_packet_get_pts(pkt);
|
||||
p->dts = mpp_packet_get_dts(pkt);
|
||||
__BITREAD_ERR:
|
||||
h263d_dbg_status("found i_frame %d frame_type %d ret %d\n",
|
||||
p->found_i_vop, p->hdr_curr.pict_type, ret);
|
||||
|
|
@ -499,6 +501,7 @@ MPP_RET mpp_h263_parser_setup_hal_output(H263dParser ctx, RK_S32 *output)
|
|||
mpp_buf_slot_get_unused(slots, &index);
|
||||
mpp_buf_slot_set_flag(slots, index, SLOT_HAL_OUTPUT);
|
||||
mpp_frame_set_pts(frame, p->pts);
|
||||
mpp_frame_set_dts(frame, p->dts);
|
||||
mpp_frame_set_mode(frame, MPP_FRAME_FLAG_FRAME);
|
||||
|
||||
mpp_buf_slot_set_prop(slots, index, SLOT_FRAME, frame);
|
||||
|
|
|
|||
|
|
@ -430,6 +430,7 @@ MPP_RET mpp_m2vd_parser_split(M2VDParserContext *ctx, MppPacket dst, MppPacket s
|
|||
*/
|
||||
if (p->state == SEQUENCE_HEADER_CODE || p->state == PICTURE_START_CODE) {
|
||||
p->pts = mpp_packet_get_pts(src);
|
||||
p->dts = mpp_packet_get_dts(src);
|
||||
p->vop_header_found = 1;
|
||||
break;
|
||||
}
|
||||
|
|
@ -530,6 +531,7 @@ MPP_RET m2vd_parser_prepare(void *ctx, MppPacket pkt, HalDecTask *task)
|
|||
mpp_packet_set_eos(p->input_packet);
|
||||
|
||||
p->pts = mpp_packet_get_pts(pkt);
|
||||
p->dts = mpp_packet_get_dts(pkt);
|
||||
task->valid = 1;
|
||||
mpp_packet_set_length(pkt, 0);
|
||||
} else {
|
||||
|
|
@ -548,6 +550,7 @@ MPP_RET m2vd_parser_prepare(void *ctx, MppPacket pkt, HalDecTask *task)
|
|||
|
||||
p->eos = mpp_packet_get_eos(p->input_packet);
|
||||
mpp_packet_set_pts(p->input_packet, p->pts);
|
||||
mpp_packet_set_dts(p->input_packet, p->dts);
|
||||
task->input_packet = p->input_packet;
|
||||
task->flags.eos = p->eos;
|
||||
|
||||
|
|
@ -1287,6 +1290,7 @@ static MPP_RET m2vd_alloc_frame(M2VDParserContext *ctx)
|
|||
mpp_frame_set_ver_stride(ctx->frame_cur->f, 0);
|
||||
mpp_frame_set_errinfo(ctx->frame_cur->f, 0);
|
||||
mpp_frame_set_pts(ctx->frame_cur->f, frm_pts);
|
||||
mpp_frame_set_dts(ctx->frame_cur->f, ctx->dts);
|
||||
ctx->frame_cur->flags = M2V_OUT_FLAG;
|
||||
|
||||
if (ctx->seq_ext_head.progressive_sequence) {
|
||||
|
|
|
|||
|
|
@ -292,6 +292,7 @@ typedef struct M2VDParserContext_t {
|
|||
MppDecCfgSet *dec_cfg;
|
||||
|
||||
RK_U64 pts;
|
||||
RK_U64 dts;
|
||||
|
||||
FILE *fp_dbg_file[M2VD_DBG_FILE_NUM];
|
||||
FILE *fp_dbg_yuv;
|
||||
|
|
|
|||
|
|
@ -252,6 +252,7 @@ static MPP_RET mpg4d_prepare(void *dec, MppPacket pkt, HalDecTask *task)
|
|||
mpp_packet_set_pos(p->task_pkt, p->stream);
|
||||
mpp_packet_set_length(p->task_pkt, length);
|
||||
mpp_packet_set_pts(p->task_pkt, mpp_packet_get_pts(pkt));
|
||||
mpp_packet_set_dts(p->task_pkt, mpp_packet_get_dts(pkt));
|
||||
// set input packet length to 0 here
|
||||
// indicate that the input packet has been all consumed
|
||||
mpp_packet_set_pos(pkt, pos + length);
|
||||
|
|
|
|||
|
|
@ -195,6 +195,7 @@ typedef struct {
|
|||
RK_S64 last_pts;
|
||||
RK_S64 pts_inc;
|
||||
RK_S64 pts;
|
||||
RK_S64 dts;
|
||||
RK_U32 frame_num;
|
||||
MppDecCfgSet *dec_cfg;
|
||||
|
||||
|
|
@ -1361,6 +1362,7 @@ MPP_RET mpp_mpg4_parser_decode(Mpg4dParser ctx, MppPacket pkt)
|
|||
}
|
||||
|
||||
p->pts = mpp_packet_get_pts(pkt);
|
||||
p->dts = mpp_packet_get_dts(pkt);
|
||||
|
||||
ret = (p->found_vol && p->found_vop) ? (MPP_OK) : (MPP_NOK);
|
||||
|
||||
|
|
@ -1435,6 +1437,7 @@ MPP_RET mpp_mpg4_parser_setup_hal_output(Mpg4dParser ctx, RK_S32 *output)
|
|||
mpp_buf_slot_get_unused(slots, &index);
|
||||
mpp_buf_slot_set_flag(slots, index, SLOT_HAL_OUTPUT);
|
||||
mpp_frame_set_pts(frame, p->pts);
|
||||
mpp_frame_set_dts(frame, p->dts);
|
||||
|
||||
if (hdr_curr->vol.interlacing) {
|
||||
frame_mode = MPP_FRAME_FLAG_PAIRED_FIELD;
|
||||
|
|
|
|||
|
|
@ -439,6 +439,7 @@ MPP_RET vp8d_parser_prepare(void *ctx, MppPacket pkt, HalDecTask *task)
|
|||
|
||||
buf = pos = mpp_packet_get_pos(pkt);
|
||||
p->pts = mpp_packet_get_pts(pkt);
|
||||
p->dts = mpp_packet_get_dts(pkt);
|
||||
|
||||
len_in = (RK_U32)mpp_packet_get_length(pkt),
|
||||
p->eos = mpp_packet_get_eos(pkt);
|
||||
|
|
@ -630,6 +631,7 @@ static MPP_RET vp8d_alloc_frame(VP8DParserContext_t *p)
|
|||
mpp_frame_set_ver_stride(p->frame_out->f, 0);
|
||||
mpp_frame_set_errinfo(p->frame_out->f, 0);
|
||||
mpp_frame_set_pts(p->frame_out->f, p->pts);
|
||||
mpp_frame_set_dts(p->frame_out->f, p->dts);
|
||||
ret = mpp_buf_slot_get_unused(p->frame_slots,
|
||||
&p->frame_out->slot_index);
|
||||
if (MPP_OK != ret) {
|
||||
|
|
|
|||
|
|
@ -171,6 +171,7 @@ typedef struct VP8DParserContext {
|
|||
|
||||
RK_U32 frame_cnt;
|
||||
RK_U64 pts;
|
||||
RK_U64 dts;
|
||||
|
||||
RK_U32 needKeyFrame;
|
||||
MppPacket input_packet;
|
||||
|
|
|
|||
|
|
@ -392,6 +392,7 @@ static RK_S32 vp9_alloc_frame(Vp9CodecContext *ctx, VP9Frame *frame)
|
|||
mpp_frame_set_errinfo(frame->f, 0);
|
||||
mpp_frame_set_discard(frame->f, 0);
|
||||
mpp_frame_set_pts(frame->f, s->pts);
|
||||
mpp_frame_set_dts(frame->f, s->dts);
|
||||
// set current poc
|
||||
s->cur_poc++;
|
||||
mpp_frame_set_poc(frame->f, s->cur_poc);
|
||||
|
|
@ -1656,6 +1657,7 @@ RK_S32 vp9_parser_frame(Vp9CodecContext *ctx, HalDecTask *task)
|
|||
size = (RK_S32)mpp_packet_get_length(ctx->pkt);
|
||||
|
||||
s->pts = mpp_packet_get_pts(ctx->pkt);
|
||||
s->dts = mpp_packet_get_dts(ctx->pkt);
|
||||
|
||||
vp9d_dbg(VP9D_DBG_HEADER, "data size %d", size);
|
||||
if (size <= 0) {
|
||||
|
|
@ -1673,6 +1675,7 @@ RK_S32 vp9_parser_frame(Vp9CodecContext *ctx, HalDecTask *task)
|
|||
|
||||
mpp_buf_slot_get_prop(s->slots, s->refs[ref].slot_index, SLOT_FRAME_PTR, &frame);
|
||||
mpp_frame_set_pts(frame, s->pts);
|
||||
mpp_frame_set_dts(frame, s->dts);
|
||||
mpp_buf_slot_set_flag(s->slots, s->refs[ref].slot_index, SLOT_QUEUE_USE);
|
||||
mpp_buf_slot_enqueue(s->slots, s->refs[ref].slot_index, QUEUE_DISPLAY);
|
||||
s->refs[ref].ref->is_output = 1;
|
||||
|
|
|
|||
|
|
@ -260,6 +260,7 @@ typedef struct VP9Context {
|
|||
HalDecTask *task;
|
||||
RK_S32 eos; ///< current packet contains an EOS/EOB NAL
|
||||
RK_S64 pts;
|
||||
RK_S64 dts;
|
||||
RK_S32 upprobe_num;
|
||||
RK_S32 outframe_num;
|
||||
RK_U32 cur_poc;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue