Revision 36e16253 libavcodec/vp3.c

View differences:

libavcodec/vp3.c
150 150
    /* this is the macroblock that the fragment belongs to */
151 151
    uint16_t macroblock;
152 152
    uint8_t coding_method;
153
    uint8_t coeff_count;
154 153
    int8_t motion_x;
155 154
    int8_t motion_y;
156 155
} Vp3Fragment;
......
255 254
    int fragment_height;
256 255

  
257 256
    Vp3Fragment *all_fragments;
257
    uint8_t *coeff_counts;
258 258
    Coeff *coeffs;
259 259
    Coeff *next_coeff;
260 260
    int fragment_start[3];
......
588 588
    /* zero out all of the fragment information */
589 589
    s->coded_fragment_list_index = 0;
590 590
    for (i = 0; i < s->fragment_count; i++) {
591
        s->all_fragments[i].coeff_count = 0;
591
        s->coeff_counts[i] = 0;
592 592
        s->all_fragments[i].motion_x = 127;
593 593
        s->all_fragments[i].motion_y = 127;
594 594
        s->all_fragments[i].next_coeff= NULL;
......
1160 1160
    }
1161 1161

  
1162 1162
    for (i = first_fragment; i <= last_fragment; i++) {
1163
        int fragment_num = s->coded_fragment_list[i];
1163 1164

  
1164
        fragment = &s->all_fragments[s->coded_fragment_list[i]];
1165
        if (fragment->coeff_count > coeff_index)
1165
        if (s->coeff_counts[fragment_num] > coeff_index)
1166 1166
            continue;
1167
        fragment = &s->all_fragments[fragment_num];
1167 1168

  
1168 1169
        if (!eob_run) {
1169 1170
            /* decode a VLC into a token */
......
1189 1190
        }
1190 1191

  
1191 1192
        if (!eob_run) {
1192
            fragment->coeff_count += zero_run;
1193
            if (fragment->coeff_count < 64){
1193
            s->coeff_counts[fragment_num] += zero_run;
1194
            if (s->coeff_counts[fragment_num] < 64){
1194 1195
                fragment->next_coeff->coeff= coeff;
1195
                fragment->next_coeff->index= perm[fragment->coeff_count++]; //FIXME perm here already?
1196
                fragment->next_coeff->index= perm[s->coeff_counts[fragment_num]++]; //FIXME perm here already?
1196 1197
                fragment->next_coeff->next= s->next_coeff;
1197 1198
                s->next_coeff->next=NULL;
1198 1199
                fragment->next_coeff= s->next_coeff++;
......
1200 1201
            debug_vlc(" fragment %d coeff = %d\n",
1201 1202
                s->coded_fragment_list[i], fragment->next_coeff[coeff_index]);
1202 1203
        } else {
1203
            fragment->coeff_count |= 128;
1204
            s->coeff_counts[fragment_num] |= 128;
1204 1205
            debug_vlc(" fragment %d eob with %d coefficients\n",
1205
                s->coded_fragment_list[i], fragment->coeff_count&127);
1206
                s->coded_fragment_list[i], s->coeff_counts[fragment_num]&127);
1206 1207
            eob_run--;
1207 1208
        }
1208 1209
    }
......
1474 1475
                s->coeffs[i].coeff += predicted_dc;
1475 1476
                /* save the DC */
1476 1477
                last_dc[current_frame_type] = DC_COEFF(i);
1477
                if(DC_COEFF(i) && !(s->all_fragments[i].coeff_count&127)){
1478
                    s->all_fragments[i].coeff_count= 129;
1478
                if(DC_COEFF(i) && !(s->coeff_counts[i]&127)){
1479
                    s->coeff_counts[i]= 129;
1479 1480
//                    s->all_fragments[i].next_coeff= s->next_coeff;
1480 1481
                    s->coeffs[i].next= s->next_coeff;
1481 1482
                    (s->next_coeff++)->next=NULL;
......
2007 2008
        s->fragment_start[2]);
2008 2009

  
2009 2010
    s->all_fragments = av_malloc(s->fragment_count * sizeof(Vp3Fragment));
2011
    s->coeff_counts = av_malloc(s->fragment_count * sizeof(*s->coeff_counts));
2010 2012
    s->coeffs = av_malloc(s->fragment_count * sizeof(Coeff) * 65);
2011 2013
    s->coded_fragment_list = av_malloc(s->fragment_count * sizeof(int));
2012 2014
    s->pixel_addresses_initialized = 0;
......
2317 2319

  
2318 2320
    av_free(s->superblock_coding);
2319 2321
    av_free(s->all_fragments);
2322
    av_free(s->coeff_counts);
2320 2323
    av_free(s->coeffs);
2321 2324
    av_free(s->coded_fragment_list);
2322 2325
    av_free(s->superblock_fragments);

Also available in: Unified diff