2009-06-12 05:29:29 +00:00
|
|
|
/*
|
|
|
|
* DPX (.dpx) image decoder
|
|
|
|
* Copyright (c) 2009 Jimmy Christensen
|
|
|
|
*
|
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "libavutil/intreadwrite.h"
|
2014-05-10 19:56:35 +00:00
|
|
|
#include "libavutil/intfloat.h"
|
2011-02-07 13:37:08 +00:00
|
|
|
#include "libavutil/imgutils.h"
|
2009-06-12 05:29:29 +00:00
|
|
|
#include "bytestream.h"
|
|
|
|
#include "avcodec.h"
|
2012-11-10 12:22:56 +00:00
|
|
|
#include "internal.h"
|
2009-06-12 05:29:29 +00:00
|
|
|
|
2013-10-04 23:31:15 +00:00
|
|
|
static unsigned int read16(const uint8_t **ptr, int is_big)
|
|
|
|
{
|
|
|
|
unsigned int temp;
|
|
|
|
if (is_big) {
|
|
|
|
temp = AV_RB16(*ptr);
|
|
|
|
} else {
|
|
|
|
temp = AV_RL16(*ptr);
|
|
|
|
}
|
|
|
|
*ptr += 2;
|
|
|
|
return temp;
|
|
|
|
}
|
|
|
|
|
2009-06-12 05:29:29 +00:00
|
|
|
static unsigned int read32(const uint8_t **ptr, int is_big)
|
|
|
|
{
|
|
|
|
unsigned int temp;
|
|
|
|
if (is_big) {
|
|
|
|
temp = AV_RB32(*ptr);
|
|
|
|
} else {
|
|
|
|
temp = AV_RL32(*ptr);
|
|
|
|
}
|
|
|
|
*ptr += 4;
|
|
|
|
return temp;
|
|
|
|
}
|
|
|
|
|
2012-10-12 19:18:49 +00:00
|
|
|
static uint16_t read10in32(const uint8_t **ptr, uint32_t * lbuf,
|
|
|
|
int * n_datum, int is_big)
|
|
|
|
{
|
|
|
|
if (*n_datum)
|
|
|
|
(*n_datum)--;
|
|
|
|
else {
|
|
|
|
*lbuf = read32(ptr, is_big);
|
|
|
|
*n_datum = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
*lbuf = (*lbuf << 10) | (*lbuf >> 22);
|
|
|
|
|
|
|
|
return *lbuf & 0x3FF;
|
|
|
|
}
|
|
|
|
|
2018-04-10 16:20:23 +00:00
|
|
|
static uint16_t read12in32(const uint8_t **ptr, uint32_t * lbuf,
|
|
|
|
int * n_datum, int is_big)
|
|
|
|
{
|
|
|
|
if (*n_datum)
|
|
|
|
(*n_datum)--;
|
|
|
|
else {
|
|
|
|
*lbuf = read32(ptr, is_big);
|
|
|
|
*n_datum = 7;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (*n_datum){
|
|
|
|
case 7: return *lbuf & 0xFFF;
|
|
|
|
case 6: return (*lbuf >> 12) & 0xFFF;
|
|
|
|
case 5: {
|
|
|
|
uint32_t c = *lbuf >> 24;
|
|
|
|
*lbuf = read32(ptr, is_big);
|
|
|
|
c |= *lbuf << 8;
|
|
|
|
return c & 0xFFF;
|
|
|
|
}
|
|
|
|
case 4: return (*lbuf >> 4) & 0xFFF;
|
|
|
|
case 3: return (*lbuf >> 16) & 0xFFF;
|
|
|
|
case 2: {
|
|
|
|
uint32_t c = *lbuf >> 28;
|
|
|
|
*lbuf = read32(ptr, is_big);
|
|
|
|
c |= *lbuf << 4;
|
|
|
|
return c & 0xFFF;
|
|
|
|
}
|
|
|
|
case 1: return (*lbuf >> 8) & 0xFFF;
|
|
|
|
default: return *lbuf >> 20;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-12 05:29:29 +00:00
|
|
|
static int decode_frame(AVCodecContext *avctx,
|
|
|
|
void *data,
|
2012-11-13 18:35:22 +00:00
|
|
|
int *got_frame,
|
2009-06-12 05:29:29 +00:00
|
|
|
AVPacket *avpkt)
|
|
|
|
{
|
|
|
|
const uint8_t *buf = avpkt->data;
|
|
|
|
int buf_size = avpkt->size;
|
2012-11-21 20:34:46 +00:00
|
|
|
AVFrame *const p = data;
|
2012-08-26 12:51:13 +00:00
|
|
|
uint8_t *ptr[AV_NUM_DATA_POINTERS];
|
2009-06-12 05:29:29 +00:00
|
|
|
|
2012-08-04 23:41:20 +00:00
|
|
|
unsigned int offset;
|
|
|
|
int magic_num, endian;
|
2014-08-12 22:37:00 +00:00
|
|
|
int x, y, stride, i, ret;
|
|
|
|
int w, h, bits_per_color, descriptor, elements, packing;
|
|
|
|
int encoding, need_align = 0;
|
2009-06-12 05:29:29 +00:00
|
|
|
|
2012-10-12 19:18:49 +00:00
|
|
|
unsigned int rgbBuffer = 0;
|
|
|
|
int n_datum = 0;
|
2009-06-12 05:29:29 +00:00
|
|
|
|
2011-04-01 12:23:28 +00:00
|
|
|
if (avpkt->size <= 1634) {
|
2011-03-25 17:58:07 +00:00
|
|
|
av_log(avctx, AV_LOG_ERROR, "Packet too small for DPX header\n");
|
|
|
|
return AVERROR_INVALIDDATA;
|
|
|
|
}
|
|
|
|
|
2009-06-12 05:29:29 +00:00
|
|
|
magic_num = AV_RB32(buf);
|
|
|
|
buf += 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\n");
|
2012-11-16 17:24:55 +00:00
|
|
|
return AVERROR_INVALIDDATA;
|
2009-06-12 05:29:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
offset = read32(&buf, endian);
|
2011-03-25 17:58:07 +00:00
|
|
|
if (avpkt->size <= offset) {
|
|
|
|
av_log(avctx, AV_LOG_ERROR, "Invalid data start offset\n");
|
|
|
|
return AVERROR_INVALIDDATA;
|
|
|
|
}
|
2014-08-12 23:44:40 +00:00
|
|
|
|
|
|
|
// Check encryption
|
|
|
|
buf = avpkt->data + 660;
|
|
|
|
ret = read32(&buf, endian);
|
|
|
|
if (ret != 0xFFFFFFFF) {
|
|
|
|
avpriv_report_missing_feature(avctx, "Encryption");
|
|
|
|
av_log(avctx, AV_LOG_WARNING, "The image is encrypted and may "
|
|
|
|
"not properly decode.\n");
|
|
|
|
}
|
|
|
|
|
2009-06-12 05:29:29 +00:00
|
|
|
// Need to end in 0x304 offset from start of file
|
|
|
|
buf = avpkt->data + 0x304;
|
|
|
|
w = read32(&buf, endian);
|
|
|
|
h = read32(&buf, endian);
|
2012-11-26 11:45:07 +00:00
|
|
|
|
2013-11-01 13:01:02 +00:00
|
|
|
if ((ret = ff_set_dimensions(avctx, w, h)) < 0)
|
|
|
|
return ret;
|
2009-06-12 05:29:29 +00:00
|
|
|
|
|
|
|
// Need to end in 0x320 to read the descriptor
|
|
|
|
buf += 20;
|
|
|
|
descriptor = buf[0];
|
|
|
|
|
|
|
|
// Need to end in 0x323 to read the bits per color
|
|
|
|
buf += 3;
|
2009-12-16 20:46:48 +00:00
|
|
|
avctx->bits_per_raw_sample =
|
2009-06-12 05:29:29 +00:00
|
|
|
bits_per_color = buf[0];
|
2012-10-12 19:18:49 +00:00
|
|
|
buf++;
|
2013-10-04 23:33:52 +00:00
|
|
|
packing = read16(&buf, endian);
|
2013-10-04 23:38:08 +00:00
|
|
|
encoding = read16(&buf, endian);
|
2009-06-12 05:29:29 +00:00
|
|
|
|
2013-10-04 23:38:47 +00:00
|
|
|
if (packing > 1) {
|
2013-10-05 12:21:58 +00:00
|
|
|
avpriv_report_missing_feature(avctx, "Packing %d", packing);
|
2013-10-04 23:38:47 +00:00
|
|
|
return AVERROR_PATCHWELCOME;
|
|
|
|
}
|
2013-10-04 23:38:08 +00:00
|
|
|
if (encoding) {
|
2013-10-05 12:21:58 +00:00
|
|
|
avpriv_report_missing_feature(avctx, "Encoding %d", encoding);
|
2013-10-04 23:38:08 +00:00
|
|
|
return AVERROR_PATCHWELCOME;
|
|
|
|
}
|
|
|
|
|
|
|
|
buf += 820;
|
2011-04-01 12:23:28 +00:00
|
|
|
avctx->sample_aspect_ratio.num = read32(&buf, endian);
|
|
|
|
avctx->sample_aspect_ratio.den = read32(&buf, endian);
|
2012-06-18 09:39:26 +00:00
|
|
|
if (avctx->sample_aspect_ratio.num > 0 && avctx->sample_aspect_ratio.den > 0)
|
|
|
|
av_reduce(&avctx->sample_aspect_ratio.num, &avctx->sample_aspect_ratio.den,
|
|
|
|
avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den,
|
|
|
|
0x10000);
|
|
|
|
else
|
2012-07-09 07:13:21 +00:00
|
|
|
avctx->sample_aspect_ratio = (AVRational){ 0, 1 };
|
2011-04-01 12:23:28 +00:00
|
|
|
|
2014-04-25 21:13:17 +00:00
|
|
|
if (offset >= 1724 + 4) {
|
|
|
|
buf = avpkt->data + 1724;
|
|
|
|
i = read32(&buf, endian);
|
|
|
|
if(i) {
|
2014-05-10 19:56:35 +00:00
|
|
|
AVRational q = av_d2q(av_int2float(i), 4096);
|
2014-04-25 21:13:17 +00:00
|
|
|
if (q.num > 0 && q.den > 0)
|
2014-10-15 13:57:15 +00:00
|
|
|
avctx->framerate = q;
|
2014-04-25 21:13:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-12 05:29:29 +00:00
|
|
|
switch (descriptor) {
|
2013-10-07 10:10:39 +00:00
|
|
|
case 6: // Y
|
|
|
|
elements = 1;
|
|
|
|
break;
|
2013-10-08 11:29:29 +00:00
|
|
|
case 52: // ABGR
|
2013-10-05 12:27:31 +00:00
|
|
|
case 51: // RGBA
|
2015-02-07 23:12:46 +00:00
|
|
|
case 103: // UYVA4444
|
2013-10-05 12:27:31 +00:00
|
|
|
elements = 4;
|
|
|
|
break;
|
|
|
|
case 50: // RGB
|
2015-02-07 23:12:46 +00:00
|
|
|
case 102: // UYV444
|
2013-10-05 12:27:31 +00:00
|
|
|
elements = 3;
|
|
|
|
break;
|
2015-02-07 23:12:46 +00:00
|
|
|
case 100: // UYVY422
|
|
|
|
elements = 2;
|
|
|
|
break;
|
2013-10-05 12:27:31 +00:00
|
|
|
default:
|
|
|
|
avpriv_report_missing_feature(avctx, "Descriptor %d", descriptor);
|
|
|
|
return AVERROR_PATCHWELCOME;
|
2009-06-12 05:29:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (bits_per_color) {
|
2013-10-05 12:27:31 +00:00
|
|
|
case 8:
|
2014-08-12 22:37:00 +00:00
|
|
|
stride = avctx->width * elements;
|
2013-10-05 12:27:31 +00:00
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
if (!packing) {
|
|
|
|
av_log(avctx, AV_LOG_ERROR, "Packing to 32bit required\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2014-08-12 22:37:00 +00:00
|
|
|
stride = (avctx->width * elements + 2) / 3 * 4;
|
2013-10-05 12:27:31 +00:00
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
if (!packing) {
|
2018-04-10 16:20:23 +00:00
|
|
|
int tested = 0;
|
|
|
|
if (descriptor == 50 && endian && (avctx->width%8) == 0) { // Little endian and widths not a multiple of 8 need tests
|
|
|
|
tested = 1;
|
|
|
|
}
|
|
|
|
if (!tested) {
|
|
|
|
av_log(avctx, AV_LOG_ERROR, "Packing to 16bit required\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stride = avctx->width * elements;
|
|
|
|
if (packing) {
|
|
|
|
stride *= 2;
|
|
|
|
} else {
|
|
|
|
stride *= 3;
|
|
|
|
if (stride % 8) {
|
|
|
|
stride /= 8;
|
|
|
|
stride++;
|
|
|
|
stride *= 8;
|
|
|
|
}
|
|
|
|
stride /= 2;
|
2013-10-05 12:27:31 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 16:
|
2014-08-12 22:37:00 +00:00
|
|
|
stride = 2 * avctx->width * elements;
|
2013-10-05 12:27:31 +00:00
|
|
|
break;
|
2013-10-07 09:10:00 +00:00
|
|
|
case 1:
|
|
|
|
case 32:
|
|
|
|
case 64:
|
|
|
|
avpriv_report_missing_feature(avctx, "Depth %d", bits_per_color);
|
|
|
|
return AVERROR_PATCHWELCOME;
|
2013-10-05 12:27:31 +00:00
|
|
|
default:
|
|
|
|
return AVERROR_INVALIDDATA;
|
2009-06-12 05:29:29 +00:00
|
|
|
}
|
|
|
|
|
2014-08-12 22:37:00 +00:00
|
|
|
// Table 3c: Runs will always break at scan line boundaries. Packing
|
|
|
|
// will always break to the next 32-bit word at scan-line boundaries.
|
|
|
|
// Unfortunately, the encoder produced invalid files, so attempt
|
|
|
|
// to detect it
|
|
|
|
need_align = FFALIGN(stride, 4);
|
|
|
|
if (need_align*avctx->height + (int64_t)offset > avpkt->size) {
|
|
|
|
// Alignment seems unappliable, try without
|
|
|
|
if (stride*avctx->height + (int64_t)offset > avpkt->size) {
|
|
|
|
av_log(avctx, AV_LOG_ERROR, "Overread buffer. Invalid header?\n");
|
|
|
|
return AVERROR_INVALIDDATA;
|
|
|
|
} else {
|
|
|
|
av_log(avctx, AV_LOG_INFO, "Decoding DPX without scanline "
|
|
|
|
"alignment.\n");
|
|
|
|
need_align = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
need_align -= stride;
|
|
|
|
stride = FFALIGN(stride, 4);
|
|
|
|
}
|
|
|
|
|
2013-10-07 11:20:13 +00:00
|
|
|
switch (1000 * descriptor + 10 * bits_per_color + endian) {
|
2013-10-07 10:10:39 +00:00
|
|
|
case 6081:
|
|
|
|
case 6080:
|
|
|
|
avctx->pix_fmt = AV_PIX_FMT_GRAY8;
|
|
|
|
break;
|
2016-11-10 22:04:46 +00:00
|
|
|
case 6121:
|
|
|
|
case 6120:
|
|
|
|
avctx->pix_fmt = AV_PIX_FMT_GRAY12;
|
|
|
|
break;
|
2013-10-07 11:20:13 +00:00
|
|
|
case 50081:
|
|
|
|
case 50080:
|
|
|
|
avctx->pix_fmt = AV_PIX_FMT_RGB24;
|
|
|
|
break;
|
2013-10-08 11:29:29 +00:00
|
|
|
case 52081:
|
|
|
|
case 52080:
|
|
|
|
avctx->pix_fmt = AV_PIX_FMT_ABGR;
|
|
|
|
break;
|
2013-10-07 11:20:13 +00:00
|
|
|
case 51081:
|
|
|
|
case 51080:
|
|
|
|
avctx->pix_fmt = AV_PIX_FMT_RGBA;
|
|
|
|
break;
|
|
|
|
case 50100:
|
|
|
|
case 50101:
|
|
|
|
avctx->pix_fmt = AV_PIX_FMT_GBRP10;
|
|
|
|
break;
|
2016-06-14 15:02:34 +00:00
|
|
|
case 51100:
|
|
|
|
case 51101:
|
|
|
|
avctx->pix_fmt = AV_PIX_FMT_GBRAP10;
|
|
|
|
break;
|
2013-10-07 11:20:13 +00:00
|
|
|
case 50120:
|
|
|
|
case 50121:
|
|
|
|
avctx->pix_fmt = AV_PIX_FMT_GBRP12;
|
|
|
|
break;
|
2016-06-15 15:45:51 +00:00
|
|
|
case 51120:
|
|
|
|
case 51121:
|
|
|
|
avctx->pix_fmt = AV_PIX_FMT_GBRAP12;
|
|
|
|
break;
|
2013-10-07 10:10:39 +00:00
|
|
|
case 6161:
|
|
|
|
avctx->pix_fmt = AV_PIX_FMT_GRAY16BE;
|
|
|
|
break;
|
|
|
|
case 6160:
|
|
|
|
avctx->pix_fmt = AV_PIX_FMT_GRAY16LE;
|
|
|
|
break;
|
2013-10-07 11:20:13 +00:00
|
|
|
case 50161:
|
|
|
|
avctx->pix_fmt = AV_PIX_FMT_RGB48BE;
|
|
|
|
break;
|
|
|
|
case 50160:
|
|
|
|
avctx->pix_fmt = AV_PIX_FMT_RGB48LE;
|
|
|
|
break;
|
|
|
|
case 51161:
|
|
|
|
avctx->pix_fmt = AV_PIX_FMT_RGBA64BE;
|
|
|
|
break;
|
|
|
|
case 51160:
|
|
|
|
avctx->pix_fmt = AV_PIX_FMT_RGBA64LE;
|
|
|
|
break;
|
2015-02-07 23:12:46 +00:00
|
|
|
case 100081:
|
|
|
|
avctx->pix_fmt = AV_PIX_FMT_UYVY422;
|
|
|
|
break;
|
|
|
|
case 102081:
|
|
|
|
avctx->pix_fmt = AV_PIX_FMT_YUV444P;
|
|
|
|
break;
|
|
|
|
case 103081:
|
|
|
|
avctx->pix_fmt = AV_PIX_FMT_YUVA444P;
|
|
|
|
break;
|
2013-10-07 11:20:13 +00:00
|
|
|
default:
|
|
|
|
av_log(avctx, AV_LOG_ERROR, "Unsupported format\n");
|
|
|
|
return AVERROR_PATCHWELCOME;
|
|
|
|
}
|
|
|
|
|
2014-04-28 20:08:33 +00:00
|
|
|
ff_set_sar(avctx, avctx->sample_aspect_ratio);
|
|
|
|
|
lavc: factorize ff_{thread_,re,}get_buffer error messages.
Coccinelle profile used:
@@
expression r, ctx, f, loglevel, str, flags;
@@
-if ((r = ff_get_buffer(ctx, f, flags)) < 0) {
- av_log(ctx, loglevel, str);
- return r;
-}
+if ((r = ff_get_buffer(ctx, f, flags)) < 0)
+ return r;
@@
expression r, ctx, f, loglevel, str;
@@
-if ((r = ff_reget_buffer(ctx, f)) < 0) {
- av_log(ctx, loglevel, str);
- return r;
-}
+if ((r = ff_reget_buffer(ctx, f)) < 0)
+ return r;
@@
expression r, ctx, f, loglevel, str, flags;
@@
-if ((r = ff_thread_get_buffer(ctx, f, flags)) < 0) {
- av_log(ctx, loglevel, str);
- return r;
-}
+if ((r = ff_thread_get_buffer(ctx, f, flags)) < 0)
+ return r;
...along with some manual patches for the remaining ones.
2013-03-12 07:41:53 +00:00
|
|
|
if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
|
2012-11-16 17:24:55 +00:00
|
|
|
return ret;
|
2009-06-12 05:29:29 +00:00
|
|
|
|
|
|
|
// Move pointer to offset from start of file
|
|
|
|
buf = avpkt->data + offset;
|
|
|
|
|
2012-08-26 12:51:13 +00:00
|
|
|
for (i=0; i<AV_NUM_DATA_POINTERS; i++)
|
|
|
|
ptr[i] = p->data[i];
|
2009-06-12 05:29:29 +00:00
|
|
|
|
|
|
|
switch (bits_per_color) {
|
2012-10-12 19:18:49 +00:00
|
|
|
case 10:
|
|
|
|
for (x = 0; x < avctx->height; x++) {
|
2016-06-14 15:02:34 +00:00
|
|
|
uint16_t *dst[4] = {(uint16_t*)ptr[0],
|
2012-10-12 19:18:49 +00:00
|
|
|
(uint16_t*)ptr[1],
|
2016-06-14 15:02:34 +00:00
|
|
|
(uint16_t*)ptr[2],
|
|
|
|
(uint16_t*)ptr[3]};
|
2012-10-12 19:18:49 +00:00
|
|
|
for (y = 0; y < avctx->width; y++) {
|
|
|
|
*dst[2]++ = read10in32(&buf, &rgbBuffer,
|
|
|
|
&n_datum, endian);
|
|
|
|
*dst[0]++ = read10in32(&buf, &rgbBuffer,
|
|
|
|
&n_datum, endian);
|
|
|
|
*dst[1]++ = read10in32(&buf, &rgbBuffer,
|
|
|
|
&n_datum, endian);
|
|
|
|
if (elements == 4)
|
2016-06-14 15:02:34 +00:00
|
|
|
*dst[3]++ =
|
2012-10-12 19:18:49 +00:00
|
|
|
read10in32(&buf, &rgbBuffer,
|
|
|
|
&n_datum, endian);
|
2009-06-12 05:29:29 +00:00
|
|
|
}
|
2013-04-07 19:24:06 +00:00
|
|
|
n_datum = 0;
|
2016-06-14 15:02:34 +00:00
|
|
|
for (i = 0; i < elements; i++)
|
2012-10-12 19:18:49 +00:00
|
|
|
ptr[i] += p->linesize[i];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
for (x = 0; x < avctx->height; x++) {
|
2016-06-15 15:45:51 +00:00
|
|
|
uint16_t *dst[4] = {(uint16_t*)ptr[0],
|
2012-10-12 19:18:49 +00:00
|
|
|
(uint16_t*)ptr[1],
|
2016-06-15 15:45:51 +00:00
|
|
|
(uint16_t*)ptr[2],
|
|
|
|
(uint16_t*)ptr[3]};
|
2012-10-12 19:18:49 +00:00
|
|
|
for (y = 0; y < avctx->width; y++) {
|
2018-04-10 16:20:23 +00:00
|
|
|
if (packing) {
|
2016-11-10 22:04:46 +00:00
|
|
|
if (elements >= 3)
|
|
|
|
*dst[2]++ = read16(&buf, endian) >> 4;
|
2013-10-04 23:31:15 +00:00
|
|
|
*dst[0] = read16(&buf, endian) >> 4;
|
2012-10-12 19:18:49 +00:00
|
|
|
dst[0]++;
|
2016-11-10 22:04:46 +00:00
|
|
|
if (elements >= 2)
|
|
|
|
*dst[1]++ = read16(&buf, endian) >> 4;
|
2012-10-12 19:18:49 +00:00
|
|
|
if (elements == 4)
|
2016-06-15 15:45:51 +00:00
|
|
|
*dst[3]++ = read16(&buf, endian) >> 4;
|
2018-04-10 16:20:23 +00:00
|
|
|
} else {
|
|
|
|
*dst[2]++ = read12in32(&buf, &rgbBuffer,
|
|
|
|
&n_datum, endian);
|
|
|
|
*dst[0]++ = read12in32(&buf, &rgbBuffer,
|
|
|
|
&n_datum, endian);
|
|
|
|
*dst[1]++ = read12in32(&buf, &rgbBuffer,
|
|
|
|
&n_datum, endian);
|
|
|
|
if (elements == 4)
|
|
|
|
*dst[3]++ = read12in32(&buf, &rgbBuffer,
|
|
|
|
&n_datum, endian);
|
|
|
|
}
|
2009-06-12 05:29:29 +00:00
|
|
|
}
|
2016-06-15 15:45:51 +00:00
|
|
|
for (i = 0; i < elements; i++)
|
2012-10-12 19:18:49 +00:00
|
|
|
ptr[i] += p->linesize[i];
|
2015-11-14 13:29:02 +00:00
|
|
|
// Jump to next aligned position
|
|
|
|
buf += need_align;
|
2012-10-12 19:18:49 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
elements *= 2;
|
|
|
|
case 8:
|
2015-02-07 23:12:46 +00:00
|
|
|
if ( avctx->pix_fmt == AV_PIX_FMT_YUVA444P
|
|
|
|
|| avctx->pix_fmt == AV_PIX_FMT_YUV444P) {
|
|
|
|
for (x = 0; x < avctx->height; x++) {
|
|
|
|
ptr[0] = p->data[0] + x * p->linesize[0];
|
|
|
|
ptr[1] = p->data[1] + x * p->linesize[1];
|
|
|
|
ptr[2] = p->data[2] + x * p->linesize[2];
|
|
|
|
ptr[3] = p->data[3] + x * p->linesize[3];
|
|
|
|
for (y = 0; y < avctx->width; y++) {
|
|
|
|
*ptr[1]++ = *buf++;
|
|
|
|
*ptr[0]++ = *buf++;
|
|
|
|
*ptr[2]++ = *buf++;
|
|
|
|
if (avctx->pix_fmt == AV_PIX_FMT_YUVA444P)
|
|
|
|
*ptr[3]++ = *buf++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2013-07-27 20:51:14 +00:00
|
|
|
av_image_copy_plane(ptr[0], p->linesize[0],
|
2014-08-12 22:37:00 +00:00
|
|
|
buf, stride,
|
2013-07-27 20:51:14 +00:00
|
|
|
elements * avctx->width, avctx->height);
|
2015-02-07 23:12:46 +00:00
|
|
|
}
|
2012-10-12 19:18:49 +00:00
|
|
|
break;
|
2009-06-12 05:29:29 +00:00
|
|
|
}
|
|
|
|
|
2012-11-13 18:35:22 +00:00
|
|
|
*got_frame = 1;
|
2009-06-12 05:29:29 +00:00
|
|
|
|
|
|
|
return buf_size;
|
|
|
|
}
|
|
|
|
|
2011-01-25 21:40:11 +00:00
|
|
|
AVCodec ff_dpx_decoder = {
|
2011-07-17 10:54:31 +00:00
|
|
|
.name = "dpx",
|
2013-10-06 20:17:10 +00:00
|
|
|
.long_name = NULL_IF_CONFIG_SMALL("DPX (Digital Picture Exchange) image"),
|
2011-07-17 10:54:31 +00:00
|
|
|
.type = AVMEDIA_TYPE_VIDEO,
|
2012-08-05 09:11:04 +00:00
|
|
|
.id = AV_CODEC_ID_DPX,
|
2011-07-17 10:54:31 +00:00
|
|
|
.decode = decode_frame,
|
2015-07-07 00:41:27 +00:00
|
|
|
.capabilities = AV_CODEC_CAP_DR1,
|
2009-06-12 05:29:29 +00:00
|
|
|
};
|