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

Function decode_mb_info

libavcodec/indeo4.c:469–627  ·  view source on GitHub ↗

* 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

Source from the content-addressed store, hash-verified

467 * @return result code: 0 = OK, negative number = error
468 */
469static 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) {

Callers

nothing calls this directly

Calls 7

av_logFunction · 0.85
get_bits_leftFunction · 0.85
get_bits1Function · 0.85
get_vlc2Function · 0.85
ivi_scale_mvFunction · 0.85
align_get_bitsFunction · 0.85
get_bitsFunction · 0.70

Tested by

no test coverage detected