annotate libmpcodecs/vd_qtrle.c @ 9987:988c2ffc5bc1

remove remaining cpudetect dependancy
author michael
date Fri, 25 Apr 2003 17:16:55 +0000
parents 306ea9a02ebe
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4989
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
1 #include <stdio.h>
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
2 #include <stdlib.h>
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
3
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
4 #include "config.h"
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
5 #include "mp_msg.h"
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
6
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
7 #include "vd_internal.h"
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
8
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
9 static vd_info_t info = {
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
10 "Quicktime Animation (RLE) decoder",
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
11 "qtrle",
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
12 "A'rpi",
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
13 "Mike Melanson",
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
14 "native codec"
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
15 };
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
16
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
17 LIBVD_EXTERN(qtrle)
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
18
6720
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
19 typedef struct {
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
20 int depth;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
21 void *palette;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
22 } vd_qtrle_ctx;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
23
4989
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
24 // to set/get/query special features/parameters
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
25 static int control(sh_video_t *sh,int cmd,void* arg,...){
6720
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
26 vd_qtrle_ctx *ctx = sh->context;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
27 switch(cmd)
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
28 {
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
29 case VDCTRL_QUERY_FORMAT:
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
30 {
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
31 int req_format = *((int*)arg);
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
32
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
33 /* qtrle24 supports 32bit output too */
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
34 if ((req_format == (IMGFMT_BGR|ctx->depth)) ||
9114
306ea9a02ebe Quicktime rle 32 bit supported
rtognimp
parents: 7180
diff changeset
35 ((IMGFMT_BGR_DEPTH(req_format) == 32) && (ctx->depth == 24)) ||
306ea9a02ebe Quicktime rle 32 bit supported
rtognimp
parents: 7180
diff changeset
36 ((IMGFMT_BGR_DEPTH(req_format) == 24) && (ctx->depth == 32)))
6720
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
37 return(CONTROL_TRUE);
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
38 else
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
39 return(CONTROL_FALSE);
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
40 }
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
41 }
4989
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
42 return CONTROL_UNKNOWN;
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
43 }
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
44
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
45 // init driver
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
46 static int init(sh_video_t *sh){
6720
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
47 vd_qtrle_ctx *ctx;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
48
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
49 ctx = sh->context = malloc(sizeof(vd_qtrle_ctx));
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
50 if (!ctx)
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
51 return(0);
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
52 memset(ctx, 0, sizeof(vd_qtrle_ctx));
4989
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
53
6720
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
54 if (!sh->bih)
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
55 return(0);
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
56 ctx->depth = sh->bih->biBitCount;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
57
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
58 switch(ctx->depth)
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
59 {
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
60 case 2:
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
61 case 4:
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
62 case 8:
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
63 if (sh->bih->biSize > 40)
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
64 {
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
65 ctx->palette = malloc(sh->bih->biSize-40);
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
66 memcpy(ctx->palette, sh->bih+40, sh->bih->biSize-40);
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
67 }
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
68 break;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
69 case 16:
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
70 ctx->depth--; /* this is the trick ;) */
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
71 break;
9114
306ea9a02ebe Quicktime rle 32 bit supported
rtognimp
parents: 7180
diff changeset
72 case 32:
306ea9a02ebe Quicktime rle 32 bit supported
rtognimp
parents: 7180
diff changeset
73 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"[qtrle] 32 bpp file, alpha channel will be ignored.\n");
6720
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
74 case 24:
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
75 break;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
76 default:
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
77 mp_msg(MSGT_DECVIDEO,MSGL_ERR,
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
78 "*** FYI: This Quicktime file is using %d-bit RLE Animation\n" \
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
79 "encoding, which is not yet supported by MPlayer. But if you upload\n" \
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
80 "this Quicktime file to the MPlayer FTP, the team could look at it.\n",
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
81 ctx->depth);
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
82 return(0);
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
83 }
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
84
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
85 return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_BGR|ctx->depth);
4989
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
86 }
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
87
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
88 // uninit driver
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
89 static void uninit(sh_video_t *sh){
6720
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
90 vd_qtrle_ctx *ctx = sh->context;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
91
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
92 if (ctx->palette)
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
93 free(ctx->palette);
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
94 free(ctx);
4989
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
95 }
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
96
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
97 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
98
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
99 void qt_decode_rle(
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
100 unsigned char *encoded,
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
101 int encoded_size,
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
102 unsigned char *decoded,
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
103 int width,
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
104 int height,
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
105 int encoded_bpp,
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
106 int bytes_per_pixel);
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
107
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
108 // decode a frame
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
109 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
6720
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
110 vd_qtrle_ctx *ctx = sh->context;
4989
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
111 mp_image_t* mpi;
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
112 if(len<=0) return NULL; // skipped frame
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
113
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
114 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_STATIC, MP_IMGFLAG_PRESERVE,
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
115 sh->disp_w, sh->disp_h);
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
116 if(!mpi) return NULL;
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
117
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
118 qt_decode_rle(
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
119 data,len, mpi->planes[0],
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
120 sh->disp_w, sh->disp_h,
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
121 sh->bih->biBitCount,
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
122 mpi->bpp/8);
6720
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
123
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
124 if (ctx->palette)
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 5124
diff changeset
125 mpi->planes[1] = ctx->palette;
4989
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
126
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
127 return mpi;
11d8bf468334 cyuv, nuv, qtrle, qtsmc, roq added
arpi
parents:
diff changeset
128 }