| 1039 | } |
| 1040 | |
| 1041 | static int init_tile(Jpeg2000DecoderContext *s, int tileno) |
| 1042 | { |
| 1043 | int compno; |
| 1044 | int tilex = tileno % s->numXtiles; |
| 1045 | int tiley = tileno / s->numXtiles; |
| 1046 | Jpeg2000Tile *tile = s->tile + tileno; |
| 1047 | |
| 1048 | if (!tile->comp) |
| 1049 | return AVERROR(ENOMEM); |
| 1050 | |
| 1051 | tile->coord[0][0] = av_clip(tilex * (int64_t)s->tile_width + s->tile_offset_x, s->image_offset_x, s->width); |
| 1052 | tile->coord[0][1] = av_clip((tilex + 1) * (int64_t)s->tile_width + s->tile_offset_x, s->image_offset_x, s->width); |
| 1053 | tile->coord[1][0] = av_clip(tiley * (int64_t)s->tile_height + s->tile_offset_y, s->image_offset_y, s->height); |
| 1054 | tile->coord[1][1] = av_clip((tiley + 1) * (int64_t)s->tile_height + s->tile_offset_y, s->image_offset_y, s->height); |
| 1055 | |
| 1056 | for (compno = 0; compno < s->ncomponents; compno++) { |
| 1057 | Jpeg2000Component *comp = tile->comp + compno; |
| 1058 | Jpeg2000CodingStyle *codsty = tile->codsty + compno; |
| 1059 | Jpeg2000QuantStyle *qntsty = tile->qntsty + compno; |
| 1060 | int ret; // global bandno |
| 1061 | |
| 1062 | comp->coord_o[0][0] = tile->coord[0][0]; |
| 1063 | comp->coord_o[0][1] = tile->coord[0][1]; |
| 1064 | comp->coord_o[1][0] = tile->coord[1][0]; |
| 1065 | comp->coord_o[1][1] = tile->coord[1][1]; |
| 1066 | |
| 1067 | comp->coord_o[0][0] = ff_jpeg2000_ceildiv(comp->coord_o[0][0], s->cdx[compno]); |
| 1068 | comp->coord_o[0][1] = ff_jpeg2000_ceildiv(comp->coord_o[0][1], s->cdx[compno]); |
| 1069 | comp->coord_o[1][0] = ff_jpeg2000_ceildiv(comp->coord_o[1][0], s->cdy[compno]); |
| 1070 | comp->coord_o[1][1] = ff_jpeg2000_ceildiv(comp->coord_o[1][1], s->cdy[compno]); |
| 1071 | |
| 1072 | comp->coord[0][0] = ff_jpeg2000_ceildivpow2(comp->coord_o[0][0], s->reduction_factor); |
| 1073 | comp->coord[0][1] = ff_jpeg2000_ceildivpow2(comp->coord_o[0][1], s->reduction_factor); |
| 1074 | comp->coord[1][0] = ff_jpeg2000_ceildivpow2(comp->coord_o[1][0], s->reduction_factor); |
| 1075 | comp->coord[1][1] = ff_jpeg2000_ceildivpow2(comp->coord_o[1][1], s->reduction_factor); |
| 1076 | |
| 1077 | if (!comp->roi_shift) |
| 1078 | comp->roi_shift = s->roi_shift[compno]; |
| 1079 | if (!codsty->init) |
| 1080 | return AVERROR_INVALIDDATA; |
| 1081 | if (s->isHT && (!s->Ccap15_b05) && (!codsty->transform)) { |
| 1082 | av_log(s->avctx, AV_LOG_ERROR, "Transformation = 0 (lossy DWT) is found in HTREV HT set\n"); |
| 1083 | return AVERROR_INVALIDDATA; |
| 1084 | } |
| 1085 | if (s->isHT && s->Ccap15_b14_15 != (codsty->cblk_style >> 6) && s->Ccap15_b14_15 != HTJ2K_HTONLY) { |
| 1086 | av_log(s->avctx, AV_LOG_ERROR, "SPcod/SPcoc value does not match bit 14-15 values of Ccap15\n"); |
| 1087 | return AVERROR_INVALIDDATA; |
| 1088 | } |
| 1089 | if (ret = ff_jpeg2000_init_component(comp, codsty, qntsty, |
| 1090 | s->cbps[compno], s->cdx[compno], |
| 1091 | s->cdy[compno], s->avctx)) |
| 1092 | return ret; |
| 1093 | } |
| 1094 | return 0; |
| 1095 | } |
| 1096 | |
| 1097 | /* Read the number of coding passes. */ |
| 1098 | static int getnpasses(Jpeg2000DecoderContext *s) |
no test coverage detected