2 years agogstvpe: Unref the buffer if not pushed to driver master
Ramprasad N [Tue, 19 Jun 2018 10:04:31 +0000 (15:34 +0530)]
gstvpe: Unref the buffer if not pushed to driver

A memoryleak issue was rootcaused with trick-play
where buffers from vpe were not returned to upstream
element during termination.There was a condtion which allowed
maximum 4 buffers to be with driver at any time.

Because this condition buffer will not be submitted to vpe driver,
it would be lost and never returned.

This patch adds two changes to take care of the issue.
a) Set maximum buffers with driver to min_buffer_count so
   that all buffers are submitted to driver.

b) Unref the buffer if not queued to driver to avoid memleak
   after finalize.

Signed-off-by: Ramprasad N <>
2 years agogstvpe: Ref the tracking buffer in stream-on
Ramprasad N [Thu, 14 Jun 2018 04:57:30 +0000 (10:27 +0530)]
gstvpe: Ref the tracking buffer in stream-on

Refer the input buf_tracking[0] to avoid crash
in trick-play scenario. This buffer is required
when vpe streams off and then streams on.
Unref the buffer in finalize

Signed-off-by: Ramprasad N <>
2 years agogstvpe: Force cropping for progressive streams
Ramprasad N [Wed, 2 May 2018 04:28:46 +0000 (09:58 +0530)]
gstvpe: Force cropping for progressive streams

vpe was being bypassed for progressive stream.
This patch always configures vpe to crop the
ducati output.

This is the workaround added to avoid OOM
issue when sub-titles is overlayed.

Signed-off-by: Ramprasad N <>
2 years agogstvpe: Populate the output structure with progressive
Ramprasad N [Tue, 20 Mar 2018 13:35:18 +0000 (19:05 +0530)]
gstvpe: Populate the output structure with progressive

playbin shows performance drop with waylandsink due
to frame-copy of frame buffers. The caps between vpe and
videoconverter don't match hence this results in frame-copy.
By setting the interlace-mode capabilities match and
all components will be configured to pass through mode.

Signed-off-by: Ramprasad N <>
3 years agogstvpe: Increase number of buffers in pool
Pooja Prajod [Mon, 29 May 2017 08:51:03 +0000 (14:21 +0530)]
gstvpe: Increase number of buffers in pool

The number of buffers in pool calculation has been
changed in ducati decoder as part of bug fix.
Make the change in vpe to match the calculation.

Signed-off-by: Pooja Prajod <>
3 years agogstvpe: Keep a copy of the negotiated v4l2 format
Benoit Parrot [Mon, 1 May 2017 18:39:28 +0000 (18:39 +0000)]
gstvpe: Keep a copy of the negotiated v4l2 format

When issuing VIDIOC_QBUF ideally the v4l2_buffer structure
being passed should be the exact same one return by the

Here since the QUERYBUF info is not kept we need to
at least have all the parameter needed to refilled the
v4l2_buffer structure before passing it to the driver.

Otherwise you'll currently get a kernel WARNING that
you are relying on functionality which is deprecated.

Signed-off-by: Benoit Parrot <>
3 years agogstvpe: Change NV12 buffer to use one plane instead of two
Benoit Parrot [Mon, 1 May 2017 18:39:27 +0000 (18:39 +0000)]
gstvpe: Change NV12 buffer to use one plane instead of two

Starting with TI Kernel 4.9 and mainline Kernel 4.10 the
VPE driver can now handle with single and dual plane
NV12/NV16 buffer.

Realistically NV12 is supposed to be a single plane
format where the Y and UV area are distinct but still
in a single buffer.

Since the various decoder and V4L2 capture engine are
using the single plane representation then keeping that
model when using VPE should be the method used also.

This makes it easier to share DMABUF entities between
the various component and prevent us from having to
implements various hack to make a single plane buffer
look like a dual plane one.

Signed-off-by: Benoit Parrot <>
4 years agogstvpe: Increase bin plugin ranks
Pooja Prajod [Fri, 14 Oct 2016 11:54:24 +0000 (17:24 +0530)]
gstvpe: Increase bin plugin ranks

