From f86057e18db512f857b44971ce0073ae762918ef Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sun, 21 Aug 2005 12:37:25 +0000 Subject: [PATCH] Fixed AVC extraction. Patch by Mike Matsnev . --- src/extract/xtr_avc.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/extract/xtr_avc.cpp b/src/extract/xtr_avc.cpp index 7f490ffcf..f7f735ee6 100644 --- a/src/extract/xtr_avc.cpp +++ b/src/extract/xtr_avc.cpp @@ -55,14 +55,24 @@ xtr_avc_c::create_file(xtr_base_c *_master, mxerror("Track %lld with the CodecID '%s' is missing the \"codec private" "\" element and cannot be extracted.\n", tid, codec_id.c_str()); + if (priv->GetSize() < 6) + mxerror("Track %lld CodecPrivate is too small.\n", tid); + binary *buf = priv->GetBuffer(); nal_size_size = 1 + (buf[4] & 3); - int pos = 6; - while (priv->GetSize() > pos) { + int i, pos = 6, numsps = buf[5] & 0x1f, numpps; + + for (i = 0; (i < numsps) && (priv->GetSize() > pos); ++i) + write_nal(buf, pos, priv->GetSize(), 2); + + if (priv->GetSize() <= pos) + return; + + numpps = buf[pos++]; + + for (i = 0; (i < numpps) && (priv->GetSize() > pos); ++i) write_nal(buf, pos, priv->GetSize(), 2); - ++pos; - } } void