> Assuming you prefer the modern version:
>
>    struct SwsContext* hSwsContext = sws_getContext(pCodecCtx->width, 
> pCodecCtx->height, pCodecCtx->pix_fmt,
>          pCodecCtx->width, pCodecCtx->height, PIX_FMT_RGB24,  SWS_AREA, NULL, 
> NULL, NULL)
>
>    avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet);
>
>    sws_scale(hSwsContext, pFrame->data, pFrame->linesize, 0, 
> pCodecCtx->height, pFrameRGB->data, pFrameRGB->linesize);
>
> If any of the types are unclear, I'll clarify it.
>


Well, I've managed to do this on PC - my mpeg4 stream is decoded and
converted to ARGB (32 bit) correctly.
But when I compile and run the same code on iPhone, the resulting
image is just garbage. I configure the make as follows:

./configure 
--cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc-4.2.1
--as='gas-preprocessor.pl
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc-4.2.1'
--sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.2.sdk
--enable-cross-compile --target-os=darwin --arch=arm
--cpu=arm1176jzf-s --disable-zlib --prefix='build'

The routine looks like this:
//...
packet_.size = bufferSize; // from the network
packet_.data = (uint8_t *)buffer; // from the network
int got_picture;
int len = avcodec_decode_video2(ctx_, picture_, &got_picture, &packet_);

uint8_t *bitmap = allocateBitmap(); // allocates ARGB bitmap
int rgbStride[4]={-(ctx_->width * 4), 0, 0, 0};
uint8_t *rgbDest[4]= {bitmap + (ctx_->height - 1) * ctx_->width * 4, 0, 0, 0};
SwsContext* sws = sws_getContext(ctx_->width, ctx_->height,
ctx_->pix_fmt, ctx_->width, ctx_->height, PIX_FMT_ARGB, SWS_AREA, 0,
0, 0);
sws_scale(sws, picture_->data, picture_->linesize, 0, ctx_->height,
rgbDest, rgbStride);
//....

Changing PIX_FMT_ARGB to some other 32 bit format (PIX_FMT_RGBA etc)
doesn't affect anything.

Any idea would be greatly appreciated!
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to