summaryrefslogtreecommitdiffstats
path: root/libmpcodecs/vd_realvid.c
diff options
context:
space:
mode:
authorrtogni <rtogni@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-11-14 22:40:35 +0000
committerrtogni <rtogni@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-11-14 22:40:35 +0000
commit88990e297ce30f151bc76b8d06981c5cd17aee97 (patch)
treed55dad0b28e9dd1e4dac3ae981fe7a976b782464 /libmpcodecs/vd_realvid.c
parent4254e10d2a8f1388010dd727e651948823dac634 (diff)
downloadmpv-88990e297ce30f151bc76b8d06981c5cd17aee97.tar.bz2
mpv-88990e297ce30f151bc76b8d06981c5cd17aee97.tar.xz
Fix extradata passing to lavc RV20 decoder
Pass video codec extradata unchanged from demux_real, sync vd_realvid to the new format Sync mkv demuxer to the changes above (cmsg24 extradata was totally broken before) Detect cmsg24 size from extradata (was fixed) Based on a patch by elupus >> elupus >a< ecce se << git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@20936 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpcodecs/vd_realvid.c')
-rw-r--r--libmpcodecs/vd_realvid.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/libmpcodecs/vd_realvid.c b/libmpcodecs/vd_realvid.c
index 37e68bc4f8..2ef9733c8f 100644
--- a/libmpcodecs/vd_realvid.c
+++ b/libmpcodecs/vd_realvid.c
@@ -210,12 +210,17 @@ static int init(sh_video_t *sh){
char *path;
int result;
// we export codec id and sub-id from demuxer in bitmapinfohdr:
- unsigned int* extrahdr=(unsigned int*)(sh->bih+1);
- struct rv_init_t init_data={
- 11, sh->disp_w, sh->disp_h,0,0,extrahdr[0],
- 1,extrahdr[1]}; // rv30
+ unsigned char* extrahdr=(unsigned char*)(sh->bih+1);
+ unsigned int extrahdr_size = sh->bih->biSize - sizeof(BITMAPINFOHEADER);
+ struct rv_init_t init_data;
- mp_msg(MSGT_DECVIDEO,MSGL_V,"realvideo codec id: 0x%08X sub-id: 0x%08X\n",extrahdr[1],extrahdr[0]);
+ if(extrahdr_size < 8) {
+ mp_msg(MSGT_DECVIDEO,MSGL_ERR,"realvideo: extradata too small (%u)\n", sh->bih->biSize - sizeof(BITMAPINFOHEADER));
+ return 0;
+ }
+ init_data = (struct rv_init_t){11, sh->disp_w, sh->disp_h, 0, 0, be2me_32(((unsigned int*)extrahdr)[0]), 1, be2me_32(((unsigned int*)extrahdr)[1])}; // rv30
+
+ mp_msg(MSGT_DECVIDEO,MSGL_V,"realvideo codec id: 0x%08X sub-id: 0x%08X\n",be2me_32(((unsigned int*)extrahdr)[1]),be2me_32(((unsigned int*)extrahdr)[0]));
path = malloc(strlen(REALCODEC_PATH)+strlen(sh->codec->dll)+2);
if (!path) return 0;
@@ -251,13 +256,21 @@ static int init(sh_video_t *sh){
return 0;
}
// setup rv30 codec (codec sub-type and image dimensions):
- if((sh->format<=0x30335652) && (extrahdr[1]>=0x20200002)){
- // We could read nonsense data while filling this, but input is big enough so no sig11
- uint32_t cmsg24[10]={sh->disp_w,sh->disp_h,((unsigned char *)extrahdr)[8]*4,((unsigned char *)extrahdr)[9]*4,
- ((unsigned char *)extrahdr)[10]*4,((unsigned char *)extrahdr)[11]*4,
- ((unsigned char *)extrahdr)[12]*4,((unsigned char *)extrahdr)[13]*4,
- ((unsigned char *)extrahdr)[14]*4,((unsigned char *)extrahdr)[15]*4};
- cmsg_data_t cmsg_data={0x24,1+((extrahdr[0]>>16)&7), &cmsg24[0]};
+ if((sh->format<=0x30335652) && (be2me_32(((unsigned int*)extrahdr)[1])>=0x20200002)){
+ int i, cmsg_cnt;
+ uint32_t cmsg24[16]={sh->disp_w,sh->disp_h};
+ cmsg_data_t cmsg_data={0x24,1+(extrahdr[1]&7), &cmsg24[0]};
+
+ mp_msg(MSGT_DECVIDEO,MSGL_V,"realvideo: using cmsg24 with %u elements.\n",extrahdr[1]&7);
+ cmsg_cnt = (extrahdr[1]&7)*2;
+ if (extrahdr_size-8 < cmsg_cnt) {
+ mp_msg(MSGT_DECVIDEO,MSGL_WARN,"realvideo: not enough extradata (%u) to make %u cmsg24 elements.\n",extrahdr_size-8,extrahdr[1]&7);
+ cmsg_cnt = extrahdr_size-8;
+ }
+ for (i = 0; i < cmsg_cnt; i++)
+ cmsg24[2+i] = extrahdr[8+i]*4;
+ if (extrahdr_size-8 > cmsg_cnt)
+ mp_msg(MSGT_DECVIDEO,MSGL_WARN,"realvideo: %u bytes of unknown extradata remaining.\n",extrahdr_size-8-cmsg_cnt);
#ifdef USE_WIN32DLL
if (dll_type == 1)