summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMåns Rullgård <mans@mansr.com>2006-01-20 21:20:46 +0000
committerMåns Rullgård <mans@mansr.com>2006-01-20 21:20:46 +0000
commit806011f2adb1143ca3f6db89fe6eae8fa9fb72f1 (patch)
tree7ff204d0bef19bafc50e76e8ae8feedf52f954f4
parent8228bff5c6394e5aba24c63ab9d72bf96f8047de (diff)
place SPS/PPS in extradata if GLOBAL_HEADER flag is set
Originally committed as revision 4872 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavcodec/x264.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/libavcodec/x264.c b/libavcodec/x264.c
index 68f1638569..31fe5cc65b 100644
--- a/libavcodec/x264.c
+++ b/libavcodec/x264.c
@@ -247,12 +247,30 @@ X264_init(AVCodecContext *avctx)
x4->params.i_threads = avctx->thread_count;
+ if(avctx->flags & CODEC_FLAG_GLOBAL_HEADER){
+ x4->params.b_repeat_headers = 0;
+ }
+
x4->enc = x264_encoder_open(&x4->params);
if(!x4->enc)
return -1;
avctx->coded_frame = &x4->out_pic;
+ if(avctx->flags & CODEC_FLAG_GLOBAL_HEADER){
+ x264_nal_t *nal;
+ int nnal, i, s = 0;
+
+ x264_encoder_headers(x4->enc, &nal, &nnal);
+
+ /* 5 bytes NAL header + worst case escaping */
+ for(i = 0; i < nnal; i++)
+ s += 5 + nal[i].i_payload * 4 / 3;
+
+ avctx->extradata = av_malloc(s);
+ avctx->extradata_size = encode_nals(avctx->extradata, s, nal, nnal);
+ }
+
return 0;
}