[FFmpeg-devel] [PATCH 2/2] avformat/replaygain: use av_replaygain_alloc()

James Almer jamrial at gmail.com
Mon Dec 12 05:23:01 EET 2016


Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavformat/replaygain.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/libavformat/replaygain.c b/libavformat/replaygain.c
index 707d3cd..b8658d6 100644
--- a/libavformat/replaygain.c
+++ b/libavformat/replaygain.c
@@ -71,12 +71,13 @@ int ff_replaygain_export_raw(AVStream *st, int32_t tg, uint32_t tp,
                              int32_t ag, uint32_t ap)
 {
     AVReplayGain *replaygain;
+    size_t replaygain_size;
+    int ret;
 
     if (tg == INT32_MIN && ag == INT32_MIN)
         return 0;
 
-    replaygain = (AVReplayGain*)av_stream_new_side_data(st, AV_PKT_DATA_REPLAYGAIN,
-                                                        sizeof(*replaygain));
+    replaygain = av_replaygain_alloc(&replaygain_size);
     if (!replaygain)
         return AVERROR(ENOMEM);
 
@@ -85,6 +86,13 @@ int ff_replaygain_export_raw(AVStream *st, int32_t tg, uint32_t tp,
     replaygain->album_gain = ag;
     replaygain->album_peak = ap;
 
+    ret = av_stream_add_side_data(st, AV_PKT_DATA_REPLAYGAIN, (uint8_t *)replaygain,
+                                  replaygain_size);
+    if (ret < 0) {
+        av_freep(&replaygain);
+        return ret;
+    }
+
     return 0;
 }
 
-- 
2.10.2



More information about the ffmpeg-devel mailing list