Commit 3b0ef2d8 authored by Stefan Westerfeld's avatar Stefan Westerfeld

testhls: reduce prev/next context to 3 seconds

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 9358bbf1
...@@ -165,26 +165,17 @@ hls_embed_context (const string& in_dir, const string& out_dir, const string& fi ...@@ -165,26 +165,17 @@ hls_embed_context (const string& in_dir, const string& out_dir, const string& fi
} }
fclose (pts); fclose (pts);
/* store 3 seconds of the context before this segment and after this segment (if available) */
size_t ctx_3sec = 3 * out.sample_rate();
segment.vars["start_pos"] = string_printf ("%zd", start_pos); segment.vars["start_pos"] = string_printf ("%zd", start_pos);
segment.vars["size"] = string_printf ("%zd", segment.size); segment.vars["size"] = string_printf ("%zd", segment.size);
segment.vars["prev_size"] = string_printf ("%zd", min<size_t> (start_pos, ctx_3sec));
segment.vars["next_size"] = string_printf ("%zd", min<size_t> (audio_master_data.n_frames() - (segment.size + start_pos), ctx_3sec));
start_pos += segment.size; start_pos += segment.size;
} }
/* fill out next/prev size fields */
for (size_t i = 0; i < segments.size(); i++)
{
if (i > 0)
segments[i].vars["prev_size"] = string_printf ("%zd", segments[i - 1].size);
else
segments[i].vars["prev_size"] = "0";
if (i + 1 < segments.size())
segments[i].vars["next_size"] = string_printf ("%zd", segments[i + 1].size);
else
segments[i].vars["next_size"] = "0";
}
/* write audio segments with context */ /* write audio segments with context */
for (auto& segment : segments) for (auto& segment : segments)
{ {
...@@ -375,7 +366,13 @@ hls_mark (const string& infile, const string& outfile, const string& bits) ...@@ -375,7 +366,13 @@ hls_mark (const string& infile, const string& outfile, const string& bits)
int zrc = add_stream_watermark (&in_stream, &out_stream, bits, start_pos - prev_size); int zrc = add_stream_watermark (&in_stream, &out_stream, bits, start_pos - prev_size);
if (zrc != 0) if (zrc != 0)
return zrc; {
info ("hls_time_abort_enc %f\n", (get_time() - start_time1) * 1000 /* ms */);
double end_time = get_time();
info ("hls_time_abort %f %f\n", start_pos / double (out_stream.sample_rate()), (end_time - start_time) * 1000 /* ms */);
return zrc;
}
info ("hls_time_elapsed_aac_enc %f\n", (get_time() - start_time1) * 1000 /* ms */); info ("hls_time_elapsed_aac_enc %f\n", (get_time() - start_time1) * 1000 /* ms */);
......
...@@ -52,6 +52,11 @@ public: ...@@ -52,6 +52,11 @@ public:
{ {
return m_samples.size(); return m_samples.size();
} }
size_t
n_frames() const
{
return m_samples.size() / m_n_channels;
}
const std::vector<float>& const std::vector<float>&
samples() const samples() const
{ {
......
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