Elevate NetEq short-term activity statistics to ACM level for logging.
Review URL: https://webrtc-codereview.appspot.com/1313004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3850 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
		| @@ -23,6 +23,7 @@ | |||||||
| #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" | #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" | ||||||
| #include "webrtc/system_wrappers/interface/tick_util.h" | #include "webrtc/system_wrappers/interface/tick_util.h" | ||||||
| #include "webrtc/system_wrappers/interface/trace.h" | #include "webrtc/system_wrappers/interface/trace.h" | ||||||
|  | #include "webrtc/system_wrappers/interface/trace_event.h" | ||||||
|  |  | ||||||
| namespace webrtc { | namespace webrtc { | ||||||
|  |  | ||||||
| @@ -655,6 +656,21 @@ int32_t ACMNetEQ::RecOut(AudioFrame& audio_frame) { | |||||||
|   } |   } | ||||||
|   previous_audio_activity_ = audio_frame.vad_activity_; |   previous_audio_activity_ = audio_frame.vad_activity_; | ||||||
|  |  | ||||||
|  |   WebRtcNetEQ_ProcessingActivity processing_stats; | ||||||
|  |   WebRtcNetEQ_GetProcessingActivity(inst_[0], &processing_stats); | ||||||
|  |   TRACE_EVENT2("webrtc", "ACM::RecOut", | ||||||
|  |                "accelerate bgn", processing_stats.accelerate_bgn_samples, | ||||||
|  |                "accelerate normal", processing_stats.accelerate_normal_samples); | ||||||
|  |   TRACE_EVENT2("webrtc", "ACM::RecOut", | ||||||
|  |                "expand bgn", processing_stats.expand_bgn_sampels, | ||||||
|  |                "expand normal", processing_stats.expand_normal_samples); | ||||||
|  |   TRACE_EVENT2("webrtc", "ACM::RecOut", | ||||||
|  |                "preemptive bgn", processing_stats.preemptive_expand_bgn_samples, | ||||||
|  |                "preemptive normal", | ||||||
|  |                processing_stats.preemptive_expand_normal_samples); | ||||||
|  |   TRACE_EVENT2("webrtc", "ACM::RecOut", | ||||||
|  |                "merge bgn", processing_stats.merge_expand_bgn_samples, | ||||||
|  |                "merge normal", processing_stats.merge_expand_normal_samples); | ||||||
|   return 0; |   return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -166,6 +166,8 @@ int WebRtcNetEQ_Accelerate(DSPInst_t *inst, | |||||||
|  |  | ||||||
|         /* update statistics */ |         /* update statistics */ | ||||||
|         inst->statInst.accelerateLength += w16_bestIndex; |         inst->statInst.accelerateLength += w16_bestIndex; | ||||||
|  |         /* Short-term activity statistics. */ | ||||||
|  |         inst->activity_stats.accelerate_bgn_samples += w16_bestIndex; | ||||||
|  |  | ||||||
|         return 0; |         return 0; | ||||||
|     } /* end of special code for BGN mode */ |     } /* end of special code for BGN mode */ | ||||||
| @@ -456,6 +458,8 @@ int WebRtcNetEQ_Accelerate(DSPInst_t *inst, | |||||||
|  |  | ||||||
|         /* Update in-call statistics */ |         /* Update in-call statistics */ | ||||||
|         inst->statInst.accelerateLength += w16_bestIndex; |         inst->statInst.accelerateLength += w16_bestIndex; | ||||||
|  |         /* Short-term activity statistics. */ | ||||||
|  |         inst->activity_stats.accelarate_normal_samples += w16_bestIndex; | ||||||
|  |  | ||||||
|         return 0; |         return 0; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -396,6 +396,23 @@ int WebRtcNetEQ_ClearPostCallStats(DSPInst_t *inst) | |||||||
|     return (0); |     return (0); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /**************************************************************************** | ||||||
|  |  * WebRtcNetEQ_ClearActivityStats(...) | ||||||
|  |  * | ||||||
|  |  * Reset processing activity statistics. | ||||||
|  |  * | ||||||
|  |  * Input: | ||||||
|  |  *    - inst          : NetEQ DSP instance | ||||||
|  |  * | ||||||
|  |  * Output: | ||||||
|  |  *    - inst          : Updated instance | ||||||
|  |  * | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | void WebRtcNetEQ_ClearActivityStats(DSPInst_t *inst) { | ||||||
|  |   memset(&inst->activity_stats, 0, sizeof(ActivityStats)); | ||||||
|  | } | ||||||
|  |  | ||||||
| #ifdef NETEQ_VAD | #ifdef NETEQ_VAD | ||||||
|  |  | ||||||
| /**************************************************************************** | /**************************************************************************** | ||||||
|   | |||||||
| @@ -316,6 +316,9 @@ typedef struct DSPInst_t_ | |||||||
|     /* Internal statistics instance */ |     /* Internal statistics instance */ | ||||||
|     DSPStats_t statInst; |     DSPStats_t statInst; | ||||||
|  |  | ||||||
|  |     /* Internal instance for short-term processing activity. */ | ||||||
|  |     ActivityStats activity_stats; | ||||||
|  |  | ||||||
| #ifdef NETEQ_STEREO | #ifdef NETEQ_STEREO | ||||||
|     /* Pointer to Master/Slave info */ |     /* Pointer to Master/Slave info */ | ||||||
|     MasterSlaveInfo *msInfo; |     MasterSlaveInfo *msInfo; | ||||||
| @@ -398,6 +401,21 @@ int WebRtcNetEQ_ClearInCallStats(DSPInst_t *inst); | |||||||
|  |  | ||||||
| int WebRtcNetEQ_ClearPostCallStats(DSPInst_t *inst); | int WebRtcNetEQ_ClearPostCallStats(DSPInst_t *inst); | ||||||
|  |  | ||||||
|  | /**************************************************************************** | ||||||
|  |  * WebRtcNetEQ_ClearActivityStats(...) | ||||||
|  |  * | ||||||
|  |  * Reset processing activity statistics. | ||||||
|  |  * | ||||||
|  |  * Input: | ||||||
|  |  *    - inst          : NetEQ DSP instance | ||||||
|  |  * | ||||||
|  |  * Output: | ||||||
|  |  *    - inst          : Updated instance | ||||||
|  |  * | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | void WebRtcNetEQ_ClearActivityStats(DSPInst_t *inst); | ||||||
|  |  | ||||||
| /**************************************************************************** | /**************************************************************************** | ||||||
|  * WebRtcNetEQ_RecOutInternal(...) |  * WebRtcNetEQ_RecOutInternal(...) | ||||||
|  * |  * | ||||||
|   | |||||||
| @@ -1141,11 +1141,15 @@ int WebRtcNetEQ_Expand(DSPInst_t *inst, | |||||||
|         { |         { | ||||||
|             /* Only noise expansion */ |             /* Only noise expansion */ | ||||||
|             inst->statInst.expandedNoiseSamples += *pw16_len; |             inst->statInst.expandedNoiseSamples += *pw16_len; | ||||||
|  |             /* Short-term activity statistics. */ | ||||||
|  |             inst->activity_stats.expand_bgn_samples += *pw16_len; | ||||||
|         } |         } | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|             /* Voice expand (note: not necessarily _voiced_) */ |             /* Voice expand (note: not necessarily _voiced_) */ | ||||||
|             inst->statInst.expandedVoiceSamples += *pw16_len; |             inst->statInst.expandedVoiceSamples += *pw16_len; | ||||||
|  |             /* Short-term activity statistics. */ | ||||||
|  |             inst->activity_stats.expand_normal_samples += *pw16_len; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -117,6 +117,46 @@ typedef struct | |||||||
|  */ |  */ | ||||||
| int WebRtcNetEQ_GetNetworkStatistics(void *inst, WebRtcNetEQ_NetworkStatistics *stats); | int WebRtcNetEQ_GetNetworkStatistics(void *inst, WebRtcNetEQ_NetworkStatistics *stats); | ||||||
|  |  | ||||||
|  |  | ||||||
|  | typedef struct { | ||||||
|  |   /* Samples removed from background noise only segments. */ | ||||||
|  |   int accelerate_bgn_samples; | ||||||
|  |  | ||||||
|  |   /* Samples removed from normal audio segments. */ | ||||||
|  |   int accelerate_normal_samples; | ||||||
|  |  | ||||||
|  |   /* Number of samples synthesized during background noise only segments. */ | ||||||
|  |   int expand_bgn_sampels; | ||||||
|  |  | ||||||
|  |   /* Number of samples synthesized during normal audio segments. */ | ||||||
|  |   int expand_normal_samples; | ||||||
|  |  | ||||||
|  |   /* Number of samples synthesized during background noise only segments, | ||||||
|  |    * in preemptive mode. */ | ||||||
|  |   int preemptive_expand_bgn_samples; | ||||||
|  |  | ||||||
|  |   /* Number of samples synthesized during normal audio segments, in preemptive | ||||||
|  |    * mode. */ | ||||||
|  |   int preemptive_expand_normal_samples; | ||||||
|  |  | ||||||
|  |   /* Number of samples synthesized during background noise only segments, | ||||||
|  |    * while merging. */ | ||||||
|  |   int merge_expand_bgn_samples; | ||||||
|  |  | ||||||
|  |   /* Number of samples synthesized during normal audio segments, while | ||||||
|  |    * merging. */ | ||||||
|  |   int merge_expand_normal_samples; | ||||||
|  | } WebRtcNetEQ_ProcessingActivity; | ||||||
|  |  | ||||||
|  | /* | ||||||
|  |  * Get the processing activities from NetEQ. | ||||||
|  |  * The statistics are reset after the query. | ||||||
|  |  * This API is meant to obtain processing activities in high granularity, | ||||||
|  |  * e.g. per RecOut() call. | ||||||
|  |  */ | ||||||
|  | void WebRtcNetEQ_GetProcessingActivity(void* inst, | ||||||
|  |                                        WebRtcNetEQ_ProcessingActivity* stat); | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * Get the raw waiting times for decoded frames. The function writes the last |  * Get the raw waiting times for decoded frames. The function writes the last | ||||||
|  * recorded waiting times (from frame arrival to frame decoding) to the memory |  * recorded waiting times (from frame arrival to frame decoding) to the memory | ||||||
|   | |||||||
| @@ -535,11 +535,17 @@ int WebRtcNetEQ_Merge(DSPInst_t *inst, | |||||||
|     { |     { | ||||||
|         /* expansion generates noise only */ |         /* expansion generates noise only */ | ||||||
|         inst->statInst.expandedNoiseSamples += (*pw16_len - w16_decodedLen); |         inst->statInst.expandedNoiseSamples += (*pw16_len - w16_decodedLen); | ||||||
|  |         /* Short-term activity statistics. */ | ||||||
|  |        inst->activity_stats.merge_expand_bgn_samples += | ||||||
|  |             (*pw16_len - w16_decodedLen); | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
|     { |     { | ||||||
|         /* expansion generates more than only noise */ |         /* expansion generates more than only noise */ | ||||||
|         inst->statInst.expandedVoiceSamples += (*pw16_len - w16_decodedLen); |         inst->statInst.expandedVoiceSamples += (*pw16_len - w16_decodedLen); | ||||||
|  |         /* Short-term activity statistics. */ | ||||||
|  |         inst->activity_stats.merge_expand_normal_samples += | ||||||
|  |             (*pw16_len - w16_decodedLen); | ||||||
|     } |     } | ||||||
|     inst->statInst.expandLength += (*pw16_len - w16_decodedLen); |     inst->statInst.expandLength += (*pw16_len - w16_decodedLen); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -37,5 +37,20 @@ typedef struct | |||||||
|  |  | ||||||
| } DSPStats_t; | } DSPStats_t; | ||||||
|  |  | ||||||
|  | typedef struct { | ||||||
|  |   int preemptive_expand_bgn_samples; | ||||||
|  |   int preemptive_expand_normal_samples; | ||||||
|  |  | ||||||
|  |   int expand_bgn_samples; | ||||||
|  |   int expand_normal_samples; | ||||||
|  |  | ||||||
|  |   int merge_expand_bgn_samples; | ||||||
|  |   int merge_expand_normal_samples; | ||||||
|  |  | ||||||
|  |   int accelerate_bgn_samples; | ||||||
|  |   int accelarate_normal_samples; | ||||||
|  | } ActivityStats; | ||||||
|  |  | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|   | |||||||
| @@ -181,6 +181,8 @@ int WebRtcNetEQ_PreEmptiveExpand(DSPInst_t *inst, | |||||||
|  |  | ||||||
|         /* update statistics */ |         /* update statistics */ | ||||||
|         inst->statInst.preemptiveLength += w16_bestIndex; |         inst->statInst.preemptiveLength += w16_bestIndex; | ||||||
|  |         /* Short-term activity statistics. */ | ||||||
|  |         inst->activity_stats.preemptive_expand_bgn_samples += w16_bestIndex; | ||||||
|  |  | ||||||
|         return 0; |         return 0; | ||||||
|     } /* end of special code for BGN mode */ |     } /* end of special code for BGN mode */ | ||||||
| @@ -489,7 +491,8 @@ int WebRtcNetEQ_PreEmptiveExpand(DSPInst_t *inst, | |||||||
|  |  | ||||||
|         /* Update in-call statistics */ |         /* Update in-call statistics */ | ||||||
|         inst->statInst.preemptiveLength += w16_bestIndex; |         inst->statInst.preemptiveLength += w16_bestIndex; | ||||||
|  |         /* Short-term activity statistics. */ | ||||||
|  |         inst->activity_stats.preemptive_expand_normal_samples += w16_bestIndex; | ||||||
|         return 0; |         return 0; | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
|   | |||||||
| @@ -1644,3 +1644,30 @@ int WebRtcNetEQ_SetVADMode(void *inst, int mode) | |||||||
| #endif /* NETEQ_VAD */ | #endif /* NETEQ_VAD */ | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void WebRtcNetEQ_GetProcessingActivity(void *inst, | ||||||
|  |                                        WebRtcNetEQ_ProcessingActivity *stats) { | ||||||
|  |   MainInst_t *NetEqMainInst = (MainInst_t*) inst; | ||||||
|  |  | ||||||
|  |   stats->accelerate_bgn_samples = | ||||||
|  |       NetEqMainInst->DSPinst.activity_stats.accelerate_bgn_samples; | ||||||
|  |   stats->accelerate_normal_samples = | ||||||
|  |       NetEqMainInst->DSPinst.activity_stats.accelarate_normal_samples; | ||||||
|  |  | ||||||
|  |   stats->expand_bgn_sampels = | ||||||
|  |       NetEqMainInst->DSPinst.activity_stats.expand_bgn_samples; | ||||||
|  |   stats->expand_normal_samples = | ||||||
|  |       NetEqMainInst->DSPinst.activity_stats.expand_normal_samples; | ||||||
|  |  | ||||||
|  |   stats->preemptive_expand_bgn_samples = | ||||||
|  |       NetEqMainInst->DSPinst.activity_stats.preemptive_expand_bgn_samples; | ||||||
|  |   stats->preemptive_expand_normal_samples = | ||||||
|  |       NetEqMainInst->DSPinst.activity_stats.preemptive_expand_normal_samples; | ||||||
|  |  | ||||||
|  |   stats->merge_expand_bgn_samples = | ||||||
|  |       NetEqMainInst->DSPinst.activity_stats.merge_expand_bgn_samples; | ||||||
|  |   stats->merge_expand_normal_samples = | ||||||
|  |       NetEqMainInst->DSPinst.activity_stats.merge_expand_normal_samples; | ||||||
|  |  | ||||||
|  |   WebRtcNetEQ_ClearActivityStats(&NetEqMainInst->DSPinst); | ||||||
|  | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 turaj@webrtc.org
					turaj@webrtc.org