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;
123 for (j = 1; j <
width; j++) {
124 band[j] += band[j-1];
133 for (
i = 0;
i < length;
i++)
135 band[
i] = bytestream2_get_le16(&peak->
base);
154 const int linesize =
frame->linesize[0];
155 uint16_t *
r = (uint16_t *)
frame->data[0];
156 uint16_t *g1 = (uint16_t *)(
frame->data[0] + 2);
157 uint16_t *g2 = (uint16_t *)(
frame->data[0] +
frame->linesize[0]);
158 uint16_t *
b = (uint16_t *)(
frame->data[0] +
frame->linesize[0] + 2);
159 const int mid = 1 << (bpc - 1);
160 const int factor = 1 << (16 - bpc);
162 for (
int y = 0; y <
frame->height >> 1; y++) {
163 for (
int x = 0; x <
frame->width; x += 2) {
173 R = (rg - mid) * 2 +
g;
176 B = (bg - mid) * 2 +
g;
197 int width,
int linesize,
int plane)
203 odd = (low[
i] +
high[
i])/2;
213 int odd = (low[
i] +
high[
i]) / 2;
228 s->plane[
i].idwt_size = 0;
231 s->plane[
i].subband[j] =
NULL;
233 for (j = 0; j < 10; j++)
234 s->plane[
i].l_h[j] =
NULL;
244 s->a_transform_type = INT_MIN;
251 int chroma_x_shift, chroma_y_shift;
262 &chroma_y_shift)) < 0)
273 int w8, h8, w4, h4, w2, h2;
274 int width = (
i || bayer) ?
s->coded_width >> chroma_x_shift :
s->coded_width;
275 int height = (
i || bayer) ?
s->coded_height >> chroma_y_shift :
s->coded_height;
278 if (chroma_y_shift && !bayer)
284 w8 =
FFALIGN(
s->plane[
i].width / 8, 8) + 64;
291 if (
s->transform_type == 0) {
293 s->plane[
i].idwt_buf =
294 av_calloc(
s->plane[
i].idwt_size,
sizeof(*
s->plane[
i].idwt_buf));
295 s->plane[
i].idwt_tmp =
299 s->plane[
i].idwt_buf =
300 av_calloc(
s->plane[
i].idwt_size,
sizeof(*
s->plane[
i].idwt_buf));
301 s->plane[
i].idwt_tmp =
305 if (!
s->plane[
i].idwt_buf || !
s->plane[
i].idwt_tmp)
308 s->plane[
i].subband[0] =
s->plane[
i].idwt_buf;
309 s->plane[
i].subband[1] =
s->plane[
i].idwt_buf + 2 * w8 * h8;
310 s->plane[
i].subband[2] =
s->plane[
i].idwt_buf + 1 * w8 * h8;
311 s->plane[
i].subband[3] =
s->plane[
i].idwt_buf + 3 * w8 * h8;
312 s->plane[
i].subband[4] =
s->plane[
i].idwt_buf + 2 * w4 * h4;
313 s->plane[
i].subband[5] =
s->plane[
i].idwt_buf + 1 * w4 * h4;
314 s->plane[
i].subband[6] =
s->plane[
i].idwt_buf + 3 * w4 * h4;
315 if (
s->transform_type == 0) {
316 s->plane[
i].subband[7] =
s->plane[
i].idwt_buf + 2 * w2 * h2;
317 s->plane[
i].subband[8] =
s->plane[
i].idwt_buf + 1 * w2 * h2;
318 s->plane[
i].subband[9] =
s->plane[
i].idwt_buf + 3 * w2 * h2;
321 s->plane[
i].subband[7] =
s->plane[
i].idwt_buf + 4 * w2 * h2;
322 s->plane[
i].subband[8] = frame2 + 2 * w4 * h4;
323 s->plane[
i].subband[9] = frame2 + 1 * w4 * h4;
324 s->plane[
i].subband[10] = frame2 + 3 * w4 * h4;
325 s->plane[
i].subband[11] = frame2 + 2 * w2 * h2;
326 s->plane[
i].subband[12] = frame2 + 1 * w2 * h2;
327 s->plane[
i].subband[13] = frame2 + 3 * w2 * h2;
328 s->plane[
i].subband[14] =
s->plane[
i].idwt_buf + 2 * w2 * h2;
329 s->plane[
i].subband[15] =
s->plane[
i].idwt_buf + 1 * w2 * h2;
330 s->plane[
i].subband[16] =
s->plane[
i].idwt_buf + 3 * w2 * h2;
333 if (
s->transform_type == 0) {
336 s->plane[
i].band[j][k].a_width = w8 << j;
337 s->plane[
i].band[j][k].a_height = h8 << j;
342 int t = j < 1 ? 0 : (j < 3 ? 1 : 2);
345 s->plane[
i].band[j][k].a_width = w8 << t;
346 s->plane[
i].band[j][k].a_height = h8 << t;
352 s->plane[
i].l_h[0] =
s->plane[
i].idwt_tmp;
353 s->plane[
i].l_h[1] =
s->plane[
i].idwt_tmp + 2 * w8 * h8;
355 s->plane[
i].l_h[3] =
s->plane[
i].idwt_tmp;
356 s->plane[
i].l_h[4] =
s->plane[
i].idwt_tmp + 2 * w4 * h4;
358 s->plane[
i].l_h[6] =
s->plane[
i].idwt_tmp;
359 s->plane[
i].l_h[7] =
s->plane[
i].idwt_tmp + 2 * w2 * h2;
360 if (
s->transform_type != 0) {
361 int16_t *frame2 =
s->plane[
i].idwt_tmp + 4 * w2 * h2;
363 s->plane[
i].l_h[8] = frame2;
364 s->plane[
i].l_h[9] = frame2 + 2 * w2 * h2;
368 s->a_transform_type =
s->transform_type;
369 s->a_height =
s->coded_height;
370 s->a_width =
s->coded_width;
371 s->a_format =
s->coded_format;
382 int ret = 0,
i, j, plane, got_buffer = 0;
392 uint16_t tagu = bytestream2_get_be16(&gb);
393 int16_t
tag = (int16_t)tagu;
394 int8_t tag8 = (int8_t)(tagu >> 8);
395 uint16_t abstag =
abs(
tag);
396 int8_t abs_tag8 =
abs(tag8);
397 uint16_t
data = bytestream2_get_be16(&gb);
398 if (abs_tag8 >= 0x60 && abs_tag8 <= 0x6f) {
402 s->progressive =
data & 0x0001;
404 s->frame_type =
data;
414 }
else if (abstag ==
Version) {
418 s->coded_width =
data;
421 s->coded_height =
data;
424 s->channel_cnt =
data;
438 s->channel_num =
data;
440 if (
s->channel_num >=
s->planes) {
447 if (
s->subband_num != 0 &&
data == 1 && (
s->transform_type == 0 ||
s->transform_type == 2))
450 s->subband_num =
data;
451 if ((
s->transform_type == 0 &&
s->level >=
DWT_LEVELS) ||
457 if (
s->subband_num > 3) {
470 if (
s->transform_type == 0 ||
s->transform_type == 2)
471 s->subband_num_actual =
data;
477 s->quantisation =
data;
480 for (
i = 0;
i < 8;
i++)
481 s->prescale_table[
i] = (
data >> (14 -
i * 2)) & 0x3;
489 s->band_encoding =
data;
493 s->plane[
s->channel_num].band[0][0].width =
data;
494 s->plane[
s->channel_num].band[0][0].stride =
data;
497 s->plane[
s->channel_num].band[0][0].height =
data;
499 s->sample_type =
data;
506 }
else if (
data == 1) {
511 if (
s->transform_type == -1) {
512 s->transform_type =
data;
517 }
else if (abstag >= 0x4000 && abstag <= 0x40ff) {
518 if (abstag == 0x4001)
524 s->frame_index =
data;
533 uint32_t
offset = bytestream2_get_be32(&gb);
537 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);
543 s->plane[
s->channel_num].band[
s->level][
s->subband_num].width =
data;
544 s->plane[
s->channel_num].band[
s->level][
s->subband_num].stride =
FFALIGN(
data, 8);
552 s->plane[
s->channel_num].band[
s->level][
s->subband_num].height =
data;
560 s->plane[
s->channel_num].band[
s->level][
s->subband_num].width =
data;
561 s->plane[
s->channel_num].band[
s->level][
s->subband_num].stride =
FFALIGN(
data, 8);
569 s->plane[
s->channel_num].band[
s->level][
s->subband_num].height =
data;
576 }
else if (
data >= 122 &&
data <= 128) {
578 }
else if (
data == 30) {
586 s->codebook =
data & 0xf;
587 s->difference_coding = (
data >> 4) & 1;
601 }
else if (
data == 2) {
603 }
else if (
data == 3) {
605 }
else if (
data == 4) {
615 s->cropped_height =
data;
617 s->peak.offset &= ~0xffff;
618 s->peak.offset |= (
data & 0xffff);
622 s->peak.offset &= 0xffff;
623 s->peak.offset |= (
data & 0xffff
U)<<16;
627 s->peak.level =
data;
640 int lowpass_height =
s->plane[
s->channel_num].band[0][0].height;
641 int lowpass_width =
s->plane[
s->channel_num].band[0][0].width;
644 if (
s->coded_width) {
648 if (
s->coded_height) {
652 if (!
s->a_width && !
s->coded_width) {
653 s->coded_width = lowpass_width *
factor * 8;
656 if (!
s->a_height && !
s->coded_height) {
657 s->coded_height = lowpass_height *
factor * 8;
660 if (
s->a_width && !
s->coded_width)
661 s->coded_width =
s->a_width;
662 if (
s->a_height && !
s->coded_height)
663 s->coded_height =
s->a_height;
665 if (
s->a_width !=
s->coded_width ||
s->a_height !=
s->coded_height ||
666 s->a_format !=
s->coded_format ||
667 s->transform_type !=
s->a_transform_type) {
677 if (
s->cropped_height) {
703 if (
s->subband_num_actual == 255)
705 coeff_data =
s->plane[
s->channel_num].subband[
s->subband_num_actual];
709 int lowpass_height, lowpass_width, lowpass_a_height, lowpass_a_width;
711 if (!
s->a_width || !
s->a_height) {
716 lowpass_height =
s->plane[
s->channel_num].band[0][0].height;
717 lowpass_width =
s->plane[
s->channel_num].band[0][0].width;
718 lowpass_a_height =
s->plane[
s->channel_num].band[0][0].a_height;
719 lowpass_a_width =
s->plane[
s->channel_num].band[0][0].a_width;
721 if (lowpass_width < 3 ||
722 lowpass_width > lowpass_a_width) {
728 if (lowpass_height < 3 ||
729 lowpass_height > lowpass_a_height) {
741 if (lowpass_height > lowpass_a_height || lowpass_width > lowpass_a_width ||
748 av_log(avctx,
AV_LOG_DEBUG,
"Start of lowpass coeffs component %d height:%d, width:%d\n",
s->channel_num, lowpass_height, lowpass_width);
749 for (
i = 0;
i < lowpass_height;
i++) {
750 for (j = 0; j < lowpass_width; j++)
751 coeff_data[j] = bytestream2_get_be16u(&gb);
753 coeff_data += lowpass_width;
760 if (lowpass_height & 1) {
761 memcpy(&coeff_data[lowpass_height * lowpass_width],
762 &coeff_data[(lowpass_height - 1) * lowpass_width],
763 lowpass_width *
sizeof(*coeff_data));
766 s->plane[
s->channel_num].band[0][0].read_ok = 1;
768 av_log(avctx,
AV_LOG_DEBUG,
"Lowpass coefficients %d\n", lowpass_width * lowpass_height);
773 int highpass_height, highpass_width, highpass_a_width, highpass_a_height, highpass_stride, a_expected;
776 int count = 0, bytes;
778 if (!
s->a_width || !
s->a_height) {
783 highpass_height =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].height;
784 highpass_width =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].width;
785 highpass_a_width =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].a_width;
786 highpass_a_height =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].a_height;
787 highpass_stride =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].stride;
788 a_expected = highpass_a_height * highpass_a_width;
796 if (highpass_height > highpass_a_height || highpass_width > highpass_a_width || a_expected < highpass_height * (uint64_t)highpass_stride) {
801 expected = highpass_height * highpass_stride;
803 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);
811 const int lossless =
s->band_encoding == 5;
813 if (
s->codebook == 0 &&
s->transform_type == 2 &&
s->subband_num_actual == 7)
827 if (count > expected)
835 const uint16_t q =
s->quantisation;
837 for (
i = 0;
i <
run;
i++) {
838 *coeff_data |=
coeff * 256
U;
843 *coeff_data++ =
coeff;
858 if (count > expected)
866 const uint16_t q =
s->quantisation;
868 for (
i = 0;
i <
run;
i++) {
869 *coeff_data |=
coeff * 256
U;
874 *coeff_data++ =
coeff;
881 if (count > expected) {
888 if (
s->difference_coding)
889 difference_coding(
s->plane[
s->channel_num].subband[
s->subband_num_actual], highpass_width, highpass_height);
899 av_log(avctx,
AV_LOG_DEBUG,
"End subband coeffs %i extra %i\n", count, count - expected);
900 s->plane[
s->channel_num].band[
s->level][
s->subband_num].read_ok = 1;
902 if (
s->subband_num_actual != 255)
916 s->a_transform_type == INT_MIN ||
929 for (plane = 0; plane <
s->planes; plane++) {
933 if (
s->transform_type == 2)
936 for (o = !!
level; o < 4 ; o++) {
937 if (!
s->plane[plane].band[
level][o].read_ok) {
945 if (
s->transform_type == 0 &&
s->sample_type != 1) {
946 for (plane = 0; plane <
s->planes && !
ret; plane++) {
948 int lowpass_height =
s->plane[plane].band[0][0].height;
949 int output_stride =
s->plane[plane].band[0][0].a_width;
950 int lowpass_width =
s->plane[plane].band[0][0].width;
951 int highpass_stride =
s->plane[plane].band[0][1].stride;
952 int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane;
953 ptrdiff_t dst_linesize;
958 dst_linesize = pic->
linesize[act_plane];
960 dst_linesize = pic->
linesize[act_plane] / 2;
963 if (lowpass_height >
s->plane[plane].band[0][0].a_height || lowpass_width >
s->plane[plane].band[0][0].a_width ||
964 !highpass_stride ||
s->plane[plane].band[0][1].width >
s->plane[plane].band[0][1].a_width ||
965 lowpass_width < 3 || lowpass_height < 3) {
971 av_log(avctx,
AV_LOG_DEBUG,
"Decoding level 1 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
973 low =
s->plane[plane].subband[0];
974 high =
s->plane[plane].subband[2];
975 output =
s->plane[plane].l_h[0];
976 dsp->
vert_filter(
output, output_stride, low, lowpass_width,
high, highpass_stride, lowpass_width, lowpass_height);
978 low =
s->plane[plane].subband[1];
979 high =
s->plane[plane].subband[3];
980 output =
s->plane[plane].l_h[1];
982 dsp->
vert_filter(
output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
984 low =
s->plane[plane].l_h[0];
985 high =
s->plane[plane].l_h[1];
986 output =
s->plane[plane].subband[0];
987 dsp->
horiz_filter(
output, output_stride, low, output_stride,
high, output_stride, lowpass_width, lowpass_height * 2);
989 output =
s->plane[plane].subband[0];
990 for (
i = 0;
i < lowpass_height * 2;
i++) {
991 for (j = 0; j < lowpass_width * 2; j++)
994 output += output_stride * 2;
999 lowpass_height =
s->plane[plane].band[1][1].height;
1000 output_stride =
s->plane[plane].band[1][1].a_width;
1001 lowpass_width =
s->plane[plane].band[1][1].width;
1002 highpass_stride =
s->plane[plane].band[1][1].stride;
1004 if (lowpass_height >
s->plane[plane].band[1][1].a_height || lowpass_width >
s->plane[plane].band[1][1].a_width ||
1005 !highpass_stride ||
s->plane[plane].band[1][1].width >
s->plane[plane].band[1][1].a_width ||
1006 lowpass_width < 3 || lowpass_height < 3) {
1012 av_log(avctx,
AV_LOG_DEBUG,
"Level 2 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1014 low =
s->plane[plane].subband[0];
1015 high =
s->plane[plane].subband[5];
1016 output =
s->plane[plane].l_h[3];
1017 dsp->
vert_filter(
output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1019 low =
s->plane[plane].subband[4];
1020 high =
s->plane[plane].subband[6];
1021 output =
s->plane[plane].l_h[4];
1022 dsp->
vert_filter(
output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1024 low =
s->plane[plane].l_h[3];
1025 high =
s->plane[plane].l_h[4];
1026 output =
s->plane[plane].subband[0];
1027 dsp->
horiz_filter(
output, output_stride, low, output_stride,
high, output_stride, lowpass_width, lowpass_height * 2);
1029 output =
s->plane[plane].subband[0];
1030 for (
i = 0;
i < lowpass_height * 2;
i++) {
1031 for (j = 0; j < lowpass_width * 2; j++)
1034 output += output_stride * 2;
1038 lowpass_height =
s->plane[plane].band[2][1].height;
1039 output_stride =
s->plane[plane].band[2][1].a_width;
1040 lowpass_width =
s->plane[plane].band[2][1].width;
1041 highpass_stride =
s->plane[plane].band[2][1].stride;
1043 if (lowpass_height >
s->plane[plane].band[2][1].a_height || lowpass_width >
s->plane[plane].band[2][1].a_width ||
1044 !highpass_stride ||
s->plane[plane].band[2][1].width >
s->plane[plane].band[2][1].a_width ||
1045 lowpass_height < 3 || lowpass_width < 3 || lowpass_width * 2 >
s->plane[plane].width) {
1051 av_log(avctx,
AV_LOG_DEBUG,
"Level 3 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1052 if (
s->progressive) {
1053 low =
s->plane[plane].subband[0];
1054 high =
s->plane[plane].subband[8];
1055 output =
s->plane[plane].l_h[6];
1056 dsp->
vert_filter(
output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1058 low =
s->plane[plane].subband[7];
1059 high =
s->plane[plane].subband[9];
1060 output =
s->plane[plane].l_h[7];
1061 dsp->
vert_filter(
output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1063 dst = (int16_t *)pic->
data[act_plane];
1070 low =
s->plane[plane].l_h[6];
1071 high =
s->plane[plane].l_h[7];
1081 for (
i = 0;
i <
s->plane[act_plane].height;
i++) {
1085 low += output_stride;
1086 high += output_stride;
1087 dst += dst_linesize;
1092 low =
s->plane[plane].subband[0];
1093 high =
s->plane[plane].subband[7];
1094 output =
s->plane[plane].l_h[6];
1095 dsp->
horiz_filter(
output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1097 low =
s->plane[plane].subband[8];
1098 high =
s->plane[plane].subband[9];
1099 output =
s->plane[plane].l_h[7];
1100 dsp->
horiz_filter(
output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1102 dst = (int16_t *)pic->
data[act_plane];
1103 low =
s->plane[plane].l_h[6];
1104 high =
s->plane[plane].l_h[7];
1105 for (
i = 0;
i <
s->plane[act_plane].height / 2;
i++) {
1107 low += output_stride * 2;
1108 high += output_stride * 2;
1113 }
else if (
s->transform_type == 2 && (avctx->
internal->
is_copy ||
s->frame_index == 1 ||
s->sample_type != 1)) {
1114 for (plane = 0; plane <
s->planes && !
ret; plane++) {
1115 int lowpass_height =
s->plane[plane].band[0][0].height;
1116 int output_stride =
s->plane[plane].band[0][0].a_width;
1117 int lowpass_width =
s->plane[plane].band[0][0].width;
1118 int highpass_stride =
s->plane[plane].band[0][1].stride;
1119 int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane;
1121 ptrdiff_t dst_linesize;
1125 dst_linesize = pic->
linesize[act_plane];
1127 dst_linesize = pic->
linesize[act_plane] / 2;
1130 if (lowpass_height >
s->plane[plane].band[0][0].a_height || lowpass_width >
s->plane[plane].band[0][0].a_width ||
1131 !highpass_stride ||
s->plane[plane].band[0][1].width >
s->plane[plane].band[0][1].a_width ||
1132 lowpass_width < 3 || lowpass_height < 3) {
1138 av_log(avctx,
AV_LOG_DEBUG,
"Decoding level 1 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1140 low =
s->plane[plane].subband[0];
1141 high =
s->plane[plane].subband[2];
1142 output =
s->plane[plane].l_h[0];
1143 dsp->
vert_filter(
output, output_stride, low, lowpass_width,
high, highpass_stride, lowpass_width, lowpass_height);
1145 low =
s->plane[plane].subband[1];
1146 high =
s->plane[plane].subband[3];
1147 output =
s->plane[plane].l_h[1];
1148 dsp->
vert_filter(
output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1150 low =
s->plane[plane].l_h[0];
1151 high =
s->plane[plane].l_h[1];
1152 output =
s->plane[plane].l_h[7];
1153 dsp->
horiz_filter(
output, output_stride, low, output_stride,
high, output_stride, lowpass_width, lowpass_height * 2);
1155 output =
s->plane[plane].l_h[7];
1156 for (
i = 0;
i < lowpass_height * 2;
i++) {
1157 for (j = 0; j < lowpass_width * 2; j++)
1160 output += output_stride * 2;
1164 lowpass_height =
s->plane[plane].band[1][1].height;
1165 output_stride =
s->plane[plane].band[1][1].a_width;
1166 lowpass_width =
s->plane[plane].band[1][1].width;
1167 highpass_stride =
s->plane[plane].band[1][1].stride;
1169 if (lowpass_height >
s->plane[plane].band[1][1].a_height || lowpass_width >
s->plane[plane].band[1][1].a_width ||
1170 !highpass_stride ||
s->plane[plane].band[1][1].width >
s->plane[plane].band[1][1].a_width ||
1171 lowpass_width < 3 || lowpass_height < 3) {
1177 av_log(avctx,
AV_LOG_DEBUG,
"Level 2 lowpass plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1179 low =
s->plane[plane].l_h[7];
1180 high =
s->plane[plane].subband[5];
1181 output =
s->plane[plane].l_h[3];
1182 dsp->
vert_filter(
output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1184 low =
s->plane[plane].subband[4];
1185 high =
s->plane[plane].subband[6];
1186 output =
s->plane[plane].l_h[4];
1187 dsp->
vert_filter(
output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1189 low =
s->plane[plane].l_h[3];
1190 high =
s->plane[plane].l_h[4];
1191 output =
s->plane[plane].l_h[7];
1192 dsp->
horiz_filter(
output, output_stride, low, output_stride,
high, output_stride, lowpass_width, lowpass_height * 2);
1194 output =
s->plane[plane].l_h[7];
1195 for (
i = 0;
i < lowpass_height * 2;
i++) {
1196 for (j = 0; j < lowpass_width * 2; j++)
1198 output += output_stride * 2;
1201 low =
s->plane[plane].subband[7];
1202 high =
s->plane[plane].subband[9];
1203 output =
s->plane[plane].l_h[3];
1204 dsp->
vert_filter(
output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1206 low =
s->plane[plane].subband[8];
1207 high =
s->plane[plane].subband[10];
1208 output =
s->plane[plane].l_h[4];
1209 dsp->
vert_filter(
output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1211 low =
s->plane[plane].l_h[3];
1212 high =
s->plane[plane].l_h[4];
1213 output =
s->plane[plane].l_h[9];
1214 dsp->
horiz_filter(
output, output_stride, low, output_stride,
high, output_stride, lowpass_width, lowpass_height * 2);
1216 lowpass_height =
s->plane[plane].band[4][1].height;
1217 output_stride =
s->plane[plane].band[4][1].a_width;
1218 lowpass_width =
s->plane[plane].band[4][1].width;
1219 highpass_stride =
s->plane[plane].band[4][1].stride;
1220 av_log(avctx,
AV_LOG_DEBUG,
"temporal level %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1222 if (lowpass_height >
s->plane[plane].band[4][1].a_height || lowpass_width >
s->plane[plane].band[4][1].a_width ||
1223 !highpass_stride ||
s->plane[plane].band[4][1].width >
s->plane[plane].band[4][1].a_width ||
1224 lowpass_width < 3 || lowpass_height < 3) {
1230 low =
s->plane[plane].l_h[7];
1231 high =
s->plane[plane].l_h[9];
1232 output =
s->plane[plane].l_h[7];
1233 for (
i = 0;
i < lowpass_height;
i++) {
1235 low += output_stride;
1236 high += output_stride;
1238 if (
s->progressive) {
1239 low =
s->plane[plane].l_h[7];
1240 high =
s->plane[plane].subband[15];
1241 output =
s->plane[plane].l_h[6];
1242 dsp->
vert_filter(
output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1244 low =
s->plane[plane].subband[14];
1245 high =
s->plane[plane].subband[16];
1246 output =
s->plane[plane].l_h[7];
1247 dsp->
vert_filter(
output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1249 low =
s->plane[plane].l_h[9];
1250 high =
s->plane[plane].subband[12];
1251 output =
s->plane[plane].l_h[8];
1252 dsp->
vert_filter(
output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1254 low =
s->plane[plane].subband[11];
1255 high =
s->plane[plane].subband[13];
1256 output =
s->plane[plane].l_h[9];
1257 dsp->
vert_filter(
output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1259 if (
s->sample_type == 1)
1262 dst = (int16_t *)pic->
data[act_plane];
1278 low =
s->plane[plane].l_h[6];
1279 high =
s->plane[plane].l_h[7];
1280 for (
i = 0;
i <
s->plane[act_plane].height;
i++) {
1282 low += output_stride;
1283 high += output_stride;
1284 dst += dst_linesize;
1288 low =
s->plane[plane].l_h[7];
1289 high =
s->plane[plane].subband[14];
1290 output =
s->plane[plane].l_h[6];
1291 dsp->
horiz_filter(
output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1293 low =
s->plane[plane].subband[15];
1294 high =
s->plane[plane].subband[16];
1295 output =
s->plane[plane].l_h[7];
1296 dsp->
horiz_filter(
output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1298 low =
s->plane[plane].l_h[9];
1299 high =
s->plane[plane].subband[11];
1300 output =
s->plane[plane].l_h[8];
1301 dsp->
horiz_filter(
output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1303 low =
s->plane[plane].subband[12];
1304 high =
s->plane[plane].subband[13];
1305 output =
s->plane[plane].l_h[9];
1306 dsp->
horiz_filter(
output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1308 if (
s->sample_type == 1)
1311 dst = (int16_t *)pic->
data[act_plane];
1312 low =
s->plane[plane].l_h[6];
1313 high =
s->plane[plane].l_h[7];
1314 for (
i = 0;
i <
s->plane[act_plane].height / 2;
i++) {
1316 low += output_stride * 2;
1317 high += output_stride * 2;
1324 if (
s->transform_type == 2 &&
s->sample_type == 1) {
1326 int output_stride, lowpass_height, lowpass_width;
1327 ptrdiff_t dst_linesize;
1329 for (plane = 0; plane <
s->planes; plane++) {
1330 int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane;
1334 dst_linesize = pic->
linesize[act_plane];
1336 dst_linesize = pic->
linesize[act_plane] / 2;
1339 lowpass_height =
s->plane[plane].band[4][1].height;
1340 output_stride =
s->plane[plane].band[4][1].a_width;
1341 lowpass_width =
s->plane[plane].band[4][1].width;
1343 if (lowpass_height >
s->plane[plane].band[4][1].a_height || lowpass_width >
s->plane[plane].band[4][1].a_width ||
1344 s->plane[plane].band[4][1].width >
s->plane[plane].band[4][1].a_width ||
1345 lowpass_width < 3 || lowpass_height < 3) {
1351 if (
s->progressive) {
1352 dst = (int16_t *)pic->
data[act_plane];
1353 low =
s->plane[plane].l_h[8];
1354 high =
s->plane[plane].l_h[9];
1371 for (
i = 0;
i <
s->plane[act_plane].height;
i++) {
1373 low += output_stride;
1374 high += output_stride;
1375 dst += dst_linesize;
1378 dst = (int16_t *)pic->
data[act_plane];
1379 low =
s->plane[plane].l_h[8];
1380 high =
s->plane[plane].l_h[9];
1381 for (
i = 0;
i <
s->plane[act_plane].height / 2;
i++) {
1383 low += output_stride * 2;
1384 high += output_stride * 2;
1445 for (
int plane = 0; plane < pdst->
planes; plane++) {