39 |
* MinChen <chenm001@163.com> |
* MinChen <chenm001@163.com> |
40 |
* 14.04.2002 added FrameCodeB() |
* 14.04.2002 added FrameCodeB() |
41 |
* |
* |
42 |
* $Id: encoder.c,v 1.76.2.15 2002-11-02 16:12:27 chl Exp $ |
* $Id: encoder.c,v 1.76.2.17 2002-11-11 20:53:34 Isibaar Exp $ |
43 |
* |
* |
44 |
****************************************************************************/ |
****************************************************************************/ |
45 |
|
|
107 |
}; |
}; |
108 |
|
|
109 |
|
|
|
static void __inline |
|
|
image_null(IMAGE * image) |
|
|
{ |
|
|
image->y = image->u = image->v = NULL; |
|
|
} |
|
|
|
|
|
|
|
110 |
/***************************************************************************** |
/***************************************************************************** |
111 |
* Encoder creation |
* Encoder creation |
112 |
* |
* |
616 |
start_timer(); |
start_timer(); |
617 |
if (image_input |
if (image_input |
618 |
(&pEnc->queue[pEnc->queue_tail], pEnc->mbParam.width, pEnc->mbParam.height, |
(&pEnc->queue[pEnc->queue_tail], pEnc->mbParam.width, pEnc->mbParam.height, |
619 |
pEnc->mbParam.edged_width, pFrame->image, pFrame->colorspace)) |
pEnc->mbParam.edged_width, pFrame->image, pFrame->stride, pFrame->colorspace, pFrame->general & XVID_INTERLACING)) |
620 |
return; |
return; |
621 |
stop_conv_timer(); |
stop_conv_timer(); |
622 |
|
|
711 |
pFrame->length = BitstreamLength(&bs); |
pFrame->length = BitstreamLength(&bs); |
712 |
pFrame->intra = 0; |
pFrame->intra = 0; |
713 |
|
|
714 |
|
emms(); |
715 |
|
|
716 |
return XVID_ERR_OK; |
return XVID_ERR_OK; |
717 |
} |
} |
718 |
|
|
731 |
if (input_valid) |
if (input_valid) |
732 |
queue_image(pEnc, pFrame); |
queue_image(pEnc, pFrame); |
733 |
|
|
734 |
|
emms(); |
735 |
|
|
736 |
return XVID_ERR_OK; |
return XVID_ERR_OK; |
737 |
} |
} |
738 |
|
|
766 |
if (input_valid) |
if (input_valid) |
767 |
queue_image(pEnc, pFrame); |
queue_image(pEnc, pFrame); |
768 |
|
|
769 |
|
emms(); |
770 |
|
|
771 |
return XVID_ERR_OK; |
return XVID_ERR_OK; |
772 |
} |
} |
773 |
} |
} |
798 |
start_timer(); |
start_timer(); |
799 |
if (image_input |
if (image_input |
800 |
(&pEnc->current->image, pEnc->mbParam.width, pEnc->mbParam.height, |
(&pEnc->current->image, pEnc->mbParam.width, pEnc->mbParam.height, |
801 |
pEnc->mbParam.edged_width, pFrame->image, pFrame->colorspace)) |
pEnc->mbParam.edged_width, pFrame->image, pFrame->stride, pFrame->colorspace, pFrame->general & XVID_INTERLACING)) |
802 |
|
{ |
803 |
|
emms(); |
804 |
return XVID_ERR_FORMAT; |
return XVID_ERR_FORMAT; |
805 |
|
} |
806 |
stop_conv_timer(); |
stop_conv_timer(); |
807 |
|
|
808 |
// queue input frame, and dequue next image |
// queue input frame, and dequue next image |
841 |
} |
} |
842 |
|
|
843 |
pFrame->length = BitstreamLength(&bs); |
pFrame->length = BitstreamLength(&bs); |
844 |
|
emms(); |
845 |
return XVID_ERR_OK; |
return XVID_ERR_OK; |
846 |
} |
} |
847 |
|
|
981 |
* NB : sequences like "IIBB" decode fine with msfdam but, |
* NB : sequences like "IIBB" decode fine with msfdam but, |
982 |
* go screwy with divx 5.00 |
* go screwy with divx 5.00 |
983 |
*/ |
*/ |
984 |
} else if (pEnc->bframenum_tail >= pEnc->mbParam.max_bframes || mode != 0) { |
} else if ((pEnc->bframenum_tail >= pEnc->mbParam.max_bframes) || (mode != 0)) { |
985 |
|
|
986 |
/* |
/* |
987 |
* This will be coded as a Predicted Frame |
* This will be coded as a Predicted Frame |
988 |
*/ |
*/ |
999 |
pFrame->intra = 0; |
pFrame->intra = 0; |
1000 |
pEnc->flush_bframes = 1; |
pEnc->flush_bframes = 1; |
1001 |
|
|
1002 |
if ((pEnc->global & XVID_GLOBAL_PACKED)) { |
if ((pEnc->global & XVID_GLOBAL_PACKED) && (pEnc->bframenum_tail > 0)) { |
1003 |
BitstreamPadAlways(&bs); |
BitstreamPadAlways(&bs); |
1004 |
input_valid = 0; |
input_valid = 0; |
1005 |
goto ipvop_loop; |
goto ipvop_loop; |
1080 |
stop_global_timer(); |
stop_global_timer(); |
1081 |
write_timer(); |
write_timer(); |
1082 |
|
|
1083 |
|
emms(); |
1084 |
return XVID_ERR_OK; |
return XVID_ERR_OK; |
1085 |
} |
} |
1086 |
|
|
1135 |
start_timer(); |
start_timer(); |
1136 |
if (image_input |
if (image_input |
1137 |
(&pEnc->current->image, pEnc->mbParam.width, pEnc->mbParam.height, |
(&pEnc->current->image, pEnc->mbParam.width, pEnc->mbParam.height, |
1138 |
pEnc->mbParam.edged_width, pFrame->image, pFrame->colorspace) < 0) |
pEnc->mbParam.edged_width, pFrame->image, pFrame->stride, pFrame->colorspace, pFrame->general & XVID_INTERLACING) < 0) |
1139 |
return XVID_ERR_FORMAT; |
return XVID_ERR_FORMAT; |
1140 |
stop_conv_timer(); |
stop_conv_timer(); |
1141 |
|
|
1626 |
|
|
1627 |
if (pEnc->current->global_flags & XVID_GMC) { |
if (pEnc->current->global_flags & XVID_GMC) { |
1628 |
// printf("Global Motion = %d %d quarterpel=%d\n", pEnc->current->GMC_MV.x, pEnc->current->GMC_MV.y,pEnc->current->quarterpel); |
// printf("Global Motion = %d %d quarterpel=%d\n", pEnc->current->GMC_MV.x, pEnc->current->GMC_MV.y,pEnc->current->quarterpel); |
1629 |
|
DPRINTF(DPRINTF_HEADER, "Global Motion = %d %d quarterpel=%d\n", pEnc->current->GMC_MV.x, pEnc->current->GMC_MV.y,pEnc->current->quarterpel); |
1630 |
pEnc->current->coding_type = S_VOP; |
pEnc->current->coding_type = S_VOP; |
1631 |
} else |
} else |
1632 |
pEnc->current->coding_type = P_VOP; |
pEnc->current->coding_type = P_VOP; |