omx: #define OMX_SKIP64BIT on the RPi as required by their API

Also add generic support for OMX_SKIP64BIT to gst-omx, in case other
implementations also #define that for whatever reason.

https://bugzilla.gnome.org/show_bug.cgi?id=766475
This commit is contained in:
Sebastian Dröge 2016-06-17 12:06:48 +03:00
parent 198e31355f
commit a78756c63f
7 changed files with 59 additions and 38 deletions

View file

@ -232,6 +232,7 @@ case "${ac_cv_omx_target}" in
;;
rpi)
AC_DEFINE(USE_OMX_TARGET_RPI, 1, [Use RPi OpenMAX IL target])
AC_DEFINE(OMX_SKIP64BIT, 1, [Required by the RPi implementation])
ac_cv_omx_target_struct_packing=4
;;
bellagio)

View file

@ -71,6 +71,19 @@ G_BEGIN_DECLS
(st)->nVersion.s.nStep = OMX_VERSION_STEP; \
} G_STMT_END
#ifdef OMX_SKIP64BIT
#define GST_OMX_GET_TICKS(ticks) ((((guint64) (ticks).nHighPart) << 32) | ((ticks).nLowPart))
#define GST_OMX_SET_TICKS(ticks, i) G_STMT_START { \
ticks.nLowPart = ((guint64) (i)) & 0xffffffff; \
ticks.nHighPart = ((guint64) (i)) >> 32; \
} G_STMT_END
#else
#define GST_OMX_GET_TICKS(ticks) (ticks)
#define GST_OMX_SET_TICKS(ticks, i) G_STMT_START { \
ticks = i; \
} G_STMT_END
#endif
/* Different hacks that are required to work around
* bugs in different OpenMAX implementations
*/

View file

@ -492,7 +492,8 @@ gst_omx_audio_dec_loop (GstOMXAudioDec * self)
}
GST_DEBUG_OBJECT (self, "Handling buffer: 0x%08x %" G_GUINT64_FORMAT,
(guint) buf->omx_buf->nFlags, (guint64) buf->omx_buf->nTimeStamp);
(guint) buf->omx_buf->nFlags,
(guint64) GST_OMX_GET_TICKS (buf->omx_buf->nTimeStamp));
GST_AUDIO_DECODER_STREAM_LOCK (self);
@ -1168,10 +1169,11 @@ gst_omx_audio_dec_handle_frame (GstAudioDecoder * decoder, GstBuffer * inbuf)
buf->omx_buf->nFilledLen);
if (GST_CLOCK_TIME_IS_VALID (timestamp))
buf->omx_buf->nTimeStamp =
gst_util_uint64_scale (timestamp, OMX_TICKS_PER_SECOND, GST_SECOND);
GST_OMX_SET_TICKS (buf->omx_buf->nTimeStamp,
gst_util_uint64_scale (timestamp, OMX_TICKS_PER_SECOND,
GST_SECOND));
else
buf->omx_buf->nTimeStamp = 0;
GST_OMX_SET_TICKS (buf->omx_buf->nTimeStamp, G_GUINT64_CONSTANT (0));
buf->omx_buf->nTickCount = 0;
self->started = TRUE;
@ -1196,11 +1198,11 @@ gst_omx_audio_dec_handle_frame (GstAudioDecoder * decoder, GstBuffer * inbuf)
buf->omx_buf->nFilledLen);
if (timestamp != GST_CLOCK_TIME_NONE) {
buf->omx_buf->nTimeStamp =
gst_util_uint64_scale (timestamp, OMX_TICKS_PER_SECOND, GST_SECOND);
GST_OMX_SET_TICKS (buf->omx_buf->nTimeStamp,
gst_util_uint64_scale (timestamp, OMX_TICKS_PER_SECOND, GST_SECOND));
self->last_upstream_ts = timestamp;
} else {
buf->omx_buf->nTimeStamp = 0;
GST_OMX_SET_TICKS (buf->omx_buf->nTimeStamp, G_GUINT64_CONSTANT (0));
}
if (duration != GST_CLOCK_TIME_NONE && offset == 0) {
@ -1351,9 +1353,9 @@ gst_omx_audio_dec_drain (GstOMXAudioDec * self)
g_mutex_lock (&self->drain_lock);
self->draining = TRUE;
buf->omx_buf->nFilledLen = 0;
buf->omx_buf->nTimeStamp =
GST_OMX_SET_TICKS (buf->omx_buf->nTimeStamp,
gst_util_uint64_scale (self->last_upstream_ts, OMX_TICKS_PER_SECOND,
GST_SECOND);
GST_SECOND));
buf->omx_buf->nTickCount = 0;
buf->omx_buf->nFlags |= OMX_BUFFERFLAG_EOS;
err = gst_omx_port_release_buffer (self->dec_in_port, buf);

View file

