aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mpegvideo.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2006-02-04 20:32:02 +0000
committerMichael Niedermayer <michaelni@gmx.at>2006-02-04 20:32:02 +0000
commit82fcbc145dde97c92ed7f951c9103c49a71b2b90 (patch)
tree6e2d6bb241b5dd46bce3140b0fec33eb311545e6 /libavcodec/mpegvideo.c
parent8f0df75438d7d3e5dfcd4247c480ef3e3819e6b4 (diff)
downloadffmpeg-82fcbc145dde97c92ed7f951c9103c49a71b2b90.tar.gz
faster find_startcode()
Originally committed as revision 4939 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/mpegvideo.c')
-rw-r--r--libavcodec/mpegvideo.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 31497852bb..8e2799bcad 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -228,6 +228,34 @@ void ff_write_quant_matrix(PutBitContext *pb, int16_t *matrix){
}
#endif //CONFIG_ENCODERS
+const uint8_t *ff_find_start_code(const uint8_t * restrict p, const uint8_t *end, uint32_t * restrict state){
+ int i;
+
+ for(i=0; i<3; i++){
+ uint32_t tmp= *state << 8;
+ *state= tmp + *(p++);
+ if(tmp == 0x100 || p==end)
+ return p;
+ }
+ p--; // need to recheck or might miss one
+ end--; // we need the byte after 00 00 01 too
+
+ while(p<end){
+ if (p[ 0] > 1) p+= 3;
+ else if(p[-1] ) p+= 2;
+ else if(p[-2]|(p[0]-1)) p++;
+ else{
+ p++;
+ break;
+ }
+ }
+
+ p= FFMIN(p, end)-3;
+ *state= be2me_32(unaligned32(p));
+
+ return p+4;
+}
+
/* init common dct for both encoder and decoder */
int DCT_common_init(MpegEncContext *s)
{