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