Ejemplo n.º 1
0
        public FRAME_CONTEXT CopyOf()
        {
            var copy = new FRAME_CONTEXT();

            Array.Copy(bmode_prob, copy.bmode_prob, bmode_prob.Length);
            Array.Copy(ymode_prob, copy.ymode_prob, ymode_prob.Length);
            Array.Copy(uv_mode_prob, copy.uv_mode_prob, uv_mode_prob.Length);
            Array.Copy(sub_mv_ref_prob, copy.sub_mv_ref_prob, sub_mv_ref_prob.Length);
            Array.Copy(coef_probs, copy.coef_probs, coef_probs.Length);
            Array.Copy(mvc, copy.mvc, mvc.Length);
            return(copy);
        }
Ejemplo n.º 2
0
        public static int vp8_decode_mb_tokens(VP8D_COMP dx, MACROBLOCKD x)
        {
            BOOL_DECODER  bc = x.current_bc;
            FRAME_CONTEXT fc = dx.common.fc;

            //char* eobs = x->eobs;
            sbyte[] eobs = x.eobs;

            int i;
            int nonzeros;
            int eobtotal = 0;

            //short* qcoeff_ptr;
            //ProbaArray coef_probs;
            //int coefIndex = entropy.COEF_BANDS * entropy.PREV_COEF_CONTEXTS * entropy.ENTROPY_NODES;
            //ENTROPY_CONTEXT* a_ctx = ((ENTROPY_CONTEXT*)x->above_context);
            //ENTROPY_CONTEXT* l_ctx = ((ENTROPY_CONTEXT*)x->left_context);
            //ENTROPY_CONTEXT* a;
            //ENTROPY_CONTEXT* l;

            int blockSlice = entropy.COEF_BANDS * entropy.PREV_COEF_CONTEXTS * entropy.ENTROPY_NODES;

            fixed(byte *pCoefProbs = fc.coef_probs)
            {
                byte *coef_probs = null;

                fixed(sbyte *pAboveCtx = x.above_context.get().y1, pLeftContext = x.left_context.y1)
                {
                    ENTROPY_CONTEXT *a_ctx = pAboveCtx;
                    ENTROPY_CONTEXT *l_ctx = pLeftContext;
                    ENTROPY_CONTEXT *a;
                    ENTROPY_CONTEXT *l;

                    int skip_dc = 0;

                    //qcoeff_ptr = x.qcoeff[0];
                    fixed(short *pQcoeff = x.qcoeff)
                    {
                        short *qcoeff_ptr = pQcoeff;

                        if (x.mode_info_context.get().mbmi.is_4x4 == 0)
                        {
                            a = a_ctx + 8;
                            l = l_ctx + 8;

                            //coef_probs = fc.coef_probs[1];
                            coef_probs = pCoefProbs + blockSlice;

                            nonzeros = GetCoeffs(bc, coef_probs, (*a + *l), 0, qcoeff_ptr + 24 * 16);
                            *a = *l = (sbyte)(nonzeros > 0 ? 1 : 0);

                            eobs[24]  = (sbyte)nonzeros;
                            eobtotal += nonzeros - 16;

                            //coef_probs = fc.coef_probs[0];
                            coef_probs = pCoefProbs;

                            skip_dc = 1;
                        }
                        else
                        {
                            //coef_probs = fc.coef_probs[3];
                            coef_probs = pCoefProbs + 3 * blockSlice;

                            skip_dc = 0;
                        }

                        for (i = 0; i < 16; ++i)
                        {
                            a = a_ctx + (i & 3);
                            l = l_ctx + ((i & 0xc) >> 2);

                            nonzeros = GetCoeffs(bc, coef_probs, (*a + *l), skip_dc, qcoeff_ptr);
                            *a = *l = (sbyte)(nonzeros > 0 ? 1 : 0);

                            nonzeros   += skip_dc;
                            eobs[i]     = (sbyte)nonzeros;
                            eobtotal   += nonzeros;
                            qcoeff_ptr += 16;
                        }

                        //coef_probs = fc.coef_probs[2];
                        coef_probs = pCoefProbs + 2 * blockSlice;

                        a_ctx += 4;
                        l_ctx += 4;
                        for (i = 16; i < 24; ++i)
                        {
                            a = a_ctx + ((i > 19 ? 1 : 0) << 1) + (i & 1);
                            l = l_ctx + ((i > 19 ? 1 : 0) << 1) + ((i & 3) > 1 ? 1 : 0);

                            nonzeros = GetCoeffs(bc, coef_probs, (*a + *l), 0, qcoeff_ptr);
                            *a = *l = (sbyte)(nonzeros > 0 ? 1 : 0);

                            eobs[i]     = (sbyte)nonzeros;
                            eobtotal   += nonzeros;
                            qcoeff_ptr += 16;
                        }
                    }
                }
            }

            return(eobtotal);
        }