1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avformat/dashdec: Cosmetics

1. Perform the necessary reindentations after the last few commits.
2. Adapt switches to the ordinary indentation style.
3. Now that the effective lifetimes of the variables containing
the freshly allocated strings used when parsing the representation
are disjoint, the variables can be replaced by a single variable.
Doing so has the advantage of making it more clear that these are
throwaway variables, hence it has been done.

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
Andreas Rheinhardt 2020-09-19 12:32:27 +02:00
parent f921dd0ccf
commit ed948c1149

View File

@ -843,12 +843,6 @@ static int parse_manifest_representation(AVFormatContext *s, const char *url,
xmlNodePtr segmentlists_tab[3];
xmlNodePtr fragment_timeline_node = NULL;
xmlNodePtr fragment_templates_tab[5];
char *duration_val = NULL;
char *presentation_timeoffset_val = NULL;
char *startnumber_val = NULL;
char *timescale_val = NULL;
char *initialization_val = NULL;
char *media_val = NULL;
char *val = NULL;
xmlNodePtr baseurl_nodes[4];
xmlNodePtr representation_node = node;
@ -869,6 +863,7 @@ static int parse_manifest_representation(AVFormatContext *s, const char *url,
av_log(s, AV_LOG_VERBOSE, "Parsing '%s' - skipp not supported representation type\n", url);
return 0;
}
// convert selected representation to our internal struct
rep = av_mallocz(sizeof(struct representation));
if (!rep)
@ -907,49 +902,49 @@ static int parse_manifest_representation(AVFormatContext *s, const char *url,
fragment_templates_tab[3] = period_segmenttemplate_node;
fragment_templates_tab[4] = period_segmentlist_node;
initialization_val = get_val_from_nodes_tab(fragment_templates_tab, 4, "initialization");
if (initialization_val) {
val = get_val_from_nodes_tab(fragment_templates_tab, 4, "initialization");
if (val) {
rep->init_section = av_mallocz(sizeof(struct fragment));
if (!rep->init_section) {
xmlFree(initialization_val);
xmlFree(val);
goto enomem;
}
c->max_url_size = aligned(c->max_url_size + strlen(initialization_val));
rep->init_section->url = get_content_url(baseurl_nodes, 4, c->max_url_size, rep_id_val, rep_bandwidth_val, initialization_val);
xmlFree(initialization_val);
c->max_url_size = aligned(c->max_url_size + strlen(val));
rep->init_section->url = get_content_url(baseurl_nodes, 4, c->max_url_size, rep_id_val, rep_bandwidth_val, val);
xmlFree(val);
if (!rep->init_section->url)
goto enomem;
rep->init_section->size = -1;
}
media_val = get_val_from_nodes_tab(fragment_templates_tab, 4, "media");
if (media_val) {
c->max_url_size = aligned(c->max_url_size + strlen(media_val));
rep->url_template = get_content_url(baseurl_nodes, 4, c->max_url_size, rep_id_val, rep_bandwidth_val, media_val);
xmlFree(media_val);
val = get_val_from_nodes_tab(fragment_templates_tab, 4, "media");
if (val) {
c->max_url_size = aligned(c->max_url_size + strlen(val));
rep->url_template = get_content_url(baseurl_nodes, 4, c->max_url_size, rep_id_val, rep_bandwidth_val, val);
xmlFree(val);
}
presentation_timeoffset_val = get_val_from_nodes_tab(fragment_templates_tab, 4, "presentationTimeOffset");
if (presentation_timeoffset_val) {
rep->presentation_timeoffset = (int64_t) strtoll(presentation_timeoffset_val, NULL, 10);
val = get_val_from_nodes_tab(fragment_templates_tab, 4, "presentationTimeOffset");
if (val) {
rep->presentation_timeoffset = (int64_t) strtoll(val, NULL, 10);
av_log(s, AV_LOG_TRACE, "rep->presentation_timeoffset = [%"PRId64"]\n", rep->presentation_timeoffset);
xmlFree(presentation_timeoffset_val);
xmlFree(val);
}
duration_val = get_val_from_nodes_tab(fragment_templates_tab, 4, "duration");
if (duration_val) {
rep->fragment_duration = (int64_t) strtoll(duration_val, NULL, 10);
val = get_val_from_nodes_tab(fragment_templates_tab, 4, "duration");
if (val) {
rep->fragment_duration = (int64_t) strtoll(val, NULL, 10);
av_log(s, AV_LOG_TRACE, "rep->fragment_duration = [%"PRId64"]\n", rep->fragment_duration);
xmlFree(duration_val);
xmlFree(val);
}
timescale_val = get_val_from_nodes_tab(fragment_templates_tab, 4, "timescale");
if (timescale_val) {
rep->fragment_timescale = (int64_t) strtoll(timescale_val, NULL, 10);
val = get_val_from_nodes_tab(fragment_templates_tab, 4, "timescale");
if (val) {
rep->fragment_timescale = (int64_t) strtoll(val, NULL, 10);
av_log(s, AV_LOG_TRACE, "rep->fragment_timescale = [%"PRId64"]\n", rep->fragment_timescale);
xmlFree(timescale_val);
xmlFree(val);
}
startnumber_val = get_val_from_nodes_tab(fragment_templates_tab, 4, "startNumber");
if (startnumber_val) {
rep->start_number = rep->first_seq_no = (int64_t) strtoll(startnumber_val, NULL, 10);
val = get_val_from_nodes_tab(fragment_templates_tab, 4, "startNumber");
if (val) {
rep->start_number = rep->first_seq_no = (int64_t) strtoll(val, NULL, 10);
av_log(s, AV_LOG_TRACE, "rep->first_seq_no = [%"PRId64"]\n", rep->first_seq_no);
xmlFree(startnumber_val);
xmlFree(val);
}
if (adaptionset_supplementalproperty_node) {
if (!av_strcasecmp(xmlGetProp(adaptionset_supplementalproperty_node,"schemeIdUri"), "http://dashif.org/guidelines/last-segment-number")) {
@ -1001,23 +996,23 @@ static int parse_manifest_representation(AVFormatContext *s, const char *url,
segmentlists_tab[1] = adaptionset_segmentlist_node;
segmentlists_tab[2] = period_segmentlist_node;
duration_val = get_val_from_nodes_tab(segmentlists_tab, 3, "duration");
timescale_val = get_val_from_nodes_tab(segmentlists_tab, 3, "timescale");
startnumber_val = get_val_from_nodes_tab(segmentlists_tab, 3, "startNumber");
if (duration_val) {
rep->fragment_duration = (int64_t) strtoll(duration_val, NULL, 10);
val = get_val_from_nodes_tab(segmentlists_tab, 3, "duration");
if (val) {
rep->fragment_duration = (int64_t) strtoll(val, NULL, 10);
av_log(s, AV_LOG_TRACE, "rep->fragment_duration = [%"PRId64"]\n", rep->fragment_duration);
xmlFree(duration_val);
xmlFree(val);
}
if (timescale_val) {
rep->fragment_timescale = (int64_t) strtoll(timescale_val, NULL, 10);
val = get_val_from_nodes_tab(segmentlists_tab, 3, "timescale");
if (val) {
rep->fragment_timescale = (int64_t) strtoll(val, NULL, 10);
av_log(s, AV_LOG_TRACE, "rep->fragment_timescale = [%"PRId64"]\n", rep->fragment_timescale);
xmlFree(timescale_val);
xmlFree(val);
}
if (startnumber_val) {
rep->start_number = rep->first_seq_no = (int64_t) strtoll(startnumber_val, NULL, 10);
val = get_val_from_nodes_tab(segmentlists_tab, 3, "startNumber");
if (val) {
rep->start_number = rep->first_seq_no = (int64_t) strtoll(val, NULL, 10);
av_log(s, AV_LOG_TRACE, "rep->first_seq_no = [%"PRId64"]\n", rep->first_seq_no);
xmlFree(startnumber_val);
xmlFree(val);
}
fragmenturl_node = xmlFirstElementChild(representation_segmentlist_node);
@ -1901,11 +1896,8 @@ static int reopen_demux_for_component(AVFormatContext *s, struct representation
pls->ctx = NULL;
goto fail;
}
if (c->is_live) {
ffio_init_context(&pls->pb, avio_ctx_buffer , INITIAL_BUFFER_SIZE, 0, pls, read_data, NULL, NULL);
} else {
ffio_init_context(&pls->pb, avio_ctx_buffer , INITIAL_BUFFER_SIZE, 0, pls, read_data, NULL, seek_data);
}
ffio_init_context(&pls->pb, avio_ctx_buffer, INITIAL_BUFFER_SIZE, 0,
pls, read_data, NULL, c->is_live ? NULL : seek_data);
pls->pb.seekable = 0;
if ((ret = ff_copy_whiteblacklists(pls->ctx, s)) < 0)