Vpe bin plugins should have higher rank than ducati plugins
so that they are picked up by playbin. This ensure de-interlacing
through vpe when using playbin.

Signed-off-by: Pooja Prajod <>
4 years agogstvpe: Use SEQ_TB for de-interlacing
Pooja Prajod [Wed, 21 Sep 2016 08:52:34 +0000 (14:22 +0530)]
gstvpe: Use SEQ_TB for de-interlacing

GstVpe plugin have been using V4L2_FIELD_ALTERNATE for
de-interlacing. The v4l2 framework specifies that this method
should be used when the fields are passed in 2 separate buffers.
In our usecase, a single buffer has both the fields. Hence this
patch switches vpe usage to SEQ_TB mode for de-interlacing.

Signed-off-by: Pooja Prajod <>
4 years agogstvpe: Migrate to gst 1.6
Pooja Prajod [Tue, 26 Jul 2016 12:40:13 +0000 (18:10 +0530)]
gstvpe: Migrate to gst 1.6

This patch adapts gstvpe plugin to 1.6

1. It uses v4l2 selection APIs for cropping
2. vpe plugin import functionality has been added. Now vpe can
   work out of dmabuf memory buffers
3. vpe plugin specific info is stored in a hash table rather that metadata on buffer
4. Increase the plugin rank so that it is picked by playbin

Looping at buffer import in chain funcion is removed.

Signed-off-by: Pooja Prajod <>
4 years agogstvpe: Fix memleak due to unreffed events and caps
Pooja Prajod [Mon, 11 Jul 2016 14:04:28 +0000 (19:34 +0530)]
gstvpe: Fix memleak due to unreffed events and caps

There is a memory leak due to unreffed events on gst-vpe.
Whenever there is the event is not propagated to the peer
element we need to unref the events and then return. Same applies
to caps in query.

Signed-off-by: Pooja Prajod <>
5 years agoFix to allow 0/1 framerate in input caps
Harinarayan Bhatta [Fri, 11 Mar 2016 11:12:14 +0000 (16:42 +0530)]
Fix to allow 0/1 framerate in input caps

Fixing the issue introduced in commit-id 09d74f6. The fix is to not ignore
but propogate the framerate of "0/1" in input caps set by the decoder for
some elementary streams.

Signed-off-by: Harinarayan Bhatta <>
5 years agoRepeat output buffers to increase framerate
Harinarayan Bhatta [Mon, 18 Jan 2016 07:51:07 +0000 (13:21 +0530)]
Repeat output buffers to increase framerate

If the output framerate a multiple of input framerate, this plugin
increases the output framerate by repeating frames. This feature is
not used in a real usecase, but for testing, for example to convert
a 30fps input to 60fps.

Signed-off-by: Harinarayan Bhatta <>
5 years agogst-vpe: Add checks before propagating EOS downstream
Pooja Prajod [Thu, 7 Jan 2016 13:11:13 +0000 (18:41 +0530)]
gst-vpe: Add checks before propagating EOS downstream

 EOS was received and propagated by gstvpe without any checks on
 whether VPE has actually finished processing the buffers. In some cases
 all buffers were queued to VPE but since EOS was propagated, there was a
 state change which shut down any more processing. This resulted in last
 few buffers not being processed or displayed.

 To avoid the above scenario, checks have been added to make sure the following
 conditions are met before propagating the EOS:

 1. All buffers are queued from the previous element
 2. All queued buffers are processed and pushed by gst vpe

Signed-off-by: Pooja Prajod <>
5 years agoReduce number of vpe output buffers in bin elements
Harinarayan Bhatta [Mon, 24 Aug 2015 11:33:23 +0000 (17:03 +0530)]
Reduce number of vpe output buffers in bin elements

Fine tuning to reduce memory usage.

Signed-off-by: Harinarayan Bhatta <>
5 years agoChanges to input bufferpool for efficient use of buffers
Harinarayan Bhatta [Fri, 14 Aug 2015 10:52:57 +0000 (16:22 +0530)]
Changes to input bufferpool for efficient use of buffers

