[FFmpeg-devel] [PATCH] MTH demuxer (Gamecube format)

Vitor Sessak vitor1001
Tue Feb 3 19:05:47 CET 2009


Michael Montanye wrote:
> I was hoping to find a second game to sample, but my small collection 
> only gave me one game that used these.
> 
> Two samples from the game are uploaded in the mth/ folder of incoming.

Just some nitpickings...

> +
> +#include "avformat.h"
> +
> +typedef struct MthDemuxContext {
> +    int              width;
> +    int              height;
> +    int              fps;
> +    AVRational       framerate;

Those can be local vars.

> +    int              framecnt;

> +    int              offset;

Unused

> +    int              first_frame;
> +    int              first_framesz;
> +    int              frame;
> +    int              next_frame;
> +    int              next_framesz;

> +    AVStream*        vst;

Unused

> +static int mth_probe(AVProbeData *p)
> +{
> +    /* check file header */
> +    if (AV_RL32(p->buf) == MKTAG('M', 'T', 'H', 'P'))
> +        return AVPROBE_SCORE_MAX;
> +    else
> +        return 0;
> +}

This is a little false-positive prone (just four bytes). Something like 
the following is better

if (AV_RL32(p->buf) != MKTAG('M', 'T', 'H', 'P'))
     return 0;

if ({fps, width and weight are sane})
    return AVPROBE_SCORE_MAX;
else
    return AVPROBE_SCORE_MAX/3;

> +static int mth_read_packet(AVFormatContext *s,
> +                            AVPacket *pkt)
> +{
> +    MthDemuxContext *mth = s->priv_data;
> +    ByteIOContext *pb = s->pb;
> +    int size;
> +    int ret;
> +
> +    /* Terminate when last frame is reached.  */
> +    if (mth->frame >= mth->framecnt)
> +        return AVERROR(EIO);

Is there any reason to stop before EOF? If not, them you also don't need 
all the frame counting logic...

-Vitor




More information about the ffmpeg-devel mailing list