7typedef struct jamdecodestream_s
21 unsigned char frame_palette[768];
27#ifdef JAM_USELIBAVCODECSCALE
28 unsigned char *frame_output_buffer;
29 AVFrame *frame_output;
30 AVFrame *frame_output_scale;
31 unsigned int framewidth;
32 unsigned int frameheight;
46int jam_video(
void *stream,
void *imagedata,
unsigned int Rmask,
unsigned int Gmask,
unsigned int Bmask,
unsigned int bytesperpixel,
int imagebytesperrow);
58 *errorstring =
"unable to allocate memory for stream info structure";
67 *errorstring =
"unable to open videofile";
75 *errorstring =
"JamDecoder: unexpected EOF reading header";
79 if (memcmp(jamHead,
"JAM", 4))
81 *errorstring =
"JamDecoder: not a JAM file";
98 *errorstring =
"JamDecoder: bad framesize";
107 *errorstring =
"JamDecoder: unable to allocate memory for video decoder";
113#ifdef JAM_USELIBAVCODECSCALE
118 if (cl_video_libavcodec_minwidth.integer > 0)
120 if (cl_video_libavcodec_minheight.integer > 0)
125 s->frame_output = AvCodec_AllocFrame();
126 s->frame_output_scale = AvCodec_AllocFrame();
127 if (!s->frame_output_buffer || !s->frame_output || !s->frame_output_scale)
129 *errorstring =
"JamDecoder: failed to allocate LibAvcodec frame";
148 namelen =
strlen(filename) + 10;
149 wavename = (
char *)
Z_Malloc(namelen);
187#ifdef JAM_USELIBAVCODECSCALE
188 if (s->frame_output_buffer)
189 Z_Free(s->frame_output_buffer);
190 s->frame_output_buffer =
NULL;
192 AvUtil_Free(s->frame_output);
193 s->frame_output =
NULL;
194 if (s->frame_output_scale)
195 AvUtil_Free(s->frame_output_scale);
196 s->frame_output_scale =
NULL;
230static void jam_decodeframe(
unsigned char *inbuf,
unsigned char *outbuf,
unsigned char *prevbuf,
int outsize,
int frametype)
232 unsigned char *srcptr, *destptr, *prevptr;
235 unsigned short int bits;
248 memcpy(outbuf, inbuf, outsize);
253 memcpy(&mark, srcptr, 4);
267 bits = srcptr[0] + 256*srcptr[1];
268 rep = (bits >> 11) + 3;
271 backoffs = 0x821 - (bits & 0x7ff);
272 back = destptr - backoffs;
276 backoffs = 0x400 - (bits & 0x7ff);
277 back = prevptr - backoffs;
280 memcpy(destptr, back, rep);
290int jam_video(
void *stream,
void *imagedata,
unsigned int Rmask,
unsigned int Gmask,
unsigned int Bmask,
unsigned int bytesperpixel,
int imagebytesperrow)
292 unsigned char frameHead[16], *
b;
293 unsigned int compsize, outsize,
i;
324 if (frameHead[0] == 2)
329 for(
i = 0;
i < 768;
i++)
342#ifdef JAM_USELIBAVCODECSCALE
344 b = (
unsigned char *)s->frame_output_buffer;
353 AvCodec_FillPicture((AVPicture *)s->frame_output, (uint8_t *)s->frame_output_buffer, PIX_FMT_BGRA, s->framewidth, s->frameheight);
355 SwsContext *scale_context = SwScale_GetCachedContext(
NULL, s->framewidth, s->frameheight, PIX_FMT_BGRA, s->
info_imagewidth, s->
info_imageheight, PIX_FMT_BGRA, libavcodec_scalers[
max(0,
min(LIBAVCODEC_SCALERS, cl_video_libavcodec_scaler.integer))],
NULL,
NULL,
NULL);
358 Con_Printf(
"JamDecoder: LibAvcodec: error creating scale context frame %i\n", s->
framenum);
361 if (!SwScale_Scale(scale_context, s->frame_output->data, s->frame_output->linesize, 0, s->frameheight, s->frame_output_scale->data, s->frame_output_scale->linesize))
363 SwScale_FreeContext(scale_context);
366 b = (
unsigned char *)imagedata;
double jam_getframerate(void *stream)
unsigned int jam_getheight(void *stream)
void * jam_open(clvideo_t *video, char *filename, const char **errorstring)
void jam_close(void *stream)
double jam_getaspectratio(void *stream)
static void jam_decodeframe(unsigned char *inbuf, unsigned char *outbuf, unsigned char *prevbuf, int outsize, int frametype)
unsigned int jam_getwidth(void *stream)
int jam_video(void *stream, void *imagedata, unsigned int Rmask, unsigned int Gmask, unsigned int Bmask, unsigned int bytesperpixel, int imagebytesperrow)
#define dp_strlcat(dst, src, dsize)
void Con_Printf(const char *fmt,...)
Prints to all appropriate console targets.
fs_offset_t FS_Read(qfile_t *file, void *buffer, size_t buffersize)
qfile_t * FS_OpenVirtualFile(const char *filepath, qbool quiet)
void FS_StripExtension(const char *in, char *out, size_t size_out)
int FS_Close(qfile_t *file)
#define bound(min, num, max)
int S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation)
S_StartSound returns the channel index, or -1 if an error occurred.
void S_StopChannel(unsigned int channel_ind, qbool lockmutex, qbool freesfx)
sfx_t * S_PrecacheSound(const char *name, qbool complain, qbool levelsound)
void(* close)(void *stream)
double(* getframerate)(void *stream)
unsigned int(* getheight)(void *stream)
int(* decodeframe)(void *stream, void *imagedata, unsigned int Rmask, unsigned int Gmask, unsigned int Bmask, unsigned int bytesperpixel, int imagebytesperrow)
double(* getaspectratio)(void *stream)
unsigned int(* getwidth)(void *stream)
unsigned char * frame_compressed
unsigned char * frame_prev
unsigned int info_imageheight
unsigned char frame_palette[768]
unsigned int info_imagewidth