--- trunk/xvidcore/src/encoder.c 2006/02/24 14:18:59 1684 +++ trunk/xvidcore/src/encoder.c 2010/11/28 15:19:07 1909 @@ -3,9 +3,9 @@ * XVID MPEG-4 VIDEO CODEC * - Encoder main module - * - * Copyright(C) 2002 Michael Militzer - * 2002-2003 Peter Ross - * 2002 Daniel Smith + * Copyright(C) 2002-2010 Michael Militzer + * 2002-2003 Peter Ross + * 2002 Daniel Smith * * This program is free software ; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -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.127 2006-02-24 14:18:59 syskin Exp $ + * $Id: encoder.c,v 1.133 2010-11-28 15:18:21 Isibaar Exp $ * ****************************************************************************/ @@ -435,7 +435,7 @@ /* timestamp stuff */ pEnc->mbParam.m_stamp = 0; - pEnc->m_framenum = 0; + pEnc->m_framenum = create->start_frame_num; pEnc->current->stamp = 0; pEnc->reference->stamp = 0; @@ -662,6 +662,9 @@ xvid_free(pEnc->temp_dquants); } + if ((pEnc->mbParam.plugin_flags & XVID_REQLAMBDA)) { + xvid_free(pEnc->temp_lambda); + } if (pEnc->num_plugins>0) { xvid_plg_destroy_t pdestroy; @@ -767,6 +770,7 @@ if(pEnc->mbParam.plugin_flags & XVID_REQLAMBDA) { int block = 0; + emms(); data.lambda = pEnc->temp_lambda; for(i = 0;i < pEnc->mbParam.mb_height; i++) for(j = 0;j < pEnc->mbParam.mb_width; j++) @@ -884,13 +888,13 @@ for (k = 0; k < 6; k++) { frame->mbs[j*pEnc->mbParam.mb_width + i].lambda[k] = (int) ((float)(1<mbParam.mb_height; j++) for (i = 0; imbParam.mb_width; i++) for (k = 0; k < 6; k++) { frame->mbs[j*pEnc->mbParam.mb_width + i].lambda[k] = 1<current->stamp > 0) { call_plugins(pEnc, pEnc->reference, &pEnc->sOriginal, XVID_PLG_AFTER, NULL, NULL, stats); } - else - stats->type = XVID_TYPE_NOTHING; + else if (stats) { + stats->type = XVID_TYPE_NOTHING; + } } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1651,6 +1655,11 @@ current->coding_type = P_VOP; + if (current->vop_flags & XVID_VOP_RD_PSNRHVSM) { + image_block_variance(¤t->image, pParam->edged_width, current->mbs, + pParam->mb_width, pParam->mb_height); + } + call_plugins(pEnc, pEnc->current, NULL, XVID_PLG_FRAME, NULL, NULL, NULL); SetMacroblockQuants(&pEnc->mbParam, current); @@ -1879,7 +1888,7 @@ #if 0 DPRINTF(XVID_DEBUG_DEBUG, "kmu %i %i %i\n", current->sStat.kblks, current->sStat.mblks, current->sStat.ublks); #endif - if (current->sStat.kblks + current->sStat.mblks <= + 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)) ) { @@ -1998,6 +2007,12 @@ } 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, + pEnc->mbParam.mb_width, pEnc->mbParam.mb_height); + } + call_plugins(pEnc, frame, NULL, XVID_PLG_FRAME, NULL, NULL, NULL); frame->fcode = frame->bcode = pEnc->current->fcode; @@ -2034,7 +2049,7 @@ pthread_create(&pEnc->motionData[k].handle, NULL, (void*)SMPMotionEstimationBVOP, (void*)&pEnc->motionData[k]); } - + SMPMotionEstimationBVOP(&pEnc->motionData[0]); for (k = 1; k < pEnc->num_threads; k++) {