From: <bc...@us...> - 2010-01-28 22:10:38
|
Revision: 1457 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1457&view=rev Author: bcholew Date: 2010-01-28 22:10:28 +0000 (Thu, 28 Jan 2010) Log Message: ----------- Fix for the 'dropped_frames' video statistics bucket (in struct iaxc_video_stats). Previously, this bucket wasn't being incremented. [Not tested for ffmpeg] Modified Paths: -------------- trunk/lib/codec_ffmpeg.c trunk/lib/codec_theora.c trunk/lib/iaxclient_lib.h trunk/lib/slice.c trunk/lib/slice.h trunk/lib/video.c Modified: trunk/lib/codec_ffmpeg.c =================================================================== --- trunk/lib/codec_ffmpeg.c 2010-01-28 21:48:15 UTC (rev 1456) +++ trunk/lib/codec_ffmpeg.c 2010-01-28 22:10:28 UTC (rev 1457) @@ -209,7 +209,7 @@ } static int decode_iaxc_slice(struct iaxc_video_codec * c, int inlen, - char * in, int * outlen, char * out) + char * in, int * outlen, char * out, int * frames_dropped) { struct decoder_ctx *d = (struct decoder_ctx *) c->decstate; struct slice_header_t * sh_saved = &d->slice_header; @@ -217,10 +217,15 @@ char * inp; int ret; + *frames_dropped = 0; + inp = parse_slice_header(in, &sh_this); if ( !inp ) + { + *frames_dropped = 1; return -1; + } inlen -= inp - in; @@ -237,6 +242,8 @@ } else if ( frame_delta > 0 ) { + *frames_dropped = frame_delta - 1; + /* This slice belongs to a future frame */ if ( sh_saved->slice_index > 0 ) { @@ -254,7 +261,10 @@ reset_decoder_frame_state(d); if ( ret ) + { + *frames_dropped += 1; return -1; + } } sh_saved->frame_index = sh_this.frame_index; @@ -272,6 +282,7 @@ { fprintf(stderr, "codec_ffmpeg: decode: slice overflows decoder frame buffer\n"); + *frames_dropped = 1; return -1; } @@ -294,7 +305,10 @@ reset_decoder_frame_state(d); if ( ret ) + { + *frames_dropped = 1; return -1; + } return 0; } Modified: trunk/lib/codec_theora.c =================================================================== --- trunk/lib/codec_theora.c 2010-01-28 21:48:15 UTC (rev 1456) +++ trunk/lib/codec_theora.c 2010-01-28 22:10:28 UTC (rev 1457) @@ -112,7 +112,7 @@ } static int decode(struct iaxc_video_codec *c, int inlen, const char *in, - int *outlen, char *out) + int *outlen, char *out, int * frames_dropped) { struct theora_decoder *d; ogg_packet op; @@ -123,6 +123,8 @@ int flen; char *frame; + *frames_dropped = 0; + // Sanity checks if ( !c || !c->decstate || !in || inlen <= 0 || !out || !outlen ) return -1; @@ -132,7 +134,7 @@ if ( !d->dsc ) return -1; - frame = deslice(in, inlen, &flen, d->dsc); + frame = deslice(in, inlen, &flen, d->dsc, frames_dropped); if ( frame == NULL ) return 1; Modified: trunk/lib/iaxclient_lib.h =================================================================== --- trunk/lib/iaxclient_lib.h 2010-01-28 21:48:15 UTC (rev 1456) +++ trunk/lib/iaxclient_lib.h 2010-01-28 22:10:28 UTC (rev 1457) @@ -196,7 +196,8 @@ int (*encode)(struct iaxc_video_codec * codec, int inlen, const char * in, struct slice_set_t * out); int (*decode)(struct iaxc_video_codec * codec, int inlen, - const char * in, int * outlen, char * out); + const char * in, int * outlen, char * out, + int * frames_dropped); void (*destroy)(struct iaxc_video_codec * codec); }; Modified: trunk/lib/slice.c =================================================================== --- trunk/lib/slice.c 2010-01-28 21:48:15 UTC (rev 1456) +++ trunk/lib/slice.c 2010-01-28 22:10:28 UTC (rev 1457) @@ -94,11 +94,13 @@ } char * -deslice(const char *in, int inlen, int *outlen, struct deslicer_context *dsc) +deslice(const char *in, int inlen, int *outlen, struct deslicer_context *dsc, int *frames_dropped) { unsigned char frame_index, slice_index, num_slices, version; unsigned short source_id; + *frames_dropped = 0; + // Sanity checks if ( dsc == NULL || in == NULL || inlen <= 0 || outlen == NULL ) return NULL; @@ -143,6 +145,7 @@ { /* Current frame is incomplete, drop it */ reset_deslicer_context(dsc); + *frames_dropped += frame_delta; } } } else @@ -159,6 +162,7 @@ if ( dsc->slice_size * slice_index + inlen > MAX_ENCODED_FRAME_SIZE ) { // Frame would be too large, ignore slice + *frames_dropped = 1; return NULL; } Modified: trunk/lib/slice.h =================================================================== --- trunk/lib/slice.h 2010-01-28 21:48:15 UTC (rev 1456) +++ trunk/lib/slice.h 2010-01-28 22:10:28 UTC (rev 1457) @@ -104,6 +104,7 @@ * outlen with the frame size if successful */ char * -deslice(const char *in, int inlen, int *outlen, struct deslicer_context *dsc); +deslice(const char *in, int inlen, int *outlen, struct deslicer_context *dsc, + int * frames_dropped); #endif Modified: trunk/lib/video.c =================================================================== --- trunk/lib/video.c 2010-01-28 21:48:15 UTC (rev 1456) +++ trunk/lib/video.c 2010-01-28 22:10:28 UTC (rev 1457) @@ -1259,6 +1259,7 @@ int ret; struct timeval now; long time; + int frames_dropped; if ( !call ) return 0; @@ -1315,8 +1316,10 @@ call->vdecoder->video_stats.acc_recv_size * 8000 / time; ret = call->vdecoder->decode(call->vdecoder, encoded_video_len, - (char *)encoded_video, &out_size, yuv_buf); + (char *)encoded_video, &out_size, yuv_buf, &frames_dropped); + call->vdecoder->video_stats.dropped_frames += (unsigned long) frames_dropped; + if ( ret < 0 ) { fprintf(stderr, "ERROR: decode error\n"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |