[FFmpeg-devel] [PATCH] jp2 image2 muxer

Michael Niedermayer michaelni
Sun Jan 18 00:30:23 CET 2009


On Sat, Jan 17, 2009 at 01:52:54PM -0800, Baptiste Coudurier wrote:
> Hi Michael,
> 
> Michael Niedermayer wrote:
> > On Wed, Dec 17, 2008 at 12:11:38AM -0800, Baptiste Coudurier wrote:
> >> Hi,
> >> 
> >> $subject,
> >> 
> >> You can extract jp2 files from .R3D files and also from .mov/.mj2
> >> 
> >> ffmpeg -i <file.mj2/.r3d> -vcodec copy test%d.jp2
> > [...]
> >> @@ -358,6 +359,29 @@ url_fclose(pb[1]); url_fclose(pb[2]); }else{ +
> >> if(codec->codec_id == CODEC_ID_JPEG2000){ +            AVStream *st
> >> = s->streams[0]; +            if(st->codec->extradata_size > 8 && +
> >> AV_RL32(st->codec->extradata+4) == MKTAG('j','p','2','h')){ +
> >> if(pkt->size < 8 || AV_RL32(pkt->data+4) != MKTAG('j','p','2','c'))
> >>  +                    goto error; +                put_be32(pb[0],
> >> 12); +                put_tag (pb[0], "jP  "); +
> >> put_be32(pb[0], 0x0D0A870A); // signature +
> >> put_be32(pb[0], 20); +                put_tag (pb[0], "ftyp"); +
> >> put_tag (pb[0], "jp2 "); +                put_be32(pb[0], 0); +
> >> put_tag (pb[0], "jp2 "); +                put_buffer(pb[0],
> >> st->codec->extradata, st->codec->extradata_size); +
> >> }else if(pkt->size < 8 || +
> >> (!st->codec->extradata_size && +
> >> AV_RL32(pkt->data+4) != MKTAG('j','P',' ',' '))){ // signature +
> >> error: +                av_log(s, AV_LOG_INFO, "malformated
> >> jpeg2000 codestream\n"); +                return -1; +            }
> >>  +        }
> > 
> > The thing ive used image2 for most often is debuging. this code makes
> > image2 unuseable for debuging jpeg2k, because what it writes is not
> > what is in the packets besides it even refuses malformated packets,
> > which is desireable if one wants actual j2k files but not when one 
> > like a developer wants to look at the output of a buggy demuxer.
> > 
> > maybe a "rawframes" demuxer could be added that did what image2 does
> > just without such modifications. Or the code could be moved to a
> > bitstream filter ... sadly that brings back the problem of auto
> > loading bsfs.
> 
> I undestand, I changed the check to use av_str2id which will match
> CODEC_ID_JPEG2000 when ".jp2" extension is used, in this case I think
> the code makes all its sense, since user want valid .jp2 files.
> 
> What do you think ?

looks ok

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

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- 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/20090118/0bad0e80/attachment.pgp>



More information about the ffmpeg-devel mailing list