summaryrefslogtreecommitdiff
path: root/libavformat/asfenc.c
diff options
context:
space:
mode:
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-04-10 20:58:15 +0100
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-04-10 20:59:55 +0100
commit6f69f7a8bf6a0d013985578df2ef42ee6b1c7994 (patch)
tree0c2ec8349ff1763d5f48454b8b9f26374dbd80b0 /libavformat/asfenc.c
parent60b75186b2c878b6257b43c8fcc0b1356ada218e (diff)
parent9200514ad8717c63f82101dc394f4378854325bf (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/asfenc.c')
-rw-r--r--libavformat/asfenc.c82
1 files changed, 41 insertions, 41 deletions
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index 66551ea373..cfa4fadc07 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -392,7 +392,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
int header_size, n, extra_size, extra_size2, wav_extra_size;
int has_title, has_aspect_ratio = 0;
int metadata_count;
- AVCodecContext *enc;
+ AVCodecParameters *par;
int64_t header_offset, cur_pos, hpos;
int bit_rate;
int64_t duration;
@@ -419,14 +419,14 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
bit_rate = 0;
for (n = 0; n < s->nb_streams; n++) {
AVDictionaryEntry *entry;
- enc = s->streams[n]->codec;
+ par = s->streams[n]->codecpar;
avpriv_set_pts_info(s->streams[n], 32, 1, 1000); /* 32 bit pts in ms */
- bit_rate += enc->bit_rate;
- if ( enc->codec_type == AVMEDIA_TYPE_VIDEO
- && enc->sample_aspect_ratio.num > 0
- && enc->sample_aspect_ratio.den > 0)
+ bit_rate += par->bit_rate;
+ if ( par->codec_type == AVMEDIA_TYPE_VIDEO
+ && par->sample_aspect_ratio.num > 0
+ && par->sample_aspect_ratio.den > 0)
has_aspect_ratio++;
entry = av_dict_get(s->streams[n]->metadata, "language", NULL, 0);
@@ -445,7 +445,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
asf->streams[n].stream_language_index = asf->nb_languages;
asf->nb_languages++;
}
- if (enc->codec_type == AVMEDIA_TYPE_AUDIO)
+ if (par->codec_type == AVMEDIA_TYPE_AUDIO)
audio_language_counts[asf->streams[n].stream_language_index]++;
}
} else {
@@ -509,7 +509,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
if (audio_language_counts[i]) {
avio_wl16(pb, audio_language_counts[i]);
for (n = 0; n < s->nb_streams; n++)
- if (asf->streams[n].stream_language_index == i && s->streams[n]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
+ if (asf->streams[n].stream_language_index == i && s->streams[n]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
avio_wl16(pb, n + 1);
}
}
@@ -523,10 +523,10 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
es_pos = put_header(pb, &ff_asf_extended_stream_properties_object);
avio_wl64(pb, 0); /* start time */
avio_wl64(pb, 0); /* end time */
- avio_wl32(pb, s->streams[n]->codec->bit_rate); /* data bitrate bps */
+ avio_wl32(pb, s->streams[n]->codecpar->bit_rate); /* data bitrate bps */
avio_wl32(pb, 5000); /* buffer size ms */
avio_wl32(pb, 0); /* initial buffer fullness */
- avio_wl32(pb, s->streams[n]->codec->bit_rate); /* peak data bitrate */
+ avio_wl32(pb, s->streams[n]->codecpar->bit_rate); /* peak data bitrate */
avio_wl32(pb, 5000); /* maximum buffer size ms */
avio_wl32(pb, 0); /* max initial buffer fullness */
avio_wl32(pb, 0); /* max object size */
@@ -544,11 +544,11 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
hpos2 = put_header(pb, &ff_asf_metadata_header);
avio_wl16(pb, 2 * has_aspect_ratio);
for (n = 0; n < s->nb_streams; n++) {
- enc = s->streams[n]->codec;
- if ( enc->codec_type == AVMEDIA_TYPE_VIDEO
- && enc->sample_aspect_ratio.num > 0
- && enc->sample_aspect_ratio.den > 0) {
- AVRational sar = enc->sample_aspect_ratio;
+ par = s->streams[n]->codecpar;
+ if ( par->codec_type == AVMEDIA_TYPE_VIDEO
+ && par->sample_aspect_ratio.num > 0
+ && par->sample_aspect_ratio.den > 0) {
+ AVRational sar = par->sample_aspect_ratio;
avio_wl16(pb, 0);
// the stream number is set like this below
avio_wl16(pb, n + 1);
@@ -620,11 +620,11 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
int64_t es_pos;
// ASFStream *stream = &asf->streams[n];
- enc = s->streams[n]->codec;
+ par = s->streams[n]->codecpar;
asf->streams[n].num = n + 1;
asf->streams[n].seq = 1;
- switch (enc->codec_type) {
+ switch (par->codec_type) {
case AVMEDIA_TYPE_AUDIO:
wav_extra_size = 0;
extra_size = 18 + wav_extra_size;
@@ -632,14 +632,14 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
break;
default:
case AVMEDIA_TYPE_VIDEO:
- wav_extra_size = enc->extradata_size;
+ wav_extra_size = par->extradata_size;
extra_size = 0x33 + wav_extra_size;
extra_size2 = 0;
break;
}
hpos = put_header(pb, &ff_asf_stream_header);
- if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
ff_put_guid(pb, &ff_asf_audio_stream);
ff_put_guid(pb, &ff_asf_audio_conceal_spread);
} else {
@@ -653,9 +653,9 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
avio_wl16(pb, n + 1); /* stream number */
avio_wl32(pb, 0); /* ??? */
- if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
/* WAVEFORMATEX header */
- int wavsize = ff_put_wav_header(pb, enc, FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX);
+ int wavsize = ff_put_wav_header(s, pb, par, FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX);
if (wavsize < 0)
return -1;
@@ -667,23 +667,23 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
}
/* ERROR Correction */
avio_w8(pb, 0x01);
- if (enc->codec_id == AV_CODEC_ID_ADPCM_G726 || !enc->block_align) {
+ if (par->codec_id == AV_CODEC_ID_ADPCM_G726 || !par->block_align) {
avio_wl16(pb, 0x0190);
avio_wl16(pb, 0x0190);
} else {
- avio_wl16(pb, enc->block_align);
- avio_wl16(pb, enc->block_align);
+ avio_wl16(pb, par->block_align);
+ avio_wl16(pb, par->block_align);
}
avio_wl16(pb, 0x01);
avio_w8(pb, 0x00);
} else {
- avio_wl32(pb, enc->width);
- avio_wl32(pb, enc->height);
+ avio_wl32(pb, par->width);
+ avio_wl32(pb, par->height);
avio_w8(pb, 2); /* ??? */
- avio_wl16(pb, 40 + enc->extradata_size); /* size */
+ avio_wl16(pb, 40 + par->extradata_size); /* size */
/* BITMAPINFOHEADER header */
- ff_put_bmp_header(pb, enc, ff_codec_bmp_tags, 1, 0);
+ ff_put_bmp_header(pb, par, ff_codec_bmp_tags, 1, 0);
}
end_header(pb, hpos);
}
@@ -697,17 +697,17 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
const AVCodecDescriptor *codec_desc;
const char *desc;
- enc = s->streams[n]->codec;
- codec_desc = avcodec_descriptor_get(enc->codec_id);
+ par = s->streams[n]->codecpar;
+ codec_desc = avcodec_descriptor_get(par->codec_id);
- if (enc->codec_type == AVMEDIA_TYPE_AUDIO)
+ if (par->codec_type == AVMEDIA_TYPE_AUDIO)
avio_wl16(pb, 2);
- else if (enc->codec_type == AVMEDIA_TYPE_VIDEO)
+ else if (par->codec_type == AVMEDIA_TYPE_VIDEO)
avio_wl16(pb, 1);
else
avio_wl16(pb, -1);
- if (enc->codec_id == AV_CODEC_ID_WMAV2)
+ if (par->codec_id == AV_CODEC_ID_WMAV2)
desc = "Windows Media Audio V8";
else
desc = codec_desc ? codec_desc->name : NULL;
@@ -732,14 +732,14 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
avio_wl16(pb, 0); /* no parameters */
/* id */
- if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
avio_wl16(pb, 2);
- avio_wl16(pb, enc->codec_tag);
+ avio_wl16(pb, par->codec_tag);
} else {
avio_wl16(pb, 4);
- avio_wl32(pb, enc->codec_tag);
+ avio_wl32(pb, par->codec_tag);
}
- if (!enc->codec_tag)
+ if (!par->codec_tag)
return -1;
}
end_header(pb, hpos);
@@ -963,7 +963,7 @@ static void put_frame(AVFormatContext *s, ASFStream *stream, AVStream *avst,
PACKET_HEADER_MIN_SIZE - 1;
if (frag_len1 < payload_len &&
- avst->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+ avst->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
flush_packet(s);
continue;
}
@@ -1053,7 +1053,7 @@ static int asf_write_packet(AVFormatContext *s, AVPacket *pkt)
ASFContext *asf = s->priv_data;
AVIOContext *pb = s->pb;
ASFStream *stream;
- AVCodecContext *codec;
+ AVCodecParameters *par;
uint32_t packet_number;
int64_t pts;
int start_sec;
@@ -1061,10 +1061,10 @@ static int asf_write_packet(AVFormatContext *s, AVPacket *pkt)
int ret;
uint64_t offset = avio_tell(pb);
- codec = s->streams[pkt->stream_index]->codec;
+ par = s->streams[pkt->stream_index]->codecpar;
stream = &asf->streams[pkt->stream_index];
- if (codec->codec_type == AVMEDIA_TYPE_AUDIO)
+ if (par->codec_type == AVMEDIA_TYPE_AUDIO)
flags &= ~AV_PKT_FLAG_KEY;
pts = (pkt->pts != AV_NOPTS_VALUE) ? pkt->pts : pkt->dts;