diff options
author | Anton Khirnov <anton@khirnov.net> | 2014-05-11 10:07:35 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2014-05-18 10:24:02 +0200 |
commit | c3311d472a7528c67f76d0d061704ae70a99b32e (patch) | |
tree | 97fb345498f4b727b5040633c1c1991a97bf53b9 | |
parent | ab3fdaa7131e2fd8e33006daea25a282724c01f0 (diff) | |
download | ffmpeg-c3311d472a7528c67f76d0d061704ae70a99b32e.tar.gz |
avienc: sanitize variable naming in write_header()
Do not call an AVCodecContext 'stream', that is highly confusing.
Also, add a local variable for the current AVStream in the loop over all
streams.
-rw-r--r-- | libavformat/avienc.c | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/libavformat/avienc.c b/libavformat/avienc.c index a5a2885b73..076152e21a 100644 --- a/libavformat/avienc.c +++ b/libavformat/avienc.c @@ -143,7 +143,7 @@ static int avi_write_header(AVFormatContext *s) AVIContext *avi = s->priv_data; AVIOContext *pb = s->pb; int bitrate, n, i, nb_frames, au_byterate, au_ssize, au_scale; - AVCodecContext *stream, *video_enc; + AVCodecContext *video_enc; int64_t list1, list2, strh, strf; AVDictionaryEntry *t = NULL; @@ -170,10 +170,10 @@ static int avi_write_header(AVFormatContext *s) video_enc = NULL; for (n = 0; n < s->nb_streams; n++) { - stream = s->streams[n]->codec; - bitrate += stream->bit_rate; - if (stream->codec_type == AVMEDIA_TYPE_VIDEO) - video_enc = stream; + AVCodecContext *codec = s->streams[n]->codec; + bitrate += codec->bit_rate; + if (codec->codec_type == AVMEDIA_TYPE_VIDEO) + video_enc = codec; } nb_frames = 0; @@ -208,19 +208,19 @@ static int avi_write_header(AVFormatContext *s) /* stream list */ for (i = 0; i < n; i++) { - AVIStream *avist = s->streams[i]->priv_data; + AVStream *st = s->streams[i]; + AVCodecContext *enc = st->codec; + AVIStream *avist = st->priv_data; list2 = ff_start_tag(pb, "LIST"); ffio_wfourcc(pb, "strl"); - stream = s->streams[i]->codec; - /* stream generic header */ strh = ff_start_tag(pb, "strh"); - switch (stream->codec_type) { + switch (enc->codec_type) { case AVMEDIA_TYPE_SUBTITLE: // XSUB subtitles behave like video tracks, other subtitles // are not (yet) supported. - if (stream->codec_id != AV_CODEC_ID_XSUB) { + if (enc->codec_id != AV_CODEC_ID_XSUB) { av_log(s, AV_LOG_ERROR, "Subtitle streams other than DivX XSUB are not supported by the AVI muxer.\n"); return AVERROR_PATCHWELCOME; @@ -238,9 +238,9 @@ static int avi_write_header(AVFormatContext *s) ffio_wfourcc(pb, "dats"); break; } - if (stream->codec_type == AVMEDIA_TYPE_VIDEO || - stream->codec_id == AV_CODEC_ID_XSUB) - avio_wl32(pb, stream->codec_tag); + if (enc->codec_type == AVMEDIA_TYPE_VIDEO || + enc->codec_id == AV_CODEC_ID_XSUB) + avio_wl32(pb, enc->codec_tag); else avio_wl32(pb, 1); avio_wl32(pb, 0); /* flags */ @@ -248,11 +248,11 @@ static int avi_write_header(AVFormatContext *s) avio_wl16(pb, 0); /* language */ avio_wl32(pb, 0); /* initial frame */ - ff_parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale); + ff_parse_specific_params(enc, &au_byterate, &au_ssize, &au_scale); avio_wl32(pb, au_scale); /* scale */ avio_wl32(pb, au_byterate); /* rate */ - avpriv_set_pts_info(s->streams[i], 64, au_scale, au_byterate); + avpriv_set_pts_info(st, 64, au_scale, au_byterate); avio_wl32(pb, 0); /* start */ /* remember this offset to fill later */ @@ -264,39 +264,39 @@ static int avi_write_header(AVFormatContext *s) avio_wl32(pb, 0); /* length, XXX: filled later */ /* suggested buffer size */ //FIXME set at the end to largest chunk - if (stream->codec_type == AVMEDIA_TYPE_VIDEO) + if (enc->codec_type == AVMEDIA_TYPE_VIDEO) avio_wl32(pb, 1024 * 1024); - else if (stream->codec_type == AVMEDIA_TYPE_AUDIO) + else if (enc->codec_type == AVMEDIA_TYPE_AUDIO) avio_wl32(pb, 12 * 1024); else avio_wl32(pb, 0); avio_wl32(pb, -1); /* quality */ avio_wl32(pb, au_ssize); /* sample size */ avio_wl32(pb, 0); - avio_wl16(pb, stream->width); - avio_wl16(pb, stream->height); + avio_wl16(pb, enc->width); + avio_wl16(pb, enc->height); ff_end_tag(pb, strh); - if (stream->codec_type != AVMEDIA_TYPE_DATA) { + if (enc->codec_type != AVMEDIA_TYPE_DATA) { strf = ff_start_tag(pb, "strf"); - switch (stream->codec_type) { + switch (enc->codec_type) { case AVMEDIA_TYPE_SUBTITLE: /* XSUB subtitles behave like video tracks, other subtitles * are not (yet) supported. */ - if (stream->codec_id != AV_CODEC_ID_XSUB) + if (enc->codec_id != AV_CODEC_ID_XSUB) break; case AVMEDIA_TYPE_VIDEO: - ff_put_bmp_header(pb, stream, ff_codec_bmp_tags, 0); + ff_put_bmp_header(pb, enc, ff_codec_bmp_tags, 0); break; case AVMEDIA_TYPE_AUDIO: - if (ff_put_wav_header(pb, stream) < 0) + if (ff_put_wav_header(pb, enc) < 0) return -1; break; default: return -1; } ff_end_tag(pb, strf); - if ((t = av_dict_get(s->streams[i]->metadata, "title", NULL, 0))) { + if ((t = av_dict_get(st->metadata, "title", NULL, 0))) { ff_riff_write_info_tag(s->pb, "strn", t->value); t = NULL; } @@ -316,7 +316,7 @@ static int avi_write_header(AVFormatContext *s) avio_w8(pb, 0); /* bIndexSubType (0 == frame index) */ avio_w8(pb, 0); /* bIndexType (0 == AVI_INDEX_OF_INDEXES) */ avio_wl32(pb, 0); /* nEntriesInUse (will fill out later on) */ - ffio_wfourcc(pb, avi_stream2fourcc(tag, i, stream->codec_type)); + ffio_wfourcc(pb, avi_stream2fourcc(tag, i, enc->codec_type)); /* dwChunkId */ avio_wl64(pb, 0); /* dwReserved[3] */ // avio_wl32(pb, 0); /* Must be 0. */ @@ -325,31 +325,31 @@ static int avi_write_header(AVFormatContext *s) ff_end_tag(pb, avist->indexes.indx_start); } - if (stream->codec_type == AVMEDIA_TYPE_VIDEO && - s->streams[i]->sample_aspect_ratio.num > 0 && - s->streams[i]->sample_aspect_ratio.den > 0) { + if (enc->codec_type == AVMEDIA_TYPE_VIDEO && + st->sample_aspect_ratio.num > 0 && + st->sample_aspect_ratio.den > 0) { int vprp = ff_start_tag(pb, "vprp"); - AVRational dar = av_mul_q(s->streams[i]->sample_aspect_ratio, - (AVRational) { stream->width, - stream->height }); + AVRational dar = av_mul_q(st->sample_aspect_ratio, + (AVRational) { enc->width, + enc->height }); int num, den; av_reduce(&num, &den, dar.num, dar.den, 0xFFFF); avio_wl32(pb, 0); // video format = unknown avio_wl32(pb, 0); // video standard = unknown - avio_wl32(pb, lrintf(1.0 / av_q2d(stream->time_base))); - avio_wl32(pb, stream->width); - avio_wl32(pb, stream->height); + avio_wl32(pb, lrintf(1.0 / av_q2d(enc->time_base))); + avio_wl32(pb, enc->width); + avio_wl32(pb, enc->height); avio_wl16(pb, den); avio_wl16(pb, num); - avio_wl32(pb, stream->width); - avio_wl32(pb, stream->height); + avio_wl32(pb, enc->width); + avio_wl32(pb, enc->height); avio_wl32(pb, 1); // progressive FIXME - avio_wl32(pb, stream->height); - avio_wl32(pb, stream->width); - avio_wl32(pb, stream->height); - avio_wl32(pb, stream->width); + avio_wl32(pb, enc->height); + avio_wl32(pb, enc->width); + avio_wl32(pb, enc->height); + avio_wl32(pb, enc->width); avio_wl32(pb, 0); avio_wl32(pb, 0); |