+static int64_t read_line_to_bprint_escaped(AVIOContext *s, AVBPrint *bp)
+{
+ int len, end;
+ int64_t read = 0;
+ char tmp[1024];
+ char c;
+ char prev = ' ';
+
+ do {
+ len = 0;
+ do {
+ c = avio_r8(s);
+ end = prev != '\\' && (c == '\r' || c == '\n' || c == '\0');
+ if (!end)
+ tmp[len++] = c;
+ prev = c;
+ } while (!end && len < sizeof(tmp));
+ av_bprint_append_data(bp, tmp, len);
+ read += len;
+ } while (!end);
+
+ if (c == '\r' && avio_r8(s) != '\n' && !avio_feof(s))
+ avio_skip(s, -1);
+
+ if (!c && s->error)
+ return s->error;
+
+ if (!c && !read && avio_feof(s))
+ return AVERROR_EOF;
+
+ return read;
+}
+
+static void get_bprint_line(AVIOContext *s, AVBPrint *bp)
+{
+
+ do {
+ av_bprint_clear(bp);
+ read_line_to_bprint_escaped(s, bp);
+ } while (!avio_feof(s) && (bp->str[0] == ';' || bp->str[0] == '#' || bp->str[0] == 0));
+}
+