Mercurial > mplayer.hg
comparison libmpcodecs/vd_divx4.c @ 4968:236b06410b03
vfw, vfwex, odivx, divx4 added
author | arpi |
---|---|
date | Thu, 07 Mar 2002 00:44:58 +0000 |
parents | |
children | eb57973314ae |
comparison
equal
deleted
inserted
replaced
4967:f88dfc3de52c | 4968:236b06410b03 |
---|---|
1 #include <stdio.h> | |
2 #include <stdlib.h> | |
3 #include <assert.h> | |
4 | |
5 #include "config.h" | |
6 #include "mp_msg.h" | |
7 #include "help_mp.h" | |
8 | |
9 #ifdef USE_DIVX | |
10 #ifdef NEW_DECORE | |
11 | |
12 #include "codec-cfg.h" | |
13 #include "../libvo/img_format.h" | |
14 | |
15 #include "stream.h" | |
16 #include "demuxer.h" | |
17 #include "stheader.h" | |
18 | |
19 #include "vd.h" | |
20 #include "vd_internal.h" | |
21 | |
22 static vd_info_t info = { | |
23 #ifdef DECORE_DIVX5 | |
24 "DivX5Linux lib (divx4 mode)", | |
25 #else | |
26 "DivX4Linux lib (divx4 mode)", | |
27 #endif | |
28 "divx4", | |
29 VFM_DIVX4, | |
30 "A'rpi", | |
31 "http://www.divx.com", | |
32 "native codecs" | |
33 }; | |
34 | |
35 LIBVD_EXTERN(divx4) | |
36 | |
37 #include <decore.h> | |
38 | |
39 // to set/get/query special features/parameters | |
40 static int control(sh_video_t *sh,int cmd,void* arg,...){ | |
41 switch(cmd){ | |
42 case VDCTRL_QUERY_MAX_PP_LEVEL: | |
43 return 9; // for divx4linux | |
44 case VDCTRL_SET_PP_LEVEL: { | |
45 DEC_SET dec_set; | |
46 int quality=*((int*)arg); | |
47 if(quality<0 || quality>9) quality=9; | |
48 dec_set.postproc_level=quality*10; | |
49 decore(0x123,DEC_OPT_SETPP,&dec_set,NULL); | |
50 return CONTROL_OK; | |
51 } | |
52 | |
53 } | |
54 | |
55 return CONTROL_UNKNOWN; | |
56 } | |
57 | |
58 // init driver | |
59 static int init(sh_video_t *sh){ | |
60 DEC_PARAM dec_param; | |
61 // DEC_SET dec_set; | |
62 int bits=16; | |
63 memset(&dec_param,0,sizeof(dec_param)); | |
64 | |
65 mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2); | |
66 | |
67 switch(sh->codec->outfmt[sh->outfmtidx]){ | |
68 case IMGFMT_YV12: dec_param.output_format=DEC_YV12;bits=12;break; | |
69 case IMGFMT_YUY2: dec_param.output_format=DEC_YUY2;break; | |
70 case IMGFMT_UYVY: dec_param.output_format=DEC_UYVY;break; | |
71 case IMGFMT_I420: dec_param.output_format=DEC_420;bits=12;break; | |
72 case IMGFMT_BGR15: dec_param.output_format=DEC_RGB555_INV;break; | |
73 case IMGFMT_BGR16: dec_param.output_format=DEC_RGB565_INV;break; | |
74 case IMGFMT_BGR24: dec_param.output_format=DEC_RGB24_INV;bits=24;break; | |
75 case IMGFMT_BGR32: dec_param.output_format=DEC_RGB32_INV;bits=32;break; | |
76 default: | |
77 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Unsupported out_fmt: 0x%X\n",sh->codec->outfmt[sh->outfmtidx]); | |
78 return 0; | |
79 } | |
80 dec_param.x_dim = sh->disp_w; | |
81 dec_param.y_dim = sh->disp_h; | |
82 decore(0x123, DEC_OPT_INIT, &dec_param, NULL); | |
83 // dec_set.postproc_level = divx_quality; | |
84 // decore(0x123, DEC_OPT_SETPP, &dec_set, NULL); | |
85 | |
86 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: DivX4Linux video codec init OK!\n"); | |
87 | |
88 return 1; | |
89 } | |
90 | |
91 // uninit driver | |
92 static void uninit(sh_video_t *sh){ | |
93 decore(0x123,DEC_OPT_RELEASE,NULL,NULL); | |
94 } | |
95 | |
96 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h); | |
97 | |
98 // decode a frame | |
99 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ | |
100 mp_image_t* mpi; | |
101 DEC_FRAME dec_frame; | |
102 | |
103 if(len<=0) return NULL; // skipped frame | |
104 | |
105 dec_frame.length = len; | |
106 dec_frame.bitstream = data; | |
107 dec_frame.render_flag = (flags&3)?0:1; | |
108 | |
109 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_PRESERVE | MP_IMGFLAG_ACCEPT_WIDTH, | |
110 sh->disp_w, sh->disp_h); | |
111 if(!mpi) return NULL; | |
112 | |
113 dec_frame.bmp=mpi->planes[0]; | |
114 dec_frame.stride=mpi->width; | |
115 | |
116 #ifdef DECORE_DIVX5 | |
117 decore(0x123, DEC_OPT_FRAME, &dec_frame, NULL); | |
118 #else | |
119 decore(0x123, (sh->format==mmioFOURCC('D','I','V','3'))?DEC_OPT_FRAME_311:DEC_OPT_FRAME, &dec_frame, NULL); | |
120 #endif | |
121 | |
122 return mpi; | |
123 } | |
124 | |
125 #endif | |
126 #endif | |
127 |