mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-02-04 06:08:26 +02:00
avformat/riffdec: Pass logctx as void* instead of AVFormatContext*
Also stop second-guessing error codes from ff_get_extradata(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
6a15b4d16c
commit
a94a6617a3
@ -67,7 +67,8 @@ void ff_put_bmp_header(AVIOContext *pb, AVCodecParameters *par, int for_asf, int
|
|||||||
int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int flags);
|
int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int flags);
|
||||||
|
|
||||||
enum AVCodecID ff_wav_codec_get_id(unsigned int tag, int bps);
|
enum AVCodecID ff_wav_codec_get_id(unsigned int tag, int bps);
|
||||||
int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int size, int big_endian);
|
int ff_get_wav_header(void *logctx, AVIOContext *pb, AVCodecParameters *par,
|
||||||
|
int size, int big_endian);
|
||||||
|
|
||||||
extern const AVCodecTag ff_codec_bmp_tags[]; // exposed through avformat_get_riff_video_tags()
|
extern const AVCodecTag ff_codec_bmp_tags[]; // exposed through avformat_get_riff_video_tags()
|
||||||
extern const AVCodecTag ff_codec_wav_tags[];
|
extern const AVCodecTag ff_codec_wav_tags[];
|
||||||
|
@ -58,7 +58,7 @@ enum AVCodecID ff_codec_guid_get_id(const AVCodecGuid *guids, ff_asf_guid guid)
|
|||||||
* an openended structure.
|
* an openended structure.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void parse_waveformatex(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par)
|
static void parse_waveformatex(void *logctx, AVIOContext *pb, AVCodecParameters *par)
|
||||||
{
|
{
|
||||||
ff_asf_guid subformat;
|
ff_asf_guid subformat;
|
||||||
int bps;
|
int bps;
|
||||||
@ -84,21 +84,21 @@ static void parse_waveformatex(AVFormatContext *s, AVIOContext *pb, AVCodecParam
|
|||||||
} else {
|
} else {
|
||||||
par->codec_id = ff_codec_guid_get_id(ff_codec_wav_guids, subformat);
|
par->codec_id = ff_codec_guid_get_id(ff_codec_wav_guids, subformat);
|
||||||
if (!par->codec_id)
|
if (!par->codec_id)
|
||||||
av_log(s, AV_LOG_WARNING,
|
av_log(logctx, AV_LOG_WARNING,
|
||||||
"unknown subformat:"FF_PRI_GUID"\n",
|
"unknown subformat:"FF_PRI_GUID"\n",
|
||||||
FF_ARG_GUID(subformat));
|
FF_ARG_GUID(subformat));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* "big_endian" values are needed for RIFX file format */
|
/* "big_endian" values are needed for RIFX file format */
|
||||||
int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
|
int ff_get_wav_header(void *logctx, AVIOContext *pb,
|
||||||
AVCodecParameters *par, int size, int big_endian)
|
AVCodecParameters *par, int size, int big_endian)
|
||||||
{
|
{
|
||||||
int id, channels = 0;
|
int id, channels = 0, ret;
|
||||||
uint64_t bitrate = 0;
|
uint64_t bitrate = 0;
|
||||||
|
|
||||||
if (size < 14) {
|
if (size < 14) {
|
||||||
avpriv_request_sample(s, "wav header size < 14");
|
avpriv_request_sample(logctx, "wav header size < 14");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,19 +139,20 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
|
|||||||
if (size >= 18 && id != 0x0165) { /* We're obviously dealing with WAVEFORMATEX */
|
if (size >= 18 && id != 0x0165) { /* We're obviously dealing with WAVEFORMATEX */
|
||||||
int cbSize = avio_rl16(pb); /* cbSize */
|
int cbSize = avio_rl16(pb); /* cbSize */
|
||||||
if (big_endian) {
|
if (big_endian) {
|
||||||
avpriv_report_missing_feature(s, "WAVEFORMATEX support for RIFX files");
|
avpriv_report_missing_feature(logctx, "WAVEFORMATEX support for RIFX files");
|
||||||
return AVERROR_PATCHWELCOME;
|
return AVERROR_PATCHWELCOME;
|
||||||
}
|
}
|
||||||
size -= 18;
|
size -= 18;
|
||||||
cbSize = FFMIN(size, cbSize);
|
cbSize = FFMIN(size, cbSize);
|
||||||
if (cbSize >= 22 && id == 0xfffe) { /* WAVEFORMATEXTENSIBLE */
|
if (cbSize >= 22 && id == 0xfffe) { /* WAVEFORMATEXTENSIBLE */
|
||||||
parse_waveformatex(s, pb, par);
|
parse_waveformatex(logctx, pb, par);
|
||||||
cbSize -= 22;
|
cbSize -= 22;
|
||||||
size -= 22;
|
size -= 22;
|
||||||
}
|
}
|
||||||
if (cbSize > 0) {
|
if (cbSize > 0) {
|
||||||
if (ff_get_extradata(s, par, pb, cbSize) < 0)
|
ret = ff_get_extradata(logctx, par, pb, cbSize);
|
||||||
return AVERROR(ENOMEM);
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
size -= cbSize;
|
size -= cbSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,8 +163,9 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
|
|||||||
int nb_streams, i;
|
int nb_streams, i;
|
||||||
|
|
||||||
size -= 4;
|
size -= 4;
|
||||||
if (ff_get_extradata(s, par, pb, size) < 0)
|
ret = ff_get_extradata(logctx, par, pb, size);
|
||||||
return AVERROR(ENOMEM);
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
nb_streams = AV_RL16(par->extradata + 4);
|
nb_streams = AV_RL16(par->extradata + 4);
|
||||||
par->sample_rate = AV_RL32(par->extradata + 12);
|
par->sample_rate = AV_RL32(par->extradata + 12);
|
||||||
channels = 0;
|
channels = 0;
|
||||||
@ -177,7 +179,7 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
|
|||||||
par->bit_rate = bitrate;
|
par->bit_rate = bitrate;
|
||||||
|
|
||||||
if (par->sample_rate <= 0) {
|
if (par->sample_rate <= 0) {
|
||||||
av_log(s, AV_LOG_ERROR,
|
av_log(logctx, AV_LOG_ERROR,
|
||||||
"Invalid sample rate: %d\n", par->sample_rate);
|
"Invalid sample rate: %d\n", par->sample_rate);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user