一.实现图像数据格式转换与图像缩放的三个重要函数
ffmpeg实现图像数据格式的转换以及图片的缩放的功能,主要使用swscale.h中的三个函数:
sws_getContext()
sws_scale()
sws_freeContext()
这三个函数的定义如下:
1.sws_getContext() :
/**
* Allocate and return an SwsContext. You need it to perform
* scaling/conversion operations using sws_scale().
*
* @param srcW the width of the source image
* @param srcH the height of the source image
* @param srcFormat the source image format
* @param dstW the width of the destination image
* @param dstH the height of the destination image
* @param dstFormat the destination image format
* @param flags specify which algorithm and options to use for rescaling
* @param param extra parameters to tune the used scaler
* For SWS_BICUBIC param[0] and [1] tune the shape of the basis
* function, param[0] tunes f(1) and param[1] f麓(1)
* For SWS_GAUSS param[0] tunes the exponent and thus cutoff
* frequency
* For SWS_LANCZOS param[0] tunes the width of the window function
* @return a pointer to an allocated context, or NULL in case of error
* @note this function is to be removed after a saner alternative is
* written
*/
struct SwsContext *sws_getContext(int srcW, int srcH, enum AVPixelFormat srcFormat,
int dstW, int dstH, enum AVPixelFormat dstFormat,
int flags, SwsFilter *srcFilter,
SwsFilter *dstFilter, const double *param);
参数介绍
/*
* @param srcW源图像的宽度
* @param srcH源图像的高度
* @param srcFormat源图像格式
* @param dstW目标图像的宽度
* @param dstH目标图像的高度
* @param dstFormat目标图像格式
* @后面三个参数一般都置为空