Changeset 255
- Timestamp:
- 06/09/06 15:33:51 (16 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/libfreebob-2.0/src/libstreaming/AmdtpStreamProcessor.cpp
r253 r255 106 106 *tag = IEC61883_TAG_WITH_CIP; 107 107 *sy = 0; 108 m_last_timestamp= 9000.0 + cycle * 3072.0;108 m_last_timestamp=4.0*9000.0 + cycle * 3072.0; 109 109 return RAW1394_ISO_OK; 110 110 } … … 196 196 197 197 unsigned int timestamp2=ntohs(timestamp); 198 debugOutput(DEBUG_LEVEL_VER BOSE,"XMIT %d EVENTS, SYT %04X (was: %04X) for cycle %2d: %5u ticks (%2u cycles + %04u ticks)\n",198 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"XMIT %d EVENTS, SYT %04X (was: %04X) for cycle %2d: %5u ticks (%2u cycles + %04u ticks)\n", 199 199 nevents, timestamp, packet->syt, cycle, 200 200 CYCLE_COUNTER_TO_TICKS(timestamp2), … … 878 878 // actual presentation time later 879 879 if (packet->syt != 0xFFFF) { 880 881 bool wraparound_occurred=false; 880 882 881 883 m_last_timestamp2=m_last_timestamp; … … 887 889 888 890 // if this is true, wraparound has occurred, undo this wraparound 889 if(syt_cycle<now_cycle_masked) syt_cycle += 0x F;891 if(syt_cycle<now_cycle_masked) syt_cycle += 0x10; 890 892 891 893 unsigned int delta_cycles=syt_cycle-now_cycle_masked; … … 894 896 unsigned int new_cycles=cycle + delta_cycles; 895 897 896 if(new_cycles>7999) new_cycles-=8000; // wrap around 898 if(new_cycles>7999) { 899 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Detected wraparound: %d + %d = %d\n",cycle,delta_cycles,new_cycles); 900 901 new_cycles-=8000; // wrap around 902 wraparound_occurred=true; 903 } 897 904 898 905 m_last_timestamp = (new_cycles) << 12; … … 901 908 m_last_timestamp |= (syt_timestamp & 0xFFF); 902 909 910 // mask off the seconds field 911 903 912 // m_last_timestamp timestamp now contains all info, 904 913 // including cycle number … … 906 915 if (m_last_timestamp & m_last_timestamp2) { 907 916 // try and estimate the frame rate from the device: 908 int timestamp_difference= CYCLE_COUNTER_TO_TICKS(m_last_timestamp)909 - CYCLE_COUNTER_TO_TICKS(m_last_timestamp2);917 int timestamp_difference=((int)(CYCLE_COUNTER_TO_TICKS(m_last_timestamp))) 918 -((int)(CYCLE_COUNTER_TO_TICKS(m_last_timestamp2))); 910 919 911 // handle wrap around of the cycle variable 912 if (new_cycles==0) timestamp_difference+=TICKS_PER_SECOND; 920 // handle wrap around of the cycle variable if nescessary 921 // it can be that two successive timestamps cause wraparound (if the difference between time 922 // stamps is larger than 2 cycles), thus it isn't always nescessary 923 if (wraparound_occurred & (m_last_timestamp<m_last_timestamp2)) { 924 debugOutput(DEBUG_LEVEL_VERY_VERBOSE," => correcting for timestamp difference wraparound\n"); 925 timestamp_difference+=TICKS_PER_SECOND; 926 } 913 927 914 928 // implement a 1st order DLL to estimate the framerate … … 920 934 err=err-m_ticks_per_frame; 921 935 936 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"SYT: %08X | STMP: %08X | DLL: in=%5.0f, current=%f, err=%e\n",syt_timestamp, m_last_timestamp, f,m_ticks_per_frame,err); 937 938 #ifdef DEBUG 939 if(f > 1.5*((TICKS_PER_SECOND*1.0) / m_framerate)*m_syt_interval) { 940 debugWarning("Timestamp diff more than 50%% of the nominal diff too large!\n"); 941 debugWarning(" SYT: %08X | STMP: %08X,%08X | DLL: in=%5.0f, current=%f, err=%e\n",syt_timestamp, m_last_timestamp, m_last_timestamp2, f,m_ticks_per_frame,err); 942 } 943 if(f < 0.5*((TICKS_PER_SECOND*1.0) / m_framerate)*m_syt_interval) { 944 debugWarning("Timestamp diff more than 50%% of the nominal diff too small!\n"); 945 debugWarning(" SYT: %08X | STMP: %08X,%08X | DLL: in=%5.0f, current=%f, err=%e\n",syt_timestamp, m_last_timestamp, m_last_timestamp2, f,m_ticks_per_frame,err); 946 } 947 #endif 948 949 const double coeff=0.0001; 922 950 // integrate the error 923 m_ticks_per_frame += 0.000001*err; 951 m_ticks_per_frame += coeff*err; 952 924 953 } 925 954 … … 934 963 #ifdef DEBUG 935 964 if(m_last_timestamp<m_last_timestamp2) { 936 if( new_cycles==0) {937 debug Warning("timestamp not sequential, but it's wraparound. %08X %08X %08X\n",syt_timestamp, m_last_timestamp, m_last_timestamp2);965 if(wraparound_occurred) { 966 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"timestamp not sequential for cycle %d, but it's wraparound. %08X %08X %08X\n",cycle,syt_timestamp, m_last_timestamp, m_last_timestamp2); 938 967 } else { 939 debugFatal("timestamp not sequential! %08X %08X %08X\n",syt_timestamp, m_last_timestamp, m_last_timestamp2); 940 return RAW1394_ISO_STOP; 968 debugWarning("timestamp not sequential for cycle %d! %08X %08X %08X\n", cycle, syt_timestamp, m_last_timestamp, m_last_timestamp2); 969 970 // the DLL will recover from this. 971 m_last_timestamp2=m_last_timestamp; 941 972 } 942 973 } … … 1063 1094 1064 1095 if(tmp<0) { 1065 debugOutput(DEBUG_LEVEL_VER BOSE,"SYT passed (%d ticks too late)\n",-tmp);1066 debugOutput(DEBUG_LEVEL_VER BOSE,"Periods: %d, remote ticks/frame: %f, remote framerate = %f\n",m_PeriodStat.m_count, m_ticks_per_frame, 24576000.0/m_ticks_per_frame);1096 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"SYT passed (%d ticks too late)\n",-tmp); 1097 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Periods: %d, remote ticks/frame: %f, remote framerate = %f\n",m_PeriodStat.m_count, m_ticks_per_frame, 24576000.0/m_ticks_per_frame); 1067 1098 if (-tmp>1000000) debugWarning("SYT VERY LATE: %d!\n",-tmp); 1068 1099 // return true; … … 1079 1110 #endif 1080 1111 } 1112 1113 void AmdtpReceiveStreamProcessor::dumpInfo() 1114 { 1115 1116 StreamProcessor::dumpInfo(); 1117 1118 debugOutputShort( DEBUG_LEVEL_NORMAL, " Device framerate : %f\n", 24576000.0/m_ticks_per_frame); 1119 1120 } 1121 1081 1122 1082 1123 void AmdtpReceiveStreamProcessor::setVerboseLevel(int l) { branches/libfreebob-2.0/src/libstreaming/AmdtpStreamProcessor.h
r253 r255 182 182 double getTicksPerFrame() {return m_ticks_per_frame;}; 183 183 184 void dumpInfo(); 185 184 186 protected: 185 187 branches/libfreebob-2.0/src/libstreaming/StreamProcessor.cpp
r250 r255 63 63 debugOutputShort( DEBUG_LEVEL_NORMAL, " Iso stream info:\n"); 64 64 65 ((IsoStream*)this)->dumpInfo();65 IsoStream::dumpInfo(); 66 66 debugOutputShort( DEBUG_LEVEL_NORMAL, " Frame counter : %d\n", m_framecounter); 67 67 debugOutputShort( DEBUG_LEVEL_NORMAL, " Xruns : %d\n", m_xruns); … … 74 74 75 75 76 } ;76 } 77 77 78 78 bool StreamProcessor::init()