aboutsummaryrefslogtreecommitdiff
path: root/libavformat/replaygain.c
diff options
context:
space:
mode:
authorAnton Khirnov2014-11-14 12:45:08 +0100
committerAnton Khirnov2015-01-27 09:18:32 +0100
commit4227e4fe7443733fb906f6fb6c265105e8269c74 (patch)
treee8d550c90fbcd6c574a0c68c91aac6fd7918c2d5 /libavformat/replaygain.c
parent728685f37ab333ca35980bd01766c78d197f784a (diff)
lavf: add a convenience function for adding side data to a stream
Diffstat (limited to 'libavformat/replaygain.c')
-rw-r--r--libavformat/replaygain.c25
1 files changed, 3 insertions, 22 deletions
diff --git a/libavformat/replaygain.c b/libavformat/replaygain.c
index 6c5b582cdf..98e7aad81b 100644
--- a/libavformat/replaygain.c
+++ b/libavformat/replaygain.c
@@ -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;