1 |
// 14.04.2002 added FrameCodeB() |
/************************************************************************** |
2 |
|
* |
3 |
|
* XVID MPEG-4 VIDEO CODEC |
4 |
|
* - Encoder main module - |
5 |
|
* |
6 |
|
* This program is an implementation of a part of one or more MPEG-4 |
7 |
|
* Video tools as specified in ISO/IEC 14496-2 standard. Those intending |
8 |
|
* to use this software module in hardware or software products are |
9 |
|
* advised that its use may infringe existing patents or copyrights, and |
10 |
|
* any such use would be at such party's own risk. The original |
11 |
|
* developer of this software module and his/her company, and subsequent |
12 |
|
* editors and their companies, will have no liability for use of this |
13 |
|
* software or modifications or derivatives thereof. |
14 |
|
* |
15 |
|
* This program is free software; you can redistribute it and/or modify |
16 |
|
* it under the terms of the GNU General Public License as published by |
17 |
|
* the Free Software Foundation; either version 2 of the License, or |
18 |
|
* (at your option) any later version. |
19 |
|
* |
20 |
|
* This program is distributed in the hope that it will be useful, |
21 |
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
22 |
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23 |
|
* GNU General Public License for more details. |
24 |
|
* |
25 |
|
* You should have received a copy of the GNU General Public License |
26 |
|
* along with this program; if not, write to the Free Software |
27 |
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
28 |
|
* |
29 |
|
***************************************************************************/ |
30 |
|
|
31 |
|
/**************************************************************************** |
32 |
|
* |
33 |
|
* History |
34 |
|
* |
35 |
|
* 14.04.2002 added FrameCodeB() |
36 |
|
* |
37 |
|
* $Id: encoder.c,v 1.30 2002-04-28 23:31:00 edgomez Exp $ |
38 |
|
* |
39 |
|
***************************************************************************/ |
40 |
|
|
41 |
#include <stdlib.h> |
#include <stdlib.h> |
42 |
#include <stdio.h> |
#include <stdio.h> |
189 |
pEnc->current->mbs = NULL; |
pEnc->current->mbs = NULL; |
190 |
pEnc->reference->mbs = NULL; |
pEnc->reference->mbs = NULL; |
191 |
|
|
192 |
|
#ifdef _DEBUG |
193 |
|
#ifdef WIN32 |
194 |
OutputDebugString("malloc mbs"); |
OutputDebugString("malloc mbs"); |
195 |
|
#endif |
196 |
|
#endif |
197 |
|
|
198 |
if ((pEnc->current->mbs = xvid_malloc(sizeof(MACROBLOCK) * pEnc->mbParam.mb_width * pEnc->mbParam.mb_height, CACHE_LINE)) == NULL || |
if ((pEnc->current->mbs = xvid_malloc(sizeof(MACROBLOCK) * pEnc->mbParam.mb_width * pEnc->mbParam.mb_height, CACHE_LINE)) == NULL || |
199 |
(pEnc->reference->mbs = xvid_malloc(sizeof(MACROBLOCK) * pEnc->mbParam.mb_width * pEnc->mbParam.mb_height, CACHE_LINE)) == NULL) |
(pEnc->reference->mbs = xvid_malloc(sizeof(MACROBLOCK) * pEnc->mbParam.mb_width * pEnc->mbParam.mb_height, CACHE_LINE)) == NULL) |
200 |
{ |
{ |
217 |
image_null(&pEnc->vInterHV); |
image_null(&pEnc->vInterHV); |
218 |
image_null(&pEnc->vInterHVf); |
image_null(&pEnc->vInterHVf); |
219 |
|
|
220 |
|
#ifdef _DEBUG |
221 |
|
#ifdef WIN32 |
222 |
OutputDebugString("malloc images"); |
OutputDebugString("malloc images"); |
223 |
|
#endif |
224 |
|
#endif |
225 |
if ( |
if ( |
226 |
#ifdef _DEBUG |
#ifdef _DEBUG |
227 |
image_create(&pEnc->sOriginal, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height) < 0 || |
image_create(&pEnc->sOriginal, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height) < 0 || |
510 |
MVBLOCKHINT * bhint = &hint->mvhint.block[x + y * pEnc->mbParam.mb_width]; |
MVBLOCKHINT * bhint = &hint->mvhint.block[x + y * pEnc->mbParam.mb_width]; |
511 |
VECTOR pred[4]; |
VECTOR pred[4]; |
512 |
VECTOR tmp; |
VECTOR tmp; |
513 |
int dummy[4]; |
int32_t dummy[4]; |
514 |
int vec; |
int vec; |
515 |
|
|
516 |
pMB->mode = (hint->rawhints) ? bhint->mode : BitstreamGetBits(&bs, MODEBITS); |
pMB->mode = (hint->rawhints) ? bhint->mode : BitstreamGetBits(&bs, MODEBITS); |
754 |
int iLimit; |
int iLimit; |
755 |
uint32_t x, y; |
uint32_t x, y; |
756 |
int iSearchRange; |
int iSearchRange; |
757 |
bool bIntra; |
int bIntra; |
758 |
|
|
759 |
IMAGE *pCurrent = &pEnc->current->image; |
/* IMAGE *pCurrent = &pEnc->current->image; */ |
760 |
IMAGE *pRef = &pEnc->reference->image; |
IMAGE *pRef = &pEnc->reference->image; |
761 |
|
|
762 |
start_timer(); |
start_timer(); |
931 |
} |
} |
932 |
|
|
933 |
|
|
934 |
|
#if 0 |
935 |
|
|
|
/* |
|
936 |
static void FrameCodeB(Encoder * pEnc, FRAMEINFO * frame, Bitstream * bs, uint32_t *pBits) |
static void FrameCodeB(Encoder * pEnc, FRAMEINFO * frame, Bitstream * bs, uint32_t *pBits) |
937 |
{ |
{ |
938 |
int16_t dct_codes[6][64]; |
int16_t dct_codes[6][64]; |
944 |
IMAGE *f_ref = &pEnc->reference->image; |
IMAGE *f_ref = &pEnc->reference->image; |
945 |
IMAGE *b_ref = &pEnc->current->image; |
IMAGE *b_ref = &pEnc->current->image; |
946 |
|
|
947 |
// forward |
/* forward */ |
948 |
image_setedges(f_ref, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height, pEnc->mbParam.width, pEnc->mbParam.height); |
image_setedges(f_ref, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height, pEnc->mbParam.width, pEnc->mbParam.height); |
949 |
start_timer(); |
start_timer(); |
950 |
image_interpolate(f_ref, &pEnc->f_refh, &pEnc->f_refv, &pEnc->f_refhv, |
image_interpolate(f_ref, &pEnc->f_refh, &pEnc->f_refv, &pEnc->f_refhv, |
951 |
pEnc->mbParam.edged_width, pEnc->mbParam.edged_height, 0); |
pEnc->mbParam.edged_width, pEnc->mbParam.edged_height, 0); |
952 |
stop_inter_timer(); |
stop_inter_timer(); |
953 |
|
|
954 |
// backward |
/* backward */ |
955 |
image_setedges(b_ref, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height, pEnc->mbParam.width, pEnc->mbParam.height); |
image_setedges(b_ref, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height, pEnc->mbParam.width, pEnc->mbParam.height); |
956 |
start_timer(); |
start_timer(); |
957 |
image_interpolate(b_ref, &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV, |
image_interpolate(b_ref, &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV, |
1039 |
backward.y = mb->b_mvs[0].y; |
backward.y = mb->b_mvs[0].y; |
1040 |
} |
} |
1041 |
|
|
1042 |
// printf("[%i %i] M=%i CBP=%i MVX=%i MVY=%i %i,%i %i,%i\n", x, y, pMB->mode, pMB->cbp, pMB->mvs[0].x, bmb->pmvs[0].x, bmb->pmvs[0].y, forward.x, forward.y); |
/* |
1043 |
|
printf("[%i %i] M=%i CBP=%i MVX=%i MVY=%i %i,%i %i,%i\n", |
1044 |
|
x, |
1045 |
|
y, |
1046 |
|
pMB->mode, |
1047 |
|
pMB->cbp, |
1048 |
|
pMB->mvs[0].x, |
1049 |
|
bmb->pmvs[0].x, |
1050 |
|
bmb->pmvs[0].y, |
1051 |
|
forward.x, |
1052 |
|
forward.y); |
1053 |
|
*/ |
1054 |
|
|
1055 |
start_timer(); |
start_timer(); |
1056 |
MBCodingBVOP(frame, mb, qcoeff, bs, &pEnc->sStat); |
MBCodingBVOP(frame, mb, qcoeff, bs, &pEnc->sStat); |
1066 |
|
|
1067 |
} |
} |
1068 |
|
|
|
*/ |
|
1069 |
|
#endif |