Commit f1dbfcdf authored by Andreas Rheinhardt's avatar Andreas Rheinhardt Committed by Michael Niedermayer

avformat/dvenc: Replace write_trailer by deinit function

The old write_trailer only freed memory, so it is better to make a
dedicated deinit function out of it. Given that this function will also
be called when writing the header fails, one can also remove code that
frees already allocated fifos when allocating another one fails.
Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: 's avatarPaul B Mahol <onemda@gmail.com>
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 0b1ff326
...@@ -364,10 +364,6 @@ static DVMuxContext* dv_init_mux(AVFormatContext* s) ...@@ -364,10 +364,6 @@ static DVMuxContext* dv_init_mux(AVFormatContext* s)
for (i=0; i < c->n_ast; i++) { for (i=0; i < c->n_ast; i++) {
if (c->ast[i] && !(c->audio_data[i]=av_fifo_alloc_array(100, MAX_AUDIO_FRAME_SIZE))) { if (c->ast[i] && !(c->audio_data[i]=av_fifo_alloc_array(100, MAX_AUDIO_FRAME_SIZE))) {
while (i > 0) {
i--;
av_fifo_freep(&c->audio_data[i]);
}
goto bail_out; goto bail_out;
} }
} }
...@@ -378,13 +374,6 @@ bail_out: ...@@ -378,13 +374,6 @@ bail_out:
return NULL; return NULL;
} }
static void dv_delete_mux(DVMuxContext *c)
{
int i;
for (i=0; i < c->n_ast; i++)
av_fifo_freep(&c->audio_data[i]);
}
static int dv_write_header(AVFormatContext *s) static int dv_write_header(AVFormatContext *s)
{ {
AVRational rate; AVRational rate;
...@@ -432,10 +421,12 @@ static int dv_write_packet(struct AVFormatContext *s, AVPacket *pkt) ...@@ -432,10 +421,12 @@ static int dv_write_packet(struct AVFormatContext *s, AVPacket *pkt)
* Currently we simply drop the last frame. I don't know whether this * Currently we simply drop the last frame. I don't know whether this
* is the best strategy of all * is the best strategy of all
*/ */
static int dv_write_trailer(struct AVFormatContext *s) static void dv_deinit(AVFormatContext *s)
{ {
dv_delete_mux(s->priv_data); DVMuxContext *c = s->priv_data;
return 0;
for (int i = 0; i < c->n_ast; i++)
av_fifo_freep(&c->audio_data[i]);
} }
AVOutputFormat ff_dv_muxer = { AVOutputFormat ff_dv_muxer = {
...@@ -447,5 +438,5 @@ AVOutputFormat ff_dv_muxer = { ...@@ -447,5 +438,5 @@ AVOutputFormat ff_dv_muxer = {
.video_codec = AV_CODEC_ID_DVVIDEO, .video_codec = AV_CODEC_ID_DVVIDEO,
.write_header = dv_write_header, .write_header = dv_write_header,
.write_packet = dv_write_packet, .write_packet = dv_write_packet,
.write_trailer = dv_write_trailer, .deinit = dv_deinit,
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment