[FFmpeg-devel] [PATCH] Add DPX decoder
Jimmy Christensen
jimmy
Wed May 6 16:27:49 CEST 2009
On 2009-05-06 15:44, Michael Niedermayer wrote:
> On Wed, May 06, 2009 at 02:35:30PM +0100, Jimmy Christensen wrote:
>
>>
>> Best Regards
>> Jimmy Christensen
>> Developer
>> Ghost A/S
>>
>> ----- "Michael Niedermayer"<michaelni at gmx.at> wrote:
>>
>> | On Wed, May 06, 2009 at 01:56:56PM +0100, Jimmy Christensen wrote:
>> | [...]
>> |> |
>> |> | [...]
>> |> |> + if(endian == 0x0) {
>> |> |> + offset = AV_RB32(headerBuffer); headerBuffer += 4;
>> |> |> + bytestream_get_buffer(&headerBuffer, version, 8);
>> | headerBuffer +=
>> |> | 8;
>> |> |> + // Jump in extra 744 bytes to end in address 744 + 4 + 4 + 8
>> | =
>> |> | 760 = 0x2f8
>> |> |> + headerBuffer += 744;
>> |> |> + orientation = AV_RB32(headerBuffer); headerBuffer += 4;
>> |> |> + w = AV_RB32(headerBuffer); headerBuffer += 4;
>> |> |> + h = AV_RB32(headerBuffer); headerBuffer += 4;
>> |> |> + } else {
>> |> |> + offset = AV_RL32(headerBuffer); headerBuffer += 4;
>> |> |> + bytestream_get_buffer(&headerBuffer, version, 8);
>> | headerBuffer +=
>> |> | 8;
>> |> |> + // Jump in extra 744 bytes to end in address 744 + 4 + 4 + 8
>> | =
>> |> | 760 = 0x2f8
>> |> |> + headerBuffer += 744;
>> |> |> + orientation = AV_RL32(headerBuffer); headerBuffer += 4;
>> |> |> + w = AV_RL32(headerBuffer); headerBuffer += 4;
>> |> |> + h = AV_RL32(headerBuffer); headerBuffer += 4;
>> |> |> + }
>> |> |
>> |> | code duplication
>> |> |
>> |>
>> |> No, one is for big endian numbers, the other is for little endian.
>> | There are 2 types of DPX files.
>> |
>> | you duplicate a flexible endian 32bit reading function
>> |
>>
>> How does it work then?
>>
> static unsigned int read32(ptr, is_big)
> {
> return is_big ? AV_RB32 : AV_RL32
> }
>
>
Thanks. :)
>> Sorry, I'm very new to ffmpeg and it's my first patch.
>>
>> |
>> |>
>> |> |
>> |> |> +
>> |> |> + s->width = w;
>> |> |> + s->height = h;
>> |> |> + s->bpp = 32;
>> |> |> + avctx->pix_fmt = PIX_FMT_RGB32;
>> |> |> +
>> |> |> + if(s->picture.data[0])
>> |> |> + avctx->release_buffer(avctx,&s->picture);
>> |> |> + if(avcodec_check_dimensions(avctx, w, h))
>> |> |> + return -1;
>> |> |> + if(w != avctx->width || h != avctx->height)
>> |> |> + avcodec_set_dimensions(avctx, w, h);
>> |> |> + if(avctx->get_buffer(avctx, p)< 0) {
>> |> |> + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
>> |> |> + return -1;
>> |> |> + }
>> |> |> +
>> |> |> + buf += offset;
>> |> |> +
>> |> |> + ptr = p->data[0];
>> |> |> + stride = p->linesize[0];
>> |> |> +
>> |> |> + for(x = 0; x< s->height; x++) {
>> |> |> + uint8_t *dst = ptr;
>> |> |> + for(y = 0; y< s->width; y++) {
>> |> |> + rgbBuffer = AV_RB32(buf);
>> |> |> + memcpy(&rgbField,&rgbBuffer, 4);
>> |> |> + dst[0] = ((rgbField.R * 256) / 1024);
>> |> |> + dst[1] = ((rgbField.G * 256) / 1024);
>> |> |> + dst[2] = ((rgbField.B * 256) / 1024);
>> |> |
>> |> | discarding 2 bits in the decoder is unacceptable
>> |> | also this way of reading is not portable
>> |> |
>> |>
>> |> How so? The last 2 bits are not used, since it's too small for alpha
>> | channel.
>> |
>> | ((rgbField.R * 256) / 1024);
>> | discards 2 bits
>> |
>>
>> You mean converts from 10bit to 8bit? Yes. But didn't know ffmpeg supported 10bit. Any suggestion on how to get the buffer 10bit is much appreciated.
>>
> using PIX_FMT_RGB48 would be an option
>
I tried using that but when trying to encode I get a "swScaler: Unknown
format is not supported as input pixel format". Are there any codecs
that use PIX_FMT_RGB48 which I can use for reference?
Btw. sorry about the breaking threads thing. Switched email client which
should be better.
> [...]
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
More information about the ffmpeg-devel
mailing list