Commit graph

606 commits

Author SHA1 Message Date
Luis de Bethencourt
964cb549bb omxaudiodec: impossible if statement
ret is set to GST_STATE_CHANGE_SUCCESS and never touched, so it is impossible
for it to be anything else at the if check. Remove it.

CID #1287054
2015-03-06 10:54:46 +00:00
Luis de Bethencourt
a8d26ff27a omxaudiodec: remove duplicate code path 2015-03-06 10:50:30 +00:00
George Kiagiadakis
0ef1e90b34 omx: call handle_messages() only once in acquire_buffer() to avoid potential deadlock
There is one rare case where calling handle_messages() more than once can cause a deadlock
in the video decoder element:

- sink pad thread starts the src pad task (gst_omx_video_dec_loop())
- _video_dec_loop() calls gst_omx_port_acquire_buffer() on dec_out_port
- blocks in gst_omx_component_wait_message() releasing comp->lock and comp->messages_lock
  (initially, there are no buffers configured on that port, so it waits for OMX_EventPortSettingsChanged)
- the sink pad thread pushes a buffer to the decoder with gst_omx_port_release_buffer()
- _release_buffer() grabs comp->lock and sends the buffer to OMX, which consumes it immediately
- EmptyBufferDone gets called at this point, which signals _wait_message() to unblock
- the message from EmptyBufferDone is processed in gst_omx_component_handle_messages()
  called from gst_omx_port_release_buffer()
- gst_omx_port_release_buffer releases comp->lock
- the src pad thread now gets to run, grabbing comp->lock while it exits from _wait_message()
- _acquire_buffer() calls the _handle_messages() on the next line after _wait_message(),
  which does nothing (no pending messages)
- then it goes to "retry:" and calls _handle_messages() again, which also does nothing
  (still no pending messages)
- scheduler switches to a videocore thread that calls EventHandler, informing us about the
  OMX_EventPortSettingsChanged event that just arrived
- EventHandler graps comp->messages_lock, but not comp->lock, so it can run in parallel at
  this point just fine.
- scheduler switches back to the src pad thread (which is in the middle of _acquire_buffer())
- the next _handle_messages() which is right before if (g_queue_is_empty (&port->pending_buffers))
  processes the OMX_EventPortSettingsChanged
- the buffer queue is still empty, so that thread blocks again in _wait_message()
- the sink pad thread tries to acquire the next input port buffer
- _acquire_buffer() also blocks this thread in:
   if (comp->pending_reconfigure_outports) { ... _wait_message() ... }
- DEADLOCK. gstreamer is waiting for omx to do something, omx waits for gstreamer to do something.

By removing those extra _handle_messages() calls, we can ensure that all the checks of
_acquire_buffer() will re-run. In the above case, after the scheduler switches back to
the middle of _acquire_buffer(), the code will enter _wait_message(), which will see that
there are pending messages and will return immediately, going back to "retry:" and
re-doing all the checks properly.

https://bugzilla.gnome.org/show_bug.cgi?id=741854
2015-03-04 09:51:03 +01:00
Wonchul Lee
df58d8baac omx: cleanup code a bit to remove else statement
https://bugzilla.gnome.org/show_bug.cgi?id=745191
2015-02-26 11:15:37 +02:00
Jun Ji
8936f6634c omx: Add omxamrdec
https://bugzilla.gnome.org/show_bug.cgi?id=739333
2014-11-13 13:32:16 +01:00
Sebastian Dröge
40ab1b0a45 omxaudiodec: Clean up code a bit to get rid of useless NULL checks 2014-09-30 10:47:20 +03:00
junji
eba9e3f29d omxaudiodec: Unmap input buffers after usage
https://bugzilla.gnome.org/show_bug.cgi?id=736314
2014-09-30 10:44:38 +03:00
Michal Lazo
bfeab29a39 omxvideoenc: Setup aspect ratio on RPi
Needs firmware from yesterday or newer to work with all possible
aspect ratios. Before that it only supported a fixed list.

https://bugzilla.gnome.org/show_bug.cgi?id=732533
2014-09-01 12:18:58 +03:00
Sebastian Dröge
cdb918aefb omxaudioenc: Implement the hack flag GST_OMX_HACK_NO_COMPONENT_RECONFIGURE 2014-08-28 10:45:37 +03:00
Sebastian Dröge
2c98a6ab7e omxaudioenc: Use the base class' open/close vfuncs instead of calling them ourselves 2014-08-28 10:45:37 +03:00
Peng Liu
d3d0a82ba4 omxvideoenc: Implement the hack flag GST_OMX_HACK_NO_COMPONENT_RECONFIGURE
Fix a video encoder stall problem on RPi when changing the aspect ratio.

https://bugzilla.gnome.org/show_bug.cgi?id=732533
2014-08-28 10:45:11 +03:00
Sebastian Dröge
d75334456d omx: Let base classes handle EOS
https://bugzilla.gnome.org//show_bug.cgi?id=734774
2014-08-14 17:36:11 +03:00
Sebastian Dröge
19d77004d2 omxaudiodec: Fix flushing logic and make it more similar to the video decoder 2014-08-14 17:33:07 +03:00
Sebastian Dröge
b4c7c726ef Release 1.2.0 2014-07-23 11:28:12 +02:00
Sebastian Dröge
c4deb7c07c omxaudiosink: Set port to not flushing in prepare() and keep it at flushing in unprepare()
https://bugzilla.gnome.org/show_bug.cgi?id=733168
2014-07-20 17:47:50 +02:00
Sebastian Dröge
08385fe944 omxaudiodec: Implement setting of fallback channel positions 2014-07-13 22:15:44 +02:00
Sebastian Dröge
03cf0bc9a4 omx: Add AAC audio decoder 2014-07-13 18:22:39 +02:00
Sebastian Dröge
f4961d0a72 omxaudiodec: Get PCM parameters from the out port, not the in port 2014-07-02 09:22:28 +02:00
Sebastian Dröge
c27053c94e omxaudiodec: Implement hack for not disabling the output port after set_format until the output format is known
Needed on some OMX implementations, e.g. the one from Atmel. It does
not send the settings-changed event on the output port if it is
disabled.
2014-07-02 09:21:00 +02:00
Sebastian Dröge
0c3b3ef3d0 omx: Add audio decoder base class and a subclass for MP3 2014-07-02 09:21:00 +02:00
Sebastian Dröge
3d94d3e44d omx: Link to gmodule-2.0-no-export for being able to use the g_module_*() API
https://bugzilla.gnome.org/show_bug.cgi?id=732518
2014-07-01 09:38:01 +02:00
Sebastian Dröge
33e083fff6 omxh264enc: Properly accumulate headers and push before the next frame
Fixes output of encoding on RPi, where each header buffer (SPS and PPS)
is in a separate OMX buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=726669
2014-06-29 19:10:19 +02:00
Sebastian Dröge
0a60770a28 omxvideoenc: Implement flush() instead of the deprecated reset() 2014-06-29 19:04:54 +02:00
Sebastian Dröge
4593f434a0 omxbufferpool: Copy buffers if the stride does not match and we can't use video meta
https://bugzilla.gnome.org/show_bug.cgi?id=731672
2014-06-24 15:11:53 +02:00
Sebastian Dröge
b9238195dd omx: Only include OMX_VideoExt.h conditionally
It does not exist on the RPi for example.
2014-06-24 14:52:43 +02:00
Sebastian Dröge
af38fe7dce omxbufferpool: Fix format string compiler warning 2014-06-24 13:02:13 +02:00
Michal Lazo
326e15ca85 omxbufferpool: Initialize debug category 2014-06-24 13:01:48 +02:00
Sebastian Dröge
03c54e7c0f omxbufferpool: Properly convert OMX alignment to GStreamer alignment
GStreamer uses a bitmask for the alignment while OMX uses the
alignment itself. Let's convert.

https://bugzilla.gnome.org/show_bug.cgi?id=710564
2014-06-24 12:42:22 +02:00
Sebastian Dröge
6617d6f577 omxh264enc: Don't let baseclass finish frames for SPS/PPS buffers
Otherwise we a) send them twice, and b) finish a frame for something
that does not even include a frame.