@ -379,7 +379,8 @@ gst_omx_audio_enc_loop (GstOMXAudioEnc * self)
}
GST_DEBUG_OBJECT (self, "Handling buffer: 0x%08x %" G_GUINT64_FORMAT,
(guint) buf->omx_buf->nFlags, (guint64) buf->omx_buf->nTimeStamp);
(guint) buf->omx_buf->nFlags,
(guint64) GST_OMX_GET_TICKS (buf->omx_buf->nTimeStamp));
/* This prevents a deadlock between the srcpad stream
* lock and the videocodec stream lock, if ::reset()
@ -447,8 +448,8 @@ gst_omx_audio_enc_loop (GstOMXAudioEnc * self)
}
GST_BUFFER_TIMESTAMP (outbuf) =
gst_util_uint64_scale (buf->omx_buf->nTimeStamp, GST_SECOND,
OMX_TICKS_PER_SECOND);
gst_util_uint64_scale (GST_OMX_GET_TICKS (buf->omx_buf->nTimeStamp),
GST_SECOND, OMX_TICKS_PER_SECOND);
if (buf->omx_buf->nTickCount != 0)
GST_BUFFER_DURATION (outbuf) =
gst_util_uint64_scale (buf->omx_buf->nTickCount, GST_SECOND,
@ -1036,9 +1037,9 @@ gst_omx_audio_enc_handle_frame (GstAudioEncoder * encoder, GstBuffer * inbuf)
}
if (timestamp != GST_CLOCK_TIME_NONE) {
buf->omx_buf->nTimeStamp =
GST_OMX_SET_TICKS (buf->omx_buf->nTimeStamp,
gst_util_uint64_scale (timestamp + timestamp_offset,
OMX_TICKS_PER_SECOND, GST_SECOND);
OMX_TICKS_PER_SECOND, GST_SECOND));
self->last_upstream_ts = timestamp + timestamp_offset;
}
if (duration != GST_CLOCK_TIME_NONE) {
@ -1139,9 +1140,9 @@ gst_omx_audio_enc_drain (GstOMXAudioEnc * self)
g_mutex_lock (&self->drain_lock);
self->draining = TRUE;
buf->omx_buf->nFilledLen = 0;
buf->omx_buf->nTimeStamp =
GST_OMX_SET_TICKS (buf->omx_buf->nTimeStamp,
gst_util_uint64_scale (self->last_upstream_ts, OMX_TICKS_PER_SECOND,
GST_SECOND);
GST_SECOND));
buf->omx_buf->nTickCount = 0;
buf->omx_buf->nFlags |= OMX_BUFFERFLAG_EOS;
err = gst_omx_port_release_buffer (self->enc_in_port, buf);

View file

@ -172,8 +172,8 @@ gst_omx_video_find_nearest_frame (GstOMXBuffer * buf, GList * frames)
GList *l;
timestamp =
gst_util_uint64_scale (buf->omx_buf->nTimeStamp, GST_SECOND,
OMX_TICKS_PER_SECOND);
gst_util_uint64_scale (GST_OMX_GET_TICKS (buf->omx_buf->nTimeStamp),
GST_SECOND, OMX_TICKS_PER_SECOND);
for (l = frames; l; l = l->next) {
GstVideoCodecFrame *tmp = l->data;

View file

@ -531,8 +531,8 @@ gst_omx_video_dec_fill_buffer (GstOMXVideoDec * self,
done:
if (ret) {
GST_BUFFER_PTS (outbuf) =
gst_util_uint64_scale (inbuf->omx_buf->nTimeStamp, GST_SECOND,
OMX_TICKS_PER_SECOND);
gst_util_uint64_scale (GST_OMX_GET_TICKS (inbuf->omx_buf->nTimeStamp),
GST_SECOND, OMX_TICKS_PER_SECOND);
if (inbuf->omx_buf->nTickCount != 0)
GST_BUFFER_DURATION (outbuf) =
gst_util_uint64_scale (inbuf->omx_buf->nTickCount, GST_SECOND,
@ -1178,8 +1178,9 @@ gst_omx_video_dec_clean_older_frames (GstOMXVideoDec * self,
GList *l;
GstClockTime timestamp;
timestamp = gst_util_uint64_scale (buf->omx_buf->nTimeStamp, GST_SECOND,
OMX_TICKS_PER_SECOND);
timestamp =
gst_util_uint64_scale (GST_OMX_GET_TICKS (buf->omx_buf->nTimeStamp),
GST_SECOND, OMX_TICKS_PER_SECOND);
if (GST_CLOCK_TIME_IS_VALID (timestamp)) {
/* We could release all frames stored with pts < timestamp since the
@ -1365,7 +1366,8 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self)
}
GST_DEBUG_OBJECT (self, "Handling buffer: 0x%08x %" G_GUINT64_FORMAT,
(guint) buf->omx_buf->nFlags, (guint64) buf->omx_buf->nTimeStamp);
(guint) buf->omx_buf->nFlags,
(guint64) GST_OMX_GET_TICKS (buf->omx_buf->nTimeStamp));
GST_VIDEO_DECODER_STREAM_LOCK (self);
frame = gst_omx_video_find_nearest_frame (buf,
@ -2308,10 +2310,11 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder,
buf->omx_buf->nFilledLen);
if (GST_CLOCK_TIME_IS_VALID (timestamp))
buf->omx_buf->nTimeStamp =
gst_util_uint64_scale (timestamp, OMX_TICKS_PER_SECOND, GST_SECOND);
GST_OMX_SET_TICKS (buf->omx_buf->nTimeStamp,
gst_util_uint64_scale (timestamp, OMX_TICKS_PER_SECOND,
GST_SECOND));
else
buf->omx_buf->nTimeStamp = 0;
GST_OMX_SET_TICKS (buf->omx_buf->nTimeStamp, G_GUINT64_CONSTANT (0));
buf->omx_buf->nTickCount = 0;
self->started = TRUE;
@ -2335,11 +2338,11 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder,
buf->omx_buf->nFilledLen);
if (timestamp != GST_CLOCK_TIME_NONE) {
buf->omx_buf->nTimeStamp =
gst_util_uint64_scale (timestamp, OMX_TICKS_PER_SECOND, GST_SECOND);
GST_OMX_SET_TICKS (buf->omx_buf->nTimeStamp,
gst_util_uint64_scale (timestamp, OMX_TICKS_PER_SECOND, GST_SECOND));
self->last_upstream_ts = timestamp;
} else {
buf->omx_buf->nTimeStamp = 0;
GST_OMX_SET_TICKS (buf->omx_buf->nTimeStamp, G_GUINT64_CONSTANT (0));
}
if (duration != GST_CLOCK_TIME_NONE && offset == 0) {
@ -2485,9 +2488,9 @@ gst_omx_video_dec_drain (GstVideoDecoder * decoder)
g_mutex_lock (&self->drain_lock);
self->draining = TRUE;
buf->omx_buf->nFilledLen = 0;
buf->omx_buf->nTimeStamp =
GST_OMX_SET_TICKS (buf->omx_buf->nTimeStamp,
gst_util_uint64_scale (self->last_upstream_ts, OMX_TICKS_PER_SECOND,
GST_SECOND);
GST_SECOND));
buf->omx_buf->nTickCount = 0;
buf->omx_buf->nFlags |= OMX_BUFFERFLAG_EOS;
err = gst_omx_port_release_buffer (self->dec_in_port, buf);

View file

@ -596,8 +596,8 @@ gst_omx_video_enc_handle_output_frame (GstOMXVideoEnc * self, GstOMXPort * port,
}
GST_BUFFER_TIMESTAMP (outbuf) =
gst_util_uint64_scale (buf->omx_buf->nTimeStamp, GST_SECOND,
OMX_TICKS_PER_SECOND);
gst_util_uint64_scale (GST_OMX_GET_TICKS (buf->omx_buf->nTimeStamp),
GST_SECOND, OMX_TICKS_PER_SECOND);
if (buf->omx_buf->nTickCount != 0)
GST_BUFFER_DURATION (outbuf) =
gst_util_uint64_scale (buf->omx_buf->nTickCount, GST_SECOND,
@ -747,7 +747,8 @@ gst_omx_video_enc_loop (GstOMXVideoEnc * self)
}
GST_DEBUG_OBJECT (self, "Handling buffer: 0x%08x %" G_GUINT64_FORMAT,
(guint) buf->omx_buf->nFlags, (guint64) buf->omx_buf->nTimeStamp);
(guint) buf->omx_buf->nFlags,
(guint64) GST_OMX_GET_TICKS (buf->omx_buf->nTimeStamp));
GST_VIDEO_ENCODER_STREAM_LOCK (self);
frame = gst_omx_video_find_nearest_frame (buf,
@ -1587,8 +1588,8 @@ gst_omx_video_enc_handle_frame (GstVideoEncoder * encoder,
timestamp = frame->pts;
if (timestamp != GST_CLOCK_TIME_NONE) {
buf->omx_buf->nTimeStamp =
gst_util_uint64_scale (timestamp, OMX_TICKS_PER_SECOND, GST_SECOND);
GST_OMX_SET_TICKS (buf->omx_buf->nTimeStamp,
gst_util_uint64_scale (timestamp, OMX_TICKS_PER_SECOND, GST_SECOND));
self->last_upstream_ts = timestamp;
}
@ -1720,9 +1721,9 @@ gst_omx_video_enc_drain (GstOMXVideoEnc * self)
g_mutex_lock (&self->drain_lock);
self->draining = TRUE;
buf->omx_buf->nFilledLen = 0;
buf->omx_buf->nTimeStamp =
GST_OMX_SET_TICKS (buf->omx_buf->nTimeStamp,
gst_util_uint64_scale (self->last_upstream_ts, OMX_TICKS_PER_SECOND,
GST_SECOND);
GST_SECOND));
buf->omx_buf->nTickCount = 0;
buf->omx_buf->nFlags |= OMX_BUFFERFLAG_EOS;
err = gst_omx_port_release_buffer (self->enc_in_port, buf);