Mercurial > mplayer.hg
annotate libmpcodecs/vd_cyuv.c @ 11676:bc22491f91bf
Remove 8BPS, MsRLE, MsVideo1, RPZA, SMC
These codecs are now in libavcodec
author | rtognimp |
---|---|
date | Tue, 23 Dec 2003 21:24:14 +0000 |
parents | 84f406c22df1 |
children |
rev | line source |
---|---|
7519
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
1 /* ------------------------------------------------------------------------ |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
2 * Creative YUV Video Decoder |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
3 * |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
4 * Dr. Tim Ferguson, 2001. |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
5 * For more details on the algorithm: |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
6 * http://www.csse.monash.edu.au/~timf/videocodec.html |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
7 * |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
8 * Code restructured, and adopted to MPlayer's mpi by A'rpi, 2002. |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
9 * |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
10 * This is a very simple predictive coder. A video frame is coded in YUV411 |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
11 * format. The first pixel of each scanline is coded using the upper four |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
12 * bits of its absolute value. Subsequent pixels for the scanline are coded |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
13 * using the difference between the last pixel and the current pixel (DPCM). |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
14 * The DPCM values are coded using a 16 entry table found at the start of the |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
15 * frame. Thus four bits per component are used and are as follows: |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
16 * UY VY YY UY VY YY UY VY... |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
17 * ------------------------------------------------------------------------ */ |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
18 |
4989 | 19 #include <stdio.h> |
20 #include <stdlib.h> | |
21 | |
22 #include "config.h" | |
23 #include "mp_msg.h" | |
24 | |
25 #include "vd_internal.h" | |
26 | |
27 static vd_info_t info = { | |
28 "Creative YUV decoder", | |
29 "cyuv", | |
30 "A'rpi", | |
31 "Dr. Tim Ferguson", | |
32 "native codec" | |
33 }; | |
34 | |
35 LIBVD_EXTERN(cyuv) | |
36 | |
37 // to set/get/query special features/parameters | |
38 static int control(sh_video_t *sh,int cmd,void* arg,...){ | |
39 return CONTROL_UNKNOWN; | |
40 } | |
41 | |
42 // init driver | |
43 static int init(sh_video_t *sh){ | |
7519
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
44 return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_411P); |
4989 | 45 } |
46 | |
47 // uninit driver | |
48 static void uninit(sh_video_t *sh){ | |
49 } | |
50 | |
51 // decode a frame | |
52 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ | |
53 mp_image_t* mpi; | |
7519
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
54 unsigned int xpos, ypos; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
55 unsigned char *delta_y_tbl = ((unsigned char*)data)+16; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
56 unsigned char *delta_c_tbl = ((unsigned char*)data)+32; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
57 unsigned char *ptr = ((unsigned char*)data)+48; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
58 |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
59 if(len<=48) return NULL; // skipped/broken frame |
4989 | 60 |
7519
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
61 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, |
4989 | 62 sh->disp_w, sh->disp_h); |
63 if(!mpi) return NULL; | |
64 | |
7519
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
65 for(ypos = 0; ypos < mpi->h; ypos++){ |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
66 unsigned int i; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
67 unsigned char cur_Y1,cur_Y2,cur_U,cur_V; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
68 unsigned char *frame=mpi->planes[0]+mpi->stride[0]*ypos; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
69 unsigned char *uframe=mpi->planes[1]+mpi->stride[1]*ypos; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
70 unsigned char *vframe=mpi->planes[2]+mpi->stride[2]*ypos; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
71 |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
72 for(xpos = 0; xpos < mpi->w; xpos += 2){ |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
73 |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
74 if(xpos&2){ |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
75 i = *(ptr++); |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
76 cur_Y1 = (cur_Y2 + delta_y_tbl[i & 0x0f])/* & 0xff*/; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
77 cur_Y2 = (cur_Y1 + delta_y_tbl[i >> 4])/* & 0xff*/; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
78 } else { |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
79 if(xpos == 0) { /* first pixels in scanline */ |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
80 cur_U = *(ptr++); |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
81 cur_Y1= (cur_U & 0x0f) << 4; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
82 cur_U = cur_U & 0xf0; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
83 cur_V = *(ptr++); |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
84 cur_Y2= (cur_Y1 + delta_y_tbl[cur_V & 0x0f])/* & 0xff*/; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
85 cur_V = cur_V & 0xf0; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
86 } else { /* subsequent pixels in scanline */ |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
87 i = *(ptr++); |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
88 cur_U = (cur_U + delta_c_tbl[i >> 4])/* & 0xff*/; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
89 cur_Y1= (cur_Y2 + delta_y_tbl[i & 0x0f])/* & 0xff*/; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
90 i = *(ptr++); |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
91 cur_V = (cur_V + delta_c_tbl[i >> 4])/* & 0xff*/; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
92 cur_Y2= (cur_Y1 + delta_y_tbl[i & 0x0f])/* & 0xff*/; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
93 } |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
94 } |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
95 |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
96 // ok, store the pixels: |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
97 switch(mpi->imgfmt){ |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
98 case IMGFMT_YUY2: |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
99 *frame++ = cur_Y1; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
100 *frame++ = cur_U; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
101 *frame++ = cur_Y2; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
102 *frame++ = cur_V; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
103 break; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
104 case IMGFMT_UYVY: |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
105 *frame++ = cur_U; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
106 *frame++ = cur_Y1; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
107 *frame++ = cur_V; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
108 *frame++ = cur_Y2; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
109 break; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
110 case IMGFMT_422P: |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
111 *uframe++ = cur_U; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
112 *vframe++ = cur_V; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
113 *frame++ = cur_Y1; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
114 *frame++ = cur_Y2; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
115 break; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
116 case IMGFMT_411P: |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
117 if(!(xpos&2)){ |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
118 *uframe++ = cur_U; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
119 *vframe++ = cur_V; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
120 } |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
121 *frame++ = cur_Y1; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
122 *frame++ = cur_Y2; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
123 break; |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
124 } |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
125 } // xpos |
84f406c22df1
decoder merged, using mpi now. support for stride, and outfmt 411p,422p
arpi
parents:
7180
diff
changeset
|
126 } // ypos |
4989 | 127 |
128 return mpi; | |
129 } |