[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 679, Wed Nov 27 11:41:45 2002 UTC
# Line 337  Line 337 
337    
338                          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) /
339                                  (bframe_total_ext + pframe_total_ext));                                  (bframe_total_ext + pframe_total_ext));
340    
341                            if (bframes)
342                          twopass->average_bframe = (double)bframe_total_ext / bframes / twopass->movie_curve;                          twopass->average_bframe = (double)bframe_total_ext / bframes / twopass->movie_curve;
343    
344                            if (pframes)
345                          twopass->average_pframe = (double)pframe_total_ext / pframes / twopass->movie_curve;                          twopass->average_pframe = (double)pframe_total_ext / pframes / twopass->movie_curve;
346                            else
347                                    if (bframes)
348                                            twopass->average_pframe = twopass->average_bframe;  // b-frame packed bitstream fix
349                                    else
350                                    {
351                                            DEBUGERR("ERROR:  No p-frames or b-frames were present in the 1st pass.  Rate control cannot function properly!");
352                                            return ICERR_ERROR;
353                                    }
354    
355    
356    
# Line 966  Line 978 
978          if (twopass->nns_array_pos >= twopass->nns_array_length)          if (twopass->nns_array_pos >= twopass->nns_array_length)
979          {          {
980                  twopass->nns_array_pos = 0;                  twopass->nns_array_pos = 0;
981                  DEBUG("ERROR: VIDEO EXCEEDS 1ST PASS!!!");                  DEBUGERR("ERROR: VIDEO EXCEEDS 1ST PASS!!!");
982                  frame->intra = -1;                  return ICERR_ERROR;
                 return 2;  
983          }          }
984    
985          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 1181 
1181                                                  }                                                  }
1182                                          }                                          }
1183                                  }                                  }
                                 curve_temp = curve_temp * twopass->curve_comp_scale + twopass->curve_bias_bonus;  
   
1184                                  if (twopass->nns1.dd_v & NNSTATS_BFRAME)                                  if (twopass->nns1.dd_v & NNSTATS_BFRAME)
1185                                          curve_temp *= twopass->average_bframe / twopass->average_pframe;                                          curve_temp *= twopass->average_bframe / twopass->average_pframe;
1186    
1187                                    curve_temp = curve_temp * twopass->curve_comp_scale + twopass->curve_bias_bonus;
1188    
1189                                  bytes2 += ((int)curve_temp);                                  bytes2 += ((int)curve_temp);
1190                                  curve_comp_error += curve_temp - ((int)curve_temp);                                  curve_comp_error += curve_temp - ((int)curve_temp);
1191                          }                          }
# Line 1430  Line 1441 
1441    
1442          if (capped_to_max_framesize == 0)          if (capped_to_max_framesize == 0)
1443          {          {
1444                  if (twopass->nns1.dd_v & NNSTATS_BFRAME)                  if (twopass->nns1.quant & NNSTATS_KEYFRAME)
1445                    {
1446                            last_bquant = frame->quant;
1447                            last_pquant = frame->quant;
1448                    }
1449                    else if (twopass->nns1.dd_v & NNSTATS_BFRAME)
1450                          last_bquant = frame->quant;                          last_bquant = frame->quant;
1451                  else                  else
1452                          last_pquant = frame->quant;                          last_pquant = frame->quant;
# Line 1588  Line 1604 
1604                  else if (codec->twopass.nns1.dd_v & NNSTATS_SKIPFRAME) {                  else if (codec->twopass.nns1.dd_v & NNSTATS_SKIPFRAME) {
1605                          frame_type="skipped";                          frame_type="skipped";
1606                          frame->quant = 2;                          frame->quant = 2;
1607                          codec->twopass.bytes1 = 8;                          codec->twopass.bytes1 = 1;
1608                          codec->twopass.desired_bytes2 = 8;                          codec->twopass.desired_bytes2 = 1;
1609                          frame->length = 8;                          frame->length = 1;
1610                  }                  }
1611                  else if (codec->twopass.nns1.dd_v & NNSTATS_PADFRAME) {                  else if (codec->twopass.nns1.dd_v & NNSTATS_PADFRAME) {
1612                          frame_type="padded";                          frame_type="padded";
1613                          frame->quant = 2;                          frame->quant = 2;
1614                          codec->twopass.bytes1 = 8;                          codec->twopass.bytes1 = 7;
1615                          codec->twopass.desired_bytes2 = 8;                          codec->twopass.desired_bytes2 = 7;
1616                          frame->length = 8;                          frame->length = 7;
1617                  }                  }
1618                  else if (codec->twopass.nns1.dd_v & NNSTATS_DELAYFRAME) {                  else if (codec->twopass.nns1.dd_v & NNSTATS_DELAYFRAME) {
1619                          frame_type="delayed";                          frame_type="delayed";
1620                          frame->quant = 2;                          frame->quant = 2;
1621                          codec->twopass.bytes1 = 8;                          codec->twopass.bytes1 = 1;
1622                          codec->twopass.desired_bytes2 = 8;                          codec->twopass.desired_bytes2 = 1;
1623                          frame->length = 8;                          frame->length = 1;
1624                  }                  }
1625    
1626                  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 1639 
1639          char s[100];          char s[100];
1640    
1641          if (codec->twopass.nns1_array)          if (codec->twopass.nns1_array)
1642            {
1643                  free(codec->twopass.nns1_array);                  free(codec->twopass.nns1_array);
1644                    codec->twopass.nns1_array = NULL;
1645            }
1646          if (codec->twopass.nns2_array)          if (codec->twopass.nns2_array)
1647            {
1648                  free(codec->twopass.nns2_array);                  free(codec->twopass.nns2_array);
1649                    codec->twopass.nns2_array = NULL;
1650            }
1651          codec->twopass.nns_array_size = 0;          codec->twopass.nns_array_size = 0;
1652          codec->twopass.nns_array_length = 0;          codec->twopass.nns_array_length = 0;
1653          codec->twopass.nns_array_pos = 0;          codec->twopass.nns_array_pos = 0;

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

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