renamed png functions
[swftools.git] / lib / h.263 / swfvideo.c
index 4c5983d..d9e1803 100644 (file)
@@ -37,13 +37,6 @@ U16 totalframes = 0;
 #endif
 void swf_SetVideoStreamDefine(TAG*tag, VIDEOSTREAM*stream, U16 frames, U16 width, U16 height)
 {
-    swf_SetU16(tag, frames);
-    swf_SetU16(tag, width);
-    swf_SetU16(tag, height);
-    //swf_SetU8(tag, 1); /* smoothing on */
-    swf_SetU8(tag, 0); /* smoothing off */
-    swf_SetU8(tag, 2); /* codec = h.263 sorenson spark */
-
 #ifdef MAIN
     totalframes = frames;
 #endif
@@ -58,26 +51,31 @@ void swf_SetVideoStreamDefine(TAG*tag, VIDEOSTREAM*stream, U16 frames, U16 width
     stream->height = height;
     stream->bbx = width/16;
     stream->bby = height/16;
-    stream->current = (YUV*)malloc(width*height*sizeof(YUV));
-    stream->oldpic = (YUV*)malloc(width*height*sizeof(YUV));
-    stream->mvdx = (int*)malloc(stream->bbx*stream->bby*sizeof(int));
-    stream->mvdy = (int*)malloc(stream->bbx*stream->bby*sizeof(int));
+    stream->current = (YUV*)rfx_calloc(width*height*sizeof(YUV));
+    stream->oldpic = (YUV*)rfx_calloc(width*height*sizeof(YUV));
+    stream->mvdx = (int*)rfx_alloc(stream->bbx*stream->bby*sizeof(int));
+    stream->mvdy = (int*)rfx_alloc(stream->bbx*stream->bby*sizeof(int));
     stream->do_motion = 0;
 
-    memset(stream->oldpic, 0, width*height*sizeof(YUV));
-    memset(stream->current, 0, width*height*sizeof(YUV));
-
     assert((stream->width&15) == 0);
     assert((stream->height&15) == 0);
     assert((stream->bbx*16) == stream->width);
     assert((stream->bby*16) == stream->height);
+    
+    swf_SetU16(tag, frames);
+    swf_SetU16(tag, width);
+    swf_SetU16(tag, height);
+    //swf_SetU8(tag, 1); /* smoothing on */
+    swf_SetU8(tag, 0); /* smoothing off */
+    swf_SetU8(tag, 2); /* codec = h.263 sorenson spark */
+
 }
 void swf_VideoStreamClear(VIDEOSTREAM*stream)
 {
-    free(stream->oldpic);stream->oldpic = 0;
-    free(stream->current);stream->current = 0;
-    free(stream->mvdx);stream->mvdx=0;
-    free(stream->mvdy);stream->mvdy=0;
+    rfx_free(stream->oldpic);stream->oldpic = 0;
+    rfx_free(stream->current);stream->current = 0;
+    rfx_free(stream->mvdx);stream->mvdx=0;
+    rfx_free(stream->mvdy);stream->mvdy=0;
 }
 
 typedef struct _block_t
@@ -1243,11 +1241,11 @@ void swf_SetVideoStreamBlackFrame(TAG*tag, VIDEOSTREAM*s)
 {
     int bx, by;
     int quant = 31;
+    int x,y;
     s->quant = quant;
 
     writeHeader(tag, s->width, s->height, s->frame, quant, TYPE_IFRAME);
 
-    int x,y;
     for(y=0;y<s->height;y++)
     for(x=0;x<s->width;x++) {
        s->current[y*s->width+x].y = 0;
@@ -1395,7 +1393,7 @@ void test_copy_diff()
     VIDEOSTREAM stream;
     VIDEOSTREAM* s = &stream;
     TAG*tag;
-    RGBA*pic = malloc(256*256*sizeof(RGBA));
+    RGBA*pic = (RGBA*)rfx_alloc(256*256*sizeof(RGBA));
     block_t fb;
     int x,y;
     int bx,by;
@@ -1450,8 +1448,7 @@ void mkblack()
     RGBA* pic = 0;
     VIDEOSTREAM stream;
    
-    pic = malloc(width*height*4);
-    memset(pic, 0, width*height*4);
+    pic = rfx_calloc(width*height*4);
 
     memset(&swf,0,sizeof(SWF));
     memset(&obj,0,sizeof(obj));
@@ -1502,7 +1499,7 @@ void mkblack()
     tag = swf_InsertTag(tag, ST_END);
 
     int fi = open("black.swf", O_WRONLY|O_CREAT|O_TRUNC, 0644);
-    if(swf_WriteSWC(fi,&swf)<0) {
+    if(swf_WriteSWF(fi,&swf)<0) {
        fprintf(stderr,"WriteSWF() failed.\n");
     }
     close(fi);
@@ -1517,8 +1514,8 @@ int main(int argn, char*argv[])
     TAG * tag;
     RGBA* pic, *pic2, rgb;
     SWFPLACEOBJECT obj;
-    int width = 0;
-    int height = 0;
+    unsigned width = 0;
+    unsigned height = 0;
     int frames = 10;
     int framerate = 29;
     unsigned char*data;
@@ -1535,11 +1532,11 @@ int main(int argn, char*argv[])
 
     memset(&stream, 0, sizeof(stream));
 
-    getPNG(fname, &width, &height, &data);
-    pic = (RGBA*)malloc(width*height*sizeof(RGBA));
-    pic2 = (RGBA*)malloc(width*height*sizeof(RGBA));
+    png_load(fname, &width, &height, &data);
+    pic = (RGBA*)rfx_alloc(width*height*sizeof(RGBA));
+    pic2 = (RGBA*)rfx_alloc(width*height*sizeof(RGBA));
     memcpy(pic, data, width*height*sizeof(RGBA));
-    free(data);
+    rfx_free(data);
 
     printf("Compressing %s, size %dx%d\n", fname, width, height);
 
@@ -1637,7 +1634,7 @@ int main(int argn, char*argv[])
     tag = swf_InsertTag(tag, ST_END);
 
     fi = open("video3.swf", O_WRONLY|O_CREAT|O_TRUNC, 0644);
-    if(swf_WriteSWC(fi,&swf)<0) {
+    if(swf_WriteSWF(fi,&swf)<0) {
        fprintf(stderr,"WriteSWF() failed.\n");
     }
     close(fi);