Aah.
I mis understood how it worked, sorry. Thanks for pointing that out. I went back and looked at more examples closely. I now have it working.
Cheers :)

On 14/11/10 04:37, sq.cheng wrote:
Just like my reply for another thread, the keys are the input and output for
sws_scale().

1,     nFrame = avcodec_alloc_frame();
avcodec_alloc_frame(), it can NOT know what exactly you want to do.
It don'know you want RGB24 frame, so how it can alloc RGB24 frame?

2      and in sws_scale :  the nFrame->data, and nFrame->linesize
here, you can print or dump them to see what are they,

1&  2 are not enough to let sws_scale know what you want.

For output frame, you need to allocate memory for nFrame->data
according to your image, width*height*(24/8)
and you need to give the values of nFrame->linesize[4].


On Sun, Nov 14, 2010 at 8:49 AM, George Smart<[email protected]>wrote:

Hi All,

I am trying to convert from YUV420P to RGB24 with /sws_scale/.  The source
video is from an AVI file, via /avcodec_decode_video2()/.  I get a
segmentation fault every time, and am at a complete loss.  If anyone can
suggest anything I would be greatly appreciative.  I have followed various
tutorials and looked at many different examples. I am sure it's a simple
mistake I'm making.  My /sws_getContext()/ Call is as follows:

swsC = sws_getContext(    pCodecCtx->width,    //    Source width
                                            pCodecCtx->height,    //
  Source height
                                            //pFrame->pict_type, //
  Source format (maybe PIX_FMT_YUV420P)
                                            pCodecCtx->pix_fmt, //    Source
format (maybe PIX_FMT_YUV420P)
                                            pCodecCtx->width,    //    Dest
width
                                            pCodecCtx->height,    //    Dest
height
                                            PIX_FMT_RGB24,        //    Dest
format

  SWS_FAST_BILINEAR+SWS_PRINT_INFO,    //    Transform Type (choose from SWS
FLAGS)
                                            NULL, NULL, NULL);    //
  Filters&  Pointer Setup (NULL chooses defaults for last 3 options)

After checking /swsC/ this is used directly in the /sws_scale()/ call, as
follows:

sws_scale(    swsC,                                    //    SwsContext -
Setup for scaling
                            (const uint8_t* const*)    pFrame->data,    //
  Source frame data (cast to required type)
                            pFrame->linesize,                        //
  Source frame stride
                            0,                                        //
  Source frame slice width (raster, so no width slicing)
                            pCodecCtx->height,                        //
  Source frame slice height
                            nFrame->data,                            //
  Dest frame data
                            nFrame->linesize);                        //
  Dest frame stride

In the above line(s), I get the SEG fault - every time.

Any pointers (no pun intended) would be greatly received.  Full Program
Listing, here: http://www.ee.ucl.ac.uk/~zceed42/gs.html<
http://www.ee.ucl.ac.uk/%7Ezceed42/gs.html>

Thanks, Regards,
George Smart.
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to