4968
|
1 #include <stdio.h>
|
|
2 #include <stdlib.h>
|
5003
|
3 #include <stdarg.h>
|
4968
|
4 #include <assert.h>
|
|
5
|
|
6 #include "config.h"
|
|
7 #include "mp_msg.h"
|
|
8 #include "help_mp.h"
|
|
9
|
|
10 #ifdef USE_DIVX
|
|
11 #ifdef NEW_DECORE
|
|
12
|
|
13 #include "vd_internal.h"
|
|
14
|
|
15 static vd_info_t info = {
|
|
16 #ifdef DECORE_DIVX5
|
|
17 "DivX5Linux lib (divx4 mode)",
|
|
18 #else
|
|
19 "DivX4Linux lib (divx4 mode)",
|
|
20 #endif
|
|
21 "divx4",
|
|
22 VFM_DIVX4,
|
|
23 "A'rpi",
|
|
24 "http://www.divx.com",
|
|
25 "native codecs"
|
|
26 };
|
|
27
|
|
28 LIBVD_EXTERN(divx4)
|
|
29
|
|
30 #include <decore.h>
|
|
31
|
|
32 // to set/get/query special features/parameters
|
|
33 static int control(sh_video_t *sh,int cmd,void* arg,...){
|
|
34 switch(cmd){
|
|
35 case VDCTRL_QUERY_MAX_PP_LEVEL:
|
|
36 return 9; // for divx4linux
|
|
37 case VDCTRL_SET_PP_LEVEL: {
|
|
38 DEC_SET dec_set;
|
|
39 int quality=*((int*)arg);
|
|
40 if(quality<0 || quality>9) quality=9;
|
|
41 dec_set.postproc_level=quality*10;
|
|
42 decore(0x123,DEC_OPT_SETPP,&dec_set,NULL);
|
|
43 return CONTROL_OK;
|
|
44 }
|
5003
|
45 #ifdef DECORE_VERSION
|
|
46 #if DECORE_VERSION >= 20011010
|
|
47 case VDCTRL_SET_EQUALIZER: {
|
|
48 va_list ap;
|
|
49 int value;
|
|
50 int option;
|
|
51 va_start(ap, arg);
|
|
52 value=va_arg(ap, int);
|
|
53 va_end(ap);
|
|
54
|
|
55 if(!strcmp(arg,"Brightness")) option=DEC_GAMMA_BRIGHTNESS;
|
|
56 else if(!strcmp(arg, "Contrast")) option=DEC_GAMMA_CONTRAST;
|
|
57 else if(!strcmp(arg,"Saturation")) option=DEC_GAMMA_SATURATION;
|
|
58 else return CONTROL_FALSE;
|
|
59
|
|
60 value = (value * 256) / 100 - 128;
|
|
61 decore(0x123, DEC_OPT_GAMMA, (void *)option, (void *) value);
|
|
62 return CONTROL_OK;
|
|
63 }
|
|
64 #endif
|
|
65 #endif
|
4968
|
66
|
|
67 }
|
|
68
|
|
69 return CONTROL_UNKNOWN;
|
|
70 }
|
|
71
|
|
72 // init driver
|
|
73 static int init(sh_video_t *sh){
|
|
74 DEC_PARAM dec_param;
|
5003
|
75 DEC_SET dec_set;
|
4968
|
76 int bits=16;
|
|
77
|
5168
|
78 #ifndef NEW_DECORE
|
|
79 if(sh->format==mmioFOURCC('D','I','V','3')){
|
|
80 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"DivX 3.x not supported by opendivx decore - it requires divx4linux\n");
|
|
81 return 0; // not supported
|
|
82 }
|
|
83 #endif
|
|
84 #ifndef DECORE_DIVX5
|
|
85 if(sh->format==mmioFOURCC('D','X','5','0')){
|
|
86 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"DivX 5.00 not supported by divx4linux decore - it requires divx5linux\n");
|
|
87 return 0; // not supported
|
|
88 }
|
|
89 #endif
|
|
90
|
5124
|
91 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0;
|
|
92
|
|
93 memset(&dec_param,0,sizeof(dec_param));
|
4968
|
94
|
|
95 switch(sh->codec->outfmt[sh->outfmtidx]){
|
|
96 case IMGFMT_YV12: dec_param.output_format=DEC_YV12;bits=12;break;
|
|
97 case IMGFMT_YUY2: dec_param.output_format=DEC_YUY2;break;
|
|
98 case IMGFMT_UYVY: dec_param.output_format=DEC_UYVY;break;
|
|
99 case IMGFMT_I420: dec_param.output_format=DEC_420;bits=12;break;
|
|
100 case IMGFMT_BGR15: dec_param.output_format=DEC_RGB555_INV;break;
|
|
101 case IMGFMT_BGR16: dec_param.output_format=DEC_RGB565_INV;break;
|
|
102 case IMGFMT_BGR24: dec_param.output_format=DEC_RGB24_INV;bits=24;break;
|
|
103 case IMGFMT_BGR32: dec_param.output_format=DEC_RGB32_INV;bits=32;break;
|
|
104 default:
|
|
105 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Unsupported out_fmt: 0x%X\n",sh->codec->outfmt[sh->outfmtidx]);
|
|
106 return 0;
|
|
107 }
|
4997
|
108 #ifdef DECORE_DIVX5
|
5247
|
109 switch(sh->format) {
|
|
110 case mmioFOURCC('D','I','V','3'):
|
|
111 dec_param.codec_version = 311;
|
|
112 break;
|
|
113 case mmioFOURCC('D','I','V','X'):
|
|
114 dec_param.codec_version = 400;
|
|
115 break;
|
|
116 case mmioFOURCC('D','X','5','0'):
|
|
117 default: // Fallback to DivX 5 behaviour
|
|
118 dec_param.codec_version = 500;
|
|
119 }
|
4997
|
120 dec_param.build_number = 0;
|
|
121 #endif
|
4968
|
122 dec_param.x_dim = sh->disp_w;
|
|
123 dec_param.y_dim = sh->disp_h;
|
|
124 decore(0x123, DEC_OPT_INIT, &dec_param, NULL);
|
5003
|
125
|
|
126 dec_set.postproc_level = divx_quality;
|
|
127 decore(0x123, DEC_OPT_SETPP, &dec_set, NULL);
|
4968
|
128
|
|
129 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: DivX4Linux video codec init OK!\n");
|
|
130
|
|
131 return 1;
|
|
132 }
|
|
133
|
|
134 // uninit driver
|
|
135 static void uninit(sh_video_t *sh){
|
|
136 decore(0x123,DEC_OPT_RELEASE,NULL,NULL);
|
|
137 }
|
|
138
|
|
139 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
|
|
140
|
|
141 // decode a frame
|
|
142 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
|
|
143 mp_image_t* mpi;
|
|
144 DEC_FRAME dec_frame;
|
|
145
|
|
146 if(len<=0) return NULL; // skipped frame
|
|
147
|
|
148 dec_frame.length = len;
|
|
149 dec_frame.bitstream = data;
|
|
150 dec_frame.render_flag = (flags&3)?0:1;
|
|
151
|
|
152 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_PRESERVE | MP_IMGFLAG_ACCEPT_WIDTH,
|
|
153 sh->disp_w, sh->disp_h);
|
|
154 if(!mpi) return NULL;
|
|
155
|
|
156 dec_frame.bmp=mpi->planes[0];
|
|
157 dec_frame.stride=mpi->width;
|
|
158
|
5037
|
159 #ifndef DEC_OPT_FRAME_311
|
4968
|
160 decore(0x123, DEC_OPT_FRAME, &dec_frame, NULL);
|
|
161 #else
|
|
162 decore(0x123, (sh->format==mmioFOURCC('D','I','V','3'))?DEC_OPT_FRAME_311:DEC_OPT_FRAME, &dec_frame, NULL);
|
|
163 #endif
|
|
164
|
|
165 return mpi;
|
|
166 }
|
|
167
|
|
168 #endif
|
|
169 #endif
|
|
170
|