Mercurial > libavcodec.hg
diff vp56.c @ 5711:dae0f80edbb3 libavcodec
move all model related tables into their own struct
author | aurel |
---|---|
date | Mon, 24 Sep 2007 22:29:11 +0000 |
parents | 9792a3aa9215 |
children | 314be1cfdcb0 |
line wrap: on
line diff
--- a/vp56.c Mon Sep 24 21:18:45 2007 +0000 +++ b/vp56.c Mon Sep 24 22:29:11 2007 +0000 @@ -75,13 +75,15 @@ static void vp56_parse_mb_type_models(vp56_context_t *s) { vp56_range_coder_t *c = &s->c; + vp56_model_t *model = s->modelp; int i, ctx, type; for (ctx=0; ctx<3; ctx++) { if (vp56_rac_get_prob(c, 174)) { int idx = vp56_rac_gets(c, 4); - memcpy(s->mb_types_stats[ctx],vp56_pre_def_mb_type_stats[idx][ctx], - sizeof(s->mb_types_stats[ctx])); + memcpy(model->mb_types_stats[ctx], + vp56_pre_def_mb_type_stats[idx][ctx], + sizeof(model->mb_types_stats[ctx])); } if (vp56_rac_get_prob(c, 254)) { for (type=0; type<10; type++) { @@ -93,7 +95,7 @@ vp56_mb_type_model_model); if (!delta) delta = 4 * vp56_rac_gets(c, 7); - s->mb_types_stats[ctx][type][i] += (delta ^ -sign) + sign; + model->mb_types_stats[ctx][type][i] += (delta ^ -sign) + sign; } } } @@ -105,13 +107,13 @@ int p[10]; for (type=0; type<10; type++) - p[type] = 100 * s->mb_types_stats[ctx][type][1]; + p[type] = 100 * model->mb_types_stats[ctx][type][1]; for (type=0; type<10; type++) { int p02, p34, p0234, p17, p56, p89, p5689, p156789; /* conservative MB type probability */ - s->mb_type_model[ctx][type][0] = 255 - (255 * s->mb_types_stats[ctx][type][0]) / (1 + s->mb_types_stats[ctx][type][0] + s->mb_types_stats[ctx][type][1]); + model->mb_type[ctx][type][0] = 255 - (255 * model->mb_types_stats[ctx][type][0]) / (1 + model->mb_types_stats[ctx][type][0] + model->mb_types_stats[ctx][type][1]); p[type] = 0; /* same MB type => weight is null */ @@ -125,18 +127,18 @@ p5689 = p56 + p89; p156789 = p17 + p5689; - s->mb_type_model[ctx][type][1] = 1 + 255 * p0234/(1+p0234+p156789); - s->mb_type_model[ctx][type][2] = 1 + 255 * p02 / (1+p0234); - s->mb_type_model[ctx][type][3] = 1 + 255 * p17 / (1+p156789); - s->mb_type_model[ctx][type][4] = 1 + 255 * p[0] / (1+p02); - s->mb_type_model[ctx][type][5] = 1 + 255 * p[3] / (1+p34); - s->mb_type_model[ctx][type][6] = 1 + 255 * p[1] / (1+p17); - s->mb_type_model[ctx][type][7] = 1 + 255 * p56 / (1+p5689); - s->mb_type_model[ctx][type][8] = 1 + 255 * p[5] / (1+p56); - s->mb_type_model[ctx][type][9] = 1 + 255 * p[8] / (1+p89); + model->mb_type[ctx][type][1] = 1 + 255 * p0234/(1+p0234+p156789); + model->mb_type[ctx][type][2] = 1 + 255 * p02 / (1+p0234); + model->mb_type[ctx][type][3] = 1 + 255 * p17 / (1+p156789); + model->mb_type[ctx][type][4] = 1 + 255 * p[0] / (1+p02); + model->mb_type[ctx][type][5] = 1 + 255 * p[3] / (1+p34); + model->mb_type[ctx][type][6] = 1 + 255 * p[1] / (1+p17); + model->mb_type[ctx][type][7] = 1 + 255 * p56 / (1+p5689); + model->mb_type[ctx][type][8] = 1 + 255 * p[5] / (1+p56); + model->mb_type[ctx][type][9] = 1 + 255 * p[8] / (1+p89); /* restore initial value */ - p[type] = 100 * s->mb_types_stats[ctx][type][1]; + p[type] = 100 * model->mb_types_stats[ctx][type][1]; } } } @@ -144,7 +146,7 @@ static vp56_mb_t vp56_parse_mb_type(vp56_context_t *s, vp56_mb_t prev_type, int ctx) { - uint8_t *mb_type_model = s->mb_type_model[ctx][prev_type]; + uint8_t *mb_type_model = s->modelp->mb_type[ctx][prev_type]; vp56_range_coder_t *c = &s->c; if (vp56_rac_get_prob(c, mb_type_model[0])) @@ -501,6 +503,8 @@ int golden_frame = 0; int res; + s->modelp = &s->models; + res = s->parse_header(s, buf, buf_size, &golden_frame); if (!res) return -1;