vmem - YV12 memory layout

This forum is about all development around libVLC.
neonp
Blank Cone
Blank Cone
Posts: 20
Joined: 09 Jun 2011 14:07
VLC version: 2.2.0
Operating System: Raspbian/jessie
Location: Mulhouse, France

vmem - YV12 memory layout

Postby neonp » 17 Jun 2011 23:46

Hi all,

I am using libvlc with vlcdotnet only for its interop wrapper.
I have almost rebuilt the direct3D module of VLC in C#, using the version 1.2.0 of a nightly build of VLC.
Now the issue I do have is to display a YV12 input to a D3D surface.

If in the libvlc_video_set_format_callbacks, I set the chroma to RV32, everything goes well, but the CPU has an activity increased. If I set the chroma to YV12, I get an exception between the lock and the display callbacks : Access violation writing location 0x00000004 in libmemcpymmxext_plugin.dll.

How should I set lines and pitches ? What size should be my picture ? Is a byte array not enough for VLC with YV12 ?

Any help welcome,

Thanks,
Nicolas.

Rémi Denis-Courmont
Developer
Developer
Posts: 15265
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: vmem - YV12 memory layout

Postby Rémi Denis-Courmont » 18 Jun 2011 11:10

YV12 is a planar format. You need one plane for luminance, and two subsampled planes for Cr and Cb chrominance components respectively.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

neonp
Blank Cone
Blank Cone
Posts: 20
Joined: 09 Jun 2011 14:07
VLC version: 2.2.0
Operating System: Raspbian/jessie
Location: Mulhouse, France

Re: vmem - YV12 memory layout

Postby neonp » 18 Jun 2011 12:09

Thanks for your answer, This is what I have read on http://www.fourcc.org, but I do not understand what vlc expects.

Here is what I do, but my application hangs when I do the following :

Code: Select all

IntPtr y = Marshal.AllocHGlobal((int)(pitches * lines)); IntPtr u = Marshal.AllocHGlobal((int)(pitches * lines/4)); IntPtr v = Marshal.AllocHGlobal((int)(pitches * lines/4)); opaque = Marshal.AllocHGlobal(3 * sizeof(int)); int[] planesPtr = new int[3]; planesPtr[0] = y.ToInt32(); planesPtr[1] = u.ToInt32(); planesPtr[2] = v.ToInt32(); Marshal.Copy(planesPtr, 0, opaque, 3);

Rémi Denis-Courmont
Developer
Developer
Posts: 15265
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: vmem - YV12 memory layout

Postby Rémi Denis-Courmont » 19 Jun 2011 19:21

This does not look right. As per the documentation, libVLC allocates the table of planes, and the callback initializes it with the actual planes.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

neonp
Blank Cone
Blank Cone
Posts: 20
Joined: 09 Jun 2011 14:07
VLC version: 2.2.0
Operating System: Raspbian/jessie
Location: Mulhouse, France

Re: vmem - YV12 memory layout

Postby neonp » 19 Jun 2011 19:35

Actually, it was vlcdotnet which has incorrect method signature : it was passing planes as a ref instead of an array. I changed it on the source code of vlcdotnet to be an array of IntPtr, but the plane array is ALLOCATED with a size of 1. Any clue ?

--EDIT

neonp
Blank Cone
Blank Cone
Posts: 20
Joined: 09 Jun 2011 14:07
VLC version: 2.2.0
Operating System: Raspbian/jessie
Location: Mulhouse, France

Re: vmem - YV12 memory layout

Postby neonp » 24 Jun 2011 21:29

It was actually a bug in .Net which could not recognize a void**. With an unsafe method, Works like a charm.

Thanks for your help Rémi. I now have an issue with direct3d, but I guess I should start another topic, right ?

Rémi Denis-Courmont
Developer
Developer
Posts: 15265
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: vmem - YV12 memory layout

Postby Rémi Denis-Courmont » 24 Jun 2011 22:12

Probably
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 14 guests