[FFmpeg-devel] [PATCH] R3D REDCODE demuxer
Baptiste Coudurier
baptiste.coudurier
Sun Jan 18 02:42:10 CET 2009
Hi Michael,
Michael Niedermayer wrote:
> On Wed, Dec 17, 2008 at 12:05:25AM -0800, Baptiste Coudurier wrote:
>> Hi,
>>
>> Here is the demuxer.
>>
>> Basically, chunks contains jp2 frames which can be decoded in some way
>> by openjpeg.
>>
>> I'll add seeking as soon as code is in svn.
> [...]
>> +static int r3d_read_red1(AVFormatContext *s)
>> +{
>> + AVStream *st = av_new_stream(s, 0);
>> + int tmp, tmp2, timebase;
>> +
>> + if (!st)
>> + return -1;
>> + st->codec->codec_type = CODEC_TYPE_VIDEO;
>> + st->codec->codec_id = CODEC_ID_JPEG2000;
>> + tmp = get_byte(s->pb); // major version
>> + tmp2 = get_byte(s->pb); // minor version
>> + dprintf(s, "version %d.%d\n", tmp, tmp2);
>> + get_be16(s->pb); // unknown
>
>> + timebase = get_be32(s->pb);
>> + dprintf(s, "timebase %d\n", timebase);
>> + st->time_base.num = 1;
>> + st->time_base.den = timebase;
>
> av_set_pts_info()
Changed.
> also, i think the code would be more readable with an occasional empty
> line :)
Yeah, I've gone too far :>
> [...]
>> +static int r3d_read_header(AVFormatContext *s, AVFormatParameters *ap)
>> +{
>> + R3DContext *r3d = s->priv_data;
>> + Atom atom;
>> + int ret;
>> +
>> + if (read_atom(s->pb, &atom) < 0) {
>> + av_log(s, AV_LOG_ERROR, "error reading atom\n");
>> + return -1;
>> + }
>> + dprintf(s, "atom %d %.4s offset %#llx\n",
>> + atom.size, (char*)&atom.tag, atom.offset);
>> + if (atom.tag == MKTAG('R','E','D','1')) {
>> + if ((ret = r3d_read_red1(s)) < 0) {
>> + av_log(s, AV_LOG_ERROR, "error parsing 'red1' atom\n");
>> + return ret;
>> + }
>> + } else {
>> + av_log(s, AV_LOG_ERROR, "could not find 'red1' atom\n");
>> + return -1;
>> + }
>> +
>> + s->data_offset = url_ftell(s->pb);
>> + dprintf(s, "data offset %#llx\n", s->data_offset);
>> + if (url_is_streamed(s->pb))
>> + return 0;
>> + // find REOB/REOF/REOS to load index
>> + url_fseek(s->pb, url_fsize(s->pb)-48-8, SEEK_SET);
>
>> + if (read_atom(s->pb, &atom) < 0) {
>> + av_log(s, AV_LOG_ERROR, "error reading end atom\n");
>> + return -1;
>> + }
>
> if return 0 was ok before when url_is_streamed() then it should be ok
> here too after seeking back, same for the other failure cases below
Right, changed.
>> + dprintf(s, "atom %d %.4s offset %#llx\n",
>> + atom.size, (char*)&atom.tag, atom.offset);
>
> These dprintfs() could be put in read_atom()
Good idea, done.
> [...]
>> +static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom)
>> +{
>> + int tmp, tmp2, samples, size;
>> + uint64_t pos = url_ftell(s->pb);
>> + unsigned dts;
>> +
>> + if (s->nb_streams < 2)
>> + return -1;
>> + if (s->streams[1]->discard == AVDISCARD_ALL)
>> + return 0;
>> + dts = get_be32(s->pb);
>> + dprintf(s, "dts %d\n", dts);
>> + s->streams[1]->codec->sample_rate = get_be32(s->pb);
>> + samples = get_be32(s->pb);
>> + dprintf(s, "samples %d\n", samples);
>> + tmp = get_be32(s->pb);
>> + dprintf(s, "packet num %d\n", tmp);
>> + tmp = get_be16(s->pb); // unkown
>> + dprintf(s, "unknown %d\n", tmp);
>
>> + tmp = get_byte(s->pb); // major version
>> + tmp2 = get_byte(s->pb); // minor version
>> + dprintf(s, "version %d.%d\n", tmp, tmp2);
>
> id also suggest to either drop the dprintf() or write a
> little macro that does get_* + dprintf() at once
Well this is an unspecified format and to macro it, I must deal with
different types length, etc ...
I added seeking too.
Updated patch attached.
--
Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA
Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
checking for life_signs in -lkenny... no
-------------- next part --------------
A non-text attachment was scrubbed...
Name: r3d_demuxer2.patch
Type: text/x-diff
Size: 12830 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090117/943b0900/attachment.patch>
More information about the ffmpeg-devel
mailing list