[FFmpeg-devel] [PATCH] SIFF demuxer and decoder
Michael Niedermayer
michaelni
Sat Oct 20 21:42:45 CEST 2007
Hi
On Fri, Oct 19, 2007 at 11:29:47AM +0300, Kostya wrote:
[...]
> +static int vb_decode_framedata(VBDecContext *c, uint8_t *buf, int offset)
> +{
> + uint8_t *prev, *cur;
> + int blk, blocks, t, blk2;
> + int blocktypes = 0;
> + int x, y, a, b;
> + int pattype, pattern;
> + const int width = c->avctx->width;
> + uint8_t *pstart = c->prev_frame;
> + uint8_t *pend = c->prev_frame + width*c->avctx->height;
> +
> + prev = c->prev_frame + offset;
> + cur = c->frame;
> +
> + blocks = (c->avctx->width >> 2) * (c->avctx->height >> 2);
> + blk2 = 0;
> + for(blk = 0; blk < blocks; blk++){
> + if(!(blk & 3))
> + blocktypes = bytestream_get_byte(&buf);
> + switch(blocktypes & 0xC0){
> + case 0x00: //skip
> + for(y = 0; y < 4; y++)
> + if(check_line(prev + y*width, pstart, pend))
> + memcpy(cur + y*width, prev + y*width, 4);
> + else
> + memset(cur + y*width, 0, 4);
> + break;
it should be enough to check the top-left and bottom-right pixels
the same applies to the other cases
[...]
> +static int siff_probe(AVProbeData *p)
> +{
> + /* check file header */
> + if (p->buf[0] == 'S' && p->buf[1] == 'I' &&
> + p->buf[2] == 'F' && p->buf[3] == 'F')
AV_RL32() == TAG_SIFF or something like that
[...]
> +static int siff_parse_vbv1(AVFormatContext *s, SIFFContext *c, ByteIOContext *pb)
> +{
> + AVStream *st;
> + uint32_t tag, size;
> + int width, height;
> +
> + tag = get_le32(pb);
> + if (tag != TAG_VBHD){
> + av_log(s, AV_LOG_ERROR, "Header chunk is missing\n");
> + return -1;
> + }
> + size = get_be32(pb);
> + if(size != 32){
> + av_log(s, AV_LOG_ERROR, "Header chunk size is incorrect\n");
> + return -1;
> + }
> + if(get_le16(pb) != 1){
> + av_log(s, AV_LOG_ERROR, "Incorrect header version\n");
> + return -1;
> + }
> + width = get_le16(pb);
> + height = get_le16(pb);
> + url_fskip(pb, 4);
> + c->frames = get_le16(pb);
> + if(!c->frames){
> + av_log(s, AV_LOG_ERROR, "File contains no frames ???\n");
> + return -1;
> + }
> + c->bits = get_le16(pb);
> + c->rate = get_le16(pb);
> + c->block_align = c->rate * (c->bits >> 3);
> +
> + url_fskip(pb, 16); //zeroes
> +
> + st = av_new_stream(s, 0);
> + if (!st)
> + return -1;
> + st->codec->codec_type = CODEC_TYPE_VIDEO;
> + st->codec->codec_id = CODEC_ID_VB;
> + st->codec->codec_tag = MKTAG('V', 'B', 'V', '1');
> + st->codec->width = width;
> + st->codec->height = height;
there are a lot of unneeded intermediate variables here
[...]
--
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/20071020/b6d145f5/attachment.pgp>
More information about the ffmpeg-devel
mailing list