[svn] / branches / dev-api-3 / vfw / src / 2pass.c Repository:
ViewVC logotype

Diff of /branches/dev-api-3/vfw/src/2pass.c

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

revision 660, Tue Nov 19 13:23:17 2002 UTC revision 714, Sat Dec 14 05:39:54 2002 UTC
# Line 49  Line 49 
49          double total2 = 0.0;          double total2 = 0.0;
50          double dbytes, dbytes2;          double dbytes, dbytes2;
51    
52            /* ensure free() is called safely */
53            codec->twopass.hintstream = NULL;
54            twopass->nns1_array = NULL;
55            twopass->nns2_array = NULL;
56    
57          if (codec->config.hinted_me)          if (codec->config.hinted_me)
58          {          {
59                  codec->twopass.hintstream = malloc(100000);                  codec->twopass.hintstream = malloc(100000);
# Line 337  Line 342 
342    
343                          twopass->movie_curve = ((double)(bframe_total_ext + pframe_total_ext + i_boost_total) /                          twopass->movie_curve = ((double)(bframe_total_ext + pframe_total_ext + i_boost_total) /
344                                  (bframe_total_ext + pframe_total_ext));                                  (bframe_total_ext + pframe_total_ext));
345    
346                            if (bframes)
347                          twopass->average_bframe = (double)bframe_total_ext / bframes / twopass->movie_curve;                          twopass->average_bframe = (double)bframe_total_ext / bframes / twopass->movie_curve;
348    
349                            if (pframes)
350                          twopass->average_pframe = (double)pframe_total_ext / pframes / twopass->movie_curve;                          twopass->average_pframe = (double)pframe_total_ext / pframes / twopass->movie_curve;
351                            else
352                                    if (bframes)
353                                            twopass->average_pframe = twopass->average_bframe;  // b-frame packed bitstream fix
354                                    else
355                                    {
356                                            DEBUGERR("ERROR:  No p-frames or b-frames were present in the 1st pass.  Rate control cannot function properly!");
357                                            return ICERR_ERROR;
358                                    }
359    
360    
361    
# Line 648  Line 665 
665                                  break;                                  break;
666                          }                          }
667    
668                            if (bframes)
669                          twopass->average_bframe = (double)bframe_total / bframes / twopass->movie_curve;                          twopass->average_bframe = (double)bframe_total / bframes / twopass->movie_curve;
670    
671                            if (pframes)
672                          twopass->average_pframe = (double)pframe_total / pframes / twopass->movie_curve;                          twopass->average_pframe = (double)pframe_total / pframes / twopass->movie_curve;
673                            else
674                                    if (bframes)
675                                            twopass->average_pframe = twopass->average_bframe;  // b-frame packed bitstream fix
676                                    else
677                                    {
678                                            DEBUGERR("ERROR:  No p-frames or b-frames were present in the 1st pass.  Rate control cannot function properly!");
679                                            return ICERR_ERROR;
680                                    }
681    
682    
683    
# Line 966  Line 994 
994          if (twopass->nns_array_pos >= twopass->nns_array_length)          if (twopass->nns_array_pos >= twopass->nns_array_length)
995          {          {
996                  twopass->nns_array_pos = 0;                  twopass->nns_array_pos = 0;
997                  DEBUG("ERROR: VIDEO EXCEEDS 1ST PASS!!!");                  DEBUGERR("ERROR: VIDEO EXCEEDS 1ST PASS!!!");
998                  frame->intra = -1;                  return ICERR_ERROR;
                 return 2;  
999          }          }
1000    
1001          memcpy(&twopass->nns1, &twopass->nns1_array[twopass->nns_array_pos], sizeof(NNSTATS));          memcpy(&twopass->nns1, &twopass->nns1_array[twopass->nns_array_pos], sizeof(NNSTATS));
# Line 1170  Line 1197 
1197                                                  }                                                  }
1198                                          }                                          }
1199                                  }                                  }
                                 curve_temp = curve_temp * twopass->curve_comp_scale + twopass->curve_bias_bonus;  
   
