Mercurial > mplayer.hg
comparison libmpcodecs/vd_realvid.c @ 21559:de2a96f41195
Fix realvideo size changes by using our own malloced buffer and export type mpi.
author | reimar |
---|---|
date | Sun, 10 Dec 2006 16:52:58 +0000 |
parents | abfc5854e80a |
children | c08b8066a1c6 |
comparison
equal
deleted
inserted
replaced
21558:7412d71880d5 | 21559:de2a96f41195 |
---|---|
57 static unsigned long WINAPI (*wrvyuv_transform)(char*, char*,transform_in_t*,unsigned int*,void*); | 57 static unsigned long WINAPI (*wrvyuv_transform)(char*, char*,transform_in_t*,unsigned int*,void*); |
58 #endif | 58 #endif |
59 | 59 |
60 static void *rv_handle=NULL; | 60 static void *rv_handle=NULL; |
61 static int inited=0; | 61 static int inited=0; |
62 static uint8_t *buffer = NULL; | |
62 #ifdef USE_WIN32DLL | 63 #ifdef USE_WIN32DLL |
63 static int dll_type = 0; /* 0 = unix dlopen, 1 = win32 dll */ | 64 static int dll_type = 0; /* 0 = unix dlopen, 1 = win32 dll */ |
64 #endif | 65 #endif |
65 | 66 |
66 void *__builtin_vec_new(unsigned long size) { | 67 void *__builtin_vec_new(unsigned long size) { |
294 #ifdef HAVE_LIBDL | 295 #ifdef HAVE_LIBDL |
295 if(rv_handle) dlclose(rv_handle); | 296 if(rv_handle) dlclose(rv_handle); |
296 #endif | 297 #endif |
297 rv_handle=NULL; | 298 rv_handle=NULL; |
298 inited = 0; | 299 inited = 0; |
300 if (buffer) | |
301 free(buffer); | |
302 buffer = NULL; | |
299 } | 303 } |
300 | 304 |
301 // copypaste from demux_real.c - it should match to get it working! | 305 // copypaste from demux_real.c - it should match to get it working! |
302 typedef struct dp_hdr_s { | 306 typedef struct dp_hdr_s { |
303 uint32_t chunks; // number of chunks | 307 uint32_t chunks; // number of chunks |
311 mp_image_t* mpi; | 315 mp_image_t* mpi; |
312 unsigned long result; | 316 unsigned long result; |
313 dp_hdr_t* dp_hdr=(dp_hdr_t*)data; | 317 dp_hdr_t* dp_hdr=(dp_hdr_t*)data; |
314 unsigned char* dp_data=((unsigned char*)data)+sizeof(dp_hdr_t); | 318 unsigned char* dp_data=((unsigned char*)data)+sizeof(dp_hdr_t); |
315 uint32_t* extra=(uint32_t*)(((char*)data)+dp_hdr->chunktab); | 319 uint32_t* extra=(uint32_t*)(((char*)data)+dp_hdr->chunktab); |
316 unsigned char* buffer; | |
317 | 320 |
318 unsigned int transform_out[5]; | 321 unsigned int transform_out[5]; |
319 transform_in_t transform_in={ | 322 transform_in_t transform_in={ |
320 dp_hdr->len, // length of the packet (sub-packets appended) | 323 dp_hdr->len, // length of the packet (sub-packets appended) |
321 0, // unknown, seems to be unused | 324 0, // unknown, seems to be unused |
325 dp_hdr->timestamp,// timestamp (the integer value from the stream) | 328 dp_hdr->timestamp,// timestamp (the integer value from the stream) |
326 }; | 329 }; |
327 | 330 |
328 if(len<=0 || flags&2) return NULL; // skipped frame || hardframedrop | 331 if(len<=0 || flags&2) return NULL; // skipped frame || hardframedrop |
329 | 332 |
330 if(inited){ // rv30 width/height not yet known | 333 if (!inited) { |
331 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, 0 /*MP_IMGFLAG_ACCEPT_STRIDE*/, | 334 if (buffer) free(buffer); |
332 sh->disp_w, sh->disp_h); | |
333 if(!mpi) return NULL; | |
334 buffer=mpi->planes[0]; | |
335 } else { | |
336 buffer=malloc(sh->disp_w*sh->disp_h*3/2); | 335 buffer=malloc(sh->disp_w*sh->disp_h*3/2); |
337 if (!buffer) return 0; | 336 if (!buffer) return 0; |
338 } | 337 } |
339 | 338 |
340 #ifdef USE_WIN32DLL | 339 #ifdef USE_WIN32DLL |
349 if(!inited){ // rv30 width/height now known | 348 if(!inited){ // rv30 width/height now known |
350 sh->aspect=(float)sh->disp_w/(float)sh->disp_h; | 349 sh->aspect=(float)sh->disp_w/(float)sh->disp_h; |
351 sh->disp_w=transform_out[3]; | 350 sh->disp_w=transform_out[3]; |
352 sh->disp_h=transform_out[4]; | 351 sh->disp_h=transform_out[4]; |
353 if (!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_I420)) return 0; | 352 if (!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_I420)) return 0; |
354 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, 0 /*MP_IMGFLAG_ACCEPT_STRIDE*/, | 353 inited=1; |
354 } | |
355 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0 /*MP_IMGFLAG_ACCEPT_STRIDE*/, | |
355 sh->disp_w, sh->disp_h); | 356 sh->disp_w, sh->disp_h); |
356 if(!mpi) return NULL; | 357 if(!mpi) return NULL; |
357 memcpy(mpi->planes[0],buffer,sh->disp_w*sh->disp_h*3/2); | 358 mpi->planes[0] = buffer; |
358 free(buffer); | 359 mpi->stride[0] = sh->disp_w; |
359 inited=1; | 360 mpi->planes[1] = buffer + sh->disp_w*sh->disp_h; |
360 } | 361 mpi->stride[1] = sh->disp_w / 2; |
361 | 362 mpi->planes[2] = buffer + sh->disp_w*sh->disp_h*5/4; |
363 mpi->stride[2] = sh->disp_w / 2; | |
364 | |
365 if(transform_out[0] && | |
366 (sh->disp_w != transform_out[3] || sh->disp_h != transform_out[4])) | |
367 inited = 0; | |
368 | |
362 return (result?NULL:mpi); | 369 return (result?NULL:mpi); |
363 } | 370 } |