[FFmpeg-devel] [PATCH] Add DPX decoder rev-17

Michael Niedermayer michaelni
Thu Jun 4 00:34:57 CEST 2009


On Wed, Jun 03, 2009 at 08:52:42PM +0200, Jimmy Christensen wrote:
> On 2009-06-03 20:20, Reimar D?ffinger wrote:
>> Hm. I really wonder which compiler you use.
>> Anyway I guess Michael would accept a version using macros if it was
>> done without adding useless calculation.
>> Except that it's rather silly to use macros in cases like this when
>> there is absolutely no reason to.
>> Example:
>> static inline unsigned make_16bit(unsigned value)
>> {
>>      // mask away invalid bits
>>      value&= 0xFFC0;
>>      // correctly expand to 16 bits
>>      return value + (value>>  10);
>> }
>>
>>              *dst++ = make_16bit(rgbBuffer>>  16);
>>              *dst++ = make_16bit(rgbBuffer>>   6);
>>              *dst++ = make_16bit(rgbBuffer<<   4);
>
> Thanks for the code. Works perfectly and keeps it's speed. I'm using gcc 
> 4.3.3 on Ubuntu 9.04 amd64. C is not exactly my biggest force and 
> appreciate any help I can get.
>
> Btw. should I also upload sample images to test with?

hmm, dont we already have pngs somewhere ...
anyway, uploading more surely doesnt hurt ...


[...]
> +static int decode_frame(AVCodecContext *avctx,
> +                        void *data,
> +                        int *data_size,
> +                        AVPacket *avpkt)
> +{
> +

> +    const uint8_t *headerBuffer = avpkt->data;
> +    const uint8_t *buf          = avpkt->data;

redundant


> +    int buf_size                = avpkt->size;
> +    DPXContext *const s = avctx->priv_data;
> +    AVFrame *picture  = data;
> +    AVFrame *const p = &s->picture;
> +    uint8_t *ptr;
> +
> +    int magic_num, offset;
> +    char version[8];
> +    int x, y;
> +    int w, h, stride;
> +
> +    unsigned int rgbBuffer;
> +    int endian = 0;
> +
> +    magic_num = AV_RB32(headerBuffer);
> +    headerBuffer += 4;
> +
> +    /* Check if the files "magic number" is "SDPX" which means it uses
> +     * big-endian or XPDS which is for little-endian files */
> +    if (magic_num == AV_RL32("SDPX"))
> +        endian = 0;
> +    else if (magic_num == AV_RB32("SDPX"))
> +        endian = 1;
> +    else {
> +        av_log(avctx, AV_LOG_ERROR, "DPX marker not found");
> +        return -1;
> +    }
> +
> +    offset = read32(&headerBuffer, endian);
> +    bytestream_get_buffer(&headerBuffer, version, 8);
> +    // Need to end in 0x300, so jump 768 - 8 - 4 - 4 = 752
> +    headerBuffer += 756;
> +    w = read32(&headerBuffer, endian);
> +    h = read32(&headerBuffer, endian);
> +

> +    avctx->width  = w;
> +    avctx->height = h;
[...]
> +    if (w != avctx->width || h != avctx->height)
> +        avcodec_set_dimensions(avctx, w, h);

this wont work in that order

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

I do not agree with what you have to say, but I'll defend to the death your
right to say it. -- Voltaire
-------------- 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/20090604/587fad0d/attachment.pgp>



More information about the ffmpeg-devel mailing list