Changeset 4685
- Timestamp:
- 03/12/10 02:10:27 (3 years ago)
- Location:
- vic/branches/cc
- Files:
-
- 2 modified
-
cc/o.sh (modified) (1 diff)
-
codec/encoder-h261.cpp (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vic/branches/cc/cc/o.sh
r4648 r4685 13 13 14 14 # encoding time difference 15 grep enc_time trace.s | grep -v pid | awk '{if($1=="n um:" && $3=="enc_time:") print}' | awk '{print $2"\t"$4}' > enct.xg15 grep enc_time trace.s | grep -v pid | awk '{if($1=="now:" && $3=="enc_time:") print}' | awk '{print $2"\t"$4}' > enct.xg 16 16 17 17 # start grab -
vic/branches/cc/codec/encoder-h261.cpp
r4621 r4685 114 114 } 115 115 116 // frame history size to keep track the number of packets per frame 117 #define FHSIZE 10 116 118 117 119 class H261Encoder : public TransmitterModule { 118 120 public: 119 121 void setq(int q); 122 123 // Tx pktbuf size 124 int txq_beg_; 125 int txq_end_; 126 int txq_dif_; 127 // number of transmitted packets for this round of encoding 128 int num_sent_; 129 // number of sent packets in between two encoding instances 130 // (these packets were sent from the Tx queue upon XR reception) 131 int sent_more_; 132 // packets per frame 133 int ppframe_[FHSIZE]; 134 inline void init_ppframe() { 135 for (int i = 0; i < FHSIZE; i++) 136 ppframe_[i] = 0; 137 } 138 // video frame number 139 int vfno_; 140 120 141 protected: 121 142 H261Encoder(int ft); … … 137 158 return ((double) tv.tv_sec + 1e-6 * (double) tv.tv_usec); 138 159 } 139 double ts_off_; // timestamp offset140 160 double enc_start_; // encoding start timestamp 141 161 double enc_end_; // encoding end timestamp 142 int encno_; // number of encoding routine143 162 144 163 /* bit buffer */ … … 177 196 u_int loff_[12]; /* where to find Y given gob# */ 178 197 u_int blkno_[12]; /* for CR */ 198 199 private: 179 200 }; 180 201 … … 221 242 enc_start_ = 0.0; 222 243 enc_end_ = 0.0; 223 encno_ = 1; 244 245 // Tx pktbuf size 246 txq_beg_ = 0; 247 txq_end_ = 0; 248 txq_dif_ = 0; 249 // number of transmitted packets for this round of encoding 250 num_sent_ = 0; 251 // number of sent packets in between two encoding instances 252 // (these packets were sent from the Tx queue upon XR reception) 253 sent_more_ = 0; 254 255 // packets per frame 256 init_ppframe(); 257 // video frame number 258 vfno_ = 0; 224 259 225 260 for (int q = 0; q < 32; ++q) { … … 769 804 bb_ = 0; 770 805 } 806 // increment the number of packets for this frame 807 ppframe_[vfno_%FHSIZE]++; 808 fprintf(stderr, "\tnow: %f\tppframe[%d]: %d\n", 809 h261_now()-offset(), vfno_%FHSIZE, ppframe_[vfno_%FHSIZE]); 771 810 tx_->send(pb); 772 811 … … 786 825 int H261PixelEncoder::consume(const VideoFrame *vf) 787 826 { 827 // adjust timestamp offset 828 tx_->tx_now_offset_ = offset(); 829 830 // (get the necessary stats before encoding) ---------------------* 831 // Tx queue size before entering this encoding 832 txq_beg_ = tx_->tx_buf_size(); 833 // sent packets after the previous encoding round, 834 // but before starting this encoding instance. 835 // -- these packets were sent from the Tx queue 836 // upon XR reception in between two encoding instances. 837 sent_more_ = txq_end_ - txq_beg_; 838 839 fprintf(stderr, "\tnow: %f\tsent: %d more: %d vf[%d]: %d\n", 840 h261_now()-offset(), num_sent_, sent_more_, vfno_%FHSIZE, ppframe_[vfno_%FHSIZE]); 841 842 // all encoded packets associated with 843 // the previously captured frame have been sent 844 if (num_sent_ + sent_more_ == ppframe_[vfno_%FHSIZE]) { 845 } 846 // some packets associated with 847 // the previously captured frame have not been sent 848 if (num_sent_ + sent_more_ < ppframe_[vfno_%FHSIZE]) { 849 } 850 // more packets have been sent than the encoded packets 851 // perhaps, there were some packets in the tx queue, and 852 // cwnd has been increrased allowing sending them all. 853 if (num_sent_ + sent_more_ > ppframe_[vfno_%FHSIZE]) { 854 } 855 // ---------------------------------------------------------------* 856 857 // increment frame number 858 if (vfno_++%FHSIZE == 0) 859 init_ppframe(); 860 861 // check size 788 862 if (!samesize(vf)) 789 863 size(vf->width_, vf->height_); 790 864 865 // main encoding loop 866 // (send packets while encoding) 791 867 YuvFrame* p = (YuvFrame*)vf; 792 return(encode(p, p->crvec_)); 868 int cc = encode(p, p->crvec_); 869 870 // Tx queue size after finishing encoding 871 txq_end_ = tx_->tx_buf_size(); 872 txq_dif_ = txq_end_ - txq_beg_; 873 // number of Tx'd packets during this encoding instance 874 // (these Tx'd packets may include the previous frame(s).) 875 num_sent_ = ppframe_[vfno_%FHSIZE] - txq_dif_; 876 877 fprintf(stderr, " now: %f\ttxq_end: %d\tdif: %d\n", 878 h261_now()-offset(), txq_end_, txq_dif_); 879 880 fprintf(stderr, " now: %f\tenc_time: %f\n\n", 881 h261_now()-offset(), (enc_end_ - enc_start_)); 882 883 return(cc); 793 884 } 794 885 … … 797 888 H261Encoder::encode(const VideoFrame* vf, const u_int8_t *crvec) 798 889 { 799 //fprintf(stderr,"\nH261Encoder encode()\n"); 800 ts_off_ = offset(); 801 tx_->tx_now_offset_ = ts_off_; 802 enc_start_ = h261_now() - ts_off_; 890 enc_start_ = h261_now()-offset(); 803 891 fprintf(stderr,">>>h261_encode_start\tnow: %f\n", enc_start_); 804 892 … … 898 986 899 987 // time measurement 900 enc_end_ = h261_now() - ts_off_;988 enc_end_ = h261_now()-offset(); 901 989 fprintf(stderr,"\n>>>h261_encode_end\tnow: %f\n", enc_end_); 902 fprintf(stderr," num: %d\tenc_time: %f\n\n",903 encno_++, (enc_end_ - enc_start_));904 990 905 991 return (cc);
