summaryrefslogtreecommitdiffstats
path: root/libswscale/swscale-example.c
diff options
context:
space:
mode:
authorlucabe <lucabe@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-09-17 15:15:13 +0000
committerlucabe <lucabe@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-09-17 15:15:13 +0000
commit51cd63eb1ce54742e942942e0604bbc974a4c0cb (patch)
tree731f5eb543ff4e6fbb6631cf15f769ecae180c8c /libswscale/swscale-example.c
parent212e625ee67fdb0a4e1992260986fea43063f24e (diff)
downloadmpv-51cd63eb1ce54742e942942e0604bbc974a4c0cb.tar.bz2
mpv-51cd63eb1ce54742e942942e0604bbc974a4c0cb.tar.xz
Remove the dependency of libswscale on img_format.h
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@19878 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libswscale/swscale-example.c')
-rw-r--r--libswscale/swscale-example.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/libswscale/swscale-example.c b/libswscale/swscale-example.c
index 3164377a0f..e9596f19b8 100644
--- a/libswscale/swscale-example.c
+++ b/libswscale/swscale-example.c
@@ -22,24 +22,25 @@
#include <inttypes.h>
#include <stdarg.h>
+#undef HAVE_AV_CONFIG_H
+#include "avutil.h"
#include "swscale.h"
-#include "libmpcodecs/img_format.h"
static int testFormat[]={
-IMGFMT_YVU9,
-IMGFMT_YV12,
+PIX_FMT_YUV410P,
+PIX_FMT_YUV420P,
//IMGFMT_IYUV,
-IMGFMT_I420,
-IMGFMT_BGR15,
-IMGFMT_BGR16,
-IMGFMT_BGR24,
-IMGFMT_BGR32,
-IMGFMT_RGB24,
-IMGFMT_RGB32,
+//IMGFMT_I420,
+PIX_FMT_BGR555,
+PIX_FMT_BGR565,
+PIX_FMT_BGR24,
+PIX_FMT_RGB32,
+PIX_FMT_RGB24,
+PIX_FMT_BGR32,
//IMGFMT_Y8,
-IMGFMT_Y800,
+PIX_FMT_GRAY8,
//IMGFMT_YUY2,
-0
+PIX_FMT_NONE
};
static uint64_t getSSD(uint8_t *src1, uint8_t *src2, int stride1, int stride2, int w, int h){
@@ -73,12 +74,12 @@ static void doTest(uint8_t *ref[3], int refStride[3], int w, int h, int srcForma
for(i=0; i<3; i++){
// avoid stride % bpp != 0
- if(srcFormat==IMGFMT_RGB24 || srcFormat==IMGFMT_BGR24)
+ if(srcFormat==PIX_FMT_RGB24 || srcFormat==PIX_FMT_BGR24)
srcStride[i]= srcW*3;
else
srcStride[i]= srcW*4;
- if(dstFormat==IMGFMT_RGB24 || dstFormat==IMGFMT_BGR24)
+ if(dstFormat==PIX_FMT_RGB24 || dstFormat==PIX_FMT_BGR24)
dstStride[i]= dstW*3;
else
dstStride[i]= dstW*4;
@@ -86,11 +87,16 @@ static void doTest(uint8_t *ref[3], int refStride[3], int w, int h, int srcForma
src[i]= (uint8_t*) malloc(srcStride[i]*srcH);
dst[i]= (uint8_t*) malloc(dstStride[i]*dstH);
out[i]= (uint8_t*) malloc(refStride[i]*h);
+ if ((src[i] == NULL) || (dst[i] == NULL) || (out[i] == NULL)) {
+ perror("Malloc");
+
+ goto end;
+ }
}
- srcContext= sws_getContext(w, h, IMGFMT_YV12, srcW, srcH, srcFormat, flags, NULL, NULL, NULL);
+ srcContext= sws_getContext(w, h, PIX_FMT_YUV420P, srcW, srcH, srcFormat, flags, NULL, NULL, NULL);
dstContext= sws_getContext(srcW, srcH, srcFormat, dstW, dstH, dstFormat, flags, NULL, NULL, NULL);
- outContext= sws_getContext(dstW, dstH, dstFormat, w, h, IMGFMT_YV12, flags, NULL, NULL, NULL);
+ outContext= sws_getContext(dstW, dstH, dstFormat, w, h, PIX_FMT_YUV420P, flags, NULL, NULL, NULL);
if(srcContext==NULL ||dstContext==NULL ||outContext==NULL){
printf("Failed allocating swsContext\n");
goto end;
@@ -110,7 +116,7 @@ static void doTest(uint8_t *ref[3], int refStride[3], int w, int h, int srcForma
ssdU= getSSD(ref[1], out[1], refStride[1], refStride[1], (w+1)>>1, (h+1)>>1);
ssdV= getSSD(ref[2], out[2], refStride[2], refStride[2], (w+1)>>1, (h+1)>>1);
- if(srcFormat == IMGFMT_Y800 || dstFormat==IMGFMT_Y800) ssdU=ssdV=0; //FIXME check that output is really gray
+ if(srcFormat == PIX_FMT_GRAY8 || dstFormat==PIX_FMT_GRAY8) ssdU=ssdV=0; //FIXME check that output is really gray
ssdY/= w*h;
ssdU/= w*h/4;
@@ -155,10 +161,10 @@ static void selfTest(uint8_t *src[3], int stride[3], int w, int h){
for(srcFormatIndex=0; ;srcFormatIndex++){
srcFormat= testFormat[srcFormatIndex];
- if(!srcFormat) break;
+ if(srcFormat == PIX_FMT_NONE) break;
for(dstFormatIndex=0; ;dstFormatIndex++){
dstFormat= testFormat[dstFormatIndex];
- if(!dstFormat) break;
+ if(dstFormat == PIX_FMT_NONE) break;
// if(!isSupportedOut(dstFormat)) continue;
printf("%s -> %s\n",
sws_format_name(srcFormat),
@@ -190,7 +196,7 @@ int main(int argc, char **argv){
int x, y;
struct SwsContext *sws;
- sws= sws_getContext(W/12, H/12, IMGFMT_BGR32, W, H, IMGFMT_YV12, 2, NULL, NULL, NULL);
+ sws= sws_getContext(W/12, H/12, PIX_FMT_RGB32, W, H, PIX_FMT_YUV420P, 2, NULL, NULL, NULL);
for(y=0; y<H; y++){
for(x=0; x<W*4; x++){