mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-21 10:55:51 +02:00
avformat/wc3movie: 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
04aa4065d7
commit
d6d113e454
@ -139,14 +139,10 @@ static int wc3_read_header(AVFormatContext *s)
|
|||||||
/* load up the name */
|
/* load up the name */
|
||||||
buffer = av_malloc(size+1);
|
buffer = av_malloc(size+1);
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
if (!buffer) {
|
return AVERROR(ENOMEM);
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
if ((ret = avio_read(pb, buffer, size)) != size) {
|
if ((ret = avio_read(pb, buffer, size)) != size) {
|
||||||
av_freep(&buffer);
|
av_freep(&buffer);
|
||||||
ret = AVERROR(EIO);
|
return AVERROR(EIO);
|
||||||
goto fail;
|
|
||||||
}
|
}
|
||||||
buffer[size] = 0;
|
buffer[size] = 0;
|
||||||
av_dict_set(&s->metadata, "title", buffer,
|
av_dict_set(&s->metadata, "title", buffer,
|
||||||
@ -168,26 +164,21 @@ static int wc3_read_header(AVFormatContext *s)
|
|||||||
default:
|
default:
|
||||||
av_log(s, AV_LOG_ERROR, "unrecognized WC3 chunk: %s\n",
|
av_log(s, AV_LOG_ERROR, "unrecognized WC3 chunk: %s\n",
|
||||||
av_fourcc2str(fourcc_tag));
|
av_fourcc2str(fourcc_tag));
|
||||||
ret = AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
goto fail;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fourcc_tag = avio_rl32(pb);
|
fourcc_tag = avio_rl32(pb);
|
||||||
/* chunk sizes are 16-bit aligned */
|
/* chunk sizes are 16-bit aligned */
|
||||||
size = (avio_rb32(pb) + 1) & (~1);
|
size = (avio_rb32(pb) + 1) & (~1);
|
||||||
if (avio_feof(pb)) {
|
if (avio_feof(pb))
|
||||||
ret = AVERROR(EIO);
|
return AVERROR(EIO);
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
} while (fourcc_tag != BRCH_TAG);
|
} while (fourcc_tag != BRCH_TAG);
|
||||||
|
|
||||||
/* initialize the decoder streams */
|
/* initialize the decoder streams */
|
||||||
st = avformat_new_stream(s, NULL);
|
st = avformat_new_stream(s, NULL);
|
||||||
if (!st) {
|
if (!st)
|
||||||
ret = AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
avpriv_set_pts_info(st, 33, 1, WC3_FRAME_FPS);
|
avpriv_set_pts_info(st, 33, 1, WC3_FRAME_FPS);
|
||||||
wc3->video_stream_index = st->index;
|
wc3->video_stream_index = st->index;
|
||||||
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
|
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
|
||||||
@ -197,10 +188,8 @@ static int wc3_read_header(AVFormatContext *s)
|
|||||||
st->codecpar->height = wc3->height;
|
st->codecpar->height = wc3->height;
|
||||||
|
|
||||||
st = avformat_new_stream(s, NULL);
|
st = avformat_new_stream(s, NULL);
|
||||||
if (!st) {
|
if (!st)
|
||||||
ret = AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
avpriv_set_pts_info(st, 33, 1, WC3_FRAME_FPS);
|
avpriv_set_pts_info(st, 33, 1, WC3_FRAME_FPS);
|
||||||
wc3->audio_stream_index = st->index;
|
wc3->audio_stream_index = st->index;
|
||||||
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
|
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
|
||||||
@ -215,9 +204,6 @@ static int wc3_read_header(AVFormatContext *s)
|
|||||||
st->codecpar->block_align = WC3_AUDIO_BITS * WC3_AUDIO_CHANNELS;
|
st->codecpar->block_align = WC3_AUDIO_BITS * WC3_AUDIO_CHANNELS;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
fail:
|
|
||||||
wc3_read_close(s);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wc3_read_packet(AVFormatContext *s,
|
static int wc3_read_packet(AVFormatContext *s,
|
||||||
@ -313,6 +299,7 @@ const AVInputFormat ff_wc3_demuxer = {
|
|||||||
.name = "wc3movie",
|
.name = "wc3movie",
|
||||||
.long_name = NULL_IF_CONFIG_SMALL("Wing Commander III movie"),
|
.long_name = NULL_IF_CONFIG_SMALL("Wing Commander III movie"),
|
||||||
.priv_data_size = sizeof(Wc3DemuxContext),
|
.priv_data_size = sizeof(Wc3DemuxContext),
|
||||||
|
.flags_internal = FF_FMT_INIT_CLEANUP,
|
||||||
.read_probe = wc3_probe,
|
.read_probe = wc3_probe,
|
||||||
.read_header = wc3_read_header,
|
.read_header = wc3_read_header,
|
||||||
.read_packet = wc3_read_packet,
|
.read_packet = wc3_read_packet,
|
||||||
|
Loading…
Reference in New Issue
Block a user