https://bugzilla.gnome.org/show_bug.cgi?id=726669
2014-06-24 11:11:28 +02:00
Sebastian Dröge
b496a6d6f2 omxvideo: Include the separate headers too for compatibility with 1.0.x 2014-06-24 10:22:37 +02:00
Zhao, Halley
38a07c5386 omxvp8dec: use VP8 definition from OMX_VideoExt.h
https://bugzilla.gnome.org/show_bug.cgi?id=726957
2014-06-24 10:21:07 +02:00
Aurélien Zanelli
58aa603b36 omxvideodec: fix a query leak
Also add a debug message if query fails.

https://bugzilla.gnome.org/show_bug.cgi?id=731898
2014-06-20 11:54:25 +02:00
Aurélien Zanelli
ad969ffda3 omxvideodec: release frames with old PTS to avoid memory issue
Interlaced stream could make the decoder use two input frames to produce
one output frame causing the gstvideodecoder frame list to grow.
Assuming the video decoder output frame in display order rather than in
decoding order, this commit add a way to release frames with PTS less
than current output frame.

https://bugzilla.gnome.org/show_bug.cgi?id=730995
2014-06-04 16:36:02 +02:00
Kazunori Kobayashi
4c488d425d omx: Fix a missing g_free() in error path
This fixes a memory leak with g_strdup() when an error occurs.

https://bugzilla.gnome.org/show_bug.cgi?id=731141
2014-06-03 09:23:41 +02:00
Aurélien Zanelli
3ed713db0d omxvideodec: add missing stream unlock in error path 2014-06-02 19:28:51 +02:00
Sebastian Dröge
190adce125 omx: Don't handle disabling/enabling ports exactly like flushing
Otherwise we might abort a flush operation in another thread when
enabling/disabling ports, leading to deadlocks sometimes.

https://bugzilla.gnome.org/show_bug.cgi?id=730989
2014-05-31 15:12:05 +02:00
Sebastian Dröge
bf7e6109d9 omxvideodec: Don't leak buffer pool config in error cases
CID 1216158
2014-05-26 11:03:03 +02:00
Sebastian Dröge
34577a965d omxvideoenc: Don't forget to unref codec state
CID 1214603
2014-05-19 09:10:07 +02:00
Sebastian Dröge
e542177c65 omxvideodec: Make output buffer pointer always initialized
CID 1214605
2014-05-19 09:08:33 +02:00
Sebastian Dröge
c2e5dca5f0 omxvideodec: Check return value of gst_buffer_map()
CID 1214599
2014-05-19 09:06:42 +02:00
Sebastian Dröge
429b0e1e27 omxvideodec: Check return value of gst_omx_port_set_enabled() for errors
CID 1214589
2014-05-19 09:04:09 +02:00
Sebastian Dröge
e08c0dc88a omxvideodec: Check return values of buffer pool config parsing functions
CID 1214588
2014-05-19 09:01:46 +02:00
Sebastian Dröge
59ac1dd03b omx: Remove dead code, buf can never be NULL here as we just check for that the line above
CID 1214596
2014-05-19 08:48:50 +02:00
Sebastian Dröge
800ef8ab14 omx: Fix comparisons in gst_omx_state_to_string() case to actually make sense
CID 1214593
2014-05-19 08:47:36 +02:00
Sebastian Dröge
7b558e37bc omx: Make sure to compare the error codes as unsigned integers so that comparisons >2**31 actually work
CID 1214592
2014-05-19 08:47:33 +02:00
Sebastian Dröge
93528dc43b omx: Fix comparisons in gst_omx_command_to_string() default cause to actually work
CID 1214591
2014-05-19 08:44:55 +02:00
Sebastian Dröge
2c3797acfe omxaudioenc: Implement hack for not disabling the output port after set_format until the output format is known
Needed on some OMX implementations, e.g. the one from Atmel. It does
not send the settings-changed event on the output port if it is
disabled.
2014-05-15 13:22:56 +02:00
Sebastian Dröge
40869afea7 omxvideoenc: Implement hack for not disabling the output port after set_format until the output format is known
Needed on some OMX implementations, e.g. the one from Atmel. It does
not send the settings-changed event on the output port if it is
disabled.
2014-05-15 13:21:07 +02:00
Sebastian Dröge
4e20116bc6 omx: Add a hack for not disabling the output port after set_format until the output format is known
Needed on some OMX implementations, e.g. the one from Atmel. It does
not send the settings-changed event on the output port if it is
disabled.
2014-05-15 10:59:35 +02:00
Josep Torra
e08540d969 omxaudiosink: implement _delay only in the RaspberryPI
Make code implementation conditionally built for RaspberryPI because
OMX_IndexConfigAudioRenderingLatency seems to be a Broadcom extension.

On other targets the query position might not be accurate without
implementing _delay appropriatelly.
2014-05-12 12:33:32 +02:00
Sebastian Dröge
527af797d2 omxaudioenc: Correctly scale nTickCount by OMX_TICKS_PER_SECOND 2014-05-12 08:56:15 +02:00
Sebastian Dröge
14af0f266e omxaudioenc: Drain encoder on NULL buffer and don't drain on flushing 2014-05-10 22:48:23 +02:00
Sebastian Dröge
cfbf5bf16d omxvideodec: Set nTickCount based on the buffer's duration instead of something wrong 2014-05-10 22:47:56 +02:00
Sebastian Dröge
bc2990169a omxvideoenc: Set nTickCount to the whole duration of the buffer instead of a wrong calculation 2014-05-10 22:47:21 +02:00
Sebastian Dröge
cef3fb5fc3 omxaudiosink: Fix format string compiler warnings 2014-05-10 22:46:51 +02:00
Josep Torra
b3eb4d897d omxaudiosink: Implements OpenMAX based audio sinks
Provides omxanalogaudiosink and omxhdmiaudiosink elements on
the Raspberry PI.

- omxanalogaudiosink is capable to render raw mono or stereo audio
through the jack output.
- omxhdmiaudiosink is capable to render raw audio up to 8 channels
and transmit ac3/dts(IEC 61937) through the HDMI output.
- sinks provide a clock derived from rendered samples
- sinks support the GstStreamVolume interface by implementing
the volume and mute properties.

https://bugzilla.gnome.org/show_bug.cgi?id=728962
2014-05-09 13:15:18 +02:00
Julien Isorce
bdec8c0595 omxvideodec: can negotiate caps with memory:EGLImage feature when using EGLImage allocator
Previously when using gst EGLImage allocator the caps was
video/x-raw, format=RGBA instead of
video/x-raw(memory:EGLImage), format=RGBA

Kepp previous behavior in case negotiation fails with caps feature.
It means it will still have a chance to use EGLImage even if the
feature is not in the caps.

https://bugzilla.gnome.org/show_bug.cgi?id=729196
2014-05-02 18:00:48 +01:00
Aurélien Zanelli
420b0b62d3 omxvp8dec: fix typo in GST_TYPE_OMX_VP8_DEC define
https://bugzilla.gnome.org/show_bug.cgi?id=728774
2014-04-23 10:34:52 +02:00
Aurélien Zanelli
da4cf3da1f omxvideodec: don't unref caps before logging field from it
https://bugzilla.gnome.org/show_bug.cgi?id=728322
2014-04-17 09:33:47 +02:00
Julien Isorce
499fb23e9c omxvideodec: use new libgstgl API since libgstegl has been removed
There is no point to retrieve a ref/unref type
instead of an EGLDisplay directly. It's like for EGLImage.

https://bugzilla.gnome.org/show_bug.cgi?id=703343
2014-04-15 18:32:12 +01:00
Julien Isorce
d4bb7cb4c7 configure.ac: check for libgstgl since libgstegl has been removed
https://bugzilla.gnome.org/show_bug.cgi?id=703343
2014-04-15 18:32:12 +01:00
Aurélien Zanelli
1b6879921c omxvideodec: add support of more color format
Add support for ABGR, ARGB, RGB16, BGR16, YUY2, UYVY, YVYU, GRAY8 and
NV16 color format.
2014-04-15 15:09:24 +01:00
Aurélien Zanelli
f5f876f681 omxvideodec: simplify color format conversion in fill_buffer function 2014-04-15 15:09:24 +01:00
Aurélien Zanelli
6834d2e0b3 omxbufferpool: make video stride and offset calculation easier
It will be easier to support more color format.
2014-04-15 15:09:23 +01:00
Aurélien Zanelli
c115da9fd5 omx: add an helper to convert OMX color format to GStreamer color format 2014-04-15 15:09:23 +01:00
Josep Torra
718fd1bb93 omxvideodec: Implement pipeline draining to support adaptive scenarios
When draining due a format change also drain
the pipeline to reclaim back all buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=726107
2014-03-28 11:40:20 +00:00
Josep Torra
73d83f311c omxvideodec: fixes race condition during seeks
Acording 6.1.3 Seek Event Sequence in the OpenMAX IL 1.1.2 spec
document in order to flush the component it needs to be in
paused state.

