annotate libmpcodecs/vd_xvid4.c @ 13873:89bbd098cfda

slight grammar/wording/spelling/markup improvements
author diego
date Fri, 05 Nov 2004 10:14:39 +0000
parents 3427a9f4b6e3
children a1807995e2ab
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11437
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
1 /*****************************************************************************
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
2 *
13652
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
3 * - XviD 1.x decoder module for mplayer/mencoder -
11437
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
4 *
13652
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
5 * Copyright(C) 2003 Marco Belli <elcabesa@inwind.it>
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
6 * 2003-2004 Edouard Gomez <ed.gomez@free.fr>
11437
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
7 *
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
11 * (at your option) any later version.
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
12 *
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
16 * GNU General Public License for more details.
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
17 *
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
21 *
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
22 *****************************************************************************/
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
23
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
24 /*****************************************************************************
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
25 * Includes
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
26 ****************************************************************************/
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
27
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
28 #include <stdio.h>
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
29 #include <stdlib.h>
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
30
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
31 #include "config.h"
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
32 #include "mp_msg.h"
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
33
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
34 #ifdef HAVE_XVID4
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
35
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
36 #include "vd_internal.h"
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
37 #include "m_option.h"
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
38
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
39 #include <xvid.h>
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
40
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
41 /*****************************************************************************
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
42 * Configuration options
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
43 ****************************************************************************/
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
44
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
45 static int do_dr2 = 1;
11967
4f4b81257d19 Adds support for the film grain effect and deblocking filters in xvid
attila
parents: 11437
diff changeset
46 static int filmeffect = 0;
4f4b81257d19 Adds support for the film grain effect and deblocking filters in xvid
attila
parents: 11437
diff changeset
47 static int lumadeblock = 0;
4f4b81257d19 Adds support for the film grain effect and deblocking filters in xvid
attila
parents: 11437
diff changeset
48 static int chromadeblock = 0;
13652
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
49 static int lumadering = 0;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
50 static int chromadering = 0;
11437
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
51
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
52 m_option_t xvid_dec_opts[] = {
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
53 { "dr2", &do_dr2, CONF_TYPE_FLAG, 0, 0, 1, NULL},
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
54 { "nodr2", &do_dr2, CONF_TYPE_FLAG, 0, 1, 0, NULL},
11967
4f4b81257d19 Adds support for the film grain effect and deblocking filters in xvid
attila
parents: 11437
diff changeset
55 { "filmeffect", &filmeffect, CONF_TYPE_FLAG, 0, 0, 1, NULL},
4f4b81257d19 Adds support for the film grain effect and deblocking filters in xvid
attila
parents: 11437
diff changeset
56 { "deblock-luma", &lumadeblock, CONF_TYPE_FLAG, 0, 0, 1, NULL},
4f4b81257d19 Adds support for the film grain effect and deblocking filters in xvid
attila
parents: 11437
diff changeset
57 { "deblock-chroma", &chromadeblock, CONF_TYPE_FLAG, 0, 0, 1, NULL},
13652
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
58 { "dering-luma", &lumadering, CONF_TYPE_FLAG, 0, 0, 1, NULL},
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
59 { "dering-chroma", &chromadering, CONF_TYPE_FLAG, 0, 0, 1, NULL},
11437
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
60 {NULL, NULL, 0, 0, 0, 0, NULL}
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
61 };
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
62
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
63 /*****************************************************************************
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
64 * Module private data
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
65 ****************************************************************************/
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
66
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
67 typedef struct {
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
68 int cs;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
69 unsigned char img_type;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
70 void* hdl;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
71 mp_image_t* mpi;
13652
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
72 int vo_initialized;
11437
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
73 } priv_t;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
74
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
75 /*****************************************************************************
13652
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
76 * Module function helpers
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
77 ****************************************************************************/
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
78
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
79 static float stats2aspect(xvid_dec_stats_t *stats);
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
80
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
81 /*****************************************************************************
11437
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
82 * Video decoder API function definitions
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
83 ****************************************************************************/
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
84
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
85 /*============================================================================
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
86 * control - to set/get/query special features/parameters
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
87 *==========================================================================*/
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
88
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
89 static int control(sh_video_t *sh,int cmd,void* arg,...)
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
90 {
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
91 return(CONTROL_UNKNOWN);
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
92 }
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
93
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
94 /*============================================================================
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
95 * init - initialize the codec
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
96 *==========================================================================*/
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
97
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
98 static int init(sh_video_t *sh)
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
99 {
13652
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
100 xvid_gbl_info_t xvid_gbl_info;
11437
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
101 xvid_gbl_init_t xvid_ini;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
102 xvid_dec_create_t dec_p;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
103 priv_t* p;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
104 int cs;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
105
13652
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
106 memset(&xvid_gbl_info, 0, sizeof(xvid_gbl_info_t));
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
107 xvid_gbl_info.version = XVID_VERSION;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
108
11437
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
109 memset(&xvid_ini, 0, sizeof(xvid_gbl_init_t));
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
110 xvid_ini.version = XVID_VERSION;
13652
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
111
11437
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
112 memset(&dec_p, 0, sizeof(xvid_dec_create_t));
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
113 dec_p.version = XVID_VERSION;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
114
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
115
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
116 switch(sh->codec->outfmt[sh->outfmtidx]){
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
117 case IMGFMT_YV12:
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
118 /* We will use our own buffers, this speeds decoding avoiding
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
119 * frame memcpy's overhead */
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
120 cs = (do_dr2)?XVID_CSP_INTERNAL:XVID_CSP_USER;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
121 break;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
122 case IMGFMT_YUY2:
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
123 cs = XVID_CSP_YUY2;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
124 break;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
125 case IMGFMT_UYVY:
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
126 cs = XVID_CSP_UYVY;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
127 break;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
128 case IMGFMT_I420:
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
129 case IMGFMT_IYUV:
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
130 /* We will use our own buffers, this speeds decoding avoiding
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
131 * frame memcpy's overhead */
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
132 cs = (do_dr2)?XVID_CSP_INTERNAL:XVID_CSP_USER;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
133 break;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
134 case IMGFMT_BGR15:
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
135 cs = XVID_CSP_RGB555;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
136 break;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
137 case IMGFMT_BGR16:
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
138 cs = XVID_CSP_RGB565;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
139 break;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
140 case IMGFMT_BGR32:
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
141 cs = XVID_CSP_BGRA;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
142 break;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
143 case IMGFMT_YVYU:
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
144 cs = XVID_CSP_YVYU;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
145 break;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
146 default:
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
147 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Unsupported out_fmt: 0x%X\n",
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
148 sh->codec->outfmt[sh->outfmtidx]);
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
149 return(0);
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
150 }
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
151
13652
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
152 /* Gather some information about the host library */
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
153 if(xvid_global(NULL, XVID_GBL_INFO, &xvid_gbl_info, NULL) < 0) {
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
154 mp_msg(MSGT_MENCODER,MSGL_INFO, "xvid: could not get information about the library\n");
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
155 } else {
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
156 mp_msg(MSGT_MENCODER,MSGL_INFO, "xvid: using library version %d.%d.%d (build %s)\n",
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
157 XVID_VERSION_MAJOR(xvid_gbl_info.actual_version),
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
158 XVID_VERSION_MINOR(xvid_gbl_info.actual_version),
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
159 XVID_VERSION_PATCH(xvid_gbl_info.actual_version),
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
160 xvid_gbl_info.build);
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
161 }
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
162
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
163 /* Initialize the xvidcore library */
11437
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
164 if(xvid_global(NULL, XVID_GBL_INIT, &xvid_ini, NULL))
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
165 return(0);
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
166
13652
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
167 /* We use 0 width and height so xvidcore will resize its buffers
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
168 * if required. That allows this vd plugin to do resize on first
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
169 * VOL encountered (don't trust containers' width and height) */
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
170 dec_p.width = 0;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
171 dec_p.height = 0;
11437
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
172
13652
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
173 /* Get a decoder instance */
11437
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
174 if(xvid_decore(0, XVID_DEC_CREATE, &dec_p, NULL)<0) {
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
175 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "XviD init failed\n");
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
176 return(0);
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
177 }
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
178
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
179 p = (priv_t*)malloc(sizeof(priv_t));
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
180 p->cs = cs;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
181 p->hdl = dec_p.handle;
13652
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
182 p->vo_initialized = 0;
11437
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
183 sh->context = p;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
184
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
185 switch(cs) {
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
186 case XVID_CSP_INTERNAL:
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
187 p->img_type = MP_IMGTYPE_EXPORT;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
188 break;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
189 case XVID_CSP_USER:
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
190 p->img_type = MP_IMGTYPE_STATIC;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
191 break;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
192 default:
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
193 p->img_type = MP_IMGTYPE_TEMP;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
194 break;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
195 }
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
196
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
197 return(1);
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
198 }
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
199
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
200 /*============================================================================
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
201 * uninit - close the codec
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
202 *==========================================================================*/
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
203
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
204 static void uninit(sh_video_t *sh){
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
205 priv_t* p = sh->context;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
206 if(!p)
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
207 return;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
208 xvid_decore(p->hdl,XVID_DEC_DESTROY, NULL, NULL);
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
209 free(p);
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
210 }
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
211
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
212 /*============================================================================
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
213 * decode - decode a frame from stream
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
214 *==========================================================================*/
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
215
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
216 static mp_image_t* decode(sh_video_t *sh, void* data, int len, int flags)
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
217 {
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
218 xvid_dec_frame_t dec;
13652
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
219 xvid_dec_stats_t stats;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
220 mp_image_t* mpi = NULL;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
221
11437
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
222 priv_t* p = sh->context;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
223
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
224
13652
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
225 if(!data || len <= 0)
11437
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
226 return(NULL);
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
227
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
228 memset(&dec,0,sizeof(xvid_dec_frame_t));
13652
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
229 memset(&stats, 0, sizeof(xvid_dec_stats_t));
11437
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
230 dec.version = XVID_VERSION;
13652
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
231 stats.version = XVID_VERSION;
11437
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
232
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
233 dec.bitstream = data;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
234 dec.length = len;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
235
13652
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
236 dec.general |= XVID_LOWDELAY
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
237 /* XXX: if lowdelay is unset, and xvidcore internal buffers are
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
238 * used => crash. MUST FIX */
11967
4f4b81257d19 Adds support for the film grain effect and deblocking filters in xvid
attila
parents: 11437
diff changeset
239 | (filmeffect ? XVID_FILMEFFECT : 0 )
4f4b81257d19 Adds support for the film grain effect and deblocking filters in xvid
attila
parents: 11437
diff changeset
240 | (lumadeblock ? XVID_DEBLOCKY : 0 )
4f4b81257d19 Adds support for the film grain effect and deblocking filters in xvid
attila
parents: 11437
diff changeset
241 | (chromadeblock ? XVID_DEBLOCKUV : 0 );
13652
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
242 #if XVID_API >= XVID_MAKE_API(4,1)
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
243 dec.general |= (lumadering ? XVID_DEBLOCKY|XVID_DERINGY : 0 );
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
244 dec.general |= (chromadering ? XVID_DEBLOCKUV|XVID_DERINGUV : 0 );
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
245 #endif
11437
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
246 dec.output.csp = p->cs;
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
247
13652
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
248 /* Decoding loop because xvidcore may return VOL information for
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
249 * on the fly buffer resizing. In that case we must decode VOL,
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
250 * init VO, then decode the frame */
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
251 do {
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
252 int consumed;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
253
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
254 /* If we don't know frame size yet, don't even try to request
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
255 * a buffer, we must loop until we find a VOL, so VO plugin
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
256 * is initialized and we can obviously output something */
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
257 if (p->vo_initialized) {
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
258 mpi = mpcodecs_get_image(sh, p->img_type,
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
259 MP_IMGFLAG_ACCEPT_STRIDE,
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
260 sh->disp_w, sh->disp_h);
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
261
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
262 if(p->cs != XVID_CSP_INTERNAL) {
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
263 dec.output.plane[0] = mpi->planes[0];
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
264 dec.output.plane[1] = mpi->planes[1];
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
265 dec.output.plane[2] = mpi->planes[2];
11437
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
266
13652
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
267 dec.output.stride[0] = mpi->stride[0];
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
268 dec.output.stride[1] = mpi->stride[1];
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
269 dec.output.stride[2] = mpi->stride[2];
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
270 }
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
271 }
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
272
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
273 /* Decode data */
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
274 consumed = xvid_decore(p->hdl, XVID_DEC_DECODE, &dec, &stats);
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
275 if (consumed < 0) {
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
276 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Decoding error\n");
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
277 return(NULL);
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
278 }
11437
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
279
13652
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
280 /* Found a VOL information stats, if VO plugin is not initialized
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
281 * yet then do it now */
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
282 if (stats.type == XVID_TYPE_VOL && !p->vo_initialized) {
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
283 sh->aspect = stats2aspect(&stats);
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
284 if(!mpcodecs_config_vo(sh, stats.data.vol.width, stats.data.vol.height, IMGFMT_YV12))
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
285 return(NULL);
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
286
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
287 /* Don't take this path twice */
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
288 p->vo_initialized = !p->vo_initialized;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
289 }
11437
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
290
13652
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
291 /* Don't forget to update buffer position and buffer length */
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
292 dec.bitstream += consumed;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
293 dec.length -= consumed;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
294 } while ((stats.type == XVID_TYPE_VOL || stats.type == XVID_TYPE_NOTHING) && dec.length > 0);
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
295
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
296 /* There are two ways to get out of the decoding loop:
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
297 * - a frame has been returned
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
298 * - no more data in buffer and no frames returned */
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
299
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
300 /* If mpi is NULL, it proves nothing has been returned by the decoder
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
301 * so don't try to display internal buffers. */
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
302 if (mpi != NULL && p->cs == XVID_CSP_INTERNAL) {
11437
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
303 mpi->planes[0] = dec.output.plane[0];
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
304 mpi->planes[1] = dec.output.plane[1];
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
305 mpi->planes[2] = dec.output.plane[2];
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
306
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
307 mpi->stride[0] = dec.output.stride[0];
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
308 mpi->stride[1] = dec.output.stride[1];
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
309 mpi->stride[2] = dec.output.stride[2];
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
310 }
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
311
13652
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
312 /* If we got out the decoding loop because the buffer was empty and there was nothing
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
313 * to output yet, then just return NULL */
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
314 return((stats.type == XVID_TYPE_NOTHING)? NULL: mpi);
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
315 }
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
316
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
317 /*****************************************************************************
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
318 * Helper functions
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
319 ****************************************************************************/
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
320
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
321 /* Returns DAR value according to VOL's informations contained in stats
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
322 * param */
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
323 static float stats2aspect(xvid_dec_stats_t *stats)
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
324 {
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
325 if (stats->type == XVID_TYPE_VOL) {
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
326 float wpar;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
327 float hpar;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
328 float dar;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
329
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
330 /* MPEG4 strem stores PAR (Pixel Aspect Ratio), mplayer uses
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
331 * DAR (Display Aspect Ratio)
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
332 *
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
333 * Both are related thanks to the equation:
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
334 * width
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
335 * DAR = ----- x PAR
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
336 * height
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
337 *
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
338 * As MPEG4 is so well designed (*cough*), VOL header carries
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
339 * both informations together -- lucky eh ? */
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
340
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
341 switch (stats->data.vol.par) {
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
342 case XVID_PAR_11_VGA: /* 1:1 vga (square), default if supplied PAR is not a valid value */
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
343 wpar = hpar = 1.0f;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
344 break;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
345 case XVID_PAR_43_PAL: /* 4:3 pal (12:11 625-line) */
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
346 wpar = 12;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
347 hpar = 11;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
348 break;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
349 case XVID_PAR_43_NTSC: /* 4:3 ntsc (10:11 525-line) */
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
350 wpar = 10;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
351 hpar = 11;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
352 break;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
353 case XVID_PAR_169_PAL: /* 16:9 pal (16:11 625-line) */
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
354 wpar = 16;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
355 hpar = 11;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
356 break;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
357 case XVID_PAR_169_NTSC: /* 16:9 ntsc (40:33 525-line) */
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
358 wpar = 40;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
359 hpar = 33;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
360 break;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
361 case XVID_PAR_EXT: /* extended par; use par_width, par_height */
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
362 wpar = stats->data.vol.par_width;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
363 hpar = stats->data.vol.par_height;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
364 break;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
365 default:
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
366 wpar = hpar = 1.0f;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
367 break;
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
368 }
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
369
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
370 dar = ((float)stats->data.vol.width*wpar);
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
371 dar /= ((float)stats->data.vol.height*hpar);
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
372
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
373 return(dar);
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
374 }
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
375
3427a9f4b6e3 Sync with GomGom's patch-12 version.
iive
parents: 11967
diff changeset
376 return(0.0f);
11437
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
377 }
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
378
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
379 /*****************************************************************************
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
380 * Module structure definition
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
381 ****************************************************************************/
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
382
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
383 static vd_info_t info =
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
384 {
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
385 "XviD 1.0 decoder",
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
386 "xvid",
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
387 "Marco Belli <elcabesa@inwind.it>, Edouard Gomez <ed.gomez@free.fr>",
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
388 "Marco Belli <elcabesa@inwind.it>, Edouard Gomez <ed.gomez@free.fr>",
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
389 "No Comment"
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
390 };
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
391
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
392 LIBVD_EXTERN(xvid)
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
393
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
394 #endif /* HAVE_XVID4 */
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
395
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
396 /* Please do not change that tag comment.
7826e4e376c7 XviD Api4 driver from http://ed.gomez.free.fr/
iive
parents:
diff changeset
397 * arch-tag: b7d654a5-76ea-4768-9713-2c791567fe7d mplayer xvid decoder module */