Mercurial > mplayer.hg
annotate libmpcodecs/vd_xvid.c @ 18456:dbe929ff7920
some fixes for the VfW encoding section
patch by compn, tempn##@##twmi##.##rr##.##com
author | diego |
---|---|
date | Fri, 12 May 2006 17:04:47 +0000 |
parents | 6afc2d6f5a08 |
children | a1807995e2ab |
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 |
11436 | 7 #ifdef HAVE_XVID3 |
6701
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
8 |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
9 #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
|
10 #include "m_option.h" |
6701
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
11 |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
12 #include <xvid.h> |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
13 |
8491
ce25d80dd6c3
Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents:
8462
diff
changeset
|
14 #ifdef XVID_API_UNSTABLE |
ce25d80dd6c3
Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents:
8462
diff
changeset
|
15 #warning ******************************************************************* |
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 ** 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
|
18 #warning ** ** |
ce25d80dd6c3
Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents:
8462
diff
changeset
|
19 #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
|
20 #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
|
21 #warning ** ** |
ce25d80dd6c3
Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents:
8462
diff
changeset
|
22 #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
|
23 #warning ** ** |
ce25d80dd6c3
Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents:
8462
diff
changeset
|
24 #warning ******************************************************************* |
8462
800d77666843
Support the latest development code from XViD dev-api-3 CVS
rguyom
parents:
7180
diff
changeset
|
25 #endif |
800d77666843
Support the latest development code from XViD dev-api-3 CVS
rguyom
parents:
7180
diff
changeset
|
26 |
9803
4563dfa92a5b
xvid fixes and more options by elcabesa & Martin Drab
henry
parents:
9300
diff
changeset
|
27 typedef struct |
4563dfa92a5b
xvid fixes and more options by elcabesa & Martin Drab
henry
parents:
9300
diff
changeset
|
28 { |
4563dfa92a5b
xvid fixes and more options by elcabesa & Martin Drab
henry
parents:
9300
diff
changeset
|
29 void *y; |
4563dfa92a5b
xvid fixes and more options by elcabesa & Martin Drab
henry
parents:
9300
diff
changeset
|
30 void *u; |
4563dfa92a5b
xvid fixes and more options by elcabesa & Martin Drab
henry
parents:
9300
diff
changeset
|
31 void *v; |
4563dfa92a5b
xvid fixes and more options by elcabesa & Martin Drab
henry
parents:
9300
diff
changeset
|
32 int stride_y; |
4563dfa92a5b
xvid fixes and more options by elcabesa & Martin Drab
henry
parents:
9300
diff
changeset
|
33 int stride_uv; |
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 DIVX4_DEC_PICTURE; |
4563dfa92a5b
xvid fixes and more options by elcabesa & Martin Drab
henry
parents:
9300
diff
changeset
|
36 |
4563dfa92a5b
xvid fixes and more options by elcabesa & Martin Drab
henry
parents:
9300
diff
changeset
|
37 |
4563dfa92a5b
xvid fixes and more options by elcabesa & Martin Drab
henry
parents:
9300
diff
changeset
|
38 |
6701
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
39 static vd_info_t info = |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
40 { |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
41 "xvid decoder", |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
42 "xvid", |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
43 "Albeu", |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
44 "Albeu", |
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 }; |
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 LIBVD_EXTERN(xvid) |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
49 |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
50 typedef struct { |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
51 int cs; |
6756 | 52 unsigned char img_type; |
6701
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
53 void* hdl; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
54 mp_image_t* mpi; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
55 } priv_t; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
56 |
6756 | 57 static int do_dr2 = 0; |
58 | |
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
|
59 m_option_t xvid_dec_opts[] = { |
6756 | 60 { "dr2", &do_dr2, CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
61 { "nodr2", &do_dr2, CONF_TYPE_FLAG, 0, 1, 0, NULL}, | |
62 {NULL, NULL, 0, 0, 0, 0, NULL} | |
63 }; | |
64 | |
6701
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
65 // to set/get/query special features/parameters |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
66 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
|
67 return CONTROL_UNKNOWN; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
68 } |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
69 |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
70 // init driver |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
71 static int init(sh_video_t *sh){ |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
72 XVID_INIT_PARAM ini; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
73 XVID_DEC_PARAM dec_p; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
74 priv_t* p; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
75 int cs; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
76 |
8491
ce25d80dd6c3
Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents:
8462
diff
changeset
|
77 #ifdef XVID_API_UNSTABLE |
ce25d80dd6c3
Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents:
8462
diff
changeset
|
78 mp_msg (MSGT_DECVIDEO, MSGL_WARN, |
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 "*******************************************************************\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 "** 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
|
83 "** **\n" |
ce25d80dd6c3
Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents:
8462
diff
changeset
|
84 "** 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
|
85 "** 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
|
86 "** **\n" |
ce25d80dd6c3
Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents:
8462
diff
changeset
|
87 "** 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
|
88 "** **\n" |
ce25d80dd6c3
Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents:
8462
diff
changeset
|
89 "*******************************************************************\n" |
ce25d80dd6c3
Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents:
8462
diff
changeset
|
90 "\n"); |
ce25d80dd6c3
Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents:
8462
diff
changeset
|
91 #endif |
ce25d80dd6c3
Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents:
8462
diff
changeset
|
92 |
6701
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
93 memset(&ini,0,sizeof(XVID_INIT_PARAM)); |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
94 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
|
95 |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
96 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
|
97 return 0; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
98 |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
99 switch(sh->codec->outfmt[sh->outfmtidx]){ |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
100 case IMGFMT_YV12: |
6767 | 101 #ifdef XVID_CSP_EXTERN |
6756 | 102 cs= do_dr2 ? XVID_CSP_EXTERN : XVID_CSP_USER; |
6767 | 103 #else |
104 cs= XVID_CSP_USER; | |
105 #endif | |
6701
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
106 break; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
107 case IMGFMT_YUY2: |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
108 cs=XVID_CSP_YUY2; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
109 break; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
110 case IMGFMT_UYVY: |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
111 cs=XVID_CSP_UYVY; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
112 break; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
113 case IMGFMT_I420: |
6767 | 114 case IMGFMT_IYUV: |
6701
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
115 cs=XVID_CSP_I420; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
116 break; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
117 case IMGFMT_BGR15: |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
118 cs=XVID_CSP_RGB555; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
119 break; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
120 case IMGFMT_BGR16: |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
121 cs=XVID_CSP_RGB565; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
122 break; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
123 case IMGFMT_BGR24: |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
124 cs=XVID_CSP_RGB24; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
125 break; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
126 case IMGFMT_BGR32: |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
127 cs=XVID_CSP_RGB32; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
128 break; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
129 case IMGFMT_YVYU: |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
130 cs=XVID_CSP_YVYU; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
131 break; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
132 default: |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
133 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
|
134 return 0; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
135 } |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
136 |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
137 if(xvid_init(NULL, 0, &ini, NULL)) |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
138 return 0; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
139 |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
140 if(ini.api_version != API_VERSION) { |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
141 if(ini.api_version < API_VERSION) { |
9196 | 142 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
|
143 return 0; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
144 } |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
145 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
|
146 ini.api_version,API_VERSION); |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
147 } |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
148 |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
149 dec_p.width = sh->disp_w; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
150 dec_p.height = sh->disp_h; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
151 |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
152 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
|
153 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
|
154 return 0; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
155 } |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
156 |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
157 p = (priv_t*)malloc(sizeof(priv_t)); |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
158 p->cs = cs; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
159 p->hdl = dec_p.handle; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
160 sh->context = p; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
161 |
6756 | 162 switch(cs) { |
6767 | 163 #ifdef XVID_CSP_EXTERN |
6756 | 164 case XVID_CSP_EXTERN: |
165 p->img_type = MP_IMGTYPE_STATIC; | |
166 break; | |
6767 | 167 #endif |
6756 | 168 case XVID_CSP_USER: |
169 p->img_type = MP_IMGTYPE_EXPORT; | |
170 break; | |
171 default: | |
172 p->img_type = MP_IMGTYPE_TEMP; | |
173 break; | |
174 } | |
175 | |
6701
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
176 return 1; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
177 } |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
178 |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
179 // uninit driver |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
180 static void uninit(sh_video_t *sh){ |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
181 priv_t* p = sh->context; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
182 if(!p) |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
183 return; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
184 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
|
185 free(p); |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
186 } |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
187 |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
188 // decode a frame |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
189 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
|
190 XVID_DEC_FRAME dec; |
9300
32be26de0d7c
cleanup detection of various divx4 versions/alternatives
arpi
parents:
9196
diff
changeset
|
191 DIVX4_DEC_PICTURE d4_pic; |
6915
5ca9fc4d2994
compilation bug found by Julien Portalier <julien@portalier.com>
arpi
parents:
6767
diff
changeset
|
192 #ifdef XVID_CSP_EXTERN |
6756 | 193 XVID_DEC_PICTURE pic; |
6915
5ca9fc4d2994
compilation bug found by Julien Portalier <julien@portalier.com>
arpi
parents:
6767
diff
changeset
|
194 #endif |
6701
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
195 priv_t* p = sh->context; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
196 |
6756 | 197 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
|
198 MP_IMGFLAG_ACCEPT_STRIDE, |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
199 sh->disp_w,sh->disp_h); |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
200 |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
201 if(!data || !mpi || len <= 0) |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
202 return NULL; |
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 memset(&dec,0,sizeof(XVID_DEC_FRAME)); |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
205 |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
206 dec.bitstream = data; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
207 dec.length = len; |
8491
ce25d80dd6c3
Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents:
8462
diff
changeset
|
208 #ifdef XVID_API_UNSTABLE |
8462
800d77666843
Support the latest development code from XViD dev-api-3 CVS
rguyom
parents:
7180
diff
changeset
|
209 dec.general |= XVID_DEC_LOWDELAY; |
800d77666843
Support the latest development code from XViD dev-api-3 CVS
rguyom
parents:
7180
diff
changeset
|
210 #endif |
6701
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
211 switch(p->cs) { |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
212 case XVID_CSP_USER: |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
213 dec.image = &d4_pic; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
214 break; |
6767 | 215 #ifdef XVID_CSP_EXTERN |
6756 | 216 case XVID_CSP_EXTERN: |
217 pic.y = mpi->planes[0]; | |
218 pic.u = mpi->planes[1]; | |
219 pic.v = mpi->planes[2]; | |
220 pic.stride_y = mpi->stride[0]; | |
221 pic.stride_u = mpi->stride[1]; | |
222 pic.stride_v = mpi->stride[2]; | |
223 dec.image = &pic; | |
224 break; | |
6767 | 225 #endif |
6701
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
226 default: |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
227 dec.image = mpi->planes[0]; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
228 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
|
229 dec.stride = mpi->width; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
230 else |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
231 dec.stride = mpi->stride[0]; |
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 dec.colorspace = p->cs; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
234 |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
235 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
|
236 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
|
237 return NULL; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
238 } |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
239 |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
240 if(p->cs == XVID_CSP_USER) { |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
241 mpi->planes[0] = d4_pic.y; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
242 mpi->planes[1] = d4_pic.u; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
243 mpi->planes[2] = d4_pic.v; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
244 mpi->stride[0] = d4_pic.stride_y; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
245 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
|
246 } |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
247 |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
248 return mpi; |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
diff
changeset
|
249 } |
9803
4563dfa92a5b
xvid fixes and more options by elcabesa & Martin Drab
henry
parents:
9300
diff
changeset
|
250 #endif //have_xvid |