26 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
27 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
28 |
* |
* |
29 |
* $Id: encoder.c,v 1.95.2.1 2003-02-22 08:49:44 suxen_drol Exp $ |
* $Id: encoder.c,v 1.95.2.3 2003-03-10 00:38:49 edgomez Exp $ |
30 |
* |
* |
31 |
****************************************************************************/ |
****************************************************************************/ |
32 |
|
|
634 |
* Returned values : |
* Returned values : |
635 |
* - >0 - output bytes |
* - >0 - output bytes |
636 |
* - 0 - no output |
* - 0 - no output |
637 |
|
* - XVID_ERR_VERSION - wrong version passed to core |
638 |
|
* - XVID_ERR_END - End of stream reached before end of coding |
639 |
* - XVID_ERR_FORMAT - the image subsystem reported the image had a wrong |
* - XVID_ERR_FORMAT - the image subsystem reported the image had a wrong |
640 |
* format |
* format |
641 |
****************************************************************************/ |
****************************************************************************/ |
720 |
pEnc->bframenum_head, pEnc->bframenum_tail, |
pEnc->bframenum_head, pEnc->bframenum_tail, |
721 |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
722 |
|
|
723 |
|
if (pEnc->bframes[pEnc->bframenum_head]->vop_flags & XVID_EXTRASTATS) { |
724 |
|
image_copy(&pEnc->sOriginal, &pEnc->bframes[pEnc->bframenum_head]->image, |
725 |
|
pEnc->mbParam.edged_width, pEnc->mbParam.height); |
726 |
|
} |
727 |
|
|
728 |
FrameCodeB(pEnc, pEnc->bframes[pEnc->bframenum_head], &bs); |
FrameCodeB(pEnc, pEnc->bframes[pEnc->bframenum_head], &bs); |
729 |
|
|
730 |
|
if (pEnc->bframes[pEnc->bframenum_head]->vop_flags & XVID_EXTRASTATS) { |
731 |
|
stats->sse_y = |
732 |
|
plane_sse( pEnc->sOriginal.y, pEnc->bframes[pEnc->bframenum_head]->image.y, |
733 |
|
pEnc->mbParam.edged_width, pEnc->mbParam.width, |
734 |
|
pEnc->mbParam.height); |
735 |
|
|
736 |
|
stats->sse_u = |
737 |
|
plane_sse( pEnc->sOriginal.u, pEnc->bframes[pEnc->bframenum_head]->image.u, |
738 |
|
pEnc->mbParam.edged_width/2, pEnc->mbParam.width/2, |
739 |
|
pEnc->mbParam.height/2); |
740 |
|
|
741 |
|
stats->sse_v = |
742 |
|
plane_sse( pEnc->sOriginal.v, pEnc->bframes[pEnc->bframenum_head]->image.v, |
743 |
|
pEnc->mbParam.edged_width/2, pEnc->mbParam.width/2, |
744 |
|
pEnc->mbParam.height/2); |
745 |
|
} |
746 |
|
|
747 |
set_stats(stats, &pEnc->rate_control, &pEnc->mbParam, pEnc->bframes[pEnc->bframenum_head]); |
set_stats(stats, &pEnc->rate_control, &pEnc->mbParam, pEnc->bframes[pEnc->bframenum_head]); |
748 |
|
|
749 |
pEnc->bframenum_head++; |
pEnc->bframenum_head++; |
847 |
pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.edged_width); |
pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.edged_width); |
848 |
} |
} |
849 |
|
|
850 |
if (xFrame->vop_flags & XVID_EXTRASTATS) |
if (xFrame->vop_flags & XVID_EXTRASTATS) { |
851 |
{ image_copy(&pEnc->sOriginal, &pEnc->current->image, |
image_copy(&pEnc->sOriginal, &pEnc->current->image, |
852 |
pEnc->mbParam.edged_width, pEnc->mbParam.height); |
pEnc->mbParam.edged_width, pEnc->mbParam.height); |
853 |
} |
} |
854 |
|
|
1031 |
|
|
1032 |
} |
} |
1033 |
|
|
1034 |
if (xFrame->vop_flags & XVID_EXTRASTATS) |
if (xFrame->vop_flags & XVID_EXTRASTATS) { |
1035 |
{ stats->sse_y = |
stats->sse_y = |
1036 |
plane_sse( pEnc->sOriginal.y, pEnc->current->image.y, |
plane_sse( pEnc->sOriginal.y, pEnc->current->image.y, |
1037 |
pEnc->mbParam.edged_width, pEnc->mbParam.width, |
pEnc->mbParam.edged_width, pEnc->mbParam.width, |
1038 |
pEnc->mbParam.height); |
pEnc->mbParam.height); |
1054 |
|
|
1055 |
done_flush: |
done_flush: |
1056 |
|
|
1057 |
|
#if 0 |
1058 |
{ |
{ |
1059 |
char tmp[100]; |
char tmp[100]; |
1060 |
wsprintf(tmp,"\\frame%03i.pgm", pEnc->m_framenum); |
wsprintf(tmp,"\\frame%03i.pgm", pEnc->m_framenum); |
1061 |
image_dump_yuvpgm(&pEnc->current->image, pEnc->mbParam.edged_width, |
image_dump_yuvpgm(&pEnc->current->image, pEnc->mbParam.edged_width, |
1062 |
pEnc->mbParam.width, pEnc->mbParam.height, tmp); |
pEnc->mbParam.width, pEnc->mbParam.height, tmp); |
1063 |
} |
} |
1064 |
|
#endif |
1065 |
|
|
1066 |
/* packed_mode: repeat */ |
/* packed_mode: repeat */ |
1067 |
pEnc->flush_bframes = 1; |
pEnc->flush_bframes = 1; |
1724 |
mb->quant = frame->quant; |
mb->quant = frame->quant; |
1725 |
|
|
1726 |
mb->cbp = |
mb->cbp = |
1727 |
MBTransQuantInterBVOP(&pEnc->mbParam, frame, mb, dct_codes, qcoeff); |
MBTransQuantInterBVOP(&pEnc->mbParam, frame, mb, x, y, dct_codes, qcoeff); |
1728 |
|
|
1729 |
if ( (mb->mode == MODE_DIRECT) && (mb->cbp == 0) |
if ( (mb->mode == MODE_DIRECT) && (mb->cbp == 0) |
1730 |
&& (mb->pmvs[3].x == 0) && (mb->pmvs[3].y == 0) ) { |
&& (mb->pmvs[3].x == 0) && (mb->pmvs[3].y == 0) ) { |