X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fvivo.c;h=b2904cd25a7797217155ad780c271196c71cef47;hb=0814610ee35614e417d6942784f7b299f2414a9b;hp=9b9189f307ea5262eab401f2831c1483e9d576bd;hpb=ebdc5c419aef0d9eed8c1ec57b30238194c1db0a;p=ffmpeg diff --git a/libavformat/vivo.c b/libavformat/vivo.c index 9b9189f307e..b2904cd25a7 100644 --- a/libavformat/vivo.c +++ b/libavformat/vivo.c @@ -36,11 +36,12 @@ typedef struct VivoContext { int type; int sequence; int length; + int duration; uint8_t text[1024 + 1]; } VivoContext; -static int vivo_probe(AVProbeData *p) +static int vivo_probe(const AVProbeData *p) { const unsigned char *buf = p->buf; unsigned c, length = 0; @@ -59,9 +60,10 @@ static int vivo_probe(AVProbeData *p) if (c & 0x80 || length > 1024 || length < 21) return 0; - if (memcmp(buf, "\r\nVersion:Vivo/", 15)) + buf += 2; + if (memcmp(buf, "Version:Vivo/", 13)) return 0; - buf += 15; + buf += 13; if (*buf < '0' || *buf > '2') return 0; @@ -231,6 +233,12 @@ static int vivo_read_header(AVFormatContext *s) ast->codecpar->bits_per_coded_sample = 8; ast->codecpar->block_align = 24; ast->codecpar->bit_rate = 6400; + } else { + ast->codecpar->codec_id = AV_CODEC_ID_SIREN; + ast->codecpar->bits_per_coded_sample = 16; + ast->codecpar->block_align = 40; + ast->codecpar->bit_rate = 6400; + vivo->duration = 320; } ast->start_time = 0; @@ -246,7 +254,7 @@ static int vivo_read_packet(AVFormatContext *s, AVPacket *pkt) VivoContext *vivo = s->priv_data; AVIOContext *pb = s->pb; unsigned old_sequence = vivo->sequence, old_type = vivo->type; - int stream_index, ret = 0; + int stream_index, duration, ret = 0; restart: @@ -262,10 +270,12 @@ restart: case 1: case 2: // video stream_index = 0; + duration = 1; break; case 3: case 4: // audio stream_index = 1; + duration = vivo->duration; break; default: av_log(s, AV_LOG_ERROR, "unknown packet type %d\n", vivo->type); @@ -273,36 +283,33 @@ restart: } if ((ret = av_get_packet(pb, pkt, vivo->length)) < 0) - goto fail; + return ret; // get next packet header if ((ret = vivo_get_packet_header(s)) < 0) - goto fail; + return ret; while (vivo->sequence == old_sequence && (((vivo->type - 1) >> 1) == ((old_type - 1) >> 1))) { if (avio_feof(pb)) { - ret = AVERROR_EOF; - break; + return AVERROR_EOF; } if ((ret = av_append_packet(pb, pkt, vivo->length)) < 0) - break; + return ret; // get next packet header if ((ret = vivo_get_packet_header(s)) < 0) - break; + return ret; } pkt->stream_index = stream_index; + pkt->duration = duration; -fail: - if (ret < 0) - av_packet_unref(pkt); return ret; } -AVInputFormat ff_vivo_demuxer = { +const AVInputFormat ff_vivo_demuxer = { .name = "vivo", .long_name = NULL_IF_CONFIG_SMALL("Vivo"), .priv_data_size = sizeof(VivoContext),