]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/h261_parser.c
Use MAP_FAILED to check for mmap failure instead of manually
[ffmpeg] / libavcodec / h261_parser.c
index 3671cdbf7239316288d1a347b52e0505e2621066..3fb86db1255c30ec95b283fbae9391f8da351465 100644 (file)
@@ -21,7 +21,7 @@
  */
 
 /**
- * @file h261_parser.c
+ * @file
  * h261codec.
  */
 
@@ -38,7 +38,7 @@ static int h261_find_frame_end(ParseContext *pc, AVCodecContext* avctx, const ui
     for(i=0; i<buf_size && !vop_found; i++){
         state= (state<<8) | buf[i];
         for(j=0; j<8; j++){
-            if(((state>>j)&0xFFFFF) == 0x00010){
+            if(((state>>j)&0xFFFFF0) == 0x000100){
                 vop_found=1;
                 break;
             }
@@ -48,10 +48,10 @@ static int h261_find_frame_end(ParseContext *pc, AVCodecContext* avctx, const ui
         for(; i<buf_size; i++){
             state= (state<<8) | buf[i];
             for(j=0; j<8; j++){
-                if(((state>>j)&0xFFFFF) == 0x00010){
+                if(((state>>j)&0xFFFFF0) == 0x000100){
                     pc->frame_start_found=0;
-                    pc->state= state>>(2*8);
-                    return i-1;
+                    pc->state= (state>>(3*8))+0xFF00;
+                    return i-2;
                 }
             }
         }
@@ -70,18 +70,22 @@ static int h261_parse(AVCodecParserContext *s,
     ParseContext *pc = s->priv_data;
     int next;
 
-    next= h261_find_frame_end(pc,avctx, buf, buf_size);
-    if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
-        *poutbuf = NULL;
-        *poutbuf_size = 0;
-        return buf_size;
+    if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) {
+        next = buf_size;
+    } else {
+        next= h261_find_frame_end(pc,avctx, buf, buf_size);
+        if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
+            *poutbuf = NULL;
+            *poutbuf_size = 0;
+            return buf_size;
+        }
     }
     *poutbuf = buf;
     *poutbuf_size = buf_size;
     return next;
 }
 
-AVCodecParser h261_parser = {
+AVCodecParser ff_h261_parser = {
     { CODEC_ID_H261 },
     sizeof(ParseContext),
     NULL,