1200                                  if (twopass->nns1.dd_v & NNSTATS_BFRAME)                                  if (twopass->nns1.dd_v & NNSTATS_BFRAME)
1201                                          curve_temp *= twopass->average_bframe / twopass->average_pframe;                                          curve_temp *= twopass->average_bframe / twopass->average_pframe;
1202    
1203                                    curve_temp = curve_temp * twopass->curve_comp_scale + twopass->curve_bias_bonus;
1204    
1205                                  bytes2 += ((int)curve_temp);                                  bytes2 += ((int)curve_temp);
1206                                  curve_comp_error += curve_temp - ((int)curve_temp);                                  curve_comp_error += curve_temp - ((int)curve_temp);
1207                          }                          }
# Line 1430  Line 1457 
1457    
1458          if (capped_to_max_framesize == 0)          if (capped_to_max_framesize == 0)
1459          {          {
1460                  if (twopass->nns1.dd_v & NNSTATS_BFRAME)                  if (twopass->nns1.quant & NNSTATS_KEYFRAME)
1461                    {
1462                            last_bquant = frame->quant;
1463                            last_pquant = frame->quant;
1464                    }
1465                    else if (twopass->nns1.dd_v & NNSTATS_BFRAME)
1466                          last_bquant = frame->quant;                          last_bquant = frame->quant;
1467                  else                  else
1468                          last_pquant = frame->quant;                          last_pquant = frame->quant;
# Line 1588  Line 1620 
1620                  else if (codec->twopass.nns1.dd_v & NNSTATS_SKIPFRAME) {                  else if (codec->twopass.nns1.dd_v & NNSTATS_SKIPFRAME) {
1621                          frame_type="skipped";                          frame_type="skipped";
1622                          frame->quant = 2;                          frame->quant = 2;
1623                          codec->twopass.bytes1 = 8;                          codec->twopass.bytes1 = 1;
1624                          codec->twopass.desired_bytes2 = 8;                          codec->twopass.desired_bytes2 = 1;
1625                          frame->length = 8;                          frame->length = 1;
1626                  }                  }
1627                  else if (codec->twopass.nns1.dd_v & NNSTATS_PADFRAME) {                  else if (codec->twopass.nns1.dd_v & NNSTATS_PADFRAME) {
1628                          frame_type="padded";                          frame_type="padded";
1629                          frame->quant = 2;                          frame->quant = 2;
1630                          codec->twopass.bytes1 = 8;                          codec->twopass.bytes1 = 7;
1631                          codec->twopass.desired_bytes2 = 8;                          codec->twopass.desired_bytes2 = 7;
1632                          frame->length = 8;                          frame->length = 7;
1633                  }                  }
1634                  else if (codec->twopass.nns1.dd_v & NNSTATS_DELAYFRAME) {                  else if (codec->twopass.nns1.dd_v & NNSTATS_DELAYFRAME) {
1635                          frame_type="delayed";                          frame_type="delayed";
1636                          frame->quant = 2;                          frame->quant = 2;
1637                          codec->twopass.bytes1 = 8;                          codec->twopass.bytes1 = 1;
1638                          codec->twopass.desired_bytes2 = 8;                          codec->twopass.desired_bytes2 = 1;
1639                          frame->length = 8;                          frame->length = 1;
1640                  }                  }
1641    
1642                  DEBUG2ND(frame->quant, quant_type, frame_type, codec->twopass.bytes1, codec->twopass.desired_bytes2, frame->length, codec->twopass.overflow, credits_pos)                  DEBUG2ND(frame->quant, quant_type, frame_type, codec->twopass.bytes1, codec->twopass.desired_bytes2, frame->length, codec->twopass.overflow, credits_pos)
# Line 1623  Line 1655 
1655          char s[100];          char s[100];
1656    
1657          if (codec->twopass.nns1_array)          if (codec->twopass.nns1_array)
1658            {
1659                  free(codec->twopass.nns1_array);                  free(codec->twopass.nns1_array);
1660                    codec->twopass.nns1_array = NULL;
1661            }
1662          if (codec->twopass.nns2_array)          if (codec->twopass.nns2_array)
1663            {
1664                  free(codec->twopass.nns2_array);                  free(codec->twopass.nns2_array);
1665                    codec->twopass.nns2_array = NULL;
1666            }
1667          codec->twopass.nns_array_size = 0;          codec->twopass.nns_array_size = 0;
1668          codec->twopass.nns_array_length = 0;          codec->twopass.nns_array_length = 0;
1669          codec->twopass.nns_array_pos = 0;          codec->twopass.nns_array_pos = 0;

Legend:
Removed from v.660  
changed lines
  Added in v.714

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