diff options
author | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2016-04-10 22:58:15 +0300 |
---|---|---|
committer | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2016-04-10 22:59:55 +0300 |
commit | 6f69f7a8bf6a0d013985578df2ef42ee6b1c7994 (patch) | |
tree | 0c2ec8349ff1763d5f48454b8b9f26374dbd80b0 /libavformat/rmdec.c | |
parent | 60b75186b2c878b6257b43c8fcc0b1356ada218e (diff) | |
parent | 9200514ad8717c63f82101dc394f4378854325bf (diff) |
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/rmdec.c')
-rw-r--r-- | libavformat/rmdec.c | 118 |
1 files changed, 59 insertions, 59 deletions
diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index 1a61b10d44..2500852767 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -87,13 +87,13 @@ static void get_str8(AVIOContext *pb, char *buf, int buf_size) get_strl(pb, buf, buf_size, avio_r8(pb)); } -static int rm_read_extradata(AVIOContext *pb, AVCodecContext *avctx, unsigned size) +static int rm_read_extradata(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, unsigned size) { if (size >= 1<<24) { - av_log(avctx, AV_LOG_ERROR, "extradata size %u too large\n", size); + av_log(s, AV_LOG_ERROR, "extradata size %u too large\n", size); return -1; } - if (ff_get_extradata(avctx, pb, size) < 0) + if (ff_get_extradata(par, pb, size) < 0) return AVERROR(ENOMEM); return 0; } @@ -150,12 +150,12 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb, if ((startpos + header_size) > avio_tell(pb)) avio_skip(pb, header_size + startpos - avio_tell(pb)); if (bytes_per_minute) - st->codec->bit_rate = 8LL * bytes_per_minute / 60; - st->codec->sample_rate = 8000; - st->codec->channels = 1; - st->codec->channel_layout = AV_CH_LAYOUT_MONO; - st->codec->codec_type = AVMEDIA_TYPE_AUDIO; - st->codec->codec_id = AV_CODEC_ID_RA_144; + st->codecpar->bit_rate = 8LL * bytes_per_minute / 60; + st->codecpar->sample_rate = 8000; + st->codecpar->channels = 1; + st->codecpar->channel_layout = AV_CH_LAYOUT_MONO; + st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; + st->codecpar->codec_id = AV_CODEC_ID_RA_144; ast->deint_id = DEINT_ID_INT0; } else { int flavor, sub_packet_h, coded_framesize, sub_packet_size; @@ -173,19 +173,19 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb, bytes_per_minute = avio_rb32(pb); if (version == 4) { if (bytes_per_minute) - st->codec->bit_rate = 8LL * bytes_per_minute / 60; + st->codecpar->bit_rate = 8LL * bytes_per_minute / 60; } avio_rb32(pb); /* ??? */ ast->sub_packet_h = sub_packet_h = avio_rb16(pb); /* 1 */ - st->codec->block_align= avio_rb16(pb); /* frame size */ + st->codecpar->block_align= avio_rb16(pb); /* frame size */ ast->sub_packet_size = sub_packet_size = avio_rb16(pb); /* sub packet size */ avio_rb16(pb); /* ??? */ if (version == 5) { avio_rb16(pb); avio_rb16(pb); avio_rb16(pb); } - st->codec->sample_rate = avio_rb16(pb); + st->codecpar->sample_rate = avio_rb16(pb); avio_rb32(pb); - st->codec->channels = avio_rb16(pb); + st->codecpar->channels = avio_rb16(pb); if (version == 5) { ast->deint_id = avio_rl32(pb); avio_read(pb, buf, 4); @@ -196,19 +196,19 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb, ast->deint_id = AV_RL32(buf); get_str8(pb, buf, sizeof(buf)); /* desc */ } - st->codec->codec_type = AVMEDIA_TYPE_AUDIO; - st->codec->codec_tag = AV_RL32(buf); - st->codec->codec_id = ff_codec_get_id(ff_rm_codec_tags, - st->codec->codec_tag); + st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; + st->codecpar->codec_tag = AV_RL32(buf); + st->codecpar->codec_id = ff_codec_get_id(ff_rm_codec_tags, + st->codecpar->codec_tag); - switch (st->codec->codec_id) { + switch (st->codecpar->codec_id) { case AV_CODEC_ID_AC3: st->need_parsing = AVSTREAM_PARSE_FULL; break; case AV_CODEC_ID_RA_288: - st->codec->extradata_size= 0; - ast->audio_framesize = st->codec->block_align; - st->codec->block_align = coded_framesize; + st->codecpar->extradata_size= 0; + ast->audio_framesize = st->codecpar->block_align; + st->codecpar->block_align = coded_framesize; break; case AV_CODEC_ID_COOK: st->need_parsing = AVSTREAM_PARSE_HEADERS; @@ -227,22 +227,22 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb, } } - ast->audio_framesize = st->codec->block_align; - if (st->codec->codec_id == AV_CODEC_ID_SIPR) { + ast->audio_framesize = st->codecpar->block_align; + if (st->codecpar->codec_id == AV_CODEC_ID_SIPR) { if (flavor > 3) { av_log(s, AV_LOG_ERROR, "bad SIPR file flavor %d\n", flavor); return -1; } - st->codec->block_align = ff_sipr_subpk_size[flavor]; + st->codecpar->block_align = ff_sipr_subpk_size[flavor]; } else { if(sub_packet_size <= 0){ av_log(s, AV_LOG_ERROR, "sub_packet_size is invalid\n"); return -1; } - st->codec->block_align = ast->sub_packet_size; + st->codecpar->block_align = ast->sub_packet_size; } - if ((ret = rm_read_extradata(pb, st->codec, codecdata_length)) < 0) + if ((ret = rm_read_extradata(s, pb, st->codecpar, codecdata_length)) < 0) return ret; break; @@ -257,7 +257,7 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb, } if (codecdata_length >= 1) { avio_r8(pb); - if ((ret = rm_read_extradata(pb, st->codec, codecdata_length - 1)) < 0) + if ((ret = rm_read_extradata(s, pb, st->codecpar, codecdata_length - 1)) < 0) return ret; } break; @@ -292,9 +292,9 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb, if (ast->deint_id == DEINT_ID_INT4 || ast->deint_id == DEINT_ID_GENR || ast->deint_id == DEINT_ID_SIPR) { - if (st->codec->block_align <= 0 || + if (st->codecpar->block_align <= 0 || ast->audio_framesize * sub_packet_h > (unsigned)INT_MAX || - ast->audio_framesize * sub_packet_h < st->codec->block_align) + ast->audio_framesize * sub_packet_h < st->codecpar->block_align) return AVERROR_INVALIDDATA; if (av_new_packet(&ast->pkt, ast->audio_framesize * sub_packet_h) < 0) return AVERROR(ENOMEM); @@ -334,13 +334,13 @@ int ff_rm_read_mdpr_codecdata(AVFormatContext *s, AVIOContext *pb, return -1; } else if (v == MKBETAG('L', 'S', 'D', ':')) { avio_seek(pb, -4, SEEK_CUR); - if ((ret = rm_read_extradata(pb, st->codec, codec_data_size)) < 0) + if ((ret = rm_read_extradata(s, pb, st->codecpar, codec_data_size)) < 0) return ret; - st->codec->codec_type = AVMEDIA_TYPE_AUDIO; - st->codec->codec_tag = AV_RL32(st->codec->extradata); - st->codec->codec_id = ff_codec_get_id(ff_rm_codec_tags, - st->codec->codec_tag); + st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; + st->codecpar->codec_tag = AV_RL32(st->codecpar->extradata); + st->codecpar->codec_id = ff_codec_get_id(ff_rm_codec_tags, + st->codecpar->codec_tag); } else if(mime && !strcmp(mime, "logical-fileinfo")){ int stream_count, rule_count, property_count, i; ff_free_stream(s, st); @@ -375,21 +375,21 @@ int ff_rm_read_mdpr_codecdata(AVFormatContext *s, AVIOContext *pb, av_log(s, AV_LOG_WARNING, "Unsupported stream type %08x\n", v); goto skip; } - st->codec->codec_tag = avio_rl32(pb); - st->codec->codec_id = ff_codec_get_id(ff_rm_codec_tags, - st->codec->codec_tag); - av_log(s, AV_LOG_TRACE, "%X %X\n", st->codec->codec_tag, MKTAG('R', 'V', '2', '0')); - if (st->codec->codec_id == AV_CODEC_ID_NONE) + st->codecpar->codec_tag = avio_rl32(pb); + st->codecpar->codec_id = ff_codec_get_id(ff_rm_codec_tags, + st->codecpar->codec_tag); + av_log(s, AV_LOG_TRACE, "%X %X\n", st->codecpar->codec_tag, MKTAG('R', 'V', '2', '0')); + if (st->codecpar->codec_id == AV_CODEC_ID_NONE) goto fail1; - st->codec->width = avio_rb16(pb); - st->codec->height = avio_rb16(pb); + st->codecpar->width = avio_rb16(pb); + st->codecpar->height = avio_rb16(pb); avio_skip(pb, 2); // looks like bits per sample avio_skip(pb, 4); // always zero? - st->codec->codec_type = AVMEDIA_TYPE_VIDEO; + st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; st->need_parsing = AVSTREAM_PARSE_TIMESTAMPS; fps = avio_rb32(pb); - if ((ret = rm_read_extradata(pb, st->codec, codec_data_size - (avio_tell(pb) - codec_pos))) < 0) + if ((ret = rm_read_extradata(s, pb, st->codecpar, codec_data_size - (avio_tell(pb) - codec_pos))) < 0) return ret; if (fps > 0) { @@ -511,10 +511,10 @@ static int rm_read_multi(AVFormatContext *s, AVIOContext *pb, return ret; } st2->id = st->id + (i<<16); - st2->codec->bit_rate = st->codec->bit_rate; + st2->codecpar->bit_rate = st->codecpar->bit_rate; st2->start_time = st->start_time; st2->duration = st->duration; - st2->codec->codec_type = AVMEDIA_TYPE_DATA; + st2->codecpar->codec_type = AVMEDIA_TYPE_DATA; st2->priv_data = ff_rm_alloc_rmstream(); if (!st2->priv_data) return AVERROR(ENOMEM); @@ -598,7 +598,7 @@ static int rm_read_header(AVFormatContext *s) } st->id = avio_rb16(pb); avio_rb32(pb); /* max bit rate */ - st->codec->bit_rate = avio_rb32(pb); /* bit rate */ + st->codecpar->bit_rate = avio_rb32(pb); /* bit rate */ avio_rb32(pb); /* max packet size */ avio_rb32(pb); /* avg packet size */ start_time = avio_rb32(pb); /* start time */ @@ -610,7 +610,7 @@ static int rm_read_header(AVFormatContext *s) s->duration = AV_NOPTS_VALUE; get_str8(pb, buf, sizeof(buf)); /* desc */ get_str8(pb, mime, sizeof(mime)); /* mimetype */ - st->codec->codec_type = AVMEDIA_TYPE_DATA; + st->codecpar->codec_type = AVMEDIA_TYPE_DATA; st->priv_data = ff_rm_alloc_rmstream(); if (!st->priv_data) return AVERROR(ENOMEM); @@ -864,7 +864,7 @@ rm_ac3_swap_bytes (AVStream *st, AVPacket *pkt) uint8_t *ptr; int j; - if (st->codec->codec_id == AV_CODEC_ID_AC3) { + if (st->codecpar->codec_id == AV_CODEC_ID_AC3) { ptr = pkt->data; for (j=0;j<pkt->size;j+=2) { FFSWAP(int, ptr[0], ptr[1]); @@ -891,12 +891,12 @@ ff_rm_parse_packet (AVFormatContext *s, AVIOContext *pb, RMDemuxContext *rm = s->priv_data; int ret; - if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { + if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { rm->current_stream= st->id; ret = rm_assemble_video_frame(s, pb, rm, ast, pkt, len, seq, ×tamp); if(ret) return ret < 0 ? ret : -1; //got partial frame or error - } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { + } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { if ((ast->deint_id == DEINT_ID_GENR) || (ast->deint_id == DEINT_ID_INT4) || (ast->deint_id == DEINT_ID_SIPR)) { @@ -933,7 +933,7 @@ ff_rm_parse_packet (AVFormatContext *s, AVIOContext *pb, ast->sub_packet_cnt = 0; rm->audio_stream_num = st->index; - rm->audio_pkt_cnt = h * w / st->codec->block_align; + rm->audio_pkt_cnt = h * w / st->codecpar->block_align; } else if ((ast->deint_id == DEINT_ID_VBRF) || (ast->deint_id == DEINT_ID_VBRS)) { int x; @@ -959,8 +959,8 @@ ff_rm_parse_packet (AVFormatContext *s, AVIOContext *pb, pkt->stream_index = st->index; #if 0 - if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { - if(st->codec->codec_id == AV_CODEC_ID_RV20){ + if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { + if(st->codecpar->codec_id == AV_CODEC_ID_RV20){ int seq= 128*(pkt->data[2]&0x7F) + (pkt->data[3]>>1); av_log(s, AV_LOG_DEBUG, "%d %"PRId64" %d\n", *timestamp, *timestamp*512LL/25, seq); @@ -975,7 +975,7 @@ ff_rm_parse_packet (AVFormatContext *s, AVIOContext *pb, if (flags & 2) pkt->flags |= AV_PKT_FLAG_KEY; - return st->codec->codec_type == AVMEDIA_TYPE_AUDIO ? rm->audio_pkt_cnt : 0; + return st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO ? rm->audio_pkt_cnt : 0; } int @@ -992,12 +992,12 @@ ff_rm_retrieve_cache (AVFormatContext *s, AVIOContext *pb, if (ret < 0) return ret; } else { - int ret = av_new_packet(pkt, st->codec->block_align); + int ret = av_new_packet(pkt, st->codecpar->block_align); if (ret < 0) return ret; - memcpy(pkt->data, ast->pkt.data + st->codec->block_align * //FIXME avoid this - (ast->sub_packet_h * ast->audio_framesize / st->codec->block_align - rm->audio_pkt_cnt), - st->codec->block_align); + memcpy(pkt->data, ast->pkt.data + st->codecpar->block_align * //FIXME avoid this + (ast->sub_packet_h * ast->audio_framesize / st->codecpar->block_align - rm->audio_pkt_cnt), + st->codecpar->block_align); } rm->audio_pkt_cnt--; if ((pkt->pts = ast->audiotimestamp) != AV_NOPTS_VALUE) { @@ -1114,7 +1114,7 @@ static int64_t rm_read_dts(AVFormatContext *s, int stream_index, return AV_NOPTS_VALUE; st = s->streams[stream_index2]; - if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { + if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { h= avio_r8(s->pb); len--; if(!(h & 0x40)){ seq = avio_r8(s->pb); len--; |