Unified · Split
| @@ -1112,6 +1112,11 @@ static int dwa_uncompress(const EXRContext *s, const uint8_t *src, int compresse · 1111 unmodified lines | ||
| 1112 | 1112 | |
| 1113 | 1113 | for (int y = 0; y < td->ysize; y += 8) { |
| 1114 | 1114 | for (int x = 0; x < td->xsize; x += 8) { |
| 1115 | + const int o = s->nb_channels == 4; | |
| 1116 | + float *yb = td->block[0]; | |
| 1117 | + float *ub = td->block[1]; | |
| 1118 | + float *vb = td->block[2]; | |
| 1119 | + | |
| 1115 | 1120 | memset(td->block, 0, sizeof(td->block)); |
| 1116 | 1121 | |
| 1117 | 1122 | for (int j = 0; j < 3; j++) { |
| @@ -1127,36 +1132,31 @@ static int dwa_uncompress(const EXRContext *s, const uint8_t *src, int compresse · 9 unmodified lines | ||
| 1127 | 1132 | dct_inverse(block); |
| 1128 | 1133 | } |
| 1129 | 1134 | |
| 1130 | − { | |
| 1131 | − const int o = s->nb_channels == 4; | |
| 1132 | − float *yb = td->block[0]; | |
| 1133 | − float *ub = td->block[1]; | |
| 1134 | − float *vb = td->block[2]; | |
| 1135 | − if (s->pixel_type == EXR_HALF) { | |
| 1136 | − uint16_t *bo = ((uint16_t *)td->uncompressed_data) + | |
| 1137 | − y * td->xsize * s->nb_channels + td->xsize * (o + 0) + x; | |
| 1138 | − uint16_t *go = ((uint16_t *)td->uncompressed_data) + | |
| 1139 | − y * td->xsize * s->nb_channels + td->xsize * (o + 1) + x; | |
| 1140 | − uint16_t *ro = ((uint16_t *)td->uncompressed_data) + | |
| 1141 | − y * td->xsize * s->nb_channels + td->xsize * (o + 2) + x; | |
| 1142 | − | |
| 1143 | − for (int yy = 0; yy < 8; yy++) { | |
| 1144 | − for (int xx = 0; xx < 8; xx++) { | |
| 1145 | − const int idx = xx + yy * 8; | |
| 1146 | − float b, g, r; | |
| 1147 | − | |
| 1148 | − convert(yb[idx], ub[idx], vb[idx], &b, &g, &r); | |
| 1149 | − | |
| 1150 | − bo[xx] = float2half(av_float2int(to_linear(b, 1.f)), &s->f2h_tables); | |
| 1151 | − go[xx] = float2half(av_float2int(to_linear(g, 1.f)), &s->f2h_tables); | |
| 1152 | − ro[xx] = float2half(av_float2int(to_linear(r, 1.f)), &s->f2h_tables); | |
| 1153 | − } | |
| 1135 | + if (s->pixel_type == EXR_HALF) { | |
| 1136 | + uint16_t *bo = ((uint16_t *)td->uncompressed_data) + | |
| 1137 | + y * td->xsize * s->nb_channels + td->xsize * (o + 0) + x; | |
| 1138 | + uint16_t *go = ((uint16_t *)td->uncompressed_data) + | |
| 1139 | + y * td->xsize * s->nb_channels + td->xsize * (o + 1) + x; | |
| 1140 | + uint16_t *ro = ((uint16_t *)td->uncompressed_data) + | |
| 1141 | + y * td->xsize * s->nb_channels + td->xsize * (o + 2) + x; | |
| 1142 | + | |
| 1143 | + for (int yy = 0; yy < 8; yy++) { | |
| 1144 | + for (int xx = 0; xx < 8; xx++) { | |
| 1145 | + const int idx = xx + yy * 8; | |
| 1146 | + float b, g, r; | |
| 1154 | 1147 | |
| 1155 | − bo += td->xsize * s->nb_channels; | |
| 1156 | − go += td->xsize * s->nb_channels; | |
| 1157 | − ro += td->xsize * s->nb_channels; | |
| 1148 | + convert(yb[idx], ub[idx], vb[idx], &b, &g, &r); | |
| 1149 | + | |
| 1150 | + bo[xx] = float2half(av_float2int(to_linear(b, 1.f)), &s->f2h_tables); | |
| 1151 | + go[xx] = float2half(av_float2int(to_linear(g, 1.f)), &s->f2h_tables); | |
| 1152 | + ro[xx] = float2half(av_float2int(to_linear(r, 1.f)), &s->f2h_tables); | |
| 1158 | 1153 | } |
| 1159 | − } else { | |
| 1154 | + | |
| 1155 | + bo += td->xsize * s->nb_channels; | |
| 1156 | + go += td->xsize * s->nb_channels; | |
| 1157 | + ro += td->xsize * s->nb_channels; | |
| 1158 | + } | |
| 1159 | + } else { | |
| 1160 | 1160 | float *bo = ((float *)td->uncompressed_data) + |
| 1161 | 1161 | y * td->xsize * s->nb_channels + td->xsize * (o + 0) + x; |
| 1162 | 1162 | float *go = ((float *)td->uncompressed_data) + |
| @@ -1179,7 +1179,6 @@ static int dwa_uncompress(const EXRContext *s, const uint8_t *src, int compresse · 16 unmodified lines | ||
| 1179 | 1179 | go += td->xsize * s->nb_channels; |
| 1180 | 1180 | ro += td->xsize * s->nb_channels; |
| 1181 | 1181 | } |
| 1182 | − } | |
| 1183 | 1182 | } |
| 1184 | 1183 | } |
| 1185 | 1184 | } |
| @@ -1197,18 +1196,18 @@ static int dwa_uncompress(const EXRContext *s, const uint8_t *src, int compresse · 11 unmodified lines | ||
| 1197 | 1196 | ao[x] = ai0[x] | (ai1[x] << 8); |
| 1198 | 1197 | } |
| 1199 | 1198 | } else { |
| 1200 | − for (int y = 0; y < td->ysize && td->rle_raw_data; y++) { | |
| 1201 | − uint32_t *ao = ((uint32_t *)td->uncompressed_data) + y * td->xsize * s->nb_channels; | |
| 1202 | − uint8_t *ai0 = td->rle_raw_data + y * td->xsize; | |
| 1203 | − uint8_t *ai1 = td->rle_raw_data + y * td->xsize + rle_raw_size / 2; | |
| 1199 | + for (int y = 0; y < td->ysize && td->rle_raw_data; y++) { | |
| 1200 | + uint32_t *ao = ((uint32_t *)td->uncompressed_data) + y * td->xsize * s->nb_channels; | |
| 1201 | + uint8_t *ai0 = td->rle_raw_data + y * td->xsize; | |
| 1202 | + uint8_t *ai1 = td->rle_raw_data + y * td->xsize + rle_raw_size / 2; | |
| 1204 | 1203 | |
| 1205 | − for (int x = 0; x < td->xsize; x++) { | |
| 1206 | − uint16_t ha = ai0[x] | (ai1[x] << 8); | |
| 1204 | + for (int x = 0; x < td->xsize; x++) { | |
| 1205 | + uint16_t ha = ai0[x] | (ai1[x] << 8); | |
| 1207 | 1206 | |
| 1208 | − ao[x] = half2float(ha, &s->h2f_tables); | |
| 1207 | + ao[x] = half2float(ha, &s->h2f_tables); | |
| 1208 | + } | |
| 1209 | 1209 | } |
| 1210 | 1210 | } |
| 1211 | − } | |
| 1212 | 1211 | |
| 1213 | 1212 | return 0; |
| 1214 | 1213 | } |
| @@ -2076,20 +2075,20 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture, · 861 unmodified lines | ||
| 2076 | 2075 | |
| 2077 | 2076 | switch (s->pixel_type) { |
| 2078 | 2077 | case EXR_HALF: |
| 2079 | − if (s->channel_offsets[3] >= 0) { | |
| 2080 | − if (!s->is_luma) { | |
| 2081 | − avctx->pix_fmt = AV_PIX_FMT_GBRAPF16; | |
| 2082 | − } else { | |
| 2083 | − avctx->pix_fmt = AV_PIX_FMT_YAF16; | |
| 2084 | − } | |
| 2078 | + if (s->channel_offsets[3] >= 0) { | |
| 2079 | + if (!s->is_luma) { | |
| 2080 | + avctx->pix_fmt = AV_PIX_FMT_GBRAPF16; | |
| 2085 | 2081 | } else { |
| 2086 | − if (!s->is_luma) { | |
| 2087 | − avctx->pix_fmt = AV_PIX_FMT_GBRPF16; | |
| 2088 | − } else { | |
| 2089 | − avctx->pix_fmt = AV_PIX_FMT_GRAYF16; | |
| 2090 | − } | |
| 2082 | + avctx->pix_fmt = AV_PIX_FMT_YAF16; | |
| 2091 | 2083 | } |
| 2092 | − break; | |
| 2084 | + } else { | |
| 2085 | + if (!s->is_luma) { | |
| 2086 | + avctx->pix_fmt = AV_PIX_FMT_GBRPF16; | |
| 2087 | + } else { | |
| 2088 | + avctx->pix_fmt = AV_PIX_FMT_GRAYF16; | |
| 2089 | + } | |
| 2090 | + } | |
| 2091 | + break; | |
| 2093 | 2092 | case EXR_FLOAT: |
| 2094 | 2093 | if (s->channel_offsets[3] >= 0) { |
| 2095 | 2094 | if (!s->is_luma) { |