| 278 | } |
| 279 | |
| 280 | static int decode_frame(AVCodecContext *avctx, AVFrame *p, |
| 281 | int *got_frame, AVPacket *avpkt) |
| 282 | { |
| 283 | DPXDecContext *dpx = avctx->priv_data; |
| 284 | |
| 285 | enum AVPixelFormat pix_fmt; |
| 286 | const uint8_t *buf = avpkt->data; |
| 287 | int buf_size = avpkt->size; |
| 288 | uint32_t header_version, version = 0; |
| 289 | char creator[101] = { 0 }; |
| 290 | char input_device[33] = { 0 }; |
| 291 | |
| 292 | unsigned int offset; |
| 293 | int magic_num; |
| 294 | int i, j, ret; |
| 295 | int w, h, descriptor; |
| 296 | int yuv, color_trc, color_spec; |
| 297 | int encoding; |
| 298 | |
| 299 | if (avpkt->size <= 1634) { |
| 300 | av_log(avctx, AV_LOG_ERROR, "Packet too small for DPX header\n"); |
| 301 | return AVERROR_INVALIDDATA; |
| 302 | } |
| 303 | |
| 304 | magic_num = AV_RB32(buf); |
| 305 | buf += 4; |
| 306 | |
| 307 | /* Check if the files "magic number" is "SDPX" which means it uses |
| 308 | * big-endian or XPDS which is for little-endian files */ |
| 309 | if (magic_num == AV_RL32("SDPX")) { |
| 310 | dpx->endian = 0; |
| 311 | } else if (magic_num == AV_RB32("SDPX")) { |
| 312 | dpx->endian = 1; |
| 313 | } else { |
| 314 | av_log(avctx, AV_LOG_ERROR, "DPX marker not found\n"); |
| 315 | return AVERROR_INVALIDDATA; |
| 316 | } |
| 317 | |
| 318 | offset = read32(&buf, dpx->endian); |
| 319 | if (avpkt->size <= offset) { |
| 320 | av_log(avctx, AV_LOG_ERROR, "Invalid data start offset\n"); |
| 321 | return AVERROR_INVALIDDATA; |
| 322 | } |
| 323 | |
| 324 | header_version = read32(&buf, 0); |
| 325 | if (header_version == MKTAG('V','1','.','0')) |
| 326 | version = 1; |
| 327 | if (header_version == MKTAG('V','2','.','0')) |
| 328 | version = 2; |
| 329 | if (!version) |
| 330 | av_log(avctx, AV_LOG_WARNING, "Unknown header format version %s.\n", |
| 331 | av_fourcc2str(header_version)); |
| 332 | |
| 333 | // Check encryption |
| 334 | buf = avpkt->data + 660; |
| 335 | ret = read32(&buf, dpx->endian); |
| 336 | if (ret != 0xFFFFFFFF) { |
| 337 | avpriv_report_missing_feature(avctx, "Encryption"); |
nothing calls this directly
no test coverage detected