mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-25 16:52:31 +00:00
avcodec/flac: forward errors from ff_flac_parse_streaminfo()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
020d53ebdb
commit
6567c59c49
@ -201,7 +201,7 @@ void ff_flac_set_channel_layout(AVCodecContext *avctx)
|
||||
avctx->channel_layout = 0;
|
||||
}
|
||||
|
||||
void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
|
||||
int ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
|
||||
const uint8_t *buffer)
|
||||
{
|
||||
GetBitContext gb;
|
||||
@ -213,6 +213,7 @@ void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
|
||||
av_log(avctx, AV_LOG_WARNING, "invalid max blocksize: %d\n",
|
||||
s->max_blocksize);
|
||||
s->max_blocksize = 16;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
skip_bits(&gb, 24); /* skip min frame size */
|
||||
@ -225,6 +226,7 @@ void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
|
||||
if (s->bps < 4) {
|
||||
av_log(avctx, AV_LOG_ERROR, "invalid bps: %d\n", s->bps);
|
||||
s->bps = 16;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
avctx->channels = s->channels;
|
||||
@ -239,4 +241,6 @@ void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
|
||||
|
||||
skip_bits_long(&gb, 64); /* md5 sum */
|
||||
skip_bits_long(&gb, 64); /* md5 sum */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -95,8 +95,10 @@ typedef struct FLACFrameInfo {
|
||||
* @param[out] avctx codec context to set basic stream parameters
|
||||
* @param[out] s where parsed information is stored
|
||||
* @param[in] buffer pointer to start of 34-byte streaminfo data
|
||||
*
|
||||
* @return negative error code on faiure or >= 0 on success
|
||||
*/
|
||||
void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
|
||||
int ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
|
||||
const uint8_t *buffer);
|
||||
|
||||
/**
|
||||
|
@ -109,7 +109,9 @@ static av_cold int flac_decode_init(AVCodecContext *avctx)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
/* initialize based on the demuxer-supplied streamdata header */
|
||||
ff_flac_parse_streaminfo(avctx, &s->flac_stream_info, streaminfo);
|
||||
ret = ff_flac_parse_streaminfo(avctx, &s->flac_stream_info, streaminfo);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
ret = allocate_buffers(s);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
@ -175,7 +177,9 @@ static int parse_streaminfo(FLACContext *s, const uint8_t *buf, int buf_size)
|
||||
metadata_size != FLAC_STREAMINFO_SIZE) {
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
ff_flac_parse_streaminfo(s->avctx, &s->flac_stream_info, &buf[8]);
|
||||
ret = ff_flac_parse_streaminfo(s->avctx, &s->flac_stream_info, &buf[8]);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
ret = allocate_buffers(s);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user