annotate libmpcodecs/vd_dmo.c @ 25254:f1da4024c3ab

10l, len may change after initialization time
author rfelker
date Mon, 03 Dec 2007 09:57:21 +0000
parents 1ba0aff3ed0a
children 0f1b5b68af32
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
1 #include <stdio.h>
cd02bf201f38 DMO support
arpi
parents:
diff changeset
2 #include <stdlib.h>
cd02bf201f38 DMO support
arpi
parents:
diff changeset
3 #include <stdarg.h>
cd02bf201f38 DMO support
arpi
parents:
diff changeset
4
cd02bf201f38 DMO support
arpi
parents:
diff changeset
5 #include "config.h"
cd02bf201f38 DMO support
arpi
parents:
diff changeset
6
cd02bf201f38 DMO support
arpi
parents:
diff changeset
7 #include "mp_msg.h"
cd02bf201f38 DMO support
arpi
parents:
diff changeset
8 #include "help_mp.h"
cd02bf201f38 DMO support
arpi
parents:
diff changeset
9
cd02bf201f38 DMO support
arpi
parents:
diff changeset
10 #include "vd_internal.h"
cd02bf201f38 DMO support
arpi
parents:
diff changeset
11
cd02bf201f38 DMO support
arpi
parents:
diff changeset
12 #include "loader/dmo/DMO_VideoDecoder.h"
cd02bf201f38 DMO support
arpi
parents:
diff changeset
13
cd02bf201f38 DMO support
arpi
parents:
diff changeset
14 static vd_info_t info = {
cd02bf201f38 DMO support
arpi
parents:
diff changeset
15 "DMO video codecs",
cd02bf201f38 DMO support
arpi
parents:
diff changeset
16 "dmo",
cd02bf201f38 DMO support
arpi
parents:
diff changeset
17 "A'rpi",
cd02bf201f38 DMO support
arpi
parents:
diff changeset
18 "based on http://avifile.sf.net",
cd02bf201f38 DMO support
arpi
parents:
diff changeset
19 "win32 codecs"
cd02bf201f38 DMO support
arpi
parents:
diff changeset
20 };
cd02bf201f38 DMO support
arpi
parents:
diff changeset
21
cd02bf201f38 DMO support
arpi
parents:
diff changeset
22 LIBVD_EXTERN(dmo)
cd02bf201f38 DMO support
arpi
parents:
diff changeset
23
cd02bf201f38 DMO support
arpi
parents:
diff changeset
24 // to set/get/query special features/parameters
cd02bf201f38 DMO support
arpi
parents:
diff changeset
25 static int control(sh_video_t *sh,int cmd,void* arg,...){
cd02bf201f38 DMO support
arpi
parents:
diff changeset
26 return CONTROL_UNKNOWN;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
27 }
cd02bf201f38 DMO support
arpi
parents:
diff changeset
28
cd02bf201f38 DMO support
arpi
parents:
diff changeset
29 // init driver
cd02bf201f38 DMO support
arpi
parents:
diff changeset
30 static int init(sh_video_t *sh){
cd02bf201f38 DMO support
arpi
parents:
diff changeset
31 unsigned int out_fmt;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
32 if(!(sh->context=DMO_VideoDecoder_Open(sh->codec->dll,&sh->codec->guid, sh->bih, 0, 0))){
cd02bf201f38 DMO support
arpi
parents:
diff changeset
33 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingDLLcodec,sh->codec->dll);
12763
f34a7cf4265a Console message corrected and moved to help_mp-en.h.
diego
parents: 8504
diff changeset
34 mp_msg(MSGT_DECVIDEO,MSGL_HINT,MSGTR_DownloadCodecPackage);
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
35 return 0;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
36 }
cd02bf201f38 DMO support
arpi
parents:
diff changeset
37 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
38 out_fmt=sh->codec->outfmt[sh->outfmtidx];
cd02bf201f38 DMO support
arpi
parents:
diff changeset
39 switch(out_fmt){
cd02bf201f38 DMO support
arpi
parents:
diff changeset
40 case IMGFMT_YUY2:
cd02bf201f38 DMO support
arpi
parents:
diff changeset
41 case IMGFMT_UYVY:
cd02bf201f38 DMO support
arpi
parents:
diff changeset
42 DMO_VideoDecoder_SetDestFmt(sh->context,16,out_fmt);break; // packed YUV
cd02bf201f38 DMO support
arpi
parents:
diff changeset
43 case IMGFMT_YV12:
cd02bf201f38 DMO support
arpi
parents:
diff changeset
44 case IMGFMT_I420:
cd02bf201f38 DMO support
arpi
parents:
diff changeset
45 case IMGFMT_IYUV:
cd02bf201f38 DMO support
arpi
parents:
diff changeset
46 DMO_VideoDecoder_SetDestFmt(sh->context,12,out_fmt);break; // planar YUV
cd02bf201f38 DMO support
arpi
parents:
diff changeset
47 case IMGFMT_YVU9:
cd02bf201f38 DMO support
arpi
parents:
diff changeset
48 DMO_VideoDecoder_SetDestFmt(sh->context,9,out_fmt);break;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
49 default:
cd02bf201f38 DMO support
arpi
parents:
diff changeset
50 DMO_VideoDecoder_SetDestFmt(sh->context,out_fmt&255,0); // RGB/BGR
cd02bf201f38 DMO support
arpi
parents:
diff changeset
51 }
cd02bf201f38 DMO support
arpi
parents:
diff changeset
52 DMO_VideoDecoder_StartInternal(sh->context);
12763
f34a7cf4265a Console message corrected and moved to help_mp-en.h.
diego
parents: 8504
diff changeset
53 mp_msg(MSGT_DECVIDEO,MSGL_V,MSGTR_DMOInitOK);
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
54 return 1;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
55 }
cd02bf201f38 DMO support
arpi
parents:
diff changeset
56
cd02bf201f38 DMO support
arpi
parents:
diff changeset
57 // uninit driver
cd02bf201f38 DMO support
arpi
parents:
diff changeset
58 static void uninit(sh_video_t *sh){
cd02bf201f38 DMO support
arpi
parents:
diff changeset
59 DMO_VideoDecoder_Destroy(sh->context);
cd02bf201f38 DMO support
arpi
parents:
diff changeset
60 }
cd02bf201f38 DMO support
arpi
parents:
diff changeset
61
cd02bf201f38 DMO support
arpi
parents:
diff changeset
62 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
cd02bf201f38 DMO support
arpi
parents:
diff changeset
63
cd02bf201f38 DMO support
arpi
parents:
diff changeset
64 // decode a frame
cd02bf201f38 DMO support
arpi
parents:
diff changeset
65 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
cd02bf201f38 DMO support
arpi
parents:
diff changeset
66 mp_image_t* mpi;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
67 if(len<=0) return NULL; // skipped frame
cd02bf201f38 DMO support
arpi
parents:
diff changeset
68
cd02bf201f38 DMO support
arpi
parents:
diff changeset
69 if(flags&3){
cd02bf201f38 DMO support
arpi
parents:
diff changeset
70 // framedrop:
cd02bf201f38 DMO support
arpi
parents:
diff changeset
71 DMO_VideoDecoder_DecodeInternal(sh->context, data, len, 0, 0);
cd02bf201f38 DMO support
arpi
parents:
diff changeset
72 return NULL;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
73 }
cd02bf201f38 DMO support
arpi
parents:
diff changeset
74
cd02bf201f38 DMO support
arpi
parents:
diff changeset
75 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, 0 /*MP_IMGFLAG_ACCEPT_STRIDE*/,
cd02bf201f38 DMO support
arpi
parents:
diff changeset
76 sh->disp_w, sh->disp_h);
cd02bf201f38 DMO support
arpi
parents:
diff changeset
77
cd02bf201f38 DMO support
arpi
parents:
diff changeset
78 if(!mpi){ // temporary!
18004
bcd805923554 Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents: 12763
diff changeset
79 mp_msg(MSGT_DECVIDEO,MSGL_WARN,MSGTR_MPCODECS_CouldntAllocateImageForCinepakCodec);
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
80 return NULL;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
81 }
cd02bf201f38 DMO support
arpi
parents:
diff changeset
82
cd02bf201f38 DMO support
arpi
parents:
diff changeset
83 DMO_VideoDecoder_DecodeInternal(sh->context, data, len, 1, mpi->planes[0]);
cd02bf201f38 DMO support
arpi
parents:
diff changeset
84
cd02bf201f38 DMO support
arpi
parents:
diff changeset
85 return mpi;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
86 }