mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-21 10:55:51 +02:00
avformat/ape: Simplify cleanup after read_header failure
by setting the FF_FMT_INIT_CLEANUP flag. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
609672a4a3
commit
58da6b18a3
@ -79,8 +79,6 @@ typedef struct APEContext {
|
||||
uint32_t samplerate;
|
||||
} APEContext;
|
||||
|
||||
static int ape_read_close(AVFormatContext * s);
|
||||
|
||||
static int ape_probe(const AVProbeData * p)
|
||||
{
|
||||
int version = AV_RL16(p->buf+4);
|
||||
@ -276,8 +274,7 @@ static int ape_read_header(AVFormatContext * s)
|
||||
|
||||
if (pb->eof_reached) {
|
||||
av_log(s, AV_LOG_ERROR, "seektable truncated\n");
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto fail;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
ff_dlog(s, "seektable: %8d %"PRIu32"\n", i, seektable_entry);
|
||||
}
|
||||
@ -313,8 +310,7 @@ static int ape_read_header(AVFormatContext * s)
|
||||
ff_dlog(s, "bittable: %2d\n", bits);
|
||||
if (pb->eof_reached) {
|
||||
av_log(s, AV_LOG_ERROR, "bittable truncated\n");
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto fail;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -327,10 +323,8 @@ static int ape_read_header(AVFormatContext * s)
|
||||
|
||||
/* now we are ready: build format streams */
|
||||
st = avformat_new_stream(s, NULL);
|
||||
if (!st) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
if (!st)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
total_blocks = (ape->totalframes == 0) ? 0 : ((ape->totalframes - 1) * ape->blocksperframe) + ape->finalframeblocks;
|
||||
|
||||
@ -347,7 +341,7 @@ static int ape_read_header(AVFormatContext * s)
|
||||
avpriv_set_pts_info(st, 64, 1, ape->samplerate);
|
||||
|
||||
if ((ret = ff_alloc_extradata(st->codecpar, APE_EXTRADATA_SIZE)) < 0)
|
||||
goto fail;
|
||||
return ret;
|
||||
AV_WL16(st->codecpar->extradata + 0, ape->fileversion);
|
||||
AV_WL16(st->codecpar->extradata + 2, ape->compressiontype);
|
||||
AV_WL16(st->codecpar->extradata + 4, ape->formatflags);
|
||||
@ -366,10 +360,6 @@ static int ape_read_header(AVFormatContext * s)
|
||||
}
|
||||
|
||||
return 0;
|
||||
fail:
|
||||
ape_read_close(s);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
|
||||
@ -454,6 +444,7 @@ const AVInputFormat ff_ape_demuxer = {
|
||||
.name = "ape",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("Monkey's Audio"),
|
||||
.priv_data_size = sizeof(APEContext),
|
||||
.flags_internal = FF_FMT_INIT_CLEANUP,
|
||||
.read_probe = ape_probe,
|
||||
.read_header = ape_read_header,
|
||||
.read_packet = ape_read_packet,
|
||||
|
Loading…
Reference in New Issue
Block a user