Logo Search packages:      
Sourcecode: blender version File versions  Download package

static int vc9_decode_block ( VC9Context v,
DCTELEM  block[64],
int  n,
int  coded,
int  mquant 
) [static]

Decode one block, inter or intra

Parameters:
v The VC9 context
block 8x8 DCT block
n Block index in the current MB (<4=>luma)
coded If the block is coded
mquant Quantizer step for the current block
See also:
Inter TT: Table 21, p73 + p91-85

Intra TT: Table 20, p72 + p(1)05-(1)07

Todo:
TODO: Process the blocks
Todo:
TODO: Use M$ MPEG-4 cbp prediction

Definition at line 1835 of file vc9.c.

References MpegEncContext::ac_pred, MpegEncContext::avctx, MpegEncContext::block_last_index, MpegEncContext::c_dc_scale, MpegEncContext::c_dc_scale_table, MpegEncContext::dc_table_index, MpegEncContext::gb, MpegEncContext::mb_intra, mpeg4_pred_ac(), VC9Context::pq, VC9Context::s, VC9Context::tt_index, VC9Context::ttblk4x4, VC9Context::ttmb, vc9_pred_dc(), MpegEncContext::y_dc_scale, and MpegEncContext::y_dc_scale_table.

Referenced by vc9_decode_b_mb(), vc9_decode_i_mb(), and vc9_decode_p_mb().

{
    GetBitContext *gb = &v->s.gb;
    MpegEncContext *s = &v->s;
    int ttblk; /* Transform Type per Block */
    int subblkpat; /* Sub-block Transform Type Pattern */
    int dc_pred_dir; /* Direction of the DC prediction used */
    int run_diff, i;

    /* XXX: Guard against dumb values of mquant */
    mquant = (mquant < 1) ? 0 : ( (mquant>31) ? 31 : mquant );

    /* Set DC scale - y and c use the same */
    s->y_dc_scale = s->y_dc_scale_table[mquant];
    s->c_dc_scale = s->c_dc_scale_table[mquant];

    if (s->mb_intra)
    {
        int dcdiff;
        uint16_t *dc_val;

        /* Get DC differential */
        if (n < 4) {
            dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
        } else {
            dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
        }
        if (dcdiff < 0){
            av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n");
            return -1;
        }
        if (dcdiff)
        {
            if (dcdiff == 119 /* ESC index value */)
            {
                /* TODO: Optimize */
                if (mquant == 1) dcdiff = get_bits(gb, 10);
                else if (mquant == 2) dcdiff = get_bits(gb, 9);
                else dcdiff = get_bits(gb, 8);
            }
            else
            {
                if (mquant == 1)
                  dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3;
                else if (mquant == 2)
                  dcdiff = (dcdiff<<1) + get_bits(gb, 1) - 1;
            }
            if (get_bits(gb, 1))
              dcdiff = -dcdiff;
        }

        /* Prediction */
        dcdiff += vc9_pred_dc(s, n, &dc_val, &dc_pred_dir);
        *dc_val = dcdiff;
        /* Store the quantized DC coeff, used for prediction */

        if (n < 4) {
            block[0] = dcdiff * s->y_dc_scale;
        } else {
            block[0] = dcdiff * s->c_dc_scale;
        }
        if (block[0] < 0) {
#if TRACE
            //av_log(s->avctx, AV_LOG_ERROR, "DC=%i<0\n", dcdiff);
#endif
            //return -1;
        }
        /* Skip ? */
        run_diff = 0;
        i = 0;
        if (!coded) {
            goto not_coded;
        }
    }
    else
    {
        mquant = v->pq;

        /* Get TTBLK */
        if (v->ttmb < 8) /* per block */
            ttblk = get_vlc2(gb, vc9_ttblk_vlc[v->tt_index].table, VC9_TTBLK_VLC_BITS, 2);
        else /* Per frame */
          ttblk = 0; //FIXME, depends on ttfrm

        /* Get SUBBLKPAT */
        if (ttblk == v->ttblk4x4) /* 4x4 transform for that qp value */
            subblkpat = 1+get_vlc2(gb, vc9_subblkpat_vlc[v->tt_index].table,
                                   VC9_SUBBLKPAT_VLC_BITS, 2);
        else /* All others: 8x8, 4x8, 8x4 */
            subblkpat = decode012(gb);
    }

    //TODO AC Decoding
    i = 63; //XXX: nothing done yet


 not_coded:
    if (s->mb_intra) {
        mpeg4_pred_ac(s, block, n, dc_pred_dir);
        if (s->ac_pred) {
            i = 63; /* XXX: not optimal */
        }
    }
    if(i>0) i=63; //FIXME/XXX optimize
    s->block_last_index[n] = i;
    return 0;
}


Generated by  Doxygen 1.6.0   Back to index