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/smoothstreamingenc.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/smoothstreamingenc.c')
-rw-r--r-- | libavformat/smoothstreamingenc.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c index 5333ba86c7..193c360db1 100644 --- a/libavformat/smoothstreamingenc.c +++ b/libavformat/smoothstreamingenc.c @@ -146,14 +146,14 @@ static int64_t ism_seek(void *opaque, int64_t offset, int whence) static void get_private_data(OutputStream *os) { - AVCodecContext *codec = os->ctx->streams[0]->codec; - uint8_t *ptr = codec->extradata; - int size = codec->extradata_size; + AVCodecParameters *par = os->ctx->streams[0]->codecpar; + uint8_t *ptr = par->extradata; + int size = par->extradata_size; int i; - if (codec->codec_id == AV_CODEC_ID_H264) { + if (par->codec_id == AV_CODEC_ID_H264) { ff_avc_write_annexb_extradata(ptr, &ptr, &size); if (!ptr) - ptr = codec->extradata; + ptr = par->extradata; } if (!ptr) return; @@ -163,7 +163,7 @@ static void get_private_data(OutputStream *os) for (i = 0; i < size; i++) snprintf(&os->private_str[2*i], 3, "%02x", ptr[i]); fail: - if (ptr != codec->extradata) + if (ptr != par->extradata) av_free(ptr); } @@ -235,7 +235,7 @@ static int write_manifest(AVFormatContext *s, int final) Fragment *last = os->fragments[os->nb_fragments - 1]; duration = last->start_time + last->duration; } - if (s->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) { + if (s->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { video_chunks = os->nb_fragments; video_streams++; } else { @@ -260,10 +260,10 @@ static int write_manifest(AVFormatContext *s, int final) avio_printf(out, "<StreamIndex Type=\"video\" QualityLevels=\"%d\" Chunks=\"%d\" Url=\"QualityLevels({bitrate})/Fragments(video={start time})\">\n", video_streams, video_chunks); for (i = 0; i < s->nb_streams; i++) { OutputStream *os = &c->streams[i]; - if (s->streams[i]->codec->codec_type != AVMEDIA_TYPE_VIDEO) + if (s->streams[i]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO) continue; last = i; - avio_printf(out, "<QualityLevel Index=\"%d\" Bitrate=\"%"PRId64"\" FourCC=\"%s\" MaxWidth=\"%d\" MaxHeight=\"%d\" CodecPrivateData=\"%s\" />\n", index, (int64_t)s->streams[i]->codec->bit_rate, os->fourcc, s->streams[i]->codec->width, s->streams[i]->codec->height, os->private_str); + avio_printf(out, "<QualityLevel Index=\"%d\" Bitrate=\"%"PRId64"\" FourCC=\"%s\" MaxWidth=\"%d\" MaxHeight=\"%d\" CodecPrivateData=\"%s\" />\n", index, (int64_t)s->streams[i]->codecpar->bit_rate, os->fourcc, s->streams[i]->codecpar->width, s->streams[i]->codecpar->height, os->private_str); index++; } output_chunk_list(&c->streams[last], out, final, c->lookahead_count, c->window_size); @@ -274,10 +274,10 @@ static int write_manifest(AVFormatContext *s, int final) avio_printf(out, "<StreamIndex Type=\"audio\" QualityLevels=\"%d\" Chunks=\"%d\" Url=\"QualityLevels({bitrate})/Fragments(audio={start time})\">\n", audio_streams, audio_chunks); for (i = 0; i < s->nb_streams; i++) { OutputStream *os = &c->streams[i]; - if (s->streams[i]->codec->codec_type != AVMEDIA_TYPE_AUDIO) + if (s->streams[i]->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) continue; last = i; - avio_printf(out, "<QualityLevel Index=\"%d\" Bitrate=\"%"PRId64"\" FourCC=\"%s\" SamplingRate=\"%d\" Channels=\"%d\" BitsPerSample=\"16\" PacketSize=\"%d\" AudioTag=\"%d\" CodecPrivateData=\"%s\" />\n", index, (int64_t)s->streams[i]->codec->bit_rate, os->fourcc, s->streams[i]->codec->sample_rate, s->streams[i]->codec->channels, os->packet_size, os->audio_tag, os->private_str); + avio_printf(out, "<QualityLevel Index=\"%d\" Bitrate=\"%"PRId64"\" FourCC=\"%s\" SamplingRate=\"%d\" Channels=\"%d\" BitsPerSample=\"16\" PacketSize=\"%d\" AudioTag=\"%d\" CodecPrivateData=\"%s\" />\n", index, (int64_t)s->streams[i]->codecpar->bit_rate, os->fourcc, s->streams[i]->codecpar->sample_rate, s->streams[i]->codecpar->channels, os->packet_size, os->audio_tag, os->private_str); index++; } output_chunk_list(&c->streams[last], out, final, c->lookahead_count, c->window_size); @@ -319,12 +319,12 @@ static int ism_write_header(AVFormatContext *s) AVStream *st; AVDictionary *opts = NULL; - if (!s->streams[i]->codec->bit_rate) { + if (!s->streams[i]->codecpar->bit_rate) { av_log(s, AV_LOG_ERROR, "No bit rate set for stream %d\n", i); ret = AVERROR(EINVAL); goto fail; } - snprintf(os->dirname, sizeof(os->dirname), "%s/QualityLevels(%"PRId64")", s->filename, (int64_t)s->streams[i]->codec->bit_rate); + snprintf(os->dirname, sizeof(os->dirname), "%s/QualityLevels(%"PRId64")", s->filename, (int64_t)s->streams[i]->codecpar->bit_rate); if (mkdir(os->dirname, 0777) == -1 && errno != EEXIST) { ret = AVERROR(errno); av_log(s, AV_LOG_ERROR, "mkdir failed\n"); @@ -344,7 +344,7 @@ static int ism_write_header(AVFormatContext *s) ret = AVERROR(ENOMEM); goto fail; } - avcodec_copy_context(st->codec, s->streams[i]->codec); + avcodec_parameters_copy(st->codecpar, s->streams[i]->codecpar); st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio; st->time_base = s->streams[i]->time_base; @@ -363,12 +363,12 @@ static int ism_write_header(AVFormatContext *s) avio_flush(ctx->pb); av_dict_free(&opts); s->streams[i]->time_base = st->time_base; - if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { + if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { c->has_video = 1; os->stream_type_tag = "video"; - if (st->codec->codec_id == AV_CODEC_ID_H264) { + if (st->codecpar->codec_id == AV_CODEC_ID_H264) { os->fourcc = "H264"; - } else if (st->codec->codec_id == AV_CODEC_ID_VC1) { + } else if (st->codecpar->codec_id == AV_CODEC_ID_VC1) { os->fourcc = "WVC1"; } else { av_log(s, AV_LOG_ERROR, "Unsupported video codec\n"); @@ -378,10 +378,10 @@ static int ism_write_header(AVFormatContext *s) } else { c->has_audio = 1; os->stream_type_tag = "audio"; - if (st->codec->codec_id == AV_CODEC_ID_AAC) { + if (st->codecpar->codec_id == AV_CODEC_ID_AAC) { os->fourcc = "AACL"; os->audio_tag = 0xff; - } else if (st->codec->codec_id == AV_CODEC_ID_WMAPRO) { + } else if (st->codecpar->codec_id == AV_CODEC_ID_WMAPRO) { os->fourcc = "WMAP"; os->audio_tag = 0x0162; } else { @@ -389,7 +389,7 @@ static int ism_write_header(AVFormatContext *s) ret = AVERROR(EINVAL); goto fail; } - os->packet_size = st->codec->block_align ? st->codec->block_align : 4; + os->packet_size = st->codecpar->block_align ? st->codecpar->block_align : 4; } get_private_data(os); } @@ -588,7 +588,7 @@ static int ism_write_packet(AVFormatContext *s, AVPacket *pkt) if (st->first_dts == AV_NOPTS_VALUE) st->first_dts = pkt->dts; - if ((!c->has_video || st->codec->codec_type == AVMEDIA_TYPE_VIDEO) && + if ((!c->has_video || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) && av_compare_ts(pkt->dts - st->first_dts, st->time_base, end_dts, AV_TIME_BASE_Q) >= 0 && pkt->flags & AV_PKT_FLAG_KEY && os->packets_written) { |