diff options
author | Steven Liu <lq@chinaffmpeg.org> | 2019-07-04 16:11:47 +0800 |
---|---|---|
committer | Steven Liu <lq@chinaffmpeg.org> | 2019-07-04 16:11:47 +0800 |
commit | 6e988b75df9a137ddadcd1c3856e3578f5210a43 (patch) | |
tree | 9fcff26d417dbc643f3ae0d732586a2a76ec45e5 /libavformat | |
parent | 43e0ddd33dac8f7476d493ac78616b364ba28355 (diff) | |
download | ffmpeg-6e988b75df9a137ddadcd1c3856e3578f5210a43.tar.gz |
avformat/dashdec: refine and fix code style of dash_read_header
move the temp variable to the top of the expression paragraph
rename the pls to rep(representation)
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/dashdec.c | 67 |
1 files changed, 32 insertions, 35 deletions
diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index 8d020f3f48..a78b90b5b0 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -2028,6 +2028,7 @@ static int copy_init_section(struct representation *rep_dest, struct representat static int dash_read_header(AVFormatContext *s) { DASHContext *c = s->priv_data; + struct representation *rep; int ret = 0; int stream_index = 0; int i; @@ -2053,17 +2054,17 @@ static int dash_read_header(AVFormatContext *s) /* Open the demuxer for video and audio components if available */ for (i = 0; i < c->n_videos; i++) { - struct representation *cur_video = c->videos[i]; + rep = c->videos[i]; if (i > 0 && c->is_init_section_common_video) { - ret = copy_init_section(cur_video,c->videos[0]); + ret = copy_init_section(rep, c->videos[0]); if (ret < 0) goto fail; } - ret = open_demux_for_component(s, cur_video); + ret = open_demux_for_component(s, rep); if (ret) goto fail; - cur_video->stream_index = stream_index; + rep->stream_index = stream_index; ++stream_index; } @@ -2071,17 +2072,17 @@ static int dash_read_header(AVFormatContext *s) c->is_init_section_common_audio = is_common_init_section_exist(c->audios, c->n_audios); for (i = 0; i < c->n_audios; i++) { - struct representation *cur_audio = c->audios[i]; + rep = c->audios[i]; if (i > 0 && c->is_init_section_common_audio) { - ret = copy_init_section(cur_audio,c->audios[0]); + ret = copy_init_section(rep, c->audios[0]); if (ret < 0) goto fail; } - ret = open_demux_for_component(s, cur_audio); + ret = open_demux_for_component(s, rep); if (ret) goto fail; - cur_audio->stream_index = stream_index; + rep->stream_index = stream_index; ++stream_index; } @@ -2089,21 +2090,20 @@ static int dash_read_header(AVFormatContext *s) c->is_init_section_common_audio = is_common_init_section_exist(c->subtitles, c->n_subtitles); for (i = 0; i < c->n_subtitles; i++) { - struct representation *cur_subtitle = c->subtitles[i]; + rep = c->subtitles[i]; if (i > 0 && c->is_init_section_common_audio) { - ret = copy_init_section(cur_subtitle,c->subtitles[0]); + ret = copy_init_section(rep, c->subtitles[0]); if (ret < 0) goto fail; } - ret = open_demux_for_component(s, cur_subtitle); + ret = open_demux_for_component(s, rep); if (ret) goto fail; - cur_subtitle->stream_index = stream_index; + rep->stream_index = stream_index; ++stream_index; } - if (!stream_index) { ret = AVERROR_INVALIDDATA; goto fail; @@ -2118,33 +2118,30 @@ static int dash_read_header(AVFormatContext *s) } for (i = 0; i < c->n_videos; i++) { - struct representation *pls = c->videos[i]; - - av_program_add_stream_index(s, 0, pls->stream_index); - pls->assoc_stream = s->streams[pls->stream_index]; - if (pls->bandwidth > 0) - av_dict_set_int(&pls->assoc_stream->metadata, "variant_bitrate", pls->bandwidth, 0); - if (pls->id[0]) - av_dict_set(&pls->assoc_stream->metadata, "id", pls->id, 0); + rep = c->videos[i]; + av_program_add_stream_index(s, 0, rep->stream_index); + rep->assoc_stream = s->streams[rep->stream_index]; + if (rep->bandwidth > 0) + av_dict_set_int(&rep->assoc_stream->metadata, "variant_bitrate", rep->bandwidth, 0); + if (rep->id[0]) + av_dict_set(&rep->assoc_stream->metadata, "id", rep->id, 0); } for (i = 0; i < c->n_audios; i++) { - struct representation *pls = c->audios[i]; - - av_program_add_stream_index(s, 0, pls->stream_index); - pls->assoc_stream = s->streams[pls->stream_index]; - if (pls->bandwidth > 0) - av_dict_set_int(&pls->assoc_stream->metadata, "variant_bitrate", pls->bandwidth, 0); - if (pls->id[0]) - av_dict_set(&pls->assoc_stream->metadata, "id", pls->id, 0); + rep = c->audios[i]; + av_program_add_stream_index(s, 0, rep->stream_index); + rep->assoc_stream = s->streams[rep->stream_index]; + if (rep->bandwidth > 0) + av_dict_set_int(&rep->assoc_stream->metadata, "variant_bitrate", rep->bandwidth, 0); + if (rep->id[0]) + av_dict_set(&rep->assoc_stream->metadata, "id", rep->id, 0); } for (i = 0; i < c->n_subtitles; i++) { - struct representation *pls = c->subtitles[i]; - av_program_add_stream_index(s, 0, pls->stream_index); - pls->assoc_stream = s->streams[pls->stream_index]; - if (pls->id[0]) - av_dict_set(&pls->assoc_stream->metadata, "id", pls->id, 0); + rep = c->subtitles[i]; + av_program_add_stream_index(s, 0, rep->stream_index); + rep->assoc_stream = s->streams[rep->stream_index]; + if (rep->id[0]) + av_dict_set(&rep->assoc_stream->metadata, "id", rep->id, 0); } - } return 0; |