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 |
* Copyright(C) 2001-2002 Peter Ross <pross@xvid.org> |
* Copyright(C) 2001-2003 Peter Ross <pross@xvid.org> |
7 |
|
* 2002-2003 Edouard Gomez <ed.gomez@free.fr> |
8 |
* |
* |
9 |
* This file is part of XviD, a free MPEG-4 video encoder/decoder |
* 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 |
|
* XviD is free software; you can redistribute it and/or modify it |
|
|
* under the terms of the GNU General Public License as published by |
|
11 |
* the Free Software Foundation; either version 2 of the License, or |
* the Free Software Foundation; either version 2 of the License, or |
12 |
* (at your option) any later version. |
* (at your option) any later version. |
13 |
* |
* |
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 |
* |
* |
|
* Under section 8 of the GNU General Public License, the copyright |
|
|
* holders of XVID explicitly forbid distribution in the following |
|
|
* countries: |
|
|
* |
|
|
* - Japan |
|
|
* - United States of America |
|
|
* |
|
|
* Linking XviD statically or dynamically with other modules is making a |
|
|
* combined work based on XviD. Thus, the terms and conditions of the |
|
|
* GNU General Public License cover the whole combination. |
|
|
* |
|
|
* As a special exception, the copyright holders of XviD give you |
|
|
* permission to link XviD with independent modules that communicate with |
|
|
* XviD solely through the VFW1.1 and DShow interfaces, regardless of the |
|
|
* license terms of these independent modules, and to copy and distribute |
|
|
* the resulting combined work under terms of your choice, provided that |
|
|
* every copy of the combined work is accompanied by a complete copy of |
|
|
* the source code of XviD (the version of XviD used to produce the |
|
|
* combined work), being distributed under the terms of the GNU General |
|
|
* Public License plus this exception. An independent module is a module |
|
|
* which is not derived from or based on XviD. |
|
|
* |
|
|
* Note that people who make modified versions of XviD are not obligated |
|
|
* to grant this special exception for their modified versions; it is |
|
|
* their choice whether to do so. The GNU General Public License gives |
|
|
* permission to release a modified version without this exception; this |
|
|
* exception also makes it possible to release a modified version which |
|
|
* carries forward this exception. |
|
|
* |
|
23 |
* $Id$ |
* $Id$ |
24 |
* |
* |
25 |
*************************************************************************/ |
****************************************************************************/ |
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 * |