ffmpeg problem

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
kralyk
Posts: 114
Joined: Sun Apr 06, 2008 8:18 pm
Location: Czech Republic, central EU

ffmpeg problem

Post by kralyk »

Hello,
Ive been playing around with pmp/ffmpeg, Ive finally made it to compile and work on my m33 cfw, it loads video files and extracts stream/codec info allright, but now Im stuck with decoding the frames.

This code is the problem:

Code: Select all

avcodec_decode_video(pCodecCtx, pFrame, &frameFinished,
                         packet.data, packet.size);
it only works for first few frames and then the app crashes.
I think its because the input buffer - packet.data is not aligned.
packet is of type AVPacket.
and I get it with this routine:

Code: Select all

av_read_frame(pFormatCtx, &packet)
To cite ffmpeg's docu:
Note: You might have to align the input buffer buf and output buffer samples. The alignment requirements depend on the CPU: on some CPUs it isn't necessary at all, on others it won't work at all if not aligned and on others it will work but it will have an impact on performance. In practice, the bitstream should have 4 byte alignment at minimum and all sample data should be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE do). If the linesize is not a multiple of 16 then there's no sense in aligning the start of the buffer to 16.
Might that solve the problem?
And also, what's the best way to allign data buffer on psp?

Sorry for lame question and thanks.
Last edited by kralyk on Tue Aug 12, 2008 1:18 pm, edited 1 time in total.
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Re: ffmpeg problem - data alignment

Post by Raphael »

kralyk wrote:Hello,

and I get it with this routine:

Code: Select all

av_read_frame(pFormatCtx, &packet)
Might that solve the problem?
And also, what's the best way to allign data buffer on psp?

Sorry for lame question and thanks.
Take a look at mem.c file inside /avcodec, it defines the malloc behaviour for avcodec and avformat. Make av_malloc align on 64 byte and it should be ok (use memalign).

PS: If you're interested, I still have an old version of pmpmod avc 1.02 with (tried) support for all ffmpeg supported videos lying around. I only got it so far as to decode the video frames properly (ie no audio and no av-sync), and it also had problems with some formats (wmv9 I think), but it might be of interest to you.
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
kralyk
Posts: 114
Joined: Sun Apr 06, 2008 8:18 pm
Location: Czech Republic, central EU

Post by kralyk »

Thanks.
Well, it's already done, av_malloc uses memalign(64,size)
which means that alignment is not the problem,
uh, thats bad, I have no idea what could be the problem now.

My app crashes after decoding first 3~20 frames of a small sample avi file (tried various codecs and various resolutions)
Also, I tried playing them in PMP VLC player and it crashes too...

If anyone has any idea as to what could be the problem pls let me know...
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

Sorry, no idea. I don't even know on which version of pmpmod you build upon exactly, neither which modifications you might have applied to avcodec or even how you exactly use the av_* functions together with pmpmod (do proper error checking etc.).

Or if you could provide the .avi you tested and failed, I might be able to check if I get the same crash with my version.
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
kralyk
Posts: 114
Joined: Sun Apr 06, 2008 8:18 pm
Location: Czech Republic, central EU

Post by kralyk »

Ok, Im trying these files:

http://rapidshare.com/files/136664149/vid.avi.html
http://rapidshare.com/files/136664239/vid2.avi.html

one is xvid, the oher is indeo3, both low quality and low res, I made them with virtualdub.
if you have any luck decoding them let me know ;)

My code is kind of a mix, most of it is based on jonny's pmp mod, the me part comes from JockyW's pmp vlc and some patches are mine. Ive also played with the config a bit etc...
I won't post my code atm, sry, it's changin every minute and it needs some tiding up as well, Im currently doing diggins in libavcodec, Im trying to figure out what causes the crashes... Ill post later as soon as I get some results...

Anyway, thanks for your attention

EDIT:
Oh yeah, Id be very interested in that 1.02 version of yours, would be very nic if you uploaded it somewhere for me ;)
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

The xvid one plays fine for me, the IV32 one crashes after a few frames with a graphical glitch visible on the last displayed frame (redish lower half). I'd guess it's a bug in the ffmpeg library that probably got fixed in a later version (the exception forwards me to libavcodec/indeo3.c:493, but the video plays fine on PC). PMPMOD builds upon a rather old version.

I'll upload my pmpmod version later so you can have a look at how I did it. Notice though that the playback is currently not properly integrated in the PMPMOD UI, I only tested it with the included test application that just uses the pmp_decode functions to retrieve the video frames and display them as fast as possible (for benchmark purpose).
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
kralyk
Posts: 114
Joined: Sun Apr 06, 2008 8:18 pm
Location: Czech Republic, central EU

Post by kralyk »

Ok,
Btw. how did you track the exception back to libavcodec/indeo3.c:493 - I mean, I knew it was somewhere in this files, but how do you get the exact line?

Oh and I dont mind it not being properly integrated in the pmpod ui, Im not planing to use pmpmod's diplaying system anyway ... I just need to get ffmpeg to work...

Also, what CFW do you use?
mine's 390 m33-3
...sorry for my english...
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

kralyk wrote:Ok,
Btw. how did you track the exception back to libavcodec/indeo3.c:493 - I mean, I knew it was somewhere in this files, but how do you get the exact line?

Oh and I dont mind it not being properly integrated in the pmpod ui, Im not planing to use pmpmod's diplaying system anyway ... I just need to get ffmpeg to work...

Also, what CFW do you use?
mine's 390 m33-3
I just compiled libavcodec and libavformat with debug info (add -g to CFLAGS). Then use psp-addr2line to calculate the line from the exception address.

I tested on 4.01 m33-2, but in 1.5 kernel mode (old pmp mod required that still).
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
kralyk
Posts: 114
Joined: Sun Apr 06, 2008 8:18 pm
Location: Czech Republic, central EU

Post by kralyk »

Alright, thanks.

By the way, Ive also noticed PSPTube playing pretty much anything I fetch into it. All in all, it's a piece of good homebru,
has the source of it been released?
does anyone know where to get it?

Cant find it anywhere atm...
...sorry for my english...
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

I only found a link to an site that went offline already, which was supposed to hold the source.

Here's the pmpmod version I was talking about. I played a bit with libavcodec and tried to optimize the IDCT with VFPU ops a bit. idctSparseColAdd still is buggy and hence outcommented.
http://www.fx-world.org/download/pmpmodx.zip
The main change for pmpmod itself is within pmp_decode.c where I switch between normal .pmp file handling and libavformat handling depending on file extension. As said, integration is not fully working, but the speed test application works.
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
kralyk
Posts: 114
Joined: Sun Apr 06, 2008 8:18 pm
Location: Czech Republic, central EU

Post by kralyk »

Ok thanks a lot,
Ill check it out and possibly play with the code, though I might have hard times understanding the coed being a psp programming beginner. I dont really understand how the Me/IDCT part works, but thats not critical atm as long as it simply works ;) ... Ill post later when I get some results...
...sorry for my english...
Post Reply