Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
b21e6b70
Commit
b21e6b70
authored
13 years ago
by
Tomas Härdin
Committed by
Anton Khirnov
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
wav: parse 'bext' metadata
Signed-off-by:
Anton Khirnov
<
anton@khirnov.net
>
parent
67b1761f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc/general.texi
+1
-1
1 addition, 1 deletion
doc/general.texi
libavformat/wav.c
+101
-0
101 additions, 0 deletions
libavformat/wav.c
with
102 additions
and
1 deletion
doc/general.texi
+
1
−
1
View file @
b21e6b70
...
@@ -66,7 +66,7 @@ library:
...
@@ -66,7 +66,7 @@ library:
@tab Used in Z and Z95 games.
@tab Used in Z and Z95 games.
@item Brute Force
&
Ignorance @tab @tab X
@item Brute Force
&
Ignorance @tab @tab X
@tab Used in the game Flash Traffic: City of Angels.
@tab Used in the game Flash Traffic: City of Angels.
@item BWF @tab X @tab
@item BWF @tab X @tab
X
@item Interplay C93 @tab @tab X
@item Interplay C93 @tab @tab X
@tab Used in the game Cyberia from Interplay.
@tab Used in the game Cyberia from Interplay.
@item Delphine Software International CIN @tab @tab X
@item Delphine Software International CIN @tab @tab X
...
...
This diff is collapsed.
Click to expand it.
libavformat/wav.c
+
101
−
0
View file @
b21e6b70
...
@@ -23,6 +23,8 @@
...
@@ -23,6 +23,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
*/
#include
"libavutil/avassert.h"
#include
"libavutil/dict.h"
#include
"libavutil/log.h"
#include
"libavutil/log.h"
#include
"libavutil/mathematics.h"
#include
"libavutil/mathematics.h"
#include
"libavutil/opt.h"
#include
"libavutil/opt.h"
...
@@ -32,6 +34,7 @@
...
@@ -32,6 +34,7 @@
#include
"riff.h"
#include
"riff.h"
#include
"avio.h"
#include
"avio.h"
#include
"avio_internal.h"
#include
"avio_internal.h"
#include
"metadata.h"
typedef
struct
{
typedef
struct
{
const
AVClass
*
class
;
const
AVClass
*
class
;
...
@@ -284,6 +287,97 @@ static int wav_parse_fmt_tag(AVFormatContext *s, int64_t size, AVStream **st)
...
@@ -284,6 +287,97 @@ static int wav_parse_fmt_tag(AVFormatContext *s, int64_t size, AVStream **st)
return
0
;
return
0
;
}
}
static
inline
int
wav_parse_bext_string
(
AVFormatContext
*
s
,
const
char
*
key
,
int
length
)
{
char
temp
[
257
];
int
ret
;
av_assert0
(
length
<=
sizeof
(
temp
));
if
((
ret
=
avio_read
(
s
->
pb
,
temp
,
length
))
<
0
)
return
ret
;
temp
[
length
]
=
0
;
if
(
strlen
(
temp
))
return
av_dict_set
(
&
s
->
metadata
,
key
,
temp
,
0
);
return
0
;
}
static
int
wav_parse_bext_tag
(
AVFormatContext
*
s
,
int64_t
size
)
{
char
temp
[
131
],
*
coding_history
;
int
ret
,
x
;
uint64_t
time_reference
;
int64_t
umid_parts
[
8
],
umid_mask
=
0
;
if
((
ret
=
wav_parse_bext_string
(
s
,
"description"
,
256
))
<
0
||
(
ret
=
wav_parse_bext_string
(
s
,
"originator"
,
32
))
<
0
||
(
ret
=
wav_parse_bext_string
(
s
,
"originator_reference"
,
32
))
<
0
||
(
ret
=
wav_parse_bext_string
(
s
,
"origination_date"
,
10
))
<
0
||
(
ret
=
wav_parse_bext_string
(
s
,
"origination_time"
,
8
))
<
0
)
return
ret
;
time_reference
=
avio_rl64
(
s
->
pb
);
snprintf
(
temp
,
sizeof
(
temp
),
"%"
PRIu64
,
time_reference
);
if
((
ret
=
av_dict_set
(
&
s
->
metadata
,
"time_reference"
,
temp
,
0
))
<
0
)
return
ret
;
/* check if version is >= 1, in which case an UMID may be present */
if
(
avio_rl16
(
s
->
pb
)
>=
1
)
{
for
(
x
=
0
;
x
<
8
;
x
++
)
umid_mask
|=
umid_parts
[
x
]
=
avio_rb64
(
s
->
pb
);
if
(
umid_mask
)
{
/* the string formatting below is per SMPTE 330M-2004 Annex C */
if
(
umid_parts
[
4
]
==
0
&&
umid_parts
[
5
]
==
0
&&
umid_parts
[
6
]
==
0
&&
umid_parts
[
7
]
==
0
)
{
/* basic UMID */
snprintf
(
temp
,
sizeof
(
temp
),
"0x%016"
PRIX64
"%016"
PRIX64
"%016"
PRIX64
"%016"
PRIX64
,
umid_parts
[
0
],
umid_parts
[
1
],
umid_parts
[
2
],
umid_parts
[
3
]);
}
else
{
/* extended UMID */
snprintf
(
temp
,
sizeof
(
temp
),
"0x%016"
PRIX64
"%016"
PRIX64
"%016"
PRIX64
"%016"
PRIX64
"0x%016"
PRIX64
"%016"
PRIX64
"%016"
PRIX64
"%016"
PRIX64
,
umid_parts
[
0
],
umid_parts
[
1
],
umid_parts
[
2
],
umid_parts
[
3
],
umid_parts
[
4
],
umid_parts
[
5
],
umid_parts
[
6
],
umid_parts
[
7
]);
}
if
((
ret
=
av_dict_set
(
&
s
->
metadata
,
"umid"
,
temp
,
0
))
<
0
)
return
ret
;
}
avio_skip
(
s
->
pb
,
190
);
}
else
avio_skip
(
s
->
pb
,
254
);
if
(
size
>
602
)
{
/* CodingHistory present */
size
-=
602
;
if
(
!
(
coding_history
=
av_malloc
(
size
+
1
)))
return
AVERROR
(
ENOMEM
);
if
((
ret
=
avio_read
(
s
->
pb
,
coding_history
,
size
))
<
0
)
return
ret
;
coding_history
[
size
]
=
0
;
if
((
ret
=
av_dict_set
(
&
s
->
metadata
,
"coding_history"
,
coding_history
,
AV_METADATA_DONT_STRDUP_VAL
))
<
0
)
return
ret
;
}
return
0
;
}
static
const
AVMetadataConv
wav_metadata_conv
[]
=
{
{
"description"
,
"comment"
},
{
"originator"
,
"encoded_by"
},
{
"origination_date"
,
"date"
},
{
"origination_time"
,
"creation_time"
},
{
0
},
};
/* wav input */
/* wav input */
static
int
wav_read_header
(
AVFormatContext
*
s
,
static
int
wav_read_header
(
AVFormatContext
*
s
,
AVFormatParameters
*
ap
)
AVFormatParameters
*
ap
)
...
@@ -369,6 +463,10 @@ static int wav_read_header(AVFormatContext *s,
...
@@ -369,6 +463,10 @@ static int wav_read_header(AVFormatContext *s,
if
(
!
sample_count
)
if
(
!
sample_count
)
sample_count
=
avio_rl32
(
pb
);
sample_count
=
avio_rl32
(
pb
);
break
;
break
;
case
MKTAG
(
'b'
,
'e'
,
'x'
,
't'
):
if
((
ret
=
wav_parse_bext_tag
(
s
,
size
))
<
0
)
return
ret
;
break
;
}
}
/* seek to next tag unless we know that we'll run into EOF */
/* seek to next tag unless we know that we'll run into EOF */
...
@@ -389,6 +487,9 @@ break_loop:
...
@@ -389,6 +487,9 @@ break_loop:
sample_count
=
(
data_size
<<
3
)
/
(
st
->
codec
->
channels
*
(
uint64_t
)
av_get_bits_per_sample
(
st
->
codec
->
codec_id
));
sample_count
=
(
data_size
<<
3
)
/
(
st
->
codec
->
channels
*
(
uint64_t
)
av_get_bits_per_sample
(
st
->
codec
->
codec_id
));
if
(
sample_count
)
if
(
sample_count
)
st
->
duration
=
sample_count
;
st
->
duration
=
sample_count
;
ff_metadata_conv_ctx
(
s
,
NULL
,
wav_metadata_conv
);
return
0
;
return
0
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment