[cvs] / xvidcore / src / decoder.c Repository:
ViewVC logotype

Diff of /xvidcore/src/decoder.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.78, Mon Mar 27 11:21:48 2006 UTC revision 1.82, Tue Aug 10 14:17:23 2010 UTC
# Line 197  Line 197 
197    dec->time_inc_resolution = 1; /* until VOL header says otherwise */    dec->time_inc_resolution = 1; /* until VOL header says otherwise */
198    dec->ver_id = 1;    dec->ver_id = 1;
199    
200      if (create->fourcc == ((int)('X')|((int)('V')<<8)|
201                             ((int)('I')<<16)|((int)('D')<<24))) { /* XVID */
202        dec->bs_version = 1; /* Initially assume oldest xvid version */
203      }
204      else {
205    dec->bs_version = 0xffff; /* Initialize to very high value -> assume bugfree stream */    dec->bs_version = 0xffff; /* Initialize to very high value -> assume bugfree stream */
206      }
207    
208    dec->fixed_dimensions = (dec->width > 0 && dec->height > 0);    dec->fixed_dimensions = (dec->width > 0 && dec->height > 0);
209    
210    if (dec->fixed_dimensions)    if (dec->fixed_dimensions) {
211      return decoder_resize(dec);      int ret = decoder_resize(dec);
212        if (ret == XVID_ERR_MEMORY) create->handle = NULL;
213        return ret;
214      }
215    else    else
216      return 0;      return 0;
217  }  }
# Line 748  Line 757 
757          bound = read_video_packet_header(bs, dec, 0,          bound = read_video_packet_header(bs, dec, 0,
758                &quant, NULL, NULL, &intra_dc_threshold);                &quant, NULL, NULL, &intra_dc_threshold);
759          x = bound % mb_width;          x = bound % mb_width;
760          y = bound / mb_width;          y = MIN((bound / mb_width), (mb_height-1));
761        }        }
762        mb = &dec->mbs[y * dec->mb_width + x];        mb = &dec->mbs[y * dec->mb_width + x];
763    
# Line 975  Line 984 
984          bound = read_video_packet_header(bs, dec, fcode - 1,          bound = read_video_packet_header(bs, dec, fcode - 1,
985            &quant, &fcode, NULL, &intra_dc_threshold);            &quant, &fcode, NULL, &intra_dc_threshold);
986          x = bound % mb_width;          x = bound % mb_width;
987          y = bound / mb_width;          y = MIN((bound / mb_width), (mb_height-1));
988        }        }
989        mb = &dec->mbs[y * dec->mb_width + x];        mb = &dec->mbs[y * dec->mb_width + x];
990    
# Line 1335  Line 1344 
1344    return -1;    return -1;
1345  }  }
1346    
1347    static int __inline get_resync_len_b(const int fcode_backward,
1348                                         const int fcode_forward) {
1349      int resync_len = ((fcode_forward>fcode_backward) ? fcode_forward : fcode_backward) - 1;
1350      if (resync_len < 1) resync_len = 1;
1351      return resync_len;
1352    }
1353    
1354  static void  static void
1355  decoder_bframe(DECODER * dec,  decoder_bframe(DECODER * dec,
1356          Bitstream * bs,          Bitstream * bs,
# Line 1346  Line 1362 
1362    VECTOR mv;    VECTOR mv;
1363    const VECTOR zeromv = {0,0};    const VECTOR zeromv = {0,0};
1364    int i;    int i;
1365      int resync_len;
1366    
1367    if (!dec->is_edged[0]) {    if (!dec->is_edged[0]) {
1368      start_timer();      start_timer();
# Line 1363  Line 1380 
1380      stop_edges_timer();      stop_edges_timer();
1381    }    }
1382    
1383      resync_len = get_resync_len_b(fcode_backward, fcode_forward);
1384    for (y = 0; y < dec->mb_height; y++) {    for (y = 0; y < dec->mb_height; y++) {
1385      /* Initialize Pred Motion Vector */      /* Initialize Pred Motion Vector */
1386      dec->p_fmv = dec->p_bmv = zeromv;      dec->p_fmv = dec->p_bmv = zeromv;
1387      for (x = 0; x < dec->mb_width; x++) {      for (x = 0; x < dec->mb_width; x++) {
1388        MACROBLOCK *mb = &dec->mbs[y * dec->mb_width + x];        MACROBLOCK *mb = &dec->mbs[y * dec->mb_width + x];
1389        MACROBLOCK *last_mb = &dec->last_mbs[y * dec->mb_width + x];        MACROBLOCK *last_mb = &dec->last_mbs[y * dec->mb_width + x];
       const int fcode_max = (fcode_forward>fcode_backward) ? fcode_forward : fcode_backward;  
1390        int intra_dc_threshold; /* fake variable */        int intra_dc_threshold; /* fake variable */
1391    
1392        if (check_resync_marker(bs, fcode_max  - 1)) {        if (check_resync_marker(bs, resync_len)) {
1393          int bound = read_video_packet_header(bs, dec, fcode_max - 1, &quant,          int bound = read_video_packet_header(bs, dec, resync_len, &quant,
1394                             &fcode_forward, &fcode_backward, &intra_dc_threshold);                             &fcode_forward, &fcode_backward, &intra_dc_threshold);
1395          x = bound % dec->mb_width;          x = bound % dec->mb_width;
1396          y = bound / dec->mb_width;          y = MIN((bound / dec->mb_width), (dec->mb_height-1));
1397          /* reset predicted macroblocks */          /* reset predicted macroblocks */
1398          dec->p_fmv = dec->p_bmv = zeromv;          dec->p_fmv = dec->p_bmv = zeromv;
1399            /* update resync len with new fcodes */
1400            resync_len = get_resync_len_b(fcode_backward, fcode_forward);
1401        }        }
1402    
1403        mv =        mv =
# Line 1618  Line 1637 
1637    if (coding_type == -2 || coding_type == -3) { /* vol and/or resize */    if (coding_type == -2 || coding_type == -3) { /* vol and/or resize */
1638    
1639      if (coding_type == -3)      if (coding_type == -3)
1640        decoder_resize(dec);        if (decoder_resize(dec)) return XVID_ERR_MEMORY;
1641    
1642      if(stats) {      if(stats) {
1643        stats->type = XVID_TYPE_VOL;        stats->type = XVID_TYPE_VOL;

Legend:
Removed from v.1.78  
changed lines
  Added in v.1.82

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4