[FFmpeg-devel] [PATCH] Psygnosis YOP demuxer

Michael Niedermayer michaelni
Fri Aug 14 02:11:31 CEST 2009


On Thu, Aug 13, 2009 at 07:52:41PM -0400, Thomas Higdon wrote:
[...]
> +static int yop_probe(AVProbeData *probe_packet)
> +{
> +    const char *yop_signature = "YO";

static const

> +    if (memcmp(yop_signature, probe_packet->buf, strlen(yop_signature)))
> +        return 0;
> +
> +    return AVPROBE_SCORE_MAX;
> +}

2 letters is rather small, would it be possible to check more?
if not i think AVPROBE_SCORE_MAX is too much and we would have some
misdetections in the millions of files people throw at ffmpeg ...


> +
> +static int yop_read_header(AVFormatContext *s, AVFormatParameters *ap)
> +{
> +    YopDecContext *yop = s->priv_data;
> +    ByteIOContext *pb  = s->pb;
> +
> +    AVCodecContext *sound_dec, *video_dec;
> +    AVStream *sound_stream, *video_stream;
> +
> +    int num_frames, frame_rate;
> +    int ret;
> +
> +    sound_stream = av_new_stream(s, 0);
> +    video_stream = av_new_stream(s, 1);
> +

> +    // Extra data that will be passed to the decoder
> +    video_stream->codec->extradata_size = 5;
> +
> +    video_stream->codec->extradata =
> +        av_mallocz(video_stream->codec->extradata_size +
> +                   FF_INPUT_BUFFER_PADDING_SIZE);
[...]
> +    if ((ret = get_buffer(pb, video_dec->extradata, 8)) != 8)
> +        return -1;

ehm ... 5 != 8


> +
> +    yop->num_pal_colors = *(uint8_t *)video_dec->extradata;
> +
> +    // 1 nibble per sample
> +    yop->sound_data_length  = 1840 / 2;

> +    yop->sound_chunk_length = *(uint16_t *)(video_dec->extradata + 6);

that is not portable


> +
> +    url_fseek(pb, 2048, SEEK_SET);
> +
> +    av_set_pts_info(video_stream, 32, 1, frame_rate);
> +
> +    yop->stream = 1;
> +
> +    return 0;
> +}
> +

> +/**
> + * Get more data into an already allocated packet.
> + * @param s the ByteIOContext to get the data from
> + * @param pkt the AVPacket structure to get into
> + * @param offset the offset into the data pointer of the packet to get into
> + * @param size the amount of data to get
> + */
> +static int get_partial_packet(ByteIOContext *s, AVPacket* pkt,
> +                              int offset, int size)
> +{
> +    int ret = get_buffer(s, pkt->data + offset, size);
> +    if (ret <= 0)
> +        av_free_packet(pkt);
> +    else
> +        av_shrink_packet(pkt, ret);
> +
> +    pkt->size += size;

this code does not look correct


> +
> +    return ret;
> +}
> +
> +static int yop_read_packet(AVFormatContext *s, AVPacket *pkt)
> +{
> +    YopDecContext *yop = s->priv_data;
> +    ByteIOContext *pb  = s->pb;
> +
> +    int ret;
> +    int palette_size = 4 + yop->num_pal_colors * 3;
> +    int actual_video_data_size =
> +        yop->frame_size - yop->sound_chunk_length - palette_size;
> +
> +    AVStream *st;
> +    yop->stream ^= 1;
> +
> +    if (yop->stream == 0) {
> +        st = s->streams[yop->stream];
> +
> +        ret = av_new_packet(&yop->video_packet,
> +                            yop->frame_size - yop->sound_chunk_length);
> +        if (ret < 0)
> +            return ret;
> +
> +        yop->video_packet.pos = url_ftell(pb);
> +        ret = get_partial_packet(pb, &yop->video_packet, 0, palette_size);
> +
> +        if (ret < 0)
> +            return ret;
> +        else if (ret < palette_size)
> +            return AVERROR_EOF;
> +
> +        ret = av_get_packet(pb, &yop->sound_packet, yop->sound_data_length);
> +        if (ret < yop->sound_data_length)
> +            return AVERROR_EOF;
> +

> +        url_fseek(pb, yop->sound_chunk_length - yop->sound_data_length,
> +                  SEEK_CUR);

that should be a url_fskip with a positive argument i assume

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

Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090814/0518fed4/attachment.pgp>



More information about the ffmpeg-devel mailing list