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
efcde917
Commit
efcde917
authored
10 years ago
by
Anton Khirnov
Browse files
Options
Downloads
Patches
Plain Diff
vorbiscomment: simplify API by using av_dict_count()
parent
23f741f7
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
libavformat/flacenc.c
+3
-3
3 additions, 3 deletions
libavformat/flacenc.c
libavformat/oggenc.c
+2
-3
2 additions, 3 deletions
libavformat/oggenc.c
libavformat/vorbiscomment.c
+3
-5
3 additions, 5 deletions
libavformat/vorbiscomment.c
libavformat/vorbiscomment.h
+2
-5
2 additions, 5 deletions
libavformat/vorbiscomment.h
with
10 additions
and
16 deletions
libavformat/flacenc.c
+
3
−
3
View file @
efcde917
...
@@ -49,12 +49,12 @@ static int flac_write_block_comment(AVIOContext *pb, AVDictionary **m,
...
@@ -49,12 +49,12 @@ static int flac_write_block_comment(AVIOContext *pb, AVDictionary **m,
int
last_block
,
int
bitexact
)
int
last_block
,
int
bitexact
)
{
{
const
char
*
vendor
=
bitexact
?
"Libav"
:
LIBAVFORMAT_IDENT
;
const
char
*
vendor
=
bitexact
?
"Libav"
:
LIBAVFORMAT_IDENT
;
unsigned
int
len
,
count
;
unsigned
int
len
;
uint8_t
*
p
,
*
p0
;
uint8_t
*
p
,
*
p0
;
ff_metadata_conv
(
m
,
ff_vorbiscomment_metadata_conv
,
NULL
);
ff_metadata_conv
(
m
,
ff_vorbiscomment_metadata_conv
,
NULL
);
len
=
ff_vorbiscomment_length
(
*
m
,
vendor
,
&
count
);
len
=
ff_vorbiscomment_length
(
*
m
,
vendor
);
p0
=
av_malloc
(
len
+
4
);
p0
=
av_malloc
(
len
+
4
);
if
(
!
p0
)
if
(
!
p0
)
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
...
@@ -62,7 +62,7 @@ static int flac_write_block_comment(AVIOContext *pb, AVDictionary **m,
...
@@ -62,7 +62,7 @@ static int flac_write_block_comment(AVIOContext *pb, AVDictionary **m,
bytestream_put_byte
(
&
p
,
last_block
?
0x84
:
0x04
);
bytestream_put_byte
(
&
p
,
last_block
?
0x84
:
0x04
);
bytestream_put_be24
(
&
p
,
len
);
bytestream_put_be24
(
&
p
,
len
);
ff_vorbiscomment_write
(
&
p
,
m
,
vendor
,
count
);
ff_vorbiscomment_write
(
&
p
,
m
,
vendor
);
avio_write
(
pb
,
p0
,
len
+
4
);
avio_write
(
pb
,
p0
,
len
+
4
);
av_freep
(
&
p0
);
av_freep
(
&
p0
);
...
...
This diff is collapsed.
Click to expand it.
libavformat/oggenc.c
+
2
−
3
View file @
efcde917
...
@@ -273,18 +273,17 @@ static uint8_t *ogg_write_vorbiscomment(int offset, int bitexact,
...
@@ -273,18 +273,17 @@ static uint8_t *ogg_write_vorbiscomment(int offset, int bitexact,
const
char
*
vendor
=
bitexact
?
"Libav"
:
LIBAVFORMAT_IDENT
;
const
char
*
vendor
=
bitexact
?
"Libav"
:
LIBAVFORMAT_IDENT
;
int
size
;
int
size
;
uint8_t
*
p
,
*
p0
;
uint8_t
*
p
,
*
p0
;
unsigned
int
count
;
ff_metadata_conv
(
m
,
ff_vorbiscomment_metadata_conv
,
NULL
);
ff_metadata_conv
(
m
,
ff_vorbiscomment_metadata_conv
,
NULL
);
size
=
offset
+
ff_vorbiscomment_length
(
*
m
,
vendor
,
&
count
)
+
framing_bit
;
size
=
offset
+
ff_vorbiscomment_length
(
*
m
,
vendor
)
+
framing_bit
;
p
=
av_mallocz
(
size
);
p
=
av_mallocz
(
size
);
if
(
!
p
)
if
(
!
p
)
return
NULL
;
return
NULL
;
p0
=
p
;
p0
=
p
;
p
+=
offset
;
p
+=
offset
;
ff_vorbiscomment_write
(
&
p
,
m
,
vendor
,
count
);
ff_vorbiscomment_write
(
&
p
,
m
,
vendor
);
if
(
framing_bit
)
if
(
framing_bit
)
bytestream_put_byte
(
&
p
,
1
);
bytestream_put_byte
(
&
p
,
1
);
...
...
This diff is collapsed.
Click to expand it.
libavformat/vorbiscomment.c
+
3
−
5
View file @
efcde917
...
@@ -37,28 +37,26 @@ const AVMetadataConv ff_vorbiscomment_metadata_conv[] = {
...
@@ -37,28 +37,26 @@ const AVMetadataConv ff_vorbiscomment_metadata_conv[] = {
{
0
}
{
0
}
};
};
int
ff_vorbiscomment_length
(
AVDictionary
*
m
,
const
char
*
vendor_string
,
int
ff_vorbiscomment_length
(
AVDictionary
*
m
,
const
char
*
vendor_string
)
unsigned
*
count
)
{
{
int
len
=
8
;
int
len
=
8
;
len
+=
strlen
(
vendor_string
);
len
+=
strlen
(
vendor_string
);
*
count
=
0
;
if
(
m
)
{
if
(
m
)
{
AVDictionaryEntry
*
tag
=
NULL
;
AVDictionaryEntry
*
tag
=
NULL
;
while
((
tag
=
av_dict_get
(
m
,
""
,
tag
,
AV_DICT_IGNORE_SUFFIX
)))
{
while
((
tag
=
av_dict_get
(
m
,
""
,
tag
,
AV_DICT_IGNORE_SUFFIX
)))
{
len
+=
4
+
strlen
(
tag
->
key
)
+
1
+
strlen
(
tag
->
value
);
len
+=
4
+
strlen
(
tag
->
key
)
+
1
+
strlen
(
tag
->
value
);
(
*
count
)
++
;
}
}
}
}
return
len
;
return
len
;
}
}
int
ff_vorbiscomment_write
(
uint8_t
**
p
,
AVDictionary
**
m
,
int
ff_vorbiscomment_write
(
uint8_t
**
p
,
AVDictionary
**
m
,
const
char
*
vendor_string
,
const
unsigned
count
)
const
char
*
vendor_string
)
{
{
bytestream_put_le32
(
p
,
strlen
(
vendor_string
));
bytestream_put_le32
(
p
,
strlen
(
vendor_string
));
bytestream_put_buffer
(
p
,
vendor_string
,
strlen
(
vendor_string
));
bytestream_put_buffer
(
p
,
vendor_string
,
strlen
(
vendor_string
));
if
(
*
m
)
{
if
(
*
m
)
{
int
count
=
av_dict_count
(
*
m
);
AVDictionaryEntry
*
tag
=
NULL
;
AVDictionaryEntry
*
tag
=
NULL
;
bytestream_put_le32
(
p
,
count
);
bytestream_put_le32
(
p
,
count
);
while
((
tag
=
av_dict_get
(
*
m
,
""
,
tag
,
AV_DICT_IGNORE_SUFFIX
)))
{
while
((
tag
=
av_dict_get
(
*
m
,
""
,
tag
,
AV_DICT_IGNORE_SUFFIX
)))
{
...
...
This diff is collapsed.
Click to expand it.
libavformat/vorbiscomment.h
+
2
−
5
View file @
efcde917
...
@@ -32,11 +32,9 @@
...
@@ -32,11 +32,9 @@
* @param m The metadata structure to be parsed. For no metadata, set to NULL.
* @param m The metadata structure to be parsed. For no metadata, set to NULL.
* @param vendor_string The vendor string to be added into the VorbisComment.
* @param vendor_string The vendor string to be added into the VorbisComment.
* For no string, set to an empty string.
* For no string, set to an empty string.
* @param count Pointer to store the number of tags in m because m->count is "not allowed"
* @return The length in bytes.
* @return The length in bytes.
*/
*/
int
ff_vorbiscomment_length
(
AVDictionary
*
m
,
const
char
*
vendor_string
,
int
ff_vorbiscomment_length
(
AVDictionary
*
m
,
const
char
*
vendor_string
);
unsigned
*
count
);
/**
/**
* Write a VorbisComment into a buffer. The buffer, p, must have enough
* Write a VorbisComment into a buffer. The buffer, p, must have enough
...
@@ -47,10 +45,9 @@ int ff_vorbiscomment_length(AVDictionary *m, const char *vendor_string,
...
@@ -47,10 +45,9 @@ int ff_vorbiscomment_length(AVDictionary *m, const char *vendor_string,
* @param p The buffer in which to write.
* @param p The buffer in which to write.
* @param m The metadata struct to write.
* @param m The metadata struct to write.
* @param vendor_string The vendor string to write.
* @param vendor_string The vendor string to write.
* @param count The number of tags in m because m->count is "not allowed"
*/
*/
int
ff_vorbiscomment_write
(
uint8_t
**
p
,
AVDictionary
**
m
,
int
ff_vorbiscomment_write
(
uint8_t
**
p
,
AVDictionary
**
m
,
const
char
*
vendor_string
,
const
unsigned
count
);
const
char
*
vendor_string
);
extern
const
AVMetadataConv
ff_vorbiscomment_metadata_conv
[];
extern
const
AVMetadataConv
ff_vorbiscomment_metadata_conv
[];
...
...
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