summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2005-06-28 08:13:23 +0000
committerMichael Niedermayer <michaelni@gmx.at>2005-06-28 08:13:23 +0000
commit3f46995ca577a3e122c43eaf2c7305cd20444be0 (patch)
tree28fe8a20b38ec0220802e5f53fd08c05cbbe3075
parente679cd1ab0c45e2d31454b799f3e7c1b3aebbd02 (diff)
support extracting sps/pps from bitstream and putting it in extradata
Originally committed as revision 4403 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavcodec/h264.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 395ae1c503..bb3c876c98 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -7133,6 +7133,13 @@ static int find_frame_end(H264Context *h, const uint8_t *buf, int buf_size){
}
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 @@ static int h264_parse(AVCodecParserContext *s,
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 @@ AVCodecParser h264_parser = {
NULL,
h264_parse,
ff_parse_close,
+ h264_split,
};
#include "svq3.c"