[FFmpeg-devel] [PATCH] Add DPX decoder rev-22
Michael Niedermayer
michaelni
Wed Jun 10 10:27:08 CEST 2009
On Mon, Jun 08, 2009 at 11:47:42PM +0200, Jimmy Christensen wrote:
> On 2009-06-08 16:12, Michael Niedermayer wrote:
>> On Mon, Jun 08, 2009 at 12:17:32AM +0200, Jimmy Christensen wrote:
[...]
> + switch (descriptor) {
> + case 51: // RGBA
> + elements = 4;
> + break;
> + case 50: // RGB
> + elements = 3;
> + break;
> + default:
> + av_log(avctx, AV_LOG_ERROR, "Unsupported descriptor\n");
printing the value of the descriptor too, might be usefull
> + return -1;
> + break;
> + }
> +
> + switch (bits_per_color) {
> + case 8:
> + if (elements == 4)
> + avctx->pix_fmt = PIX_FMT_RGBA;
> + else
> + avctx->pix_fmt = PIX_FMT_RGB24;
> + source_packet_size = elements;
> + target_packet_size = elements;
> + break;
> + case 10:
> + avctx->pix_fmt = PIX_FMT_RGB48;
> + target_packet_size = 6;
> + source_packet_size = elements * 2;
> + break;
> + case 12:
> + case 16:
> + if (endian)
> + avctx->pix_fmt = PIX_FMT_RGB48BE;
> + else
> + avctx->pix_fmt = PIX_FMT_RGB48LE;
> + target_packet_size = 6;
> + source_packet_size = elements * 2;
> + break;
> + default:
> + av_log(avctx, AV_LOG_ERROR, "Unsupported color depth\n");
> + return -1;
> + break;
> + }
> +
> + 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;
> + }
> +
> + // Move pointer to offset from start of file
> + buf = avpkt->data + offset;
> +
> + ptr = p->data[0];
> + stride = p->linesize[0];
> +
> + switch (bits_per_color) {
> + case 10:
> + for (x = 0; x < avctx->height; x++) {
> + uint16_t *dst = ptr;
> + for (y = 0; y < avctx->width; y++) {
> + rgbBuffer = read32(&buf, endian);
> + // Read out the 10-bit colors and convert to 16-bit
> + *dst++ = make_16bit(rgbBuffer >> 16);
> + *dst++ = make_16bit(rgbBuffer >> 6);
> + *dst++ = make_16bit(rgbBuffer << 4);
> + }
> + ptr += stride;
> + }
> + break;
> + case 8:
> + case 12: // Treat 12-bit as 16-bit
> + case 16:
> + if (source_packet_size == target_packet_size) {
> + for (x = 0; x < avctx->height; x++) {
> + memcpy(ptr, buf, target_packet_size*avctx->width);
> + ptr += stride;
> + buf += source_packet_size*avctx->width;
> + }
> + } else {
> + for (x = 0; x < avctx->height; x++) {
> + uint8_t *dst = ptr;
> + for (y = 0; y < avctx->width; y++) {
> + memcpy(dst, buf, target_packet_size);
> + dst += target_packet_size;
> + buf += source_packet_size;
> + }
> + ptr += stride;
> + }
> + }
> + break;
> + default:
> + return -1;
> + break;
thats impossible to be reached
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I have often repented speaking, but never of holding my tongue.
-- Xenocrates
-------------- 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/20090610/d33bf7af/attachment.pgp>
More information about the ffmpeg-devel
mailing list