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
f610a9f2
Commit
f610a9f2
authored
Feb 28, 2009
by
Aurelien Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a metadata conversion API
Originally committed as revision 17670 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
efd8c1f6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
2 deletions
+70
-2
avformat.h
libavformat/avformat.h
+16
-2
metadata.c
libavformat/metadata.c
+49
-0
metadata.h
libavformat/metadata.h
+5
-0
No files found.
libavformat/avformat.h
View file @
f610a9f2
...
...
@@ -46,6 +46,8 @@ unsigned avformat_version(void);
#include "avio.h"
struct
AVFormatContext
;
/*
* Public Metadata API.
...
...
@@ -77,6 +79,7 @@ typedef struct {
}
AVMetadataTag
;
typedef
struct
AVMetadata
AVMetadata
;
typedef
struct
AVMetadataConv
AVMetadataConv
;
/**
* Gets a metadata element with matching key.
...
...
@@ -95,6 +98,15 @@ av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int f
*/
int
av_metadata_set
(
AVMetadata
**
pm
,
const
char
*
key
,
const
char
*
value
);
/**
* Convert all the metadata sets from ctx according to the source and
* destination conversion tables.
* @param d_conv destination tags format conversion table
* @param s_conv source tags format conversion table
*/
void
av_metadata_conv
(
struct
AVFormatContext
*
ctx
,
const
AVMetadataConv
*
d_conv
,
const
AVMetadataConv
*
s_conv
);
/**
* Frees all the memory allocated for an AVMetadata struct.
*/
...
...
@@ -220,8 +232,6 @@ typedef struct AVFrac {
struct
AVCodecTag
;
struct
AVFormatContext
;
/** This structure contains the data a format has to probe a file. */
typedef
struct
AVProbeData
{
const
char
*
filename
;
...
...
@@ -299,6 +309,8 @@ typedef struct AVOutputFormat {
enum
CodecID
subtitle_codec
;
/**< default subtitle codec */
AVMetadataConv
*
metadata_conv
;
/* private fields */
struct
AVOutputFormat
*
next
;
}
AVOutputFormat
;
...
...
@@ -378,6 +390,8 @@ typedef struct AVInputFormat {
*/
int
(
*
read_seek2
)(
struct
AVFormatContext
*
s
,
int
stream_index
,
int64_t
min_ts
,
int64_t
ts
,
int64_t
max_ts
,
int
flags
);
AVMetadataConv
*
metadata_conv
;
/* private fields */
struct
AVInputFormat
*
next
;
}
AVInputFormat
;
...
...
libavformat/metadata.c
View file @
f610a9f2
...
...
@@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <strings.h>
#include "avformat.h"
#include "metadata.h"
AVMetadataTag
*
...
...
@@ -89,3 +91,50 @@ void av_metadata_free(AVMetadata **pm)
}
av_freep
(
pm
);
}
static
void
metadata_conv
(
AVMetadata
**
pm
,
const
AVMetadataConv
*
d_conv
,
const
AVMetadataConv
*
s_conv
)
{
/* TODO: use binary search to look up the two conversion tables
if the tables are getting big enough that it would matter speed wise */
const
AVMetadataConv
*
s_conv1
=
s_conv
,
*
d_conv1
=
d_conv
,
*
sc
,
*
dc
;
AVMetadataTag
*
mtag
=
NULL
;
AVMetadata
*
dst
=
NULL
;
const
char
*
key
,
*
key2
;
while
((
mtag
=
av_metadata_get
(
*
pm
,
""
,
mtag
,
AV_METADATA_IGNORE_SUFFIX
)))
{
key
=
key2
=
mtag
->
key
;
if
(
s_conv
!=
d_conv
)
{
if
(
!
s_conv
)
s_conv1
=
(
const
AVMetadataConv
[
2
]){{
key
,
key
}};
for
(
sc
=
s_conv1
;
sc
->
native
;
sc
++
)
if
(
!
strcasecmp
(
key
,
sc
->
native
))
{
key2
=
sc
->
generic
;
break
;
}
if
(
!
d_conv
)
d_conv1
=
(
const
AVMetadataConv
[
2
]){{
key2
,
key2
}};
for
(
dc
=
d_conv1
;
dc
->
native
;
dc
++
)
if
(
!
strcasecmp
(
key2
,
dc
->
generic
))
{
key
=
dc
->
native
;
break
;
}
}
av_metadata_set
(
&
dst
,
key
,
mtag
->
value
);
}
av_metadata_free
(
pm
);
*
pm
=
dst
;
}
void
av_metadata_conv
(
AVFormatContext
*
ctx
,
const
AVMetadataConv
*
d_conv
,
const
AVMetadataConv
*
s_conv
)
{
int
i
;
metadata_conv
(
&
ctx
->
metadata
,
d_conv
,
s_conv
);
for
(
i
=
0
;
i
<
ctx
->
nb_streams
;
i
++
)
metadata_conv
(
&
ctx
->
streams
[
i
]
->
metadata
,
d_conv
,
s_conv
);
for
(
i
=
0
;
i
<
ctx
->
nb_chapters
;
i
++
)
metadata_conv
(
&
ctx
->
chapters
[
i
]
->
metadata
,
d_conv
,
s_conv
);
for
(
i
=
0
;
i
<
ctx
->
nb_programs
;
i
++
)
metadata_conv
(
&
ctx
->
programs
[
i
]
->
metadata
,
d_conv
,
s_conv
);
}
libavformat/metadata.h
View file @
f610a9f2
...
...
@@ -35,6 +35,11 @@ struct AVMetadata{
AVMetadataTag
*
elems
;
};
struct
AVMetadataConv
{
const
char
*
native
;
const
char
*
generic
;
};
#if LIBAVFORMAT_VERSION_MAJOR < 53
void
ff_metadata_demux_compat
(
AVFormatContext
*
s
);
void
ff_metadata_mux_compat
(
AVFormatContext
*
s
);
...
...
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