40 #define ALPHA_COMPAND_DC_OFFSET 256
41 #define ALPHA_COMPAND_GAIN 9400
49 for (
int i = 0;
i < 64;
i++) {
67 for (
int i = 0;
i < 256;
i++)
68 s->lut[1][
i] =
i + ((768LL *
i *
i *
i) / (256 * 256 * 256));
77 s->subband_num_actual = 0;
84 memset(&
s->peak.base, 0,
sizeof(
s->peak.base));
92 s->cropped_height = 0;
97 s->lowpass_precision = 16;
100 s->difference_coding = 0;
103 if (
s->transform_type != 2)
104 s->transform_type = -1;
114 return level * quantisation;
122 for (j = 1; j <
width; j++) {
123 band[j] += band[j-1];
132 for (
i = 0;
i < length;
i++)
134 band[
i] = bytestream2_get_le16(&peak->
base);
155 uint16_t *g1 = (uint16_t *)(
frame->
data[0] + 2);
158 const int mid = 1 << (bpc - 1);
159 const int factor = 1 << (16 - bpc);
172 R = (rg - mid) * 2 +
g;
175 B = (bg - mid) * 2 +
g;
196 int width,
int linesize,
int plane)
201 even = (low[
i] - high[
i])/2;
202 odd = (low[
i] + high[
i])/2;
211 int even = (low[
i] - high[
i]) / 2;
212 int odd = (low[
i] + high[
i]) / 2;
227 s->plane[
i].idwt_size = 0;
230 s->plane[
i].subband[j] =
NULL;
232 for (j = 0; j < 10; j++)
233 s->plane[
i].l_h[j] =
NULL;
243 s->a_transform_type = INT_MIN;
249 int i, j, ret,
planes, bayer = 0;
250 int chroma_x_shift, chroma_y_shift;
261 &chroma_y_shift)) < 0)
272 int w8, h8, w4, h4, w2, h2;
273 int width = (
i || bayer) ?
s->coded_width >> chroma_x_shift :
s->coded_width;
274 int height = (
i || bayer) ?
s->coded_height >> chroma_y_shift :
s->coded_height;
280 if (chroma_y_shift && !bayer)
286 w8 =
FFALIGN(
s->plane[
i].width / 8, 8) + 64;
293 if (
s->transform_type == 0) {
295 s->plane[
i].idwt_buf =
297 s->plane[
i].idwt_tmp =
301 s->plane[
i].idwt_buf =
303 s->plane[
i].idwt_tmp =
307 if (!
s->plane[
i].idwt_buf || !
s->plane[
i].idwt_tmp)
310 s->plane[
i].subband[0] =
s->plane[
i].idwt_buf;
311 s->plane[
i].subband[1] =
s->plane[
i].idwt_buf + 2 * w8 * h8;
312 s->plane[
i].subband[2] =
s->plane[
i].idwt_buf + 1 * w8 * h8;
313 s->plane[
i].subband[3] =
s->plane[
i].idwt_buf + 3 * w8 * h8;
314 s->plane[
i].subband[4] =
s->plane[
i].idwt_buf + 2 * w4 * h4;
315 s->plane[
i].subband[5] =
s->plane[
i].idwt_buf + 1 * w4 * h4;
316 s->plane[
i].subband[6] =
s->plane[
i].idwt_buf + 3 * w4 * h4;
317 if (
s->transform_type == 0) {
318 s->plane[
i].subband[7] =
s->plane[
i].idwt_buf + 2 * w2 * h2;
319 s->plane[
i].subband[8] =
s->plane[
i].idwt_buf + 1 * w2 * h2;
320 s->plane[
i].subband[9] =
s->plane[
i].idwt_buf + 3 * w2 * h2;
323 s->plane[
i].subband[7] =
s->plane[
i].idwt_buf + 4 * w2 * h2;
324 s->plane[
i].subband[8] = frame2 + 2 * w4 * h4;
325 s->plane[
i].subband[9] = frame2 + 1 * w4 * h4;
326 s->plane[
i].subband[10] = frame2 + 3 * w4 * h4;
327 s->plane[
i].subband[11] = frame2 + 2 * w2 * h2;
328 s->plane[
i].subband[12] = frame2 + 1 * w2 * h2;
329 s->plane[
i].subband[13] = frame2 + 3 * w2 * h2;
330 s->plane[
i].subband[14] =
s->plane[
i].idwt_buf + 2 * w2 * h2;
331 s->plane[
i].subband[15] =
s->plane[
i].idwt_buf + 1 * w2 * h2;
332 s->plane[
i].subband[16] =
s->plane[
i].idwt_buf + 3 * w2 * h2;
335 if (
s->transform_type == 0) {
338 s->plane[
i].band[j][k].a_width = w8 << j;
339 s->plane[
i].band[j][k].a_height = h8 << j;
344 int t = j < 1 ? 0 : (j < 3 ? 1 : 2);
347 s->plane[
i].band[j][k].a_width = w8 << t;
348 s->plane[
i].band[j][k].a_height = h8 << t;
354 s->plane[
i].l_h[0] =
s->plane[
i].idwt_tmp;
355 s->plane[
i].l_h[1] =
s->plane[
i].idwt_tmp + 2 * w8 * h8;
357 s->plane[
i].l_h[3] =
s->plane[
i].idwt_tmp;
358 s->plane[
i].l_h[4] =
s->plane[
i].idwt_tmp + 2 * w4 * h4;
360 s->plane[
i].l_h[6] =
s->plane[
i].idwt_tmp;
361 s->plane[
i].l_h[7] =
s->plane[
i].idwt_tmp + 2 * w2 * h2;
362 if (
s->transform_type != 0) {
363 int16_t *frame2 =
s->plane[
i].idwt_tmp + 4 * w2 * h2;
365 s->plane[
i].l_h[8] = frame2;
366 s->plane[
i].l_h[9] = frame2 + 2 * w2 * h2;
370 s->a_transform_type =
s->transform_type;
371 s->a_height =
s->coded_height;
372 s->a_width =
s->coded_width;
373 s->a_format =
s->coded_format;
386 int ret = 0,
i, j, plane, got_buffer = 0;
396 uint16_t tagu = bytestream2_get_be16(&gb);
397 int16_t
tag = (int16_t)tagu;
398 int8_t tag8 = (int8_t)(tagu >> 8);
399 uint16_t abstag =
abs(
tag);
400 int8_t abs_tag8 =
abs(tag8);
401 uint16_t
data = bytestream2_get_be16(&gb);
402 if (abs_tag8 >= 0x60 && abs_tag8 <= 0x6f) {
406 s->progressive =
data & 0x0001;
408 s->frame_type =
data;
418 }
else if (abstag ==
Version) {
422 s->coded_width =
data;
425 s->coded_height =
data;
428 s->channel_cnt =
data;
442 s->channel_num =
data;
444 if (
s->channel_num >=
s->planes) {
451 if (
s->subband_num != 0 &&
data == 1 && (
s->transform_type == 0 ||
s->transform_type == 2))
454 s->subband_num =
data;
455 if ((
s->transform_type == 0 &&
s->level >=
DWT_LEVELS) ||
461 if (
s->subband_num > 3) {
474 if (
s->transform_type == 0 ||
s->transform_type == 2)
475 s->subband_num_actual =
data;
481 s->quantisation =
data;
484 for (
i = 0;
i < 8;
i++)
485 s->prescale_table[
i] = (
data >> (14 -
i * 2)) & 0x3;
493 s->band_encoding =
data;
497 s->plane[
s->channel_num].band[0][0].width =
data;
498 s->plane[
s->channel_num].band[0][0].stride =
data;
501 s->plane[
s->channel_num].band[0][0].height =
data;
503 s->sample_type =
data;
510 }
else if (
data == 1) {
515 if (
s->transform_type == -1) {
516 s->transform_type =
data;
521 }
else if (abstag >= 0x4000 && abstag <= 0x40ff) {
522 if (abstag == 0x4001)
528 s->frame_index =
data;
537 uint32_t
offset = bytestream2_get_be32(&gb);
541 av_log(avctx,
AV_LOG_DEBUG,
"Highpass width %i channel %i level %i subband %i\n",
data,
s->channel_num,
s->level,
s->subband_num);
547 s->plane[
s->channel_num].band[
s->level][
s->subband_num].width =
data;
548 s->plane[
s->channel_num].band[
s->level][
s->subband_num].stride =
FFALIGN(
data, 8);
556 s->plane[
s->channel_num].band[
s->level][
s->subband_num].height =
data;
564 s->plane[
s->channel_num].band[
s->level][
s->subband_num].width =
data;
565 s->plane[
s->channel_num].band[
s->level][
s->subband_num].stride =
FFALIGN(
data, 8);
573 s->plane[
s->channel_num].band[
s->level][
s->subband_num].height =
data;
580 }
else if (
data >= 122 &&
data <= 128) {
582 }
else if (
data == 30) {
590 s->codebook =
data & 0xf;
591 s->difference_coding = (
data >> 4) & 1;
605 }
else if (
data == 2) {
607 }
else if (
data == 3) {
609 }
else if (
data == 4) {
619 s->cropped_height =
data;
621 s->peak.offset &= ~0xffff;
622 s->peak.offset |= (
data & 0xffff);
626 s->peak.offset &= 0xffff;
627 s->peak.offset |= (
data & 0xffffU)<<16;
631 s->peak.level =
data;
644 int lowpass_height =
s->plane[
s->channel_num].band[0][0].height;
645 int lowpass_width =
s->plane[
s->channel_num].band[0][0].width;
648 if (
s->coded_width) {
652 if (
s->coded_height) {
656 if (!
s->a_width && !
s->coded_width) {
657 s->coded_width = lowpass_width *
factor * 8;
660 if (!
s->a_height && !
s->coded_height) {
661 s->coded_height = lowpass_height *
factor * 8;
664 if (
s->a_width && !
s->coded_width)
665 s->coded_width =
s->a_width;
666 if (
s->a_height && !
s->coded_height)
667 s->coded_height =
s->a_height;
669 if (
s->a_width !=
s->coded_width ||
s->a_height !=
s->coded_height ||
670 s->a_format !=
s->coded_format ||
671 s->transform_type !=
s->a_transform_type) {
681 if (
s->cropped_height) {
709 if (
s->subband_num_actual == 255)
713 if (
s->transform_type !=
s->a_transform_type)
716 coeff_data =
s->plane[
s->channel_num].subband[
s->subband_num_actual];
720 int lowpass_height, lowpass_width, lowpass_a_height, lowpass_a_width;
722 if (!
s->a_width || !
s->a_height) {
727 lowpass_height =
s->plane[
s->channel_num].band[0][0].height;
728 lowpass_width =
s->plane[
s->channel_num].band[0][0].width;
729 lowpass_a_height =
s->plane[
s->channel_num].band[0][0].a_height;
730 lowpass_a_width =
s->plane[
s->channel_num].band[0][0].a_width;
732 if (lowpass_width < 3 ||
733 lowpass_width > lowpass_a_width) {
739 if (lowpass_height < 3 ||
740 lowpass_height > lowpass_a_height) {
752 if (lowpass_height > lowpass_a_height || lowpass_width > lowpass_a_width ||
759 av_log(avctx,
AV_LOG_DEBUG,
"Start of lowpass coeffs component %d height:%d, width:%d\n",
s->channel_num, lowpass_height, lowpass_width);
760 for (
i = 0;
i < lowpass_height;
i++) {
761 for (j = 0; j < lowpass_width; j++)
762 coeff_data[j] = bytestream2_get_be16u(&gb);
764 coeff_data += lowpass_width;
771 if (lowpass_height & 1) {
772 memcpy(&coeff_data[lowpass_height * lowpass_width],
773 &coeff_data[(lowpass_height - 1) * lowpass_width],
774 lowpass_width *
sizeof(*coeff_data));
777 s->plane[
s->channel_num].band[0][0].read_ok = 1;
779 av_log(avctx,
AV_LOG_DEBUG,
"Lowpass coefficients %d\n", lowpass_width * lowpass_height);
784 int highpass_height, highpass_width, highpass_a_width, highpass_a_height, highpass_stride, a_expected;
787 int count = 0, bytes;
789 if (!
s->a_width || !
s->a_height) {
794 highpass_height =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].height;
795 highpass_width =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].width;
796 highpass_a_width =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].a_width;
797 highpass_a_height =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].a_height;
798 highpass_stride =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].stride;
799 a_expected = highpass_a_height * highpass_a_width;
807 if (highpass_height > highpass_a_height || highpass_width > highpass_a_width || a_expected < highpass_height * (uint64_t)highpass_stride) {
812 expected = highpass_height * highpass_stride;
814 av_log(avctx,
AV_LOG_DEBUG,
"Start subband coeffs plane %i level %i codebook %i expected %i\n",
s->channel_num,
s->level,
s->codebook, expected);
822 const int lossless =
s->band_encoding == 5;
824 if (
s->codebook == 0 &&
s->transform_type == 2 &&
s->subband_num_actual == 7)
838 if (count > expected)
846 const uint16_t q =
s->quantisation;
848 for (
i = 0;
i <
run;
i++) {
849 *coeff_data |=
coeff * 256U;
854 *coeff_data++ =
coeff;
869 if (count > expected)
877 const uint16_t q =
s->quantisation;
879 for (
i = 0;
i <
run;
i++) {
880 *coeff_data |=
coeff * 256U;
885 *coeff_data++ =
coeff;
892 if (count > expected) {
899 if (
s->difference_coding)
900 difference_coding(
s->plane[
s->channel_num].subband[
s->subband_num_actual], highpass_width, highpass_height);
910 av_log(avctx,
AV_LOG_DEBUG,
"End subband coeffs %i extra %i\n", count, count - expected);
911 s->plane[
s->channel_num].band[
s->level][
s->subband_num].read_ok = 1;
913 if (
s->subband_num_actual != 255)
927 s->a_transform_type == INT_MIN ||
940 for (plane = 0; plane <
s->planes; plane++) {
944 if (
s->transform_type == 2)
947 for (o = !!
level; o < 4 ; o++) {
948 if (!
s->plane[plane].band[
level][o].read_ok) {
956 if (
s->transform_type == 0 &&
s->sample_type != 1) {
957 for (plane = 0; plane <
s->planes && !ret; plane++) {
959 int lowpass_height =
s->plane[plane].band[0][0].height;
960 int output_stride =
s->plane[plane].band[0][0].a_width;
961 int lowpass_width =
s->plane[plane].band[0][0].width;
962 int highpass_stride =
s->plane[plane].band[0][1].stride;
963 int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane;
964 ptrdiff_t dst_linesize;
965 int16_t *low, *high, *output, *dst;
969 dst_linesize = pic->
linesize[act_plane];
971 dst_linesize = pic->
linesize[act_plane] / 2;
974 if (lowpass_height >
s->plane[plane].band[0][0].a_height || lowpass_width >
s->plane[plane].band[0][0].a_width ||
975 !highpass_stride ||
s->plane[plane].band[0][1].width >
s->plane[plane].band[0][1].a_width ||
976 lowpass_width < 3 || lowpass_height < 3) {
982 av_log(avctx,
AV_LOG_DEBUG,
"Decoding level 1 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
984 low =
s->plane[plane].subband[0];
985 high =
s->plane[plane].subband[2];
986 output =
s->plane[plane].l_h[0];
987 dsp->
vert_filter(output, output_stride, low, lowpass_width, high, highpass_stride, lowpass_width, lowpass_height);
989 low =
s->plane[plane].subband[1];
990 high =
s->plane[plane].subband[3];
991 output =
s->plane[plane].l_h[1];
993 dsp->
vert_filter(output, output_stride, low, highpass_stride, high, highpass_stride, lowpass_width, lowpass_height);
995 low =
s->plane[plane].l_h[0];
996 high =
s->plane[plane].l_h[1];
997 output =
s->plane[plane].subband[0];
998 dsp->
horiz_filter(output, output_stride, low, output_stride, high, output_stride, lowpass_width, lowpass_height * 2);
1000 output =
s->plane[plane].subband[0];
1001 for (
i = 0;
i < lowpass_height * 2;
i++) {
1002 for (j = 0; j < lowpass_width * 2; j++)
1005 output += output_stride * 2;
1010 lowpass_height =
s->plane[plane].band[1][1].height;
1011 output_stride =
s->plane[plane].band[1][1].a_width;
1012 lowpass_width =
s->plane[plane].band[1][1].width;
1013 highpass_stride =
s->plane[plane].band[1][1].stride;
1015 if (lowpass_height >
s->plane[plane].band[1][1].a_height || lowpass_width >
s->plane[plane].band[1][1].a_width ||
1016 !highpass_stride ||
s->plane[plane].band[1][1].width >
s->plane[plane].band[1][1].a_width ||
1017 lowpass_width < 3 || lowpass_height < 3) {
1023 av_log(avctx,
AV_LOG_DEBUG,
"Level 2 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1025 low =
s->plane[plane].subband[0];
1026 high =
s->plane[plane].subband[5];
1027 output =
s->plane[plane].l_h[3];
1028 dsp->
vert_filter(output, output_stride, low, output_stride, high, highpass_stride, lowpass_width, lowpass_height);
1030 low =
s->plane[plane].subband[4];
1031 high =
s->plane[plane].subband[6];
1032 output =
s->plane[plane].l_h[4];
1033 dsp->
vert_filter(output, output_stride, low, highpass_stride, high, highpass_stride, lowpass_width, lowpass_height);
1035 low =
s->plane[plane].l_h[3];
1036 high =
s->plane[plane].l_h[4];
1037 output =
s->plane[plane].subband[0];
1038 dsp->
horiz_filter(output, output_stride, low, output_stride, high, output_stride, lowpass_width, lowpass_height * 2);
1040 output =
s->plane[plane].subband[0];
1041 for (
i = 0;
i < lowpass_height * 2;
i++) {
1042 for (j = 0; j < lowpass_width * 2; j++)
1045 output += output_stride * 2;
1049 lowpass_height =
s->plane[plane].band[2][1].height;
1050 output_stride =
s->plane[plane].band[2][1].a_width;
1051 lowpass_width =
s->plane[plane].band[2][1].width;
1052 highpass_stride =
s->plane[plane].band[2][1].stride;
1054 if (lowpass_height >
s->plane[plane].band[2][1].a_height || lowpass_width >
s->plane[plane].band[2][1].a_width ||
1055 !highpass_stride ||
s->plane[plane].band[2][1].width >
s->plane[plane].band[2][1].a_width ||
1056 lowpass_height < 3 || lowpass_width < 3 || lowpass_width * 2 >
s->plane[plane].width) {
1062 av_log(avctx,
AV_LOG_DEBUG,
"Level 3 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1063 if (
s->progressive) {
1064 low =
s->plane[plane].subband[0];
1065 high =
s->plane[plane].subband[8];
1066 output =
s->plane[plane].l_h[6];
1067 dsp->
vert_filter(output, output_stride, low, output_stride, high, highpass_stride, lowpass_width, lowpass_height);
1069 low =
s->plane[plane].subband[7];
1070 high =
s->plane[plane].subband[9];
1071 output =
s->plane[plane].l_h[7];
1072 dsp->
vert_filter(output, output_stride, low, highpass_stride, high, highpass_stride, lowpass_width, lowpass_height);
1074 dst = (int16_t *)pic->
data[act_plane];
1079 dst += pic->
linesize[act_plane] >> 1;
1081 low =
s->plane[plane].l_h[6];
1082 high =
s->plane[plane].l_h[7];
1092 for (
i = 0;
i <
s->plane[act_plane].height;
i++) {
1096 low += output_stride;
1097 high += output_stride;
1098 dst += dst_linesize;
1103 low =
s->plane[plane].subband[0];
1104 high =
s->plane[plane].subband[7];
1105 output =
s->plane[plane].l_h[6];
1106 dsp->
horiz_filter(output, output_stride, low, output_stride, high, highpass_stride, lowpass_width, lowpass_height);
1108 low =
s->plane[plane].subband[8];
1109 high =
s->plane[plane].subband[9];
1110 output =
s->plane[plane].l_h[7];
1111 dsp->
horiz_filter(output, output_stride, low, highpass_stride, high, highpass_stride, lowpass_width, lowpass_height);
1113 dst = (int16_t *)pic->
data[act_plane];
1114 low =
s->plane[plane].l_h[6];
1115 high =
s->plane[plane].l_h[7];
1116 for (
i = 0;
i <
s->plane[act_plane].height / 2;
i++) {
1118 low += output_stride * 2;
1119 high += output_stride * 2;
1124 }
else if (
s->transform_type == 2 && (avctx->
internal->
is_copy ||
s->frame_index == 1 ||
s->sample_type != 1)) {
1125 for (plane = 0; plane <
s->planes && !ret; plane++) {
1126 int lowpass_height =
s->plane[plane].band[0][0].height;
1127 int output_stride =
s->plane[plane].band[0][0].a_width;
1128 int lowpass_width =
s->plane[plane].band[0][0].width;
1129 int highpass_stride =
s->plane[plane].band[0][1].stride;
1130 int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane;
1131 int16_t *low, *high, *output, *dst;
1132 ptrdiff_t dst_linesize;
1136 dst_linesize = pic->
linesize[act_plane];
1138 dst_linesize = pic->
linesize[act_plane] / 2;
1141 if (lowpass_height >
s->plane[plane].band[0][0].a_height || lowpass_width >
s->plane[plane].band[0][0].a_width ||
1142 !highpass_stride ||
s->plane[plane].band[0][1].width >
s->plane[plane].band[0][1].a_width ||
1143 lowpass_width < 3 || lowpass_height < 3) {
1149 av_log(avctx,
AV_LOG_DEBUG,
"Decoding level 1 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1151 low =
s->plane[plane].subband[0];
1152 high =
s->plane[plane].subband[2];
1153 output =
s->plane[plane].l_h[0];
1154 dsp->
vert_filter(output, output_stride, low, lowpass_width, high, highpass_stride, lowpass_width, lowpass_height);
1156 low =
s->plane[plane].subband[1];
1157 high =
s->plane[plane].subband[3];
1158 output =
s->plane[plane].l_h[1];
1159 dsp->
vert_filter(output, output_stride, low, highpass_stride, high, highpass_stride, lowpass_width, lowpass_height);
1161 low =
s->plane[plane].l_h[0];
1162 high =
s->plane[plane].l_h[1];
1163 output =
s->plane[plane].l_h[7];
1164 dsp->
horiz_filter(output, output_stride, low, output_stride, high, output_stride, lowpass_width, lowpass_height * 2);
1166 output =
s->plane[plane].l_h[7];
1167 for (
i = 0;
i < lowpass_height * 2;
i++) {
1168 for (j = 0; j < lowpass_width * 2; j++)
1171 output += output_stride * 2;
1175 lowpass_height =
s->plane[plane].band[1][1].height;
1176 output_stride =
s->plane[plane].band[1][1].a_width;
1177 lowpass_width =
s->plane[plane].band[1][1].width;
1178 highpass_stride =
s->plane[plane].band[1][1].stride;
1180 if (lowpass_height >
s->plane[plane].band[1][1].a_height || lowpass_width >
s->plane[plane].band[1][1].a_width ||
1181 !highpass_stride ||
s->plane[plane].band[1][1].width >
s->plane[plane].band[1][1].a_width ||
1182 lowpass_width < 3 || lowpass_height < 3) {
1188 av_log(avctx,
AV_LOG_DEBUG,
"Level 2 lowpass plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1190 low =
s->plane[plane].l_h[7];
1191 high =
s->plane[plane].subband[5];
1192 output =
s->plane[plane].l_h[3];
1193 dsp->
vert_filter(output, output_stride, low, output_stride, high, highpass_stride, lowpass_width, lowpass_height);
1195 low =
s->plane[plane].subband[4];
1196 high =
s->plane[plane].subband[6];
1197 output =
s->plane[plane].l_h[4];
1198 dsp->
vert_filter(output, output_stride, low, highpass_stride, high, highpass_stride, lowpass_width, lowpass_height);
1200 low =
s->plane[plane].l_h[3];
1201 high =
s->plane[plane].l_h[4];
1202 output =
s->plane[plane].l_h[7];
1203 dsp->
horiz_filter(output, output_stride, low, output_stride, high, output_stride, lowpass_width, lowpass_height * 2);
1205 output =
s->plane[plane].l_h[7];
1206 for (
i = 0;
i < lowpass_height * 2;
i++) {
1207 for (j = 0; j < lowpass_width * 2; j++)
1209 output += output_stride * 2;
1212 low =
s->plane[plane].subband[7];
1213 high =
s->plane[plane].subband[9];
1214 output =
s->plane[plane].l_h[3];
1215 dsp->
vert_filter(output, output_stride, low, highpass_stride, high, highpass_stride, lowpass_width, lowpass_height);
1217 low =
s->plane[plane].subband[8];
1218 high =
s->plane[plane].subband[10];
1219 output =
s->plane[plane].l_h[4];
1220 dsp->
vert_filter(output, output_stride, low, highpass_stride, high, highpass_stride, lowpass_width, lowpass_height);
1222 low =
s->plane[plane].l_h[3];
1223 high =
s->plane[plane].l_h[4];
1224 output =
s->plane[plane].l_h[9];
1225 dsp->
horiz_filter(output, output_stride, low, output_stride, high, output_stride, lowpass_width, lowpass_height * 2);
1227 lowpass_height =
s->plane[plane].band[4][1].height;
1228 output_stride =
s->plane[plane].band[4][1].a_width;
1229 lowpass_width =
s->plane[plane].band[4][1].width;
1230 highpass_stride =
s->plane[plane].band[4][1].stride;
1231 av_log(avctx,
AV_LOG_DEBUG,
"temporal level %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1233 if (lowpass_height >
s->plane[plane].band[4][1].a_height || lowpass_width >
s->plane[plane].band[4][1].a_width ||
1234 !highpass_stride ||
s->plane[plane].band[4][1].width >
s->plane[plane].band[4][1].a_width ||
1235 lowpass_width < 3 || lowpass_height < 3) {
1241 low =
s->plane[plane].l_h[7];
1242 high =
s->plane[plane].l_h[9];
1243 output =
s->plane[plane].l_h[7];
1244 for (
i = 0;
i < lowpass_height;
i++) {
1246 low += output_stride;
1247 high += output_stride;
1249 if (
s->progressive) {
1250 low =
s->plane[plane].l_h[7];
1251 high =
s->plane[plane].subband[15];
1252 output =
s->plane[plane].l_h[6];
1253 dsp->
vert_filter(output, output_stride, low, output_stride, high, highpass_stride, lowpass_width, lowpass_height);
1255 low =
s->plane[plane].subband[14];
1256 high =
s->plane[plane].subband[16];
1257 output =
s->plane[plane].l_h[7];
1258 dsp->
vert_filter(output, output_stride, low, highpass_stride, high, highpass_stride, lowpass_width, lowpass_height);
1260 low =
s->plane[plane].l_h[9];
1261 high =
s->plane[plane].subband[12];
1262 output =
s->plane[plane].l_h[8];
1263 dsp->
vert_filter(output, output_stride, low, output_stride, high, highpass_stride, lowpass_width, lowpass_height);
1265 low =
s->plane[plane].subband[11];
1266 high =
s->plane[plane].subband[13];
1267 output =
s->plane[plane].l_h[9];
1268 dsp->
vert_filter(output, output_stride, low, highpass_stride, high, highpass_stride, lowpass_width, lowpass_height);
1270 if (
s->sample_type == 1)
1273 dst = (int16_t *)pic->
data[act_plane];
1278 dst += pic->
linesize[act_plane] >> 1;
1289 low =
s->plane[plane].l_h[6];
1290 high =
s->plane[plane].l_h[7];
1291 for (
i = 0;
i <
s->plane[act_plane].height;
i++) {
1293 low += output_stride;
1294 high += output_stride;
1295 dst += dst_linesize;
1299 low =
s->plane[plane].l_h[7];
1300 high =
s->plane[plane].subband[14];
1301 output =
s->plane[plane].l_h[6];
1302 dsp->
horiz_filter(output, output_stride, low, output_stride, high, highpass_stride, lowpass_width, lowpass_height);
1304 low =
s->plane[plane].subband[15];
1305 high =
s->plane[plane].subband[16];
1306 output =
s->plane[plane].l_h[7];
1307 dsp->
horiz_filter(output, output_stride, low, highpass_stride, high, highpass_stride, lowpass_width, lowpass_height);
1309 low =
s->plane[plane].l_h[9];
1310 high =
s->plane[plane].subband[11];
1311 output =
s->plane[plane].l_h[8];
1312 dsp->
horiz_filter(output, output_stride, low, output_stride, high, highpass_stride, lowpass_width, lowpass_height);
1314 low =
s->plane[plane].subband[12];
1315 high =
s->plane[plane].subband[13];
1316 output =
s->plane[plane].l_h[9];
1317 dsp->
horiz_filter(output, output_stride, low, highpass_stride, high, highpass_stride, lowpass_width, lowpass_height);
1319 if (
s->sample_type == 1)
1322 dst = (int16_t *)pic->
data[act_plane];
1323 low =
s->plane[plane].l_h[6];
1324 high =
s->plane[plane].l_h[7];
1325 for (
i = 0;
i <
s->plane[act_plane].height / 2;
i++) {
1327 low += output_stride * 2;
1328 high += output_stride * 2;
1335 if (
s->transform_type == 2 &&
s->sample_type == 1) {
1336 int16_t *low, *high, *dst;
1337 int output_stride, lowpass_height, lowpass_width;
1338 ptrdiff_t dst_linesize;
1340 for (plane = 0; plane <
s->planes; plane++) {
1341 int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane;
1345 dst_linesize = pic->
linesize[act_plane];
1347 dst_linesize = pic->
linesize[act_plane] / 2;
1350 lowpass_height =
s->plane[plane].band[4][1].height;
1351 output_stride =
s->plane[plane].band[4][1].a_width;
1352 lowpass_width =
s->plane[plane].band[4][1].width;
1354 if (lowpass_height >
s->plane[plane].band[4][1].a_height || lowpass_width >
s->plane[plane].band[4][1].a_width ||
1355 s->plane[plane].band[4][1].width >
s->plane[plane].band[4][1].a_width ||
1356 lowpass_width < 3 || lowpass_height < 3) {
1362 if (
s->progressive) {
1363 dst = (int16_t *)pic->
data[act_plane];
1364 low =
s->plane[plane].l_h[8];
1365 high =
s->plane[plane].l_h[9];
1371 dst += pic->
linesize[act_plane] >> 1;
1382 for (
i = 0;
i <
s->plane[act_plane].height;
i++) {
1384 low += output_stride;
1385 high += output_stride;
1386 dst += dst_linesize;
1389 dst = (int16_t *)pic->
data[act_plane];
1390 low =
s->plane[plane].l_h[8];
1391 high =
s->plane[plane].l_h[9];
1392 for (
i = 0;
i <
s->plane[act_plane].height / 2;
i++) {
1394 low += output_stride * 2;
1395 high += output_stride * 2;
1459 for (
int plane = 0; plane < pdst->
planes; plane++) {
static double val(void *priv, double ch)
Macro definitions for various function/variable attributes.
static av_always_inline int even(uint64_t layout)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
static av_cold int init(AVCodecContext *avctx)
void ff_free_vlc(VLC *vlc)
refcounted data buffer API
static av_always_inline void bytestream2_skipu(GetByteContext *g, unsigned int size)
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
static av_always_inline int bytestream2_tell(GetByteContext *g)
static void difference_coding(int16_t *band, int width, int height)
static av_cold int cfhd_init(AVCodecContext *avctx)
static void interlaced_vertical_filter(int16_t *output, int16_t *low, int16_t *high, int width, int linesize, int plane)
static void inverse_temporal_filter(int16_t *low, int16_t *high, int width)
#define ALPHA_COMPAND_GAIN
static void init_plane_defaults(CFHDContext *s)
static void process_alpha(int16_t *alpha, int width)
static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static int alloc_buffers(AVCodecContext *avctx)
static void init_frame_defaults(CFHDContext *s)
#define ALPHA_COMPAND_DC_OFFSET
static void process_bayer(AVFrame *frame, int bpc)
static void peak_table(int16_t *band, Peak *peak, int length)
static av_cold int cfhd_close(AVCodecContext *avctx)
static void init_peak_table_defaults(CFHDContext *s)
static void free_buffers(CFHDContext *s)
static int dequant_and_decompand(CFHDContext *s, int level, int quantisation, int codebook)
int ff_cfhd_init_vlcs(CFHDContext *s)
av_cold void ff_cfhddsp_init(CFHDDSPContext *c, int depth, int bayer)
static const unsigned codebook[256][2]
common internal and external API header
#define AV_CEIL_RSHIFT(a, b)
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
channel
Use these values when setting the channel map with ebur128_set_channel().
FrameType
G723.1 frame types.
bitstream reader API header.
#define CLOSE_READER(name, gb)
#define OPEN_READER(name, gb)
#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update)
#define UPDATE_CACHE(name, gb)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static int get_bits_count(const GetBitContext *s)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * av_mallocz_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().
int av_image_check_size2(unsigned int w, unsigned int h, int64_t max_pixels, enum AVPixelFormat pix_fmt, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of a plane of an image with...
static const int16_t alpha[]
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
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.
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
static const struct @322 planes[]
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor.
#define AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_BAYER_RGGB16
FF_ENABLE_DEPRECATION_WARNINGS int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
void ff_thread_finish_setup(AVCodecContext *avctx)
If the codec defines update_thread_context(), call this when they are ready for the next thread to st...
#define FF_ARRAY_ELEMS(a)
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int64_t max_pixels
The number of pixels per image to maximally accept.
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
int coded_width
Bitstream width / height, may be different from width/height e.g.
struct AVCodecInternal * internal
Private context used for internal data.
int is_copy
Whether the parent AVCodecContext is a copy of the context which had init() called on it.
const char * name
Name of the codec implementation.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int interlaced_frame
The content of the picture is interlaced.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
This structure stores compressed data.
enum AVPixelFormat coded_format
void(* horiz_filter_clip)(int16_t *output, const int16_t *low, const int16_t *high, int width, int bpc)
void(* vert_filter)(int16_t *output, ptrdiff_t out_stride, const int16_t *low, ptrdiff_t low_stride, const int16_t *high, ptrdiff_t high_stride, int width, int height)
void(* horiz_filter)(int16_t *output, ptrdiff_t out_stride, const int16_t *low, ptrdiff_t low_stride, const int16_t *high, ptrdiff_t high_stride, int width, int height)
SubBand band[DWT_LEVELS_3D][4]
#define av_malloc_array(a, b)
static const double coeff[2][5]
static const int factor[16]
static const uint8_t offset[127][2]