comparison libmpcodecs/vd_zlib.c @ 5277:7df9fc3308ac

10l. IMGFLAG_ALLOCATED shouldn't be set from vd driver\! - it's for internal use by the core
author arpi
date Sat, 23 Mar 2002 16:56:05 +0000
parents 8037d34ce806
children a11cd73811a8
comparison
equal deleted inserted replaced
5276:8037d34ce806 5277:7df9fc3308ac
24 typedef struct { 24 typedef struct {
25 int width; 25 int width;
26 int height; 26 int height;
27 int depth; 27 int depth;
28 z_stream zstrm; 28 z_stream zstrm;
29 mp_image_t *mpi;
30 } vd_zlib_ctx; 29 } vd_zlib_ctx;
31 30
32 // to set/get/query special features/parameters 31 // to set/get/query special features/parameters
33 static int control(sh_video_t *sh, int cmd, void *arg, ...) 32 static int control(sh_video_t *sh, int cmd, void *arg, ...)
34 { 33 {
90 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h); 89 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
91 90
92 // decode a frame 91 // decode a frame
93 static mp_image_t* decode(sh_video_t *sh, void* data, int len, int flags) 92 static mp_image_t* decode(sh_video_t *sh, void* data, int len, int flags)
94 { 93 {
94 mp_image_t *mpi;
95 vd_zlib_ctx *ctx = sh->context; 95 vd_zlib_ctx *ctx = sh->context;
96 int zret; 96 int zret;
97 int decomp_size = ctx->width*ctx->height*((ctx->depth+7)/8); 97 int decomp_size = ctx->width*ctx->height*((ctx->depth+7)/8);
98 z_stream *zstrm = &ctx->zstrm; 98 z_stream *zstrm = &ctx->zstrm;
99 99
100 if (len <= 0) 100 if (len <= 0)
101 return(NULL); // skipped frame 101 return(NULL); // skipped frame
102 102
103 ctx->mpi = mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ALLOCATED, 103 mpi = mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, 0, ctx->width, ctx->height);
104 ctx->width, ctx->height); 104 if (!mpi) return(NULL);
105 if (!ctx->mpi)
106 return(NULL);
107 105
108 zstrm->next_in = data; 106 zstrm->next_in = data;
109 zstrm->avail_in = len; 107 zstrm->avail_in = len;
110 zstrm->next_out = ctx->mpi->planes[0]; 108 zstrm->next_out = mpi->planes[0];
111 zstrm->avail_out = decomp_size; 109 zstrm->avail_out = decomp_size;
112 110
113 mp_dbg(MSGT_DECVIDEO, MSGL_DBG2, "[vd_zlib] input: %p (%d bytes), output: %p (%d bytes)\n", 111 mp_dbg(MSGT_DECVIDEO, MSGL_DBG2, "[vd_zlib] input: %p (%d bytes), output: %p (%d bytes)\n",
114 zstrm->next_in, zstrm->avail_in, zstrm->next_out, zstrm->avail_out); 112 zstrm->next_in, zstrm->avail_in, zstrm->next_out, zstrm->avail_out);
115 113
126 mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[vd_zlib] decoded size differs (%d != %d)\n", 124 mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[vd_zlib] decoded size differs (%d != %d)\n",
127 decomp_size, zstrm->total_out); 125 decomp_size, zstrm->total_out);
128 return(NULL); 126 return(NULL);
129 } 127 }
130 128
131 return(ctx->mpi); 129 return mpi;
132 } 130 }
133 #endif 131 #endif