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) {
681 if (
s->cropped_height) {
707 if (
s->subband_num_actual == 255)
711 if (
s->transform_type !=
s->a_transform_type)
714 coeff_data =
s->plane[
s->channel_num].subband[
s->subband_num_actual];
718 int lowpass_height, lowpass_width, lowpass_a_height, lowpass_a_width;
720 if (!
s->a_width || !
s->a_height) {
725 lowpass_height =
s->plane[
s->channel_num].band[0][0].height;
726 lowpass_width =
s->plane[
s->channel_num].band[0][0].width;
727 lowpass_a_height =
s->plane[
s->channel_num].band[0][0].a_height;
728 lowpass_a_width =
s->plane[
s->channel_num].band[0][0].a_width;
730 if (lowpass_width < 3 ||
731 lowpass_width > lowpass_a_width) {
737 if (lowpass_height < 3 ||
738 lowpass_height > lowpass_a_height) {
750 if (lowpass_height > lowpass_a_height || lowpass_width > lowpass_a_width ||
757 av_log(avctx,
AV_LOG_DEBUG,
"Start of lowpass coeffs component %d height:%d, width:%d\n",
s->channel_num, lowpass_height, lowpass_width);
758 for (
int i = 0;
i < lowpass_height;
i++) {
759 for (
int j = 0; j < lowpass_width; j++)
760 coeff_data[j] = bytestream2_get_be16u(&gb);
762 coeff_data += lowpass_width;
769 if (lowpass_height & 1) {
770 memcpy(&coeff_data[lowpass_height * lowpass_width],
771 &coeff_data[(lowpass_height - 1) * lowpass_width],
772 lowpass_width *
sizeof(*coeff_data));
775 s->plane[
s->channel_num].band[0][0].read_ok = 1;
777 av_log(avctx,
AV_LOG_DEBUG,
"Lowpass coefficients %d\n", lowpass_width * lowpass_height);
782 int highpass_height, highpass_width, highpass_a_width, highpass_a_height, highpass_stride, a_expected;
785 int count = 0, bytes;
787 if (!
s->a_width || !
s->a_height) {
792 highpass_height =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].height;
793 highpass_width =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].width;
794 highpass_a_width =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].a_width;
795 highpass_a_height =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].a_height;
796 highpass_stride =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].stride;
797 a_expected = highpass_a_height * highpass_a_width;
805 if (highpass_height > highpass_a_height || highpass_width > highpass_a_width || a_expected < highpass_height * (uint64_t)highpass_stride) {
810 expected = highpass_height * highpass_stride;
812 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);
820 const int lossless =
s->band_encoding == 5;
822 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 (
int i = 0;
i <
run;
i++) {
849 *coeff_data |=
coeff * 256U;
853 for (
int i = 0;
i <
run;
i++)
854 *coeff_data++ =
coeff;
871 if (count > expected)
879 const uint16_t q =
s->quantisation;
881 for (
int i = 0;
i <
run;
i++) {
882 *coeff_data |=
coeff * 256U;
886 for (
int i = 0;
i <
run;
i++)
887 *coeff_data++ =
coeff;
894 if (count > expected) {
901 if (
s->difference_coding)
902 difference_coding(
s->plane[
s->channel_num].subband[
s->subband_num_actual], highpass_width, highpass_height);
912 av_log(avctx,
AV_LOG_DEBUG,
"End subband coeffs %i extra %i\n", count, count - expected);
913 s->plane[
s->channel_num].band[
s->level][
s->subband_num].read_ok = 1;
915 if (
s->subband_num_actual != 255)
929 s->a_transform_type == INT_MIN) {
941 for (
int plane = 0; plane <
s->planes; plane++) {
943 if (
s->transform_type == 2)
946 for (
int o = !!
level; o < 4 ; o++) {
947 if (!
s->plane[plane].band[
level][o].read_ok) {
955 if (
s->transform_type == 0 &&
s->sample_type != 1) {
956 for (
int plane = 0; plane <
s->planes && !ret; plane++) {
958 int lowpass_height =
s->plane[plane].band[0][0].height;
959 int output_stride =
s->plane[plane].band[0][0].a_width;
960 int lowpass_width =
s->plane[plane].band[0][0].width;
961 int highpass_stride =
s->plane[plane].band[0][1].stride;
962 int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane;
963 ptrdiff_t dst_linesize;
964 int16_t *low, *
high, *output, *
dst;
968 dst_linesize = pic->
linesize[act_plane];
970 dst_linesize = pic->
linesize[act_plane] / 2;
973 if (lowpass_height >
s->plane[plane].band[0][0].a_height || lowpass_width >
s->plane[plane].band[0][0].a_width ||
974 !highpass_stride ||
s->plane[plane].band[0][1].width >
s->plane[plane].band[0][1].a_width ||
975 lowpass_width < 3 || lowpass_height < 3) {
981 av_log(avctx,
AV_LOG_DEBUG,
"Decoding level 1 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
983 low =
s->plane[plane].subband[0];
984 high =
s->plane[plane].subband[2];
985 output =
s->plane[plane].l_h[0];
986 dsp->
vert_filter(output, output_stride, low, lowpass_width,
high, highpass_stride, lowpass_width, lowpass_height);
988 low =
s->plane[plane].subband[1];
989 high =
s->plane[plane].subband[3];
990 output =
s->plane[plane].l_h[1];
992 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
994 low =
s->plane[plane].l_h[0];
995 high =
s->plane[plane].l_h[1];
996 output =
s->plane[plane].subband[0];
997 dsp->
horiz_filter(output, output_stride, low, output_stride,
high, output_stride, lowpass_width, lowpass_height * 2);
999 output =
s->plane[plane].subband[0];
1000 for (
int i = 0;
i < lowpass_height * 2;
i++) {
1001 for (
int j = 0; j < lowpass_width * 2; j++)
1004 output += output_stride * 2;
1009 lowpass_height =
s->plane[plane].band[1][1].height;
1010 output_stride =
s->plane[plane].band[1][1].a_width;
1011 lowpass_width =
s->plane[plane].band[1][1].width;
1012 highpass_stride =
s->plane[plane].band[1][1].stride;
1014 if (lowpass_height >
s->plane[plane].band[1][1].a_height || lowpass_width >
s->plane[plane].band[1][1].a_width ||
1015 !highpass_stride ||
s->plane[plane].band[1][1].width >
s->plane[plane].band[1][1].a_width ||
1016 lowpass_width < 3 || lowpass_height < 3) {
1022 av_log(avctx,
AV_LOG_DEBUG,
"Level 2 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1024 low =
s->plane[plane].subband[0];
1025 high =
s->plane[plane].subband[5];
1026 output =
s->plane[plane].l_h[3];
1027 dsp->
vert_filter(output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1029 low =
s->plane[plane].subband[4];
1030 high =
s->plane[plane].subband[6];
1031 output =
s->plane[plane].l_h[4];
1032 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1034 low =
s->plane[plane].l_h[3];
1035 high =
s->plane[plane].l_h[4];
1036 output =
s->plane[plane].subband[0];
1037 dsp->
horiz_filter(output, output_stride, low, output_stride,
high, output_stride, lowpass_width, lowpass_height * 2);
1039 output =
s->plane[plane].subband[0];
1040 for (
int i = 0;
i < lowpass_height * 2;
i++) {
1041 for (
int j = 0; j < lowpass_width * 2; j++)
1044 output += output_stride * 2;
1048 lowpass_height =
s->plane[plane].band[2][1].height;
1049 output_stride =
s->plane[plane].band[2][1].a_width;
1050 lowpass_width =
s->plane[plane].band[2][1].width;
1051 highpass_stride =
s->plane[plane].band[2][1].stride;
1053 if (lowpass_height >
s->plane[plane].band[2][1].a_height || lowpass_width >
s->plane[plane].band[2][1].a_width ||
1054 !highpass_stride ||
s->plane[plane].band[2][1].width >
s->plane[plane].band[2][1].a_width ||
1055 lowpass_height < 3 || lowpass_width < 3 || lowpass_width * 2 >
s->plane[plane].width) {
1061 av_log(avctx,
AV_LOG_DEBUG,
"Level 3 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1062 if (
s->progressive) {
1063 low =
s->plane[plane].subband[0];
1064 high =
s->plane[plane].subband[8];
1065 output =
s->plane[plane].l_h[6];
1066 dsp->
vert_filter(output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1068 low =
s->plane[plane].subband[7];
1069 high =
s->plane[plane].subband[9];
1070 output =
s->plane[plane].l_h[7];
1071 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1073 dst = (int16_t *)pic->
data[act_plane];
1080 low =
s->plane[plane].l_h[6];
1081 high =
s->plane[plane].l_h[7];
1091 for (
int i = 0;
i <
s->plane[act_plane].height;
i++) {
1095 low += output_stride;
1096 high += output_stride;
1097 dst += dst_linesize;
1102 low =
s->plane[plane].subband[0];
1103 high =
s->plane[plane].subband[7];
1104 output =
s->plane[plane].l_h[6];
1105 dsp->
horiz_filter(output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1107 low =
s->plane[plane].subband[8];
1108 high =
s->plane[plane].subband[9];
1109 output =
s->plane[plane].l_h[7];
1110 dsp->
horiz_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1112 dst = (int16_t *)pic->
data[act_plane];
1113 low =
s->plane[plane].l_h[6];
1114 high =
s->plane[plane].l_h[7];
1115 for (
int i = 0;
i <
s->plane[act_plane].height / 2;
i++) {
1117 low += output_stride * 2;
1118 high += output_stride * 2;
1123 }
else if (
s->transform_type == 2 && (avctx->
internal->
is_copy ||
s->frame_index == 1 ||
s->sample_type != 1)) {
1124 for (
int plane = 0; plane <
s->planes && !ret; plane++) {
1125 int lowpass_height =
s->plane[plane].band[0][0].height;
1126 int output_stride =
s->plane[plane].band[0][0].a_width;
1127 int lowpass_width =
s->plane[plane].band[0][0].width;
1128 int highpass_stride =
s->plane[plane].band[0][1].stride;
1129 int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane;
1130 int16_t *low, *
high, *output, *
dst;
1131 ptrdiff_t dst_linesize;
1135 dst_linesize = pic->
linesize[act_plane];
1137 dst_linesize = pic->
linesize[act_plane] / 2;
1140 if (lowpass_height >
s->plane[plane].band[0][0].a_height || lowpass_width >
s->plane[plane].band[0][0].a_width ||
1141 !highpass_stride ||
s->plane[plane].band[0][1].width >
s->plane[plane].band[0][1].a_width ||
1142 lowpass_width < 3 || lowpass_height < 3) {
1148 av_log(avctx,
AV_LOG_DEBUG,
"Decoding level 1 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1150 low =
s->plane[plane].subband[0];
1151 high =
s->plane[plane].subband[2];
1152 output =
s->plane[plane].l_h[0];
1153 dsp->
vert_filter(output, output_stride, low, lowpass_width,
high, highpass_stride, lowpass_width, lowpass_height);
1155 low =
s->plane[plane].subband[1];
1156 high =
s->plane[plane].subband[3];
1157 output =
s->plane[plane].l_h[1];
1158 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1160 low =
s->plane[plane].l_h[0];
1161 high =
s->plane[plane].l_h[1];
1162 output =
s->plane[plane].l_h[7];
1163 dsp->
horiz_filter(output, output_stride, low, output_stride,
high, output_stride, lowpass_width, lowpass_height * 2);
1165 output =
s->plane[plane].l_h[7];
1166 for (
int i = 0;
i < lowpass_height * 2;
i++) {
1167 for (
int j = 0; j < lowpass_width * 2; j++)
1170 output += output_stride * 2;
1174 lowpass_height =
s->plane[plane].band[1][1].height;
1175 output_stride =
s->plane[plane].band[1][1].a_width;
1176 lowpass_width =
s->plane[plane].band[1][1].width;
1177 highpass_stride =
s->plane[plane].band[1][1].stride;
1179 if (lowpass_height >
s->plane[plane].band[1][1].a_height || lowpass_width >
s->plane[plane].band[1][1].a_width ||
1180 !highpass_stride ||
s->plane[plane].band[1][1].width >
s->plane[plane].band[1][1].a_width ||
1181 lowpass_width < 3 || lowpass_height < 3) {
1187 av_log(avctx,
AV_LOG_DEBUG,
"Level 2 lowpass plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1189 low =
s->plane[plane].l_h[7];
1190 high =
s->plane[plane].subband[5];
1191 output =
s->plane[plane].l_h[3];
1192 dsp->
vert_filter(output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1194 low =
s->plane[plane].subband[4];
1195 high =
s->plane[plane].subband[6];
1196 output =
s->plane[plane].l_h[4];
1197 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1199 low =
s->plane[plane].l_h[3];
1200 high =
s->plane[plane].l_h[4];
1201 output =
s->plane[plane].l_h[7];
1202 dsp->
horiz_filter(output, output_stride, low, output_stride,
high, output_stride, lowpass_width, lowpass_height * 2);
1204 output =
s->plane[plane].l_h[7];
1205 for (
int i = 0;
i < lowpass_height * 2;
i++) {
1206 for (
int j = 0; j < lowpass_width * 2; j++)
1208 output += output_stride * 2;
1211 low =
s->plane[plane].subband[7];
1212 high =
s->plane[plane].subband[9];
1213 output =
s->plane[plane].l_h[3];
1214 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1216 low =
s->plane[plane].subband[8];
1217 high =
s->plane[plane].subband[10];
1218 output =
s->plane[plane].l_h[4];
1219 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1221 low =
s->plane[plane].l_h[3];
1222 high =
s->plane[plane].l_h[4];
1223 output =
s->plane[plane].l_h[9];
1224 dsp->
horiz_filter(output, output_stride, low, output_stride,
high, output_stride, lowpass_width, lowpass_height * 2);
1226 lowpass_height =
s->plane[plane].band[4][1].height;
1227 output_stride =
s->plane[plane].band[4][1].a_width;
1228 lowpass_width =
s->plane[plane].band[4][1].width;
1229 highpass_stride =
s->plane[plane].band[4][1].stride;
1230 av_log(avctx,
AV_LOG_DEBUG,
"temporal level %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1232 if (lowpass_height >
s->plane[plane].band[4][1].a_height || lowpass_width >
s->plane[plane].band[4][1].a_width ||
1233 !highpass_stride ||
s->plane[plane].band[4][1].width >
s->plane[plane].band[4][1].a_width ||
1234 lowpass_width < 3 || lowpass_height < 3 || lowpass_width * 2 >
s->plane[plane].width) {
1240 low =
s->plane[plane].l_h[7];
1241 high =
s->plane[plane].l_h[9];
1242 output =
s->plane[plane].l_h[7];
1243 for (
int i = 0;
i < lowpass_height;
i++) {
1245 low += output_stride;
1246 high += output_stride;
1248 if (
s->progressive) {
1249 low =
s->plane[plane].l_h[7];
1250 high =
s->plane[plane].subband[15];
1251 output =
s->plane[plane].l_h[6];
1252 dsp->
vert_filter(output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1254 low =
s->plane[plane].subband[14];
1255 high =
s->plane[plane].subband[16];
1256 output =
s->plane[plane].l_h[7];
1257 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1259 low =
s->plane[plane].l_h[9];
1260 high =
s->plane[plane].subband[12];
1261 output =
s->plane[plane].l_h[8];
1262 dsp->
vert_filter(output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1264 low =
s->plane[plane].subband[11];
1265 high =
s->plane[plane].subband[13];
1266 output =
s->plane[plane].l_h[9];
1267 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1269 if (
s->sample_type == 1)
1272 dst = (int16_t *)pic->
data[act_plane];
1288 low =
s->plane[plane].l_h[6];
1289 high =
s->plane[plane].l_h[7];
1290 for (
int i = 0;
i <
s->plane[act_plane].height;
i++) {
1292 low += output_stride;
1293 high += output_stride;
1294 dst += dst_linesize;
1298 low =
s->plane[plane].l_h[7];
1299 high =
s->plane[plane].subband[14];
1300 output =
s->plane[plane].l_h[6];
1301 dsp->
horiz_filter(output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1303 low =
s->plane[plane].subband[15];
1304 high =
s->plane[plane].subband[16];
1305 output =
s->plane[plane].l_h[7];
1306 dsp->
horiz_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1308 low =
s->plane[plane].l_h[9];
1309 high =
s->plane[plane].subband[11];
1310 output =
s->plane[plane].l_h[8];
1311 dsp->
horiz_filter(output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1313 low =
s->plane[plane].subband[12];
1314 high =
s->plane[plane].subband[13];
1315 output =
s->plane[plane].l_h[9];
1316 dsp->
horiz_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1318 if (
s->sample_type == 1)
1321 dst = (int16_t *)pic->
data[act_plane];
1322 low =
s->plane[plane].l_h[6];
1323 high =
s->plane[plane].l_h[7];
1324 for (
int i = 0;
i <
s->plane[act_plane].height / 2;
i++) {
1326 low += output_stride * 2;
1327 high += output_stride * 2;
1334 if (
s->transform_type == 2 &&
s->sample_type == 1) {
1336 int output_stride, lowpass_height, lowpass_width;
1337 ptrdiff_t dst_linesize;
1339 for (
int plane = 0; plane <
s->planes; plane++) {
1340 int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane;
1344 dst_linesize = pic->
linesize[act_plane];
1346 dst_linesize = pic->
linesize[act_plane] / 2;
1349 lowpass_height =
s->plane[plane].band[4][1].height;
1350 output_stride =
s->plane[plane].band[4][1].a_width;
1351 lowpass_width =
s->plane[plane].band[4][1].width;
1353 if (lowpass_height >
s->plane[plane].band[4][1].a_height || lowpass_width >
s->plane[plane].band[4][1].a_width ||
1354 s->plane[plane].band[4][1].width >
s->plane[plane].band[4][1].a_width ||
1355 lowpass_width < 3 || lowpass_height < 3 || lowpass_width * 2 >
s->plane[plane].width) {
1361 if (
s->progressive) {
1362 dst = (int16_t *)pic->
data[act_plane];
1363 low =
s->plane[plane].l_h[8];
1364 high =
s->plane[plane].l_h[9];
1381 for (
int i = 0;
i <
s->plane[act_plane].height;
i++) {
1383 low += output_stride;
1384 high += output_stride;
1385 dst += dst_linesize;
1388 dst = (int16_t *)pic->
data[act_plane];
1389 low =
s->plane[plane].l_h[8];
1390 high =
s->plane[plane].l_h[9];
1391 for (
int i = 0;
i <
s->plane[act_plane].height / 2;
i++) {
1393 low += output_stride * 2;
1394 high += output_stride * 2;