21 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
22 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 |
* |
* |
24 |
* $Id: encoder.c,v 1.95.2.54 2003-11-19 15:42:38 syskin Exp $ |
* $Id: encoder.c,v 1.95.2.55 2003-11-20 12:07:19 syskin Exp $ |
25 |
* |
* |
26 |
****************************************************************************/ |
****************************************************************************/ |
27 |
|
|
776 |
frame->mbs[j*pEnc->mbParam.mb_width + i].dquant = 0; |
frame->mbs[j*pEnc->mbParam.mb_width + i].dquant = 0; |
777 |
} |
} |
778 |
} |
} |
779 |
frame->mbs[0].quant = data.quant; /* BEFORE2 will not affect the quant in stats */ |
frame->mbs[0].quant = data.quant; /* FRAME will not affect the quant in stats */ |
780 |
} |
} |
781 |
|
|
782 |
|
|
783 |
} |
} |
784 |
|
|
785 |
|
|
|
|
|
|
|
|
786 |
static __inline void inc_frame_num(Encoder * pEnc) |
static __inline void inc_frame_num(Encoder * pEnc) |
787 |
{ |
{ |
788 |
pEnc->current->frame_num = pEnc->m_framenum; |
pEnc->current->frame_num = pEnc->m_framenum; |
798 |
pEnc->m_framenum--; /* debug ticker */ |
pEnc->m_framenum--; /* debug ticker */ |
799 |
} |
} |
800 |
|
|
801 |
|
static __inline void |
802 |
|
MBSetDquant(MACROBLOCK * pMB, int x, int y, MBParam * mbParam) |
803 |
|
{ |
804 |
|
if (pMB->cbp == 0) { |
805 |
|
/* we want to code dquant but the quantizer value will not be used yet |
806 |
|
let's find out if we can postpone dquant to next MB |
807 |
|
*/ |
808 |
|
if (x == mbParam->mb_width-1 && y == mbParam->mb_height-1) { |
809 |
|
pMB->dquant = 0; /* it's the last MB of all, the easiest case */ |
810 |
|
return; |
811 |
|
} else { |
812 |
|
MACROBLOCK * next = pMB + 1; |
813 |
|
const MACROBLOCK * prev = pMB - 1; |
814 |
|
if (next->mode != MODE_INTER4V && next->mode != MODE_NOT_CODED) |
815 |
|
/* mode allows dquant change in the future */ |
816 |
|
if (abs(next->quant - prev->quant) <= 2) { |
817 |
|
/* quant change is not out of range */ |
818 |
|
pMB->quant = prev->quant; |
819 |
|
pMB->dquant = 0; |
820 |
|
next->dquant = next->quant - prev->quant; |
821 |
|
return; |
822 |
|
} |
823 |
|
} |
824 |
|
} |
825 |
|
/* couldn't skip this dquant */ |
826 |
|
pMB->mode = MODE_INTER_Q; |
827 |
|
} |
828 |
|
|
829 |
|
|
830 |
|
|
831 |
static __inline void |
static __inline void |
1629 |
|
|
1630 |
stop_comp_timer(); |
stop_comp_timer(); |
1631 |
|
|
|
if (pMB->dquant != 0) { |
|
|
pMB->mode = MODE_INTER_Q; |
|
|
} |
|
|
|
|
1632 |
pMB->field_pred = 0; |
pMB->field_pred = 0; |
1633 |
|
|
1634 |
if (pMB->mode != MODE_NOT_CODED) |
if (pMB->mode != MODE_NOT_CODED) |
1637 |
dct_codes, qcoeff); |
dct_codes, qcoeff); |
1638 |
} |
} |
1639 |
|
|
1640 |
|
if (pMB->dquant != 0) |
1641 |
|
MBSetDquant(pMB, x, y, &pEnc->mbParam); |
1642 |
|
|
1643 |
|
|
1644 |
if (pMB->cbp || pMB->mvs[0].x || pMB->mvs[0].y || |
if (pMB->cbp || pMB->mvs[0].x || pMB->mvs[0].y || |
1645 |
pMB->mvs[1].x || pMB->mvs[1].y || pMB->mvs[2].x || |
pMB->mvs[1].x || pMB->mvs[1].y || pMB->mvs[2].x || |
1646 |
pMB->mvs[2].y || pMB->mvs[3].x || pMB->mvs[3].y) { |
pMB->mvs[2].y || pMB->mvs[3].x || pMB->mvs[3].y) { |