Video format callbacks

This forum is about all development around libVLC.
sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Video format callbacks

Postby sherington » 24 Feb 2019 09:29

I've been using libvlc_video_set_format_callbacks successfully for some time, it works but I have a question about the implementation.

I added some debug statements recently and noticed the following behaviour:

Code: Select all

setup chroma=VAOP, size=1280x720 cleanup setup chroma=VDV0, size=1280x720 cleanup setup chroma=I420, size=1280x738
So, when I play media (in this case an mp4), I get the format callback three times with different parameters (two of them get a corresponding cleanup), before playback starts.

My callback implementation each time simply sets up the buffer format to be RV32 with same width and height specified.

The question then is while my code appears to work correctly, I'm wondering if this behaviour is normal or if I'm supposed to be doing something differently with these different buffer formats?

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

Re: Video format callbacks

Postby Rémi Denis-Courmont » 24 Feb 2019 17:58

VLC is probing different formats, until it finds one that works.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: Video format callbacks

Postby sherington » 24 Feb 2019 22:19

Thank you for replying.

What I don't get is that in the first callback VLC probes VAOP and I return RV32, why does it then keep going and probing the other two formats? Why doesn't it accept the RV32 I returned the first time?

I'm just trying to determine if my implementation/understanding of this callback is wrong.

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

Re: Video format callbacks

Postby Rémi Denis-Courmont » 25 Feb 2019 17:23

It cannot find a working path to convert VAOP to RV32.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: Video format callbacks

Postby sherington » 26 Feb 2019 09:05

It's clear now, thanks a lot.

Tibweizh
New Cone
New Cone
Posts: 7
Joined: 28 Jun 2019 09:03

Re: Video format callbacks

Postby Tibweizh » 28 Jun 2019 09:05

Hi Sherington,

I'm facing some problems with my implementation of video format callback, could you please share yours ? Or tell me what you did ?

Thanks

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: Video format callbacks

Postby sherington » 28 Jun 2019 19:19

What do you want to know? My implementation is deeply integrated in a Java library and I can't just cleanly pull the code out unfortunately.

Tibweizh
New Cone
New Cone
Posts: 7
Joined: 28 Jun 2019 09:03

Re: Video format callbacks

Postby Tibweizh » 01 Jul 2019 08:59

In your format setup callback, your basics steps. Because mine does not work as I wish

Code: Select all

unsigned VLCReader::cb_setup(void **opaque, char *chroma, unsigned *width, unsigned *height, unsigned *pitches, unsigned *lines) { VLCReader *p = (VLCReader*)opaque; memcpy(chroma, "RV24", sizeof("RV24") - 1); p->m_width = *width; p->m_height = *height; *pitches = (*width) * 3; *lines = *height; return 1; // indicates the number of buffers allocated }
This version is crashing but when I remove the multiplication it works but video does not show up entirely (only squares on the top part of my window)

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: Video format callbacks

Postby sherington » 01 Jul 2019 19:42

From a quick look, the only thing I do different is use RV32 format and a pitches value of width*4.

(I'm not saying RV32 is necessary but it was the only useful format I could get to work with the UI toolkit I was using).

You are definitely allocating enough memory for your *3 buffer size?

Tibweizh
New Cone
New Cone
Posts: 7
Joined: 28 Jun 2019 09:03

Re: Video format callbacks

Postby Tibweizh » 02 Jul 2019 08:20

Humm I think so but I'll work on this point, thanks mate !

If I succeed I'd tell you

Tibweizh
New Cone
New Cone
Posts: 7
Joined: 28 Jun 2019 09:03

Re: Video format callbacks

Postby Tibweizh » 02 Jul 2019 15:08

Ok definitely it came from memory allocation, my buffer was too small but... I found something strange with libvlc_video_get_size

Here it is : the size obtained by libvlc_video_get_size was not the same as the one I get from the calllback setup (unsigned *width and unsigned *height). Is this a bug or whatever else ?

Thanks again mate !

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: Video format callbacks

Postby sherington » 02 Jul 2019 18:07

I am no expert on this, but I suppose certain buffer formats might require e.g. aligning to 8/16/32 bit boundaries and that could explain the discrepancies you are seeing.

So e.g. if the video height is 500, you'd actually need a buffer height of 504 to hold it (504/8 = 63.0 whereas 500/8 = 62.5). I'm just guessing.

In practical terms does it matter? I don't think so.

unidan
Developer
Developer
Posts: 1493
Joined: 25 Mar 2018 01:00

Re: Video format callbacks

Postby unidan » 03 Jul 2019 09:32

It's the difference between visible_size (video size in VLC) and real buffer size (buffer size in VLC). What you get in setup is the size of the video without the padding.

Tibweizh
New Cone
New Cone
Posts: 7
Joined: 28 Jun 2019 09:03

Re: Video format callbacks

Postby Tibweizh » 03 Jul 2019 09:37

Oh that's it ! Thank you very much Unidan, it's quite clear now for me


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 8 guests