On 11.07.2015 13:08, Luca Barbato wrote: > --- > libavformat/asfdec.c | 2 +- > libavformat/avidec.c | 2 +- > libavformat/dxa.c | 2 +- > libavformat/matroskadec.c | 2 +- > libavformat/mov.c | 2 +- > libavformat/riff.h | 2 +- > libavformat/riffdec.c | 5 +++-- > libavformat/wavdec.c | 4 ++-- > libavformat/wtv.c | 2 +- > libavformat/xwma.c | 2 +- > 10 files changed, 13 insertions(+), 12 deletions(-) > > diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c > index 01d753f..8e706fb 100644 > --- a/libavformat/asfdec.c > +++ b/libavformat/asfdec.c > @@ -752,7 +752,7 @@ static int asf_read_stream_properties(AVFormatContext *s, > const GUIDParseTable * > switch (type) { > case AVMEDIA_TYPE_AUDIO: > asf_st->type = AVMEDIA_TYPE_AUDIO; > - if ((ret = ff_get_wav_header(pb, st->codec, ts_data_len)) < 0) > + if ((ret = ff_get_wav_header(s, pb, st->codec, ts_data_len)) < 0) > return ret; > break; > case AVMEDIA_TYPE_VIDEO: > diff --git a/libavformat/avidec.c b/libavformat/avidec.c > index 4caba46..8639765 100644 > --- a/libavformat/avidec.c > +++ b/libavformat/avidec.c > @@ -708,7 +708,7 @@ static int avi_read_header(AVFormatContext *s) > // avio_skip(pb, size - 5 * 4); > break; > case AVMEDIA_TYPE_AUDIO: > - ret = ff_get_wav_header(pb, st->codec, size); > + ret = ff_get_wav_header(s, pb, st->codec, size); > if (ret < 0) > return ret; > ast->dshow_block_align = st->codec->block_align; > diff --git a/libavformat/dxa.c b/libavformat/dxa.c > index 4a4d7c2..34085cf 100644 > --- a/libavformat/dxa.c > +++ b/libavformat/dxa.c > @@ -106,7 +106,7 @@ static int dxa_read_header(AVFormatContext *s) > ast = avformat_new_stream(s, NULL); > if (!ast) > return -1; > - ret = ff_get_wav_header(pb, ast->codec, fsize); > + ret = ff_get_wav_header(s, pb, ast->codec, fsize); > if (ret < 0) > return ret; > if (ast->codec->sample_rate > 0) > diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c > index 34bbf37..0425d24 100644 > --- a/libavformat/matroskadec.c > +++ b/libavformat/matroskadec.c > @@ -1597,7 +1597,7 @@ static int matroska_parse_tracks(AVFormatContext *s) > ffio_init_context(&b, track->codec_priv.data, > track->codec_priv.size, > 0, NULL, NULL, NULL, NULL); > - ret = ff_get_wav_header(&b, st->codec, track->codec_priv.size); > + ret = ff_get_wav_header(s, &b, st->codec, > track->codec_priv.size); > if (ret < 0) > return ret; > codec_id = st->codec->codec_id; > diff --git a/libavformat/mov.c b/libavformat/mov.c > index d075645..66a0391 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -758,7 +758,7 @@ static int mov_read_wfex(MOVContext *c, AVIOContext *pb, > MOVAtom atom) > return 0; > st = c->fc->streams[c->fc->nb_streams-1]; > > - return ff_get_wav_header(pb, st->codec, atom.size); > + return ff_get_wav_header(c->fc, pb, st->codec, atom.size); > } > > static int mov_read_pasp(MOVContext *c, AVIOContext *pb, MOVAtom atom) > diff --git a/libavformat/riff.h b/libavformat/riff.h > index ddfb0fa..5bac95a 100644 > --- a/libavformat/riff.h > +++ b/libavformat/riff.h > @@ -48,7 +48,7 @@ int ff_get_bmp_header(AVIOContext *pb, AVStream *st); > void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc, const > AVCodecTag *tags, int for_asf); > int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc); > enum AVCodecID ff_wav_codec_get_id(unsigned int tag, int bps); > -int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size); > +int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecContext > *codec, int size); > > extern const AVCodecTag ff_codec_bmp_tags[]; > extern const AVCodecTag ff_codec_wav_tags[]; > diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c > index 2c43afc..fc6f76c 100644 > --- a/libavformat/riffdec.c > +++ b/libavformat/riffdec.c > @@ -75,7 +75,8 @@ static void parse_waveformatex(AVIOContext *pb, > AVCodecContext *c) > } > } > > -int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size) > +int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, > + AVCodecContext *codec, int size) > { > int id; > > @@ -124,7 +125,7 @@ int ff_get_wav_header(AVIOContext *pb, AVCodecContext > *codec, int size) > avio_skip(pb, size); > } > if (codec->sample_rate <= 0) { > - av_log(NULL, AV_LOG_ERROR, > + av_log(s, AV_LOG_ERROR, > "Invalid sample rate: %d\n", codec->sample_rate); > return AVERROR_INVALIDDATA; > } > diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c > index f65a66a..83c860d 100644 > --- a/libavformat/wavdec.c > +++ b/libavformat/wavdec.c > @@ -102,7 +102,7 @@ static int wav_parse_fmt_tag(AVFormatContext *s, int64_t > size, AVStream **st) > if (!*st) > return AVERROR(ENOMEM); > > - ret = ff_get_wav_header(pb, (*st)->codec, size); > + ret = ff_get_wav_header(s, pb, (*st)->codec, size); > if (ret < 0) > return ret; > (*st)->need_parsing = AVSTREAM_PARSE_FULL; > @@ -498,7 +498,7 @@ static int w64_read_header(AVFormatContext *s) > return AVERROR(ENOMEM); > > /* subtract chunk header size - normal wav file doesn't count it */ > - ret = ff_get_wav_header(pb, st->codec, size - 24); > + ret = ff_get_wav_header(s, pb, st->codec, size - 24); > if (ret < 0) > return ret; > avio_skip(pb, FFALIGN(size, INT64_C(8)) - size); > diff --git a/libavformat/wtv.c b/libavformat/wtv.c > index 7fe737e..bab61f3 100644 > --- a/libavformat/wtv.c > +++ b/libavformat/wtv.c > @@ -691,7 +691,7 @@ static AVStream * parse_media_type(AVFormatContext *s, > AVStream *st, int sid, > if (!st) > return NULL; > if (!ff_guidcmp(formattype, format_waveformatex)) { > - int ret = ff_get_wav_header(pb, st->codec, size); > + int ret = ff_get_wav_header(s, pb, st->codec, size); > if (ret < 0) > return NULL; > } else { > diff --git a/libavformat/xwma.c b/libavformat/xwma.c > index 4a30001..cab4616 100644 > --- a/libavformat/xwma.c > +++ b/libavformat/xwma.c > @@ -75,7 +75,7 @@ static int xwma_read_header(AVFormatContext *s) > if (!st) > return AVERROR(ENOMEM); > > - ret = ff_get_wav_header(pb, st->codec, size); > + ret = ff_get_wav_header(s, pb, st->codec, size); > if (ret < 0) > return ret; > st->need_parsing = AVSTREAM_PARSE_NONE; >
This looks good. It has the nice side effect, that it makes it possible to get an explode mode working in ff_get_wav_header. (Attached is this patch rebased on ffmpeg, since my next riff patch depends on this.) Best regards, Andreas
>From e6c6e127ed733c6781b1379a6321f057e5b2e1ab Mon Sep 17 00:00:00 2001 From: Luca Barbato <lu_z...@gentoo.org> Date: Sat, 11 Jul 2015 13:08:17 +0200 Subject: [PATCH] riff: Use the correct logging context Signed-off-by: Andreas Cadhalpun <andreas.cadhal...@googlemail.com> --- libavformat/act.c | 2 +- libavformat/asfdec_f.c | 2 +- libavformat/avidec.c | 2 +- libavformat/dxa.c | 2 +- libavformat/matroskadec.c | 2 +- libavformat/mlvdec.c | 2 +- libavformat/mov.c | 2 +- libavformat/riff.h | 2 +- libavformat/riffdec.c | 5 +++-- libavformat/wavdec.c | 4 ++-- libavformat/wtvdec.c | 2 +- libavformat/xwma.c | 2 +- 12 files changed, 15 insertions(+), 14 deletions(-) diff --git a/libavformat/act.c b/libavformat/act.c index 7b6b840..35aacbc 100644 --- a/libavformat/act.c +++ b/libavformat/act.c @@ -75,7 +75,7 @@ static int read_header(AVFormatContext *s) avio_skip(pb, 16); size=avio_rl32(pb); - ff_get_wav_header(pb, st->codec, size, 0); + ff_get_wav_header(s, pb, st->codec, size, 0); /* 8000Hz (Fine-rec) file format has 10 bytes long diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c index 3775cdb..b6867de 100644 --- a/libavformat/asfdec_f.c +++ b/libavformat/asfdec_f.c @@ -470,7 +470,7 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size) st->codec->codec_type = type; if (type == AVMEDIA_TYPE_AUDIO) { - int ret = ff_get_wav_header(pb, st->codec, type_specific_size, 0); + int ret = ff_get_wav_header(s, pb, st->codec, type_specific_size, 0); if (ret < 0) return ret; if (is_dvr_ms_audio) { diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 5348b44..73d1d16 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -835,7 +835,7 @@ static int avi_read_header(AVFormatContext *s) // avio_skip(pb, size - 5 * 4); break; case AVMEDIA_TYPE_AUDIO: - ret = ff_get_wav_header(pb, st->codec, size, 0); + ret = ff_get_wav_header(s, pb, st->codec, size, 0); if (ret < 0) return ret; ast->dshow_block_align = st->codec->block_align; diff --git a/libavformat/dxa.c b/libavformat/dxa.c index 4403356..228e6fd 100644 --- a/libavformat/dxa.c +++ b/libavformat/dxa.c @@ -106,7 +106,7 @@ static int dxa_read_header(AVFormatContext *s) ast = avformat_new_stream(s, NULL); if (!ast) return AVERROR(ENOMEM); - ret = ff_get_wav_header(pb, ast->codec, fsize, 0); + ret = ff_get_wav_header(s, pb, ast->codec, fsize, 0); if (ret < 0) return ret; if (ast->codec->sample_rate > 0) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 9247a75..b546798 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1792,7 +1792,7 @@ static int matroska_parse_tracks(AVFormatContext *s) ffio_init_context(&b, track->codec_priv.data, track->codec_priv.size, 0, NULL, NULL, NULL, NULL); - ret = ff_get_wav_header(&b, st->codec, track->codec_priv.size, 0); + ret = ff_get_wav_header(s, &b, st->codec, track->codec_priv.size, 0); if (ret < 0) return ret; codec_id = st->codec->codec_id; diff --git a/libavformat/mlvdec.c b/libavformat/mlvdec.c index aa1ba60..48a429e 100644 --- a/libavformat/mlvdec.c +++ b/libavformat/mlvdec.c @@ -143,7 +143,7 @@ static int scan_file(AVFormatContext *avctx, AVStream *vst, AVStream *ast, int f vst->codec->codec_tag = MKTAG('B', 'I', 'T', 16); size -= 164; } else if (ast && type == MKTAG('W', 'A', 'V', 'I') && size >= 16) { - ret = ff_get_wav_header(pb, ast->codec, 16, 0); + ret = ff_get_wav_header(avctx, pb, ast->codec, 16, 0); if (ret < 0) return ret; size -= 16; diff --git a/libavformat/mov.c b/libavformat/mov.c index 6d59863..453e85c 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -769,7 +769,7 @@ static int mov_read_wfex(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; st = c->fc->streams[c->fc->nb_streams-1]; - if ((ret = ff_get_wav_header(pb, st->codec, atom.size, 0)) < 0) + if ((ret = ff_get_wav_header(c->fc, pb, st->codec, atom.size, 0)) < 0) av_log(c->fc, AV_LOG_WARNING, "get_wav_header failed\n"); return ret; diff --git a/libavformat/riff.h b/libavformat/riff.h index ae5ecef..399c527 100644 --- a/libavformat/riff.h +++ b/libavformat/riff.h @@ -62,7 +62,7 @@ void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc, const AVCodecTag *t int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc, int flags); enum AVCodecID ff_wav_codec_get_id(unsigned int tag, int bps); -int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size, int big_endian); +int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecContext *codec, int size, int big_endian); extern const AVCodecTag ff_codec_bmp_tags[]; // exposed through avformat_get_riff_video_tags() extern const AVCodecTag ff_codec_wav_tags[]; diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c index eebd8ed..5ae9163 100644 --- a/libavformat/riffdec.c +++ b/libavformat/riffdec.c @@ -83,7 +83,8 @@ static void parse_waveformatex(AVIOContext *pb, AVCodecContext *c) } /* "big_endian" values are needed for RIFX file format */ -int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size, int big_endian) +int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, + AVCodecContext *codec, int size, int big_endian) { int id; @@ -147,7 +148,7 @@ int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size, int big_ avio_skip(pb, size); } if (codec->sample_rate <= 0) { - av_log(NULL, AV_LOG_ERROR, + av_log(s, AV_LOG_ERROR, "Invalid sample rate: %d\n", codec->sample_rate); return AVERROR_INVALIDDATA; } diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c index 864185f..9bc8c4f 100644 --- a/libavformat/wavdec.c +++ b/libavformat/wavdec.c @@ -134,7 +134,7 @@ static int wav_parse_fmt_tag(AVFormatContext *s, int64_t size, AVStream **st) if (!*st) return AVERROR(ENOMEM); - ret = ff_get_wav_header(pb, (*st)->codec, size, wav->rifx); + ret = ff_get_wav_header(s, pb, (*st)->codec, size, wav->rifx); if (ret < 0) return ret; handle_stream_probing(*st); @@ -689,7 +689,7 @@ static int w64_read_header(AVFormatContext *s) if (!memcmp(guid, ff_w64_guid_fmt, 16)) { /* subtract chunk header size - normal wav file doesn't count it */ - ret = ff_get_wav_header(pb, st->codec, size - 24, 0); + ret = ff_get_wav_header(s, pb, st->codec, size - 24, 0); if (ret < 0) return ret; avio_skip(pb, FFALIGN(size, INT64_C(8)) - size); diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c index e226690..e8f6196 100644 --- a/libavformat/wtvdec.c +++ b/libavformat/wtvdec.c @@ -670,7 +670,7 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid, if (!st) return NULL; if (!ff_guidcmp(formattype, ff_format_waveformatex)) { - int ret = ff_get_wav_header(pb, st->codec, size, 0); + int ret = ff_get_wav_header(s, pb, st->codec, size, 0); if (ret < 0) return NULL; } else { diff --git a/libavformat/xwma.c b/libavformat/xwma.c index 683d3d0..9edad7d 100644 --- a/libavformat/xwma.c +++ b/libavformat/xwma.c @@ -75,7 +75,7 @@ static int xwma_read_header(AVFormatContext *s) if (!st) return AVERROR(ENOMEM); - ret = ff_get_wav_header(pb, st->codec, size, 0); + ret = ff_get_wav_header(s, pb, st->codec, size, 0); if (ret < 0) return ret; st->need_parsing = AVSTREAM_PARSE_NONE; -- 2.1.4
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel