[Sumover-dev] [svn commit] r4760 - in vic/branches/cc: . codec

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Tue Apr 6 16:28:25 BST 2010


Author: soohyunc
Date: Tue Apr  6 16:28:25 2010
New Revision: 4760

Modified:
   vic/branches/cc/codec/encoder-h261.cpp
   vic/branches/cc/module.h
   vic/branches/cc/video/grabber-still.cpp

Log:
added a method to return the average number of packets per video frame
(suspend_grabbing() method uses this one, hence changed)



Modified: vic/branches/cc/codec/encoder-h261.cpp
==============================================================================
--- vic/branches/cc/codec/encoder-h261.cpp	(original)
+++ vic/branches/cc/codec/encoder-h261.cpp	Tue Apr  6 16:28:25 2010
@@ -140,7 +140,7 @@
 	int vfno_;
 
 	// should we suspend grabbing?
-	virtual bool suspend_grabbing();
+	virtual bool suspend_grabbing(int m);
 
     protected:
 	H261Encoder(int ft);
@@ -195,6 +195,9 @@
 	u_int loff_[12];	/* where to find Y given gob# */
 	u_int blkno_[12];	/* for CR */
 
+	// average number of packets per frame
+	int avg_packets_per_frame();
+
 	// print Tx queue info
 	inline void print_txq_info() {
 	fprintf(stderr, "   now: %f\ttxq_now: %d\n", 
@@ -1021,10 +1024,24 @@
 }
 
 /*
+ * average number of packets per frame
+ */
+int H261Encoder::avg_packets_per_frame() {
+	int num = 0;
+	int k = (vfno_ < FHSIZE) ? vfno_ : FHSIZE;
+	if (k < 1) return 1;
+
+	for (int i = 0; i < k; i++)
+		num += ppframe_[vfno_%FHSIZE];
+
+	return (num /= k);
+}
+
+/*
  * if Tx queue is building up more than 5 frames, roughly,
  * then we should suspend grabbing to prevent it from growing up forever.
  */
-bool H261Encoder::suspend_grabbing() {
+bool H261Encoder::suspend_grabbing(int m) {
 	// Tx queue len (in packets) at the time of calling this method
 	int txq = tx_->tx_buf_size();
 	// highest watermark
@@ -1033,16 +1050,9 @@
 	if (vfno_ < FHSIZE) 
 	return false;
 
-	for (int i = 0; i < FHSIZE; i++)
-		highmark += ppframe_[vfno_%FHSIZE];
-
-	// highmark is the average number of packets per frame
-	// (average window size is equal to FHSIZE)
-	highmark /= FHSIZE;
-
-	// now, highmark is set to "5 * (num packets per frame)",
-	// which roughly represents 5 frames.
-	highmark = 5 * highmark;
+	// now, highmark is set to "m * (num packets per frame)",
+	// which roughly represents "m" frames.
+	highmark = m * avg_packets_per_frame();
 
 	if (txq > highmark)
 		return true;

Modified: vic/branches/cc/module.h
==============================================================================
--- vic/branches/cc/module.h	(original)
+++ vic/branches/cc/module.h	Tue Apr  6 16:28:25 2010
@@ -125,7 +125,7 @@
 
 	double offset_;
 	inline double offset() { return offset_; }
-	virtual bool suspend_grabbing() {};
+	virtual bool suspend_grabbing(int) {};
 
     protected:
 	Module(int ft);

Modified: vic/branches/cc/video/grabber-still.cpp
==============================================================================
--- vic/branches/cc/video/grabber-still.cpp	(original)
+++ vic/branches/cc/video/grabber-still.cpp	Tue Apr  6 16:28:25 2010
@@ -370,7 +370,7 @@
 
 	// check if Tx queue is growing too much.
 	// if so, we should suspend grabbing more frames.
-	if (target_->suspend_grabbing())
+	if (target_->suspend_grabbing(5))
 	return (frc);
 
 	// time measurement



More information about the Sumover-dev mailing list