please include the mailing list On Mon, Jan 21, 2013 at 8:16 PM, Harry van Haaren <[email protected]> wrote: > On Mon, Jan 21, 2013 at 10:05 PM, Dan Dennedy <[email protected]> wrote: >> >> If the consumer is not going to the drawing, >> then you use an audio-only consumer such as sdl_audio, and in your app >> you listen to the mlt_event "consumer-frame-show". The event handler >> will receive a mlt_frame. Then you call mlt_frame_get_image() on that >> frame to get the image data pointer. Kdenlive and Shotcut's >> OpenGL-based video widgets are the main examples of that technique. > > > Ok that makes sense, implemented. > > I don't fully understand the memory management when using mlt_frame.
It is reference counted. If you want to use the frame or any of its contents outside of the callback function, then you must increment the reference with mlt_properties_inc_ref() and then mlt_frame_close() to release your reference when you are done with it. > uint8_t* image = NULL; > passing in &image makes mlt_frame set the pointer to the location of its > internal frame memory? just the image part of that internal frame memory. The image pointer is only valid as long as the frame is valid (not all references are released). > and then its up to the caller to do something useful with that pointer? yes > I'm getting segfaults when I try to copy that memory using memcpy: > mlt_frame_get_image (frame, &image, &format, &width, &height, false); > size_t size = 320*240*4; This size is only valid if you set format to mlt_image_rgb24a before the call to mlt_frame_get_image(). The width and height should also be set to 320 and 240 before the call if the mlt_profile is not 320x240. If you set width and height to 0 before the call, then you get back the width and height of the profile. > data = (unsigned char*) malloc( size ); > memcpy( data, image, size ); > > GDB output is as follows (seems fine to me) > 79 memcpy( data, image, width * height * 3 ); > (gdb) p data > $1 = (void *) 0x7fffffffea40 > (gdb) p image > $2 = (uint8_t *) 0x7fffb8291830 "" > (gdb) p width > $3 = 320 > (gdb) p height > $4 = 240 > > Can you make any sense of what's going on? I don't have a clue anymore. -H ------------------------------------------------------------------------------ Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnnow-d2d _______________________________________________ Mlt-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mlt-devel
