On Mon, Dec 10, 2018 at 01:05:05PM +0100, Paul B Mahol wrote: > Signed-off-by: Paul B Mahol <[email protected]> > --- > libavformat/Makefile | 1 + > libavformat/allformats.c | 1 + > libavformat/vividas.c | 708 +++++++++++++++++++++++++++++++++++++++ > 3 files changed, 710 insertions(+) > create mode 100644 libavformat/vividas.c [...] > +} > + > +static int viv_read_packet(AVFormatContext *s, > + AVPacket *pkt) > +{ > + VividasDemuxContext *viv = s->priv_data; > + AVIOContext *pb; > + int64_t off; > + > + if (avio_feof(viv->sb_pb)) > + return AVERROR_EOF; > + > + if (viv->current_audio_subpacket < viv->n_audio_subpackets) { > + AVStream *astream; > + int size = > viv->audio_subpackets[viv->current_audio_subpacket+1].start - > viv->audio_subpackets[viv->current_audio_subpacket].start; > + pb = viv->sb_pb;
> + av_get_packet(pb, pkt, size);
missing failure check
> + pkt->pos += viv->sb_offset +
> viv->sb_blocks[viv->current_sb].byte_offset;
> +
> + pkt->stream_index = 1;
> + astream = s->streams[pkt->stream_index];
> +
> + pkt->pts = av_rescale(viv->audio_sample, astream->time_base.den,
> astream->time_base.num) / astream->codecpar->sample_rate;
> + viv->audio_sample +=
> viv->audio_subpackets[viv->current_audio_subpacket].pcm_bytes / 2 /
> astream->codecpar->channels;
> + pkt->flags |= AV_PKT_FLAG_KEY;
> + viv->current_audio_subpacket++;
> + return 0;
> + }
> +
> + if (viv->current_sb_entry >= viv->n_sb_entries) {
> + if (viv->current_sb+1 >= viv->n_sb_blocks)
> + return AVERROR(EIO);
> + viv->current_sb++;
> +
> + load_sb_block(s, viv, 0);
> + viv->current_sb_entry = 0;
> + }
> +
> + pb = viv->sb_pb;
> + off = avio_tell(pb);
> + off += viv->sb_entries[viv->current_sb_entry].size;
> +
> + if (viv->sb_entries[viv->current_sb_entry].flag == 0) {
> + int i, v_size = ffio_read_varlen(pb);
> + ffio_read_varlen(pb);
> + av_get_packet(pb, pkt, v_size);
missing failure check
> + pkt->pos += viv->sb_offset +
> viv->sb_blocks[viv->current_sb].byte_offset;
> +
> + pkt->pts = viv->sb_blocks[viv->current_sb].packet_offset +
> viv->current_sb_entry;
> + pkt->flags |= (pkt->data[0]&0x80)?0:AV_PKT_FLAG_KEY;
> + pkt->stream_index = 0;
> +
> + for (i = 0; i < MAX_AUDIO_SUBPACKETS - 1; i++) {
> + int start, pcm_bytes;
> + start = ffio_read_varlen(pb);
> + pcm_bytes = ffio_read_varlen(pb);
> +
> + if (i > 0 && start == 0)
> + break;
> +
> + viv->n_audio_subpackets = i+1;
> + viv->audio_subpackets[i].start = start;
> + viv->audio_subpackets[i].pcm_bytes = pcm_bytes;
> + }
> + viv->audio_subpackets[viv->n_audio_subpackets].start = (int)(off -
> avio_tell(pb));
> + viv->current_audio_subpacket = 0;
> + //viv->n_audio_subpackets = 0;
> + //avio_seek(pb, off, SEEK_SET);
is that intended to be here ?
> +
> + } else {
> + int v_size = ffio_read_varlen(pb);
> + av_get_packet(pb, pkt, v_size);
missing error check
[...]
> +static int viv_read_seek(AVFormatContext *s, int stream_index, int64_t
> timestamp, int flags)
> +{
> + VividasDemuxContext *viv = s->priv_data;
> + int frame = 0;
> + int i;
> +
> + if (stream_index == 0)
> + frame = (int)timestamp;
> + else
> + frame = (int)timestamp * s->streams[stream_index]->time_base.den *
> s->streams[0]->time_base.num / s->streams[stream_index]->time_base.num /
> s->streams[0]->time_base.den;
timestamp is truncated which would lead to incorrect results if a timestamp
outside the int range is used
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
You can kill me, but you cannot change the truth.
signature.asc
Description: PGP signature
_______________________________________________ ffmpeg-devel mailing list [email protected] http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
