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
4227e4fe
Commit
4227e4fe
authored
Nov 14, 2014
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavf: add a convenience function for adding side data to a stream
parent
728685f3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
22 deletions
+47
-22
internal.h
libavformat/internal.h
+7
-0
replaygain.c
libavformat/replaygain.c
+3
-22
utils.c
libavformat/utils.c
+37
-0
No files found.
libavformat/internal.h
View file @
4227e4fe
...
...
@@ -366,4 +366,11 @@ static inline int ff_rename(const char *oldpath, const char *newpath)
return
0
;
}
/**
* Add new side data to a stream. If a side data of this type already exists, it
* is replaced.
*/
uint8_t
*
ff_stream_new_side_data
(
AVStream
*
st
,
enum
AVPacketSideDataType
type
,
int
size
);
#endif
/* AVFORMAT_INTERNAL_H */
libavformat/replaygain.c
View file @
4227e4fe
...
...
@@ -33,6 +33,7 @@
#include "libavutil/replaygain.h"
#include "avformat.h"
#include "internal.h"
#include "replaygain.h"
static
int32_t
parse_value
(
const
char
*
value
,
int32_t
min
)
...
...
@@ -69,36 +70,16 @@ static int32_t parse_value(const char *value, int32_t min)
int
ff_replaygain_export_raw
(
AVStream
*
st
,
int32_t
tg
,
uint32_t
tp
,
int32_t
ag
,
uint32_t
ap
)
{
AVPacketSideData
*
sd
,
*
tmp
;
AVReplayGain
*
replaygain
;
if
(
tg
==
INT32_MIN
&&
ag
==
INT32_MIN
)
return
0
;
for
(
int
i
=
0
;
i
<
st
->
nb_side_data
;
i
++
)
{
AVPacketSideData
*
src_sd
=
&
st
->
side_data
[
i
];
if
(
src_sd
->
type
==
AV_PKT_DATA_REPLAYGAIN
)
return
0
;
}
replaygain
=
av_mallocz
(
sizeof
(
*
replaygain
));
replaygain
=
(
AVReplayGain
*
)
ff_stream_new_side_data
(
st
,
AV_PKT_DATA_REPLAYGAIN
,
sizeof
(
*
replaygain
));
if
(
!
replaygain
)
return
AVERROR
(
ENOMEM
);
tmp
=
av_realloc_array
(
st
->
side_data
,
st
->
nb_side_data
+
1
,
sizeof
(
*
tmp
));
if
(
!
tmp
)
{
av_freep
(
&
replaygain
);
return
AVERROR
(
ENOMEM
);
}
st
->
side_data
=
tmp
;
st
->
nb_side_data
++
;
sd
=
&
st
->
side_data
[
st
->
nb_side_data
-
1
];
sd
->
type
=
AV_PKT_DATA_REPLAYGAIN
;
sd
->
data
=
(
uint8_t
*
)
replaygain
;
sd
->
size
=
sizeof
(
*
replaygain
);
replaygain
->
track_gain
=
tg
;
replaygain
->
track_peak
=
tp
;
replaygain
->
album_gain
=
ag
;
...
...
libavformat/utils.c
View file @
4227e4fe
...
...
@@ -3113,3 +3113,40 @@ uint8_t *av_stream_get_side_data(AVStream *st, enum AVPacketSideDataType type,
}
return
NULL
;
}
uint8_t
*
ff_stream_new_side_data
(
AVStream
*
st
,
enum
AVPacketSideDataType
type
,
int
size
)
{
AVPacketSideData
*
sd
,
*
tmp
;
int
i
;
uint8_t
*
data
=
av_malloc
(
size
);
if
(
!
data
)
return
NULL
;
for
(
i
=
0
;
i
<
st
->
nb_side_data
;
i
++
)
{
sd
=
&
st
->
side_data
[
i
];
if
(
sd
->
type
==
type
)
{
av_freep
(
&
sd
->
data
);
sd
->
data
=
data
;
sd
->
size
=
size
;
return
sd
->
data
;
}
}
tmp
=
av_realloc_array
(
st
->
side_data
,
st
->
nb_side_data
+
1
,
sizeof
(
*
tmp
));
if
(
!
tmp
)
{
av_freep
(
&
data
);
return
NULL
;
}
st
->
side_data
=
tmp
;
st
->
nb_side_data
++
;
sd
=
&
st
->
side_data
[
st
->
nb_side_data
-
1
];
sd
->
type
=
type
;
sd
->
data
=
data
;
sd
->
size
=
size
;
return
data
;
}
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