378 int ret = 0, got_buffer = 0;
387 uint16_t tagu = bytestream2_get_be16(&gb);
388 int16_t
tag = (int16_t)tagu;
389 int8_t tag8 = (int8_t)(tagu >> 8);
390 uint16_t abstag =
abs(
tag);
391 int8_t abs_tag8 =
abs(tag8);
392 uint16_t
data = bytestream2_get_be16(&gb);
395 if (abs_tag8 >= 0x60 && abs_tag8 <= 0x6f) {
399 s->progressive =
data & 0x0001;
401 s->frame_type =
data;
411 }
else if (abstag ==
Version) {
415 s->coded_width =
data;
418 s->coded_height =
data;
421 s->channel_cnt =
data;
435 s->channel_num =
data;
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 & 0xffffU)<<16;
619 s->peak.level =
data;
630 if (
s->channel_num >=
s->planes) {
636 if (got_buffer && (
s->coded_width ||
s->coded_height ||
s->coded_format !=
AV_PIX_FMT_NONE)) {
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) {
682 if (
s->cropped_height) {
715 if (
s->subband_num_actual == 255)
719 if (
s->transform_type !=
s->a_transform_type)
722 coeff_data =
s->plane[
s->channel_num].subband[
s->subband_num_actual];
726 int lowpass_height, lowpass_width, lowpass_a_height, lowpass_a_width;
728 if (!
s->a_width || !
s->a_height) {
733 lowpass_height =
s->plane[
s->channel_num].band[0][0].height;
734 lowpass_width =
s->plane[
s->channel_num].band[0][0].width;
735 lowpass_a_height =
s->plane[
s->channel_num].band[0][0].a_height;
736 lowpass_a_width =
s->plane[
s->channel_num].band[0][0].a_width;
738 if (lowpass_width < 3 ||
739 lowpass_width > lowpass_a_width) {
745 if (lowpass_height < 3 ||
746 lowpass_height > lowpass_a_height) {
758 if (lowpass_height > lowpass_a_height || lowpass_width > lowpass_a_width ||
765 av_log(avctx,
AV_LOG_DEBUG,
"Start of lowpass coeffs component %d height:%d, width:%d\n",
s->channel_num, lowpass_height, lowpass_width);
766 for (
int i = 0;
i < lowpass_height;
i++) {
767 for (
int j = 0; j < lowpass_width; j++)
768 coeff_data[j] = bytestream2_get_be16u(&gb);
770 coeff_data += lowpass_width;
777 if (lowpass_height & 1) {
778 memcpy(&coeff_data[lowpass_height * lowpass_width],
779 &coeff_data[(lowpass_height - 1) * lowpass_width],
780 lowpass_width *
sizeof(*coeff_data));
783 s->plane[
s->channel_num].band[0][0].read_ok = 1;
785 av_log(avctx,
AV_LOG_DEBUG,
"Lowpass coefficients %d\n", lowpass_width * lowpass_height);
790 int highpass_height, highpass_width, highpass_a_width, highpass_a_height, highpass_stride, a_expected;
793 int count = 0, bytes;
795 if (!
s->a_width || !
s->a_height) {
800 highpass_height =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].height;
801 highpass_width =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].width;
802 highpass_a_width =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].a_width;
803 highpass_a_height =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].a_height;
804 highpass_stride =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].stride;
805 a_expected = highpass_a_height * highpass_a_width;
813 if (highpass_height > highpass_a_height || highpass_width > highpass_a_width || a_expected < highpass_height * (uint64_t)highpass_stride) {
818 expected = highpass_height * highpass_stride;
820 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);
828 const int lossless =
s->band_encoding == 5;
830 if (
s->codebook == 0 &&
s->transform_type == 2 &&
s->subband_num_actual == 7)
846 if (count > expected)
854 const uint16_t q =
s->quantisation;
856 for (
int i = 0;
i <
run;
i++) {
857 *coeff_data |= coeff * 256U;
861 for (
int i = 0;
i <
run;
i++)
862 *coeff_data++ = coeff;
879 if (count > expected)
887 const uint16_t q =
s->quantisation;
889 for (
int i = 0;
i <
run;
i++) {
890 *coeff_data |= coeff * 256U;
894 for (
int i = 0;
i <
run;
i++)
895 *coeff_data++ = coeff;
902 if (count > expected) {
909 if (
s->difference_coding)
910 difference_coding(
s->plane[
s->channel_num].subband[
s->subband_num_actual], highpass_width, highpass_height);
920 av_log(avctx,
AV_LOG_DEBUG,
"End subband coeffs %i extra %i\n", count, count - expected);
921 s->plane[
s->channel_num].band[
s->level][
s->subband_num].read_ok = 1;
923 if (
s->subband_num_actual != 255)
937 s->a_transform_type == INT_MIN) {
949 for (
int plane = 0; plane <
s->planes; plane++) {
951 if (
s->transform_type == 2)
954 for (
int o = !!
level; o < 4 ; o++) {
955 if (!
s->plane[plane].band[
level][o].read_ok) {
963 if (
s->transform_type == 0 &&
s->sample_type != 1) {
964 for (
int plane = 0; plane <
s->planes && !
ret; plane++) {
966 int lowpass_height =
s->plane[plane].band[0][0].height;
967 int output_stride =
s->plane[plane].band[0][0].a_width;
968 int lowpass_width =
s->plane[plane].band[0][0].width;
969 int highpass_stride =
s->plane[plane].band[0][1].stride;
970 int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane;
971 ptrdiff_t dst_linesize;
972 int16_t *low, *
high, *output, *
dst;
976 dst_linesize = pic->
linesize[act_plane];
978 dst_linesize = pic->
linesize[act_plane] / 2;
981 if (lowpass_height >
s->plane[plane].band[0][0].a_height || lowpass_width >
s->plane[plane].band[0][0].a_width ||
982 !highpass_stride ||
s->plane[plane].band[0][1].width >
s->plane[plane].band[0][1].a_width ||
983 lowpass_width < 3 || lowpass_height < 3) {
989 av_log(avctx,
AV_LOG_DEBUG,
"Decoding level 1 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
991 low =
s->plane[plane].subband[0];
992 high =
s->plane[plane].subband[2];
993 output =
s->plane[plane].l_h[0];
994 dsp->
vert_filter(output, output_stride, low, lowpass_width,
high, highpass_stride, lowpass_width, lowpass_height);
996 low =
s->plane[plane].subband[1];
997 high =
s->plane[plane].subband[3];
998 output =
s->plane[plane].l_h[1];
1000 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1002 low =
s->plane[plane].l_h[0];
1003 high =
s->plane[plane].l_h[1];
1004 output =
s->plane[plane].subband[0];
1005 dsp->
horiz_filter(output, output_stride, low, output_stride,
high, output_stride, lowpass_width, lowpass_height * 2);
1007 output =
s->plane[plane].subband[0];
1008 for (
int i = 0;
i < lowpass_height * 2;
i++) {
1009 for (
int j = 0; j < lowpass_width * 2; j++)
1012 output += output_stride * 2;
1017 lowpass_height =
s->plane[plane].band[1][1].height;
1018 output_stride =
s->plane[plane].band[1][1].a_width;
1019 lowpass_width =
s->plane[plane].band[1][1].width;
1020 highpass_stride =
s->plane[plane].band[1][1].stride;
1022 if (lowpass_height >
s->plane[plane].band[1][1].a_height || lowpass_width >
s->plane[plane].band[1][1].a_width ||
1023 !highpass_stride ||
s->plane[plane].band[1][1].width >
s->plane[plane].band[1][1].a_width ||
1024 lowpass_width < 3 || lowpass_height < 3) {
1030 av_log(avctx,
AV_LOG_DEBUG,
"Level 2 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1032 low =
s->plane[plane].subband[0];
1033 high =
s->plane[plane].subband[5];
1034 output =
s->plane[plane].l_h[3];
1035 dsp->
vert_filter(output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1037 low =
s->plane[plane].subband[4];
1038 high =
s->plane[plane].subband[6];
1039 output =
s->plane[plane].l_h[4];
1040 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1042 low =
s->plane[plane].l_h[3];
1043 high =
s->plane[plane].l_h[4];
1044 output =
s->plane[plane].subband[0];
1045 dsp->
horiz_filter(output, output_stride, low, output_stride,
high, output_stride, lowpass_width, lowpass_height * 2);
1047 output =
s->plane[plane].subband[0];
1048 for (
int i = 0;
i < lowpass_height * 2;
i++) {
1049 for (
int j = 0; j < lowpass_width * 2; j++)
1052 output += output_stride * 2;
1056 lowpass_height =
s->plane[plane].band[2][1].height;
1057 output_stride =
s->plane[plane].band[2][1].a_width;
1058 lowpass_width =
s->plane[plane].band[2][1].width;
1059 highpass_stride =
s->plane[plane].band[2][1].stride;
1061 if (lowpass_height >
s->plane[plane].band[2][1].a_height || lowpass_width >
s->plane[plane].band[2][1].a_width ||
1062 !highpass_stride ||
s->plane[plane].band[2][1].width >
s->plane[plane].band[2][1].a_width ||
1063 lowpass_height < 3 || lowpass_width < 3 || lowpass_width * 2 >
s->plane[plane].width) {
1069 av_log(avctx,
AV_LOG_DEBUG,
"Level 3 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1070 if (
s->progressive) {
1071 low =
s->plane[plane].subband[0];
1072 high =
s->plane[plane].subband[8];
1073 output =
s->plane[plane].l_h[6];
1074 dsp->
vert_filter(output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1076 low =
s->plane[plane].subband[7];
1077 high =
s->plane[plane].subband[9];
1078 output =
s->plane[plane].l_h[7];
1079 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1081 dst = (int16_t *)pic->
data[act_plane];
1088 low =
s->plane[plane].l_h[6];
1089 high =
s->plane[plane].l_h[7];
1099 for (
int i = 0;
i <
s->plane[act_plane].height;
i++) {
1103 low += output_stride;
1104 high += output_stride;
1105 dst += dst_linesize;
1110 low =
s->plane[plane].subband[0];
1111 high =
s->plane[plane].subband[7];
1112 output =
s->plane[plane].l_h[6];
1113 dsp->
horiz_filter(output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1115 low =
s->plane[plane].subband[8];
1116 high =
s->plane[plane].subband[9];
1117 output =
s->plane[plane].l_h[7];
1118 dsp->
horiz_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1120 dst = (int16_t *)pic->
data[act_plane];
1121 low =
s->plane[plane].l_h[6];
1122 high =
s->plane[plane].l_h[7];
1123 for (
int i = 0;
i <
s->plane[act_plane].height / 2;
i++) {
1125 low += output_stride * 2;
1126 high += output_stride * 2;
1131 }
else if (
s->transform_type == 2 && (avctx->
internal->
is_copy ||
s->frame_index == 1 ||
s->sample_type != 1)) {
1132 for (
int plane = 0; plane <
s->planes && !
ret; plane++) {
1133 int lowpass_height =
s->plane[plane].band[0][0].height;
1134 int output_stride =
s->plane[plane].band[0][0].a_width;
1135 int lowpass_width =
s->plane[plane].band[0][0].width;
1136 int highpass_stride =
s->plane[plane].band[0][1].stride;
1137 int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane;
1138 int16_t *low, *
high, *output, *
dst;
1139 ptrdiff_t dst_linesize;
1143 dst_linesize = pic->
linesize[act_plane];
1145 dst_linesize = pic->
linesize[act_plane] / 2;
1148 if (lowpass_height >
s->plane[plane].band[0][0].a_height || lowpass_width >
s->plane[plane].band[0][0].a_width ||
1149 !highpass_stride ||
s->plane[plane].band[0][1].width >
s->plane[plane].band[0][1].a_width ||
1150 lowpass_width < 3 || lowpass_height < 3) {
1156 av_log(avctx,
AV_LOG_DEBUG,
"Decoding level 1 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1158 low =
s->plane[plane].subband[0];
1159 high =
s->plane[plane].subband[2];
1160 output =
s->plane[plane].l_h[0];
1161 dsp->
vert_filter(output, output_stride, low, lowpass_width,
high, highpass_stride, lowpass_width, lowpass_height);
1163 low =
s->plane[plane].subband[1];
1164 high =
s->plane[plane].subband[3];
1165 output =
s->plane[plane].l_h[1];
1166 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1168 low =
s->plane[plane].l_h[0];
1169 high =
s->plane[plane].l_h[1];
1170 output =
s->plane[plane].l_h[7];
1171 dsp->
horiz_filter(output, output_stride, low, output_stride,
high, output_stride, lowpass_width, lowpass_height * 2);
1173 output =
s->plane[plane].l_h[7];
1174 for (
int i = 0;
i < lowpass_height * 2;
i++) {
1175 for (
int j = 0; j < lowpass_width * 2; j++)
1178 output += output_stride * 2;
1182 lowpass_height =
s->plane[plane].band[1][1].height;
1183 output_stride =
s->plane[plane].band[1][1].a_width;
1184 lowpass_width =
s->plane[plane].band[1][1].width;
1185 highpass_stride =
s->plane[plane].band[1][1].stride;
1187 if (lowpass_height >
s->plane[plane].band[1][1].a_height || lowpass_width >
s->plane[plane].band[1][1].a_width ||
1188 !highpass_stride ||
s->plane[plane].band[1][1].width >
s->plane[plane].band[1][1].a_width ||
1189 lowpass_width < 3 || lowpass_height < 3) {
1195 av_log(avctx,
AV_LOG_DEBUG,
"Level 2 lowpass plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1197 low =
s->plane[plane].l_h[7];
1198 high =
s->plane[plane].subband[5];
1199 output =
s->plane[plane].l_h[3];
1200 dsp->
vert_filter(output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1202 low =
s->plane[plane].subband[4];
1203 high =
s->plane[plane].subband[6];
1204 output =
s->plane[plane].l_h[4];
1205 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1207 low =
s->plane[plane].l_h[3];
1208 high =
s->plane[plane].l_h[4];
1209 output =
s->plane[plane].l_h[7];
1210 dsp->
horiz_filter(output, output_stride, low, output_stride,
high, output_stride, lowpass_width, lowpass_height * 2);
1212 output =
s->plane[plane].l_h[7];
1213 for (
int i = 0;
i < lowpass_height * 2;
i++) {
1214 for (
int j = 0; j < lowpass_width * 2; j++)
1216 output += output_stride * 2;
1219 low =
s->plane[plane].subband[7];
1220 high =
s->plane[plane].subband[9];
1221 output =
s->plane[plane].l_h[3];
1222 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1224 low =
s->plane[plane].subband[8];
1225 high =
s->plane[plane].subband[10];
1226 output =
s->plane[plane].l_h[4];
1227 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1229 low =
s->plane[plane].l_h[3];
1230 high =
s->plane[plane].l_h[4];
1231 output =
s->plane[plane].l_h[9];
1232 dsp->
horiz_filter(output, output_stride, low, output_stride,
high, output_stride, lowpass_width, lowpass_height * 2);
1234 lowpass_height =
s->plane[plane].band[4][1].height;
1235 output_stride =
s->plane[plane].band[4][1].a_width;
1236 lowpass_width =
s->plane[plane].band[4][1].width;
1237 highpass_stride =
s->plane[plane].band[4][1].stride;
1238 av_log(avctx,
AV_LOG_DEBUG,
"temporal level %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1240 if (lowpass_height >
s->plane[plane].band[4][1].a_height || lowpass_width >
s->plane[plane].band[4][1].a_width ||
1241 !highpass_stride ||
s->plane[plane].band[4][1].width >
s->plane[plane].band[4][1].a_width ||
1242 lowpass_width < 3 || lowpass_height < 3 || lowpass_width * 2 >
s->plane[plane].width) {
1248 low =
s->plane[plane].l_h[7];
1249 high =
s->plane[plane].l_h[9];
1250 output =
s->plane[plane].l_h[7];
1251 for (
int i = 0;
i < lowpass_height;
i++) {
1253 low += output_stride;
1254 high += output_stride;
1256 if (
s->progressive) {
1257 low =
s->plane[plane].l_h[7];
1258 high =
s->plane[plane].subband[15];
1259 output =
s->plane[plane].l_h[6];
1260 dsp->
vert_filter(output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1262 low =
s->plane[plane].subband[14];
1263 high =
s->plane[plane].subband[16];
1264 output =
s->plane[plane].l_h[7];
1265 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1267 low =
s->plane[plane].l_h[9];
1268 high =
s->plane[plane].subband[12];
1269 output =
s->plane[plane].l_h[8];
1270 dsp->
vert_filter(output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1272 low =
s->plane[plane].subband[11];
1273 high =
s->plane[plane].subband[13];
1274 output =
s->plane[plane].l_h[9];
1275 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1277 if (
s->sample_type == 1)
1280 dst = (int16_t *)pic->
data[act_plane];
1296 low =
s->plane[plane].l_h[6];
1297 high =
s->plane[plane].l_h[7];
1298 for (
int i = 0;
i <
s->plane[act_plane].height;
i++) {
1300 low += output_stride;
1301 high += output_stride;
1302 dst += dst_linesize;
1306 low =
s->plane[plane].l_h[7];
1307 high =
s->plane[plane].subband[14];
1308 output =
s->plane[plane].l_h[6];
1309 dsp->
horiz_filter(output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1311 low =
s->plane[plane].subband[15];
1312 high =
s->plane[plane].subband[16];
1313 output =
s->plane[plane].l_h[7];
1314 dsp->
horiz_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1316 low =
s->plane[plane].l_h[9];
1317 high =
s->plane[plane].subband[11];
1318 output =
s->plane[plane].l_h[8];
1319 dsp->
horiz_filter(output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1321 low =
s->plane[plane].subband[12];
1322 high =
s->plane[plane].subband[13];
1323 output =
s->plane[plane].l_h[9];
1324 dsp->
horiz_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1326 if (
s->sample_type == 1)
1329 dst = (int16_t *)pic->
data[act_plane];
1330 low =
s->plane[plane].l_h[6];
1331 high =
s->plane[plane].l_h[7];
1332 for (
int i = 0;
i <
s->plane[act_plane].height / 2;
i++) {
1334 low += output_stride * 2;
1335 high += output_stride * 2;
1342 if (
s->transform_type == 2 &&
s->sample_type == 1) {
1344 int output_stride, lowpass_height, lowpass_width;
1345 ptrdiff_t dst_linesize;
1347 for (
int plane = 0; plane <
s->planes; plane++) {
1348 int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane;
1352 dst_linesize = pic->
linesize[act_plane];
1354 dst_linesize = pic->
linesize[act_plane] / 2;
1357 lowpass_height =
s->plane[plane].band[4][1].height;
1358 output_stride =
s->plane[plane].band[4][1].a_width;
1359 lowpass_width =
s->plane[plane].band[4][1].width;
1361 if (lowpass_height >
s->plane[plane].band[4][1].a_height || lowpass_width >
s->plane[plane].band[4][1].a_width ||
1362 s->plane[plane].band[4][1].width >
s->plane[plane].band[4][1].a_width ||
1363 lowpass_width < 3 || lowpass_height < 3 || lowpass_width * 2 >
s->plane[plane].width) {
1369 if (
s->progressive) {
1370 dst = (int16_t *)pic->
data[act_plane];
1371 low =
s->plane[plane].l_h[8];
1372 high =
s->plane[plane].l_h[9];
1389 for (
int i = 0;
i <
s->plane[act_plane].height;
i++) {
1391 low += output_stride;
1392 high += output_stride;
1393 dst += dst_linesize;
1396 dst = (int16_t *)pic->
data[act_plane];
1397 low =
s->plane[plane].l_h[8];
1398 high =
s->plane[plane].l_h[9];
1399 for (
int i = 0;
i <
s->plane[act_plane].height / 2;
i++) {
1401 low += output_stride * 2;
1402 high += output_stride * 2;