#include <mlib_status.h>
#include <mlib_sys.h>
#include <mlib_video.h>
+#include <inttypes.h>
+#include <stdlib.h>
+#include <assert.h>
-static void mlib_YUV2ARGB420_32(uint8_t* image, uint8_t* py,
- uint8_t* pu, uint8_t* pv,
- int h_size, int v_size,
- int rgb_stride, int y_stride, int uv_stride)
-{
- mlib_VideoColorYUV2ARGB420(image, py, pu, pv, h_size,
- v_size, rgb_stride, y_stride, uv_stride);
-}
+#include "libvo/img_format.h" //FIXME try to reduce dependency of such stuff
+#include "swscale.h"
-static void mlib_YUV2ABGR420_32(uint8_t* image, uint8_t* py,
- uint8_t* pu, uint8_t* pv,
- int h_size, int v_size,
- int rgb_stride, int y_stride, int uv_stride)
-{
- mlib_VideoColorYUV2ABGR420(image, py, pu, pv, h_size,
- v_size, rgb_stride, y_stride, uv_stride);
+static int mlib_YUV2ARGB420_32(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
+ int srcSliceH, uint8_t* dst[], int dstStride[]){
+ if(c->srcFormat == IMGFMT_422P){
+ srcStride[1] *= 2;
+ srcStride[2] *= 2;
+ }
+
+ assert(srcStride[1] == srcStride[2]);
+
+ mlib_VideoColorYUV2ARGB420(dst[0]+srcSliceY*dstStride[0], src[0], src[1], src[2], c->dstW,
+ srcSliceH, dstStride[0], srcStride[0], srcStride[1]);
+ return srcSliceH;
}
-static void mlib_YUV2RGB420_24(uint8_t* image, uint8_t* py,
- uint8_t* pu, uint8_t* pv,
- int h_size, int v_size,
- int rgb_stride, int y_stride, int uv_stride)
-{
- mlib_VideoColorYUV2RGB420(image, py, pu, pv, h_size,
- v_size, rgb_stride, y_stride, uv_stride);
+static int mlib_YUV2ABGR420_32(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
+ int srcSliceH, uint8_t* dst[], int dstStride[]){
+ if(c->srcFormat == IMGFMT_422P){
+ srcStride[1] *= 2;
+ srcStride[2] *= 2;
+ }
+
+ assert(srcStride[1] == srcStride[2]);
+
+ mlib_VideoColorYUV2ABGR420(dst[0]+srcSliceY*dstStride[0], src[0], src[1], src[2], c->dstW,
+ srcSliceH, dstStride[0], srcStride[0], srcStride[1]);
+ return srcSliceH;
}
+static int mlib_YUV2RGB420_24(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
+ int srcSliceH, uint8_t* dst[], int dstStride[]){
+ if(c->srcFormat == IMGFMT_422P){
+ srcStride[1] *= 2;
+ srcStride[2] *= 2;
+ }
+
+ assert(srcStride[1] == srcStride[2]);
+
+ mlib_VideoColorYUV2RGB420(dst[0]+srcSliceY*dstStride[0], src[0], src[1], src[2], c->dstW,
+ srcSliceH, dstStride[0], srcStride[0], srcStride[1]);
+ return srcSliceH;
+}
-yuv2rgb_fun yuv2rgb_init_mlib(int bpp, int mode)
-{
-
- if( bpp == 24 )
- {
- if( mode == MODE_RGB )
- return mlib_YUV2RGB420_24;
- }
- if( bpp == 32 )
- {
- if( mode == MODE_RGB )
- return mlib_YUV2ARGB420_32;
- else if( mode == MODE_BGR )
- return mlib_YUV2ABGR420_32;
+SwsFunc yuv2rgb_init_mlib(SwsContext *c)
+{
+ switch(c->dstFormat){
+ case IMGFMT_RGB24: return mlib_YUV2RGB420_24;
+ case IMGFMT_RGB32: return mlib_YUV2ARGB420_32;
+ case IMGFMT_BGR32: return mlib_YUV2ABGR420_32;
+ default: return NULL;
}
-
- return NULL;
}