41 #define ALPHA_COMPAND_DC_OFFSET 256
42 #define ALPHA_COMPAND_GAIN 9400
50 for (
int i = 0;
i < 64;
i++) {
68 for (
int i = 0;
i < 256;
i++)
69 s->lut[1][
i] =
i + ((768LL *
i *
i *
i) / (256 * 256 * 256));
78 s->subband_num_actual = 0;
85 memset(&
s->peak.base, 0,
sizeof(
s->peak.base));
93 s->cropped_height = 0;
98 s->lowpass_precision = 16;
101 s->difference_coding = 0;
104 if (
s->transform_type != 2)
105 s->transform_type = -1;
115 return level * quantisation;
121 for (
int j = 1; j <
width; j++) {
122 band[j] += band[j-1];
130 for (
int i = 0;
i < length;
i++)
132 band[
i] = bytestream2_get_le16(&peak->
base);
150 const int linesize =
frame->linesize[0];
151 uint16_t *
r = (uint16_t *)
frame->data[0];
152 uint16_t *g1 = (uint16_t *)(
frame->data[0] + 2);
153 uint16_t *g2 = (uint16_t *)(
frame->data[0] +
frame->linesize[0]);
154 uint16_t *
b = (uint16_t *)(
frame->data[0] +
frame->linesize[0] + 2);
155 const int mid = 1 << (bpc - 1);
156 const int factor = 1 << (16 - bpc);
158 for (
int y = 0; y <
frame->height >> 1; y++) {
159 for (
int x = 0; x <
frame->width; x += 2) {
169 R = (rg - mid) * 2 +
g;
172 B = (bg - mid) * 2 +
g;
193 int width,
int linesize,
int plane)
197 int16_t odd = (low[
i] +
high[
i])/2;
207 int odd = (low[
i] +
high[
i]) / 2;
220 s->plane[
i].idwt_size = 0;
223 s->plane[
i].subband[j] =
NULL;
225 for (
int j = 0; j < 10; j++)
226 s->plane[
i].l_h[j] =
NULL;
236 s->a_transform_type = INT_MIN;
243 int chroma_x_shift, chroma_y_shift;
253 &chroma_y_shift)) < 0)
264 int w8, h8, w4, h4, w2, h2;
265 int width = (
i || bayer) ?
s->coded_width >> chroma_x_shift :
s->coded_width;
266 int height = (
i || bayer) ?
s->coded_height >> chroma_y_shift :
s->coded_height;
269 if (chroma_y_shift && !bayer)
275 w8 =
FFALIGN(
s->plane[
i].width / 8, 8) + 64;
282 if (
s->transform_type == 0) {
284 s->plane[
i].idwt_buf =
285 av_calloc(
s->plane[
i].idwt_size,
sizeof(*
s->plane[
i].idwt_buf));
286 s->plane[
i].idwt_tmp =
290 s->plane[
i].idwt_buf =
291 av_calloc(
s->plane[
i].idwt_size,
sizeof(*
s->plane[
i].idwt_buf));
292 s->plane[
i].idwt_tmp =
296 if (!
s->plane[
i].idwt_buf || !
s->plane[
i].idwt_tmp)
299 s->plane[
i].subband[0] =
s->plane[
i].idwt_buf;
300 s->plane[
i].subband[1] =
s->plane[
i].idwt_buf + 2 * w8 * h8;
301 s->plane[
i].subband[2] =
s->plane[
i].idwt_buf + 1 * w8 * h8;
302 s->plane[
i].subband[3] =
s->plane[
i].idwt_buf + 3 * w8 * h8;
303 s->plane[
i].subband[4] =
s->plane[
i].idwt_buf + 2 * w4 * h4;
304 s->plane[
i].subband[5] =
s->plane[
i].idwt_buf + 1 * w4 * h4;
305 s->plane[
i].subband[6] =
s->plane[
i].idwt_buf + 3 * w4 * h4;
306 if (
s->transform_type == 0) {
307 s->plane[
i].subband[7] =
s->plane[
i].idwt_buf + 2 * w2 * h2;
308 s->plane[
i].subband[8] =
s->plane[
i].idwt_buf + 1 * w2 * h2;
309 s->plane[
i].subband[9] =
s->plane[
i].idwt_buf + 3 * w2 * h2;
312 s->plane[
i].subband[7] =
s->plane[
i].idwt_buf + 4 * w2 * h2;
313 s->plane[
i].subband[8] = frame2 + 2 * w4 * h4;
314 s->plane[
i].subband[9] = frame2 + 1 * w4 * h4;
315 s->plane[
i].subband[10] = frame2 + 3 * w4 * h4;
316 s->plane[
i].subband[11] = frame2 + 2 * w2 * h2;
317 s->plane[
i].subband[12] = frame2 + 1 * w2 * h2;
318 s->plane[
i].subband[13] = frame2 + 3 * w2 * h2;
319 s->plane[
i].subband[14] =
s->plane[
i].idwt_buf + 2 * w2 * h2;
320 s->plane[
i].subband[15] =
s->plane[
i].idwt_buf + 1 * w2 * h2;
321 s->plane[
i].subband[16] =
s->plane[
i].idwt_buf + 3 * w2 * h2;
324 if (
s->transform_type == 0) {
327 s->plane[
i].band[j][k].a_width = w8 << j;
328 s->plane[
i].band[j][k].a_height = h8 << j;
333 int t = j < 1 ? 0 : (j < 3 ? 1 : 2);
336 s->plane[
i].band[j][k].a_width = w8 << t;
337 s->plane[
i].band[j][k].a_height = h8 << t;
343 s->plane[
i].l_h[0] =
s->plane[
i].idwt_tmp;
344 s->plane[
i].l_h[1] =
s->plane[
i].idwt_tmp + 2 * w8 * h8;
346 s->plane[
i].l_h[3] =
s->plane[
i].idwt_tmp;
347 s->plane[
i].l_h[4] =
s->plane[
i].idwt_tmp + 2 * w4 * h4;
349 s->plane[
i].l_h[6] =
s->plane[
i].idwt_tmp;
350 s->plane[
i].l_h[7] =
s->plane[
i].idwt_tmp + 2 * w2 * h2;
351 if (
s->transform_type != 0) {
352 int16_t *frame2 =
s->plane[
i].idwt_tmp + 4 * w2 * h2;
354 s->plane[
i].l_h[8] = frame2;
355 s->plane[
i].l_h[9] = frame2 + 2 * w2 * h2;
359 s->a_transform_type =
s->transform_type;
360 s->a_height =
s->coded_height;
361 s->a_width =
s->coded_width;
362 s->a_format =
s->coded_format;
373 int ret = 0, got_buffer = 0;
382 uint16_t tagu = bytestream2_get_be16(&gb);
383 int16_t
tag = (int16_t)tagu;
384 int8_t tag8 = (int8_t)(tagu >> 8);
385 uint16_t abstag =
abs(
tag);
386 int8_t abs_tag8 =
abs(tag8);
387 uint16_t
data = bytestream2_get_be16(&gb);
390 if (abs_tag8 >= 0x60 && abs_tag8 <= 0x6f) {
394 s->progressive =
data & 0x0001;
396 s->frame_type =
data;
406 }
else if (abstag ==
Version) {
410 s->coded_width =
data;
413 s->coded_height =
data;
416 s->channel_cnt =
data;
430 s->channel_num =
data;
432 if (
s->channel_num >=
s->planes) {
439 if (
s->subband_num != 0 &&
data == 1 && (
s->transform_type == 0 ||
s->transform_type == 2))
442 s->subband_num =
data;
443 if ((
s->transform_type == 0 &&
s->level >=
DWT_LEVELS) ||
449 if (
s->subband_num > 3) {
462 if (
s->transform_type == 0 ||
s->transform_type == 2)
463 s->subband_num_actual =
data;
469 s->quantisation =
data;
472 for (
int i = 0;
i < 8;
i++)
473 s->prescale_table[
i] = (
data >> (14 -
i * 2)) & 0x3;
481 s->band_encoding =
data;
485 s->plane[
s->channel_num].band[0][0].width =
data;
486 s->plane[
s->channel_num].band[0][0].stride =
data;
489 s->plane[
s->channel_num].band[0][0].height =
data;
491 s->sample_type =
data;
498 }
else if (
data == 1) {
503 if (
s->transform_type == -1) {
504 s->transform_type =
data;
509 }
else if (abstag >= 0x4000 && abstag <= 0x40ff) {
510 if (abstag == 0x4001)
516 s->frame_index =
data;
524 for (
int i = 0;
i <
data;
i++) {
525 uint32_t
offset = bytestream2_get_be32(&gb);
529 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);
535 s->plane[
s->channel_num].band[
s->level][
s->subband_num].width =
data;
536 s->plane[
s->channel_num].band[
s->level][
s->subband_num].stride =
FFALIGN(
data, 8);
544 s->plane[
s->channel_num].band[
s->level][
s->subband_num].height =
data;
552 s->plane[
s->channel_num].band[
s->level][
s->subband_num].width =
data;
553 s->plane[
s->channel_num].band[
s->level][
s->subband_num].stride =
FFALIGN(
data, 8);
561 s->plane[
s->channel_num].band[
s->level][
s->subband_num].height =
data;
568 }
else if (
data >= 122 &&
data <= 128) {
570 }
else if (
data == 30) {
578 s->codebook =
data & 0xf;
579 s->difference_coding = (
data >> 4) & 1;
593 }
else if (
data == 2) {
595 }
else if (
data == 3) {
597 }
else if (
data == 4) {
607 s->cropped_height =
data;
609 s->peak.offset &= ~0xffff;
610 s->peak.offset |= (
data & 0xffff);
614 s->peak.offset &= 0xffff;
615 s->peak.offset |= (
data & 0xffff
U)<<16;
619 s->peak.level =
data;
632 int lowpass_height =
s->plane[
s->channel_num].band[0][0].height;
633 int lowpass_width =
s->plane[
s->channel_num].band[0][0].width;
636 if (
s->coded_width) {
640 if (
s->coded_height) {
644 if (!
s->a_width && !
s->coded_width) {
645 s->coded_width = lowpass_width *
factor * 8;
648 if (!
s->a_height && !
s->coded_height) {
649 s->coded_height = lowpass_height *
factor * 8;
652 if (
s->a_width && !
s->coded_width)
653 s->coded_width =
s->a_width;
654 if (
s->a_height && !
s->coded_height)
655 s->coded_height =
s->a_height;
657 if (
s->a_width !=
s->coded_width ||
s->a_height !=
s->coded_height ||
658 s->a_format !=
s->coded_format ||
659 s->transform_type !=
s->a_transform_type) {
669 if (
s->cropped_height) {
695 if (
s->subband_num_actual == 255)
697 coeff_data =
s->plane[
s->channel_num].subband[
s->subband_num_actual];
701 int lowpass_height, lowpass_width, lowpass_a_height, lowpass_a_width;
703 if (!
s->a_width || !
s->a_height) {
708 lowpass_height =
s->plane[
s->channel_num].band[0][0].height;
709 lowpass_width =
s->plane[
s->channel_num].band[0][0].width;
710 lowpass_a_height =
s->plane[
s->channel_num].band[0][0].a_height;
711 lowpass_a_width =
s->plane[
s->channel_num].band[0][0].a_width;
713 if (lowpass_width < 3 ||
714 lowpass_width > lowpass_a_width) {
720 if (lowpass_height < 3 ||
721 lowpass_height > lowpass_a_height) {
733 if (lowpass_height > lowpass_a_height || lowpass_width > lowpass_a_width ||
740 av_log(avctx,
AV_LOG_DEBUG,
"Start of lowpass coeffs component %d height:%d, width:%d\n",
s->channel_num, lowpass_height, lowpass_width);
741 for (
int i = 0;
i < lowpass_height;
i++) {
742 for (
int j = 0; j < lowpass_width; j++)
743 coeff_data[j] = bytestream2_get_be16u(&gb);
745 coeff_data += lowpass_width;
752 if (lowpass_height & 1) {
753 memcpy(&coeff_data[lowpass_height * lowpass_width],
754 &coeff_data[(lowpass_height - 1) * lowpass_width],
755 lowpass_width *
sizeof(*coeff_data));
758 s->plane[
s->channel_num].band[0][0].read_ok = 1;
760 av_log(avctx,
AV_LOG_DEBUG,
"Lowpass coefficients %d\n", lowpass_width * lowpass_height);
765 int highpass_height, highpass_width, highpass_a_width, highpass_a_height, highpass_stride, a_expected;
768 int count = 0, bytes;
770 if (!
s->a_width || !
s->a_height) {
775 highpass_height =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].height;
776 highpass_width =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].width;
777 highpass_a_width =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].a_width;
778 highpass_a_height =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].a_height;
779 highpass_stride =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].stride;
780 a_expected = highpass_a_height * highpass_a_width;
788 if (highpass_height > highpass_a_height || highpass_width > highpass_a_width || a_expected < highpass_height * (uint64_t)highpass_stride) {
793 expected = highpass_height * highpass_stride;
795 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);
803 const int lossless =
s->band_encoding == 5;
805 if (
s->codebook == 0 &&
s->transform_type == 2 &&
s->subband_num_actual == 7)
821 if (count > expected)
829 const uint16_t q =
s->quantisation;
831 for (
int i = 0;
i <
run;
i++) {
832 *coeff_data |=
coeff * 256
U;
836 for (
int i = 0;
i <
run;
i++)
837 *coeff_data++ =
coeff;
854 if (count > expected)
862 const uint16_t q =
s->quantisation;
864 for (
int i = 0;
i <
run;
i++) {
865 *coeff_data |=
coeff * 256
U;
869 for (
int i = 0;
i <
run;
i++)
870 *coeff_data++ =
coeff;
877 if (count > expected) {
884 if (
s->difference_coding)
885 difference_coding(
s->plane[
s->channel_num].subband[
s->subband_num_actual], highpass_width, highpass_height);
895 av_log(avctx,
AV_LOG_DEBUG,
"End subband coeffs %i extra %i\n", count, count - expected);
896 s->plane[
s->channel_num].band[
s->level][
s->subband_num].read_ok = 1;
898 if (
s->subband_num_actual != 255)
912 s->a_transform_type == INT_MIN ||
925 for (
int plane = 0; plane <
s->planes; plane++) {
927 if (
s->transform_type == 2)
930 for (
int o = !!
level; o < 4 ; o++) {
931 if (!
s->plane[plane].band[
level][o].read_ok) {
939 if (
s->transform_type == 0 &&
s->sample_type != 1) {
940 for (
int plane = 0; plane <
s->planes && !
ret; plane++) {
942 int lowpass_height =
s->plane[plane].band[0][0].height;
943 int output_stride =
s->plane[plane].band[0][0].a_width;
944 int lowpass_width =
s->plane[plane].band[0][0].width;
945 int highpass_stride =
s->plane[plane].band[0][1].stride;
946 int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane;
947 ptrdiff_t dst_linesize;
952 dst_linesize = pic->
linesize[act_plane];
954 dst_linesize = pic->
linesize[act_plane] / 2;
957 if (lowpass_height >
s->plane[plane].band[0][0].a_height || lowpass_width >
s->plane[plane].band[0][0].a_width ||
958 !highpass_stride ||
s->plane[plane].band[0][1].width >
s->plane[plane].band[0][1].a_width ||
959 lowpass_width < 3 || lowpass_height < 3) {
965 av_log(avctx,
AV_LOG_DEBUG,
"Decoding level 1 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
967 low =
s->plane[plane].subband[0];
968 high =
s->plane[plane].subband[2];
969 output =
s->plane[plane].l_h[0];
970 dsp->
vert_filter(
output, output_stride, low, lowpass_width,
high, highpass_stride, lowpass_width, lowpass_height);
972 low =
s->plane[plane].subband[1];
973 high =
s->plane[plane].subband[3];
974 output =
s->plane[plane].l_h[1];
976 dsp->
vert_filter(
output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
978 low =
s->plane[plane].l_h[0];
979 high =
s->plane[plane].l_h[1];
980 output =
s->plane[plane].subband[0];
981 dsp->
horiz_filter(
output, output_stride, low, output_stride,
high, output_stride, lowpass_width, lowpass_height * 2);
983 output =
s->plane[plane].subband[0];
984 for (
int i = 0;
i < lowpass_height * 2;
i++) {
985 for (
int j = 0; j < lowpass_width * 2; j++)
988 output += output_stride * 2;
993 lowpass_height =
s->plane[plane].band[1][1].height;
994 output_stride =
s->plane[plane].band[1][1].a_width;
995 lowpass_width =
s->plane[plane].band[1][1].width;
996 highpass_stride =
s->plane[plane].band[1][1].stride;
998 if (lowpass_height >
s->plane[plane].band[1][1].a_height || lowpass_width >
s->plane[plane].band[1][1].a_width ||
999 !highpass_stride ||
s->plane[plane].band[1][1].width >
s->plane[plane].band[1][1].a_width ||
1000 lowpass_width < 3 || lowpass_height < 3) {
1006 av_log(avctx,
AV_LOG_DEBUG,
"Level 2 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1008 low =
s->plane[plane].subband[0];
1009 high =
s->plane[plane].subband[5];
1010 output =
s->plane[plane].l_h[3];
1011 dsp->
vert_filter(
output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1013 low =
s->plane[plane].subband[4];
1014 high =
s->plane[plane].subband[6];
1015 output =
s->plane[plane].l_h[4];
1016 dsp->
vert_filter(
output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1018 low =
s->plane[plane].l_h[3];
1019 high =
s->plane[plane].l_h[4];
1020 output =
s->plane[plane].subband[0];
1021 dsp->
horiz_filter(
output, output_stride, low, output_stride,
high, output_stride, lowpass_width, lowpass_height * 2);
1023 output =
s->plane[plane].subband[0];
1024 for (
int i = 0;
i < lowpass_height * 2;
i++) {
1025 for (
int j = 0; j < lowpass_width * 2; j++)
1028 output += output_stride * 2;
1032 lowpass_height =
s->plane[plane].band[2][1].height;
1033 output_stride =
s->plane[plane].band[2][1].a_width;
1034 lowpass_width =
s->plane[plane].band[2][1].width;
1035 highpass_stride =
s->plane[plane].band[2][1].stride;
1037 if (lowpass_height >
s->plane[plane].band[2][1].a_height || lowpass_width >
s->plane[plane].band[2][1].a_width ||
1038 !highpass_stride ||
s->plane[plane].band[2][1].width >
s->plane[plane].band[2][1].a_width ||
1039 lowpass_height < 3 || lowpass_width < 3 || lowpass_width * 2 >
s->plane[plane].width) {
1045 av_log(avctx,
AV_LOG_DEBUG,
"Level 3 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1046 if (
s->progressive) {
1047 low =
s->plane[plane].subband[0];
1048 high =
s->plane[plane].subband[8];
1049 output =
s->plane[plane].l_h[6];
1050 dsp->
vert_filter(
output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1052 low =
s->plane[plane].subband[7];
1053 high =
s->plane[plane].subband[9];
1054 output =
s->plane[plane].l_h[7];
1055 dsp->
vert_filter(
output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1057 dst = (int16_t *)pic->
data[act_plane];
1064 low =
s->plane[plane].l_h[6];
1065 high =
s->plane[plane].l_h[7];
1075 for (
int i = 0;
i <
s->plane[act_plane].height;
i++) {
1079 low += output_stride;
1080 high += output_stride;
1081 dst += dst_linesize;
1086 low =
s->plane[plane].subband[0];
1087 high =
s->plane[plane].subband[7];
1088 output =
s->plane[plane].l_h[6];
1089 dsp->
horiz_filter(
output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1091 low =
s->plane[plane].subband[8];
1092 high =
s->plane[plane].subband[9];
1093 output =
s->plane[plane].l_h[7];
1094 dsp->
horiz_filter(
output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1096 dst = (int16_t *)pic->
data[act_plane];
1097 low =
s->plane[plane].l_h[6];
1098 high =
s->plane[plane].l_h[7];
1099 for (
int i = 0;
i <
s->plane[act_plane].height / 2;
i++) {
1101 low += output_stride * 2;
1102 high += output_stride * 2;
1107 }
else if (
s->transform_type == 2 && (avctx->
internal->
is_copy ||
s->frame_index == 1 ||
s->sample_type != 1)) {
1108 for (
int plane = 0; plane <
s->planes && !
ret; plane++) {
1109 int lowpass_height =
s->plane[plane].band[0][0].height;
1110 int output_stride =
s->plane[plane].band[0][0].a_width;
1111 int lowpass_width =
s->plane[plane].band[0][0].width;
1112 int highpass_stride =
s->plane[plane].band[0][1].stride;
1113 int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane;
1115 ptrdiff_t dst_linesize;
1119 dst_linesize = pic->
linesize[act_plane];
1121 dst_linesize = pic->
linesize[act_plane] / 2;
1124 if (lowpass_height >
s->plane[plane].band[0][0].a_height || lowpass_width >
s->plane[plane].band[0][0].a_width ||
1125 !highpass_stride ||
s->plane[plane].band[0][1].width >
s->plane[plane].band[0][1].a_width ||
1126 lowpass_width < 3 || lowpass_height < 3) {
1132 av_log(avctx,
AV_LOG_DEBUG,
"Decoding level 1 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1134 low =
s->plane[plane].subband[0];
1135 high =
s->plane[plane].subband[2];
1136 output =
s->plane[plane].l_h[0];
1137 dsp->
vert_filter(
output, output_stride, low, lowpass_width,
high, highpass_stride, lowpass_width, lowpass_height);
1139 low =
s->plane[plane].subband[1];
1140 high =
s->plane[plane].subband[3];
1141 output =
s->plane[plane].l_h[1];
1142 dsp->
vert_filter(
output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1144 low =
s->plane[plane].l_h[0];
1145 high =
s->plane[plane].l_h[1];
1146 output =
s->plane[plane].l_h[7];
1147 dsp->
horiz_filter(
output, output_stride, low, output_stride,
high, output_stride, lowpass_width, lowpass_height * 2);
1149 output =
s->plane[plane].l_h[7];
1150 for (
int i = 0;
i < lowpass_height * 2;
i++) {
1151 for (
int j = 0; j < lowpass_width * 2; j++)
1154 output += output_stride * 2;
1158 lowpass_height =
s->plane[plane].band[1][1].height;
1159 output_stride =
s->plane[plane].band[1][1].a_width;
1160 lowpass_width =
s->plane[plane].band[1][1].width;
1161 highpass_stride =
s->plane[plane].band[1][1].stride;
1163 if (lowpass_height >
s->plane[plane].band[1][1].a_height || lowpass_width >
s->plane[plane].band[1][1].a_width ||
1164 !highpass_stride ||
s->plane[plane].band[1][1].width >
s->plane[plane].band[1][1].a_width ||
1165 lowpass_width < 3 || lowpass_height < 3) {
1171 av_log(avctx,
AV_LOG_DEBUG,
"Level 2 lowpass plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1173 low =
s->plane[plane].l_h[7];
1174 high =
s->plane[plane].subband[5];
1175 output =
s->plane[plane].l_h[3];
1176 dsp->
vert_filter(
output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1178 low =
s->plane[plane].subband[4];
1179 high =
s->plane[plane].subband[6];
1180 output =
s->plane[plane].l_h[4];
1181 dsp->
vert_filter(
output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1183 low =
s->plane[plane].l_h[3];
1184 high =
s->plane[plane].l_h[4];
1185 output =
s->plane[plane].l_h[7];
1186 dsp->
horiz_filter(
output, output_stride, low, output_stride,
high, output_stride, lowpass_width, lowpass_height * 2);
1188 output =
s->plane[plane].l_h[7];
1189 for (
int i = 0;
i < lowpass_height * 2;
i++) {
1190 for (
int j = 0; j < lowpass_width * 2; j++)
1192 output += output_stride * 2;
1195 low =
s->plane[plane].subband[7];
1196 high =
s->plane[plane].subband[9];
1197 output =
s->plane[plane].l_h[3];
1198 dsp->
vert_filter(
output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1200 low =
s->plane[plane].subband[8];
1201 high =
s->plane[plane].subband[10];
1202 output =
s->plane[plane].l_h[4];
1203 dsp->
vert_filter(
output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1205 low =
s->plane[plane].l_h[3];
1206 high =
s->plane[plane].l_h[4];
1207 output =
s->plane[plane].l_h[9];
1208 dsp->
horiz_filter(
output, output_stride, low, output_stride,
high, output_stride, lowpass_width, lowpass_height * 2);
1210 lowpass_height =
s->plane[plane].band[4][1].height;
1211 output_stride =
s->plane[plane].band[4][1].a_width;
1212 lowpass_width =
s->plane[plane].band[4][1].width;
1213 highpass_stride =
s->plane[plane].band[4][1].stride;
1214 av_log(avctx,
AV_LOG_DEBUG,
"temporal level %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1216 if (lowpass_height >
s->plane[plane].band[4][1].a_height || lowpass_width >
s->plane[plane].band[4][1].a_width ||
1217 !highpass_stride ||
s->plane[plane].band[4][1].width >
s->plane[plane].band[4][1].a_width ||
1218 lowpass_width < 3 || lowpass_height < 3) {
1224 low =
s->plane[plane].l_h[7];
1225 high =
s->plane[plane].l_h[9];
1226 output =
s->plane[plane].l_h[7];
1227 for (
int i = 0;
i < lowpass_height;
i++) {
1229 low += output_stride;
1230 high += output_stride;
1232 if (
s->progressive) {
1233 low =
s->plane[plane].l_h[7];
1234 high =
s->plane[plane].subband[15];
1235 output =
s->plane[plane].l_h[6];
1236 dsp->
vert_filter(
output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1238 low =
s->plane[plane].subband[14];
1239 high =
s->plane[plane].subband[16];
1240 output =
s->plane[plane].l_h[7];
1241 dsp->
vert_filter(
output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1243 low =
s->plane[plane].l_h[9];
1244 high =
s->plane[plane].subband[12];
1245 output =
s->plane[plane].l_h[8];
1246 dsp->
vert_filter(
output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1248 low =
s->plane[plane].subband[11];
1249 high =
s->plane[plane].subband[13];
1250 output =
s->plane[plane].l_h[9];
1251 dsp->
vert_filter(
output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1253 if (
s->sample_type == 1)
1256 dst = (int16_t *)pic->
data[act_plane];
1272 low =
s->plane[plane].l_h[6];
1273 high =
s->plane[plane].l_h[7];
1274 for (
int i = 0;
i <
s->plane[act_plane].height;
i++) {
1276 low += output_stride;
1277 high += output_stride;
1278 dst += dst_linesize;
1282 low =
s->plane[plane].l_h[7];
1283 high =
s->plane[plane].subband[14];
1284 output =
s->plane[plane].l_h[6];
1285 dsp->
horiz_filter(
output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1287 low =
s->plane[plane].subband[15];
1288 high =
s->plane[plane].subband[16];
1289 output =
s->plane[plane].l_h[7];
1290 dsp->
horiz_filter(
output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1292 low =
s->plane[plane].l_h[9];
1293 high =
s->plane[plane].subband[11];
1294 output =
s->plane[plane].l_h[8];
1295 dsp->
horiz_filter(
output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1297 low =
s->plane[plane].subband[12];
1298 high =
s->plane[plane].subband[13];
1299 output =
s->plane[plane].l_h[9];
1300 dsp->
horiz_filter(
output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1302 if (
s->sample_type == 1)
1305 dst = (int16_t *)pic->
data[act_plane];
1306 low =
s->plane[plane].l_h[6];
1307 high =
s->plane[plane].l_h[7];
1308 for (
int i = 0;
i <
s->plane[act_plane].height / 2;
i++) {
1310 low += output_stride * 2;
1311 high += output_stride * 2;
1318 if (
s->transform_type == 2 &&
s->sample_type == 1) {
1320 int output_stride, lowpass_height, lowpass_width;
1321 ptrdiff_t dst_linesize;
1323 for (
int plane = 0; plane <
s->planes; plane++) {
1324 int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane;
1328 dst_linesize = pic->
linesize[act_plane];
1330 dst_linesize = pic->
linesize[act_plane] / 2;
1333 lowpass_height =
s->plane[plane].band[4][1].height;
1334 output_stride =
s->plane[plane].band[4][1].a_width;
1335 lowpass_width =
s->plane[plane].band[4][1].width;
1337 if (lowpass_height >
s->plane[plane].band[4][1].a_height || lowpass_width >
s->plane[plane].band[4][1].a_width ||
1338 s->plane[plane].band[4][1].width >
s->plane[plane].band[4][1].a_width ||
1339 lowpass_width < 3 || lowpass_height < 3) {
1345 if (
s->progressive) {
1346 dst = (int16_t *)pic->
data[act_plane];
1347 low =
s->plane[plane].l_h[8];
1348 high =
s->plane[plane].l_h[9];
1365 for (
int i = 0;
i <
s->plane[act_plane].height;
i++) {
1367 low += output_stride;
1368 high += output_stride;
1369 dst += dst_linesize;
1372 dst = (int16_t *)pic->
data[act_plane];
1373 low =
s->plane[plane].l_h[8];
1374 high =
s->plane[plane].l_h[9];
1375 for (
int i = 0;
i <
s->plane[act_plane].height / 2;
i++) {
1377 low += output_stride * 2;
1378 high += output_stride * 2;
1439 for (
int plane = 0; plane < pdst->
planes; plane++) {