aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/mp3enc.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2019-10-20 23:25:53 -0300
committerJames Almer <jamrial@gmail.com>2019-10-21 17:20:20 -0300
commitdf57246aafea8442bff0a5d39858bbb0c2a1bb51 (patch)
treea3092d99e9853ef2f6986a6588e26bfb8a21ead7 /libavformat/mp3enc.c
parentb46cdd9d23703f4976d2504055ccc86741013f4b (diff)
downloadffmpeg-df57246aafea8442bff0a5d39858bbb0c2a1bb51.tar.gz
avformat/mp3enc: add init and deinit functions
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/mp3enc.c')
-rw-r--r--libavformat/mp3enc.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index f4814be80e..34b753ffa0 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -473,8 +473,6 @@ static int mp3_write_trailer(struct AVFormatContext *s)
if (mp3->xing_offset)
mp3_update_xing(s);
- av_freep(&mp3->xing_frame);
-
return 0;
}
@@ -551,10 +549,10 @@ static int mp3_write_packet(AVFormatContext *s, AVPacket *pkt)
* Write an ID3v2 header at beginning of stream
*/
-static int mp3_write_header(struct AVFormatContext *s)
+static int mp3_init(struct AVFormatContext *s)
{
MP3Context *mp3 = s->priv_data;
- int ret, i;
+ int i;
if (mp3->id3v2_version &&
mp3->id3v2_version != 3 &&
@@ -593,6 +591,14 @@ static int mp3_write_header(struct AVFormatContext *s)
return AVERROR(EINVAL);
}
+ return 0;
+}
+
+static int mp3_write_header(struct AVFormatContext *s)
+{
+ MP3Context *mp3 = s->priv_data;
+ int ret;
+
if (mp3->id3v2_version) {
ff_id3v2_start(&mp3->id3, s->pb, mp3->id3v2_version, ID3v2_DEFAULT_MAGIC);
ret = ff_id3v2_write_metadata(s, &mp3->id3);
@@ -609,6 +615,14 @@ static int mp3_write_header(struct AVFormatContext *s)
return 0;
}
+static void mp3_deinit(struct AVFormatContext *s)
+{
+ MP3Context *mp3 = s->priv_data;
+
+ ff_packet_list_free(&mp3->queue, &mp3->queue_end);
+ av_freep(&mp3->xing_frame);
+}
+
AVOutputFormat ff_mp3_muxer = {
.name = "mp3",
.long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"),
@@ -617,9 +631,11 @@ AVOutputFormat ff_mp3_muxer = {
.priv_data_size = sizeof(MP3Context),
.audio_codec = AV_CODEC_ID_MP3,
.video_codec = AV_CODEC_ID_PNG,
+ .init = mp3_init,
.write_header = mp3_write_header,
.write_packet = mp3_write_packet,
.write_trailer = mp3_write_trailer,
+ .deinit = mp3_deinit,
.query_codec = query_codec,
.flags = AVFMT_NOTIMESTAMPS,
.priv_class = &mp3_muxer_class,