demux_mkv.c, ebml.c: Reformat to K&R style

This commit is contained in:
Uoti Urpala 2009-12-29 21:06:21 +02:00
parent c447ef4e74
commit 9fe4f64782
2 changed files with 2217 additions and 2430 deletions

File diff suppressed because it is too large Load Diff

View File

@ -39,8 +39,7 @@
* Read: the element content data ID.
* Return: the ID.
*/
uint32_t
ebml_read_id (stream_t *s, int *length)
uint32_t ebml_read_id(stream_t *s, int *length)
{
int i, len_mask = 0x80;
uint32_t id;
@ -59,8 +58,7 @@ ebml_read_id (stream_t *s, int *length)
/*
* Read a variable length unsigned int.
*/
uint64_t
ebml_read_vlen_uint (uint8_t *buffer, int *length)
uint64_t ebml_read_vlen_uint(uint8_t *buffer, int *length)
{
int i, j, num_ffs = 0, len_mask = 0x80;
uint64_t num;
@ -74,8 +72,7 @@ ebml_read_vlen_uint (uint8_t *buffer, int *length)
*length = j;
if ((int) (num &= (len_mask - 1)) == len_mask - 1)
num_ffs++;
while (i--)
{
while (i--) {
num = (num << 8) | *buffer++;
if ((num & 0xFF) == 0xFF)
num_ffs++;
@ -88,8 +85,7 @@ ebml_read_vlen_uint (uint8_t *buffer, int *length)
/*
* Read a variable length signed int.
*/
int64_t
ebml_read_vlen_int (uint8_t *buffer, int *length)
int64_t ebml_read_vlen_int(uint8_t *buffer, int *length)
{
uint64_t unum;
int l;
@ -107,8 +103,7 @@ ebml_read_vlen_int (uint8_t *buffer, int *length)
/*
* Read: element content length.
*/
uint64_t
ebml_read_length (stream_t *s, int *length)
uint64_t ebml_read_length(stream_t *s, int *length)
{
int i, j, num_ffs = 0, len_mask = 0x80;
uint64_t len;
@ -122,8 +117,7 @@ ebml_read_length (stream_t *s, int *length)
*length = j;
if ((int) (len &= (len_mask - 1)) == len_mask - 1)
num_ffs++;
while (i--)
{
while (i--) {
len = (len << 8) | stream_read_char(s);
if ((len & 0xFF) == 0xFF)
num_ffs++;
@ -136,8 +130,7 @@ ebml_read_length (stream_t *s, int *length)
/*
* Read the next element as an unsigned int.
*/
uint64_t
ebml_read_uint (stream_t *s, uint64_t *length)
uint64_t ebml_read_uint(stream_t *s, uint64_t *length)
{
uint64_t len, value = 0;
int l;
@ -157,8 +150,7 @@ ebml_read_uint (stream_t *s, uint64_t *length)
/*
* Read the next element as a signed int.
*/
int64_t
ebml_read_int (stream_t *s, uint64_t *length)
int64_t ebml_read_int(stream_t *s, uint64_t *length)
{
int64_t value = 0;
uint64_t len;
@ -184,16 +176,14 @@ ebml_read_int (stream_t *s, uint64_t *length)
/*
* Read the next element as a float.
*/
long double
ebml_read_float (stream_t *s, uint64_t *length)
long double ebml_read_float(stream_t *s, uint64_t *length)
{
long double value;
uint64_t len;
int l;
len = ebml_read_length(s, &l);
switch (len)
{
switch (len) {
case 4:
value = av_int2flt(stream_read_dword(s));
break;
@ -215,8 +205,7 @@ ebml_read_float (stream_t *s, uint64_t *length)
/*
* Read the next element as an ASCII string.
*/
char *
ebml_read_ascii (stream_t *s, uint64_t *length)
char *ebml_read_ascii(stream_t *s, uint64_t *length)
{
uint64_t len;
char *str;
@ -231,8 +220,7 @@ ebml_read_ascii (stream_t *s, uint64_t *length)
*length = len + l;
str = (char *) malloc(len + 1);
if (stream_read(s, str, len) != (int) len)
{
if (stream_read(s, str, len) != (int) len) {
free(str);
return NULL;
}
@ -244,8 +232,7 @@ ebml_read_ascii (stream_t *s, uint64_t *length)
/*
* Read the next element as a UTF-8 string.
*/
char *
ebml_read_utf8 (stream_t *s, uint64_t *length)
char *ebml_read_utf8(stream_t *s, uint64_t *length)
{
return ebml_read_ascii(s, length);
}
@ -253,8 +240,7 @@ ebml_read_utf8 (stream_t *s, uint64_t *length)
/*
* Skip the next element.
*/
int
ebml_read_skip (stream_t *s, uint64_t *length)
int ebml_read_skip(stream_t *s, uint64_t *length)
{
uint64_t len;
int l;
@ -274,8 +260,7 @@ ebml_read_skip (stream_t *s, uint64_t *length)
* Read the next element, but only the header. The contents
* are supposed to be sub-elements which can be read separately.
*/
uint32_t
ebml_read_master (stream_t *s, uint64_t *length)
uint32_t ebml_read_master(stream_t *s, uint64_t *length)
{
uint64_t len;
uint32_t id;
@ -297,8 +282,7 @@ ebml_read_master (stream_t *s, uint64_t *length)
/*
* Read an EBML header.
*/
char *
ebml_read_header (stream_t *s, int *version)
char *ebml_read_header(stream_t *s, int *version)
{
uint64_t length, l, num;
uint32_t id;
@ -310,15 +294,13 @@ ebml_read_header (stream_t *s, int *version)
if (version)
*version = 1;
while (length > 0)
{
while (length > 0) {
id = ebml_read_id(s, NULL);
if (id == EBML_ID_INVALID)
return NULL;
length -= 2;
switch (id)
{
switch (id) {
/* is our read version uptodate? */
case EBML_ID_EBMLREADVERSION:
num = ebml_read_uint(s, &l);