1. The V4L2 driver pins omap DRM buffers to the tiler at queueing time instead
   of when it is actually needed (dma-time). So, if many buffers are queued
   into the driver, we run out of tiler memory which affects scenarios such as
   reverse playback and sumultaneous playback of multiple streams. This fix
   adds code to restrict the number of buffers queued into V4L2 driver to 8.
2. Increase maximum allocated buffers to 128 (from 64) for reverse playback.
3. Add a property to set video device name instead of hardcoding it to
4. Removed compile flag for SEQ_TB mode (Use FIELD_ALTERNATE mode always)

Signed-off-by: Harinarayan Bhatta <>
5 years agoFix input crop handling
Harinarayan Bhatta [Fri, 5 Jun 2015 04:46:50 +0000 (10:16 +0530)]
Fix input crop handling

Fix crop left and top values.

Signed-off-by: Harinarayan Bhatta <>
5 years agoMake buffer allocation in input buffer pool dynamic
Harinarayan Bhatta [Thu, 4 Jun 2015 10:57:59 +0000 (16:27 +0530)]
Make buffer allocation in input buffer pool dynamic

1. Add min and max buffer count to vpebuuferpool.
2. The actual number of buffers in the pool is allowed to
   grow based on decoder requests until stream-on.
3. Delay stream-on until a non-passthrough frame. In
   passthough mode, stream-on is not called. This saves
   output buffers being allocated in this case.
4. Use max-ref-frames information from decoder to
   determine the minimum number of buffers in the input
   buffer pool.

Signed-off-by: Harinarayan Bhatta <>
5 years agoEnable ducati*decvpe bin elements
Harinarayan Bhatta [Thu, 4 Jun 2015 10:48:54 +0000 (16:18 +0530)]
Enable ducati*decvpe bin elements

Enable ducati*decvpe bin elements which has a higher rank to help
playbin pick us in preference to ducati*dec elements. This allows
automatic de-interlacing and (optional) scaling of interlaced
streams when playing with playbin.

Signed-off-by: Pooja Prajod <>
Signed-off-by: Harinarayan Bhatta <>
6 years agoModify output_loop to call both input and output dequeue
Harinarayan Bhatta [Tue, 10 Feb 2015 12:08:18 +0000 (17:38 +0530)]
Modify output_loop to call both input and output dequeue

Some upstream elements of VPE, such as v4l2src does not
call VPE bufferpool's allocbuffer function at steady state,
but expects that the buffers go back to their own buffer
pool after they are consumed. To handle this case, the
v4l2 dequeue calls for input port has been moved to the
output_loop thread.

Signed-off-by: Harinarayan Bhatta <>
6 years agoMove to gstreamer version (1.2.3+)
Harinarayan Bhatta [Wed, 28 Jan 2015 11:22:32 +0000 (16:52 +0530)]
Move to gstreamer version (1.2.3+)

Various changes as suggested by gstreamer 1.x porting

Signed-off-by: Pooja Prajod <>
Signed-off-by: Harinarayan Bhatta <>
6 years agoFix incorrect return value for bufferalloc function gst-0.10
Harinarayan Bhatta [Thu, 4 Sep 2014 11:28:13 +0000 (16:58 +0530)]
Fix incorrect return value for bufferalloc function

The bufferalloc function should return GST_FLOW_WRONG_STATE
instead of GST_FLOW_ERROR when in flushing state.

Also minor fix in the way 'passthrough' flag is determined

Signed-off-by: Harinarayan Bhatta <>
6 years agoAdd support for YUYV, and color conversion from/to NV12
Harinarayan Bhatta [Wed, 20 Aug 2014 09:52:02 +0000 (15:22 +0530)]
Add support for YUYV, and color conversion from/to NV12

This plugin should now supports 2 input and ouput YUV
formats, YUYV/YUY2 & NV12. Color conversion is done
automatically when input and output formats are different.

Signed-off-by: Harinarayan Bhatta <>
6 years agoChanges to support reverse playback and seek
Harinarayan Bhatta [Fri, 4 Jul 2014 10:22:55 +0000 (15:52 +0530)]
Changes to support reverse playback and seek

Fix some issues with seek and support reverse playback as
much as possible.

