annotate libmpcodecs/vd_divx4.c @ 5476:ac09ea252466

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