MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / decode_block

Function decode_block

libavcodec/exr.c:1248–1541  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1246}
1247
1248static int decode_block(AVCodecContext *avctx, void *tdata,
1249 int jobnr, int threadnr)
1250{
1251 const EXRContext *s = avctx->priv_data;
1252 AVFrame *const p = s->picture;
1253 EXRThreadData *td = &s->thread_data[threadnr];
1254 const uint8_t *channel_buffer[4] = { 0 };
1255 const uint8_t *buf = s->buf;
1256 uint64_t line_offset, uncompressed_size;
1257 uint8_t *ptr;
1258 uint32_t data_size;
1259 int line, col = 0;
1260 uint64_t tile_x, tile_y, tile_level_x, tile_level_y;
1261 const uint8_t *src;
1262 int step = s->desc->comp[0].step;
1263 int bxmin = 0, axmax = 0, window_xoffset = 0;
1264 int window_xmin, window_xmax, window_ymin, window_ymax;
1265 int data_xoffset, data_yoffset, data_window_offset, xsize, ysize;
1266 int i, x, buf_size = s->buf_size;
1267 int c, rgb_channel_count;
1268#if FF_API_EXR_GAMMA
1269 float one_gamma = 1.0f / s->gamma;
1270 av_csp_trc_function trc_func = av_csp_trc_func_from_id(s->apply_trc_type);
1271#endif
1272 int ret;
1273
1274 line_offset = AV_RL64(s->gb.buffer + jobnr * 8);
1275
1276 if (s->is_tile) {
1277 if (buf_size < 20 || line_offset > buf_size - 20)
1278 return AVERROR_INVALIDDATA;
1279
1280 src = buf + line_offset + 20;
1281 if (s->is_multipart)
1282 src += 4;
1283
1284 tile_x = AV_RL32(src - 20);
1285 tile_y = AV_RL32(src - 16);
1286 tile_level_x = AV_RL32(src - 12);
1287 tile_level_y = AV_RL32(src - 8);
1288
1289 data_size = AV_RL32(src - 4);
1290 if (data_size <= 0 || data_size > buf_size - line_offset - 20)
1291 return AVERROR_INVALIDDATA;
1292
1293 if (tile_level_x || tile_level_y) { /* tile level, is not the full res level */
1294 avpriv_report_missing_feature(s->avctx, "Subres tile before full res tile");
1295 return AVERROR_PATCHWELCOME;
1296 }
1297
1298 if (tile_x && s->tile_attr.xSize + (int64_t)FFMAX(s->xmin, 0) >= INT_MAX / tile_x )
1299 return AVERROR_INVALIDDATA;
1300 if (tile_y && s->tile_attr.ySize + (int64_t)FFMAX(s->ymin, 0) >= INT_MAX / tile_y )
1301 return AVERROR_INVALIDDATA;
1302
1303 line = s->ymin + s->tile_attr.ySize * tile_y;
1304 col = s->tile_attr.xSize * tile_x;
1305

Callers

nothing calls this directly

Calls 13

av_csp_trc_func_from_idFunction · 0.85
av_image_check_size2Function · 0.85
av_fast_padded_mallocFunction · 0.85
zip_uncompressFunction · 0.85
piz_uncompressFunction · 0.85
pxr24_uncompressFunction · 0.85
b44_uncompressFunction · 0.85
dwa_uncompressFunction · 0.85
av_logFunction · 0.85
av_int2floatFunction · 0.85
av_float2intFunction · 0.85

Tested by

no test coverage detected