[Sumover-dev] [svn commit] r3956 - vic/branches/mpeg4/codec

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Wed Dec 13 17:31:44 GMT 2006


Author: barz
Date: Wed Dec 13 17:31:57 2006
New Revision: 3956

Modified:
   vic/branches/mpeg4/codec/encoder-h264.cpp
   vic/branches/mpeg4/codec/x264encoder.cpp

Log:
bugfix: x264encoder crash problem in win32

Modified: vic/branches/mpeg4/codec/encoder-h264.cpp
==============================================================================
--- vic/branches/mpeg4/codec/encoder-h264.cpp	(original)
+++ vic/branches/mpeg4/codec/encoder-h264.cpp	Wed Dec 13 17:31:57 2006
@@ -34,7 +34,6 @@
 
     void size(int w, int h);
     int consume(const VideoFrame *);
-    static void rtp_callback(void *data, int size, int packet_number);
 
   protected:
     int fps, kbps, gop;
@@ -92,12 +91,7 @@
 {
     if (argc == 3) {
 	if (strcmp(argv[1], "q") == 0) {
-	    // mpeg4.quality = atoi(argv[2]);
-	    // mpeg4.set_max_quantizer(mpeg4.quality);
 	    gop = atoi(argv[2]);
-	    //if(enc->isInitialized())
-	    //      enc->setGOP(gop);
-	    //h264.set_gop(gop);
 	    return (TCL_OK);
 	}
 	else if (strcmp(argv[1], "fps") == 0) {
@@ -114,8 +108,6 @@
 	}
 	else if (strcmp(argv[1], "hq") == 0) {
 	    int enable_hq = atoi(argv[2]);
-	    // printf("enable h264 high quality encoding\n");
-	    //h264.enable_hq_encoding = bool(enable_hq);
 	    return (TCL_OK);
 	}
     }
@@ -145,7 +137,6 @@
 	    enc->init(vf->width_, vf->height_, kbps, fps);
 	    enc->setGOP(gop);
 	    frame_size = vf->width_ * vf->height_;
-	    //fptr = fopen("out.m4v", "w");
     }
 
     frame_size = vf->width_ * vf->height_;
@@ -166,8 +157,7 @@
 
 	sent_size += fOut->getDataSize();
 	char *data = fOut->getData();
-	//DEBUG
-	//fwrite(data, fOut->getFrameSize(), 1, fptr);
+
 
 	int nalSize = fOut->getDataSize();
 	if (i == i_nal - 1 && f_total_pkt == 0)
@@ -178,8 +168,7 @@
 	    rh = (rtphdr *) pb->data;
 	    if (nalSize > 1000) {
 		memcpy(&pb->data[14], data + offset, 1000);
-		//DEBUG
-		//fwrite(data+offset, 1000, 1, fptr);
+
 		pb->len = 1000 + 14;
 		offset += 1000;
 		nalSize -= 1000;
@@ -190,9 +179,6 @@
 		    rh->rh_flags |= htons(RTP_M);	// set M bit
 		}
 		memcpy(&pb->data[14], data + offset, nalSize);
-		//DEBUG
-		//printf("encode a frame...\n");
-		//fwrite(data+offset, nalSize, 1, fptr);
 
 		pb->len = nalSize + 14;
 		nalSize = 0;

Modified: vic/branches/mpeg4/codec/x264encoder.cpp
==============================================================================
--- vic/branches/mpeg4/codec/x264encoder.cpp	(original)
+++ vic/branches/mpeg4/codec/x264encoder.cpp	Wed Dec 13 17:31:57 2006
@@ -36,6 +36,7 @@
     x264 *enc = (x264 *) encoder;
     if (enc->h != NULL) {
 	  x264_encoder_close(enc->h);
+	  x264_picture_clean(&(enc->pic));
     }
     free(enc);
 }
@@ -83,6 +84,8 @@
     param->i_width = w;
     param->i_height = h;
 
+	x264_picture_alloc(&(enc->pic), X264_CSP_I420, param->i_width,
+	       param->i_height);
 
     x264_t *handle = x264_encoder_open(param);
     if (handle != NULL) {
@@ -104,13 +107,6 @@
 
     //refresh 
     enc->i_nal = 0;
-
-    enc->pic.img.i_csp = X264_CSP_I420;
-    enc->pic.img.i_plane = 3;
-    enc->pic.i_type = X264_TYPE_AUTO;
-    enc->pic.img.i_stride[0] = param->i_width;
-    enc->pic.img.i_stride[1] = param->i_width/2;
-    enc->pic.img.i_stride[2] = param->i_width/2;
     enc->pic.img.plane[0] = buf;
     enc->pic.img.plane[1] = buf + frame_size;
     enc->pic.img.plane[2] = buf + frame_size*5/4;



More information about the Sumover-dev mailing list