Fix for missing timestamps when data exceed one buffers worth

The addition of a NAL flag appears to have broken timestamps with
large buffers. This simplifies the 'if' around timestamps and takes
the NAL change in to account.

Also fixed up some bad code formatting after the if statement. Yes, I know.
This commit is contained in:
James Hughes
2019-05-29 17:20:57 +01:00
parent 517cdc30da
commit 8f3da506e6

View File

@@ -1379,22 +1379,19 @@ static void encoder_buffer_callback(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buf
if(pData->flush_buffers) fflush(pData->file_handle); if(pData->flush_buffers) fflush(pData->file_handle);
if (pData->pstate->save_pts && if (pData->pstate->save_pts &&
(buffer->flags & MMAL_BUFFER_HEADER_FLAG_FRAME_END || !(buffer->flags & MMAL_BUFFER_HEADER_FLAG_CONFIG) &&
buffer->flags == 0 || buffer->pts != MMAL_TIME_UNKNOWN &&
buffer->flags & MMAL_BUFFER_HEADER_FLAG_KEYFRAME) && buffer->pts != pData->pstate->lasttime)
!(buffer->flags & MMAL_BUFFER_HEADER_FLAG_CONFIG))
{
if(buffer->pts != MMAL_TIME_UNKNOWN && buffer->pts != pData->pstate->lasttime)
{ {
int64_t pts; int64_t pts;
if(pData->pstate->frame==0)pData->pstate->starttime=buffer->pts; if (pData->pstate->frame == 0)
pData->pstate->starttime = buffer->pts;
pData->pstate->lasttime = buffer->pts; pData->pstate->lasttime = buffer->pts;
pts = buffer->pts - pData->pstate->starttime; pts = buffer->pts - pData->pstate->starttime;
fprintf(pData->pts_file_handle, "%lld.%03lld\n", pts/1000, pts%1000); fprintf(pData->pts_file_handle, "%lld.%03lld\n", pts/1000, pts%1000);
pData->pstate->frame++; pData->pstate->frame++;
} }
} }
}
mmal_buffer_header_mem_unlock(buffer); mmal_buffer_header_mem_unlock(buffer);