152 #define HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP 0x38000000
156 #define HALF_FLOAT_MAX_BIASED_EXP_AS_SINGLE_FP_EXP 0x47800000
159 #define FLOAT_MAX_BIASED_EXP (0xFF << 23)
161 #define HALF_FLOAT_MAX_BIASED_EXP (0x1F << 10)
172 unsigned int sign = (
unsigned int) (hf >> 15);
173 unsigned int mantissa = (
unsigned int) (hf & ((1 << 10) - 1));
177 if (
exp == HALF_FLOAT_MAX_BIASED_EXP) {
183 mantissa = (1 << 23) - 1;
184 }
else if (
exp == 0x0) {
190 while ((mantissa & (1 << 10))) {
197 mantissa &= ((1 << 10) - 1);
208 f.
i = (sign << 31) |
exp | mantissa;
223 unsigned int exp = v >> 23;
226 if (exp <= 127 + 7 - 24)
231 return (v + (1 << 23)) >> (127 + 7 -
exp);
243 unsigned exp = 14 - (v >> 10);
248 return (v & 0x8000) ? 0 : 0xffff;
251 return (v + (1 << 16)) >> (exp + 1);
260 int d = (int) t[-1] + (
int) t[0] - 128;
268 const int8_t *
t1 =
src;
269 const int8_t *
t2 = src + (size + 1) / 2;
271 int8_t *stop = s +
size;
289 unsigned long dest_len = uncompressed_size;
291 if (uncompress(td->
tmp, &dest_len, src, compressed_size) != Z_OK ||
292 dest_len != uncompressed_size)
305 const int8_t *
s =
src;
306 int ssize = compressed_size;
307 int dsize = uncompressed_size;
317 if ((dsize -= count) < 0 ||
318 (ssize -= count + 1) < 0)
326 if ((dsize -= count) < 0 ||
346 #define USHORT_RANGE (1 << 16)
347 #define BITMAP_SIZE (1 << 13)
354 if ((i == 0) || (bitmap[i >> 3] & (1 << (i & 7))))
359 memset(lut + k, 0, (USHORT_RANGE - k) * 2);
364 static void apply_lut(
const uint16_t *lut, uint16_t *dst,
int dsize)
368 for (i = 0; i < dsize; ++
i)
369 dst[i] = lut[dst[i]];
372 #define HUF_ENCBITS 16 // literal (value) bit length
373 #define HUF_DECBITS 14 // decoding bit size (>= 8)
375 #define HUF_ENCSIZE ((1 << HUF_ENCBITS) + 1) // encoding table size
376 #define HUF_DECSIZE (1 << HUF_DECBITS) // decoding table size
377 #define HUF_DECMASK (HUF_DECSIZE - 1)
387 uint64_t
c,
n[59] = { 0 };
394 for (i = 58; i > 0; --i) {
395 uint64_t nc = ((c + n[i]) >> 1);
404 hcode[i] = l | (n[l]++ << 6);
408 #define SHORT_ZEROCODE_RUN 59
409 #define LONG_ZEROCODE_RUN 63
410 #define SHORTEST_LONG_RUN (2 + LONG_ZEROCODE_RUN - SHORT_ZEROCODE_RUN)
411 #define LONGEST_LONG_RUN (255 + SHORTEST_LONG_RUN)
421 for (; im <= iM; im++) {
427 if (im + zerun > iM + 1)
437 if (im + zerun > iM + 1)
456 for (; im <= iM; im++) {
457 uint64_t
c = hcode[
im] >> 6;
458 int i, l = hcode[
im] & 63;
478 for (i = 1 << (
HUF_DECBITS - l); i > 0; i--, pl++) {
479 if (pl->
len || pl->
p)
490 #define get_char(c, lc, gb) \
492 c = (c << 8) | bytestream2_get_byte(gb); \
496 #define get_code(po, rlc, c, lc, gb, out, oe, outb) \
500 get_char(c, lc, gb); \
505 if (out + cs > oe || out == outb) \
506 return AVERROR_INVALIDDATA; \
512 } else if (out < oe) { \
515 return AVERROR_INVALIDDATA; \
521 int rlc,
int no, uint16_t *
out)
524 uint16_t *outb =
out;
525 uint16_t *oe = out + no;
546 for (j = 0; j < pl.
lit; j++) {
547 int l = hcode[pl.
p[j]] & 63;
553 if ((hcode[pl.
p[j]] >> 6) ==
554 ((c >> (lc - l)) & ((1LL << l) - 1))) {
556 get_code(pl.
p[j], rlc, c, lc, gb, out, oe, outb);
583 if (out - outb != no)
589 uint16_t *dst,
int dst_size)
597 src_size = bytestream2_get_le32(gb);
598 im = bytestream2_get_le32(gb);
599 iM = bytestream2_get_le32(gb);
601 nBits = bytestream2_get_le32(gb);
611 if (!freq || !hdec) {
626 ret =
huf_decode(freq, hdec, gb, nBits, iM, dst_size, dst);
639 static inline void wdec14(uint16_t l, uint16_t
h, uint16_t *
a, uint16_t *
b)
644 int ai = ls + (hi & 1) + (hi >> 1);
646 int16_t bs = ai - hi;
653 #define A_OFFSET (1 << (NBITS - 1))
654 #define MOD_MASK ((1 << NBITS) - 1)
656 static inline void wdec16(uint16_t l, uint16_t
h, uint16_t *
a, uint16_t *
b)
667 int ny,
int oy, uint16_t mx)
669 int w14 = (mx < (1 << 14));
670 int n = (nx > ny) ? ny : nx;
683 uint16_t *ey = in + oy * (ny - p2);
684 uint16_t i00, i01, i10, i11;
690 for (; py <= ey; py += oy2) {
692 uint16_t *ex = py + ox * (nx - p2);
694 for (; px <= ex; px += ox2) {
695 uint16_t *p01 = px + ox1;
696 uint16_t *p10 = px + oy1;
697 uint16_t *p11 = p10 + ox1;
700 wdec14(*px, *p10, &i00, &i10);
701 wdec14(*p01, *p11, &i01, &i11);
702 wdec14(i00, i01, px, p01);
703 wdec14(i10, i11, p10, p11);
705 wdec16(*px, *p10, &i00, &i10);
706 wdec16(*p01, *p11, &i01, &i11);
707 wdec16(i00, i01, px, p01);
708 wdec16(i10, i11, p10, p11);
713 uint16_t *p10 = px + oy1;
716 wdec14(*px, *p10, &i00, p10);
718 wdec16(*px, *p10, &i00, p10);
726 uint16_t *ex = py + ox * (nx - p2);
728 for (; px <= ex; px += ox2) {
729 uint16_t *p01 = px + ox1;
732 wdec14(*px, *p01, &i00, p01);
734 wdec16(*px, *p01, &i00, p01);
749 uint16_t maxval, min_non_zero, max_non_zero;
751 uint16_t *
tmp = (uint16_t *)td->
tmp;
769 min_non_zero = bytestream2_get_le16(&gb);
770 max_non_zero = bytestream2_get_le16(&gb);
776 if (min_non_zero <= max_non_zero)
778 max_non_zero - min_non_zero + 1);
791 if (channel->pixel_type ==
EXR_HALF)
796 for (j = 0; j < pixel_half_size; j++)
798 td->
xsize * pixel_half_size, maxval);
799 ptr += td->
xsize * td->
ysize * pixel_half_size;
805 for (i = 0; i < td->
ysize; i++) {
815 in = tmp + tmp_offset * td->
xsize * td->
ysize + i * td->
xsize * pixel_half_size;
816 tmp_offset += pixel_half_size;
817 memcpy(
out, in, td->
xsize * 2 * pixel_half_size);
818 out += td->
xsize * 2 * pixel_half_size;
826 int compressed_size,
int uncompressed_size,
829 unsigned long dest_len, expected_len = 0;
844 dest_len = expected_len;
846 if (uncompress(td->
tmp, &dest_len, src, compressed_size) != Z_OK) {
848 }
else if (dest_len != expected_len) {
853 for (i = 0; i < td->
ysize; i++)
862 ptr[1] = ptr[0] + td->
xsize;
863 ptr[2] = ptr[1] + td->
xsize;
864 in = ptr[2] + td->
xsize;
866 for (j = 0; j < td->
xsize; ++j) {
867 uint32_t
diff = (*(ptr[0]++) << 24) |
868 (*(ptr[1]++) << 16) |
871 bytestream_put_le32(&out, pixel);
876 ptr[1] = ptr[0] + td->
xsize;
877 in = ptr[1] + td->
xsize;
878 for (j = 0; j < td->
xsize; j++) {
879 uint32_t
diff = (*(ptr[0]++) << 8) | *(ptr[1]++);
882 bytestream_put_le16(&out, pixel);
895 unsigned short shift = (b[ 2] >> 2);
896 unsigned short bias = (0x20 <<
shift);
899 s[ 0] = (b[0] << 8) | b[1];
901 s[ 4] = s[ 0] + ((((b[ 2] << 4) | (b[ 3] >> 4)) & 0x3f) <<
shift) - bias;
902 s[ 8] = s[ 4] + ((((b[ 3] << 2) | (b[ 4] >> 6)) & 0x3f) <<
shift) - bias;
903 s[12] = s[ 8] + ((b[ 4] & 0x3f) << shift) - bias;
905 s[ 1] = s[ 0] + ((b[ 5] >> 2) << shift) - bias;
906 s[ 5] = s[ 4] + ((((b[ 5] << 4) | (b[ 6] >> 4)) & 0x3f) <<
shift) - bias;
907 s[ 9] = s[ 8] + ((((b[ 6] << 2) | (b[ 7] >> 6)) & 0x3f) <<
shift) - bias;
908 s[13] = s[12] + ((b[ 7] & 0x3f) << shift) - bias;
910 s[ 2] = s[ 1] + ((b[ 8] >> 2) << shift) - bias;
911 s[ 6] = s[ 5] + ((((b[ 8] << 4) | (b[ 9] >> 4)) & 0x3f) <<
shift) - bias;
912 s[10] = s[ 9] + ((((b[ 9] << 2) | (b[10] >> 6)) & 0x3f) <<
shift) - bias;
913 s[14] = s[13] + ((b[10] & 0x3f) << shift) - bias;
915 s[ 3] = s[ 2] + ((b[11] >> 2) << shift) - bias;
916 s[ 7] = s[ 6] + ((((b[11] << 4) | (b[12] >> 4)) & 0x3f) <<
shift) - bias;
917 s[11] = s[10] + ((((b[12] << 2) | (b[13] >> 6)) & 0x3f) <<
shift) - bias;
918 s[15] = s[14] + ((b[13] & 0x3f) << shift) - bias;
920 for (i = 0; i < 16; ++i) {
932 s[0] = (b[0] << 8) | b[1];
939 for (i = 1; i < 16; i++)
946 const int8_t *sr =
src;
947 int stay_to_uncompress = compressed_size;
948 int nb_b44_block_w, nb_b44_block_h;
949 int index_tl_x, index_tl_y, index_out, index_tmp;
950 uint16_t tmp_buffer[16];
952 int target_channel_offset = 0;
955 nb_b44_block_w = td->
xsize / 4;
956 if ((td->
xsize % 4) != 0)
959 nb_b44_block_h = td->
ysize / 4;
960 if ((td->
ysize % 4) != 0)
965 for (iY = 0; iY < nb_b44_block_h; iY++) {
966 for (iX = 0; iX < nb_b44_block_w; iX++) {
967 if (stay_to_uncompress < 3) {
972 if (src[compressed_size - stay_to_uncompress + 2] == 0xfc) {
975 stay_to_uncompress -= 3;
977 if (stay_to_uncompress < 14) {
983 stay_to_uncompress -= 14;
990 for (y = index_tl_y; y <
FFMIN(index_tl_y + 4, td->
ysize); y++) {
991 for (x = index_tl_x; x <
FFMIN(index_tl_x + 4, td->
xsize); x++) {
993 index_tmp = (y-index_tl_y) * 4 + (x-index_tl_x);
1000 target_channel_offset += 2;
1002 if (stay_to_uncompress < td->ysize * td->
xsize * 4) {
1003 av_log(s,
AV_LOG_ERROR,
"Not enough data for uncompress channel: %d", stay_to_uncompress);
1007 for (y = 0; y < td->
ysize; y++) {
1010 sr += td->
xsize * 4;
1012 target_channel_offset += 4;
1014 stay_to_uncompress -= td->
ysize * td->
xsize * 4;
1022 int jobnr,
int threadnr)
1027 const uint8_t *channel_buffer[4] = { 0 };
1029 uint64_t line_offset, uncompressed_size;
1033 uint64_t
line, col = 0;
1034 uint64_t tileX, tileY, tileLevelX, tileLevelY;
1039 int c, rgb_channel_count;
1040 float one_gamma = 1.0f / s->
gamma;
1047 if (line_offset > buf_size - 20)
1050 src = buf + line_offset + 20;
1054 tileLevelX =
AV_RL32(src - 12);
1055 tileLevelY =
AV_RL32(src - 8);
1058 if (data_size <= 0 || data_size > buf_size)
1061 if (tileLevelX || tileLevelY) {
1075 col < s->xmin || col > s->
xmax)
1091 if (line_offset > buf_size - 8)
1094 src = buf + line_offset + 8;
1101 if (data_size <= 0 || data_size > buf_size)
1111 line_offset > buf_size - uncompressed_size)) ||
1113 line_offset > buf_size - data_size))) {
1118 if (data_size < uncompressed_size || s->is_tile) {
1124 if (data_size < uncompressed_size) {
1162 rgb_channel_count = 3;
1165 rgb_channel_count = 1;
1178 for (c = 0; c < rgb_channel_count; c++){
1179 rgb[
c] = channel_buffer[
c];
1182 if (channel_buffer[3])
1183 a = channel_buffer[3];
1185 ptr_x = (uint16_t *) ptr;
1188 memset(ptr_x, 0, bxmin);
1194 for (x = 0; x < td->
xsize; x++) {
1197 for (c = 0; c < rgb_channel_count; c++) {
1198 t.
i = bytestream_get_le32(&rgb[c]);
1199 t.
f = trc_func(t.
f);
1202 if (channel_buffer[3])
1206 for (x = 0; x < td->
xsize; x++) {
1210 for (c = 0; c < rgb_channel_count; c++) {
1211 t.
i = bytestream_get_le32(&rgb[c]);
1213 t.
f =
powf(t.
f, one_gamma);
1217 if (channel_buffer[3])
1223 for (x = 0; x < td->
xsize; x++) {
1225 for (c = 0; c < rgb_channel_count; c++) {
1226 *ptr_x++ = s->
gamma_table[bytestream_get_le16(&rgb[c])];
1229 if (channel_buffer[3])
1235 memset(ptr_x, 0, axmax);
1240 if (channel_buffer[3])
1260 const char *value_name,
1261 const char *value_type,
1262 unsigned int minimum_length)
1267 !strcmp(s->
gb.
buffer, value_name)) {
1269 s->
gb.
buffer += strlen(value_name) + 1;
1270 if (!strcmp(s->
gb.
buffer, value_type)) {
1271 s->
gb.
buffer += strlen(value_type) + 1;
1272 var_size = bytestream2_get_le32(&s->
gb);
1278 s->
gb.
buffer -= strlen(value_name) + 1;
1280 "Unknown data type %s for header variable %s.\n",
1281 value_type, value_name);
1291 int layer_match = 0;
1319 magic_number = bytestream2_get_le32(&s->
gb);
1320 if (magic_number != 20000630) {
1327 version = bytestream2_get_byte(&s->
gb);
1333 flags = bytestream2_get_le24(&s->
gb);
1337 else if (flags & 0x02)
1348 "chlist", 38)) >= 0) {
1358 int channel_index = -1;
1361 if (strcmp(s->
layer,
"") != 0) {
1365 "Channel match layer : %s.\n", ch_gb.
buffer);
1367 if (*ch_gb.
buffer ==
'.')
1371 "Channel doesn't match layer : %s.\n", ch_gb.
buffer);
1378 if (!strcmp(ch_gb.
buffer,
"R") ||
1379 !strcmp(ch_gb.
buffer,
"X") ||
1380 !strcmp(ch_gb.
buffer,
"U")) {
1383 }
else if (!strcmp(ch_gb.
buffer,
"G") ||
1384 !strcmp(ch_gb.
buffer,
"V")) {
1387 }
else if (!strcmp(ch_gb.
buffer,
"Y")) {
1390 }
else if (!strcmp(ch_gb.
buffer,
"B") ||
1391 !strcmp(ch_gb.
buffer,
"Z") ||
1392 !strcmp(ch_gb.
buffer,
"W")){
1395 }
else if (!strcmp(ch_gb.
buffer,
"A")) {
1399 "Unsupported channel %.256s.\n", ch_gb.
buffer);
1405 bytestream2_get_byte(&ch_gb))
1413 current_pixel_type = bytestream2_get_le32(&ch_gb);
1416 current_pixel_type);
1421 xsub = bytestream2_get_le32(&ch_gb);
1422 ysub = bytestream2_get_le32(&ch_gb);
1424 if (xsub != 1 || ysub != 1) {
1426 "Subsampling %dx%d",
1432 if (channel_index >= 0) {
1436 "RGB channels not of the same depth.\n");
1450 channel->
xsub = xsub;
1451 channel->
ysub = ysub;
1480 s->
xmin = bytestream2_get_le32(&s->
gb);
1481 s->
ymin = bytestream2_get_le32(&s->
gb);
1482 s->
xmax = bytestream2_get_le32(&s->
gb);
1483 s->
ymax = bytestream2_get_le32(&s->
gb);
1489 "box2i", 34)) >= 0) {
1494 s->
w = bytestream2_get_le32(&s->
gb) + 1;
1495 s->
h = bytestream2_get_le32(&s->
gb) + 1;
1499 "lineOrder", 25)) >= 0) {
1504 line_order = bytestream2_get_byte(&s->
gb);
1506 if (line_order > 2) {
1513 "float", 31)) >= 0) {
1517 sar = bytestream2_get_le32(&s->
gb);
1521 "compression", 29)) >= 0) {
1529 "Found more than one compression attribute.\n");
1533 "tiledesc", 22)) >= 0) {
1538 "Found tile attribute and scanline flags. Exr will be interpreted as scanline.\n");
1543 tileLevel = bytestream2_get_byte(&s->
gb);
1569 for (i = 0; i < 2; i++)
1570 while (bytestream2_get_byte(&s->
gb) != 0);
1701 ptr = picture->
data[0];
1704 for (y = 0; y < s->
ymin; y++) {
1705 memset(ptr, 0, out_line_size);
1714 for (y = s->
ymax + 1; y < avctx->
height; y++) {
1715 memset(ptr, 0, out_line_size);
1730 float one_gamma = 1.0
f / s->
gamma;
1737 for (i = 0; i < 65536; ++
i) {
1739 t.
f = trc_func(t.
f);
1743 if (one_gamma > 0.9999
f && one_gamma < 1.0001
f) {
1744 for (i = 0; i < 65536; ++
i)
1747 for (i = 0; i < 65536; ++
i) {
1753 t.
f =
powf(t.
f, one_gamma);
1799 #define OFFSET(x) offsetof(EXRContext, x)
1800 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
1802 {
"layer",
"Set the decoding layer",
OFFSET(layer),
1804 {
"gamma",
"Set the float gamma value when decoding",
OFFSET(gamma),
1808 {
"apply_trc",
"color transfer characteristics to apply to EXR linear input",
OFFSET(apply_trc_type),
1810 {
"bt709",
"BT.709", 0,
1812 {
"gamma",
"gamma", 0,
1814 {
"gamma22",
"BT.470 M", 0,
1816 {
"gamma28",
"BT.470 BG", 0,
1818 {
"smpte170m",
"SMPTE 170 M", 0,
1820 {
"smpte240m",
"SMPTE 240 M", 0,
1822 {
"linear",
"Linear", 0,
1826 {
"log_sqrt",
"Log square root", 0,
1828 {
"iec61966_2_4",
"IEC 61966-2-4", 0,
1830 {
"bt1361",
"BT.1361", 0,
1832 {
"iec61966_2_1",
"IEC 61966-2-1", 0,
1834 {
"bt2020_10bit",
"BT.2020 - 10 bit", 0,
1836 {
"bt2020_12bit",
"BT.2020 - 12 bit", 0,
1838 {
"smpte2084",
"SMPTE ST 2084", 0,
1840 {
"smpte428_1",
"SMPTE ST 428-1", 0,
ITU-R BT2020 for 12-bit system.
static uint16_t exr_flt2uint(uint32_t v)
Convert from 32-bit float as uint32_t to uint16_t.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int shift(int a, int b)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
ptrdiff_t const GLvoid * data
"Linear transfer characteristics"
static uint16_t reverse_lut(const uint8_t *bitmap, uint16_t *lut)
double(* avpriv_trc_function)(double)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
static int init_thread_copy(AVCodecContext *avctx)
#define LIBAVUTIL_VERSION_INT
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
static av_cold int init(AVCodecContext *avctx)
static av_always_inline float av_int2float(uint32_t i)
Reinterpret a 32-bit integer as a float.
#define AV_PIX_FMT_RGBA64
static int pxr24_uncompress(EXRContext *s, const uint8_t *src, int compressed_size, int uncompressed_size, EXRThreadData *td)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end w...
enum ExrPixelType pixel_type
static int decode_block(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr)
#define HALF_FLOAT_MAX_BIASED_EXP
AVColorTransferCharacteristic
Color Transfer Characteristic.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
static void wav_decode(uint16_t *in, int nx, int ox, int ny, int oy, uint16_t mx)
#define get_code(po, rlc, c, lc, gb, out, oe, outb)
Multithreading support functions.
also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
static int huf_uncompress(GetByteContext *gb, uint16_t *dst, int dst_size)
static int huf_build_dec_table(const uint64_t *hcode, int im, int iM, HufDec *hdecod)
#define get_char(c, lc, gb)
static int get_bits_count(const GetBitContext *s)
static const AVOption options[]
int ff_set_sar(AVCodecContext *avctx, AVRational sar)
Check that the provided sample aspect ratio is valid and set it on the codec context.
bitstream reader API header.
uint8_t * uncompressed_data
static int huf_decode(const uint64_t *hcode, const HufDec *hdecod, GetByteContext *gb, int nbits, int rlc, int no, uint16_t *out)
static void predictor(uint8_t *src, int size)
#define FLOAT_MAX_BIASED_EXP
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
ITU-R BT1361 Extended Colour Gamut.
static av_cold int decode_init(AVCodecContext *avctx)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
uint16_t gamma_table[65536]
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
static void reorder_pixels(uint8_t *src, uint8_t *dst, int size)
enum AVColorTransferCharacteristic apply_trc_type
enum ExrPixelType pixel_type
const char * name
Name of the codec implementation.
#define LONG_ZEROCODE_RUN
static void * av_mallocz_array(size_t nmemb, size_t size)
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
int current_channel_offset
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
EXRThreadData * thread_data
static void unpack_3(const uint8_t b[3], uint16_t s[16])
uint8_t nb_components
The number of components each pixel has, (1-4)
enum AVPictureType pict_type
Picture type of the frame.
#define HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP
#define AV_PIX_FMT_GRAY16
int width
picture width / height.
enum ExrCompr compression
static uint16_t exr_halflt2uint(uint16_t v)
Convert from 16-bit float as uint16_t to uint16_t.
EXRTileAttribute tile_attr
static void unpack_14(const uint8_t b[14], uint16_t s[16])
avpriv_trc_function avpriv_get_trc_function_from_trc(enum AVColorTransferCharacteristic trc)
Determine the function needed to apply the given AVColorTransferCharacteristic to linear input...
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
enum ExrTileLevelMode level_mode
#define SHORTEST_LONG_RUN
static int check_header_variable(EXRContext *s, const char *value_name, const char *value_type, unsigned int minimum_length)
Check if the variable name corresponds to its data type.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
static int b44_uncompress(EXRContext *s, const uint8_t *src, int compressed_size, int uncompressed_size, EXRThreadData *td)
#define AV_LOG_INFO
Standard information.
also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
main external API structure.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
static int zip_uncompress(const uint8_t *src, int compressed_size, int uncompressed_size, EXRThreadData *td)
Describe the class of an AVClass context structure.
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
"Logarithmic transfer characteristic (100 * Sqrt(10) : 1 range)"
static av_cold int decode_end(AVCodecContext *avctx)
static int rle_uncompress(const uint8_t *src, int compressed_size, int uncompressed_size, EXRThreadData *td)
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVRational av_d2q(double d, int max)
Convert a double precision floating point number to a rational.
#define SHORT_ZEROCODE_RUN
static union av_intfloat32 exr_half2float(uint16_t hf)
Convert a half float as a uint16_t into a full float.
IEC 61966-2-1 (sRGB or sYCC)
common internal api header.
common internal and external API header
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
static av_always_inline int diff(const uint32_t a, const uint32_t b)
int(* execute2)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count)
The codec may call this to execute several independent things.
static int piz_uncompress(EXRContext *s, const uint8_t *src, int ssize, int dsize, EXRThreadData *td)
static void huf_canonical_code_table(uint64_t *hcode)
ITU-R BT2020 for 10-bit system.
static void apply_lut(const uint16_t *lut, uint16_t *dst, int dsize)
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static void wdec14(uint16_t l, uint16_t h, uint16_t *a, uint16_t *b)
static int decode_header(EXRContext *s)
static void wdec16(uint16_t l, uint16_t h, uint16_t *a, uint16_t *b)
static int huf_unpack_enc_table(GetByteContext *gb, int32_t im, int32_t iM, uint64_t *hcode)
const AVPixFmtDescriptor * desc
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static const AVClass exr_class
enum ExrTileLevelRound level_round
"Logarithmic transfer characteristic (100:1 range)"