annotate libmpcodecs/vd_xvid.c @ 19264:3826d2cfa4b0

There is a reference to a file COPYRIGHT that we do not include, so paste the contents of COPYRIGHT into the file header.
author diego
date Sun, 30 Jul 2006 22:17:25 +0000
parents cc65a585fdcc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6701
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
1 #include <stdio.h>
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
2 #include <stdlib.h>
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
3
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
4 #include "config.h"
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
5 #include "mp_msg.h"
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
6
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
7 #include "vd_internal.h"
10594
57bdcdb061d7 Removed the historic cfgparser and switched full to the new config parser (altought some macros still remain for compatibility). As a side effect 90% of the warning messages are gone from the core. Things should be cleaner now and less confusing for newbies.
alex
parents: 9803
diff changeset
8 #include "m_option.h"
6701
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
9
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
10 #include <xvid.h>
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
11
8491
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
12 #ifdef XVID_API_UNSTABLE
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
13 #warning *******************************************************************
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
14 #warning ** **
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
15 #warning ** Y O U '' R E U S I N G U N S T A B L E S O F T W A R E **
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
16 #warning ** **
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
17 #warning ** There are bugs, this code could crash, could blow up your PC **
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
18 #warning ** or the whole building and do many other nasty things ! **
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
19 #warning ** **
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
20 #warning ** If you want stable code use stable XViD releases (0.9.x). **
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
21 #warning ** **
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
22 #warning *******************************************************************
8462
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 7180
diff changeset
23 #endif
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 7180
diff changeset
24
9803
4563dfa92a5b xvid fixes and more options by elcabesa & Martin Drab
henry
parents: 9300
diff changeset
25 typedef struct
4563dfa92a5b xvid fixes and more options by elcabesa & Martin Drab
henry
parents: 9300
diff changeset
26 {
4563dfa92a5b xvid fixes and more options by elcabesa & Martin Drab
henry
parents: 9300
diff changeset
27 void *y;
4563dfa92a5b xvid fixes and more options by elcabesa & Martin Drab
henry
parents: 9300
diff changeset
28 void *u;
4563dfa92a5b xvid fixes and more options by elcabesa & Martin Drab
henry
parents: 9300
diff changeset
29 void *v;
4563dfa92a5b xvid fixes and more options by elcabesa & Martin Drab
henry
parents: 9300
diff changeset
30 int stride_y;
4563dfa92a5b xvid fixes and more options by elcabesa & Martin Drab
henry
parents: 9300
diff changeset
31 int stride_uv;
4563dfa92a5b xvid fixes and more options by elcabesa & Martin Drab
henry
parents: 9300
diff changeset
32 }
4563dfa92a5b xvid fixes and more options by elcabesa & Martin Drab
henry
parents: 9300
diff changeset
33 DIVX4_DEC_PICTURE;
4563dfa92a5b xvid fixes and more options by elcabesa & Martin Drab
henry
parents: 9300
diff changeset
34
4563dfa92a5b xvid fixes and more options by elcabesa & Martin Drab
henry
parents: 9300
diff changeset
35
4563dfa92a5b xvid fixes and more options by elcabesa & Martin Drab
henry
parents: 9300
diff changeset
36
6701
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
37 static vd_info_t info =
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
38 {
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
39 "xvid decoder",
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
40 "xvid",
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
41 "Albeu",
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
42 "Albeu",
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
43 ""
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
44 };
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
45
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
46 LIBVD_EXTERN(xvid)
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
47
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
48 typedef struct {
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
49 int cs;
6756
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
50 unsigned char img_type;
6701
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
51 void* hdl;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
52 mp_image_t* mpi;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
53 } priv_t;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
54
6756
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
55 static int do_dr2 = 0;
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
56
10594
57bdcdb061d7 Removed the historic cfgparser and switched full to the new config parser (altought some macros still remain for compatibility). As a side effect 90% of the warning messages are gone from the core. Things should be cleaner now and less confusing for newbies.
alex
parents: 9803
diff changeset
57 m_option_t xvid_dec_opts[] = {
6756
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
58 { "dr2", &do_dr2, CONF_TYPE_FLAG, 0, 0, 1, NULL},
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
59 { "nodr2", &do_dr2, CONF_TYPE_FLAG, 0, 1, 0, NULL},
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
60 {NULL, NULL, 0, 0, 0, 0, NULL}
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
61 };
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
62
6701
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
63 // to set/get/query special features/parameters
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
64 static int control(sh_video_t *sh,int cmd,void* arg,...){
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
65 return CONTROL_UNKNOWN;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
66 }
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
67
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
68 // init driver
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
69 static int init(sh_video_t *sh){
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
70 XVID_INIT_PARAM ini;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
71 XVID_DEC_PARAM dec_p;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
72 priv_t* p;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
73 int cs;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
74
8491
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
75 #ifdef XVID_API_UNSTABLE
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
76 mp_msg (MSGT_DECVIDEO, MSGL_WARN,
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
77 "\n"
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
78 "*******************************************************************\n"
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
79 "** **\n"
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
80 "** Y O U ' R E U S I N G U N S T A B L E S O F T W A R E **\n"
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
81 "** **\n"
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
82 "** There are bugs, this code could crash, could blow up your PC **\n"
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
83 "** or the whole building and do many other nasty things ! **\n"
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
84 "** **\n"
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
85 "** If you want stable code use stable XViD releases (0.9.x). **\n"
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
86 "** **\n"
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
87 "*******************************************************************\n"
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
88 "\n");
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
89 #endif
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
90
6701
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
91 memset(&ini,0,sizeof(XVID_INIT_PARAM));
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
92 memset(&dec_p,0,sizeof(XVID_DEC_PARAM));
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
93
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
94 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YV12))
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
95 return 0;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
96
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
97 switch(sh->codec->outfmt[sh->outfmtidx]){
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
98 case IMGFMT_YV12:
6767
a6240ba29795 support for older xvid versions and IMGFMT_IYUV
alex
parents: 6756
diff changeset
99 #ifdef XVID_CSP_EXTERN
6756
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
100 cs= do_dr2 ? XVID_CSP_EXTERN : XVID_CSP_USER;
6767
a6240ba29795 support for older xvid versions and IMGFMT_IYUV
alex
parents: 6756
diff changeset
101 #else
a6240ba29795 support for older xvid versions and IMGFMT_IYUV
alex
parents: 6756
diff changeset
102 cs= XVID_CSP_USER;
a6240ba29795 support for older xvid versions and IMGFMT_IYUV
alex
parents: 6756
diff changeset
103 #endif
6701
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
104 break;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
105 case IMGFMT_YUY2:
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
106 cs=XVID_CSP_YUY2;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
107 break;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
108 case IMGFMT_UYVY:
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
109 cs=XVID_CSP_UYVY;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
110 break;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
111 case IMGFMT_I420:
6767
a6240ba29795 support for older xvid versions and IMGFMT_IYUV
alex
parents: 6756
diff changeset
112 case IMGFMT_IYUV:
6701
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
113 cs=XVID_CSP_I420;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
114 break;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
115 case IMGFMT_BGR15:
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
116 cs=XVID_CSP_RGB555;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
117 break;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
118 case IMGFMT_BGR16:
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
119 cs=XVID_CSP_RGB565;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
120 break;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
121 case IMGFMT_BGR24:
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
122 cs=XVID_CSP_RGB24;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
123 break;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
124 case IMGFMT_BGR32:
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
125 cs=XVID_CSP_RGB32;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
126 break;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
127 case IMGFMT_YVYU:
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
128 cs=XVID_CSP_YVYU;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
129 break;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
130 default:
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
131 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Unsupported out_fmt: 0x%X\n",sh->codec->outfmt[sh->outfmtidx]);
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
132 return 0;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
133 }
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
134
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
135 if(xvid_init(NULL, 0, &ini, NULL))
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
136 return 0;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
137
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
138 if(ini.api_version != API_VERSION) {
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
139 if(ini.api_version < API_VERSION) {
9196
kmkaplan
parents: 8530
diff changeset
140 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Too old version of xvid (min. %d)\n",API_VERSION);
6701
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
141 return 0;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
142 }
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
143 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Bad xvid version %d was compiled with %d\n",
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
144 ini.api_version,API_VERSION);
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
145 }
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
146
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
147 dec_p.width = sh->disp_w;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
148 dec_p.height = sh->disp_h;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
149
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
150 if(xvid_decore(NULL, XVID_DEC_CREATE, &dec_p, NULL)) {
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
151 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"xvid init failed\n");
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
152 return 0;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
153 }
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
154
18879
cc65a585fdcc rm unnecesary casts from void* - part 3
reynaldo
parents: 18771
diff changeset
155 p = malloc(sizeof(priv_t));
6701
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
156 p->cs = cs;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
157 p->hdl = dec_p.handle;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
158 sh->context = p;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
159
6756
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
160 switch(cs) {
6767
a6240ba29795 support for older xvid versions and IMGFMT_IYUV
alex
parents: 6756
diff changeset
161 #ifdef XVID_CSP_EXTERN
6756
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
162 case XVID_CSP_EXTERN:
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
163 p->img_type = MP_IMGTYPE_STATIC;
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
164 break;
6767
a6240ba29795 support for older xvid versions and IMGFMT_IYUV
alex
parents: 6756
diff changeset
165 #endif
6756
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
166 case XVID_CSP_USER:
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
167 p->img_type = MP_IMGTYPE_EXPORT;
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
168 break;
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
169 default:
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
170 p->img_type = MP_IMGTYPE_TEMP;
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
171 break;
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
172 }
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
173
6701
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
174 return 1;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
175 }
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
176
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
177 // uninit driver
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
178 static void uninit(sh_video_t *sh){
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
179 priv_t* p = sh->context;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
180 if(!p)
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
181 return;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
182 xvid_decore(p->hdl,XVID_DEC_DESTROY, NULL, NULL);
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
183 free(p);
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
184 }
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
185
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
186 // decode a frame
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
187 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
188 XVID_DEC_FRAME dec;
9300
32be26de0d7c cleanup detection of various divx4 versions/alternatives
arpi
parents: 9196
diff changeset
189 DIVX4_DEC_PICTURE d4_pic;
6915
5ca9fc4d2994 compilation bug found by Julien Portalier <julien@portalier.com>
arpi
parents: 6767
diff changeset
190 #ifdef XVID_CSP_EXTERN
6756
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
191 XVID_DEC_PICTURE pic;
6915
5ca9fc4d2994 compilation bug found by Julien Portalier <julien@portalier.com>
arpi
parents: 6767
diff changeset
192 #endif
6701
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
193 priv_t* p = sh->context;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
194
6756
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
195 mp_image_t* mpi = mpcodecs_get_image(sh, p->img_type,
6701
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
196 MP_IMGFLAG_ACCEPT_STRIDE,
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
197 sh->disp_w,sh->disp_h);
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
198
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
199 if(!data || !mpi || len <= 0)
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
200 return NULL;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
201
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
202 memset(&dec,0,sizeof(XVID_DEC_FRAME));
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
203
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
204 dec.bitstream = data;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
205 dec.length = len;
8491
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
206 #ifdef XVID_API_UNSTABLE
8462
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 7180
diff changeset
207 dec.general |= XVID_DEC_LOWDELAY;
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 7180
diff changeset
208 #endif
6701
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
209 switch(p->cs) {
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
210 case XVID_CSP_USER:
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
211 dec.image = &d4_pic;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
212 break;
6767
a6240ba29795 support for older xvid versions and IMGFMT_IYUV
alex
parents: 6756
diff changeset
213 #ifdef XVID_CSP_EXTERN
6756
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
214 case XVID_CSP_EXTERN:
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
215 pic.y = mpi->planes[0];
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
216 pic.u = mpi->planes[1];
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
217 pic.v = mpi->planes[2];
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
218 pic.stride_y = mpi->stride[0];
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
219 pic.stride_u = mpi->stride[1];
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
220 pic.stride_v = mpi->stride[2];
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
221 dec.image = &pic;
6af6d7b40638 Add direct rendering method 2
albeu
parents: 6701
diff changeset
222 break;
6767
a6240ba29795 support for older xvid versions and IMGFMT_IYUV
alex
parents: 6756
diff changeset
223 #endif
6701
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
224 default:
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
225 dec.image = mpi->planes[0];
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
226 if(IMGFMT_IS_BGR(mpi->imgfmt) || IMGFMT_IS_RGB(mpi->imgfmt))
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
227 dec.stride = mpi->width;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
228 else
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
229 dec.stride = mpi->stride[0];
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
230 }
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
231 dec.colorspace = p->cs;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
232
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
233 if(xvid_decore(p->hdl,XVID_DEC_DECODE,&dec,NULL)) {
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
234 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"decoding error\n");
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
235 return NULL;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
236 }
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
237
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
238 if(p->cs == XVID_CSP_USER) {
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
239 mpi->planes[0] = d4_pic.y;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
240 mpi->planes[1] = d4_pic.u;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
241 mpi->planes[2] = d4_pic.v;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
242 mpi->stride[0] = d4_pic.stride_y;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
243 mpi->stride[1] = mpi->stride[2] = d4_pic.stride_uv;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
244 }
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
245
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
246 return mpi;
522713337297 Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff changeset
247 }