X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fffmetadec.c;h=21e5ee9da4193d7fe176a9ed42efede1d25839b7;hb=65a25adc97406adaab9ed0c6244fbb69c5cbcc93;hp=0269ac5a0bef09bd7715285ef548a8ba6b31ec96;hpb=645439c3c3ce39114e4f46a9198cd8b9a11c3e66;p=ffmpeg diff --git a/libavformat/ffmetadec.c b/libavformat/ffmetadec.c index 0269ac5a0be..21e5ee9da41 100644 --- a/libavformat/ffmetadec.c +++ b/libavformat/ffmetadec.c @@ -2,25 +2,28 @@ * Metadata demuxer * Copyright (c) 2010 Anton Khirnov * - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * FFmpeg is distributed in the hope that it will be useful, + * Libav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mathematics.h" #include "avformat.h" -#include "meta.h" +#include "ffmeta.h" +#include "internal.h" +#include "libavutil/dict.h" static int probe(AVProbeData *p) { @@ -29,17 +32,17 @@ static int probe(AVProbeData *p) return 0; } -static void get_line(ByteIOContext *s, uint8_t *buf, int size) +static void get_line(AVIOContext *s, uint8_t *buf, int size) { do { uint8_t c; int i = 0; - while ((c = get_byte(s))) { + while ((c = avio_r8(s))) { if (c == '\\') { if (i < size - 1) buf[i++] = c; - c = get_byte(s); + c = avio_r8(s); } else if (c == '\n') break; @@ -47,7 +50,7 @@ static void get_line(ByteIOContext *s, uint8_t *buf, int size) buf[i++] = c; } buf[i] = 0; - } while (!url_feof(s) && (buf[0] == ';' || buf[0] == '#' || buf[0] == 0)); + } while (!s->eof_reached && (buf[0] == ';' || buf[0] == '#' || buf[0] == 0)); } static AVChapter *read_chapter(AVFormatContext *s) @@ -60,19 +63,19 @@ static AVChapter *read_chapter(AVFormatContext *s) if (sscanf(line, "TIMEBASE=%d/%d", &tb.num, &tb.den)) get_line(s->pb, line, sizeof(line)); - if (!sscanf(line, "START=%lld", &start)) { + if (!sscanf(line, "START=%"SCNd64, &start)) { av_log(s, AV_LOG_ERROR, "Expected chapter start timestamp, found %s.\n", line); start = (s->nb_chapters && s->chapters[s->nb_chapters - 1]->end != AV_NOPTS_VALUE) ? s->chapters[s->nb_chapters - 1]->end : 0; } else get_line(s->pb, line, sizeof(line)); - if (!sscanf(line, "END=%lld", &end)) { + if (!sscanf(line, "END=%"SCNd64, &end)) { av_log(s, AV_LOG_ERROR, "Expected chapter end timestamp, found %s.\n", line); end = AV_NOPTS_VALUE; } - return ff_new_chapter(s, s->nb_chapters, tb, start, end, NULL); + return avpriv_new_chapter(s, s->nb_chapters, tb, start, end, NULL); } static uint8_t *unescape(uint8_t *buf, int size) @@ -92,7 +95,7 @@ static uint8_t *unescape(uint8_t *buf, int size) return ret; } -static int read_tag(uint8_t *line, AVMetadata **m) +static int read_tag(uint8_t *line, AVDictionary **m) { uint8_t *key, *value, *p = line; @@ -116,20 +119,20 @@ static int read_tag(uint8_t *line, AVMetadata **m) return AVERROR(ENOMEM); } - av_metadata_set2(m, key, value, AV_METADATA_DONT_STRDUP_KEY | AV_METADATA_DONT_STRDUP_VAL); + av_dict_set(m, key, value, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL); return 0; } static int read_header(AVFormatContext *s, AVFormatParameters *ap) { - AVMetadata **m = &s->metadata; + AVDictionary **m = &s->metadata; uint8_t line[1024]; - while(!url_feof(s->pb)) { + while(!s->pb->eof_reached) { get_line(s->pb, line, sizeof(line)); if (!memcmp(line, ID_STREAM, strlen(ID_STREAM))) { - AVStream *st = av_new_stream(s, 0); + AVStream *st = avformat_new_stream(s, NULL); if (!st) return -1; @@ -163,7 +166,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR_EOF; } -AVInputFormat ffmetadata_demuxer = { +AVInputFormat ff_ffmetadata_demuxer = { .name = "ffmetadata", .long_name = NULL_IF_CONFIG_SMALL("FFmpeg metadata in text format"), .read_probe = probe,