# HG changeset patch # User michael # Date 1071366120 0 # Node ID 04b759af8bd4d0d778a34436818692f391319823 # Parent cdc3d4106fb636ab316b173d3c116f1761765ae7 error concealment regression test diff -r cdc3d4106fb6 -r 04b759af8bd4 avcodec.h --- a/avcodec.h Sat Dec 13 20:41:33 2003 +0000 +++ b/avcodec.h Sun Dec 14 01:42:00 2003 +0000 @@ -17,7 +17,7 @@ #define FFMPEG_VERSION_INT 0x000408 #define FFMPEG_VERSION "0.4.8" -#define LIBAVCODEC_BUILD 4695 +#define LIBAVCODEC_BUILD 4696 #define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT #define LIBAVCODEC_VERSION FFMPEG_VERSION @@ -1461,6 +1461,13 @@ * - decoding: set by user. */ int flags2; + + /** + * simulates errors in the bitstream to test error concealment. + * - encoding: set by user. + * - decoding: unused. + */ + int error_rate; } AVCodecContext; diff -r cdc3d4106fb6 -r 04b759af8bd4 mpegvideo.c --- a/mpegvideo.c Sat Dec 13 20:41:33 2003 +0000 +++ b/mpegvideo.c Sun Dec 14 01:42:00 2003 +0000 @@ -4002,6 +4002,18 @@ assert((get_bit_count(&s->pb)&7) == 0); current_packet_size= pbBufPtr(&s->pb) - s->ptr_lastgob; + + if(s->avctx->error_rate && s->resync_mb_x + s->resync_mb_y > 0){ + int r= get_bit_count(&s->pb)/8 + s->picture_number + s->codec_id + s->mb_x + s->mb_y; + int d= 100 / s->avctx->error_rate; + if(r % d == 0){ + current_packet_size=0; +#ifndef ALT_BITSTREAM_WRITER + s->pb.buf_ptr= s->ptr_lastgob; +#endif + assert(pbBufPtr(&s->pb) == s->ptr_lastgob); + } + } if (s->avctx->rtp_callback) s->avctx->rtp_callback(s->ptr_lastgob, current_packet_size, 0);