[FFmpeg-devel] [PATCH] Demuxer for Leitch/Harris' VR native stream format (LXF)

Michael Niedermayer michaelni
Tue Sep 28 00:22:01 CEST 2010


On Mon, Sep 27, 2010 at 09:59:40AM +0200, Tomas H?rdin wrote:
> On Sat, 2010-09-25 at 05:22 +0200, Michael Niedermayer wrote:
> > > +
> > > +/**
> > > + * Read and checksum the next packet header
> > > + *
> > > + * @param[out] header the read packet header
> > > + * @param[out] format context dependent format information
> > > + * @return the size of the payload following the header or < 0 on failure
> > > + */
> > > +static int get_packet_header(AVFormatContext *s, uint8_t *header, uint32_t *format)
> > > +{
> > > +    ByteIOContext   *pb  = s->pb;
> > > +    int size, track_size, samples;
> > > +    AVStream *st;
> > > +
> > > +    if (get_buffer(pb, header, LXF_PACKET_HEADER_SIZE) != LXF_PACKET_HEADER_SIZE)
> > > +        return AVERROR(EIO);
> > > +
> > > +    if (memcmp(header, LXF_IDENT, LXF_IDENT_LENGTH)) {
> > > +        av_log(s, AV_LOG_ERROR, "packet ident mismatch - out of sync?\n");
> > > +        return -1;
> > > +    }
> > 
> > searching for the next matching ident instead of failing would make sense
> 
> I had thought of that, but forgot to implement it. Updated patch
> attached. I tested it by corrupting a bunch of idents in my test files.
> Worked great, except for the obvious packet loss artifacts.
> 
> Both patches attached since I rebased against the latest revision.
> 
> /Tomas
[...]
> +static int lxf_read_packet(AVFormatContext *s, AVPacket *pkt)
> +{
> +    LXFDemuxContext *lxf = s->priv_data;
> +    ByteIOContext   *pb  = s->pb;
> +    uint8_t header[LXF_PACKET_HEADER_SIZE], *buf;
> +    int ret, stream, format;
> +    AVStream *ast = NULL;
> +
> +    if ((ret = get_packet_header(s, header, &format)) < 0)
> +        return ret;
> +
> +    av_log(s, AV_LOG_DEBUG, "got %d B packet\n", ret);
> +
> +    if ((stream = AV_RL32(&header[16])) == 1 && !(ast = s->streams[stream])) {
> +        av_log(s, AV_LOG_ERROR, "got audio packet without having an audio stream\n");
> +        return -1;
> +    }
> +
> +    //make sure the data fits in the de-planerization buffer
> +    if (ast && ret > LXF_MAX_AUDIO_PACKET) {
> +        av_log(s, AV_LOG_ERROR, "audio packet too large (%i > %i)\n",
> +            ret, LXF_MAX_AUDIO_PACKET);
> +        return -1;
> +    }
> +
> +    if (av_new_packet(pkt, ret))
> +        return AVERROR_IO;
> +
> +    //read non-20-bit audio data into lxf->temp so we can deplanarize it
> +    buf = ast && ast->codec->codec_id != CODEC_ID_PCM_LXF ? lxf->temp : pkt->data;
> +
> +    if (get_buffer(pb, buf, ret) != ret) {
> +        av_free_packet(pkt);
> +        return AVERROR_IO;
> +    }
> +

> +    pkt->stream_index = stream;

this isnt checked for validity


[...]
>  allcodecs.c |    1 +
>  avcodec.h   |    5 +++--
>  pcm.c       |   26 +++++++++++++++++++++++++-
>  3 files changed, 29 insertions(+), 3 deletions(-)
> 02b2b0f0730e657212c3ea98c89783be3f6854cf  pcm_lxf2.patch

looks ok

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100928/d8eb9a90/attachment.pgp>



More information about the ffmpeg-devel mailing list