* Decode information (block type, cbp, quant delta, motion vector) * for all macroblocks in the current tile. * * @param[in,out] ctx pointer to the decoder context * @param[in,out] band pointer to the band descriptor * @param[in,out] tile pointer to the tile descriptor * @param[in] avctx pointer to the AVCodecContext * @return result code: 0 = OK, negat
| 467 | * @return result code: 0 = OK, negative number = error |
| 468 | */ |
| 469 | static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc *band, |
| 470 | IVITile *tile, AVCodecContext *avctx) |
| 471 | { |
| 472 | int x, y, mv_x, mv_y, mv_delta, offs, mb_offset, blks_per_mb, |
| 473 | mv_scale, mb_type_bits, s; |
| 474 | IVIMbInfo *mb, *ref_mb; |
| 475 | int row_offset = band->mb_size * band->pitch; |
| 476 | |
| 477 | mb = tile->mbs; |
| 478 | ref_mb = tile->ref_mbs; |
| 479 | offs = tile->ypos * band->pitch + tile->xpos; |
| 480 | |
| 481 | blks_per_mb = band->mb_size != band->blk_size ? 4 : 1; |
| 482 | mb_type_bits = ctx->frame_type == IVI4_FRAMETYPE_BIDIR ? 2 : 1; |
| 483 | |
| 484 | /* scale factor for motion vectors */ |
| 485 | mv_scale = (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3); |
| 486 | mv_x = mv_y = 0; |
| 487 | |
| 488 | if (((tile->width + band->mb_size-1)/band->mb_size) * ((tile->height + band->mb_size-1)/band->mb_size) != tile->num_MBs) { |
| 489 | av_log(avctx, AV_LOG_ERROR, "num_MBs mismatch %d %d %d %d\n", tile->width, tile->height, band->mb_size, tile->num_MBs); |
| 490 | return -1; |
| 491 | } |
| 492 | |
| 493 | for (y = tile->ypos; y < tile->ypos + tile->height; y += band->mb_size) { |
| 494 | mb_offset = offs; |
| 495 | |
| 496 | for (x = tile->xpos; x < tile->xpos + tile->width; x += band->mb_size) { |
| 497 | mb->xpos = x; |
| 498 | mb->ypos = y; |
| 499 | mb->buf_offs = mb_offset; |
| 500 | mb->b_mv_x = |
| 501 | mb->b_mv_y = 0; |
| 502 | |
| 503 | if (get_bits_left(&ctx->gb) < 1) { |
| 504 | av_log(avctx, AV_LOG_ERROR, "Insufficient input for mb info\n"); |
| 505 | return AVERROR_INVALIDDATA; |
| 506 | } |
| 507 | |
| 508 | if (get_bits1(&ctx->gb)) { |
| 509 | if (ctx->frame_type == IVI4_FRAMETYPE_INTRA) { |
| 510 | av_log(avctx, AV_LOG_ERROR, "Empty macroblock in an INTRA picture!\n"); |
| 511 | return AVERROR_INVALIDDATA; |
| 512 | } |
| 513 | mb->type = 1; /* empty macroblocks are always INTER */ |
| 514 | mb->cbp = 0; /* all blocks are empty */ |
| 515 | |
| 516 | mb->q_delta = 0; |
| 517 | if (!band->plane && !band->band_num && ctx->in_q) { |
| 518 | mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table, |
| 519 | IVI_VLC_BITS, 1); |
| 520 | mb->q_delta = IVI_TOSIGNED(mb->q_delta); |
| 521 | } |
| 522 | |
| 523 | mb->mv_x = mb->mv_y = 0; /* no motion vector coded */ |
| 524 | if (band->inherit_mv && ref_mb) { |
| 525 | /* motion vector inheritance */ |
| 526 | if (mv_scale) { |
nothing calls this directly
no test coverage detected