changeset 2774:3eddfe241bb9 libavcodec

support extracting sps/pps from bitstream and putting it in extradata
author michael
date Tue, 28 Jun 2005 08:13:23 +0000
parents 1d1b328d07ce
children f3cdd51c9e16
files h264.c
diffstat 1 files changed, 33 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/h264.c	Tue Jun 28 06:45:41 2005 +0000
+++ b/h264.c	Tue Jun 28 08:13:23 2005 +0000
@@ -7133,6 +7133,13 @@
             }
             pc->frame_start_found = 1;
         }
+        if((state&0xFFFFFF1F) == 0x107 || (state&0xFFFFFF1F) == 0x108 || (state&0xFFFFFF1F) == 0x109){
+           if(pc->frame_start_found){
+                pc->state=-1; 
+                pc->frame_start_found= 0;
+                return i-4;               
+           }
+        }
         if (i<buf_size)
             state= (state<<8) | buf[i];
     }
@@ -7163,6 +7170,31 @@
     return next;
 }
 
+static int h264_split(AVCodecContext *avctx,
+                      const uint8_t *buf, int buf_size)
+{
+    int i;
+    uint32_t state = -1;
+    int has_sps= 0;
+
+    for(i=0; i<=buf_size; i++){
+        if((state&0xFFFFFF1F) == 0x107)
+            has_sps=1;
+/*        if((state&0xFFFFFF1F) == 0x101 || (state&0xFFFFFF1F) == 0x102 || (state&0xFFFFFF1F) == 0x105){
+        }*/
+        if((state&0xFFFFFF00) == 0x100 && (state&0xFFFFFF1F) != 0x107 && (state&0xFFFFFF1F) != 0x108 && (state&0xFFFFFF1F) != 0x109){
+            if(has_sps){
+                while(i>4 && buf[i-5]==0) i--;
+                return i-4;
+            }
+        }
+        if (i<buf_size)
+            state= (state<<8) | buf[i];
+    }
+    return 0;
+}
+
+
 static int decode_nal_units(H264Context *h, uint8_t *buf, int buf_size){
     MpegEncContext * const s = &h->s;
     AVCodecContext * const avctx= s->avctx;
@@ -7709,6 +7741,7 @@
     NULL,
     h264_parse,
     ff_parse_close,
+    h264_split,
 };
 
 #include "svq3.c"