sws_scale(img_convert_ctx, rgbFrame->data, rgbFrame->linesize,
0, c->height, picture->data,
picture->linesize);
pay attention to this function the fourth param must be set. take a look
at libswscale\swscale.h line 61
/* values for the flags, the stuff on the command line is different */
#define SWS_FAST_BILINEAR 1
#define SWS_BILINEAR 2
#define SWS_BICUBIC 4
#define SWS_X 8
#define SWS_POINT 0x10
#define SWS_AREA 0x20
#define SWS_BICUBLIN 0x40
#define SWS_GAUSS 0x80
#define SWS_SINC 0x100
#define SWS_LANCZOS 0x200
#define SWS_SPLINE 0x400
#define SWS_SRC_V_CHR_DROP_MASK 0x30000
#define SWS_SRC_V_CHR_DROP_SHIFT 16
#define SWS_PARAM_DEFAULT 123456
#define SWS_PRINT_INFO 0x1000
enjoy!
On Fri, Mar 19, 2010 at 9:57 PM, Sujyanarayan Das <
[email protected]> wrote:
> Hi,
> I'm developing an application which tries to convert array of uiimages to
> video
> format. As uiimages are in RGBA format and I have to convert it into
> YUV420P
> format. So for that i'm using the following code:-
> img_convert_ctx = sws_getContext(c->width, c->height,PIX_FMT_RGB32,
> c->width, c->height,
> c->pix_fmt,
> sws_flags, NULL, NULL,
> NULL);
> if (img_convert_ctx == NULL) {
> fprintf(stderr, "Cannot initialize the conversion
> context\n");
> exit(1);
> }
> UIImage *image = [UIImage imageWithData:[frames
> objectAtIndex:frame_count]];
> CGImageRef imageRef = image.CGImage;
> NSData *data = (NSData *)
> CGDataProviderCopyData(CGImageGetDataProvider(imageRef));
> uint8_t *pixels = (uint8_t *)[data bytes];
> uint8_t *pixelsR = (uint8_t *)malloc([data length]/4);
> uint8_t *pixelsG = (uint8_t *)malloc([data length]/4);
> uint8_t *pixelsB = (uint8_t *)malloc([data length]/4);
> uint8_t *pixelsA = (uint8_t *)malloc([data length]/4);
> int p = 0;
> for(int i = 0; i < [data length]; i += 4)
> {
> int r = i ; int g = i+1; int b = i+2; int a = i+3;
> pixelsR[p] = pixels[r];
> pixelsG[p] = pixels[g];
> pixelsB[p] = pixels[b];
> pixelsA[p] = pixels[a];
> p++;
> }
> rgbFrame->data[0] = pixelsR;
> rgbFrame->data[1] = pixelsG;
> rgbFrame->data[2] = pixelsB;
> rgbFrame->linesize[0] = c->width;
> //rgbFrame->linesize[1] = c->width;
> //rgbFrame->linesize[2] = c->width;
> sws_scale(img_convert_ctx, rgbFrame->data, rgbFrame->linesize,
> 0, c->height, picture->data,
> picture->linesize);
>
> I'm getting the video but not clear with some different colors.
> I think I'm not initializing the data[0],data[1],data[2],data[3],
> linesize[0],
> linesize[1], linesize[2], linesize[3].
> Can I get the help that where i'm going wrong by rectifying me. As it is
> little
> bit tricky.
>
> Thanks in Advance.
>
> _______________________________________________
> 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