--- encoder.c 2010/12/28 19:19:43 1.136 +++ encoder.c 2011/03/08 19:16:26 1.140 @@ -21,7 +21,7 @@ * along with this program ; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: encoder.c,v 1.136 2010/12/28 19:19:43 Isibaar Exp $ + * $Id: encoder.c,v 1.140 2011/03/08 19:16:26 Isibaar Exp $ * ****************************************************************************/ @@ -1609,7 +1609,8 @@ memcpy((void *)((ptr_t)bs->start + pos), (void *)((ptr_t)pEnc->smpData[k].bs->start), len); - current->length = pos += len; + current->length += len; + pos += len; /* collect stats */ current->sStat.iTextBits += pEnc->smpData[k].sStat->iTextBits; @@ -1916,7 +1917,7 @@ if (!reference->is_edged) { start_timer(); image_setedges(pRef, pParam->edged_width, pParam->edged_height, - pParam->width, pParam->height, 0); + pParam->width, pParam->height, XVID_BS_VERSION); stop_edges_timer(); reference->is_edged = 1; } @@ -2129,7 +2130,8 @@ if (current->sStat.kblks + current->sStat.mblks < (pParam->frame_drop_ratio * mb_width * mb_height) / 100 && - ( (pEnc->bframenum_head >= pEnc->bframenum_tail) || !(pEnc->mbParam.global_flags & XVID_GLOBAL_CLOSED_GOP)) ) + ( (pEnc->bframenum_head >= pEnc->bframenum_tail) || !(pEnc->mbParam.global_flags & XVID_GLOBAL_CLOSED_GOP)) && + (current->coding_type == P_VOP) ) { current->sStat.kblks = current->sStat.mblks = current->sStat.iTextBits = 0; current->sStat.ublks = mb_width * mb_height; @@ -2301,8 +2303,8 @@ if (!pEnc->reference->is_edged) { image_setedges(f_ref, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height, pEnc->mbParam.width, - pEnc->mbParam.height, 0); - pEnc->current->is_edged = 1; + pEnc->mbParam.height, XVID_BS_VERSION); + pEnc->reference->is_edged = 1; } if (pEnc->reference->is_interpolated != 0) { @@ -2318,7 +2320,7 @@ if (!pEnc->current->is_edged) { image_setedges(b_ref, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height, pEnc->mbParam.width, - pEnc->mbParam.height, 0); + pEnc->mbParam.height, XVID_BS_VERSION); pEnc->current->is_edged = 1; } @@ -2333,8 +2335,8 @@ frame->coding_type = B_VOP; - if (pEnc->current->vop_flags & XVID_VOP_RD_PSNRHVSM) { - image_block_variance(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->current->mbs, + if ((frame->vop_flags & XVID_VOP_RD_PSNRHVSM) && (frame->vop_flags & XVID_VOP_RD_BVOP)) { + image_block_variance(&frame->image, pEnc->mbParam.edged_width, frame->mbs, pEnc->mbParam.mb_width, pEnc->mbParam.mb_height); }