~ubuntu-branches/ubuntu/jaunty/xvidcap/jaunty-proposed

« back to all changes in this revision

Viewing changes to ffmpeg/libavcodec/vp5.c

  • Committer: Bazaar Package Importer
  • Author(s): Lionel Le Folgoc, Andrew Starr-Bochicchio, Lionel Le Folgoc
  • Date: 2008-12-26 00:10:06 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20081226001006-2040ls9680bd1blt
Tags: 1.1.7-0.2ubuntu1
[ Andrew Starr-Bochicchio ]
* Merge from debian-multimedia (LP: #298547), Ubuntu Changes:
 - For ffmpeg-related build-deps, fix versionized dependencies
   as the ubuntu versioning is different than debian-multimedia's.

[ Lionel Le Folgoc ]
* LP: #311412 is fixed since the 1.1.7~rc1-0.1 revision.
* debian/patches/03_ffmpeg.diff: updated to fix FTBFS due to libswscale API
  change (cherry-pick from Gentoo #234383).

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *
19
19
 * You should have received a copy of the GNU Lesser General Public
20
20
 * License along with FFmpeg; if not, write to the Free Software
21
 
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
21
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
22
 */
23
23
 
24
24
#include <stdlib.h>
27
27
#include "avcodec.h"
28
28
#include "dsputil.h"
29
29
#include "bitstream.h"
30
 
#include "mpegvideo.h"
31
30
 
32
31
#include "vp56.h"
33
32
#include "vp56data.h"
34
33
#include "vp5data.h"
35
34
 
36
35
 
37
 
static int vp5_parse_header(vp56_context_t *s, uint8_t *buf, int buf_size,
 
36
static int vp5_parse_header(vp56_context_t *s, const uint8_t *buf, int buf_size,
38
37
                            int *golden_frame)
39
38
{
40
39
    vp56_range_coder_t *c = &s->c;
88
87
static void vp5_parse_vector_adjustment(vp56_context_t *s, vp56_mv_t *vect)
89
88
{
90
89
    vp56_range_coder_t *c = &s->c;
 
90
    vp56_model_t *model = s->modelp;
91
91
    int comp, di;
92
92
 
93
93
    for (comp=0; comp<2; comp++) {
94
94
        int delta = 0;
95
 
        if (vp56_rac_get_prob(c, s->vector_model_dct[comp])) {
96
 
            int sign = vp56_rac_get_prob(c, s->vector_model_sig[comp]);
97
 
            di  = vp56_rac_get_prob(c, s->vector_model_pdi[comp][0]);
98
 
            di |= vp56_rac_get_prob(c, s->vector_model_pdi[comp][1]) << 1;
 
95
        if (vp56_rac_get_prob(c, model->vector_dct[comp])) {
 
96
            int sign = vp56_rac_get_prob(c, model->vector_sig[comp]);
 
97
            di  = vp56_rac_get_prob(c, model->vector_pdi[comp][0]);
 
98
            di |= vp56_rac_get_prob(c, model->vector_pdi[comp][1]) << 1;
99
99
            delta = vp56_rac_get_tree(c, vp56_pva_tree,
100
 
                                      s->vector_model_pdv[comp]);
 
100
                                      model->vector_pdv[comp]);
101
101
            delta = di | (delta << 2);
102
102
            delta = (delta ^ -sign) + sign;
103
103
        }
111
111
static void vp5_parse_vector_models(vp56_context_t *s)
112
112
{
113
113
    vp56_range_coder_t *c = &s->c;
 
114
    vp56_model_t *model = s->modelp;
114
115
    int comp, node;
115
116
 
116
117
    for (comp=0; comp<2; comp++) {
117
118
        if (vp56_rac_get_prob(c, vp5_vmc_pct[comp][0]))
118
 
            s->vector_model_dct[comp] = vp56_rac_gets_nn(c, 7);
 
119
            model->vector_dct[comp] = vp56_rac_gets_nn(c, 7);
119
120
        if (vp56_rac_get_prob(c, vp5_vmc_pct[comp][1]))
120
 
            s->vector_model_sig[comp] = vp56_rac_gets_nn(c, 7);
 
121
            model->vector_sig[comp] = vp56_rac_gets_nn(c, 7);
121
122
        if (vp56_rac_get_prob(c, vp5_vmc_pct[comp][2]))
122
 
            s->vector_model_pdi[comp][0] = vp56_rac_gets_nn(c, 7);
 
123
            model->vector_pdi[comp][0] = vp56_rac_gets_nn(c, 7);
123
124
        if (vp56_rac_get_prob(c, vp5_vmc_pct[comp][3]))
124
 
            s->vector_model_pdi[comp][1] = vp56_rac_gets_nn(c, 7);
 
125
            model->vector_pdi[comp][1] = vp56_rac_gets_nn(c, 7);
125
126
    }
126
127
 
127
128
    for (comp=0; comp<2; comp++)
128
129
        for (node=0; node<7; node++)
129
130
            if (vp56_rac_get_prob(c, vp5_vmc_pct[comp][4 + node]))
130
 
                s->vector_model_pdv[comp][node] = vp56_rac_gets_nn(c, 7);
 
131
                model->vector_pdv[comp][node] = vp56_rac_gets_nn(c, 7);
131
132
}
132
133
 
133
134
static void vp5_parse_coeff_models(vp56_context_t *s)
134
135
{
135
136
    vp56_range_coder_t *c = &s->c;
 
137
    vp56_model_t *model = s->modelp;
136
138
    uint8_t def_prob[11];
137
139
    int node, cg, ctx;
138
140
    int ct;    /* code type */
144
146
        for (node=0; node<11; node++)
145
147
            if (vp56_rac_get_prob(c, vp5_dccv_pct[pt][node])) {
146
148
                def_prob[node] = vp56_rac_gets_nn(c, 7);
147
 
                s->coeff_model_dccv[pt][node] = def_prob[node];
 
149
                model->coeff_dccv[pt][node] = def_prob[node];
148
150
            } else if (s->framep[VP56_FRAME_CURRENT]->key_frame) {
149
 
                s->coeff_model_dccv[pt][node] = def_prob[node];
 
151
                model->coeff_dccv[pt][node] = def_prob[node];
150
152
            }
151
153
 
152
154
    for (ct=0; ct<3; ct++)
155
157
                for (node=0; node<11; node++)
156
158
                    if (vp56_rac_get_prob(c, vp5_ract_pct[ct][pt][cg][node])) {
157
159
                        def_prob[node] = vp56_rac_gets_nn(c, 7);
158
 
                        s->coeff_model_ract[pt][ct][cg][node] = def_prob[node];
 
160
                        model->coeff_ract[pt][ct][cg][node] = def_prob[node];
159
161
                    } else if (s->framep[VP56_FRAME_CURRENT]->key_frame) {
160
 
                        s->coeff_model_ract[pt][ct][cg][node] = def_prob[node];
 
162
                        model->coeff_ract[pt][ct][cg][node] = def_prob[node];
161
163
                    }
162
164
 
163
 
    /* coeff_model_dcct is a linear combination of coeff_model_dccv */
 
165
    /* coeff_dcct is a linear combination of coeff_dccv */
164
166
    for (pt=0; pt<2; pt++)
165
167
        for (ctx=0; ctx<36; ctx++)
166
168
            for (node=0; node<5; node++)
167
 
                s->coeff_model_dcct[pt][ctx][node] = av_clip(((s->coeff_model_dccv[pt][node] * vp5_dccv_lc[node][ctx][0] + 128) >> 8) + vp5_dccv_lc[node][ctx][1], 1, 254);
 
169
                model->coeff_dcct[pt][ctx][node] = av_clip(((model->coeff_dccv[pt][node] * vp5_dccv_lc[node][ctx][0] + 128) >> 8) + vp5_dccv_lc[node][ctx][1], 1, 254);
168
170
 
169
 
    /* coeff_model_acct is a linear combination of coeff_model_ract */
 
171
    /* coeff_acct is a linear combination of coeff_ract */
170
172
    for (ct=0; ct<3; ct++)
171
173
        for (pt=0; pt<2; pt++)
172
174
            for (cg=0; cg<3; cg++)
173
175
                for (ctx=0; ctx<6; ctx++)
174
176
                    for (node=0; node<5; node++)
175
 
                        s->coeff_model_acct[pt][ct][cg][ctx][node] = av_clip(((s->coeff_model_ract[pt][ct][cg][node] * vp5_ract_lc[ct][cg][node][ctx][0] + 128) >> 8) + vp5_ract_lc[ct][cg][node][ctx][1], 1, 254);
 
177
                        model->coeff_acct[pt][ct][cg][ctx][node] = av_clip(((model->coeff_ract[pt][ct][cg][node] * vp5_ract_lc[ct][cg][node][ctx][0] + 128) >> 8) + vp5_ract_lc[ct][cg][node][ctx][1], 1, 254);
176
178
}
177
179
 
178
180
static void vp5_parse_coeff(vp56_context_t *s)
179
181
{
180
182
    vp56_range_coder_t *c = &s->c;
 
183
    vp56_model_t *model = s->modelp;
181
184
    uint8_t *permute = s->scantable.permutated;
182
 
    uint8_t *model, *model2;
 
185
    uint8_t *model1, *model2;
183
186
    int coeff, sign, coeff_idx;
184
187
    int b, i, cg, idx, ctx, ctx_last;
185
188
    int pt = 0;    /* plane type (0 for Y, 1 for U or V) */
191
194
 
192
195
        ctx = 6*s->coeff_ctx[vp56_b6to4[b]][0]
193
196
              + s->above_blocks[s->above_block_idx[b]].not_null_dc;
194
 
        model = s->coeff_model_dccv[pt];
195
 
        model2 = s->coeff_model_dcct[pt][ctx];
 
197
        model1 = model->coeff_dccv[pt];
 
198
        model2 = model->coeff_dcct[pt][ctx];
196
199
 
197
200
        for (coeff_idx=0; coeff_idx<64; ) {
198
201
            if (vp56_rac_get_prob(c, model2[0])) {
199
202
                if (vp56_rac_get_prob(c, model2[2])) {
200
203
                    if (vp56_rac_get_prob(c, model2[3])) {
201
204
                        s->coeff_ctx[vp56_b6to4[b]][coeff_idx] = 4;
202
 
                        idx = vp56_rac_get_tree(c, vp56_pc_tree, model);
 
205
                        idx = vp56_rac_get_tree(c, vp56_pc_tree, model1);
203
206
                        sign = vp56_rac_get(c);
204
 
                        coeff = vp56_coeff_bias[idx];
 
207
                        coeff = vp56_coeff_bias[idx+5];
205
208
                        for (i=vp56_coeff_bit_length[idx]; i>=0; i--)
206
209
                            coeff += vp56_rac_get_prob(c, vp56_coeff_parse_table[idx][i]) << i;
207
210
                    } else {
208
211
                        if (vp56_rac_get_prob(c, model2[4])) {
209
 
                            coeff = 3 + vp56_rac_get_prob(c, model[5]);
 
212
                            coeff = 3 + vp56_rac_get_prob(c, model1[5]);
210
213
                            s->coeff_ctx[vp56_b6to4[b]][coeff_idx] = 3;
211
214
                        } else {
212
215
                            coeff = 2;
234
237
 
235
238
            cg = vp5_coeff_groups[++coeff_idx];
236
239
            ctx = s->coeff_ctx[vp56_b6to4[b]][coeff_idx];
237
 
            model = s->coeff_model_ract[pt][ct][cg];
238
 
            model2 = cg > 2 ? model : s->coeff_model_acct[pt][ct][cg][ctx];
 
240
            model1 = model->coeff_ract[pt][ct][cg];
 
241
            model2 = cg > 2 ? model1 : model->coeff_acct[pt][ct][cg][ctx];
239
242
        }
240
243
 
241
244
        ctx_last = FFMIN(s->coeff_ctx_last[vp56_b6to4[b]], 24);
249
252
 
250
253
static void vp5_default_models_init(vp56_context_t *s)
251
254
{
 
255
    vp56_model_t *model = s->modelp;
252
256
    int i;
253
257
 
254
258
    for (i=0; i<2; i++) {
255
 
        s->vector_model_sig[i] = 0x80;
256
 
        s->vector_model_dct[i] = 0x80;
257
 
        s->vector_model_pdi[i][0] = 0x55;
258
 
        s->vector_model_pdi[i][1] = 0x80;
 
259
        model->vector_sig[i] = 0x80;
 
260
        model->vector_dct[i] = 0x80;
 
261
        model->vector_pdi[i][0] = 0x55;
 
262
        model->vector_pdi[i][1] = 0x80;
259
263
    }
260
 
    memcpy(s->mb_types_stats, vp56_def_mb_types_stats, sizeof(s->mb_types_stats));
261
 
    memset(s->vector_model_pdv, 0x80, sizeof(s->vector_model_pdv));
 
264
    memcpy(model->mb_types_stats, vp56_def_mb_types_stats, sizeof(model->mb_types_stats));
 
265
    memset(model->vector_pdv, 0x80, sizeof(model->vector_pdv));
262
266
}
263
267
 
264
 
static int vp5_decode_init(AVCodecContext *avctx)
 
268
static av_cold int vp5_decode_init(AVCodecContext *avctx)
265
269
{
266
270
    vp56_context_t *s = avctx->priv_data;
267
271
 
268
 
    vp56_init(s, avctx, 1);
 
272
    vp56_init(avctx, 1, 0);
269
273
    s->vp56_coord_div = vp5_coord_div;
270
274
    s->parse_vector_adjustment = vp5_parse_vector_adjustment;
271
275
    s->adjust = vp5_adjust;
287
291
    NULL,
288
292
    vp56_free,
289
293
    vp56_decode_frame,
 
294
    CODEC_CAP_DR1,
 
295
    .long_name = "On2 VP5",
290
296
};