Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
d03eea36
Commit
d03eea36
authored
Nov 15, 2013
by
Jan Gerber
Committed by
Michael Niedermayer
Nov 15, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavf/matroska*: add support for signed integers
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
5592d1b7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
0 deletions
+51
-0
matroskadec.c
libavformat/matroskadec.c
+30
-0
matroskaenc.c
libavformat/matroskaenc.c
+21
-0
No files found.
libavformat/matroskadec.c
View file @
d03eea36
...
@@ -62,6 +62,7 @@ typedef enum {
...
@@ -62,6 +62,7 @@ typedef enum {
EBML_NEST
,
EBML_NEST
,
EBML_PASS
,
EBML_PASS
,
EBML_STOP
,
EBML_STOP
,
EBML_SINT
,
EBML_TYPE_COUNT
EBML_TYPE_COUNT
}
EbmlType
;
}
EbmlType
;
...
@@ -758,6 +759,34 @@ static int ebml_read_uint(AVIOContext *pb, int size, uint64_t *num)
...
@@ -758,6 +759,34 @@ static int ebml_read_uint(AVIOContext *pb, int size, uint64_t *num)
return
0
;
return
0
;
}
}
/*
* Read the next element as a signed int.
* 0 is success, < 0 is failure.
*/
static
int
ebml_read_sint
(
AVIOContext
*
pb
,
int
size
,
int64_t
*
num
)
{
int
n
=
1
;
if
(
size
>
8
)
return
AVERROR_INVALIDDATA
;
if
(
size
==
0
)
{
*
num
=
0
;
}
else
{
*
num
=
avio_r8
(
pb
);
/* negative value */
if
(
*
num
&
0x80
)
{
*
num
=
(
-
1
<<
8
)
|
*
num
;
}
/* big-endian ordering; build up number */
while
(
n
++
<
size
)
*
num
=
(
*
num
<<
8
)
|
avio_r8
(
pb
);
}
return
0
;
}
/*
/*
* Read the next element as a float.
* Read the next element as a float.
* 0 is success, < 0 is failure.
* 0 is success, < 0 is failure.
...
@@ -985,6 +1014,7 @@ static int ebml_parse_elem(MatroskaDemuxContext *matroska,
...
@@ -985,6 +1014,7 @@ static int ebml_parse_elem(MatroskaDemuxContext *matroska,
switch
(
syntax
->
type
)
{
switch
(
syntax
->
type
)
{
case
EBML_UINT
:
res
=
ebml_read_uint
(
pb
,
length
,
data
);
break
;
case
EBML_UINT
:
res
=
ebml_read_uint
(
pb
,
length
,
data
);
break
;
case
EBML_SINT
:
res
=
ebml_read_sint
(
pb
,
length
,
data
);
break
;
case
EBML_FLOAT
:
res
=
ebml_read_float
(
pb
,
length
,
data
);
break
;
case
EBML_FLOAT
:
res
=
ebml_read_float
(
pb
,
length
,
data
);
break
;
case
EBML_STR
:
case
EBML_STR
:
case
EBML_UTF8
:
res
=
ebml_read_ascii
(
pb
,
length
,
data
);
break
;
case
EBML_UTF8
:
res
=
ebml_read_ascii
(
pb
,
length
,
data
);
break
;
...
...
libavformat/matroskaenc.c
View file @
d03eea36
...
@@ -202,6 +202,27 @@ static void put_ebml_uint(AVIOContext *pb, unsigned int elementid, uint64_t val)
...
@@ -202,6 +202,27 @@ static void put_ebml_uint(AVIOContext *pb, unsigned int elementid, uint64_t val)
avio_w8
(
pb
,
(
uint8_t
)(
val
>>
i
*
8
));
avio_w8
(
pb
,
(
uint8_t
)(
val
>>
i
*
8
));
}
}
static
void
put_ebml_sint
(
AVIOContext
*
pb
,
unsigned
int
elementid
,
int64_t
val
)
{
int
i
,
bytes
=
1
;
uint64_t
uval
=
(
val
<
0
?
(
-
val
-
1
)
<<
1
:
val
<<
1
);
while
(
uval
>>=
8
)
bytes
++
;
/* make unsigned */
if
(
val
>=
0
)
{
uval
=
val
;
}
else
{
uval
=
0x80
<<
(
bytes
-
1
);
uval
+=
val
;
uval
|=
0x80
<<
(
bytes
-
1
);
}
put_ebml_id
(
pb
,
elementid
);
put_ebml_num
(
pb
,
bytes
,
0
);
for
(
i
=
bytes
-
1
;
i
>=
0
;
i
--
)
avio_w8
(
pb
,
(
uint8_t
)(
uval
>>
i
*
8
));
}
static
void
put_ebml_float
(
AVIOContext
*
pb
,
unsigned
int
elementid
,
double
val
)
static
void
put_ebml_float
(
AVIOContext
*
pb
,
unsigned
int
elementid
,
double
val
)
{
{
put_ebml_id
(
pb
,
elementid
);
put_ebml_id
(
pb
,
elementid
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment