1 |
/************************************************************************** |
/***************************************************************************** |
2 |
* |
* |
3 |
* XVID MPEG-4 VIDEO CODEC |
* XVID MPEG-4 VIDEO CODEC |
4 |
* - OpenDivx API wrapper - |
* - DivX 4.x compatibility layer (Deprecated and not up2date code) - |
5 |
* |
* |
6 |
* This program is an implementation of a part of one or more MPEG-4 |
* Copyright(C) 2001-2003 Peter Ross <pross@xvid.org> |
7 |
* Video tools as specified in ISO/IEC 14496-2 standard. Those intending |
* 2002-2003 Edouard Gomez <ed.gomez@free.fr> |
|
* to use this software module in hardware or software products are |
|
|
* advised that its use may infringe existing patents or copyrights, and |
|
|
* any such use would be at such party's own risk. The original |
|
|
* developer of this software module and his/her company, and subsequent |
|
|
* editors and their companies, will have no liability for use of this |
|
|
* software or modifications or derivatives thereof. |
|
8 |
* |
* |
9 |
* This program is free software; you can redistribute it and/or modify |
* This program is free software; you can redistribute it and/or modify |
10 |
* it under the terms of the GNU General Public License as published by |
* it under the terms of the GNU General Public License as published by |
18 |
* |
* |
19 |
* You should have received a copy of the GNU General Public License |
* You should have received a copy of the GNU General Public License |
20 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
21 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 |
* |
* |
23 |
*************************************************************************/ |
* $Id: divx4.c,v 1.21.2.2 2003-06-09 13:50:12 edgomez Exp $ |
|
|
|
|
/************************************************************************** |
|
|
* |
|
|
* History: |
|
|
* |
|
|
* 26.02.2001 fixed dec_csp bugs |
|
|
* 26.12.2001 xvid_init() support |
|
|
* 22.12.2001 removed some compiler warnings |
|
|
* 16.12.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
|
24 |
* |
* |
25 |
* $Id: divx4.c,v 1.14 2002-06-12 20:38:39 edgomez Exp $ |
****************************************************************************/ |
|
* |
|
|
*************************************************************************/ |
|
26 |
|
|
27 |
#include <stdlib.h> |
#include <stdlib.h> |
28 |
#include <string.h> |
#include <string.h> |
35 |
|
|
36 |
#define EMULATED_DIVX_VERSION 20011001 |
#define EMULATED_DIVX_VERSION 20011001 |
37 |
|
|
38 |
/************************************************************************** |
/***************************************************************************** |
39 |
* Divx Instance Structure |
* Divx Instance Structure |
40 |
* |
* |
41 |
* This chain list datatype allows XviD do instanciate multiples divx4 |
* This chain list datatype allows XviD do instanciate multiples divx4 |
45 |
* because they are not protected by any kind of mutex to allow |
* because they are not protected by any kind of mutex to allow |
46 |
* only one modifier. We should add a mutex for each element in |
* only one modifier. We should add a mutex for each element in |
47 |
* the chainlist. |
* the chainlist. |
48 |
*************************************************************************/ |
****************************************************************************/ |
49 |
|
|
50 |
|
|
51 |
typedef struct DINST |
typedef struct DINST |
69 |
} |
} |
70 |
EINST; |
EINST; |
71 |
|
|
72 |
/************************************************************************** |
/***************************************************************************** |
73 |
* Global data (needed to emulate correctly exported symbols from divx4) |
* Global data (needed to emulate correctly exported symbols from divx4) |
74 |
*************************************************************************/ |
****************************************************************************/ |
75 |
|
|
76 |
/* This is not used in this module but is required by some divx4 encoders*/ |
/* This is not used in this module but is required by some divx4 encoders*/ |
77 |
int quiet_encore = 1; |
int quiet_encore = 1; |
78 |
|
|
79 |
/************************************************************************** |
/***************************************************************************** |
80 |
* Local data |
* Local data |
81 |
*************************************************************************/ |
****************************************************************************/ |
82 |
|
|
83 |
/* The Divx4 instance chainlist */ |
/* The Divx4 instance chainlist */ |
84 |
static DINST *dhead = NULL; |
static DINST *dhead = NULL; |
88 |
static int const divx4_motion_presets[7] = { |
static int const divx4_motion_presets[7] = { |
89 |
0, |
0, |
90 |
|
|
91 |
PMV_EARLYSTOP16, |
0, |
92 |
|
|
93 |
PMV_EARLYSTOP16 | PMV_ADVANCEDDIAMOND16, |
XVID_ME_ADVANCEDDIAMOND16, |
94 |
|
|
95 |
PMV_EARLYSTOP16 | PMV_HALFPELREFINE16, |
XVID_ME_HALFPELREFINE16, |
96 |
|
|
97 |
PMV_EARLYSTOP16 | PMV_HALFPELREFINE16 | PMV_EARLYSTOP8 | |
XVID_ME_HALFPELREFINE16 | XVID_ME_HALFPELREFINE8, |
|
PMV_HALFPELREFINE8, |
|
98 |
|
|
99 |
PMV_EARLYSTOP16 | PMV_HALFPELREFINE16 | PMV_EARLYSTOP8 | |
XVID_ME_HALFPELREFINE16 | XVID_ME_HALFPELREFINE8, |
|
PMV_HALFPELREFINE8, |
|
100 |
|
|
101 |
PMV_EARLYSTOP16 | PMV_HALFPELREFINE16 | PMV_EXTSEARCH16 | PMV_EARLYSTOP8 | |
XVID_ME_HALFPELREFINE16 | XVID_ME_EXTSEARCH16 | XVID_ME_HALFPELREFINE8 |
|
PMV_HALFPELREFINE8 |
|
102 |
}; |
}; |
103 |
|
|
104 |
|
|
107 |
0, |
0, |
108 |
XVID_H263QUANT, |
XVID_H263QUANT, |
109 |
XVID_H263QUANT, |
XVID_H263QUANT, |
110 |
XVID_H263QUANT | XVID_HALFPEL, |
XVID_H263QUANT | XVID_VOP_HALFPEL, |
111 |
XVID_H263QUANT | XVID_INTER4V | XVID_HALFPEL, |
XVID_H263QUANT | XVID_VOP_INTER4V | XVID_VOP_HALFPEL, |
112 |
XVID_H263QUANT | XVID_INTER4V | XVID_HALFPEL, |
XVID_H263QUANT | XVID_VOP_INTER4V | XVID_VOP_HALFPEL, |
113 |
XVID_H263QUANT | XVID_INTER4V | XVID_HALFPEL |
XVID_H263QUANT | XVID_VOP_INTER4V | XVID_VOP_HALFPEL |
114 |
}; |
}; |
115 |
|
|
116 |
/************************************************************************** |
/***************************************************************************** |
117 |
* Local Prototypes |
* Local Prototypes |
118 |
*************************************************************************/ |
****************************************************************************/ |
119 |
|
|
120 |
/* Chain list helper functions */ |
/* Chain list helper functions */ |
121 |
static DINST *dinst_find(unsigned long key); |
static DINST *dinst_find(unsigned long key); |
130 |
static int xvid_to_opendivx_dec_csp(int csp); |
static int xvid_to_opendivx_dec_csp(int csp); |
131 |
static int xvid_to_opendivx_enc_csp(int csp); |
static int xvid_to_opendivx_enc_csp(int csp); |
132 |
|
|
133 |
/************************************************************************** |
/***************************************************************************** |
134 |
* decore part |
* decore part |
135 |
* |
* |
136 |
* decore is the divx4 entry point used to decompress the mpeg4 bitstream |
* decore is the divx4 entry point used to decompress the mpeg4 bitstream |
137 |
* into a user defined image format. |
* into a user defined image format. |
138 |
*************************************************************************/ |
****************************************************************************/ |
139 |
|
|
140 |
int |
int |
141 |
decore(unsigned long key, |
decore(unsigned long key, |
266 |
} |
} |
267 |
|
|
268 |
/* Decode the bitstream */ |
/* Decode the bitstream */ |
269 |
xerr = decoder_decode(dcur->handle, &dcur->xframe); |
xerr = decoder_decode(dcur->handle, &dcur->xframe, NULL); |
270 |
|
|
271 |
/* Restore the real colorspace for this instance */ |
/* Restore the real colorspace for this instance */ |
272 |
if (!dframe->render_flag) { |
if (!dframe->render_flag) { |
301 |
} |
} |
302 |
} |
} |
303 |
|
|
304 |
/************************************************************************** |
/***************************************************************************** |
305 |
* Encore Part |
* Encore Part |
306 |
* |
* |
307 |
* encore is the divx4 entry point used to compress a frame to a mpeg4 |
* encore is the divx4 entry point used to compress a frame to a mpeg4 |
308 |
* bitstream. |
* bitstream. |
309 |
*************************************************************************/ |
****************************************************************************/ |
310 |
|
|
311 |
#define FRAMERATE_INCR 1001 |
#define FRAMERATE_INCR 1001 |
312 |
|
|
349 |
xparam.max_quantizer = eparam->max_quantizer; |
xparam.max_quantizer = eparam->max_quantizer; |
350 |
xparam.max_key_interval = eparam->max_key_interval; |
xparam.max_key_interval = eparam->max_key_interval; |
351 |
|
|
352 |
|
xparam.global = 0; |
353 |
|
xparam.max_bframes = -1; /* use "original" IP-frame encoder */ |
354 |
|
xparam.bquant_ratio = 200; |
355 |
|
xparam.frame_drop_ratio = 0; /* dont drop frames */ |
356 |
|
|
357 |
/* Create the encoder session */ |
/* Create the encoder session */ |
358 |
xerr = encoder_create(&xparam); |
xerr = encoder_create(&xparam); |
359 |
|
|
461 |
} |
} |
462 |
} |
} |
463 |
|
|
464 |
/************************************************************************** |
/***************************************************************************** |
465 |
* Local Functions |
* Local Functions |
466 |
*************************************************************************/ |
****************************************************************************/ |
467 |
|
|
468 |
/*************************************** |
/*************************************** |
469 |
* DINST chainlist helper functions * |
* DINST chainlist helper functions * |