[FFmpeg-devel] [PATCH] Add DPX decoder rev-9
Jimmy Christensen
jimmy
Mon May 25 08:54:12 CEST 2009
On 2009-05-15 03:51, Michael Niedermayer wrote:
> On Mon, May 11, 2009 at 11:31:25AM +0200, Jimmy Christensen wrote:
> [...]
>> +typedef struct DPXContext {
>> + AVFrame picture;
>> + int width;
>> + int height;
>
>> + int bpp;
>
> useless
>
removed
>
>> + }
>> +
>> + offset = read32(headerBuffer, endian);
>> + headerBuffer += 4;
>> + bytestream_get_buffer(&headerBuffer, version, 8);
>> + headerBuffer += 8;
>> + // Jump in extra 744 bytes to end at address 744 + 4 + 4 + 8 = 760 = 0x2f8
>> + headerBuffer += 744;
>> + orientation = read32(headerBuffer, endian);
>> + headerBuffer += 4;
>> + w = read32(headerBuffer, endian);
>> + headerBuffer += 4;
>> + h = read32(headerBuffer, endian);
>> + headerBuffer += 4;
>
> your read32() function could add 4 to headerBuffer
Good idea :) Done.
>
>
> [...]
>> + for (x = 0; x< s->height; x++) {
>> + uint8_t *dst = ptr;
>> + for (y = 0; y< s->width; y++) {
>
>> + rgbBuffer = AV_RB32(buf);
>> + memcpy(&rgb10Field,&rgbBuffer, 4);
>> + rgb16Field.R = rgb10Field.R * 64; // 10-bit> 16-bit
>> + rgb16Field.G = rgb10Field.G * 64; // 10-bit> 16-bit
>> + rgb16Field.B = rgb10Field.B * 64; // 10-bit> 16-bit
>> + memcpy(dst,&rgb16Field, dstBpp);
>
> not portable
>
I rewrote a little, but still uses memcpy from rgb16Field to dst, since
that should actually be portable. As far as I can see the pixel format
becomes PIX_FMT_RGB48BE on big endian systems and PIX_FMT_RGB48LE on
little endian systems. sw_scaler should then take care of the rest..
>
>> + dst += dstBpp;
>> + buf += 4;
>> + }
>> + ptr += stride;
>> + }
>> +
>> + *picture = s->picture;
>> + *data_size = sizeof(AVPicture);
>> +
>> + return buf_size;
>> +}
>> +
>
>> +static av_cold int dpx_init(AVCodecContext *avctx)
>> +{
>> + DPXContext *s = avctx->priv_data;
>> + avcodec_get_frame_defaults((AVFrame*)&s->picture);
>> + avctx->coded_frame = (AVFrame*)&s->picture;
>> + return 0;
>> +}
>
> useless casts
>
Removed.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ffmpegDPX-rev9.diff
Type: text/x-patch
Size: 8639 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090525/add8d1cb/attachment.bin>
More information about the ffmpeg-devel
mailing list