diff options
author | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2016-04-10 20:58:15 +0100 |
---|---|---|
committer | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2016-04-10 20:59:55 +0100 |
commit | 6f69f7a8bf6a0d013985578df2ef42ee6b1c7994 (patch) | |
tree | 0c2ec8349ff1763d5f48454b8b9f26374dbd80b0 /libavformat/oggparseflac.c | |
parent | 60b75186b2c878b6257b43c8fcc0b1356ada218e (diff) | |
parent | 9200514ad8717c63f82101dc394f4378854325bf (diff) | |
download | ffmpeg-6f69f7a8bf6a0d013985578df2ef42ee6b1c7994.tar.gz |
Merge commit '9200514ad8717c63f82101dc394f4378854325bf'
* commit '9200514ad8717c63f82101dc394f4378854325bf':
lavf: replace AVStream.codec with AVStream.codecpar
This has been a HUGE effort from:
- Derek Buitenhuis <derek.buitenhuis@gmail.com>
- Hendrik Leppkes <h.leppkes@gmail.com>
- wm4 <nfxjfg@googlemail.com>
- Clément Bœsch <clement@stupeflix.com>
- James Almer <jamrial@gmail.com>
- Michael Niedermayer <michael@niedermayer.cc>
- Rostislav Pehlivanov <atomnuker@gmail.com>
Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Diffstat (limited to 'libavformat/oggparseflac.c')
-rw-r--r-- | libavformat/oggparseflac.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c index c7fb44618d..f08d07d7ab 100644 --- a/libavformat/oggparseflac.c +++ b/libavformat/oggparseflac.c @@ -57,15 +57,15 @@ flac_header (AVFormatContext * s, int idx) if (get_bits_long(&gb, 32) != FLAC_STREAMINFO_SIZE) return -1; - st->codec->codec_type = AVMEDIA_TYPE_AUDIO; - st->codec->codec_id = AV_CODEC_ID_FLAC; + st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; + st->codecpar->codec_id = AV_CODEC_ID_FLAC; st->need_parsing = AVSTREAM_PARSE_HEADERS; - if (ff_alloc_extradata(st->codec, FLAC_STREAMINFO_SIZE) < 0) + if (ff_alloc_extradata(st->codecpar, FLAC_STREAMINFO_SIZE) < 0) return AVERROR(ENOMEM); - memcpy(st->codec->extradata, streaminfo_start, st->codec->extradata_size); + memcpy(st->codecpar->extradata, streaminfo_start, st->codecpar->extradata_size); - samplerate = AV_RB24(st->codec->extradata + 10) >> 4; + samplerate = AV_RB24(st->codecpar->extradata + 10) >> 4; if (!samplerate) return AVERROR_INVALIDDATA; @@ -84,27 +84,38 @@ old_flac_header (AVFormatContext * s, int idx) AVStream *st = s->streams[idx]; struct ogg_stream *os = ogg->streams + idx; AVCodecParserContext *parser = av_parser_init(AV_CODEC_ID_FLAC); - int size; + AVCodecContext *avctx; + int size, ret; uint8_t *data; if (!parser) return -1; - st->codec->codec_type = AVMEDIA_TYPE_AUDIO; - st->codec->codec_id = AV_CODEC_ID_FLAC; + st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; + st->codecpar->codec_id = AV_CODEC_ID_FLAC; + + avctx = avcodec_alloc_context3(NULL); + if (!avctx) + return -1; + + ret = avcodec_parameters_to_context(avctx, st->codecpar); + if (ret < 0) + return -1; parser->flags = PARSER_FLAG_COMPLETE_FRAMES; - av_parser_parse2(parser, st->codec, + av_parser_parse2(parser, avctx, &data, &size, os->buf + os->pstart, os->psize, AV_NOPTS_VALUE, AV_NOPTS_VALUE, -1); av_parser_close(parser); - if (st->codec->sample_rate) { - avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); + if (avctx->sample_rate) { + avpriv_set_pts_info(st, 64, 1, avctx->sample_rate); + avcodec_free_context(&avctx); return 0; } + avcodec_free_context(&avctx); return 1; } |