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) {
708 if (
s->subband_num_actual == 255)
712 if (
s->transform_type !=
s->a_transform_type)
715 coeff_data =
s->plane[
s->channel_num].subband[
s->subband_num_actual];
719 int lowpass_height, lowpass_width, lowpass_a_height, lowpass_a_width;
721 if (!
s->a_width || !
s->a_height) {
726 lowpass_height =
s->plane[
s->channel_num].band[0][0].height;
727 lowpass_width =
s->plane[
s->channel_num].band[0][0].width;
728 lowpass_a_height =
s->plane[
s->channel_num].band[0][0].a_height;
729 lowpass_a_width =
s->plane[
s->channel_num].band[0][0].a_width;
731 if (lowpass_width < 3 ||
732 lowpass_width > lowpass_a_width) {
738 if (lowpass_height < 3 ||
739 lowpass_height > lowpass_a_height) {
751 if (lowpass_height > lowpass_a_height || lowpass_width > lowpass_a_width ||
758 av_log(avctx,
AV_LOG_DEBUG,
"Start of lowpass coeffs component %d height:%d, width:%d\n",
s->channel_num, lowpass_height, lowpass_width);
759 for (
int i = 0;
i < lowpass_height;
i++) {
760 for (
int j = 0; j < lowpass_width; j++)
761 coeff_data[j] = bytestream2_get_be16u(&gb);
763 coeff_data += lowpass_width;
770 if (lowpass_height & 1) {
771 memcpy(&coeff_data[lowpass_height * lowpass_width],
772 &coeff_data[(lowpass_height - 1) * lowpass_width],
773 lowpass_width *
sizeof(*coeff_data));
776 s->plane[
s->channel_num].band[0][0].read_ok = 1;
778 av_log(avctx,
AV_LOG_DEBUG,
"Lowpass coefficients %d\n", lowpass_width * lowpass_height);
783 int highpass_height, highpass_width, highpass_a_width, highpass_a_height, highpass_stride, a_expected;
786 int count = 0, bytes;
788 if (!
s->a_width || !
s->a_height) {
793 highpass_height =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].height;
794 highpass_width =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].width;
795 highpass_a_width =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].a_width;
796 highpass_a_height =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].a_height;
797 highpass_stride =
s->plane[
s->channel_num].band[
s->level][
s->subband_num].stride;
798 a_expected = highpass_a_height * highpass_a_width;
806 if (highpass_height > highpass_a_height || highpass_width > highpass_a_width || a_expected < highpass_height * (uint64_t)highpass_stride) {
811 expected = highpass_height * highpass_stride;
813 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);
821 const int lossless =
s->band_encoding == 5;
823 if (
s->codebook == 0 &&
s->transform_type == 2 &&
s->subband_num_actual == 7)
839 if (count > expected)
847 const uint16_t q =
s->quantisation;
849 for (
int i = 0;
i <
run;
i++) {
850 *coeff_data |=
coeff * 256U;
854 for (
int i = 0;
i <
run;
i++)
855 *coeff_data++ =
coeff;
872 if (count > expected)
880 const uint16_t q =
s->quantisation;
882 for (
int i = 0;
i <
run;
i++) {
883 *coeff_data |=
coeff * 256U;
887 for (
int i = 0;
i <
run;
i++)
888 *coeff_data++ =
coeff;
895 if (count > expected) {
902 if (
s->difference_coding)
903 difference_coding(
s->plane[
s->channel_num].subband[
s->subband_num_actual], highpass_width, highpass_height);
913 av_log(avctx,
AV_LOG_DEBUG,
"End subband coeffs %i extra %i\n", count, count - expected);
914 s->plane[
s->channel_num].band[
s->level][
s->subband_num].read_ok = 1;
916 if (
s->subband_num_actual != 255)
930 s->a_transform_type == INT_MIN) {
942 for (
int plane = 0; plane <
s->planes; plane++) {
944 if (
s->transform_type == 2)
947 for (
int o = !!
level; o < 4 ; o++) {
948 if (!
s->plane[plane].band[
level][o].read_ok) {
956 if (
s->transform_type == 0 &&
s->sample_type != 1) {
957 for (
int plane = 0; plane <
s->planes && !ret; plane++) {
959 int lowpass_height =
s->plane[plane].band[0][0].height;
960 int output_stride =
s->plane[plane].band[0][0].a_width;
961 int lowpass_width =
s->plane[plane].band[0][0].width;
962 int highpass_stride =
s->plane[plane].band[0][1].stride;
963 int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane;
964 ptrdiff_t dst_linesize;
965 int16_t *low, *
high, *output, *
dst;
969 dst_linesize = pic->
linesize[act_plane];
971 dst_linesize = pic->
linesize[act_plane] / 2;
974 if (lowpass_height >
s->plane[plane].band[0][0].a_height || lowpass_width >
s->plane[plane].band[0][0].a_width ||
975 !highpass_stride ||
s->plane[plane].band[0][1].width >
s->plane[plane].band[0][1].a_width ||
976 lowpass_width < 3 || lowpass_height < 3) {
982 av_log(avctx,
AV_LOG_DEBUG,
"Decoding level 1 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
984 low =
s->plane[plane].subband[0];
985 high =
s->plane[plane].subband[2];
986 output =
s->plane[plane].l_h[0];
987 dsp->
vert_filter(output, output_stride, low, lowpass_width,
high, highpass_stride, lowpass_width, lowpass_height);
989 low =
s->plane[plane].subband[1];
990 high =
s->plane[plane].subband[3];
991 output =
s->plane[plane].l_h[1];
993 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
995 low =
s->plane[plane].l_h[0];
996 high =
s->plane[plane].l_h[1];
997 output =
s->plane[plane].subband[0];
998 dsp->
horiz_filter(output, output_stride, low, output_stride,
high, output_stride, lowpass_width, lowpass_height * 2);
1000 output =
s->plane[plane].subband[0];
1001 for (
int i = 0;
i < lowpass_height * 2;
i++) {
1002 for (
int j = 0; j < lowpass_width * 2; j++)
1005 output += output_stride * 2;
1010 lowpass_height =
s->plane[plane].band[1][1].height;
1011 output_stride =
s->plane[plane].band[1][1].a_width;
1012 lowpass_width =
s->plane[plane].band[1][1].width;
1013 highpass_stride =
s->plane[plane].band[1][1].stride;
1015 if (lowpass_height >
s->plane[plane].band[1][1].a_height || lowpass_width >
s->plane[plane].band[1][1].a_width ||
1016 !highpass_stride ||
s->plane[plane].band[1][1].width >
s->plane[plane].band[1][1].a_width ||
1017 lowpass_width < 3 || lowpass_height < 3) {
1023 av_log(avctx,
AV_LOG_DEBUG,
"Level 2 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1025 low =
s->plane[plane].subband[0];
1026 high =
s->plane[plane].subband[5];
1027 output =
s->plane[plane].l_h[3];
1028 dsp->
vert_filter(output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1030 low =
s->plane[plane].subband[4];
1031 high =
s->plane[plane].subband[6];
1032 output =
s->plane[plane].l_h[4];
1033 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1035 low =
s->plane[plane].l_h[3];
1036 high =
s->plane[plane].l_h[4];
1037 output =
s->plane[plane].subband[0];
1038 dsp->
horiz_filter(output, output_stride, low, output_stride,
high, output_stride, lowpass_width, lowpass_height * 2);
1040 output =
s->plane[plane].subband[0];
1041 for (
int i = 0;
i < lowpass_height * 2;
i++) {
1042 for (
int j = 0; j < lowpass_width * 2; j++)
1045 output += output_stride * 2;
1049 lowpass_height =
s->plane[plane].band[2][1].height;
1050 output_stride =
s->plane[plane].band[2][1].a_width;
1051 lowpass_width =
s->plane[plane].band[2][1].width;
1052 highpass_stride =
s->plane[plane].band[2][1].stride;
1054 if (lowpass_height >
s->plane[plane].band[2][1].a_height || lowpass_width >
s->plane[plane].band[2][1].a_width ||
1055 !highpass_stride ||
s->plane[plane].band[2][1].width >
s->plane[plane].band[2][1].a_width ||
1056 lowpass_height < 3 || lowpass_width < 3 || lowpass_width * 2 >
s->plane[plane].width) {
1062 av_log(avctx,
AV_LOG_DEBUG,
"Level 3 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1063 if (
s->progressive) {
1064 low =
s->plane[plane].subband[0];
1065 high =
s->plane[plane].subband[8];
1066 output =
s->plane[plane].l_h[6];
1067 dsp->
vert_filter(output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1069 low =
s->plane[plane].subband[7];
1070 high =
s->plane[plane].subband[9];
1071 output =
s->plane[plane].l_h[7];
1072 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1074 dst = (int16_t *)pic->
data[act_plane];
1081 low =
s->plane[plane].l_h[6];
1082 high =
s->plane[plane].l_h[7];
1092 for (
int i = 0;
i <
s->plane[act_plane].height;
i++) {
1096 low += output_stride;
1097 high += output_stride;
1098 dst += dst_linesize;
1103 low =
s->plane[plane].subband[0];
1104 high =
s->plane[plane].subband[7];
1105 output =
s->plane[plane].l_h[6];
1106 dsp->
horiz_filter(output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1108 low =
s->plane[plane].subband[8];
1109 high =
s->plane[plane].subband[9];
1110 output =
s->plane[plane].l_h[7];
1111 dsp->
horiz_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1113 dst = (int16_t *)pic->
data[act_plane];
1114 low =
s->plane[plane].l_h[6];
1115 high =
s->plane[plane].l_h[7];
1116 for (
int i = 0;
i <
s->plane[act_plane].height / 2;
i++) {
1118 low += output_stride * 2;
1119 high += output_stride * 2;
1124 }
else if (
s->transform_type == 2 && (avctx->
internal->
is_copy ||
s->frame_index == 1 ||
s->sample_type != 1)) {
1125 for (
int plane = 0; plane <
s->planes && !ret; plane++) {
1126 int lowpass_height =
s->plane[plane].band[0][0].height;
1127 int output_stride =
s->plane[plane].band[0][0].a_width;
1128 int lowpass_width =
s->plane[plane].band[0][0].width;
1129 int highpass_stride =
s->plane[plane].band[0][1].stride;
1130 int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane;
1131 int16_t *low, *
high, *output, *
dst;
1132 ptrdiff_t dst_linesize;
1136 dst_linesize = pic->
linesize[act_plane];
1138 dst_linesize = pic->
linesize[act_plane] / 2;
1141 if (lowpass_height >
s->plane[plane].band[0][0].a_height || lowpass_width >
s->plane[plane].band[0][0].a_width ||
1142 !highpass_stride ||
s->plane[plane].band[0][1].width >
s->plane[plane].band[0][1].a_width ||
1143 lowpass_width < 3 || lowpass_height < 3) {
1149 av_log(avctx,
AV_LOG_DEBUG,
"Decoding level 1 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1151 low =
s->plane[plane].subband[0];
1152 high =
s->plane[plane].subband[2];
1153 output =
s->plane[plane].l_h[0];
1154 dsp->
vert_filter(output, output_stride, low, lowpass_width,
high, highpass_stride, lowpass_width, lowpass_height);
1156 low =
s->plane[plane].subband[1];
1157 high =
s->plane[plane].subband[3];
1158 output =
s->plane[plane].l_h[1];
1159 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1161 low =
s->plane[plane].l_h[0];
1162 high =
s->plane[plane].l_h[1];
1163 output =
s->plane[plane].l_h[7];
1164 dsp->
horiz_filter(output, output_stride, low, output_stride,
high, output_stride, lowpass_width, lowpass_height * 2);
1166 output =
s->plane[plane].l_h[7];
1167 for (
int i = 0;
i < lowpass_height * 2;
i++) {
1168 for (
int j = 0; j < lowpass_width * 2; j++)
1171 output += output_stride * 2;
1175 lowpass_height =
s->plane[plane].band[1][1].height;
1176 output_stride =
s->plane[plane].band[1][1].a_width;
1177 lowpass_width =
s->plane[plane].band[1][1].width;
1178 highpass_stride =
s->plane[plane].band[1][1].stride;
1180 if (lowpass_height >
s->plane[plane].band[1][1].a_height || lowpass_width >
s->plane[plane].band[1][1].a_width ||
1181 !highpass_stride ||
s->plane[plane].band[1][1].width >
s->plane[plane].band[1][1].a_width ||
1182 lowpass_width < 3 || lowpass_height < 3) {
1188 av_log(avctx,
AV_LOG_DEBUG,
"Level 2 lowpass plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1190 low =
s->plane[plane].l_h[7];
1191 high =
s->plane[plane].subband[5];
1192 output =
s->plane[plane].l_h[3];
1193 dsp->
vert_filter(output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1195 low =
s->plane[plane].subband[4];
1196 high =
s->plane[plane].subband[6];
1197 output =
s->plane[plane].l_h[4];
1198 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1200 low =
s->plane[plane].l_h[3];
1201 high =
s->plane[plane].l_h[4];
1202 output =
s->plane[plane].l_h[7];
1203 dsp->
horiz_filter(output, output_stride, low, output_stride,
high, output_stride, lowpass_width, lowpass_height * 2);
1205 output =
s->plane[plane].l_h[7];
1206 for (
int i = 0;
i < lowpass_height * 2;
i++) {
1207 for (
int j = 0; j < lowpass_width * 2; j++)
1209 output += output_stride * 2;
1212 low =
s->plane[plane].subband[7];
1213 high =
s->plane[plane].subband[9];
1214 output =
s->plane[plane].l_h[3];
1215 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1217 low =
s->plane[plane].subband[8];
1218 high =
s->plane[plane].subband[10];
1219 output =
s->plane[plane].l_h[4];
1220 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1222 low =
s->plane[plane].l_h[3];
1223 high =
s->plane[plane].l_h[4];
1224 output =
s->plane[plane].l_h[9];
1225 dsp->
horiz_filter(output, output_stride, low, output_stride,
high, output_stride, lowpass_width, lowpass_height * 2);
1227 lowpass_height =
s->plane[plane].band[4][1].height;
1228 output_stride =
s->plane[plane].band[4][1].a_width;
1229 lowpass_width =
s->plane[plane].band[4][1].width;
1230 highpass_stride =
s->plane[plane].band[4][1].stride;
1231 av_log(avctx,
AV_LOG_DEBUG,
"temporal level %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
1233 if (lowpass_height >
s->plane[plane].band[4][1].a_height || lowpass_width >
s->plane[plane].band[4][1].a_width ||
1234 !highpass_stride ||
s->plane[plane].band[4][1].width >
s->plane[plane].band[4][1].a_width ||
1235 lowpass_width < 3 || lowpass_height < 3 || lowpass_width * 2 >
s->plane[plane].width) {
1241 low =
s->plane[plane].l_h[7];
1242 high =
s->plane[plane].l_h[9];
1243 output =
s->plane[plane].l_h[7];
1244 for (
int i = 0;
i < lowpass_height;
i++) {
1246 low += output_stride;
1247 high += output_stride;
1249 if (
s->progressive) {
1250 low =
s->plane[plane].l_h[7];
1251 high =
s->plane[plane].subband[15];
1252 output =
s->plane[plane].l_h[6];
1253 dsp->
vert_filter(output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1255 low =
s->plane[plane].subband[14];
1256 high =
s->plane[plane].subband[16];
1257 output =
s->plane[plane].l_h[7];
1258 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1260 low =
s->plane[plane].l_h[9];
1261 high =
s->plane[plane].subband[12];
1262 output =
s->plane[plane].l_h[8];
1263 dsp->
vert_filter(output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1265 low =
s->plane[plane].subband[11];
1266 high =
s->plane[plane].subband[13];
1267 output =
s->plane[plane].l_h[9];
1268 dsp->
vert_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1270 if (
s->sample_type == 1)
1273 dst = (int16_t *)pic->
data[act_plane];
1289 low =
s->plane[plane].l_h[6];
1290 high =
s->plane[plane].l_h[7];
1291 for (
int i = 0;
i <
s->plane[act_plane].height;
i++) {
1293 low += output_stride;
1294 high += output_stride;
1295 dst += dst_linesize;
1299 low =
s->plane[plane].l_h[7];
1300 high =
s->plane[plane].subband[14];
1301 output =
s->plane[plane].l_h[6];
1302 dsp->
horiz_filter(output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1304 low =
s->plane[plane].subband[15];
1305 high =
s->plane[plane].subband[16];
1306 output =
s->plane[plane].l_h[7];
1307 dsp->
horiz_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1309 low =
s->plane[plane].l_h[9];
1310 high =
s->plane[plane].subband[11];
1311 output =
s->plane[plane].l_h[8];
1312 dsp->
horiz_filter(output, output_stride, low, output_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1314 low =
s->plane[plane].subband[12];
1315 high =
s->plane[plane].subband[13];
1316 output =
s->plane[plane].l_h[9];
1317 dsp->
horiz_filter(output, output_stride, low, highpass_stride,
high, highpass_stride, lowpass_width, lowpass_height);
1319 if (
s->sample_type == 1)
1322 dst = (int16_t *)pic->
data[act_plane];
1323 low =
s->plane[plane].l_h[6];
1324 high =
s->plane[plane].l_h[7];
1325 for (
int i = 0;
i <
s->plane[act_plane].height / 2;
i++) {
1327 low += output_stride * 2;
1328 high += output_stride * 2;
1335 if (
s->transform_type == 2 &&
s->sample_type == 1) {
1337 int output_stride, lowpass_height, lowpass_width;
1338 ptrdiff_t dst_linesize;
1340 for (
int plane = 0; plane <
s->planes; plane++) {
1341 int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane;
1345 dst_linesize = pic->
linesize[act_plane];
1347 dst_linesize = pic->
linesize[act_plane] / 2;
1350 lowpass_height =
s->plane[plane].band[4][1].height;
1351 output_stride =
s->plane[plane].band[4][1].a_width;
1352 lowpass_width =
s->plane[plane].band[4][1].width;
1354 if (lowpass_height >
s->plane[plane].band[4][1].a_height || lowpass_width >
s->plane[plane].band[4][1].a_width ||
1355 s->plane[plane].band[4][1].width >
s->plane[plane].band[4][1].a_width ||
1356 lowpass_width < 3 || lowpass_height < 3 || lowpass_width * 2 >
s->plane[plane].width) {
1362 if (
s->progressive) {
1363 dst = (int16_t *)pic->
data[act_plane];
1364 low =
s->plane[plane].l_h[8];
1365 high =
s->plane[plane].l_h[9];
1382 for (
int i = 0;
i <
s->plane[act_plane].height;
i++) {
1384 low += output_stride;
1385 high += output_stride;
1386 dst += dst_linesize;
1389 dst = (int16_t *)pic->
data[act_plane];
1390 low =
s->plane[plane].l_h[8];
1391 high =
s->plane[plane].l_h[9];
1392 for (
int i = 0;
i <
s->plane[act_plane].height / 2;
i++) {
1394 low += output_stride * 2;
1395 high += output_stride * 2;