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/rmenc.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/rmenc.c')
-rw-r--r-- | libavformat/rmenc.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/libavformat/rmenc.c b/libavformat/rmenc.c index 33eaf6360d..a0cda92da1 100644 --- a/libavformat/rmenc.c +++ b/libavformat/rmenc.c @@ -33,7 +33,7 @@ typedef struct StreamInfo { int nb_frames; /* current frame number */ int total_frames; /* total number of frames */ int num; - AVCodecContext *enc; + AVCodecParameters *par; } StreamInfo; typedef struct RMMuxContext { @@ -147,7 +147,7 @@ static int rv10_write_header(AVFormatContext *ctx, stream = &rm->streams[i]; - if (stream->enc->codec_type == AVMEDIA_TYPE_AUDIO) { + if (stream->par->codec_type == AVMEDIA_TYPE_AUDIO) { desc = "The Audio Stream"; mimetype = "audio/x-pn-realaudio"; codec_data_size = 73; @@ -183,11 +183,11 @@ static int rv10_write_header(AVFormatContext *ctx, put_str8(s, mimetype); avio_wb32(s, codec_data_size); - if (stream->enc->codec_type == AVMEDIA_TYPE_AUDIO) { + if (stream->par->codec_type == AVMEDIA_TYPE_AUDIO) { int coded_frame_size, fscode, sample_rate; - int frame_size = av_get_audio_frame_duration(stream->enc, 0); - sample_rate = stream->enc->sample_rate; - coded_frame_size = (stream->enc->bit_rate * + int frame_size = av_get_audio_frame_duration2(stream->par, 0); + sample_rate = stream->par->sample_rate; + coded_frame_size = (stream->par->bit_rate * frame_size) / (8 * sample_rate); /* audio codec info */ avio_write(s, ".ra", 3); @@ -222,19 +222,19 @@ static int rv10_write_header(AVFormatContext *ctx, coded_frame_size--; avio_wb32(s, coded_frame_size); /* frame length */ avio_wb32(s, 0x51540); /* unknown */ - avio_wb32(s, stream->enc->bit_rate / 8 * 60); /* bytes per minute */ - avio_wb32(s, stream->enc->bit_rate / 8 * 60); /* bytes per minute */ + avio_wb32(s, stream->par->bit_rate / 8 * 60); /* bytes per minute */ + avio_wb32(s, stream->par->bit_rate / 8 * 60); /* bytes per minute */ avio_wb16(s, 0x01); /* frame length : seems to be very important */ avio_wb16(s, coded_frame_size); avio_wb32(s, 0); /* unknown */ - avio_wb16(s, stream->enc->sample_rate); /* sample rate */ + avio_wb16(s, stream->par->sample_rate); /* sample rate */ avio_wb32(s, 0x10); /* unknown */ - avio_wb16(s, stream->enc->channels); + avio_wb16(s, stream->par->channels); put_str8(s, "Int0"); /* codec name */ - if (stream->enc->codec_tag) { + if (stream->par->codec_tag) { avio_w8(s, 4); /* tag length */ - avio_wl32(s, stream->enc->codec_tag); + avio_wl32(s, stream->par->codec_tag); } else { av_log(ctx, AV_LOG_ERROR, "Invalid codec tag\n"); return -1; @@ -247,12 +247,12 @@ static int rv10_write_header(AVFormatContext *ctx, /* video codec info */ avio_wb32(s,34); /* size */ ffio_wfourcc(s, "VIDO"); - if(stream->enc->codec_id == AV_CODEC_ID_RV10) + if(stream->par->codec_id == AV_CODEC_ID_RV10) ffio_wfourcc(s,"RV10"); else ffio_wfourcc(s,"RV20"); - avio_wb16(s, stream->enc->width); - avio_wb16(s, stream->enc->height); + avio_wb16(s, stream->par->width); + avio_wb16(s, stream->par->height); avio_wb16(s, stream->frame_rate.num / stream->frame_rate.den); /* frames per seconds ? */ avio_wb32(s,0); /* unknown meaning */ avio_wb16(s, stream->frame_rate.num / stream->frame_rate.den); /* unknown meaning */ @@ -261,7 +261,7 @@ static int rv10_write_header(AVFormatContext *ctx, /* Seems to be the codec version: only use basic H263. The next versions seems to add a diffential DC coding as in MPEG... nothing new under the sun */ - if(stream->enc->codec_id == AV_CODEC_ID_RV10) + if(stream->par->codec_id == AV_CODEC_ID_RV10) avio_wb32(s,0x10000000); else avio_wb32(s,0x20103001); @@ -312,7 +312,7 @@ static int rm_write_header(AVFormatContext *s) RMMuxContext *rm = s->priv_data; StreamInfo *stream; int n; - AVCodecContext *codec; + AVCodecParameters *par; if (s->nb_streams > 2) { av_log(s, AV_LOG_ERROR, "At most 2 streams are currently supported for muxing in RM\n"); @@ -324,18 +324,18 @@ static int rm_write_header(AVFormatContext *s) int frame_size; s->streams[n]->id = n; - codec = s->streams[n]->codec; + par = s->streams[n]->codecpar; stream = &rm->streams[n]; memset(stream, 0, sizeof(StreamInfo)); stream->num = n; - stream->bit_rate = codec->bit_rate; - stream->enc = codec; + stream->bit_rate = par->bit_rate; + stream->par = par; - switch(codec->codec_type) { + switch (par->codec_type) { case AVMEDIA_TYPE_AUDIO: rm->audio_stream = stream; - frame_size = av_get_audio_frame_duration(codec, 0); - stream->frame_rate = (AVRational){codec->sample_rate, frame_size}; + frame_size = av_get_audio_frame_duration2(par, 0); + stream->frame_rate = (AVRational){par->sample_rate, frame_size}; /* XXX: dummy values */ stream->packet_max_size = 1024; stream->nb_packets = 0; @@ -370,7 +370,7 @@ static int rm_write_audio(AVFormatContext *s, const uint8_t *buf, int size, int write_packet_header(s, stream, size, !!(flags & AV_PKT_FLAG_KEY)); - if (stream->enc->codec_id == AV_CODEC_ID_AC3) { + if (stream->par->codec_id == AV_CODEC_ID_AC3) { /* for AC-3, the words seem to be reversed */ for (i = 0; i < size; i += 2) { avio_w8(pb, buf[i + 1]); @@ -433,7 +433,7 @@ static int rm_write_video(AVFormatContext *s, const uint8_t *buf, int size, int static int rm_write_packet(AVFormatContext *s, AVPacket *pkt) { - if (s->streams[pkt->stream_index]->codec->codec_type == + if (s->streams[pkt->stream_index]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) return rm_write_audio(s, pkt->data, pkt->size, pkt->flags); else |