Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-08-24 18:47:04 +0300
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-09-17 05:17:25 +0300
commiteaacb5c513512b13140d161cd038a845d87ae0d9 (patch)
tree3c597b33e52d5b9f7b88aed55eae8b011b55a549 /libavformat/asfenc.c
parent8ab5bf512a5705975f698f799979a77d748a7313 (diff)
avformat/asfenc, mux, utils: Use smaller scope for variables
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat/asfenc.c')
-rw-r--r--libavformat/asfenc.c54
1 files changed, 23 insertions, 31 deletions
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index b294431aec..07588772c6 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -329,10 +329,9 @@ static int64_t unix_to_file_time(int64_t ti)
static int32_t get_send_time(ASFContext *asf, int64_t pres_time, uint64_t *offset)
{
- int i;
int32_t send_time = 0;
*offset = asf->data_offset + DATA_HEADER_SIZE;
- for (i = 0; i < asf->next_start_sec; i++) {
+ for (int i = 0; i < asf->next_start_sec; i++) {
if (pres_time <= asf->index_ptr[i].send_time)
break;
send_time = asf->index_ptr[i].send_time;
@@ -346,7 +345,6 @@ static int asf_write_markers(AVFormatContext *s)
{
ASFContext *asf = s->priv_data;
AVIOContext *pb = s->pb;
- int i;
AVRational scale = {1, 10000000};
int64_t hpos = put_header(pb, &ff_asf_marker_header);
@@ -355,7 +353,7 @@ static int asf_write_markers(AVFormatContext *s)
avio_wl16(pb, 0); // ASF spec mandates 0 for this
avio_wl16(pb, 0); // name length 0, no name given
- for (i = 0; i < s->nb_chapters; i++) {
+ for (unsigned i = 0; i < s->nb_chapters; i++) {
AVChapter *c = s->chapters[i];
AVDictionaryEntry *t = av_dict_get(c->metadata, "title", NULL, 0);
int64_t pres_time = av_rescale_q(c->start, c->time_base, scale);
@@ -392,10 +390,9 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
ASFContext *asf = s->priv_data;
AVIOContext *pb = s->pb;
AVDictionaryEntry *tags[5];
- int header_size, n, extra_size, extra_size2, wav_extra_size;
+ int header_size, extra_size, extra_size2, wav_extra_size;
int has_title, has_aspect_ratio = 0;
int metadata_count;
- AVCodecParameters *par;
int64_t header_offset, cur_pos, hpos;
int bit_rate;
int64_t duration;
@@ -420,9 +417,10 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
metadata_count = av_dict_count(s->metadata);
bit_rate = 0;
- for (n = 0; n < s->nb_streams; n++) {
+ for (unsigned n = 0; n < s->nb_streams; n++) {
+ AVStream *const st = s->streams[n];
+ AVCodecParameters *const par = st->codecpar;
AVDictionaryEntry *entry;
- par = s->streams[n]->codecpar;
avpriv_set_pts_info(s->streams[n], 32, 1, 1000); /* 32 bit pts in ms */
@@ -489,18 +487,17 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
avio_wl32(pb, 0); /* length, to be filled later */
if (asf->nb_languages) {
int64_t hpos2;
- int i;
int nb_audio_languages = 0;
hpos2 = put_header(pb, &ff_asf_language_guid);
avio_wl16(pb, asf->nb_languages);
- for (i = 0; i < asf->nb_languages; i++) {
+ for (int i = 0; i < asf->nb_languages; i++) {
avio_w8(pb, 6);
avio_put_str16le(pb, asf->languages[i]);
}
end_header(pb, hpos2);
- for (i = 0; i < asf->nb_languages; i++)
+ for (int i = 0; i < asf->nb_languages; i++)
if (audio_language_counts[i])
nb_audio_languages++;
@@ -508,10 +505,10 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
hpos2 = put_header(pb, &ff_asf_group_mutual_exclusion_object);
ff_put_guid(pb, &ff_asf_mutex_language);
avio_wl16(pb, nb_audio_languages);
- for (i = 0; i < asf->nb_languages; i++) {
+ for (int i = 0; i < asf->nb_languages; i++) {
if (audio_language_counts[i]) {
avio_wl16(pb, audio_language_counts[i]);
- for (n = 0; n < s->nb_streams; n++)
+ for (unsigned n = 0; n < s->nb_streams; n++)
if (asf->streams[n].stream_language_index == i && s->streams[n]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
avio_wl16(pb, n + 1);
}
@@ -519,7 +516,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
end_header(pb, hpos2);
}
- for (n = 0; n < s->nb_streams; n++) {
+ for (unsigned n = 0; n < s->nb_streams; n++) {
int64_t es_pos;
if (asf->streams[n].stream_language_index > 127)
continue;
@@ -546,8 +543,8 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
int64_t hpos2;
hpos2 = put_header(pb, &ff_asf_metadata_header);
avio_wl16(pb, 2 * has_aspect_ratio);
- for (n = 0; n < s->nb_streams; n++) {
- par = s->streams[n]->codecpar;
+ for (unsigned n = 0; n < s->nb_streams; n++) {
+ AVCodecParameters *const par = s->streams[n]->codecpar;
if ( par->codec_type == AVMEDIA_TYPE_VIDEO
&& par->sample_aspect_ratio.num > 0
&& par->sample_aspect_ratio.den > 0) {
@@ -592,7 +589,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
hpos = put_header(pb, &ff_asf_comment_header);
- for (n = 0; n < FF_ARRAY_ELEMS(tags); n++) {
+ for (size_t n = 0; n < FF_ARRAY_ELEMS(tags); n++) {
len = tags[n] ? avio_put_str16le(dyn_buf, tags[n]->value) : 0;
avio_wl16(pb, len);
}
@@ -619,11 +616,11 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
return ret;
}
/* stream headers */
- for (n = 0; n < s->nb_streams; n++) {
+ for (unsigned n = 0; n < s->nb_streams; n++) {
+ AVCodecParameters *const par = s->streams[n]->codecpar;
int64_t es_pos;
// ASFStream *stream = &asf->streams[n];
- par = s->streams[n]->codecpar;
asf->streams[n].num = n + 1;
asf->streams[n].seq = 1;
@@ -696,13 +693,11 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
hpos = put_header(pb, &ff_asf_codec_comment_header);
ff_put_guid(pb, &ff_asf_codec_comment1_header);
avio_wl32(pb, s->nb_streams);
- for (n = 0; n < s->nb_streams; n++) {
- const AVCodecDescriptor *codec_desc;
+ for (unsigned n = 0; n < s->nb_streams; n++) {
+ AVCodecParameters *const par = s->streams[n]->codecpar;
+ const AVCodecDescriptor *const codec_desc = avcodec_descriptor_get(par->codec_id);
const char *desc;
- par = s->streams[n]->codecpar;
- codec_desc = avcodec_descriptor_get(par->codec_id);
-
if (par->codec_type == AVMEDIA_TYPE_AUDIO)
avio_wl16(pb, 2);
else if (par->codec_type == AVMEDIA_TYPE_VIDEO)
@@ -832,7 +827,7 @@ static int put_payload_parsing_info(AVFormatContext *s,
{
ASFContext *asf = s->priv_data;
AVIOContext *pb = s->pb;
- int ppi_size, i;
+ int ppi_size;
int64_t start = avio_tell(pb);
int iLengthTypeFlags = ASF_PPI_LENGTH_TYPE_FLAGS;
@@ -843,7 +838,7 @@ static int put_payload_parsing_info(AVFormatContext *s,
av_assert0(padsize >= 0);
avio_w8(pb, ASF_PACKET_ERROR_CORRECTION_FLAGS);
- for (i = 0; i < ASF_PACKET_ERROR_CORRECTION_DATA_SIZE; i++)
+ for (int i = 0; i < ASF_PACKET_ERROR_CORRECTION_DATA_SIZE; i++)
avio_w8(pb, 0x0);
if (asf->multi_payloads_present)
@@ -1015,8 +1010,6 @@ static int update_index(AVFormatContext *s, int start_sec,
ASFContext *asf = s->priv_data;
if (start_sec > asf->next_start_sec) {
- int i;
-
if (!asf->next_start_sec) {
asf->next_packet_number = packet_number;
asf->next_packet_count = packet_count;
@@ -1033,7 +1026,7 @@ static int update_index(AVFormatContext *s, int start_sec,
return err;
}
}
- for (i = asf->next_start_sec; i < start_sec; i++) {
+ for (int i = asf->next_start_sec; i < start_sec; i++) {
asf->index_ptr[i].packet_number = asf->next_packet_number;
asf->index_ptr[i].packet_count = asf->next_packet_count;
asf->index_ptr[i].send_time = asf->next_start_sec * INT64_C(10000000);
@@ -1102,7 +1095,6 @@ static int asf_write_index(AVFormatContext *s, const ASFIndex *index,
uint16_t max, uint32_t count)
{
AVIOContext *pb = s->pb;
- int i;
ff_put_guid(pb, &ff_asf_simple_index_header);
avio_wl64(pb, 24 + 16 + 8 + 4 + 4 + (4 + 2) * count);
@@ -1110,7 +1102,7 @@ static int asf_write_index(AVFormatContext *s, const ASFIndex *index,
avio_wl64(pb, ASF_INDEXED_INTERVAL);
avio_wl32(pb, max);
avio_wl32(pb, count);
- for (i = 0; i < count; i++) {
+ for (uint32_t i = 0; i < count; i++) {
avio_wl32(pb, index[i].packet_number);
avio_wl16(pb, index[i].packet_count);
}