| 369 | } |
| 370 | |
| 371 | static int cfhd_decode(AVCodecContext *avctx, AVFrame *pic, |
| 372 | int *got_frame, AVPacket *avpkt) |
| 373 | { |
| 374 | CFHDContext *s = avctx->priv_data; |
| 375 | CFHDDSPContext *dsp = &s->dsp; |
| 376 | GetByteContext gb; |
| 377 | int ret = 0, got_buffer = 0; |
| 378 | |
| 379 | init_frame_defaults(s); |
| 380 | s->planes = av_pix_fmt_count_planes(s->coded_format); |
| 381 | |
| 382 | bytestream2_init(&gb, avpkt->data, avpkt->size); |
| 383 | |
| 384 | while (bytestream2_get_bytes_left(&gb) >= 4) { |
| 385 | /* Bit weird but implement the tag parsing as the spec says */ |
| 386 | uint16_t tagu = bytestream2_get_be16(&gb); |
| 387 | int16_t tag = (int16_t)tagu; |
| 388 | int8_t tag8 = (int8_t)(tagu >> 8); |
| 389 | uint16_t abstag = abs(tag); |
| 390 | int8_t abs_tag8 = abs(tag8); |
| 391 | uint16_t data = bytestream2_get_be16(&gb); |
| 392 | int16_t *coeff_data; |
| 393 | |
| 394 | if (abs_tag8 >= 0x60 && abs_tag8 <= 0x6f) { |
| 395 | av_log(avctx, AV_LOG_DEBUG, "large len %x\n", ((tagu & 0xff) << 16) | data); |
| 396 | } else if (tag == SampleFlags) { |
| 397 | av_log(avctx, AV_LOG_DEBUG, "Progressive? %"PRIu16"\n", data); |
| 398 | s->progressive = data & 0x0001; |
| 399 | } else if (tag == FrameType) { |
| 400 | s->frame_type = data; |
| 401 | av_log(avctx, AV_LOG_DEBUG, "Frame type %"PRIu16"\n", data); |
| 402 | } else if (abstag == VersionMajor) { |
| 403 | av_log(avctx, AV_LOG_DEBUG, "Version major %"PRIu16"\n", data); |
| 404 | } else if (abstag == VersionMinor) { |
| 405 | av_log(avctx, AV_LOG_DEBUG, "Version minor %"PRIu16"\n", data); |
| 406 | } else if (abstag == VersionRevision) { |
| 407 | av_log(avctx, AV_LOG_DEBUG, "Version revision %"PRIu16"\n", data); |
| 408 | } else if (abstag == VersionEdit) { |
| 409 | av_log(avctx, AV_LOG_DEBUG, "Version edit %"PRIu16"\n", data); |
| 410 | } else if (abstag == Version) { |
| 411 | av_log(avctx, AV_LOG_DEBUG, "Version %"PRIu16"\n", data); |
| 412 | } else if (tag == ImageWidth) { |
| 413 | av_log(avctx, AV_LOG_DEBUG, "Width %"PRIu16"\n", data); |
| 414 | s->coded_width = data; |
| 415 | } else if (tag == ImageHeight) { |
| 416 | av_log(avctx, AV_LOG_DEBUG, "Height %"PRIu16"\n", data); |
| 417 | s->coded_height = data; |
| 418 | } else if (tag == ChannelCount) { |
| 419 | av_log(avctx, AV_LOG_DEBUG, "Channel Count: %"PRIu16"\n", data); |
| 420 | s->channel_cnt = data; |
| 421 | if (data > 4) { |
| 422 | av_log(avctx, AV_LOG_ERROR, "Channel Count of %"PRIu16" is unsupported\n", data); |
| 423 | ret = AVERROR_PATCHWELCOME; |
| 424 | goto end; |
| 425 | } |
| 426 | } else if (tag == SubbandCount) { |
| 427 | av_log(avctx, AV_LOG_DEBUG, "Subband Count: %"PRIu16"\n", data); |
| 428 | if (data != SUBBAND_COUNT && data != SUBBAND_COUNT_3D) { |
nothing calls this directly
no test coverage detected