[FFmpeg-devel] [PATCH v2 1/2] avformat/cafdec: Implement FLAC-in-CAF parsing
Anton Khirnov
anton at khirnov.net
Tue Jun 7 12:05:59 EEST 2022
Quoting Martijn van Beurden (2022-06-04 12:35:06)
> @@ -170,6 +171,49 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
> }
> avio_skip(pb, size - ALAC_NEW_KUKI);
> }
> + } else if (st->codecpar->codec_id == AV_CODEC_ID_FLAC) {
> + int last, type, flac_metadata_size;
> + uint8_t buf[4];
> + /* The magic cookie format for FLAC consists mostly of an mp4 dfLa atom. */
> + if (size < (16 + FLAC_STREAMINFO_SIZE)) {
> + av_log(s, AV_LOG_ERROR, "invalid FLAC magic cookie\n");
> + return AVERROR_INVALIDDATA;
> + }
> + /* Check cookie version. */
> + if (avio_r8(pb) != 0) {
> + av_log(s, AV_LOG_ERROR, "unknown FLAC magic cookie\n");
> + return AVERROR_INVALIDDATA;
> + }
> + avio_rb24(pb); /* Flags */
> + /* read dfLa fourcc */
> + if (avio_read(pb, buf, 4) != 4) {
> + av_log(s, AV_LOG_ERROR, "failed to read FLAC magic cookie\n");
> + return AVERROR_INVALIDDATA;
Should probably forward the IO error with something like
return (pb->error < 0 ? pb->error : AVERROR_INVALIDDATA);
same below and in the second patch
--
Anton Khirnov
More information about the ffmpeg-devel
mailing list