Stephane List
2008-09-11 15:17:24 UTC
Hi,
Since img_convert is deprecated, I'm trying to use sws_scale from the
latest svn.
The prototype of sws_scale is :
int sws_scale(SwsContext *c, uint8_t* src[], int srcStride[], int
srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[])
I want to convert from RGB8 to YUV420P from a buffer srcdata to a buffer
dstdata.
Here is my code in C++:
int src_pix_fmt = PIX_FMT_RGB8;
int dst_pix_fmt = PIX_FMT_YUV420P;
int w = 320;
int h = 240;
struct SwsContext *img_convert_ctx = sws_getContext(w, h, src_pix_fmt,
w, h, dst_pix_fmt, SWS_BICUBIC, NULL, NULL, NULL);
if (img_convert_ctx == NULL) {
qDebug() << "Cannot initialize the conversion context!";
return;
}
int srcStride[3];
int dstStride[3];
uint8_t *src[3]= {srcdata, NULL, NULL};
uint8_t *dst[3]= {dstdata, NULL, NULL};
sws_scale(img_convert_ctx, src, srcStride, 0, h, dst, dstStride);
What should I put in srcStride and dstStride ?
Is the rest correct ?
Regards
Stephane
Since img_convert is deprecated, I'm trying to use sws_scale from the
latest svn.
The prototype of sws_scale is :
int sws_scale(SwsContext *c, uint8_t* src[], int srcStride[], int
srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[])
I want to convert from RGB8 to YUV420P from a buffer srcdata to a buffer
dstdata.
Here is my code in C++:
int src_pix_fmt = PIX_FMT_RGB8;
int dst_pix_fmt = PIX_FMT_YUV420P;
int w = 320;
int h = 240;
struct SwsContext *img_convert_ctx = sws_getContext(w, h, src_pix_fmt,
w, h, dst_pix_fmt, SWS_BICUBIC, NULL, NULL, NULL);
if (img_convert_ctx == NULL) {
qDebug() << "Cannot initialize the conversion context!";
return;
}
int srcStride[3];
int dstStride[3];
uint8_t *src[3]= {srcdata, NULL, NULL};
uint8_t *dst[3]= {dstdata, NULL, NULL};
sws_scale(img_convert_ctx, src, srcStride, 0, h, dst, dstStride);
What should I put in srcStride and dstStride ?
Is the rest correct ?
Regards
Stephane