Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
751549af
Unverified
Commit
751549af
authored
Jun 02, 2022
by
Pierre-Anthony Lemieux
Committed by
Zane van Iperen
Jun 12, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/imf: refactor to use avutil/uuid
parent
1fd67581
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
78 deletions
+52
-78
imf.h
libavformat/imf.h
+5
-13
imf_cpl.c
libavformat/imf_cpl.c
+21
-39
imfdec.c
libavformat/imfdec.c
+17
-17
imf.c
libavformat/tests/imf.c
+9
-9
No files found.
libavformat/imf.h
View file @
751549af
...
...
@@ -58,17 +58,9 @@
#include "avformat.h"
#include "libavformat/avio.h"
#include "libavutil/rational.h"
#include "libavutil/uuid.h"
#include <libxml/tree.h>
#define FF_IMF_UUID_FORMAT \
"urn:uuid:%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-" \
"%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
/**
* UUID as defined in IETF RFC 422
*/
typedef
uint8_t
FFIMFUUID
[
16
];
/**
* IMF Composition Playlist Base Resource
*/
...
...
@@ -84,7 +76,7 @@ typedef struct FFIMFBaseResource {
*/
typedef
struct
FFIMFTrackFileResource
{
FFIMFBaseResource
base
;
FFIMF
UUID
track_file_uuid
;
/**< TrackFileResourceType/TrackFileId */
AV
UUID
track_file_uuid
;
/**< TrackFileResourceType/TrackFileId */
}
FFIMFTrackFileResource
;
/**
...
...
@@ -109,7 +101,7 @@ typedef struct FFIMFMarkerResource {
* IMF Composition Playlist Virtual Track
*/
typedef
struct
FFIMFBaseVirtualTrack
{
FFIMF
UUID
id_uuid
;
/**< TrackId associated with the Virtual Track */
AV
UUID
id_uuid
;
/**< TrackId associated with the Virtual Track */
}
FFIMFBaseVirtualTrack
;
/**
...
...
@@ -135,7 +127,7 @@ typedef struct FFIMFMarkerVirtualTrack {
* IMF Composition Playlist
*/
typedef
struct
FFIMFCPL
{
FFIMF
UUID
id_uuid
;
/**< CompositionPlaylist/Id element */
AV
UUID
id_uuid
;
/**< CompositionPlaylist/Id element */
xmlChar
*
content_title_utf8
;
/**< CompositionPlaylist/ContentTitle element */
AVRational
edit_rate
;
/**< CompositionPlaylist/EditRate element */
FFIMFMarkerVirtualTrack
*
main_markers_track
;
/**< Main Marker Virtual Track */
...
...
@@ -196,7 +188,7 @@ int ff_imf_xml_read_rational(xmlNodePtr element, AVRational *rational);
* Reads a UUID from an XML element
* @return 0 on success, < 0 AVERROR code on error.
*/
int
ff_imf_xml_read_uuid
(
xmlNodePtr
element
,
uint8_t
uuid
[
16
]
);
int
ff_imf_xml_read_uuid
(
xmlNodePtr
element
,
AVUUID
uuid
);
/**
* Returns the first child element with the specified local name
...
...
libavformat/imf_cpl.c
View file @
751549af
...
...
@@ -70,32 +70,14 @@ xmlNodePtr ff_imf_xml_get_child_element_by_name(xmlNodePtr parent, const char *n
return
NULL
;
}
int
ff_imf_xml_read_uuid
(
xmlNodePtr
element
,
uint8_t
uuid
[
16
]
)
int
ff_imf_xml_read_uuid
(
xmlNodePtr
element
,
AVUUID
uuid
)
{
xmlChar
*
element_text
=
NULL
;
int
scanf_ret
;
int
ret
=
0
;
element_text
=
xmlNodeListGetString
(
element
->
doc
,
element
->
xmlChildrenNode
,
1
);
scanf_ret
=
sscanf
(
element_text
,
FF_IMF_UUID_FORMAT
,
&
uuid
[
0
],
&
uuid
[
1
],
&
uuid
[
2
],
&
uuid
[
3
],
&
uuid
[
4
],
&
uuid
[
5
],
&
uuid
[
6
],
&
uuid
[
7
],
&
uuid
[
8
],
&
uuid
[
9
],
&
uuid
[
10
],
&
uuid
[
11
],
&
uuid
[
12
],
&
uuid
[
13
],
&
uuid
[
14
],
&
uuid
[
15
]);
if
(
scanf_ret
!=
16
)
{
ret
=
av_uuid_urn_parse
(
element_text
,
uuid
);
if
(
ret
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Invalid UUID
\n
"
);
ret
=
AVERROR_INVALIDDATA
;
}
...
...
@@ -370,7 +352,7 @@ static int fill_marker_resource(xmlNodePtr marker_resource_elem,
static
int
push_marker_sequence
(
xmlNodePtr
marker_sequence_elem
,
FFIMFCPL
*
cpl
)
{
int
ret
=
0
;
uint8_t
uuid
[
16
]
;
AVUUID
uuid
;
xmlNodePtr
resource_list_elem
=
NULL
;
xmlNodePtr
resource_elem
=
NULL
;
xmlNodePtr
track_id_elem
=
NULL
;
...
...
@@ -388,8 +370,8 @@ static int push_marker_sequence(xmlNodePtr marker_sequence_elem, FFIMFCPL *cpl)
}
av_log
(
NULL
,
AV_LOG_DEBUG
,
"Processing IMF CPL Marker Sequence for Virtual Track "
FF_IMF_UUID_FORMAT
"
\n
"
,
UID_ARG
(
uuid
));
"Processing IMF CPL Marker Sequence for Virtual Track "
AV_PRI_UUID
"
\n
"
,
AV_U
UID_ARG
(
uuid
));
/* create main marker virtual track if it does not exist */
if
(
!
cpl
->
main_markers_track
)
{
...
...
@@ -397,9 +379,9 @@ static int push_marker_sequence(xmlNodePtr marker_sequence_elem, FFIMFCPL *cpl)
if
(
!
cpl
->
main_markers_track
)
return
AVERROR
(
ENOMEM
);
imf_marker_virtual_track_init
(
cpl
->
main_markers_track
);
memcpy
(
cpl
->
main_markers_track
->
base
.
id_uuid
,
uuid
,
sizeof
(
uuid
)
);
av_uuid_copy
(
cpl
->
main_markers_track
->
base
.
id_uuid
,
uuid
);
}
else
if
(
memcmp
(
cpl
->
main_markers_track
->
base
.
id_uuid
,
uuid
,
sizeof
(
uuid
))
!=
0
)
{
}
else
if
(
!
av_uuid_equal
(
cpl
->
main_markers_track
->
base
.
id_uuid
,
uuid
)
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Multiple marker virtual tracks were found
\n
"
);
return
AVERROR_INVALIDDATA
;
}
...
...
@@ -457,7 +439,7 @@ static int has_stereo_resources(xmlNodePtr element)
static
int
push_main_audio_sequence
(
xmlNodePtr
audio_sequence_elem
,
FFIMFCPL
*
cpl
)
{
int
ret
=
0
;
uint8_t
uuid
[
16
]
;
AVUUID
uuid
;
xmlNodePtr
resource_list_elem
=
NULL
;
xmlNodePtr
resource_elem
=
NULL
;
xmlNodePtr
track_id_elem
=
NULL
;
...
...
@@ -476,12 +458,12 @@ static int push_main_audio_sequence(xmlNodePtr audio_sequence_elem, FFIMFCPL *cp
}
av_log
(
NULL
,
AV_LOG_DEBUG
,
"Processing IMF CPL Audio Sequence for Virtual Track "
FF_IMF_UUID_FORMAT
"
\n
"
,
UID_ARG
(
uuid
));
"Processing IMF CPL Audio Sequence for Virtual Track "
AV_PRI_UUID
"
\n
"
,
AV_U
UID_ARG
(
uuid
));
/* get the main audio virtual track corresponding to the sequence */
for
(
uint32_t
i
=
0
;
i
<
cpl
->
main_audio_track_count
;
i
++
)
{
if
(
memcmp
(
cpl
->
main_audio_tracks
[
i
].
base
.
id_uuid
,
uuid
,
sizeof
(
uuid
))
==
0
)
{
if
(
av_uuid_equal
(
cpl
->
main_audio_tracks
[
i
].
base
.
id_uuid
,
uuid
)
)
{
vt
=
&
cpl
->
main_audio_tracks
[
i
];
break
;
}
...
...
@@ -501,7 +483,7 @@ static int push_main_audio_sequence(xmlNodePtr audio_sequence_elem, FFIMFCPL *cp
vt
=
&
cpl
->
main_audio_tracks
[
cpl
->
main_audio_track_count
];
imf_trackfile_virtual_track_init
(
vt
);
cpl
->
main_audio_track_count
++
;
memcpy
(
vt
->
base
.
id_uuid
,
uuid
,
sizeof
(
uuid
)
);
av_uuid_copy
(
vt
->
base
.
id_uuid
,
uuid
);
}
/* process resources */
...
...
@@ -544,7 +526,7 @@ static int push_main_audio_sequence(xmlNodePtr audio_sequence_elem, FFIMFCPL *cp
static
int
push_main_image_2d_sequence
(
xmlNodePtr
image_sequence_elem
,
FFIMFCPL
*
cpl
)
{
int
ret
=
0
;
uint8_t
uuid
[
16
]
;
AVUUID
uuid
;
xmlNodePtr
resource_list_elem
=
NULL
;
xmlNodePtr
resource_elem
=
NULL
;
xmlNodePtr
track_id_elem
=
NULL
;
...
...
@@ -573,16 +555,16 @@ static int push_main_image_2d_sequence(xmlNodePtr image_sequence_elem, FFIMFCPL
if
(
!
cpl
->
main_image_2d_track
)
return
AVERROR
(
ENOMEM
);
imf_trackfile_virtual_track_init
(
cpl
->
main_image_2d_track
);
memcpy
(
cpl
->
main_image_2d_track
->
base
.
id_uuid
,
uuid
,
sizeof
(
uuid
)
);
av_uuid_copy
(
cpl
->
main_image_2d_track
->
base
.
id_uuid
,
uuid
);
}
else
if
(
memcmp
(
cpl
->
main_image_2d_track
->
base
.
id_uuid
,
uuid
,
sizeof
(
uuid
))
!=
0
)
{
}
else
if
(
!
av_uuid_equal
(
cpl
->
main_image_2d_track
->
base
.
id_uuid
,
uuid
)
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Multiple MainImage virtual tracks found
\n
"
);
return
AVERROR_INVALIDDATA
;
}
av_log
(
NULL
,
AV_LOG_DEBUG
,
"Processing IMF CPL Main Image Sequence for Virtual Track "
FF_IMF_UUID_FORMAT
"
\n
"
,
UID_ARG
(
uuid
));
"Processing IMF CPL Main Image Sequence for Virtual Track "
AV_PRI_UUID
"
\n
"
,
AV_U
UID_ARG
(
uuid
));
/* process resources */
resource_list_elem
=
ff_imf_xml_get_child_element_by_name
(
image_sequence_elem
,
"ResourceList"
);
...
...
@@ -746,7 +728,7 @@ static void imf_trackfile_virtual_track_free(FFIMFTrackFileVirtualTrack *vt)
static
void
imf_cpl_init
(
FFIMFCPL
*
cpl
)
{
memset
(
cpl
->
id_uuid
,
0
,
sizeof
(
cpl
->
id_uuid
)
);
av_uuid_nil
(
cpl
->
id_uuid
);
cpl
->
content_title_utf8
=
NULL
;
cpl
->
edit_rate
=
av_make_q
(
0
,
1
);
cpl
->
main_markers_track
=
NULL
;
...
...
@@ -828,8 +810,8 @@ int ff_imf_parse_cpl(AVIOContext *in, FFIMFCPL **cpl)
(
*
cpl
)
->
content_title_utf8
);
av_log
(
NULL
,
AV_LOG_INFO
,
"IMF CPL Id: "
FF_IMF_UUID_FORMAT
"
\n
"
,
UID_ARG
((
*
cpl
)
->
id_uuid
));
"IMF CPL Id: "
AV_PRI_UUID
"
\n
"
,
AV_U
UID_ARG
((
*
cpl
)
->
id_uuid
));
}
xmlFreeDoc
(
doc
);
...
...
libavformat/imfdec.c
View file @
751549af
...
...
@@ -82,7 +82,7 @@
* IMF Asset locator
*/
typedef
struct
IMFAssetLocator
{
FFIMF
UUID
uuid
;
AV
UUID
uuid
;
char
*
absolute_uri
;
}
IMFAssetLocator
;
...
...
@@ -238,7 +238,7 @@ static int parse_imf_asset_map_from_xml_dom(AVFormatContext *s,
return
AVERROR_INVALIDDATA
;
}
av_log
(
s
,
AV_LOG_DEBUG
,
"Found asset id: "
FF_IMF_UUID_FORMAT
"
\n
"
,
UID_ARG
(
asset
->
uuid
));
av_log
(
s
,
AV_LOG_DEBUG
,
"Found asset id: "
AV_PRI_URN_UUID
"
\n
"
,
AV_U
UID_ARG
(
asset
->
uuid
));
if
(
!
(
node
=
ff_imf_xml_get_child_element_by_name
(
asset_element
,
"ChunkList"
)))
{
av_log
(
s
,
AV_LOG_ERROR
,
"Unable to parse asset map XML - missing ChunkList node
\n
"
);
...
...
@@ -343,7 +343,7 @@ clean_up:
return
ret
;
}
static
IMFAssetLocator
*
find_asset_map_locator
(
IMFAssetLocatorMap
*
asset_map
,
FFIMF
UUID
uuid
)
static
IMFAssetLocator
*
find_asset_map_locator
(
IMFAssetLocatorMap
*
asset_map
,
AV
UUID
uuid
)
{
for
(
uint32_t
i
=
0
;
i
<
asset_map
->
asset_count
;
i
++
)
{
if
(
memcmp
(
asset_map
->
assets
[
i
].
uuid
,
uuid
,
16
)
==
0
)
...
...
@@ -453,15 +453,15 @@ static int open_track_file_resource(AVFormatContext *s,
asset_locator
=
find_asset_map_locator
(
&
c
->
asset_locator_map
,
track_file_resource
->
track_file_uuid
);
if
(
!
asset_locator
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Could not find asset locator for UUID: "
FF_IMF_UUID_FORMAT
"
\n
"
,
UID_ARG
(
track_file_resource
->
track_file_uuid
));
av_log
(
s
,
AV_LOG_ERROR
,
"Could not find asset locator for UUID: "
AV_PRI_URN_UUID
"
\n
"
,
AV_U
UID_ARG
(
track_file_resource
->
track_file_uuid
));
return
AVERROR_INVALIDDATA
;
}
av_log
(
s
,
AV_LOG_DEBUG
,
"Found locator for "
FF_IMF_UUID_FORMAT
": %s
\n
"
,
UID_ARG
(
asset_locator
->
uuid
),
"Found locator for "
AV_PRI_URN_UUID
": %s
\n
"
,
AV_U
UID_ARG
(
asset_locator
->
uuid
),
asset_locator
->
absolute_uri
);
if
(
track
->
resource_count
>
INT32_MAX
-
track_file_resource
->
base
.
repeat_count
...
...
@@ -523,14 +523,14 @@ static int open_virtual_track(AVFormatContext *s,
for
(
uint32_t
i
=
0
;
i
<
virtual_track
->
resource_count
;
i
++
)
{
av_log
(
s
,
AV_LOG_DEBUG
,
"Open stream from file "
FF_IMF_UUID_FORMAT
", stream %d
\n
"
,
UID_ARG
(
virtual_track
->
resources
[
i
].
track_file_uuid
),
"Open stream from file "
AV_PRI_URN_UUID
", stream %d
\n
"
,
AV_U
UID_ARG
(
virtual_track
->
resources
[
i
].
track_file_uuid
),
i
);
if
((
ret
=
open_track_file_resource
(
s
,
&
virtual_track
->
resources
[
i
],
track
))
!=
0
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Could not open image track resource "
FF_IMF_UUID_FORMAT
"
\n
"
,
UID_ARG
(
virtual_track
->
resources
[
i
].
track_file_uuid
));
"Could not open image track resource "
AV_PRI_URN_UUID
"
\n
"
,
AV_U
UID_ARG
(
virtual_track
->
resources
[
i
].
track_file_uuid
));
goto
clean_up
;
}
}
...
...
@@ -604,16 +604,16 @@ static int open_cpl_tracks(AVFormatContext *s)
if
(
c
->
cpl
->
main_image_2d_track
)
{
if
((
ret
=
open_virtual_track
(
s
,
c
->
cpl
->
main_image_2d_track
,
track_index
++
))
!=
0
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Could not open image track "
FF_IMF_UUID_FORMAT
"
\n
"
,
UID_ARG
(
c
->
cpl
->
main_image_2d_track
->
base
.
id_uuid
));
av_log
(
s
,
AV_LOG_ERROR
,
"Could not open image track "
AV_PRI_URN_UUID
"
\n
"
,
AV_U
UID_ARG
(
c
->
cpl
->
main_image_2d_track
->
base
.
id_uuid
));
return
ret
;
}
}
for
(
uint32_t
i
=
0
;
i
<
c
->
cpl
->
main_audio_track_count
;
i
++
)
{
if
((
ret
=
open_virtual_track
(
s
,
&
c
->
cpl
->
main_audio_tracks
[
i
],
track_index
++
))
!=
0
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Could not open audio track "
FF_IMF_UUID_FORMAT
"
\n
"
,
UID_ARG
(
c
->
cpl
->
main_audio_tracks
[
i
].
base
.
id_uuid
));
av_log
(
s
,
AV_LOG_ERROR
,
"Could not open audio track "
AV_PRI_URN_UUID
"
\n
"
,
AV_U
UID_ARG
(
c
->
cpl
->
main_audio_tracks
[
i
].
base
.
id_uuid
));
return
ret
;
}
}
...
...
@@ -647,8 +647,8 @@ static int imf_read_header(AVFormatContext *s)
av_log
(
s
,
AV_LOG_DEBUG
,
"parsed IMF CPL: "
FF_IMF_UUID_FORMAT
"
\n
"
,
UID_ARG
(
c
->
cpl
->
id_uuid
));
"parsed IMF CPL: "
AV_PRI_URN_UUID
"
\n
"
,
AV_U
UID_ARG
(
c
->
cpl
->
id_uuid
));
if
(
!
c
->
asset_map_paths
)
{
c
->
asset_map_paths
=
av_append_path_component
(
c
->
base_url
,
"ASSETMAP.xml"
);
...
...
libavformat/tests/imf.c
View file @
751549af
...
...
@@ -304,7 +304,7 @@ static int test_cpl_parsing(void)
}
printf
(
"%s
\n
"
,
cpl
->
content_title_utf8
);
printf
(
FF_IMF_UUID_FORMAT
"
\n
"
,
UID_ARG
(
cpl
->
id_uuid
));
printf
(
AV_PRI_URN_UUID
"
\n
"
,
AV_U
UID_ARG
(
cpl
->
id_uuid
));
printf
(
"%i %i
\n
"
,
cpl
->
edit_rate
.
num
,
cpl
->
edit_rate
.
den
);
printf
(
"Marker resource count: %"
PRIu32
"
\n
"
,
cpl
->
main_markers_track
->
resource_count
);
...
...
@@ -320,7 +320,7 @@ static int test_cpl_parsing(void)
printf
(
"Main image resource count: %"
PRIu32
"
\n
"
,
cpl
->
main_image_2d_track
->
resource_count
);
for
(
uint32_t
i
=
0
;
i
<
cpl
->
main_image_2d_track
->
resource_count
;
i
++
)
{
printf
(
"Track file resource %"
PRIu32
"
\n
"
,
i
);
printf
(
" "
FF_IMF_UUID_FORMAT
"
\n
"
,
UID_ARG
(
cpl
->
main_image_2d_track
->
resources
[
i
].
track_file_uuid
));
printf
(
" "
AV_PRI_URN_UUID
"
\n
"
,
AV_U
UID_ARG
(
cpl
->
main_image_2d_track
->
resources
[
i
].
track_file_uuid
));
}
printf
(
"Main audio track count: %"
PRIu32
"
\n
"
,
cpl
->
main_audio_track_count
);
...
...
@@ -329,7 +329,7 @@ static int test_cpl_parsing(void)
printf
(
" Main audio resource count: %"
PRIu32
"
\n
"
,
cpl
->
main_audio_tracks
[
i
].
resource_count
);
for
(
uint32_t
j
=
0
;
j
<
cpl
->
main_audio_tracks
[
i
].
resource_count
;
j
++
)
{
printf
(
" Track file resource %"
PRIu32
"
\n
"
,
j
);
printf
(
" "
FF_IMF_UUID_FORMAT
"
\n
"
,
UID_ARG
(
cpl
->
main_audio_tracks
[
i
].
resources
[
j
].
track_file_uuid
));
printf
(
" "
AV_PRI_URN_UUID
"
\n
"
,
AV_U
UID_ARG
(
cpl
->
main_audio_tracks
[
i
].
resources
[
j
].
track_file_uuid
));
}
}
...
...
@@ -363,15 +363,15 @@ static int test_bad_cpl_parsing(void)
static
int
check_asset_locator_attributes
(
IMFAssetLocator
*
asset
,
IMFAssetLocator
*
expected_asset
)
{
printf
(
"
\t
Compare "
FF_IMF_UUID_FORMAT
" to "
FF_IMF_UUID_FORMAT
".
\n
"
,
UID_ARG
(
asset
->
uuid
),
UID_ARG
(
expected_asset
->
uuid
));
printf
(
"
\t
Compare "
AV_PRI_URN_UUID
" to "
AV_PRI_URN_UUID
".
\n
"
,
AV_U
UID_ARG
(
asset
->
uuid
),
AV_U
UID_ARG
(
expected_asset
->
uuid
));
for
(
uint32_t
i
=
0
;
i
<
16
;
++
i
)
{
if
(
asset
->
uuid
[
i
]
!=
expected_asset
->
uuid
[
i
])
{
printf
(
"Invalid asset locator UUID: found "
FF_IMF_UUID_FORMAT
" instead of "
FF_IMF_UUID_FORMAT
" expected.
\n
"
,
UID_ARG
(
asset
->
uuid
),
UID_ARG
(
expected_asset
->
uuid
));
printf
(
"Invalid asset locator UUID: found "
AV_PRI_URN_UUID
" instead of "
AV_PRI_URN_UUID
" expected.
\n
"
,
AV_U
UID_ARG
(
asset
->
uuid
),
AV_U
UID_ARG
(
expected_asset
->
uuid
));
return
1
;
}
}
...
...
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