https://bugzilla.gnome.org/show_bug.cgi?id=726038
2014-03-25 16:07:25 +00:00
Julien Isorce
39ca9f980e omxvideodec: use flush because reset is deprecated
https://bugzilla.gnome.org/show_bug.cgi?id=726038
2014-03-25 16:07:15 +00:00
Julien Isorce
777411c286 omxvideodec: populate the most downstream output port on reset
Make seeking work when using egl_render component

https://bugzilla.gnome.org/show_bug.cgi?id=726038
2014-03-25 16:06:51 +00:00
Josep Torra
100e9f998d omxbufferpool: return buffers to the pool instead of freeing them
We have to return the buffers back to the pool in when stopping to
not mess with the GstBufferPool accounting.
The OMX buffers will be freed when those won't be in charge of the
pool in the chained up call to 'stop'.
Fixes segfaults on finalize and pool not being properly deactivated.

https://bugzilla.gnome.org/show_bug.cgi?id=726337
2014-03-24 18:20:51 +00:00
Christian König
651e67e32d omxvideodec: add missing unlock in the error path
Signed-off-by: Christian König <christian.koenig@amd.com>

https://bugzilla.gnome.org/show_bug.cgi?id=726958
2014-03-24 11:11:39 +00:00
Michal Lazo
c832b03b3b fix filemode 2014-03-19 08:53:02 +01:00
Julien Isorce
e8ca74c6f8 omxbufferpool: fix memory leak if used on output port
When using GstOMXBufferPool on an output port, it internally uses
a GPtrArray to manage the GstBuffers instead of the default queue
from the GstBufferPool base class.

In this case GstBufferPool::default_free_buffer is not called when
the pool is stopped. Because the queue is empty. So explicitely
call gst_omx_buffer_pool_free_buffer on each buffer contained in
the GPtrArray.

https://bugzilla.gnome.org/show_bug.cgi?id=726337
2014-03-17 18:02:51 +00:00
Sebastian Dröge
922d036ae7 omxh264enc: Fix compiler warnings 2014-03-16 17:32:05 +01:00
Michal Lazo
e55bf0a4c5 omxh264enc: IDR interval, SPS and PPS headers for rpi
https://bugzilla.gnome.org/show_bug.cgi?id=720031
2014-03-16 17:31:01 +01:00
Christian König
8a860bd024 omxvideo: fix debug category initialisation
https://bugzilla.gnome.org/show_bug.cgi?id=726024
2014-03-15 12:42:03 +01:00
Christian König
0ea0eb1579 omxbufferpool: add proper type definitions
https://bugzilla.gnome.org/show_bug.cgi?id=726325
2014-03-15 11:26:36 +01:00
Christian König
0700d6875f omx: consolidate message waiting code
Add a wait_message helper function and remove all those duplicated code.

https://bugzilla.gnome.org/show_bug.cgi?id=725493
2014-03-12 14:04:57 +01:00
Sebastian Dröge
6b28cf0378 omx: Copy old copyright notice into the new file 2014-03-12 12:48:12 +01:00
Sebastian Dröge
a04ef276e5 omx: Rename function from _4_ to _for_ for clarity 2014-03-12 12:47:34 +01:00
Christian König
6bf4d9a498 omxvideo: start sharing more code between video decoder and encoder
Identical functionality spread of two different components.
We can't use a common base class because of different inheritance,
but let's try to share the code anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=726024
2014-03-12 12:47:09 +01:00
Sebastian Dröge
e9b7dc230b omxbufferpool: Fix header include guard 2014-03-12 12:42:23 +01:00
Christian König
325c90f99d omxvideodec: separate the buffer pool from the decoder
https://bugzilla.gnome.org/show_bug.cgi?id=726025
2014-03-12 12:42:03 +01:00
Christian König
de5f940186 omx: simplify tunnel functions
Specifying the component is error prone and unnecessary.

https://bugzilla.gnome.org/show_bug.cgi?id=726021
2014-03-12 08:48:46 +01:00
Christian König
14a0da437f omxvideodec: fix memory leak in gst_omx_video_dec_allocate_output_buffers
https://bugzilla.gnome.org/show_bug.cgi?id=725907
2014-03-08 15:23:59 +01:00
Christian König
5ac0fe2108 omxvideodec: fix memory leak gst_omx_video_dec_negotiate
https://bugzilla.gnome.org/show_bug.cgi?id=725907
2014-03-08 15:22:15 +01:00
Christian König
20cfcda4db omxvideoenc: fix a memory leak in gst_omx_video_enc_getcaps
https://bugzilla.gnome.org/show_bug.cgi?id=725826
2014-03-06 20:37:02 +01:00
Christian König
85db124673 omxvideoenc: simplify _find_nearest_frame
Just the same as we did with the decoder. Also give the
function a gst_omx_video_enc prefix to distinct it from
the decoder function.

https://bugzilla.gnome.org/show_bug.cgi?id=724236
2014-03-03 20:12:58 +01:00
Christian König
2cfe70ed5d omxvideodec: simplify _find_nearest_frame
No need to make it more complicated and error prone than
necessary. Also give the function a gst_omx_video_dec prefix
to distinct it from the encoder function.

https://bugzilla.gnome.org/show_bug.cgi?id=724236
2014-03-03 20:12:51 +01:00
Christian König
bf0d2614c3 omxvideodec: remove dead code
This code doesn't seems to be used for quite a while,
remove it before it starts to rot.

https://bugzilla.gnome.org/show_bug.cgi?id=724236
2014-03-03 20:12:35 +01:00
Christian König
8b06b07f6f omx: fix two serious message handling bugs
Waiting for the next message if we already got one
is nonsense and can lead to lockups.

https://bugzilla.gnome.org/show_bug.cgi?id=725468
2014-03-02 12:09:59 +01:00
Christian König
4e4f093319 omxvideoenc: fix startup race condition
The reset function shouldn't start the src pad
loop if it wasn't started before.

Signed-off-by: Christian König <christian.koenig@amd.com>
2014-03-02 12:08:09 +01:00
Christian König
0a8cfcde87 omxvideodec: fix startup race condition
The reset function shouldn't start the src pad
loop if it wasn't started before.

Signed-off-by: Christian König <christian.koenig@amd.com>
2014-03-02 12:08:09 +01:00
Sebastian Dröge
1bf4edf721 omx: Don't handle FLUSHING and NOT_LINKED as errors
Also don't stop the task on NOT_LINKED. We're not a demuxer.
2014-01-25 17:44:57 +01:00
Tim-Philipp Müller
498b74ab6a omx: don't use the 'z' modifier to print size_t
gcc will warn in some cases even if the size of the type
is exactly that of size_t on the platform.

https://bugzilla.gnome.org/show_bug.cgi?id=699008
2013-08-20 16:00:07 +01:00
Roman Arutyunyan
5ba55b6c9a gstomxvideoenc: Set bitrate in setcaps
Otherwise it gets lost whenever we configure new caps

https://bugzilla.gnome.org/show_bug.cgi?id=698049
2013-07-01 15:48:47 +02:00
Josep Torra
f3f9330332 omx: Take lock on EOS to update the flow return value
Fixes "GThread-ERROR **: file gthread-posix.c: line 171
(g_mutex_free_posix_impl): error 'Device or resource busy' during
'pthread_mutex_destroy ((pthread_mutex_t *) mutex)'" in _finalize.
2013-05-20 12:06:34 +02:00
Josep Torra
64ef1f0e11 omxvideodec: Redesign video size change reconfiguration code
Ensure stop the decoder before clossing the tunnel.
2013-05-10 12:25:07 +02:00
jitendra
715b44ea66 omx: Add pads based on element type
This allows to later add sources and sink that only have a srcpad
or sinkpad.

https://bugzilla.gnome.org/show_bug.cgi?id=699754
2013-05-06 16:20:20 +02:00
Carlos Rafael Giani
2d1138f45c omx: fixed type error in printf call
%zu expects size_t

https://bugzilla.gnome.org/show_bug.cgi?id=699008
2013-04-27 09:17:28 +01:00