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
ec5a4af5
Commit
ec5a4af5
authored
Mar 02, 2015
by
Mark Reid
Committed by
Michael Niedermayer
Mar 04, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libavformat/mxfdec: refactor reading strong ref array
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
5dce7237
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
39 deletions
+22
-39
mxfdec.c
libavformat/mxfdec.c
+22
-39
No files found.
libavformat/mxfdec.c
View file @
ec5a4af5
...
@@ -671,6 +671,19 @@ static int mxf_read_cryptographic_context(void *arg, AVIOContext *pb, int tag, i
...
@@ -671,6 +671,19 @@ static int mxf_read_cryptographic_context(void *arg, AVIOContext *pb, int tag, i
return
0
;
return
0
;
}
}
static
int
mxf_read_strong_ref_array
(
AVIOContext
*
pb
,
UID
**
refs
,
int
*
count
)
{
*
count
=
avio_rb32
(
pb
);
*
refs
=
av_calloc
(
*
count
,
sizeof
(
UID
));
if
(
!*
refs
)
{
*
count
=
0
;
return
AVERROR
(
ENOMEM
);
}
avio_skip
(
pb
,
4
);
/* useless size of objects, always 16 according to specs */
avio_read
(
pb
,
(
uint8_t
*
)
*
refs
,
*
count
*
sizeof
(
UID
));
return
0
;
}
static
int
mxf_read_content_storage
(
void
*
arg
,
AVIOContext
*
pb
,
int
tag
,
int
size
,
UID
uid
,
int64_t
klv_offset
)
static
int
mxf_read_content_storage
(
void
*
arg
,
AVIOContext
*
pb
,
int
tag
,
int
size
,
UID
uid
,
int64_t
klv_offset
)
{
{
MXFContext
*
mxf
=
arg
;
MXFContext
*
mxf
=
arg
;
...
@@ -679,13 +692,7 @@ static int mxf_read_content_storage(void *arg, AVIOContext *pb, int tag, int siz
...
@@ -679,13 +692,7 @@ static int mxf_read_content_storage(void *arg, AVIOContext *pb, int tag, int siz
if
(
mxf
->
packages_refs
)
if
(
mxf
->
packages_refs
)
av_log
(
mxf
->
fc
,
AV_LOG_VERBOSE
,
"Multiple packages_refs
\n
"
);
av_log
(
mxf
->
fc
,
AV_LOG_VERBOSE
,
"Multiple packages_refs
\n
"
);
av_free
(
mxf
->
packages_refs
);
av_free
(
mxf
->
packages_refs
);
mxf
->
packages_count
=
avio_rb32
(
pb
);
return
mxf_read_strong_ref_array
(
pb
,
&
mxf
->
packages_refs
,
&
mxf
->
packages_count
);
mxf
->
packages_refs
=
av_calloc
(
mxf
->
packages_count
,
sizeof
(
UID
));
if
(
!
mxf
->
packages_refs
)
return
AVERROR
(
ENOMEM
);
avio_skip
(
pb
,
4
);
/* useless size of objects, always 16 according to specs */
avio_read
(
pb
,
(
uint8_t
*
)
mxf
->
packages_refs
,
mxf
->
packages_count
*
sizeof
(
UID
));
break
;
}
}
return
0
;
return
0
;
}
}
...
@@ -775,15 +782,8 @@ static int mxf_read_sequence(void *arg, AVIOContext *pb, int tag, int size, UID
...
@@ -775,15 +782,8 @@ static int mxf_read_sequence(void *arg, AVIOContext *pb, int tag, int size, UID
sequence
->
origin
=
avio_r8
(
pb
);
sequence
->
origin
=
avio_r8
(
pb
);
break
;
break
;
case
0x1001
:
case
0x1001
:
sequence
->
structural_components_count
=
avio_rb32
(
pb
);
return
mxf_read_strong_ref_array
(
pb
,
&
sequence
->
structural_components_refs
,
sequence
->
structural_components_refs
=
av_calloc
(
sequence
->
structural_components_count
,
sizeof
(
UID
));
&
sequence
->
structural_components_count
);
if
(
!
sequence
->
structural_components_refs
)
{
sequence
->
structural_components_count
=
0
;
return
AVERROR
(
ENOMEM
);
}
avio_skip
(
pb
,
4
);
/* useless size of objects, always 16 according to specs */
avio_read
(
pb
,
(
uint8_t
*
)
sequence
->
structural_components_refs
,
sequence
->
structural_components_count
*
sizeof
(
UID
));
break
;
}
}
return
0
;
return
0
;
}
}
...
@@ -796,15 +796,8 @@ static int mxf_read_essence_group(void *arg, AVIOContext *pb, int tag, int size,
...
@@ -796,15 +796,8 @@ static int mxf_read_essence_group(void *arg, AVIOContext *pb, int tag, int size,
essence_group
->
duration
=
avio_rb64
(
pb
);
essence_group
->
duration
=
avio_rb64
(
pb
);
break
;
break
;
case
0x0501
:
case
0x0501
:
essence_group
->
structural_components_count
=
avio_rb32
(
pb
);
return
mxf_read_strong_ref_array
(
pb
,
&
essence_group
->
structural_components_refs
,
essence_group
->
structural_components_refs
=
av_calloc
(
essence_group
->
structural_components_count
,
sizeof
(
UID
));
&
essence_group
->
structural_components_count
);
if
(
!
essence_group
->
structural_components_refs
)
{
essence_group
->
structural_components_count
=
0
;
return
AVERROR
(
ENOMEM
);
}
avio_skip
(
pb
,
4
);
/* useless size of objects, always 16 according to specs */
avio_read
(
pb
,
(
uint8_t
*
)
essence_group
->
structural_components_refs
,
essence_group
->
structural_components_count
*
sizeof
(
UID
));
break
;
}
}
return
0
;
return
0
;
}
}
...
@@ -835,13 +828,8 @@ static int mxf_read_package(void *arg, AVIOContext *pb, int tag, int size, UID u
...
@@ -835,13 +828,8 @@ static int mxf_read_package(void *arg, AVIOContext *pb, int tag, int size, UID u
MXFPackage
*
package
=
arg
;
MXFPackage
*
package
=
arg
;
switch
(
tag
)
{
switch
(
tag
)
{
case
0x4403
:
case
0x4403
:
package
->
tracks_count
=
avio_rb32
(
pb
);
return
mxf_read_strong_ref_array
(
pb
,
&
package
->
tracks_refs
,
package
->
tracks_refs
=
av_calloc
(
package
->
tracks_count
,
sizeof
(
UID
));
&
package
->
tracks_count
);
if
(
!
package
->
tracks_refs
)
return
AVERROR
(
ENOMEM
);
avio_skip
(
pb
,
4
);
/* useless size of objects, always 16 according to specs */
avio_read
(
pb
,
(
uint8_t
*
)
package
->
tracks_refs
,
package
->
tracks_count
*
sizeof
(
UID
));
break
;
case
0x4401
:
case
0x4401
:
/* UMID */
/* UMID */
avio_read
(
pb
,
package
->
package_ul
,
16
);
avio_read
(
pb
,
package
->
package_ul
,
16
);
...
@@ -944,13 +932,8 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int
...
@@ -944,13 +932,8 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int
MXFDescriptor
*
descriptor
=
arg
;
MXFDescriptor
*
descriptor
=
arg
;
switch
(
tag
)
{
switch
(
tag
)
{
case
0x3F01
:
case
0x3F01
:
descriptor
->
sub_descriptors_count
=
avio_rb32
(
pb
);
return
mxf_read_strong_ref_array
(
pb
,
&
descriptor
->
sub_descriptors_refs
,
descriptor
->
sub_descriptors_refs
=
av_calloc
(
descriptor
->
sub_descriptors_count
,
sizeof
(
UID
));
&
descriptor
->
sub_descriptors_count
);
if
(
!
descriptor
->
sub_descriptors_refs
)
return
AVERROR
(
ENOMEM
);
avio_skip
(
pb
,
4
);
/* useless size of objects, always 16 according to specs */
avio_read
(
pb
,
(
uint8_t
*
)
descriptor
->
sub_descriptors_refs
,
descriptor
->
sub_descriptors_count
*
sizeof
(
UID
));
break
;
case
0x3002
:
/* ContainerDuration */
case
0x3002
:
/* ContainerDuration */
descriptor
->
duration
=
avio_rb64
(
pb
);
descriptor
->
duration
=
avio_rb64
(
pb
);
break
;
break
;
...
...
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