Skip to content
Snippets Groups Projects
Commit 4b325af6 authored by Martin Storsjö's avatar Martin Storsjö
Browse files

omxil: Convert from/to OMX_TICKS via helper functions


The 64 bit timestamp fields can be defined either as 64 bit
integers or as structs with two 32 bit members. If the
struct variant is being used, we need to convert to/from it
with helper functions.

Signed-off-by: default avatarMartin Storsjö <martin@martin.st>
parent c793eb04
No related branches found
No related tags found
No related merge requests found
......@@ -1341,7 +1341,7 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
}
if (p_pic)
p_pic->date = p_header->nTimeStamp;
p_pic->date = FromOmxTicks(p_header->nTimeStamp);
p_header->nFilledLen = 0;
p_header->pAppPrivate = 0;
}
......@@ -1382,9 +1382,9 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
p_header->nOffset = 0;
p_header->nFlags = OMX_BUFFERFLAG_ENDOFFRAME;
if (p_sys->b_use_pts && p_block->i_pts)
p_header->nTimeStamp = p_block->i_pts;
p_header->nTimeStamp = ToOmxTicks(p_block->i_pts);
else
p_header->nTimeStamp = p_block->i_dts;
p_header->nTimeStamp = ToOmxTicks(p_block->i_dts);
/* In direct mode we pass the input pointer as is.
* Otherwise we memcopy the data */
......@@ -1507,9 +1507,10 @@ block_t *DecodeAudio ( decoder_t *p_dec, block_t **pp_block )
memcpy( p_buffer->p_buffer, p_header->pBuffer, p_buffer->i_buffer );
p_header->nFilledLen = 0;
if( p_header->nTimeStamp != 0 &&
p_header->nTimeStamp != date_Get( &p_sys->end_date ) )
date_Set( &p_sys->end_date, p_header->nTimeStamp );
int64_t timestamp = FromOmxTicks(p_header->nTimeStamp);
if( timestamp != 0 &&
timestamp != date_Get( &p_sys->end_date ) )
date_Set( &p_sys->end_date, timestamp );
p_buffer->i_pts = date_Get( &p_sys->end_date );
p_buffer->i_length = date_Increment( &p_sys->end_date, i_samples ) -
......@@ -1537,7 +1538,7 @@ block_t *DecodeAudio ( decoder_t *p_dec, block_t **pp_block )
p_header->nFilledLen = p_block->i_buffer;
p_header->nOffset = 0;
p_header->nFlags = OMX_BUFFERFLAG_ENDOFFRAME;
p_header->nTimeStamp = p_block->i_dts;
p_header->nTimeStamp = ToOmxTicks(p_block->i_dts);
/* In direct mode we pass the input pointer as is.
* Otherwise we memcopy the data */
......@@ -1622,7 +1623,7 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pic )
p_header->nFilledLen = p_sys->in.i_frame_size;
p_header->nOffset = 0;
p_header->nFlags = OMX_BUFFERFLAG_ENDOFFRAME;
p_header->nTimeStamp = p_pic->date;
p_header->nTimeStamp = ToOmxTicks(p_pic->date);
#ifdef OMXIL_EXTRA_DEBUG
msg_Dbg( p_dec, "EmptyThisBuffer %p, %p, %i", p_header, p_header->pBuffer,
(int)p_header->nFilledLen );
......@@ -1663,7 +1664,7 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pic )
}
p_block->i_buffer = p_header->nFilledLen;
p_block->i_pts = p_block->i_dts = p_header->nTimeStamp;
p_block->i_pts = p_block->i_dts = FromOmxTicks(p_header->nTimeStamp);
p_header->nFilledLen = 0;
p_header->pAppPrivate = 0;
}
......
......@@ -55,6 +55,23 @@
#define CHECK_ERROR(a, ...) \
if(a != OMX_ErrorNone) {msg_Dbg( p_dec, __VA_ARGS__ ); goto error;}
#ifdef OMX_SKIP64BIT
static inline int64_t FromOmxTicks(OMX_TICKS value)
{
return (((int64_t)value.nHighPart) << 32) | value.nLowPart;
}
static inline OMX_TICKS ToOmxTicks(int64_t value)
{
OMX_TICKS s;
s.nLowPart = value;
s.nHighPart = value >> 32;
return s;
}
#else
#define FromOmxTicks(x) (x)
#define ToOmxTicks(x) (x)
#endif
/*****************************************************************************
* OMX buffer FIFO macros
*****************************************************************************/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment