@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/bprint.h"
#include "libavutil/mathematics.h"
#include "avformat.h"
#include "ffmeta.h"
@@ -32,6 +33,15 @@ static int probe(AVProbeData *p)
return 0;
}
+static void get_bprint_line(AVIOContext *s, AVBPrint *bp)
+{
+
+ do {
+ av_bprint_clear(bp);
+ ff_read_line_to_bprint(s, bp);
+ } while (!avio_feof(s) && (bp->str[0] == ';' || bp->str[0] == '#' || bp->str[0] == 0));
+}
+
static void get_line(AVIOContext *s, uint8_t *buf, int size)
{
do {
@@ -128,12 +138,14 @@ static int read_tag(const uint8_t *line, AVDictionary **m)
static int read_header(AVFormatContext *s)
{
AVDictionary **m = &s->metadata;
- uint8_t line[1024];
+ AVBPrint bp;
+
+ av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
while(!avio_feof(s->pb)) {
- get_line(s->pb, line, sizeof(line));
+ get_bprint_line(s->pb, &bp);
- if (!memcmp(line, ID_STREAM, strlen(ID_STREAM))) {
+ if (!memcmp(bp.str, ID_STREAM, strlen(ID_STREAM))) {
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
@@ -143,7 +155,7 @@ static int read_header(AVFormatContext *s)
st->codecpar->codec_id = AV_CODEC_ID_FFMETADATA;
m = &st->metadata;
- } else if (!memcmp(line, ID_CHAPTER, strlen(ID_CHAPTER))) {
+ } else if (!memcmp(bp.str, ID_CHAPTER, strlen(ID_CHAPTER))) {
AVChapter *ch = read_chapter(s);
if (!ch)
@@ -151,9 +163,11 @@ static int read_header(AVFormatContext *s)
m = &ch->metadata;
} else
- read_tag(line, m);
+ read_tag(bp.str, m);
}
+ av_bprint_finalize(&bp, NULL);
+
s->start_time = 0;
if (s->nb_chapters)
s->duration = av_rescale_q(s->chapters[s->nb_chapters - 1]->end,
Use bprint API instead. Fixes #4833. Signed-off-by: Paul B Mahol <onemda@gmail.com> --- libavformat/ffmetadec.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)