Commit 6e988b75 authored by Steven Liu's avatar Steven Liu

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)
parent 43e0ddd3
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment