[m2v_parser]: fix pts calculate error

Signed-off-by: Rimon Xu <rimon.xu@rock-chips.com>
Change-Id: Ibd263a16a2780796774aac1bd4d8a6c6600f915d
This commit is contained in:
Rimon Xu
2022-11-29 14:28:46 +08:00
parent 38fc8aada8
commit b5f6decb49
2 changed files with 13 additions and 13 deletions

View File

@@ -1113,7 +1113,7 @@ static MPP_RET m2vd_alloc_frame(M2VDParserContext *ctx)
{
M2VDHeadPic *pic_head = &ctx->pic_head;
M2VDHeadPicCodeExt *pic_code_ext_head = &ctx->pic_code_ext_head;
RK_U64 pts = ctx->pts;
double pts = (double)ctx->pts / 1000;
if (ctx->resetFlag && pic_head->picture_coding_type != M2VD_CODING_TYPE_I) {
mpp_log("[m2v]: resetFlag[%d] && picture_coding_type[%d] != I_TYPE", ctx->resetFlag, pic_head->picture_coding_type);
@@ -1131,7 +1131,7 @@ static MPP_RET m2vd_alloc_frame(M2VDParserContext *ctx)
if ((pic_code_ext_head->picture_structure == M2VD_PIC_STRUCT_FRAME ) ||
((pic_code_ext_head->picture_structure == M2VD_PIC_STRUCT_TOP_FIELD) && pic_code_ext_head->top_field_first) ||
((pic_code_ext_head->picture_structure == M2VD_PIC_STRUCT_BOTTOM_FIELD) && (!pic_code_ext_head->top_field_first))) {
RK_S64 frm_pts = 0;
double frm_pts = 0;
RK_U32 frametype = 0;
if (ctx->frame_cur->slot_index >= 0) {
@@ -1150,7 +1150,7 @@ static MPP_RET m2vd_alloc_frame(M2VDParserContext *ctx)
}
if (ctx->PreGetFrameTime != pts) {
RK_S64 tmp_frame_period;
double tmp_frame_period;
if (ctx->GroupFrameCnt) {
ctx->GroupFrameCnt = ctx->GroupFrameCnt + pic_head->temporal_reference;
@@ -1176,8 +1176,8 @@ static MPP_RET m2vd_alloc_frame(M2VDParserContext *ctx)
if ((pts > ctx->PreGetFrameTime) && (ctx->GroupFrameCnt > 0)) {
tmp_frame_period = (tmp_frame_period * 256) / ctx->GroupFrameCnt;
if ((tmp_frame_period > 4200) && (tmp_frame_period < 11200) &&
(llabs(ctx->frame_period - tmp_frame_period) > 128)) {
if (llabs(ctx->preframe_period - tmp_frame_period) > 128)
(fabs(ctx->frame_period - tmp_frame_period) > 128)) {
if (fabs(ctx->preframe_period - tmp_frame_period) > 128)
ctx->preframe_period = tmp_frame_period;
else
ctx->frame_period = tmp_frame_period;
@@ -1241,7 +1241,7 @@ static MPP_RET m2vd_alloc_frame(M2VDParserContext *ctx)
mpp_frame_set_hor_stride(ctx->frame_cur->f, ctx->display_width);
mpp_frame_set_ver_stride(ctx->frame_cur->f, ctx->display_height);
mpp_frame_set_errinfo(ctx->frame_cur->f, 0);
mpp_frame_set_pts(ctx->frame_cur->f, frm_pts);
mpp_frame_set_pts(ctx->frame_cur->f, frm_pts * 1000);
ctx->frame_cur->flags = M2V_OUT_FLAG;
if (ctx->seq_ext_head.progressive_sequence) {

View File

@@ -255,15 +255,15 @@ typedef struct M2VDParserContext_t {
RK_S32 resetFlag;
RK_U64 PreGetFrameTime;
RK_S64 Group_start_Time;
double PreGetFrameTime;
double Group_start_Time;
RK_U32 GroupFrameCnt;
RK_U32 pretemporal_reference;
RK_U32 pretime_temporal;
RK_U32 max_temporal_reference;
float pretemporal_reference;
float pretime_temporal;
float max_temporal_reference;
RK_U32 PreChangeTime_index;
RK_S32 frame_period;
RK_S32 preframe_period;
float frame_period;
float preframe_period;
RK_U32 maxFrame_inGOP;
RK_U32 ref_frame_cnt;
long long top_first_cnt;