Signed-off-by: Harinarayan Bhatta <>
6 years agoAdd commands for fast forward and rewind playback
Harinarayan Bhatta [Tue, 3 Jun 2014 09:37:14 +0000 (15:07 +0530)]
Add commands for fast forward and rewind playback

Add fast forward and rewind playback to test player

Signed-off-by: Harinarayan Bhatta <>
6 years agoAdding test application and perf plugin
Harinarayan Bhatta [Fri, 2 May 2014 05:57:50 +0000 (11:27 +0530)]
Adding test application and perf plugin

The "gstvpetest" application is useful to test pause/seek and
multiple pipelines from a single process. It also prints out
memory leaks and dmabuf leaks.

The "perf" plugin a simple plugin that displays the framerate
of data passing through it, useful for debugging and used in the
gstvpetest application.

Signed-off-by: Harinarayan Bhatta <>
7 years agoDecrease number of buffers/memory with default settings
Harinarayan Bhatta [Thu, 10 Apr 2014 11:44:39 +0000 (17:14 +0530)]
Decrease number of buffers/memory with default settings

Signed-off-by: Harinarayan Bhatta <>
7 years agoRevert creating bin elements with parser for jpeg
Harinarayan Bhatta [Tue, 8 Apr 2014 11:38:52 +0000 (17:08 +0530)]
Revert creating bin elements with parser for jpeg

Signed-off-by: Harinarayan Bhatta <>
7 years agoChanges to support seek and using lock to protect internal data structures
Harinarayan Bhatta [Thu, 3 Apr 2014 09:34:19 +0000 (15:04 +0530)]
Changes to support seek and using lock to protect internal data structures

Signed-off-by: Harinarayan Bhatta <>
7 years agoAdded support for scaling for progressive input
Harinarayan Bhatta [Wed, 2 Apr 2014 08:49:45 +0000 (14:19 +0530)]
Added support for scaling for progressive input

Signed-off-by: Harinarayan Bhatta <>
7 years agoAdd parser for ducatijpegdecvpe 'bin' eleement
Harinarayan Bhatta [Tue, 1 Apr 2014 12:12:48 +0000 (17:42 +0530)]
Add parser for ducatijpegdecvpe 'bin' eleement

Signed-off-by: Harinarayan Bhatta <>
7 years agoCorrecting the submodule revision to fix build issue
Harinarayan Bhatta [Fri, 28 Mar 2014 11:12:59 +0000 (16:42 +0530)]
Correcting the submodule revision to fix build issue

Signed-off-by: Harinarayan Bhatta <>
7 years agoAdding bin elements with ducati decoder and vpe
Harinarayan Bhatta [Fri, 28 Mar 2014 07:42:58 +0000 (13:12 +0530)]
Adding bin elements with ducati decoder and vpe

Added bin elements like "ducatih264decvpe" for each ducati decoder
has as the VPE elements attached. This bin element has a higher
priority than the decoder elements and will get picked up by playbin
automatically. This ensures that interlaced output automatically gets
de-interlaced via the VPE.

Signed-off-by: Harinarayan Bhatta <>
7 years agoIncreased the default number of input buffers to 24.
Harinarayan Bhatta [Wed, 26 Mar 2014 12:19:54 +0000 (17:49 +0530)]
Increased the default number of input buffers to 24.

24 buffers are required for the pass-through case.

Signed-off-by: Harinarayan Bhatta <>
7 years agoBug fix for handling 3:2 pulldown content
Harinarayan Bhatta [Wed, 26 Mar 2014 11:11:27 +0000 (16:41 +0530)]
Bug fix for handling 3:2 pulldown content

Bug fix for handling bottom field first and 3:2 pulldown
content, also some other minor fixes.

Signed-off-by: Harinarayan Bhatta <>
7 years agoFist working version of gst-plugins-vpe
Harinarayan Bhatta [Wed, 26 Mar 2014 05:11:18 +0000 (10:41 +0530)]
Fist working version of gst-plugins-vpe

This plugin uses the V4L2 M2M driver for VPE video processing
hardware accelerator on TI DRA7xx processors. This plugin currently
supports NV12 format for input and output with de-interlacing
and scaling processing.

Signed-off-by: Harinarayan Bhatta <>