You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avcodec/flac: forward errors from ff_flac_parse_streaminfo()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
@@ -201,7 +201,7 @@ void ff_flac_set_channel_layout(AVCodecContext *avctx)
|
|||||||
avctx->channel_layout = 0;
|
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)
|
const uint8_t *buffer)
|
||||||
{
|
{
|
||||||
GetBitContext gb;
|
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",
|
av_log(avctx, AV_LOG_WARNING, "invalid max blocksize: %d\n",
|
||||||
s->max_blocksize);
|
s->max_blocksize);
|
||||||
s->max_blocksize = 16;
|
s->max_blocksize = 16;
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
skip_bits(&gb, 24); /* skip min frame size */
|
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) {
|
if (s->bps < 4) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "invalid bps: %d\n", s->bps);
|
av_log(avctx, AV_LOG_ERROR, "invalid bps: %d\n", s->bps);
|
||||||
s->bps = 16;
|
s->bps = 16;
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
avctx->channels = s->channels;
|
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 */
|
||||||
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] avctx codec context to set basic stream parameters
|
||||||
* @param[out] s where parsed information is stored
|
* @param[out] s where parsed information is stored
|
||||||
* @param[in] buffer pointer to start of 34-byte streaminfo data
|
* @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);
|
const uint8_t *buffer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -109,7 +109,9 @@ static av_cold int flac_decode_init(AVCodecContext *avctx)
|
|||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
/* initialize based on the demuxer-supplied streamdata header */
|
/* 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);
|
ret = allocate_buffers(s);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
@@ -175,7 +177,9 @@ static int parse_streaminfo(FLACContext *s, const uint8_t *buf, int buf_size)
|
|||||||
metadata_size != FLAC_STREAMINFO_SIZE) {
|
metadata_size != FLAC_STREAMINFO_SIZE) {
|
||||||
return AVERROR_INVALIDDATA;
|
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);
|
ret = allocate_buffers(s);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
Reference in New Issue
Block a user