comparison libmpcodecs/vd_qtrle.c @ 6720:180e27f21ff2

8 and 16bpp qtrle support
author alex
date Fri, 12 Jul 2002 17:49:04 +0000
parents 3dcbf67c0de0
children 28677d779205
comparison
equal deleted inserted replaced
6719:5291d74a60c9 6720:180e27f21ff2
15 "native codec" 15 "native codec"
16 }; 16 };
17 17
18 LIBVD_EXTERN(qtrle) 18 LIBVD_EXTERN(qtrle)
19 19
20 typedef struct {
21 int depth;
22 void *palette;
23 } vd_qtrle_ctx;
24
20 // to set/get/query special features/parameters 25 // to set/get/query special features/parameters
21 static int control(sh_video_t *sh,int cmd,void* arg,...){ 26 static int control(sh_video_t *sh,int cmd,void* arg,...){
27 vd_qtrle_ctx *ctx = sh->context;
28 switch(cmd)
29 {
30 case VDCTRL_QUERY_FORMAT:
31 {
32 int req_format = *((int*)arg);
33
34 /* qtrle24 supports 32bit output too */
35 if ((req_format == (IMGFMT_BGR|ctx->depth)) ||
36 ((IMGFMT_BGR_DEPTH(req_format) == 32) && (ctx->depth == 24)))
37 return(CONTROL_TRUE);
38 else
39 return(CONTROL_FALSE);
40 }
41 }
22 return CONTROL_UNKNOWN; 42 return CONTROL_UNKNOWN;
23 } 43 }
24 44
25 // init driver 45 // init driver
26 static int init(sh_video_t *sh){ 46 static int init(sh_video_t *sh){
27 if (sh->bih->biBitCount != 24){ 47 vd_qtrle_ctx *ctx;
28 mp_msg(MSGT_DECVIDEO,MSGL_ERR,
29 " *** FYI: This Quicktime file is using %d-bit RLE Animation\n" \
30 " encoding, which is not yet supported by MPlayer. But if you upload\n" \
31 " this Quicktime file to the MPlayer FTP, the team could look at it.\n",
32 sh->bih->biBitCount);
33 return 0;
34 }
35 48
36 return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_BGR24); 49 ctx = sh->context = malloc(sizeof(vd_qtrle_ctx));
50 if (!ctx)
51 return(0);
52 memset(ctx, 0, sizeof(vd_qtrle_ctx));
53
54 if (!sh->bih)
55 return(0);
56 ctx->depth = sh->bih->biBitCount;
57
58 switch(ctx->depth)
59 {
60 case 2:
61 case 4:
62 case 8:
63 if (sh->bih->biSize > 40)
64 {
65 ctx->palette = malloc(sh->bih->biSize-40);
66 memcpy(ctx->palette, sh->bih+40, sh->bih->biSize-40);
67 }
68 break;
69 case 16:
70 ctx->depth--; /* this is the trick ;) */
71 break;
72 case 24:
73 break;
74 default:
75 mp_msg(MSGT_DECVIDEO,MSGL_ERR,
76 "*** FYI: This Quicktime file is using %d-bit RLE Animation\n" \
77 "encoding, which is not yet supported by MPlayer. But if you upload\n" \
78 "this Quicktime file to the MPlayer FTP, the team could look at it.\n",
79 ctx->depth);
80 return(0);
81 }
82
83 return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_BGR|ctx->depth);
37 } 84 }
38 85
39 // uninit driver 86 // uninit driver
40 static void uninit(sh_video_t *sh){ 87 static void uninit(sh_video_t *sh){
88 vd_qtrle_ctx *ctx = sh->context;
89
90 if (ctx->palette)
91 free(ctx->palette);
92 free(ctx);
41 } 93 }
42 94
43 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h); 95 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
44 96
45 void qt_decode_rle( 97 void qt_decode_rle(
51 int encoded_bpp, 103 int encoded_bpp,
52 int bytes_per_pixel); 104 int bytes_per_pixel);
53 105
54 // decode a frame 106 // decode a frame
55 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ 107 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
108 vd_qtrle_ctx *ctx = sh->context;
56 mp_image_t* mpi; 109 mp_image_t* mpi;
57 if(len<=0) return NULL; // skipped frame 110 if(len<=0) return NULL; // skipped frame
58 111
59 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_STATIC, MP_IMGFLAG_PRESERVE, 112 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_STATIC, MP_IMGFLAG_PRESERVE,
60 sh->disp_w, sh->disp_h); 113 sh->disp_w, sh->disp_h);
63 qt_decode_rle( 116 qt_decode_rle(
64 data,len, mpi->planes[0], 117 data,len, mpi->planes[0],
65 sh->disp_w, sh->disp_h, 118 sh->disp_w, sh->disp_h,
66 sh->bih->biBitCount, 119 sh->bih->biBitCount,
67 mpi->bpp/8); 120 mpi->bpp/8);
121
122 if (ctx->palette)
123 mpi->planes[1] = ctx->palette;
68 124
69 return mpi; 125 return mpi;
70 } 126 }