EbmlWriter.cpp revision 3607b5be4cdbed324d26cb3009c12937390e6702
/* $Id$ */
/** @file
* EbmlWriter.cpp - EBML writer + WebM container
*/
/*
* Copyright (C) 2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/*
* This code is based on:
*
* 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"
{
}
{
}
{
}
{
}
{
}
{
{
if (RT_FAILURE(rc))
return rc;
}
return VINF_SUCCESS;
}
{
int rc;
if (class_id >= 0x01000000)
else if (class_id >= 0x00010000)
else if (class_id >= 0x00000100)
else
return rc;
}
{
if (RT_SUCCESS(rc))
return rc;
}
{
// todo this is always taking 8 bytes, this may need later optimization
// this is a key that says lenght unknown
}
{
/* Save the current file pointer */
/* Calculate the size of this element */
/* Seek back to the beginning of the element and write the new size */
/* Reset the file pointer */
return rc;
}
{
//TODO check and make sure we are not > than 0x0100000000000000LLU
{
break;
}
}
{
//TODO: it's not clear from the spec whether the nul terminator
//should be serialized too. For now we omit the null terminator.
if (RT_SUCCESS(rc))
return rc;
}
{
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
return rc;
}
{
if (RT_FAILURE(rc))
return rc;
{
break;
minVal <<= 7;
}
if (RT_SUCCESS(rc))
return rc;
}
//TODO: perhaps this is a poor name for this id serializer helper function
{
int size;
{
break;
}
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
return rc;
}
{
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
return rc;
}
{
if (RT_SUCCESS(rc))
return rc;
}
{
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
return rc;
}
{
int rc = VINF_SUCCESS;
/* Save the current file pointer */
if (ebml->seek_info_pos)
else
{
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
}
{
//segment info
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
char szVersion[64];
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
}
return rc;
}
const vpx_codec_enc_cfg_t *cfg,
const struct vpx_rational *fps)
{
int rc = VINF_SUCCESS;
{
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
}
{
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
}
if (RT_SUCCESS(rc))
}
if (RT_SUCCESS(rc))
}
// segment element is open
}
return rc;
}
const vpx_codec_enc_cfg_t *cfg,
const vpx_codec_cx_pkt_t *pkt)
{
uint16_t block_timecode = 0;
int start_cluster = 0;
int rc = VINF_SUCCESS;
/* Calculate the PTS of this frame in milliseconds */
/* Calculate the relative time of this block */
start_cluster = 1;
else
if (start_cluster || fKeyframe)
{
if (glob->cluster_open)
/* Open the new cluster */
block_timecode = 0;
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
/* Save a cue point if this is a keyframe. */
if (fKeyframe)
{
}
}
/* Write the Simple Block */
if (RT_SUCCESS(rc))
block_length |= 0x10000000;
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (fKeyframe)
flags |= 0x80;
flags |= 0x08;
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
return rc;
}
{
int rc = VINF_SUCCESS;
if (glob->cluster_open)
{
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
//Ebml_SerializeUnsigned(glob, CueBlockNumber, cue->blockNumber);
if (RT_SUCCESS(rc))
}
if (RT_SUCCESS(rc))
}
if (RT_SUCCESS(rc))
}
if (RT_SUCCESS(rc))
/* Patch up the seek info block */
if (RT_SUCCESS(rc))
/* Patch up the track id */
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
return rc;
}