Removing unused third-party libraries.
We use libwebm instead of libmkv and nestegg. Change-Id: I339eae081061c2e3eb8b234f14ae1bc846f85011
This commit is contained in:
parent
b59b324171
commit
0907cb6b4c
52
third_party/libmkv/EbmlBufferWriter.c
vendored
52
third_party/libmkv/EbmlBufferWriter.c
vendored
@ -1,52 +0,0 @@
|
||||
// #include <strmif.h>
|
||||
#include "EbmlBufferWriter.h"
|
||||
#include "EbmlWriter.h"
|
||||
// #include <cassert>
|
||||
// #include <limits>
|
||||
// #include <malloc.h> //_alloca
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include <string.h>
|
||||
|
||||
void Ebml_Write(EbmlGlobal *glob, const void *buffer_in, unsigned long len) {
|
||||
unsigned char *src = glob->buf;
|
||||
src += glob->offset;
|
||||
memcpy(src, buffer_in, len);
|
||||
glob->offset += len;
|
||||
}
|
||||
|
||||
static void _Serialize(EbmlGlobal *glob, const unsigned char *p, const unsigned char *q) {
|
||||
while (q != p) {
|
||||
--q;
|
||||
memcpy(&(glob->buf[glob->offset]), q, 1);
|
||||
glob->offset++;
|
||||
}
|
||||
}
|
||||
|
||||
void Ebml_Serialize(EbmlGlobal *glob, const void *buffer_in, unsigned long len) {
|
||||
// assert(buf);
|
||||
|
||||
const unsigned char *const p = (const unsigned char *)(buffer_in);
|
||||
const unsigned char *const q = p + len;
|
||||
|
||||
_Serialize(glob, p, q);
|
||||
}
|
||||
|
||||
|
||||
void Ebml_StartSubElement(EbmlGlobal *glob, EbmlLoc *ebmlLoc, unsigned long class_id) {
|
||||
Ebml_WriteID(glob, class_id);
|
||||
ebmlLoc->offset = glob->offset;
|
||||
// todo this is always taking 8 bytes, this may need later optimization
|
||||
unsigned long long unknownLen = 0x01FFFFFFFFFFFFFFLLU;
|
||||
Ebml_Serialize(glob, (void *)&unknownLen, 8); // this is a key that says lenght unknown
|
||||
}
|
||||
|
||||
void Ebml_EndSubElement(EbmlGlobal *glob, EbmlLoc *ebmlLoc) {
|
||||
unsigned long long size = glob->offset - ebmlLoc->offset - 8;
|
||||
unsigned long long curOffset = glob->offset;
|
||||
glob->offset = ebmlLoc->offset;
|
||||
size |= 0x0100000000000000LLU;
|
||||
Ebml_Serialize(glob, &size, 8);
|
||||
glob->offset = curOffset;
|
||||
}
|
||||
|
19
third_party/libmkv/EbmlBufferWriter.h
vendored
19
third_party/libmkv/EbmlBufferWriter.h
vendored
@ -1,19 +0,0 @@
|
||||
#ifndef EBMLBUFFERWRITER_HPP
|
||||
#define EBMLBUFFERWRITER_HPP
|
||||
|
||||
typedef struct {
|
||||
unsigned long long offset;
|
||||
} EbmlLoc;
|
||||
|
||||
typedef struct {
|
||||
unsigned char *buf;
|
||||
unsigned int length;
|
||||
unsigned int offset;
|
||||
} EbmlGlobal;
|
||||
|
||||
|
||||
void Ebml_StartSubElement(EbmlGlobal *glob, EbmlLoc *ebmlLoc, unsigned long class_id);
|
||||
void Ebml_EndSubElement(EbmlGlobal *glob, EbmlLoc *ebmlLoc);
|
||||
|
||||
|
||||
#endif
|
231
third_party/libmkv/EbmlIDs.h
vendored
231
third_party/libmkv/EbmlIDs.h
vendored
@ -1,231 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#ifndef MKV_DEFS_HPP
|
||||
#define MKV_DEFS_HPP 1
|
||||
|
||||
/* Commenting out values not available in webm, but available in matroska */
|
||||
|
||||
enum mkv {
|
||||
EBML = 0x1A45DFA3,
|
||||
EBMLVersion = 0x4286,
|
||||
EBMLReadVersion = 0x42F7,
|
||||
EBMLMaxIDLength = 0x42F2,
|
||||
EBMLMaxSizeLength = 0x42F3,
|
||||
DocType = 0x4282,
|
||||
DocTypeVersion = 0x4287,
|
||||
DocTypeReadVersion = 0x4285,
|
||||
/* CRC_32 = 0xBF, */
|
||||
Void = 0xEC,
|
||||
SignatureSlot = 0x1B538667,
|
||||
SignatureAlgo = 0x7E8A,
|
||||
SignatureHash = 0x7E9A,
|
||||
SignaturePublicKey = 0x7EA5,
|
||||
Signature = 0x7EB5,
|
||||
SignatureElements = 0x7E5B,
|
||||
SignatureElementList = 0x7E7B,
|
||||
SignedElement = 0x6532,
|
||||
/* segment */
|
||||
Segment = 0x18538067,
|
||||
/* Meta Seek Information */
|
||||
SeekHead = 0x114D9B74,
|
||||
Seek = 0x4DBB,
|
||||
SeekID = 0x53AB,
|
||||
SeekPosition = 0x53AC,
|
||||
/* Segment Information */
|
||||
Info = 0x1549A966,
|
||||
/* SegmentUID = 0x73A4, */
|
||||
/* SegmentFilename = 0x7384, */
|
||||
/* PrevUID = 0x3CB923, */
|
||||
/* PrevFilename = 0x3C83AB, */
|
||||
/* NextUID = 0x3EB923, */
|
||||
/* NextFilename = 0x3E83BB, */
|
||||
/* SegmentFamily = 0x4444, */
|
||||
/* ChapterTranslate = 0x6924, */
|
||||
/* ChapterTranslateEditionUID = 0x69FC, */
|
||||
/* ChapterTranslateCodec = 0x69BF, */
|
||||
/* ChapterTranslateID = 0x69A5, */
|
||||
TimecodeScale = 0x2AD7B1,
|
||||
Segment_Duration = 0x4489,
|
||||
DateUTC = 0x4461,
|
||||
/* Title = 0x7BA9, */
|
||||
MuxingApp = 0x4D80,
|
||||
WritingApp = 0x5741,
|
||||
/* Cluster */
|
||||
Cluster = 0x1F43B675,
|
||||
Timecode = 0xE7,
|
||||
/* SilentTracks = 0x5854, */
|
||||
/* SilentTrackNumber = 0x58D7, */
|
||||
/* Position = 0xA7, */
|
||||
PrevSize = 0xAB,
|
||||
BlockGroup = 0xA0,
|
||||
Block = 0xA1,
|
||||
/* BlockVirtual = 0xA2, */
|
||||
BlockAdditions = 0x75A1,
|
||||
BlockMore = 0xA6,
|
||||
BlockAddID = 0xEE,
|
||||
BlockAdditional = 0xA5,
|
||||
BlockDuration = 0x9B,
|
||||
/* ReferencePriority = 0xFA, */
|
||||
ReferenceBlock = 0xFB,
|
||||
/* ReferenceVirtual = 0xFD, */
|
||||
/* CodecState = 0xA4, */
|
||||
/* Slices = 0x8E, */
|
||||
/* TimeSlice = 0xE8, */
|
||||
LaceNumber = 0xCC,
|
||||
/* FrameNumber = 0xCD, */
|
||||
/* BlockAdditionID = 0xCB, */
|
||||
/* MkvDelay = 0xCE, */
|
||||
/* Cluster_Duration = 0xCF, */
|
||||
SimpleBlock = 0xA3,
|
||||
/* EncryptedBlock = 0xAF, */
|
||||
/* Track */
|
||||
Tracks = 0x1654AE6B,
|
||||
TrackEntry = 0xAE,
|
||||
TrackNumber = 0xD7,
|
||||
TrackUID = 0x73C5,
|
||||
TrackType = 0x83,
|
||||
FlagEnabled = 0xB9,
|
||||
FlagDefault = 0x88,
|
||||
FlagForced = 0x55AA,
|
||||
FlagLacing = 0x9C,
|
||||
/* MinCache = 0x6DE7, */
|
||||
/* MaxCache = 0x6DF8, */
|
||||
DefaultDuration = 0x23E383,
|
||||
/* TrackTimecodeScale = 0x23314F, */
|
||||
/* TrackOffset = 0x537F, */
|
||||
MaxBlockAdditionID = 0x55EE,
|
||||
Name = 0x536E,
|
||||
Language = 0x22B59C,
|
||||
CodecID = 0x86,
|
||||
CodecPrivate = 0x63A2,
|
||||
CodecName = 0x258688,
|
||||
/* AttachmentLink = 0x7446, */
|
||||
/* CodecSettings = 0x3A9697, */
|
||||
/* CodecInfoURL = 0x3B4040, */
|
||||
/* CodecDownloadURL = 0x26B240, */
|
||||
/* CodecDecodeAll = 0xAA, */
|
||||
/* TrackOverlay = 0x6FAB, */
|
||||
/* TrackTranslate = 0x6624, */
|
||||
/* TrackTranslateEditionUID = 0x66FC, */
|
||||
/* TrackTranslateCodec = 0x66BF, */
|
||||
/* TrackTranslateTrackID = 0x66A5, */
|
||||
/* video */
|
||||
Video = 0xE0,
|
||||
FlagInterlaced = 0x9A,
|
||||
StereoMode = 0x53B8,
|
||||
AlphaMode = 0x53C0,
|
||||
PixelWidth = 0xB0,
|
||||
PixelHeight = 0xBA,
|
||||
PixelCropBottom = 0x54AA,
|
||||
PixelCropTop = 0x54BB,
|
||||
PixelCropLeft = 0x54CC,
|
||||
PixelCropRight = 0x54DD,
|
||||
DisplayWidth = 0x54B0,
|
||||
DisplayHeight = 0x54BA,
|
||||
DisplayUnit = 0x54B2,
|
||||
AspectRatioType = 0x54B3,
|
||||
/* ColourSpace = 0x2EB524, */
|
||||
/* GammaValue = 0x2FB523, */
|
||||
FrameRate = 0x2383E3,
|
||||
/* end video */
|
||||
/* audio */
|
||||
Audio = 0xE1,
|
||||
SamplingFrequency = 0xB5,
|
||||
OutputSamplingFrequency = 0x78B5,
|
||||
Channels = 0x9F,
|
||||
/* ChannelPositions = 0x7D7B, */
|
||||
BitDepth = 0x6264,
|
||||
/* end audio */
|
||||
/* content encoding */
|
||||
/* ContentEncodings = 0x6d80, */
|
||||
/* ContentEncoding = 0x6240, */
|
||||
/* ContentEncodingOrder = 0x5031, */
|
||||
/* ContentEncodingScope = 0x5032, */
|
||||
/* ContentEncodingType = 0x5033, */
|
||||
/* ContentCompression = 0x5034, */
|
||||
/* ContentCompAlgo = 0x4254, */
|
||||
/* ContentCompSettings = 0x4255, */
|
||||
/* ContentEncryption = 0x5035, */
|
||||
/* ContentEncAlgo = 0x47e1, */
|
||||
/* ContentEncKeyID = 0x47e2, */
|
||||
/* ContentSignature = 0x47e3, */
|
||||
/* ContentSigKeyID = 0x47e4, */
|
||||
/* ContentSigAlgo = 0x47e5, */
|
||||
/* ContentSigHashAlgo = 0x47e6, */
|
||||
/* end content encoding */
|
||||
/* Cueing Data */
|
||||
Cues = 0x1C53BB6B,
|
||||
CuePoint = 0xBB,
|
||||
CueTime = 0xB3,
|
||||
CueTrackPositions = 0xB7,
|
||||
CueTrack = 0xF7,
|
||||
CueClusterPosition = 0xF1,
|
||||
CueBlockNumber = 0x5378
|
||||
/* CueCodecState = 0xEA, */
|
||||
/* CueReference = 0xDB, */
|
||||
/* CueRefTime = 0x96, */
|
||||
/* CueRefCluster = 0x97, */
|
||||
/* CueRefNumber = 0x535F, */
|
||||
/* CueRefCodecState = 0xEB, */
|
||||
/* Attachment */
|
||||
/* Attachments = 0x1941A469, */
|
||||
/* AttachedFile = 0x61A7, */
|
||||
/* FileDescription = 0x467E, */
|
||||
/* FileName = 0x466E, */
|
||||
/* FileMimeType = 0x4660, */
|
||||
/* FileData = 0x465C, */
|
||||
/* FileUID = 0x46AE, */
|
||||
/* FileReferral = 0x4675, */
|
||||
/* Chapters */
|
||||
/* Chapters = 0x1043A770, */
|
||||
/* EditionEntry = 0x45B9, */
|
||||
/* EditionUID = 0x45BC, */
|
||||
/* EditionFlagHidden = 0x45BD, */
|
||||
/* EditionFlagDefault = 0x45DB, */
|
||||
/* EditionFlagOrdered = 0x45DD, */
|
||||
/* ChapterAtom = 0xB6, */
|
||||
/* ChapterUID = 0x73C4, */
|
||||
/* ChapterTimeStart = 0x91, */
|
||||
/* ChapterTimeEnd = 0x92, */
|
||||
/* ChapterFlagHidden = 0x98, */
|
||||
/* ChapterFlagEnabled = 0x4598, */
|
||||
/* ChapterSegmentUID = 0x6E67, */
|
||||
/* ChapterSegmentEditionUID = 0x6EBC, */
|
||||
/* ChapterPhysicalEquiv = 0x63C3, */
|
||||
/* ChapterTrack = 0x8F, */
|
||||
/* ChapterTrackNumber = 0x89, */
|
||||
/* ChapterDisplay = 0x80, */
|
||||
/* ChapString = 0x85, */
|
||||
/* ChapLanguage = 0x437C, */
|
||||
/* ChapCountry = 0x437E, */
|
||||
/* ChapProcess = 0x6944, */
|
||||
/* ChapProcessCodecID = 0x6955, */
|
||||
/* ChapProcessPrivate = 0x450D, */
|
||||
/* ChapProcessCommand = 0x6911, */
|
||||
/* ChapProcessTime = 0x6922, */
|
||||
/* ChapProcessData = 0x6933, */
|
||||
/* Tagging */
|
||||
/* Tags = 0x1254C367, */
|
||||
/* Tag = 0x7373, */
|
||||
/* Targets = 0x63C0, */
|
||||
/* TargetTypeValue = 0x68CA, */
|
||||
/* TargetType = 0x63CA, */
|
||||
/* Tagging_TrackUID = 0x63C5, */
|
||||
/* Tagging_EditionUID = 0x63C9, */
|
||||
/* Tagging_ChapterUID = 0x63C4, */
|
||||
/* AttachmentUID = 0x63C6, */
|
||||
/* SimpleTag = 0x67C8, */
|
||||
/* TagName = 0x45A3, */
|
||||
/* TagLanguage = 0x447A, */
|
||||
/* TagDefault = 0x4484, */
|
||||
/* TagString = 0x4487, */
|
||||
/* TagBinary = 0x4485, */
|
||||
};
|
||||
#endif
|
157
third_party/libmkv/EbmlWriter.c
vendored
157
third_party/libmkv/EbmlWriter.c
vendored
@ -1,157 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#include "EbmlWriter.h"
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#if defined(_MSC_VER)
|
||||
#define LITERALU64(n) n
|
||||
#else
|
||||
#define LITERALU64(n) n##LLU
|
||||
#endif
|
||||
|
||||
void Ebml_WriteLen(EbmlGlobal *glob, int64_t val) {
|
||||
/* TODO check and make sure we are not > than 0x0100000000000000LLU */
|
||||
unsigned char size = 8; /* size in bytes to output */
|
||||
|
||||
/* mask to compare for byte size */
|
||||
int64_t minVal = 0xff;
|
||||
|
||||
for (size = 1; size < 8; size ++) {
|
||||
if (val < minVal)
|
||||
break;
|
||||
|
||||
minVal = (minVal << 7);
|
||||
}
|
||||
|
||||
val |= (((uint64_t)0x80) << ((size - 1) * 7));
|
||||
|
||||
Ebml_Serialize(glob, (void *) &val, sizeof(val), size);
|
||||
}
|
||||
|
||||
void Ebml_WriteString(EbmlGlobal *glob, const char *str) {
|
||||
const size_t size_ = strlen(str);
|
||||
const uint64_t size = size_;
|
||||
Ebml_WriteLen(glob, size);
|
||||
/* TODO: it's not clear from the spec whether the nul terminator
|
||||
* should be serialized too. For now we omit the null terminator.
|
||||
*/
|
||||
Ebml_Write(glob, str, (unsigned long)size);
|
||||
}
|
||||
|
||||
void Ebml_WriteUTF8(EbmlGlobal *glob, const wchar_t *wstr) {
|
||||
const size_t strlen = wcslen(wstr);
|
||||
|
||||
/* TODO: it's not clear from the spec whether the nul terminator
|
||||
* should be serialized too. For now we include it.
|
||||
*/
|
||||
const uint64_t size = strlen;
|
||||
|
||||
Ebml_WriteLen(glob, size);
|
||||
Ebml_Write(glob, wstr, (unsigned long)size);
|
||||
}
|
||||
|
||||
void Ebml_WriteID(EbmlGlobal *glob, unsigned long class_id) {
|
||||
int len;
|
||||
|
||||
if (class_id >= 0x01000000)
|
||||
len = 4;
|
||||
else if (class_id >= 0x00010000)
|
||||
len = 3;
|
||||
else if (class_id >= 0x00000100)
|
||||
len = 2;
|
||||
else
|
||||
len = 1;
|
||||
|
||||
Ebml_Serialize(glob, (void *)&class_id, sizeof(class_id), len);
|
||||
}
|
||||
|
||||
void Ebml_SerializeUnsigned64(EbmlGlobal *glob, unsigned long class_id, uint64_t ui) {
|
||||
unsigned char sizeSerialized = 8 | 0x80;
|
||||
Ebml_WriteID(glob, class_id);
|
||||
Ebml_Serialize(glob, &sizeSerialized, sizeof(sizeSerialized), 1);
|
||||
Ebml_Serialize(glob, &ui, sizeof(ui), 8);
|
||||
}
|
||||
|
||||
void Ebml_SerializeUnsigned(EbmlGlobal *glob, unsigned long class_id, unsigned long ui) {
|
||||
unsigned char size = 8; /* size in bytes to output */
|
||||
unsigned char sizeSerialized = 0;
|
||||
unsigned long minVal;
|
||||
|
||||
Ebml_WriteID(glob, class_id);
|
||||
minVal = 0x7fLU; /* mask to compare for byte size */
|
||||
|
||||
for (size = 1; size < 4; size ++) {
|
||||
if (ui < minVal) {
|
||||
break;
|
||||
}
|
||||
|
||||
minVal <<= 7;
|
||||
}
|
||||
|
||||
sizeSerialized = 0x80 | size;
|
||||
Ebml_Serialize(glob, &sizeSerialized, sizeof(sizeSerialized), 1);
|
||||
Ebml_Serialize(glob, &ui, sizeof(ui), size);
|
||||
}
|
||||
/* TODO: perhaps this is a poor name for this id serializer helper function */
|
||||
void Ebml_SerializeBinary(EbmlGlobal *glob, unsigned long class_id, unsigned long bin) {
|
||||
int size;
|
||||
for (size = 4; size > 1; size--) {
|
||||
if (bin & (unsigned int)0x000000ff << ((size - 1) * 8))
|
||||
break;
|
||||
}
|
||||
Ebml_WriteID(glob, class_id);
|
||||
Ebml_WriteLen(glob, size);
|
||||
Ebml_WriteID(glob, bin);
|
||||
}
|
||||
|
||||
void Ebml_SerializeFloat(EbmlGlobal *glob, unsigned long class_id, double d) {
|
||||
unsigned char len = 0x88;
|
||||
|
||||
Ebml_WriteID(glob, class_id);
|
||||
Ebml_Serialize(glob, &len, sizeof(len), 1);
|
||||
Ebml_Serialize(glob, &d, sizeof(d), 8);
|
||||
}
|
||||
|
||||
void Ebml_WriteSigned16(EbmlGlobal *glob, short val) {
|
||||
signed long out = ((val & 0x003FFFFF) | 0x00200000) << 8;
|
||||
Ebml_Serialize(glob, &out, sizeof(out), 3);
|
||||
}
|
||||
|
||||
void Ebml_SerializeString(EbmlGlobal *glob, unsigned long class_id, const char *s) {
|
||||
Ebml_WriteID(glob, class_id);
|
||||
Ebml_WriteString(glob, s);
|
||||
}
|
||||
|
||||
void Ebml_SerializeUTF8(EbmlGlobal *glob, unsigned long class_id, wchar_t *s) {
|
||||
Ebml_WriteID(glob, class_id);
|
||||
Ebml_WriteUTF8(glob, s);
|
||||
}
|
||||
|
||||
void Ebml_SerializeData(EbmlGlobal *glob, unsigned long class_id, unsigned char *data, unsigned long data_length) {
|
||||
Ebml_WriteID(glob, class_id);
|
||||
Ebml_WriteLen(glob, data_length);
|
||||
Ebml_Write(glob, data, data_length);
|
||||
}
|
||||
|
||||
void Ebml_WriteVoid(EbmlGlobal *glob, unsigned long vSize) {
|
||||
unsigned char tmp = 0;
|
||||
unsigned long i = 0;
|
||||
|
||||
Ebml_WriteID(glob, 0xEC);
|
||||
Ebml_WriteLen(glob, vSize);
|
||||
|
||||
for (i = 0; i < vSize; i++) {
|
||||
Ebml_Write(glob, &tmp, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO Serialize Date */
|
42
third_party/libmkv/EbmlWriter.h
vendored
42
third_party/libmkv/EbmlWriter.h
vendored
@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#ifndef EBMLWRITER_HPP
|
||||
#define EBMLWRITER_HPP
|
||||
#include <stddef.h>
|
||||
#include "vpx/vpx_integer.h"
|
||||
|
||||
/* note: you must define write and serialize functions as well as your own
|
||||
* EBML_GLOBAL
|
||||
*
|
||||
* These functions MUST be implemented
|
||||
*/
|
||||
|
||||
typedef struct EbmlGlobal EbmlGlobal;
|
||||
void Ebml_Serialize(EbmlGlobal *glob, const void *, int, unsigned long);
|
||||
void Ebml_Write(EbmlGlobal *glob, const void *, unsigned long);
|
||||
|
||||
/*****/
|
||||
|
||||
void Ebml_WriteLen(EbmlGlobal *glob, int64_t val);
|
||||
void Ebml_WriteString(EbmlGlobal *glob, const char *str);
|
||||
void Ebml_WriteUTF8(EbmlGlobal *glob, const wchar_t *wstr);
|
||||
void Ebml_WriteID(EbmlGlobal *glob, unsigned long class_id);
|
||||
void Ebml_SerializeUnsigned64(EbmlGlobal *glob, unsigned long class_id, uint64_t ui);
|
||||
void Ebml_SerializeUnsigned(EbmlGlobal *glob, unsigned long class_id, unsigned long ui);
|
||||
void Ebml_SerializeBinary(EbmlGlobal *glob, unsigned long class_id, unsigned long ui);
|
||||
void Ebml_SerializeFloat(EbmlGlobal *glob, unsigned long class_id, double d);
|
||||
/* TODO make this more generic to signed */
|
||||
void Ebml_WriteSigned16(EbmlGlobal *glob, short val);
|
||||
void Ebml_SerializeString(EbmlGlobal *glob, unsigned long class_id, const char *s);
|
||||
void Ebml_SerializeUTF8(EbmlGlobal *glob, unsigned long class_id, wchar_t *s);
|
||||
void Ebml_SerializeData(EbmlGlobal *glob, unsigned long class_id, unsigned char *data, unsigned long data_length);
|
||||
void Ebml_WriteVoid(EbmlGlobal *glob, unsigned long vSize);
|
||||
/* TODO need date function */
|
||||
#endif
|
25
third_party/libmkv/Makefile
vendored
25
third_party/libmkv/Makefile
vendored
@ -1,25 +0,0 @@
|
||||
#Variables
|
||||
CC=gcc
|
||||
LINKER=gcc
|
||||
FLAGS=-g -Wall
|
||||
|
||||
all: testlibmkv
|
||||
|
||||
#Build Targets
|
||||
EbmlWriter.o: EbmlWriter.c EbmlWriter.h
|
||||
$(CC) $(FLAGS) -c EbmlWriter.c
|
||||
|
||||
EbmlBufferWriter.o: EbmlBufferWriter.c EbmlBufferWriter.h
|
||||
$(CC) $(FLAGS) -c EbmlBufferWriter.c
|
||||
|
||||
WebMElement.o: WebMElement.c WebMElement.h
|
||||
$(CC) $(FLAGS) -c WebMElement.c
|
||||
|
||||
testlibmkv.o: testlibmkv.c
|
||||
$(CC) $(FLAGS) -c testlibmkv.c
|
||||
|
||||
testlibmkv: testlibmkv.o WebMElement.o EbmlBufferWriter.o EbmlWriter.o
|
||||
$(LINKER) $(FLAGS) -o testlibmkv testlibmkv.o WebMElement.o EbmlBufferWriter.o EbmlWriter.o
|
||||
|
||||
clean:
|
||||
rm -rf *.o testlibmkv
|
217
third_party/libmkv/WebMElement.c
vendored
217
third_party/libmkv/WebMElement.c
vendored
@ -1,217 +0,0 @@
|
||||
// Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
|
||||
#include "EbmlBufferWriter.h"
|
||||
#include "EbmlIDs.h"
|
||||
#include "WebMElement.h"
|
||||
#include <stdio.h>
|
||||
#include "vpx/vpx_integer.h"
|
||||
|
||||
#define kVorbisPrivateMaxSize 4000
|
||||
|
||||
void writeHeader(EbmlGlobal *glob) {
|
||||
EbmlLoc start;
|
||||
Ebml_StartSubElement(glob, &start, EBML);
|
||||
Ebml_SerializeUnsigned(glob, EBMLVersion, 1);
|
||||
Ebml_SerializeUnsigned(glob, EBMLReadVersion, 1); // EBML Read Version
|
||||
Ebml_SerializeUnsigned(glob, EBMLMaxIDLength, 4); // EBML Max ID Length
|
||||
Ebml_SerializeUnsigned(glob, EBMLMaxSizeLength, 8); // EBML Max Size Length
|
||||
Ebml_SerializeString(glob, DocType, "webm"); // Doc Type
|
||||
Ebml_SerializeUnsigned(glob, DocTypeVersion, 2); // Doc Type Version
|
||||
Ebml_SerializeUnsigned(glob, DocTypeReadVersion, 2); // Doc Type Read Version
|
||||
Ebml_EndSubElement(glob, &start);
|
||||
}
|
||||
|
||||
void writeSimpleBlock(EbmlGlobal *glob, unsigned char trackNumber, short timeCode,
|
||||
int isKeyframe, unsigned char lacingFlag, int discardable,
|
||||
unsigned char *data, unsigned long dataLength) {
|
||||
Ebml_WriteID(glob, SimpleBlock);
|
||||
unsigned long blockLength = 4 + dataLength;
|
||||
blockLength |= 0x10000000; // TODO check length < 0x0FFFFFFFF
|
||||
Ebml_Serialize(glob, &blockLength, sizeof(blockLength), 4);
|
||||
trackNumber |= 0x80; // TODO check track nubmer < 128
|
||||
Ebml_Write(glob, &trackNumber, 1);
|
||||
// Ebml_WriteSigned16(glob, timeCode,2); //this is 3 bytes
|
||||
Ebml_Serialize(glob, &timeCode, sizeof(timeCode), 2);
|
||||
unsigned char flags = 0x00 | (isKeyframe ? 0x80 : 0x00) | (lacingFlag << 1) | discardable;
|
||||
Ebml_Write(glob, &flags, 1);
|
||||
Ebml_Write(glob, data, dataLength);
|
||||
}
|
||||
|
||||
static uint64_t generateTrackID(unsigned int trackNumber) {
|
||||
uint64_t t = time(NULL) * trackNumber;
|
||||
uint64_t r = rand();
|
||||
r = r << 32;
|
||||
r += rand();
|
||||
uint64_t rval = t ^ r;
|
||||
return rval;
|
||||
}
|
||||
|
||||
void writeVideoTrack(EbmlGlobal *glob, unsigned int trackNumber,
|
||||
int flagLacing, const char *codecId,
|
||||
unsigned int pixelWidth, unsigned int pixelHeight,
|
||||
double frameRate) {
|
||||
EbmlLoc start;
|
||||
Ebml_StartSubElement(glob, &start, TrackEntry);
|
||||
Ebml_SerializeUnsigned(glob, TrackNumber, trackNumber);
|
||||
uint64_t trackID = generateTrackID(trackNumber);
|
||||
Ebml_SerializeUnsigned(glob, TrackUID, trackID);
|
||||
Ebml_SerializeString(glob, CodecName, "VP8"); // TODO shouldn't be fixed
|
||||
|
||||
Ebml_SerializeUnsigned(glob, TrackType, 1); // video is always 1
|
||||
Ebml_SerializeString(glob, CodecID, codecId);
|
||||
{
|
||||
EbmlLoc videoStart;
|
||||
Ebml_StartSubElement(glob, &videoStart, Video);
|
||||
Ebml_SerializeUnsigned(glob, PixelWidth, pixelWidth);
|
||||
Ebml_SerializeUnsigned(glob, PixelHeight, pixelHeight);
|
||||
Ebml_SerializeFloat(glob, FrameRate, frameRate);
|
||||
Ebml_EndSubElement(glob, &videoStart); // Video
|
||||
}
|
||||
Ebml_EndSubElement(glob, &start); // Track Entry
|
||||
}
|
||||
void writeAudioTrack(EbmlGlobal *glob, unsigned int trackNumber,
|
||||
int flagLacing, const char *codecId,
|
||||
double samplingFrequency, unsigned int channels,
|
||||
unsigned char *private, unsigned long privateSize) {
|
||||
EbmlLoc start;
|
||||
Ebml_StartSubElement(glob, &start, TrackEntry);
|
||||
Ebml_SerializeUnsigned(glob, TrackNumber, trackNumber);
|
||||
uint64_t trackID = generateTrackID(trackNumber);
|
||||
Ebml_SerializeUnsigned(glob, TrackUID, trackID);
|
||||
Ebml_SerializeUnsigned(glob, TrackType, 2); // audio is always 2
|
||||
// I am using defaults for thesed required fields
|
||||
/* Ebml_SerializeUnsigned(glob, FlagEnabled, 1);
|
||||
Ebml_SerializeUnsigned(glob, FlagDefault, 1);
|
||||
Ebml_SerializeUnsigned(glob, FlagForced, 1);
|
||||
Ebml_SerializeUnsigned(glob, FlagLacing, flagLacing);*/
|
||||
Ebml_SerializeString(glob, CodecID, codecId);
|
||||
Ebml_SerializeData(glob, CodecPrivate, private, privateSize);
|
||||
|
||||
Ebml_SerializeString(glob, CodecName, "VORBIS"); // fixed for now
|
||||
{
|
||||
EbmlLoc AudioStart;
|
||||
Ebml_StartSubElement(glob, &AudioStart, Audio);
|
||||
Ebml_SerializeFloat(glob, SamplingFrequency, samplingFrequency);
|
||||
Ebml_SerializeUnsigned(glob, Channels, channels);
|
||||
Ebml_EndSubElement(glob, &AudioStart);
|
||||
}
|
||||
Ebml_EndSubElement(glob, &start);
|
||||
}
|
||||
void writeSegmentInformation(EbmlGlobal *ebml, EbmlLoc *startInfo, unsigned long timeCodeScale, double duration) {
|
||||
Ebml_StartSubElement(ebml, startInfo, Info);
|
||||
Ebml_SerializeUnsigned(ebml, TimecodeScale, timeCodeScale);
|
||||
Ebml_SerializeFloat(ebml, Segment_Duration, duration * 1000.0); // Currently fixed to using milliseconds
|
||||
Ebml_SerializeString(ebml, 0x4D80, "QTmuxingAppLibWebM-0.0.1");
|
||||
Ebml_SerializeString(ebml, 0x5741, "QTwritingAppLibWebM-0.0.1");
|
||||
Ebml_EndSubElement(ebml, startInfo);
|
||||
}
|
||||
|
||||
/*
|
||||
void Mkv_InitializeSegment(Ebml& ebml_out, EbmlLoc& ebmlLoc)
|
||||
{
|
||||
Ebml_StartSubElement(ebml_out, ebmlLoc, 0x18538067);
|
||||
}
|
||||
|
||||
void Mkv_InitializeSeek(Ebml& ebml_out, EbmlLoc& ebmlLoc)
|
||||
{
|
||||
Ebml_StartSubElement(ebml_out, ebmlLoc, 0x114d9b74);
|
||||
}
|
||||
void Mkv_WriteSeekInformation(Ebml& ebml_out, SeekStruct& seekInformation)
|
||||
{
|
||||
EbmlLoc ebmlLoc;
|
||||
Ebml_StartSubElement(ebml_out, ebmlLoc, 0x4dbb);
|
||||
Ebml_SerializeString(ebml_out, 0x53ab, seekInformation.SeekID);
|
||||
Ebml_SerializeUnsigned(ebml_out, 0x53ac, seekInformation.SeekPosition);
|
||||
Ebml_EndSubElement(ebml_out, ebmlLoc);
|
||||
}
|
||||
|
||||
void Mkv_WriteSegmentInformation(Ebml& ebml_out, SegmentInformationStruct& segmentInformation)
|
||||
{
|
||||
Ebml_SerializeUnsigned(ebml_out, 0x73a4, segmentInformation.segmentUID);
|
||||
if (segmentInformation.filename != 0)
|
||||
Ebml_SerializeString(ebml_out, 0x7384, segmentInformation.filename);
|
||||
Ebml_SerializeUnsigned(ebml_out, 0x2AD7B1, segmentInformation.TimecodeScale);
|
||||
Ebml_SerializeUnsigned(ebml_out, 0x4489, segmentInformation.Duration);
|
||||
// TODO date
|
||||
Ebml_SerializeWString(ebml_out, 0x4D80, L"MKVMUX");
|
||||
Ebml_SerializeWString(ebml_out, 0x5741, segmentInformation.WritingApp);
|
||||
}
|
||||
|
||||
void Mkv_InitializeTrack(Ebml& ebml_out, EbmlLoc& ebmlLoc)
|
||||
{
|
||||
Ebml_StartSubElement(ebml_out, ebmlLoc, 0x1654AE6B);
|
||||
}
|
||||
|
||||
static void Mkv_WriteGenericTrackData(Ebml& ebml_out, TrackStruct& track)
|
||||
{
|
||||
Ebml_SerializeUnsigned(ebml_out, 0xD7, track.TrackNumber);
|
||||
Ebml_SerializeUnsigned(ebml_out, 0x73C5, track.TrackUID);
|
||||
Ebml_SerializeUnsigned(ebml_out, 0x83, track.TrackType);
|
||||
Ebml_SerializeUnsigned(ebml_out, 0xB9, track.FlagEnabled ? 1 :0);
|
||||
Ebml_SerializeUnsigned(ebml_out, 0x88, track.FlagDefault ? 1 :0);
|
||||
Ebml_SerializeUnsigned(ebml_out, 0x55AA, track.FlagForced ? 1 :0);
|
||||
if (track.Language != 0)
|
||||
Ebml_SerializeString(ebml_out, 0x22B59C, track.Language);
|
||||
if (track.CodecID != 0)
|
||||
Ebml_SerializeString(ebml_out, 0x86, track.CodecID);
|
||||
if (track.CodecPrivate != 0)
|
||||
Ebml_SerializeData(ebml_out, 0x63A2, track.CodecPrivate, track.CodecPrivateLength);
|
||||
if (track.CodecName != 0)
|
||||
Ebml_SerializeWString(ebml_out, 0x258688, track.CodecName);
|
||||
}
|
||||
|
||||
void Mkv_WriteVideoTrack(Ebml& ebml_out, TrackStruct & track, VideoTrackStruct& video)
|
||||
{
|
||||
EbmlLoc trackHeadLoc, videoHeadLoc;
|
||||
Ebml_StartSubElement(ebml_out, trackHeadLoc, 0xAE); // start Track
|
||||
Mkv_WriteGenericTrackData(ebml_out, track);
|
||||
Ebml_StartSubElement(ebml_out, videoHeadLoc, 0xE0); // start Video
|
||||
Ebml_SerializeUnsigned(ebml_out, 0x9A, video.FlagInterlaced ? 1 :0);
|
||||
Ebml_SerializeUnsigned(ebml_out, 0xB0, video.PixelWidth);
|
||||
Ebml_SerializeUnsigned(ebml_out, 0xBA, video.PixelHeight);
|
||||
Ebml_SerializeUnsigned(ebml_out, 0x54B0, video.PixelDisplayWidth);
|
||||
Ebml_SerializeUnsigned(ebml_out, 0x54BA, video.PixelDisplayHeight);
|
||||
Ebml_SerializeUnsigned(ebml_out, 0x54B2, video.displayUnit);
|
||||
Ebml_SerializeFloat(ebml_out, 0x2383E3, video.FrameRate);
|
||||
Ebml_EndSubElement(ebml_out, videoHeadLoc);
|
||||
Ebml_EndSubElement(ebml_out, trackHeadLoc);
|
||||
|
||||
}
|
||||
|
||||
void Mkv_WriteAudioTrack(Ebml& ebml_out, TrackStruct & track, AudioTrackStruct& video)
|
||||
{
|
||||
EbmlLoc trackHeadLoc, audioHeadLoc;
|
||||
Ebml_StartSubElement(ebml_out, trackHeadLoc, 0xAE);
|
||||
Mkv_WriteGenericTrackData(ebml_out, track);
|
||||
Ebml_StartSubElement(ebml_out, audioHeadLoc, 0xE0); // start Audio
|
||||
Ebml_SerializeFloat(ebml_out, 0xB5, video.SamplingFrequency);
|
||||
Ebml_SerializeUnsigned(ebml_out, 0x9F, video.Channels);
|
||||
Ebml_SerializeUnsigned(ebml_out, 0x6264, video.BitDepth);
|
||||
Ebml_EndSubElement(ebml_out, audioHeadLoc); // end audio
|
||||
Ebml_EndSubElement(ebml_out, trackHeadLoc);
|
||||
}
|
||||
|
||||
void Mkv_WriteEbmlClusterHead(Ebml& ebml_out, EbmlLoc& ebmlLoc, ClusterHeadStruct & clusterHead)
|
||||
{
|
||||
Ebml_StartSubElement(ebml_out, ebmlLoc, 0x1F43B675);
|
||||
Ebml_SerializeUnsigned(ebml_out, 0x6264, clusterHead.TimeCode);
|
||||
}
|
||||
|
||||
void Mkv_WriteSimpleBlockHead(Ebml& ebml_out, EbmlLoc& ebmlLoc, SimpleBlockStruct& block)
|
||||
{
|
||||
Ebml_StartSubElement(ebml_out, ebmlLoc, 0xA3);
|
||||
Ebml_Write1UInt(ebml_out, block.TrackNumber);
|
||||
Ebml_WriteSigned16(ebml_out,block.TimeCode);
|
||||
unsigned char flags = 0x00 | (block.iskey ? 0x80:0x00) | (block.lacing << 1) | block.discardable;
|
||||
Ebml_Write1UInt(ebml_out, flags); // TODO this may be the wrong function
|
||||
Ebml_Serialize(ebml_out, block.data, block.dataLength);
|
||||
Ebml_EndSubElement(ebml_out,ebmlLoc);
|
||||
}
|
||||
*/
|
32
third_party/libmkv/WebMElement.h
vendored
32
third_party/libmkv/WebMElement.h
vendored
@ -1,32 +0,0 @@
|
||||
// Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
|
||||
#ifndef MKV_CONTEXT_HPP
|
||||
#define MKV_CONTEXT_HPP 1
|
||||
|
||||
// these are helper functions
|
||||
void writeHeader(EbmlGlobal *ebml);
|
||||
void writeSegmentInformation(EbmlGlobal *ebml, EbmlLoc *startInfo,
|
||||
unsigned long timeCodeScale, double duration);
|
||||
// this function is a helper only, it assumes a lot of defaults
|
||||
void writeVideoTrack(EbmlGlobal *ebml, unsigned int trackNumber,
|
||||
int flagLacing, const char *codecId,
|
||||
unsigned int pixelWidth, unsigned int pixelHeight,
|
||||
double frameRate);
|
||||
void writeAudioTrack(EbmlGlobal *glob, unsigned int trackNumber,
|
||||
int flagLacing, const char *codecId,
|
||||
double samplingFrequency, unsigned int channels,
|
||||
unsigned char *private, unsigned long privateSize);
|
||||
|
||||
void writeSimpleBlock(EbmlGlobal *ebml, unsigned char trackNumber,
|
||||
short timeCode, int isKeyframe,
|
||||
unsigned char lacingFlag, int discardable,
|
||||
unsigned char *data, unsigned long dataLength);
|
||||
|
||||
#endif
|
62
third_party/libmkv/testlibmkv.c
vendored
62
third_party/libmkv/testlibmkv.c
vendored
@ -1,62 +0,0 @@
|
||||
// Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
|
||||
|
||||
#include "EbmlIDs.h"
|
||||
#include "EbmlBufferWriter.h"
|
||||
#include "WebMElement.h"
|
||||
|
||||
#include <stdio.h>
|
||||
int main(int argc, char *argv[]) {
|
||||
// init the datatype we're using for ebml output
|
||||
unsigned char data[8192];
|
||||
EbmlGlobal ebml;
|
||||
ebml.buf = data;
|
||||
ebml.offset = 0;
|
||||
ebml.length = 8192;
|
||||
|
||||
writeHeader(&ebml);
|
||||
{
|
||||
EbmlLoc startSegment;
|
||||
Ebml_StartSubElement(&ebml, &startSegment, Segment); // segment
|
||||
{
|
||||
// segment info
|
||||
EbmlLoc startInfo;
|
||||
Ebml_StartSubElement(&ebml, &startInfo, Info);
|
||||
Ebml_SerializeString(&ebml, 0x4D80, "muxingAppLibMkv");
|
||||
Ebml_SerializeString(&ebml, 0x5741, "writingAppLibMkv");
|
||||
Ebml_EndSubElement(&ebml, &startInfo);
|
||||
}
|
||||
|
||||
{
|
||||
EbmlLoc trackStart;
|
||||
Ebml_StartSubElement(&ebml, &trackStart, Tracks);
|
||||
writeVideoTrack(&ebml, 1, 1, "V_MS/VFW/FOURCC", 320, 240, 29.97);
|
||||
// writeAudioTrack(&ebml,2,1, "A_VORBIS", 32000, 1, NULL, 0);
|
||||
Ebml_EndSubElement(&ebml, &trackStart);
|
||||
}
|
||||
|
||||
{
|
||||
EbmlLoc clusterStart;
|
||||
Ebml_StartSubElement(&ebml, &clusterStart, Cluster); // cluster
|
||||
Ebml_SerializeUnsigned(&ebml, Timecode, 0);
|
||||
|
||||
unsigned char someData[4] = {1, 2, 3, 4};
|
||||
writeSimpleBlock(&ebml, 1, 0, 1, 0, 0, someData, 4);
|
||||
Ebml_EndSubElement(&ebml, &clusterStart);
|
||||
} // end cluster
|
||||
Ebml_EndSubElement(&ebml, &startSegment);
|
||||
}
|
||||
|
||||
// dump ebml stuff to the file
|
||||
FILE *file_out = fopen("test.mkv", "wb");
|
||||
size_t bytesWritten = fwrite(data, 1, ebml.offset, file_out);
|
||||
fclose(file_out);
|
||||
return 0;
|
||||
}
|
41
third_party/nestegg/0001-include-paths.diff
vendored
41
third_party/nestegg/0001-include-paths.diff
vendored
@ -1,41 +0,0 @@
|
||||
diff --git a/nestegg/halloc/src/halloc.c b/nestegg/halloc/src/halloc.c
|
||||
index 5758fc0..837b3ff 100644
|
||||
--- a/nestegg/halloc/src/halloc.c
|
||||
+++ b/nestegg/halloc/src/halloc.c
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <stdlib.h> /* realloc */
|
||||
#include <string.h> /* memset & co */
|
||||
|
||||
-#include "halloc.h"
|
||||
+#include "third_party/nestegg/halloc/halloc.h"
|
||||
#include "align.h"
|
||||
#include "hlist.h"
|
||||
|
||||
diff --git a/nestegg/include/nestegg/nestegg.h b/nestegg/include/nestegg/nestegg.h
|
||||
index ff13728..c18d1d3 100644
|
||||
--- a/nestegg/include/nestegg/nestegg.h
|
||||
+++ b/nestegg/include/nestegg/nestegg.h
|
||||
@@ -7,7 +7,7 @@
|
||||
#if !defined(NESTEGG_671cac2a_365d_ed69_d7a3_4491d3538d79)
|
||||
#define NESTEGG_671cac2a_365d_ed69_d7a3_4491d3538d79
|
||||
|
||||
-#include <nestegg/nestegg-stdint.h>
|
||||
+#include "vpx/vpx_integer.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
diff --git a/nestegg/src/nestegg.c b/nestegg/src/nestegg.c
|
||||
index daf1eed..4fb10e7 100644
|
||||
--- a/nestegg/src/nestegg.c
|
||||
+++ b/nestegg/src/nestegg.c
|
||||
@@ -8,8 +8,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
-#include "halloc.h"
|
||||
-#include "nestegg/nestegg.h"
|
||||
+#include "third_party/nestegg/halloc/halloc.h"
|
||||
+#include "third_party/nestegg/include/nestegg/nestegg.h"
|
||||
|
||||
/* EBML Elements */
|
||||
#define ID_EBML 0x1a45dfa3
|
@ -1,21 +0,0 @@
|
||||
diff --git a/nestegg/src/nestegg.c b/nestegg/src/nestegg.c
|
||||
index 4fb10e7..b6bc460 100644
|
||||
--- a/nestegg/src/nestegg.c
|
||||
+++ b/nestegg/src/nestegg.c
|
||||
@@ -934,7 +934,7 @@ static int
|
||||
ne_read_simple(nestegg * ctx, struct ebml_element_desc * desc, size_t length)
|
||||
{
|
||||
struct ebml_type * storage;
|
||||
- int r;
|
||||
+ int r = 0;
|
||||
|
||||
storage = (struct ebml_type *) (ctx->ancestor->data + desc->offset);
|
||||
|
||||
@@ -968,7 +968,6 @@ ne_read_simple(nestegg * ctx, struct ebml_element_desc * desc, size_t length)
|
||||
case TYPE_MASTER:
|
||||
case TYPE_UNKNOWN:
|
||||
assert(0);
|
||||
- r = 0;
|
||||
break;
|
||||
}
|
||||
|
3
third_party/nestegg/AUTHORS
vendored
3
third_party/nestegg/AUTHORS
vendored
@ -1,3 +0,0 @@
|
||||
Matthew Gregan <kinetik@flim.org>
|
||||
Steve Workman <sjhworkman@gmail.com>
|
||||
Paul Adenot <paul@paul.cx>
|
8
third_party/nestegg/INSTALL
vendored
8
third_party/nestegg/INSTALL
vendored
@ -1,8 +0,0 @@
|
||||
Build instructions for libnestegg
|
||||
=================================
|
||||
|
||||
0. Change directory into the source directory.
|
||||
1. Run |autoreconf --install| to generate configure.
|
||||
2. Run |./configure| to configure the build.
|
||||
3. Run |make| to build.
|
||||
4. Run |make check| to run the test suite.
|
13
third_party/nestegg/LICENSE
vendored
13
third_party/nestegg/LICENSE
vendored
@ -1,13 +0,0 @@
|
||||
Copyright © 2010 Mozilla Foundation
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
6
third_party/nestegg/README
vendored
6
third_party/nestegg/README
vendored
@ -1,6 +0,0 @@
|
||||
See INSTALL for build instructions.
|
||||
|
||||
Licensed under an ISC-style license. See LICENSE for details.
|
||||
|
||||
The source under the halloc/ directory is licensed under a BSD license. See
|
||||
halloc/halloc.h for details.
|
24
third_party/nestegg/README.libvpx
vendored
24
third_party/nestegg/README.libvpx
vendored
@ -1,24 +0,0 @@
|
||||
URL: https://github.com/kinetiknz/nestegg.git
|
||||
Version: f46223191d8116a36bf299b5b9793fcb798417b1
|
||||
License: ISC-style
|
||||
License File: LICENSE
|
||||
|
||||
Description:
|
||||
The source under the halloc/ directory is licensed under a BSD license. See
|
||||
halloc/halloc.h for details.
|
||||
|
||||
Local Modifications:
|
||||
- delete unnecessary docs and build files
|
||||
- nestegg/0001-include-paths.diff
|
||||
include path modifications for the libvpx build system
|
||||
- 0002-ne_read_simple-uninitialized_variable.diff
|
||||
fixes:
|
||||
nestegg.c|975 col 6| warning: ‘r’ may be used uninitialized in this function [-Wuninitialized]
|
||||
- add ne_get_uint32 convenience function
|
||||
- fix track_number uint64->uint32 warnings
|
||||
- fix track_scale double->uint64 warning
|
||||
- nestegg_packet_track: fix uint64->uint32 warning
|
||||
- ne_read_(string|binary|block): normalize size_t usage
|
||||
- ne_parse: normalize size_t usage
|
||||
- quiet read related uint64->size_t warnings
|
||||
- ne_buffer_read: quiet uint64->size_t warning
|
21
third_party/nestegg/TODO
vendored
21
third_party/nestegg/TODO
vendored
@ -1,21 +0,0 @@
|
||||
- Document when read, seek, tell callbacks are used.
|
||||
- Add an automated testsuite.
|
||||
- Test (and fix, if necessary) support for unknown sizes.
|
||||
- Test (and fix, if necessary) support for large files.
|
||||
- Read past unknown elements rather than seeking.
|
||||
- Try to handle unknown elements with unknown sizes.
|
||||
- Formalize handling of default element values.
|
||||
- Try to resynchronize stream when read_block fails so that failure to parse
|
||||
a single block can be treated as non-fatal.
|
||||
- Make logging more useful to API users.
|
||||
- Avoid reparsing Cues and ignore any SeekHead at end of file.
|
||||
- Optionally build a Cue index as Clusters are parsed.
|
||||
- Support seeking without Cues.
|
||||
- Avoid building a list of Clusters as they are parsed and retain only the
|
||||
last one parsed.
|
||||
- Add an asynchronous error code to struct nestegg and ensure that API calls
|
||||
continue to fail safely one a fatal error has been returned.
|
||||
- Modify parser/data structures to provide a clean separation. Perhaps the
|
||||
parser should return a generic tree of nodes that a second pass uses to
|
||||
initialize the main data structures.
|
||||
- Use pool allocator for all allocations.
|
45
third_party/nestegg/halloc/README
vendored
45
third_party/nestegg/halloc/README
vendored
@ -1,45 +0,0 @@
|
||||
halloc 1.2.1
|
||||
============
|
||||
|
||||
Hierarchical memory heap interface - an extension to standard
|
||||
malloc/free interface that simplifies tasks of memory disposal
|
||||
when allocated structures exhibit hierarchical properties.
|
||||
|
||||
http://swapped.cc/halloc
|
||||
=
|
||||
To build libhalloc.a with GNU tools run
|
||||
make
|
||||
|
||||
To install in /usr/include and /usr/lib
|
||||
make install
|
||||
|
||||
To cleanup the build files
|
||||
make clean
|
||||
=
|
||||
halloc-1.2.1
|
||||
* fixed a double-free bug in _set_allocator() as per
|
||||
Matthew Gregan comments
|
||||
|
||||
* switched to using NULL instead of 0 where applicable
|
||||
|
||||
halloc-1.2.0
|
||||
* added missing <string.h> include to halloc.c
|
||||
|
||||
* improved standard compliance thanks to the feedback
|
||||
received from Stan Tobias. Two things were fixed -
|
||||
|
||||
- hblock_t structure no longer uses zero-sized 'data'
|
||||
array, which happened to be common, but non-standard
|
||||
extension;
|
||||
|
||||
- secondly, added the code to test the behaviour of
|
||||
realloc(ptr, 0). Standard allows it NOT to act as
|
||||
free(), in which case halloc will use its own version
|
||||
of allocator calling free() when neccessary.
|
||||
|
||||
halloc-1.1.0
|
||||
* initial public release (rewrite of hhmalloc library)
|
||||
|
||||
=============================================================================
|
||||
Copyright (c) 2004-2010, Alex Pankratov (ap@swapped.cc). All rights reserved.
|
||||
|
43
third_party/nestegg/halloc/halloc.h
vendored
43
third_party/nestegg/halloc/halloc.h
vendored
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2010 Alex Pankratov. All rights reserved.
|
||||
*
|
||||
* Hierarchical memory allocator, 1.2.1
|
||||
* http://swapped.cc/halloc
|
||||
*/
|
||||
|
||||
/*
|
||||
* The program is distributed under terms of BSD license.
|
||||
* You can obtain the copy of the license by visiting:
|
||||
*
|
||||
* http://www.opensource.org/licenses/bsd-license.php
|
||||
*/
|
||||
|
||||
#ifndef _LIBP_HALLOC_H_
|
||||
#define _LIBP_HALLOC_H_
|
||||
|
||||
#include <stddef.h> /* size_t */
|
||||
|
||||
/*
|
||||
* Core API
|
||||
*/
|
||||
void * halloc (void * block, size_t len);
|
||||
void hattach(void * block, void * parent);
|
||||
|
||||
/*
|
||||
* standard malloc/free api
|
||||
*/
|
||||
void * h_malloc (size_t len);
|
||||
void * h_calloc (size_t n, size_t len);
|
||||
void * h_realloc(void * p, size_t len);
|
||||
void h_free (void * p);
|
||||
char * h_strdup (const char * str);
|
||||
|
||||
/*
|
||||
* the underlying allocator
|
||||
*/
|
||||
typedef void * (* realloc_t)(void * ptr, size_t len);
|
||||
|
||||
extern realloc_t halloc_allocator;
|
||||
|
||||
#endif
|
||||
|
36
third_party/nestegg/halloc/src/align.h
vendored
36
third_party/nestegg/halloc/src/align.h
vendored
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2010 Alex Pankratov. All rights reserved.
|
||||
*
|
||||
* Hierarchical memory allocator, 1.2.1
|
||||
* http://swapped.cc/halloc
|
||||
*/
|
||||
|
||||
/*
|
||||
* The program is distributed under terms of BSD license.
|
||||
* You can obtain the copy of the license by visiting:
|
||||
*
|
||||
* http://www.opensource.org/licenses/bsd-license.php
|
||||
*/
|
||||
|
||||
#ifndef _LIBP_ALIGN_H_
|
||||
#define _LIBP_ALIGN_H_
|
||||
|
||||
/*
|
||||
* a type with the most strict alignment requirements
|
||||
*/
|
||||
union max_align
|
||||
{
|
||||
char c;
|
||||
short s;
|
||||
long l;
|
||||
int i;
|
||||
float f;
|
||||
double d;
|
||||
void * v;
|
||||
void (*q)(void);
|
||||
};
|
||||
|
||||
typedef union max_align max_align_t;
|
||||
|
||||
#endif
|
||||
|
254
third_party/nestegg/halloc/src/halloc.c
vendored
254
third_party/nestegg/halloc/src/halloc.c
vendored
@ -1,254 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004i-2010 Alex Pankratov. All rights reserved.
|
||||
*
|
||||
* Hierarchical memory allocator, 1.2.1
|
||||
* http://swapped.cc/halloc
|
||||
*/
|
||||
|
||||
/*
|
||||
* The program is distributed under terms of BSD license.
|
||||
* You can obtain the copy of the license by visiting:
|
||||
*
|
||||
* http://www.opensource.org/licenses/bsd-license.php
|
||||
*/
|
||||
|
||||
#include <stdlib.h> /* realloc */
|
||||
#include <string.h> /* memset & co */
|
||||
|
||||
#include "third_party/nestegg/halloc/halloc.h"
|
||||
#include "align.h"
|
||||
#include "hlist.h"
|
||||
|
||||
/*
|
||||
* block control header
|
||||
*/
|
||||
typedef struct hblock
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
#define HH_MAGIC 0x20040518L
|
||||
long magic;
|
||||
#endif
|
||||
hlist_item_t siblings; /* 2 pointers */
|
||||
hlist_head_t children; /* 1 pointer */
|
||||
max_align_t data[1]; /* not allocated, see below */
|
||||
|
||||
} hblock_t;
|
||||
|
||||
#define sizeof_hblock offsetof(hblock_t, data)
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
realloc_t halloc_allocator = NULL;
|
||||
|
||||
#define allocator halloc_allocator
|
||||
|
||||
/*
|
||||
* static methods
|
||||
*/
|
||||
static void _set_allocator(void);
|
||||
static void * _realloc(void * ptr, size_t n);
|
||||
|
||||
static int _relate(hblock_t * b, hblock_t * p);
|
||||
static void _free_children(hblock_t * p);
|
||||
|
||||
/*
|
||||
* Core API
|
||||
*/
|
||||
void * halloc(void * ptr, size_t len)
|
||||
{
|
||||
hblock_t * p;
|
||||
|
||||
/* set up default allocator */
|
||||
if (! allocator)
|
||||
{
|
||||
_set_allocator();
|
||||
assert(allocator);
|
||||
}
|
||||
|
||||
/* calloc */
|
||||
if (! ptr)
|
||||
{
|
||||
if (! len)
|
||||
return NULL;
|
||||
|
||||
p = allocator(0, len + sizeof_hblock);
|
||||
if (! p)
|
||||
return NULL;
|
||||
#ifndef NDEBUG
|
||||
p->magic = HH_MAGIC;
|
||||
#endif
|
||||
hlist_init(&p->children);
|
||||
hlist_init_item(&p->siblings);
|
||||
|
||||
return p->data;
|
||||
}
|
||||
|
||||
p = structof(ptr, hblock_t, data);
|
||||
assert(p->magic == HH_MAGIC);
|
||||
|
||||
/* realloc */
|
||||
if (len)
|
||||
{
|
||||
p = allocator(p, len + sizeof_hblock);
|
||||
if (! p)
|
||||
return NULL;
|
||||
|
||||
hlist_relink(&p->siblings);
|
||||
hlist_relink_head(&p->children);
|
||||
|
||||
return p->data;
|
||||
}
|
||||
|
||||
/* free */
|
||||
_free_children(p);
|
||||
hlist_del(&p->siblings);
|
||||
allocator(p, 0);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void hattach(void * block, void * parent)
|
||||
{
|
||||
hblock_t * b, * p;
|
||||
|
||||
if (! block)
|
||||
{
|
||||
assert(! parent);
|
||||
return;
|
||||
}
|
||||
|
||||
/* detach */
|
||||
b = structof(block, hblock_t, data);
|
||||
assert(b->magic == HH_MAGIC);
|
||||
|
||||
hlist_del(&b->siblings);
|
||||
|
||||
if (! parent)
|
||||
return;
|
||||
|
||||
/* attach */
|
||||
p = structof(parent, hblock_t, data);
|
||||
assert(p->magic == HH_MAGIC);
|
||||
|
||||
/* sanity checks */
|
||||
assert(b != p); /* trivial */
|
||||
assert(! _relate(p, b)); /* heavy ! */
|
||||
|
||||
hlist_add(&p->children, &b->siblings);
|
||||
}
|
||||
|
||||
/*
|
||||
* malloc/free api
|
||||
*/
|
||||
void * h_malloc(size_t len)
|
||||
{
|
||||
return halloc(0, len);
|
||||
}
|
||||
|
||||
void * h_calloc(size_t n, size_t len)
|
||||
{
|
||||
void * ptr = halloc(0, len*=n);
|
||||
return ptr ? memset(ptr, 0, len) : NULL;
|
||||
}
|
||||
|
||||
void * h_realloc(void * ptr, size_t len)
|
||||
{
|
||||
return halloc(ptr, len);
|
||||
}
|
||||
|
||||
void h_free(void * ptr)
|
||||
{
|
||||
halloc(ptr, 0);
|
||||
}
|
||||
|
||||
char * h_strdup(const char * str)
|
||||
{
|
||||
size_t len = strlen(str);
|
||||
char * ptr = halloc(0, len + 1);
|
||||
return ptr ? (ptr[len] = 0, memcpy(ptr, str, len)) : NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* static stuff
|
||||
*/
|
||||
static void _set_allocator(void)
|
||||
{
|
||||
void * p;
|
||||
assert(! allocator);
|
||||
|
||||
/*
|
||||
* the purpose of the test below is to check the behaviour
|
||||
* of realloc(ptr, 0), which is defined in the standard
|
||||
* as an implementation-specific. if it returns zero,
|
||||
* then it's equivalent to free(). it can however return
|
||||
* non-zero, in which case it cannot be used for freeing
|
||||
* memory blocks and we'll need to supply our own version
|
||||
*
|
||||
* Thanks to Stan Tobias for pointing this tricky part out.
|
||||
*/
|
||||
allocator = realloc;
|
||||
if (! (p = malloc(1)))
|
||||
/* hmm */
|
||||
return;
|
||||
|
||||
if ((p = realloc(p, 0)))
|
||||
{
|
||||
/* realloc cannot be used as free() */
|
||||
allocator = _realloc;
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
|
||||
static void * _realloc(void * ptr, size_t n)
|
||||
{
|
||||
/*
|
||||
* free'ing realloc()
|
||||
*/
|
||||
if (n)
|
||||
return realloc(ptr, n);
|
||||
free(ptr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int _relate(hblock_t * b, hblock_t * p)
|
||||
{
|
||||
hlist_item_t * i;
|
||||
|
||||
if (!b || !p)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* since there is no 'parent' pointer, which would've allowed
|
||||
* O(log(n)) upward traversal, the check must use O(n) downward
|
||||
* iteration of the entire hierarchy; and this can be VERY SLOW
|
||||
*/
|
||||
hlist_for_each(i, &p->children)
|
||||
{
|
||||
hblock_t * q = structof(i, hblock_t, siblings);
|
||||
if (q == b || _relate(b, q))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _free_children(hblock_t * p)
|
||||
{
|
||||
hlist_item_t * i, * tmp;
|
||||
|
||||
#ifndef NDEBUG
|
||||
/*
|
||||
* this catches loops in hierarchy with almost zero
|
||||
* overhead (compared to _relate() running time)
|
||||
*/
|
||||
assert(p && p->magic == HH_MAGIC);
|
||||
p->magic = 0;
|
||||
#endif
|
||||
hlist_for_each_safe(i, tmp, &p->children)
|
||||
{
|
||||
hblock_t * q = structof(i, hblock_t, siblings);
|
||||
_free_children(q);
|
||||
allocator(q, 0);
|
||||
}
|
||||
}
|
||||
|
136
third_party/nestegg/halloc/src/hlist.h
vendored
136
third_party/nestegg/halloc/src/hlist.h
vendored
@ -1,136 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2010 Alex Pankratov. All rights reserved.
|
||||
*
|
||||
* Hierarchical memory allocator, 1.2.1
|
||||
* http://swapped.cc/halloc
|
||||
*/
|
||||
|
||||
/*
|
||||
* The program is distributed under terms of BSD license.
|
||||
* You can obtain the copy of the license by visiting:
|
||||
*
|
||||
* http://www.opensource.org/licenses/bsd-license.php
|
||||
*/
|
||||
|
||||
#ifndef _LIBP_HLIST_H_
|
||||
#define _LIBP_HLIST_H_
|
||||
|
||||
#include <assert.h>
|
||||
#include "macros.h" /* static_inline */
|
||||
|
||||
/*
|
||||
* weak double-linked list w/ tail sentinel
|
||||
*/
|
||||
typedef struct hlist_head hlist_head_t;
|
||||
typedef struct hlist_item hlist_item_t;
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
struct hlist_head
|
||||
{
|
||||
hlist_item_t * next;
|
||||
};
|
||||
|
||||
struct hlist_item
|
||||
{
|
||||
hlist_item_t * next;
|
||||
hlist_item_t ** prev;
|
||||
};
|
||||
|
||||
/*
|
||||
* shared tail sentinel
|
||||
*/
|
||||
struct hlist_item hlist_null;
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
#define __hlist_init(h) { &hlist_null }
|
||||
#define __hlist_init_item(i) { &hlist_null, &(i).next }
|
||||
|
||||
static_inline void hlist_init(hlist_head_t * h);
|
||||
static_inline void hlist_init_item(hlist_item_t * i);
|
||||
|
||||
/* static_inline void hlist_purge(hlist_head_t * h); */
|
||||
|
||||
/* static_inline bool_t hlist_empty(const hlist_head_t * h); */
|
||||
|
||||
/* static_inline hlist_item_t * hlist_head(const hlist_head_t * h); */
|
||||
|
||||
/* static_inline hlist_item_t * hlist_next(const hlist_item_t * i); */
|
||||
/* static_inline hlist_item_t * hlist_prev(const hlist_item_t * i,
|
||||
const hlist_head_t * h); */
|
||||
|
||||
static_inline void hlist_add(hlist_head_t * h, hlist_item_t * i);
|
||||
|
||||
/* static_inline void hlist_add_prev(hlist_item_t * l, hlist_item_t * i); */
|
||||
/* static_inline void hlist_add_next(hlist_item_t * l, hlist_item_t * i); */
|
||||
|
||||
static_inline void hlist_del(hlist_item_t * i);
|
||||
|
||||
static_inline void hlist_relink(hlist_item_t * i);
|
||||
static_inline void hlist_relink_head(hlist_head_t * h);
|
||||
|
||||
#define hlist_for_each(i, h) \
|
||||
for (i = (h)->next; i != &hlist_null; i = i->next)
|
||||
|
||||
#define hlist_for_each_safe(i, tmp, h) \
|
||||
for (i = (h)->next, tmp = i->next; \
|
||||
i!= &hlist_null; \
|
||||
i = tmp, tmp = i->next)
|
||||
|
||||
/*
|
||||
* static
|
||||
*/
|
||||
static_inline void hlist_init(hlist_head_t * h)
|
||||
{
|
||||
assert(h);
|
||||
h->next = &hlist_null;
|
||||
}
|
||||
|
||||
static_inline void hlist_init_item(hlist_item_t * i)
|
||||
{
|
||||
assert(i);
|
||||
i->prev = &i->next;
|
||||
i->next = &hlist_null;
|
||||
}
|
||||
|
||||
static_inline void hlist_add(hlist_head_t * h, hlist_item_t * i)
|
||||
{
|
||||
hlist_item_t * next;
|
||||
assert(h && i);
|
||||
|
||||
next = i->next = h->next;
|
||||
next->prev = &i->next;
|
||||
h->next = i;
|
||||
i->prev = &h->next;
|
||||
}
|
||||
|
||||
static_inline void hlist_del(hlist_item_t * i)
|
||||
{
|
||||
hlist_item_t * next;
|
||||
assert(i);
|
||||
|
||||
next = i->next;
|
||||
next->prev = i->prev;
|
||||
*i->prev = next;
|
||||
|
||||
hlist_init_item(i);
|
||||
}
|
||||
|
||||
static_inline void hlist_relink(hlist_item_t * i)
|
||||
{
|
||||
assert(i);
|
||||
*i->prev = i;
|
||||
i->next->prev = &i->next;
|
||||
}
|
||||
|
||||
static_inline void hlist_relink_head(hlist_head_t * h)
|
||||
{
|
||||
assert(h);
|
||||
h->next->prev = &h->next;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
36
third_party/nestegg/halloc/src/macros.h
vendored
36
third_party/nestegg/halloc/src/macros.h
vendored
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2010 Alex Pankratov. All rights reserved.
|
||||
*
|
||||
* Hierarchical memory allocator, 1.2.1
|
||||
* http://swapped.cc/halloc
|
||||
*/
|
||||
|
||||
/*
|
||||
* The program is distributed under terms of BSD license.
|
||||
* You can obtain the copy of the license by visiting:
|
||||
*
|
||||
* http://www.opensource.org/licenses/bsd-license.php
|
||||
*/
|
||||
|
||||
#ifndef _LIBP_MACROS_H_
|
||||
#define _LIBP_MACROS_H_
|
||||
|
||||
#include <stddef.h> /* offsetof */
|
||||
|
||||
/*
|
||||
restore pointer to the structure by a pointer to its field
|
||||
*/
|
||||
#define structof(p,t,f) ((t*)(- (ptrdiff_t) offsetof(t,f) + (char*)(p)))
|
||||
|
||||
/*
|
||||
* redefine for the target compiler
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
#define static_inline static __inline
|
||||
#else
|
||||
#define static_inline static __inline__
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
353
third_party/nestegg/include/nestegg/nestegg.h
vendored
353
third_party/nestegg/include/nestegg/nestegg.h
vendored
@ -1,353 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2010 Mozilla Foundation
|
||||
*
|
||||
* This program is made available under an ISC-style license. See the
|
||||
* accompanying file LICENSE for details.
|
||||
*/
|
||||
#if !defined(NESTEGG_671cac2a_365d_ed69_d7a3_4491d3538d79)
|
||||
#define NESTEGG_671cac2a_365d_ed69_d7a3_4491d3538d79
|
||||
|
||||
#include "vpx/vpx_integer.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @mainpage
|
||||
|
||||
@section intro Introduction
|
||||
|
||||
This is the documentation for the <tt>libnestegg</tt> C API.
|
||||
<tt>libnestegg</tt> is a demultiplexing library for <a
|
||||
href="http://www.webmproject.org/code/specs/container/">WebM</a>
|
||||
media files.
|
||||
|
||||
@section example Example code
|
||||
|
||||
@code
|
||||
nestegg * demux_ctx;
|
||||
nestegg_init(&demux_ctx, io, NULL);
|
||||
|
||||
nestegg_packet * pkt;
|
||||
while ((r = nestegg_read_packet(demux_ctx, &pkt)) > 0) {
|
||||
unsigned int track;
|
||||
|
||||
nestegg_packet_track(pkt, &track);
|
||||
|
||||
// This example decodes the first track only.
|
||||
if (track == 0) {
|
||||
unsigned int chunk, chunks;
|
||||
|
||||
nestegg_packet_count(pkt, &chunks);
|
||||
|
||||
// Decode each chunk of data.
|
||||
for (chunk = 0; chunk < chunks; ++chunk) {
|
||||
unsigned char * data;
|
||||
size_t data_size;
|
||||
|
||||
nestegg_packet_data(pkt, chunk, &data, &data_size);
|
||||
|
||||
example_codec_decode(codec_ctx, data, data_size);
|
||||
}
|
||||
}
|
||||
|
||||
nestegg_free_packet(pkt);
|
||||
}
|
||||
|
||||
nestegg_destroy(demux_ctx);
|
||||
@endcode
|
||||
*/
|
||||
|
||||
|
||||
/** @file
|
||||
The <tt>libnestegg</tt> C API. */
|
||||
|
||||
#define NESTEGG_TRACK_VIDEO 0 /**< Track is of type video. */
|
||||
#define NESTEGG_TRACK_AUDIO 1 /**< Track is of type audio. */
|
||||
|
||||
#define NESTEGG_CODEC_VP8 0 /**< Track uses Google On2 VP8 codec. */
|
||||
#define NESTEGG_CODEC_VORBIS 1 /**< Track uses Xiph Vorbis codec. */
|
||||
#define NESTEGG_CODEC_VP9 2 /**< Track uses Google On2 VP9 codec. */
|
||||
#define NESTEGG_CODEC_OPUS 3 /**< Track uses Xiph Opus codec. */
|
||||
|
||||
#define NESTEGG_VIDEO_MONO 0 /**< Track is mono video. */
|
||||
#define NESTEGG_VIDEO_STEREO_LEFT_RIGHT 1 /**< Track is side-by-side stereo video. Left first. */
|
||||
#define NESTEGG_VIDEO_STEREO_BOTTOM_TOP 2 /**< Track is top-bottom stereo video. Right first. */
|
||||
#define NESTEGG_VIDEO_STEREO_TOP_BOTTOM 3 /**< Track is top-bottom stereo video. Left first. */
|
||||
#define NESTEGG_VIDEO_STEREO_RIGHT_LEFT 11 /**< Track is side-by-side stereo video. Right first. */
|
||||
|
||||
#define NESTEGG_SEEK_SET 0 /**< Seek offset relative to beginning of stream. */
|
||||
#define NESTEGG_SEEK_CUR 1 /**< Seek offset relative to current position in stream. */
|
||||
#define NESTEGG_SEEK_END 2 /**< Seek offset relative to end of stream. */
|
||||
|
||||
#define NESTEGG_LOG_DEBUG 1 /**< Debug level log message. */
|
||||
#define NESTEGG_LOG_INFO 10 /**< Informational level log message. */
|
||||
#define NESTEGG_LOG_WARNING 100 /**< Warning level log message. */
|
||||
#define NESTEGG_LOG_ERROR 1000 /**< Error level log message. */
|
||||
#define NESTEGG_LOG_CRITICAL 10000 /**< Critical level log message. */
|
||||
|
||||
typedef struct nestegg nestegg; /**< Opaque handle referencing the stream state. */
|
||||
typedef struct nestegg_packet nestegg_packet; /**< Opaque handle referencing a packet of data. */
|
||||
|
||||
/** User supplied IO context. */
|
||||
typedef struct {
|
||||
/** User supplied read callback.
|
||||
@param buffer Buffer to read data into.
|
||||
@param length Length of supplied buffer in bytes.
|
||||
@param userdata The #userdata supplied by the user.
|
||||
@retval 1 Read succeeded.
|
||||
@retval 0 End of stream.
|
||||
@retval -1 Error. */
|
||||
int (* read)(void * buffer, size_t length, void * userdata);
|
||||
|
||||
/** User supplied seek callback.
|
||||
@param offset Offset within the stream to seek to.
|
||||
@param whence Seek direction. One of #NESTEGG_SEEK_SET,
|
||||
#NESTEGG_SEEK_CUR, or #NESTEGG_SEEK_END.
|
||||
@param userdata The #userdata supplied by the user.
|
||||
@retval 0 Seek succeeded.
|
||||
@retval -1 Error. */
|
||||
int (* seek)(int64_t offset, int whence, void * userdata);
|
||||
|
||||
/** User supplied tell callback.
|
||||
@param userdata The #userdata supplied by the user.
|
||||
@returns Current position within the stream.
|
||||
@retval -1 Error. */
|
||||
int64_t (* tell)(void * userdata);
|
||||
|
||||
/** User supplied pointer to be passed to the IO callbacks. */
|
||||
void * userdata;
|
||||
} nestegg_io;
|
||||
|
||||
/** Parameters specific to a video track. */
|
||||
typedef struct {
|
||||
unsigned int stereo_mode; /**< Video mode. One of #NESTEGG_VIDEO_MONO,
|
||||
#NESTEGG_VIDEO_STEREO_LEFT_RIGHT,
|
||||
#NESTEGG_VIDEO_STEREO_BOTTOM_TOP, or
|
||||
#NESTEGG_VIDEO_STEREO_TOP_BOTTOM. */
|
||||
unsigned int width; /**< Width of the video frame in pixels. */
|
||||
unsigned int height; /**< Height of the video frame in pixels. */
|
||||
unsigned int display_width; /**< Display width of the video frame in pixels. */
|
||||
unsigned int display_height; /**< Display height of the video frame in pixels. */
|
||||
unsigned int crop_bottom; /**< Pixels to crop from the bottom of the frame. */
|
||||
unsigned int crop_top; /**< Pixels to crop from the top of the frame. */
|
||||
unsigned int crop_left; /**< Pixels to crop from the left of the frame. */
|
||||
unsigned int crop_right; /**< Pixels to crop from the right of the frame. */
|
||||
} nestegg_video_params;
|
||||
|
||||
/** Parameters specific to an audio track. */
|
||||
typedef struct {
|
||||
double rate; /**< Sampling rate in Hz. */
|
||||
unsigned int channels; /**< Number of audio channels. */
|
||||
unsigned int depth; /**< Bits per sample. */
|
||||
uint64_t codec_delay; /**< Nanoseconds that must be discarded from the start. */
|
||||
uint64_t seek_preroll;/**< Nanoseconds that must be discarded after a seek. */
|
||||
} nestegg_audio_params;
|
||||
|
||||
/** Logging callback function pointer. */
|
||||
typedef void (* nestegg_log)(nestegg * context, unsigned int severity, char const * format, ...);
|
||||
|
||||
/** Initialize a nestegg context. During initialization the parser will
|
||||
read forward in the stream processing all elements until the first
|
||||
block of media is reached. All track metadata has been processed at this point.
|
||||
@param context Storage for the new nestegg context. @see nestegg_destroy
|
||||
@param io User supplied IO context.
|
||||
@param callback Optional logging callback function pointer. May be NULL.
|
||||
@param max_offset Optional maximum offset to be read. Set -1 to ignore.
|
||||
@retval 0 Success.
|
||||
@retval -1 Error. */
|
||||
int nestegg_init(nestegg ** context, nestegg_io io, nestegg_log callback, int64_t max_offset);
|
||||
|
||||
/** Destroy a nestegg context and free associated memory.
|
||||
@param context #nestegg context to be freed. @see nestegg_init */
|
||||
void nestegg_destroy(nestegg * context);
|
||||
|
||||
/** Query the duration of the media stream in nanoseconds.
|
||||
@param context Stream context initialized by #nestegg_init.
|
||||
@param duration Storage for the queried duration.
|
||||
@retval 0 Success.
|
||||
@retval -1 Error. */
|
||||
int nestegg_duration(nestegg * context, uint64_t * duration);
|
||||
|
||||
/** Query the tstamp scale of the media stream in nanoseconds.
|
||||
Timecodes presented by nestegg have been scaled by this value
|
||||
before presentation to the caller.
|
||||
@param context Stream context initialized by #nestegg_init.
|
||||
@param scale Storage for the queried scale factor.
|
||||
@retval 0 Success.
|
||||
@retval -1 Error. */
|
||||
int nestegg_tstamp_scale(nestegg * context, uint64_t * scale);
|
||||
|
||||
/** Query the number of tracks in the media stream.
|
||||
@param context Stream context initialized by #nestegg_init.
|
||||
@param tracks Storage for the queried track count.
|
||||
@retval 0 Success.
|
||||
@retval -1 Error. */
|
||||
int nestegg_track_count(nestegg * context, unsigned int * tracks);
|
||||
|
||||
/** Query the start and end offset for a particular cluster.
|
||||
@param context Stream context initialized by #nestegg_init.
|
||||
@param cluster_num Zero-based cluster number; order they appear in cues.
|
||||
@param max_offset Optional maximum offset to be read. Set -1 to ignore.
|
||||
@param start_pos Starting offset of the cluster. -1 means non-existant.
|
||||
@param end_pos Starting offset of the cluster. -1 means non-existant or
|
||||
final cluster.
|
||||
@param tstamp Starting timestamp of the cluster.
|
||||
@retval 0 Success.
|
||||
@retval -1 Error. */
|
||||
int nestegg_get_cue_point(nestegg * context, unsigned int cluster_num,
|
||||
int64_t max_offset, int64_t * start_pos,
|
||||
int64_t * end_pos, uint64_t * tstamp);
|
||||
|
||||
/** Seek to @a offset. Stream will seek directly to offset.
|
||||
Should be used to seek to the start of a resync point, i.e. cluster; the
|
||||
parser will not be able to understand other offsets.
|
||||
@param context Stream context initialized by #nestegg_init.
|
||||
@param offset Absolute offset in bytes.
|
||||
@retval 0 Success.
|
||||
@retval -1 Error. */
|
||||
int nestegg_offset_seek(nestegg * context, uint64_t offset);
|
||||
|
||||
/** Seek @a track to @a tstamp. Stream seek will terminate at the earliest
|
||||
key point in the stream at or before @a tstamp. Other tracks in the
|
||||
stream will output packets with unspecified but nearby timestamps.
|
||||
@param context Stream context initialized by #nestegg_init.
|
||||
@param track Zero based track number.
|
||||
@param tstamp Absolute timestamp in nanoseconds.
|
||||
@retval 0 Success.
|
||||
@retval -1 Error. */
|
||||
int nestegg_track_seek(nestegg * context, unsigned int track, uint64_t tstamp);
|
||||
|
||||
/** Query the type specified by @a track.
|
||||
@param context Stream context initialized by #nestegg_init.
|
||||
@param track Zero based track number.
|
||||
@retval #NESTEGG_TRACK_VIDEO Track type is video.
|
||||
@retval #NESTEGG_TRACK_AUDIO Track type is audio.
|
||||
@retval -1 Error. */
|
||||
int nestegg_track_type(nestegg * context, unsigned int track);
|
||||
|
||||
/** Query the codec ID specified by @a track.
|
||||
@param context Stream context initialized by #nestegg_init.
|
||||
@param track Zero based track number.
|
||||
@retval #NESTEGG_CODEC_VP8 Track codec is VP8.
|
||||
@retval #NESTEGG_CODEC_VORBIS Track codec is Vorbis.
|
||||
@retval -1 Error. */
|
||||
int nestegg_track_codec_id(nestegg * context, unsigned int track);
|
||||
|
||||
/** Query the number of codec initialization chunks for @a track. Each
|
||||
chunk of data should be passed to the codec initialization functions in
|
||||
the order returned.
|
||||
@param context Stream context initialized by #nestegg_init.
|
||||
@param track Zero based track number.
|
||||
@param count Storage for the queried chunk count.
|
||||
@retval 0 Success.
|
||||
@retval -1 Error. */
|
||||
int nestegg_track_codec_data_count(nestegg * context, unsigned int track,
|
||||
unsigned int * count);
|
||||
|
||||
/** Get a pointer to chunk number @a item of codec initialization data for
|
||||
@a track.
|
||||
@param context Stream context initialized by #nestegg_init.
|
||||
@param track Zero based track number.
|
||||
@param item Zero based chunk item number.
|
||||
@param data Storage for the queried data pointer.
|
||||
The data is owned by the #nestegg context.
|
||||
@param length Storage for the queried data size.
|
||||
@retval 0 Success.
|
||||
@retval -1 Error. */
|
||||
int nestegg_track_codec_data(nestegg * context, unsigned int track, unsigned int item,
|
||||
unsigned char ** data, size_t * length);
|
||||
|
||||
/** Query the video parameters specified by @a track.
|
||||
@param context Stream context initialized by #nestegg_init.
|
||||
@param track Zero based track number.
|
||||
@param params Storage for the queried video parameters.
|
||||
@retval 0 Success.
|
||||
@retval -1 Error. */
|
||||
int nestegg_track_video_params(nestegg * context, unsigned int track,
|
||||
nestegg_video_params * params);
|
||||
|
||||
/** Query the audio parameters specified by @a track.
|
||||
@param context Stream context initialized by #nestegg_init.
|
||||
@param track Zero based track number.
|
||||
@param params Storage for the queried audio parameters.
|
||||
@retval 0 Success.
|
||||
@retval -1 Error. */
|
||||
int nestegg_track_audio_params(nestegg * context, unsigned int track,
|
||||
nestegg_audio_params * params);
|
||||
|
||||
/** Read a packet of media data. A packet consists of one or more chunks of
|
||||
data associated with a single track. nestegg_read_packet should be
|
||||
called in a loop while the return value is 1 to drive the stream parser
|
||||
forward. @see nestegg_free_packet
|
||||
@param context Context returned by #nestegg_init.
|
||||
@param packet Storage for the returned nestegg_packet.
|
||||
@retval 1 Additional packets may be read in subsequent calls.
|
||||
@retval 0 End of stream.
|
||||
@retval -1 Error. */
|
||||
int nestegg_read_packet(nestegg * context, nestegg_packet ** packet);
|
||||
|
||||
/** Destroy a nestegg_packet and free associated memory.
|
||||
@param packet #nestegg_packet to be freed. @see nestegg_read_packet */
|
||||
void nestegg_free_packet(nestegg_packet * packet);
|
||||
|
||||
/** Query the track number of @a packet.
|
||||
@param packet Packet initialized by #nestegg_read_packet.
|
||||
@param track Storage for the queried zero based track index.
|
||||
@retval 0 Success.
|
||||
@retval -1 Error. */
|
||||
int nestegg_packet_track(nestegg_packet * packet, unsigned int * track);
|
||||
|
||||
/** Query the time stamp in nanoseconds of @a packet.
|
||||
@param packet Packet initialized by #nestegg_read_packet.
|
||||
@param tstamp Storage for the queried timestamp in nanoseconds.
|
||||
@retval 0 Success.
|
||||
@retval -1 Error. */
|
||||
int nestegg_packet_tstamp(nestegg_packet * packet, uint64_t * tstamp);
|
||||
|
||||
/** Query the number of data chunks contained in @a packet.
|
||||
@param packet Packet initialized by #nestegg_read_packet.
|
||||
@param count Storage for the queried timestamp in nanoseconds.
|
||||
@retval 0 Success.
|
||||
@retval -1 Error. */
|
||||
int nestegg_packet_count(nestegg_packet * packet, unsigned int * count);
|
||||
|
||||
/** Get a pointer to chunk number @a item of packet data.
|
||||
@param packet Packet initialized by #nestegg_read_packet.
|
||||
@param item Zero based chunk item number.
|
||||
@param data Storage for the queried data pointer.
|
||||
The data is owned by the #nestegg_packet packet.
|
||||
@param length Storage for the queried data size.
|
||||
@retval 0 Success.
|
||||
@retval -1 Error. */
|
||||
int nestegg_packet_data(nestegg_packet * packet, unsigned int item,
|
||||
unsigned char ** data, size_t * length);
|
||||
|
||||
/** Returns discard_padding for given packet
|
||||
@param packet Packet initialized by #nestegg_read_packet.
|
||||
@param discard_padding pointer to store discard padding in.
|
||||
@retval 0 Success.
|
||||
@retval -1 Error. */
|
||||
int nestegg_packet_discard_padding(nestegg_packet * packet,
|
||||
int64_t * discard_padding);
|
||||
|
||||
/** Query the presence of cues.
|
||||
@param context Stream context initialized by #nestegg_init.
|
||||
@retval 0 The media has no cues.
|
||||
@retval 1 The media has cues. */
|
||||
int nestegg_has_cues(nestegg * context);
|
||||
|
||||
/**
|
||||
* Try to determine if the buffer looks like the beginning of a WebM file.
|
||||
*
|
||||
* @param buffer A buffer containing the beginning of a media file.
|
||||
* @param length The size of the buffer.
|
||||
* @retval 0 The file is not a WebM file.
|
||||
* @retval 1 The file is a WebM file. */
|
||||
int nestegg_sniff(unsigned char const * buffer, size_t length);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NESTEGG_671cac2a_365d_ed69_d7a3_4491d3538d79 */
|
2323
third_party/nestegg/src/nestegg.c
vendored
2323
third_party/nestegg/src/nestegg.c
vendored
File diff suppressed because it is too large
Load Diff
250
third_party/nestegg/test/test.c
vendored
250
third_party/nestegg/test/test.c
vendored
@ -1,250 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2010 Mozilla Foundation
|
||||
*
|
||||
* This program is made available under an ISC-style license. See the
|
||||
* accompanying file LICENSE for details.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "nestegg/nestegg.h"
|
||||
|
||||
#undef DEBUG
|
||||
#define SEEK_TEST
|
||||
|
||||
static int
|
||||
stdio_read(void * p, size_t length, void * file)
|
||||
{
|
||||
size_t r;
|
||||
FILE * fp = file;
|
||||
|
||||
r = fread(p, length, 1, fp);
|
||||
if (r == 0 && feof(fp))
|
||||
return 0;
|
||||
return r == 0 ? -1 : 1;
|
||||
}
|
||||
|
||||
static int
|
||||
stdio_seek(int64_t offset, int whence, void * file)
|
||||
{
|
||||
FILE * fp = file;
|
||||
return fseek(fp, offset, whence);
|
||||
}
|
||||
|
||||
static int64_t
|
||||
stdio_tell(void * fp)
|
||||
{
|
||||
return ftell(fp);
|
||||
}
|
||||
|
||||
static void
|
||||
log_callback(nestegg * ctx, unsigned int severity, char const * fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char const * sev = NULL;
|
||||
|
||||
#if !defined(DEBUG)
|
||||
if (severity < NESTEGG_LOG_WARNING)
|
||||
return;
|
||||
#endif
|
||||
|
||||
switch (severity) {
|
||||
case NESTEGG_LOG_DEBUG:
|
||||
sev = "debug: ";
|
||||
break;
|
||||
case NESTEGG_LOG_WARNING:
|
||||
sev = "warning: ";
|
||||
break;
|
||||
case NESTEGG_LOG_CRITICAL:
|
||||
sev = "critical:";
|
||||
break;
|
||||
default:
|
||||
sev = "unknown: ";
|
||||
}
|
||||
|
||||
fprintf(stderr, "%p %s ", (void *) ctx, sev);
|
||||
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char * argv[])
|
||||
{
|
||||
FILE * fp;
|
||||
int r, type;
|
||||
nestegg * ctx;
|
||||
nestegg_audio_params aparams;
|
||||
nestegg_packet * pkt;
|
||||
nestegg_video_params vparams;
|
||||
size_t length, size;
|
||||
uint64_t duration, tstamp, pkt_tstamp;
|
||||
unsigned char * codec_data, * ptr;
|
||||
unsigned int cnt, i, j, track, tracks, pkt_cnt, pkt_track;
|
||||
unsigned int data_items = 0;
|
||||
nestegg_io io = {
|
||||
stdio_read,
|
||||
stdio_seek,
|
||||
stdio_tell,
|
||||
NULL
|
||||
};
|
||||
|
||||
if (argc != 2)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
fp = fopen(argv[1], "rb");
|
||||
if (!fp)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
io.userdata = fp;
|
||||
|
||||
ctx = NULL;
|
||||
r = nestegg_init(&ctx, io, log_callback, -1);
|
||||
if (r != 0)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
nestegg_track_count(ctx, &tracks);
|
||||
nestegg_duration(ctx, &duration);
|
||||
#if defined(DEBUG)
|
||||
fprintf(stderr, "media has %u tracks and duration %fs\n", tracks, duration / 1e9);
|
||||
#endif
|
||||
|
||||
for (i = 0; i < tracks; ++i) {
|
||||
type = nestegg_track_type(ctx, i);
|
||||
#if defined(DEBUG)
|
||||
fprintf(stderr, "track %u: type: %d codec: %d", i,
|
||||
type, nestegg_track_codec_id(ctx, i));
|
||||
#endif
|
||||
nestegg_track_codec_data_count(ctx, i, &data_items);
|
||||
for (j = 0; j < data_items; ++j) {
|
||||
nestegg_track_codec_data(ctx, i, j, &codec_data, &length);
|
||||
#if defined(DEBUG)
|
||||
fprintf(stderr, " (%p, %u)", codec_data, (unsigned int) length);
|
||||
#endif
|
||||
}
|
||||
if (type == NESTEGG_TRACK_VIDEO) {
|
||||
nestegg_track_video_params(ctx, i, &vparams);
|
||||
#if defined(DEBUG)
|
||||
fprintf(stderr, " video: %ux%u (d: %ux%u %ux%ux%ux%u)",
|
||||
vparams.width, vparams.height,
|
||||
vparams.display_width, vparams.display_height,
|
||||
vparams.crop_top, vparams.crop_left, vparams.crop_bottom, vparams.crop_right);
|
||||
#endif
|
||||
} else if (type == NESTEGG_TRACK_AUDIO) {
|
||||
nestegg_track_audio_params(ctx, i, &aparams);
|
||||
#if defined(DEBUG)
|
||||
fprintf(stderr, " audio: %.2fhz %u bit %u channels",
|
||||
aparams.rate, aparams.depth, aparams.channels);
|
||||
#endif
|
||||
}
|
||||
#if defined(DEBUG)
|
||||
fprintf(stderr, "\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(SEEK_TEST)
|
||||
#if defined(DEBUG)
|
||||
fprintf(stderr, "seek to middle\n");
|
||||
#endif
|
||||
r = nestegg_track_seek(ctx, 0, duration / 2);
|
||||
if (r == 0) {
|
||||
#if defined(DEBUG)
|
||||
fprintf(stderr, "middle ");
|
||||
#endif
|
||||
r = nestegg_read_packet(ctx, &pkt);
|
||||
if (r == 1) {
|
||||
nestegg_packet_track(pkt, &track);
|
||||
nestegg_packet_count(pkt, &cnt);
|
||||
nestegg_packet_tstamp(pkt, &tstamp);
|
||||
#if defined(DEBUG)
|
||||
fprintf(stderr, "* t %u pts %f frames %u\n", track, tstamp / 1e9, cnt);
|
||||
#endif
|
||||
nestegg_free_packet(pkt);
|
||||
} else {
|
||||
#if defined(DEBUG)
|
||||
fprintf(stderr, "middle seek failed\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(DEBUG)
|
||||
fprintf(stderr, "seek to ~end\n");
|
||||
#endif
|
||||
r = nestegg_track_seek(ctx, 0, duration - (duration / 10));
|
||||
if (r == 0) {
|
||||
#if defined(DEBUG)
|
||||
fprintf(stderr, "end ");
|
||||
#endif
|
||||
r = nestegg_read_packet(ctx, &pkt);
|
||||
if (r == 1) {
|
||||
nestegg_packet_track(pkt, &track);
|
||||
nestegg_packet_count(pkt, &cnt);
|
||||
nestegg_packet_tstamp(pkt, &tstamp);
|
||||
#if defined(DEBUG)
|
||||
fprintf(stderr, "* t %u pts %f frames %u\n", track, tstamp / 1e9, cnt);
|
||||
#endif
|
||||
nestegg_free_packet(pkt);
|
||||
} else {
|
||||
#if defined(DEBUG)
|
||||
fprintf(stderr, "end seek failed\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(DEBUG)
|
||||
fprintf(stderr, "seek to ~start\n");
|
||||
#endif
|
||||
r = nestegg_track_seek(ctx, 0, duration / 10);
|
||||
if (r == 0) {
|
||||
#if defined(DEBUG)
|
||||
fprintf(stderr, "start ");
|
||||
#endif
|
||||
r = nestegg_read_packet(ctx, &pkt);
|
||||
if (r == 1) {
|
||||
nestegg_packet_track(pkt, &track);
|
||||
nestegg_packet_count(pkt, &cnt);
|
||||
nestegg_packet_tstamp(pkt, &tstamp);
|
||||
#if defined(DEBUG)
|
||||
fprintf(stderr, "* t %u pts %f frames %u\n", track, tstamp / 1e9, cnt);
|
||||
#endif
|
||||
nestegg_free_packet(pkt);
|
||||
} else {
|
||||
#if defined(DEBUG)
|
||||
fprintf(stderr, "start seek failed\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
while (nestegg_read_packet(ctx, &pkt) > 0) {
|
||||
nestegg_packet_track(pkt, &pkt_track);
|
||||
nestegg_packet_count(pkt, &pkt_cnt);
|
||||
nestegg_packet_tstamp(pkt, &pkt_tstamp);
|
||||
|
||||
#if defined(DEBUG)
|
||||
fprintf(stderr, "t %u pts %f frames %u: ", pkt_track, pkt_tstamp / 1e9, pkt_cnt);
|
||||
#endif
|
||||
|
||||
for (i = 0; i < pkt_cnt; ++i) {
|
||||
nestegg_packet_data(pkt, i, &ptr, &size);
|
||||
#if defined(DEBUG)
|
||||
fprintf(stderr, "%u ", (unsigned int) size);
|
||||
#endif
|
||||
}
|
||||
#if defined(DEBUG)
|
||||
fprintf(stderr, "\n");
|
||||
#endif
|
||||
|
||||
nestegg_free_packet(pkt);
|
||||
}
|
||||
|
||||
nestegg_destroy(ctx);
|
||||
fclose(fp);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@ -123,7 +123,6 @@ git show > "${ORIG_DIFF}"
|
||||
for f in $(git diff HEAD^ --name-only -M90 --diff-filter=AM); do
|
||||
case "$f" in
|
||||
third_party/*) continue;;
|
||||
nestegg/*) continue;;
|
||||
esac
|
||||
vpx_style "$f"
|
||||
done
|
||||
|
Loading…
x
Reference in New Issue
Block a user